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/get-template.ts
Views: 688
1
import { z } from "../../framework";
2
3
import { FailedAPIOperationSchema } from "../common";
4
5
import {
6
BaseServerConfigurationSchema,
7
ComputeServerCloudSchema,
8
ComputeServerColorSchema,
9
ComputeServerIdSchema,
10
ComputeServerTitleSchema,
11
} from "./common";
12
13
// OpenAPI spec
14
//
15
export const ComputeServerTemplateObjectSchema = z
16
.object({
17
enabled: z
18
.boolean()
19
.describe(
20
"If true, this server template is to be shown in the CoCalc UI.",
21
)
22
.optional(),
23
priority: z
24
.number()
25
.describe("Semantic priority for this server template.")
26
.optional(),
27
})
28
.describe(
29
"Contains information about this template's priority and availability.",
30
);
31
32
export const GetComputeServerTemplateSchema = z.object({
33
id: ComputeServerIdSchema.describe("Compute server template id"),
34
title: ComputeServerTitleSchema,
35
color: ComputeServerColorSchema,
36
cloud: ComputeServerCloudSchema,
37
configuration:
38
BaseServerConfigurationSchema.describe(`Default cloud server configuration for this template. _The exact
39
structure of this object is still in development, and this schema should
40
be used accordingly.`),
41
template: ComputeServerTemplateObjectSchema,
42
avatar_image_tiny: z
43
.union([z.string().describe("Image URL"), z.null()])
44
.describe(
45
`tiny (32x32) visual image associated with the compute server. Suitable to
46
include as part of changefeed`,
47
),
48
position: z
49
.number()
50
.int()
51
.describe("Used for sorting a list of compute servers in the UI."),
52
cost_per_hour: z
53
.object({
54
running: z
55
.number()
56
.describe(
57
"Cost in (fractional) cents for the compute server when powered on.",
58
),
59
off: z
60
.number()
61
.describe(
62
"Cost in (fractional) cents for the compute server when powered off.",
63
),
64
})
65
.describe("Compute server template.")
66
.optional(),
67
});
68
69
export const GetComputeServerTemplateInputSchema = z
70
.object({
71
id: ComputeServerIdSchema.describe("Compute server template id."),
72
})
73
.describe("Get a specific compute server template by `id`.");
74
75
export const GetComputeServerTemplateOutputSchema = z.union([
76
FailedAPIOperationSchema,
77
GetComputeServerTemplateSchema,
78
]);
79
80
export type GetComputeServerTemplateInput = z.infer<
81
typeof GetComputeServerTemplateInputSchema
82
>;
83
export type GetComputeServerTemplateOutput = z.infer<
84
typeof GetComputeServerTemplateOutputSchema
85
>;
86
87