Path: blob/master/src/packages/next/pages/api/v2/compute/get-log.ts
1451 views
/*1Get event log for a particular compute server.2*/34import getAccountId from "lib/account/get-account";5import { getEventLog } from "@cocalc/server/compute/event-log";6import getParams from "lib/api/get-params";78import { apiRoute, apiRouteOperation } from "lib/api";9import {10GetComputeServerLogInputSchema,11GetComputeServerLogOutputSchema,12} from "lib/api/schema/compute/get-log";1314async function handle(req, res) {15try {16res.json(await get(req));17} catch (err) {18res.json({ error: `${err.message}` });19return;20}21}2223async function get(req) {24const account_id = await getAccountId(req);25if (!account_id) {26throw Error("must be signed in");27}28const { id } = getParams(req);29return await getEventLog({ id, account_id });30}3132export default apiRoute({33getLog: apiRouteOperation({34method: "POST",35openApiOperation: {36tags: ["Compute"],37},38})39.input({40contentType: "application/json",41body: GetComputeServerLogInputSchema,42})43.outputs([44{45status: 200,46contentType: "application/json",47body: GetComputeServerLogOutputSchema,48},49])50.handler(handle),51});525354