1
- import { authFirstRequireAccount } from "./util" ;
1
+ import { authFirstRequireAccount , authFirst } from "./util" ;
2
2
import type {
3
- // Action,
3
+ Action ,
4
4
Cloud ,
5
- // ComputeServerTemplate,
6
- // ComputeServerUserInfo,
5
+ ComputeServerTemplate ,
6
+ ComputeServerUserInfo ,
7
7
Configuration ,
8
- // Images,
9
- // GoogleCloudImages,
8
+ Images ,
9
+ GoogleCloudImages ,
10
10
} from "@cocalc/util/db-schema/compute-servers" ;
11
+ import type { GoogleCloudData } from "@cocalc/util/compute/cloud/google-cloud/compute-cost" ;
12
+ import type { HyperstackPriceData } from "@cocalc/util/compute/cloud/hyperstack/pricing" ;
13
+ import type {
14
+ ConfigurationTemplate ,
15
+ ConfigurationTemplates ,
16
+ } from "@cocalc/util/compute/templates" ;
11
17
12
18
export const compute = {
13
19
createServer : authFirstRequireAccount ,
20
+ computeServerAction : authFirstRequireAccount ,
21
+ getServersById : authFirstRequireAccount ,
22
+ getServers : authFirstRequireAccount ,
23
+ getServerState : authFirstRequireAccount ,
24
+ getSerialPortOutput : authFirstRequireAccount ,
25
+ deleteServer : authFirstRequireAccount ,
26
+ undeleteServer : authFirstRequireAccount ,
27
+ isDnsAvailable : authFirstRequireAccount ,
28
+ setServerColor : authFirstRequireAccount ,
29
+ setServerTitle : authFirstRequireAccount ,
30
+ setServerConfiguration : authFirstRequireAccount ,
31
+ setTemplate : authFirstRequireAccount ,
32
+ getTemplate : true ,
33
+ getTemplates : authFirstRequireAccount ,
34
+ setServerCloud : authFirstRequireAccount ,
35
+ setServerOwner : authFirstRequireAccount ,
36
+ getGoogleCloudPriceData : authFirstRequireAccount ,
37
+ getHyperstackPriceData : authFirstRequireAccount ,
38
+ getNetworkUsage : authFirstRequireAccount ,
39
+ getApiKey : authFirstRequireAccount ,
40
+ deleteApiKey : authFirstRequireAccount ,
41
+ getLog : authFirstRequireAccount ,
42
+ getTitle : authFirstRequireAccount ,
43
+ setDetailedState : authFirstRequireAccount ,
44
+ getImages : authFirst ,
45
+ getGoogleCloudImages : authFirst ,
46
+ setImageTested : authFirstRequireAccount ,
14
47
} ;
15
48
16
49
export interface Compute {
50
+ // server lifecycle
17
51
createServer : ( opts : {
18
52
account_id ?: string ;
19
53
project_id : string ;
@@ -26,4 +60,131 @@ export interface Compute {
26
60
course_project_id ?: string ;
27
61
course_server_id ?: number ;
28
62
} ) => Promise < number > ;
63
+
64
+ computeServerAction : ( opts : {
65
+ account_id ?: string ;
66
+ id : number ;
67
+ action : Action ;
68
+ } ) => Promise < void > ;
69
+
70
+ getServersById : ( opts : {
71
+ account_id ?: string ;
72
+ ids : number [ ] ;
73
+ fields ?: Array < keyof ComputeServerUserInfo > ;
74
+ } ) => Promise < Partial < ComputeServerUserInfo > [ ] > ;
75
+
76
+ getServers : ( opts : {
77
+ account_id ?: string ;
78
+ id ?: number ;
79
+ project_id : string ;
80
+ } ) => Promise < ComputeServerUserInfo [ ] > ;
81
+
82
+ getServerState : ( opts : {
83
+ account_id ?: string ;
84
+ id : number ;
85
+ } ) => Promise < ComputeServerUserInfo [ "state" ] > ;
86
+ getSerialPortOutput : ( opts : {
87
+ account_id ?: string ;
88
+ id : number ;
89
+ } ) => Promise < string > ;
90
+
91
+ deleteServer : ( opts : { account_id ?: string ; id : number } ) => Promise < void > ;
92
+ undeleteServer : ( opts : { account_id ?: string ; id : number } ) => Promise < void > ;
93
+
94
+ isDnsAvailable : ( opts : {
95
+ account_id ?: string ;
96
+ dns : string ;
97
+ } ) => Promise < boolean > ;
98
+
99
+ // ownership & metadata
100
+ setServerColor : ( opts : {
101
+ account_id ?: string ;
102
+ id : number ;
103
+ color : string ;
104
+ } ) => Promise < void > ;
105
+ setServerTitle : ( opts : {
106
+ account_id ?: string ;
107
+ id : number ;
108
+ title : string ;
109
+ } ) => Promise < void > ;
110
+ setServerConfiguration : ( opts : {
111
+ account_id ?: string ;
112
+ id : number ;
113
+ configuration : Partial < Configuration > ;
114
+ } ) => Promise < void > ;
115
+
116
+ setTemplate : ( opts : {
117
+ account_id ?: string ;
118
+ id : number ;
119
+ template : ComputeServerTemplate ;
120
+ } ) => Promise < void > ;
121
+
122
+ getTemplate : ( opts : {
123
+ account_id ?: string ;
124
+ id : number ;
125
+ } ) => Promise < ConfigurationTemplate > ;
126
+ getTemplates : ( ) => Promise < ConfigurationTemplates > ;
127
+
128
+ setServerCloud : ( opts : {
129
+ account_id ?: string ;
130
+ id : number ;
131
+ cloud : Cloud | string ;
132
+ } ) => Promise < void > ;
133
+ setServerOwner : ( opts : {
134
+ account_id ?: string ;
135
+ id : number ;
136
+ new_account_id : string ;
137
+ } ) => Promise < void > ;
138
+
139
+ // pricing caches
140
+ getGoogleCloudPriceData : ( ) => Promise < GoogleCloudData > ;
141
+ getHyperstackPriceData : ( ) => Promise < HyperstackPriceData > ;
142
+
143
+ // usage & logs
144
+ getNetworkUsage : ( opts : {
145
+ account_id ?: string ;
146
+ id : number ;
147
+ start : Date ;
148
+ end : Date ;
149
+ } ) => Promise < { amount : number ; cost : number } > ;
150
+
151
+ getApiKey : ( opts : { account_id ?: string ; id : number } ) => Promise < string > ;
152
+ deleteApiKey : ( opts : { account_id ?: string ; id : number } ) => Promise < void > ;
153
+
154
+ getLog : ( opts : {
155
+ account_id ?: string ;
156
+ id : number ;
157
+ type : "activity" | "files" ;
158
+ } ) => Promise < any > ;
159
+
160
+ getTitle : ( opts : { account_id ?: string ; id : number } ) => Promise < {
161
+ title : string ;
162
+ color : string ;
163
+ project_specific_id : number ;
164
+ } > ;
165
+
166
+ setDetailedState : ( opts : {
167
+ account_id ?: string ;
168
+ project_id : string ;
169
+ id : number ;
170
+ name : string ;
171
+ state ?: string ;
172
+ extra ?: string ;
173
+ timeout ?: number ;
174
+ progress ?: number ;
175
+ } ) => Promise < void > ;
176
+
177
+ getImages : ( opts ?: {
178
+ noCache ?: boolean ;
179
+ account_id ?: string ;
180
+ } ) => Promise < Images > ;
181
+ getGoogleCloudImages : ( opts ?: {
182
+ noCache ?: boolean ;
183
+ account_id ?: string ;
184
+ } ) => Promise < GoogleCloudImages > ;
185
+ setImageTested : ( opts : {
186
+ account_id ?: string ;
187
+ id : number ;
188
+ tested : boolean ;
189
+ } ) => Promise < void > ;
29
190
}
0 commit comments