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/lib/api/schema/compute/create-server.ts
Views: 688
1
import { z } from "../../framework";
2
3
import { FailedAPIOperationSchema } from "../common";
4
5
import { ProjectIdSchema } from "../projects/common";
6
7
import {
8
ComputeServerCloudSchema,
9
ComputeServerColorSchema,
10
ComputeServerIdSchema,
11
ComputeServerTitleSchema,
12
ServerConfigurationSchema,
13
} from "./common";
14
15
// OpenAPI spec
16
//
17
export const CreateServerInputSchema = z
18
.object({
19
configuration: ServerConfigurationSchema,
20
title: ComputeServerTitleSchema,
21
color: ComputeServerColorSchema,
22
cloud: ComputeServerCloudSchema,
23
project_id: ProjectIdSchema.describe(
24
"The project id that this compute server provides compute for.",
25
),
26
idle_timeout: z
27
.number()
28
.describe(
29
`The idle timeout in seconds of this compute server. If set to 0, the server will
30
never turn off automatically. The compute server idle timeouts if none of the tabs
31
it is providing are actively touched through the web UI. _Not yet implemented._`,
32
)
33
.optional(),
34
autorestart: z
35
.boolean()
36
.describe(
37
`If true and the compute server stops for any reason, then it
38
will be automatically started again. This is primarily useful for
39
stopping instances.`,
40
)
41
.optional(),
42
notes: z
43
.string()
44
.describe("Open-ended text in markdown about this item.")
45
.optional(),
46
})
47
.describe("Create a new compute server with the provided configuration.");
48
49
export const CreateServerOutputSchema = z.union([
50
FailedAPIOperationSchema,
51
ComputeServerIdSchema.describe("The id of the created compute server."),
52
]);
53
54
export type CreateServerInput = z.infer<typeof CreateServerInputSchema>;
55
export type CreateServerOutput = z.infer<typeof CreateServerOutputSchema>;
56
57