CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
sagemathinc

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

GitHub Repository: sagemathinc/cocalc
Path: blob/master/src/packages/next/pages/api/v2/compute/undelete-server.ts
Views: 687
1
/*
2
Undelete a compute server.
3
*/
4
5
import getAccountId from "lib/account/get-account";
6
import undeleteServer from "@cocalc/server/compute/undelete-server";
7
import getParams from "lib/api/get-params";
8
9
import { apiRoute, apiRouteOperation } from "lib/api";
10
import { OkStatus } from "lib/api/status";
11
import {
12
UndeleteComputeServerInputSchema,
13
UndeleteComputeServerOutputSchema,
14
} from "lib/api/schema/compute/undelete-server";
15
16
async function handle(req, res) {
17
try {
18
res.json(await get(req));
19
} catch (err) {
20
res.json({ error: `${err.message}` });
21
return;
22
}
23
}
24
25
async function get(req) {
26
const account_id = await getAccountId(req);
27
if (!account_id) {
28
throw Error("must be signed in");
29
}
30
const { id } = getParams(req);
31
await undeleteServer({
32
account_id,
33
id,
34
});
35
return OkStatus;
36
}
37
38
export default apiRoute({
39
undeleteServer: apiRouteOperation({
40
method: "POST",
41
openApiOperation: {
42
tags: ["Compute"],
43
},
44
})
45
.input({
46
contentType: "application/json",
47
body: UndeleteComputeServerInputSchema,
48
})
49
.outputs([
50
{
51
status: 200,
52
contentType: "application/json",
53
body: UndeleteComputeServerOutputSchema,
54
},
55
])
56
.handler(handle),
57
});
58
59