freestyle-sandboxes 0.0.26 → 0.0.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ai/index.d.cts +1 -1
- package/dist/ai/index.d.mts +1 -1
- package/dist/index.cjs +321 -58
- package/dist/index.d.cts +73 -8
- package/dist/index.d.mts +73 -8
- package/dist/index.mjs +321 -58
- package/dist/langgraph/index.d.cts +1 -1
- package/dist/langgraph/index.d.mts +1 -1
- package/dist/mastra/index.d.cts +1 -1
- package/dist/mastra/index.d.mts +1 -1
- package/dist/types.gen-BzRtj_TA.d.ts +725 -0
- package/dist/utils/index.d.cts +1 -1
- package/dist/utils/index.d.mts +1 -1
- package/openapi/sdk.gen.ts +203 -9
- package/openapi/types.gen.ts +440 -20
- package/openapi.json +1 -1
- package/package.json +1 -1
- package/src/index.ts +400 -80
package/src/index.ts
CHANGED
|
@@ -1,6 +1,66 @@
|
|
|
1
|
-
import { Client, createClient } from "@hey-api/client-fetch";
|
|
1
|
+
import { type Client, createClient } from "@hey-api/client-fetch";
|
|
2
2
|
import * as sandbox_openapi from "../openapi/index.ts";
|
|
3
3
|
|
|
4
|
+
import type {
|
|
5
|
+
AccessLevel,
|
|
6
|
+
CreatedToken,
|
|
7
|
+
CreateRepositoryResponseSuccess,
|
|
8
|
+
DescribePermissionResponseSuccess,
|
|
9
|
+
FreestyleCloudstateDeployRequest,
|
|
10
|
+
FreestyleCloudstateDeploySuccessResponse,
|
|
11
|
+
FreestyleDeployWebConfiguration,
|
|
12
|
+
FreestyleDeployWebSuccessResponse,
|
|
13
|
+
FreestyleExecuteScriptParamsConfiguration,
|
|
14
|
+
FreestyleExecuteScriptResultSuccess,
|
|
15
|
+
GitIdentity,
|
|
16
|
+
HandleBackupCloudstateResponse,
|
|
17
|
+
HandleCreateDomainVerificationResponse,
|
|
18
|
+
HandleDeleteDomainVerificationResponse,
|
|
19
|
+
HandleDeleteIdentityResponse,
|
|
20
|
+
HandleDeleteRepoResponse,
|
|
21
|
+
HandleGetExecuteRunResponse,
|
|
22
|
+
HandleGetLogsResponse,
|
|
23
|
+
HandleListDomainsResponse,
|
|
24
|
+
HandleListDomainVerificationRequestsResponse,
|
|
25
|
+
HandleListExecuteRunsResponse,
|
|
26
|
+
HandleListRepositoriesResponse,
|
|
27
|
+
HandleListWebDeploysResponse,
|
|
28
|
+
HandleVerifyDomainError,
|
|
29
|
+
HandleVerifyDomainResponse,
|
|
30
|
+
ListGitTokensResponseSuccess,
|
|
31
|
+
ListPermissionResponseSuccess,
|
|
32
|
+
} from "../openapi/index.ts";
|
|
33
|
+
|
|
34
|
+
export type {
|
|
35
|
+
AccessLevel,
|
|
36
|
+
CreatedToken,
|
|
37
|
+
CreateRepositoryResponseSuccess,
|
|
38
|
+
DescribePermissionResponseSuccess,
|
|
39
|
+
FreestyleCloudstateDeployRequest,
|
|
40
|
+
FreestyleCloudstateDeploySuccessResponse,
|
|
41
|
+
FreestyleDeployWebConfiguration,
|
|
42
|
+
FreestyleDeployWebSuccessResponse,
|
|
43
|
+
FreestyleExecuteScriptParamsConfiguration,
|
|
44
|
+
FreestyleExecuteScriptResultSuccess,
|
|
45
|
+
GitIdentity,
|
|
46
|
+
HandleBackupCloudstateResponse,
|
|
47
|
+
HandleCreateDomainVerificationResponse,
|
|
48
|
+
HandleDeleteDomainVerificationResponse,
|
|
49
|
+
HandleDeleteIdentityResponse,
|
|
50
|
+
HandleDeleteRepoResponse,
|
|
51
|
+
HandleGetExecuteRunResponse,
|
|
52
|
+
HandleGetLogsResponse,
|
|
53
|
+
HandleListDomainsResponse,
|
|
54
|
+
HandleListDomainVerificationRequestsResponse,
|
|
55
|
+
HandleListExecuteRunsResponse,
|
|
56
|
+
HandleListRepositoriesResponse,
|
|
57
|
+
HandleListWebDeploysResponse,
|
|
58
|
+
HandleVerifyDomainError,
|
|
59
|
+
HandleVerifyDomainResponse,
|
|
60
|
+
ListGitTokensResponseSuccess,
|
|
61
|
+
ListPermissionResponseSuccess,
|
|
62
|
+
} from "../openapi/index.ts";
|
|
63
|
+
|
|
4
64
|
export class FreestyleSandboxes {
|
|
5
65
|
private client: Client;
|
|
6
66
|
constructor(options: {
|
|
@@ -17,6 +77,20 @@ export class FreestyleSandboxes {
|
|
|
17
77
|
*/
|
|
18
78
|
headers?: Record<string, string>;
|
|
19
79
|
}) {
|
|
80
|
+
//@ts-expect-error Deno has a weird behavior thats patched here
|
|
81
|
+
if (typeof Deno !== "undefined") {
|
|
82
|
+
class FreestyleRequest extends Request {
|
|
83
|
+
constructor(input, init) {
|
|
84
|
+
if (init.client !== undefined) {
|
|
85
|
+
console.warn("Unsupported client detected, using default client");
|
|
86
|
+
delete init.client;
|
|
87
|
+
}
|
|
88
|
+
super(input, init);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
Request = FreestyleRequest;
|
|
93
|
+
}
|
|
20
94
|
this.client = createClient({
|
|
21
95
|
baseUrl: options.baseUrl ?? "https://api.freestyle.sh",
|
|
22
96
|
headers: {
|
|
@@ -31,8 +105,8 @@ export class FreestyleSandboxes {
|
|
|
31
105
|
*/
|
|
32
106
|
async executeScript(
|
|
33
107
|
script: string,
|
|
34
|
-
config?:
|
|
35
|
-
): Promise<
|
|
108
|
+
config?: FreestyleExecuteScriptParamsConfiguration
|
|
109
|
+
): Promise<FreestyleExecuteScriptResultSuccess> {
|
|
36
110
|
const response = await sandbox_openapi.handleExecuteScript({
|
|
37
111
|
client: this.client,
|
|
38
112
|
body: {
|
|
@@ -43,13 +117,12 @@ export class FreestyleSandboxes {
|
|
|
43
117
|
|
|
44
118
|
if (response.data) {
|
|
45
119
|
return response.data;
|
|
46
|
-
} else {
|
|
47
|
-
throw new Error(
|
|
48
|
-
`Failed to execute script: \n\n${script}\n\nError:\n\n${JSON.stringify(
|
|
49
|
-
response
|
|
50
|
-
)}`
|
|
51
|
-
);
|
|
52
120
|
}
|
|
121
|
+
throw new Error(
|
|
122
|
+
`Failed to execute script: \n\n${script}\n\nError:\n\n${JSON.stringify(
|
|
123
|
+
response
|
|
124
|
+
)}`
|
|
125
|
+
);
|
|
53
126
|
}
|
|
54
127
|
|
|
55
128
|
/**
|
|
@@ -63,8 +136,8 @@ export class FreestyleSandboxes {
|
|
|
63
136
|
encoding?: string;
|
|
64
137
|
}
|
|
65
138
|
>,
|
|
66
|
-
config?:
|
|
67
|
-
): Promise<
|
|
139
|
+
config?: FreestyleDeployWebConfiguration
|
|
140
|
+
): Promise<FreestyleDeployWebSuccessResponse> {
|
|
68
141
|
const response = await sandbox_openapi.handleDeployWeb({
|
|
69
142
|
client: this.client,
|
|
70
143
|
body: {
|
|
@@ -74,28 +147,28 @@ export class FreestyleSandboxes {
|
|
|
74
147
|
});
|
|
75
148
|
if (response.data) {
|
|
76
149
|
return response.data;
|
|
77
|
-
} else {
|
|
78
|
-
throw new Error(
|
|
79
|
-
`Failed to deploy web project\n\nStatus: ${response.response.status}\n\nMessage: ${response.error?.message}`
|
|
80
|
-
);
|
|
81
150
|
}
|
|
151
|
+
throw new Error(
|
|
152
|
+
`Failed to deploy web project\n\nStatus: ${response.response.status}\n\nMessage: ${response.error?.message}`
|
|
153
|
+
);
|
|
82
154
|
}
|
|
83
155
|
|
|
84
156
|
/**
|
|
85
157
|
* Deploy a Cloudstate project to a sandbox.
|
|
86
158
|
*/
|
|
87
159
|
async deployCloudstate(
|
|
88
|
-
body:
|
|
89
|
-
): Promise<
|
|
160
|
+
body: FreestyleCloudstateDeployRequest
|
|
161
|
+
): Promise<FreestyleCloudstateDeploySuccessResponse> {
|
|
90
162
|
const response = await sandbox_openapi.handleDeployCloudstate({
|
|
91
163
|
client: this.client,
|
|
92
164
|
body: body,
|
|
93
165
|
});
|
|
166
|
+
|
|
94
167
|
if (response.data) {
|
|
95
168
|
return response.data;
|
|
96
|
-
} else {
|
|
97
|
-
throw new Error("Failed to deploy Cloudstate project");
|
|
98
169
|
}
|
|
170
|
+
|
|
171
|
+
throw new Error("Failed to deploy Cloudstate project");
|
|
99
172
|
}
|
|
100
173
|
|
|
101
174
|
/**
|
|
@@ -104,20 +177,19 @@ export class FreestyleSandboxes {
|
|
|
104
177
|
* @returns The backup of the Cloudstate project.
|
|
105
178
|
* @throws An error if the backup could not be retrieved.
|
|
106
179
|
*/
|
|
107
|
-
async backupCloudstate(
|
|
108
|
-
id: string
|
|
109
|
-
): Promise<sandbox_openapi.HandleBackupCloudstateResponse> {
|
|
180
|
+
async backupCloudstate(id: string): Promise<HandleBackupCloudstateResponse> {
|
|
110
181
|
const response = await sandbox_openapi.handleBackupCloudstate({
|
|
111
182
|
client: this.client,
|
|
112
183
|
path: {
|
|
113
184
|
id: id,
|
|
114
185
|
},
|
|
115
186
|
});
|
|
187
|
+
|
|
116
188
|
if (response.data) {
|
|
117
189
|
return response.data;
|
|
118
|
-
} else {
|
|
119
|
-
throw new Error("Failed to get backup of Cloudstate project");
|
|
120
190
|
}
|
|
191
|
+
|
|
192
|
+
throw new Error("Failed to get backup of Cloudstate project");
|
|
121
193
|
}
|
|
122
194
|
|
|
123
195
|
/**
|
|
@@ -126,7 +198,7 @@ export class FreestyleSandboxes {
|
|
|
126
198
|
* @returns The logs for the sandbox.
|
|
127
199
|
* @throws An error if the logs could not be retrieved.
|
|
128
200
|
*/
|
|
129
|
-
async getLogs(id: string): Promise<
|
|
201
|
+
async getLogs(id: string): Promise<HandleGetLogsResponse> {
|
|
130
202
|
const response = await sandbox_openapi.handleGetLogs({
|
|
131
203
|
client: this.client,
|
|
132
204
|
query: {
|
|
@@ -138,9 +210,8 @@ export class FreestyleSandboxes {
|
|
|
138
210
|
});
|
|
139
211
|
if (response.data) {
|
|
140
212
|
return response.data;
|
|
141
|
-
} else {
|
|
142
|
-
throw new Error("Failed to get logs for sandbox");
|
|
143
213
|
}
|
|
214
|
+
throw new Error("Failed to get logs for sandbox");
|
|
144
215
|
}
|
|
145
216
|
|
|
146
217
|
/**
|
|
@@ -150,7 +221,7 @@ export class FreestyleSandboxes {
|
|
|
150
221
|
*/
|
|
151
222
|
async createDomainVerificationRequest(
|
|
152
223
|
domain: string
|
|
153
|
-
): Promise<
|
|
224
|
+
): Promise<HandleCreateDomainVerificationResponse> {
|
|
154
225
|
const response = await sandbox_openapi.handleCreateDomainVerification({
|
|
155
226
|
client: this.client,
|
|
156
227
|
body: {
|
|
@@ -159,9 +230,9 @@ export class FreestyleSandboxes {
|
|
|
159
230
|
});
|
|
160
231
|
if (response.data) {
|
|
161
232
|
return response.data;
|
|
162
|
-
} else {
|
|
163
|
-
throw new Error(response.error.message);
|
|
164
233
|
}
|
|
234
|
+
|
|
235
|
+
throw new Error(response.error.message);
|
|
165
236
|
}
|
|
166
237
|
|
|
167
238
|
/**
|
|
@@ -171,10 +242,7 @@ export class FreestyleSandboxes {
|
|
|
171
242
|
*/
|
|
172
243
|
async verifyDomain(
|
|
173
244
|
domain: string
|
|
174
|
-
): Promise<
|
|
175
|
-
| sandbox_openapi.HandleVerifyDomainResponse
|
|
176
|
-
| sandbox_openapi.HandleVerifyDomainError
|
|
177
|
-
> {
|
|
245
|
+
): Promise<HandleVerifyDomainResponse | HandleVerifyDomainError> {
|
|
178
246
|
const response = await sandbox_openapi.handleVerifyDomain({
|
|
179
247
|
client: this.client,
|
|
180
248
|
body: {
|
|
@@ -183,25 +251,24 @@ export class FreestyleSandboxes {
|
|
|
183
251
|
});
|
|
184
252
|
if (response.data) {
|
|
185
253
|
return response.data;
|
|
186
|
-
} else {
|
|
187
|
-
throw new Error(
|
|
188
|
-
`Failed to verify domain ${domain}: ${response.error.message}`
|
|
189
|
-
);
|
|
190
254
|
}
|
|
255
|
+
throw new Error(
|
|
256
|
+
`Failed to verify domain ${domain}: ${response.error.message}`
|
|
257
|
+
);
|
|
191
258
|
}
|
|
192
259
|
|
|
193
|
-
async listDomains(): Promise<
|
|
260
|
+
async listDomains(): Promise<HandleListDomainsResponse> {
|
|
194
261
|
const response = await sandbox_openapi.handleListDomains({
|
|
195
262
|
client: this.client,
|
|
196
263
|
});
|
|
197
264
|
if (response.data) {
|
|
198
265
|
return response.data;
|
|
199
|
-
} else {
|
|
200
|
-
throw new Error("Failed to list domains\n" + response.error.message);
|
|
201
266
|
}
|
|
267
|
+
|
|
268
|
+
throw new Error(`Failed to list domains\n${response.error.message}`);
|
|
202
269
|
}
|
|
203
270
|
|
|
204
|
-
async listDomainVerificationRequests(): Promise<
|
|
271
|
+
async listDomainVerificationRequests(): Promise<HandleListDomainVerificationRequestsResponse> {
|
|
205
272
|
const response = await sandbox_openapi.handleListDomainVerificationRequests(
|
|
206
273
|
{
|
|
207
274
|
client: this.client,
|
|
@@ -209,17 +276,17 @@ export class FreestyleSandboxes {
|
|
|
209
276
|
);
|
|
210
277
|
if (response.data) {
|
|
211
278
|
return response.data;
|
|
212
|
-
} else {
|
|
213
|
-
throw new Error(
|
|
214
|
-
"Failed to list domain verification requests\n" + response.error.message
|
|
215
|
-
);
|
|
216
279
|
}
|
|
280
|
+
|
|
281
|
+
throw new Error(
|
|
282
|
+
`Failed to list domain verification requests\n${response.error.message}`
|
|
283
|
+
);
|
|
217
284
|
}
|
|
218
285
|
|
|
219
286
|
async deleteDomainVerificationRequest(
|
|
220
287
|
domain: string,
|
|
221
288
|
verificationCode: string
|
|
222
|
-
): Promise<
|
|
289
|
+
): Promise<HandleDeleteDomainVerificationResponse> {
|
|
223
290
|
const response = await sandbox_openapi.handleDeleteDomainVerification({
|
|
224
291
|
client: this.client,
|
|
225
292
|
body: {
|
|
@@ -229,17 +296,17 @@ export class FreestyleSandboxes {
|
|
|
229
296
|
});
|
|
230
297
|
if (response.data) {
|
|
231
298
|
return response.data;
|
|
232
|
-
} else {
|
|
233
|
-
throw new Error(
|
|
234
|
-
`Failed to delete domain verification request for domain ${domain}: ${response.error.message}`
|
|
235
|
-
);
|
|
236
299
|
}
|
|
300
|
+
|
|
301
|
+
throw new Error(
|
|
302
|
+
`Failed to delete domain verification request for domain ${domain}: ${response.error.message}`
|
|
303
|
+
);
|
|
237
304
|
}
|
|
238
305
|
|
|
239
306
|
async listWebDeployments(
|
|
240
307
|
limit?: number,
|
|
241
308
|
offset?: number
|
|
242
|
-
): Promise<
|
|
309
|
+
): Promise<HandleListWebDeploysResponse> {
|
|
243
310
|
const response = await sandbox_openapi.handleListWebDeploys({
|
|
244
311
|
client: this.client,
|
|
245
312
|
query: {
|
|
@@ -247,19 +314,20 @@ export class FreestyleSandboxes {
|
|
|
247
314
|
offset: offset ?? 0,
|
|
248
315
|
},
|
|
249
316
|
});
|
|
317
|
+
|
|
250
318
|
if (response.data) {
|
|
251
319
|
return response.data;
|
|
252
|
-
} else {
|
|
253
|
-
throw new Error(
|
|
254
|
-
"Failed to list web deployments\n" + response.error.message
|
|
255
|
-
);
|
|
256
320
|
}
|
|
321
|
+
|
|
322
|
+
throw new Error(
|
|
323
|
+
`Failed to list web deployments\n${response.error.message}`
|
|
324
|
+
);
|
|
257
325
|
}
|
|
258
326
|
|
|
259
327
|
async listExecuteRuns(
|
|
260
328
|
limit?: number,
|
|
261
329
|
offset?: number
|
|
262
|
-
): Promise<
|
|
330
|
+
): Promise<HandleListExecuteRunsResponse> {
|
|
263
331
|
const response = await sandbox_openapi.handleListExecuteRuns({
|
|
264
332
|
client: this.client,
|
|
265
333
|
query: {
|
|
@@ -269,14 +337,11 @@ export class FreestyleSandboxes {
|
|
|
269
337
|
});
|
|
270
338
|
if (response.data) {
|
|
271
339
|
return response.data;
|
|
272
|
-
} else {
|
|
273
|
-
throw new Error("Failed to list execute runs\n" + response.error.message);
|
|
274
340
|
}
|
|
341
|
+
throw new Error(`Failed to list execute runs\n${response.error.message}`);
|
|
275
342
|
}
|
|
276
343
|
|
|
277
|
-
async getExecuteRun(
|
|
278
|
-
id: string
|
|
279
|
-
): Promise<sandbox_openapi.HandleGetExecuteRunResponse> {
|
|
344
|
+
async getExecuteRun(id: string): Promise<HandleGetExecuteRunResponse> {
|
|
280
345
|
const response = await sandbox_openapi.handleGetExecuteRun({
|
|
281
346
|
client: this.client,
|
|
282
347
|
path: {
|
|
@@ -293,6 +358,24 @@ export class FreestyleSandboxes {
|
|
|
293
358
|
);
|
|
294
359
|
}
|
|
295
360
|
|
|
361
|
+
/** Provision a wildcard certificate for domain. */
|
|
362
|
+
async provisionWildcard(domain: string) {
|
|
363
|
+
const response = await sandbox_openapi.handleVerifyWildcard({
|
|
364
|
+
client: this.client,
|
|
365
|
+
path: {
|
|
366
|
+
domain,
|
|
367
|
+
},
|
|
368
|
+
});
|
|
369
|
+
|
|
370
|
+
if (response.data) {
|
|
371
|
+
return response.data;
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
throw new Error(
|
|
375
|
+
`Failed to provision wildcard for domain ${domain}: ${response.error.message}`
|
|
376
|
+
);
|
|
377
|
+
}
|
|
378
|
+
|
|
296
379
|
/**
|
|
297
380
|
* Create a new git repository.
|
|
298
381
|
*
|
|
@@ -300,16 +383,18 @@ export class FreestyleSandboxes {
|
|
|
300
383
|
*/
|
|
301
384
|
async createGitRepository(
|
|
302
385
|
name: string
|
|
303
|
-
): Promise<
|
|
304
|
-
const response = await sandbox_openapi.
|
|
386
|
+
): Promise<CreateRepositoryResponseSuccess> {
|
|
387
|
+
const response = await sandbox_openapi.handleCreateRepo({
|
|
305
388
|
client: this.client,
|
|
306
389
|
body: {
|
|
307
390
|
name,
|
|
308
391
|
},
|
|
309
392
|
});
|
|
393
|
+
|
|
310
394
|
if (response.data) {
|
|
311
395
|
return response.data;
|
|
312
396
|
}
|
|
397
|
+
|
|
313
398
|
throw new Error(
|
|
314
399
|
`Failed to create git repository ${name}: ${response.error}`
|
|
315
400
|
);
|
|
@@ -324,17 +409,19 @@ export class FreestyleSandboxes {
|
|
|
324
409
|
async listGitRepositories(
|
|
325
410
|
limit?: number,
|
|
326
411
|
offset?: number
|
|
327
|
-
): Promise<
|
|
328
|
-
const response = await sandbox_openapi.
|
|
412
|
+
): Promise<HandleListRepositoriesResponse> {
|
|
413
|
+
const response = await sandbox_openapi.handleListRepositories({
|
|
329
414
|
client: this.client,
|
|
330
415
|
query: {
|
|
331
416
|
limit: limit ?? 10,
|
|
332
417
|
offset: offset ?? 0,
|
|
333
418
|
},
|
|
334
419
|
});
|
|
420
|
+
|
|
335
421
|
if (response.data) {
|
|
336
422
|
return response.data;
|
|
337
423
|
}
|
|
424
|
+
|
|
338
425
|
throw new Error(`Failed to list git repositories: ${response.error}`);
|
|
339
426
|
}
|
|
340
427
|
|
|
@@ -345,8 +432,8 @@ export class FreestyleSandboxes {
|
|
|
345
432
|
*/
|
|
346
433
|
async deleteGitRepository(
|
|
347
434
|
repositoryId: string
|
|
348
|
-
): Promise<
|
|
349
|
-
const response = await sandbox_openapi.
|
|
435
|
+
): Promise<HandleDeleteRepoResponse> {
|
|
436
|
+
const response = await sandbox_openapi.handleDeleteRepo({
|
|
350
437
|
client: this.client,
|
|
351
438
|
path: {
|
|
352
439
|
repo: repositoryId,
|
|
@@ -355,29 +442,262 @@ export class FreestyleSandboxes {
|
|
|
355
442
|
|
|
356
443
|
if (response.data) {
|
|
357
444
|
return response.data;
|
|
358
|
-
} else {
|
|
359
|
-
throw new Error(
|
|
360
|
-
`Failed to delete git repository ${repositoryId}: ${response.error}`
|
|
361
|
-
);
|
|
362
445
|
}
|
|
446
|
+
|
|
447
|
+
throw new Error(
|
|
448
|
+
`Failed to delete git repository ${repositoryId}: ${response.error}`
|
|
449
|
+
);
|
|
363
450
|
}
|
|
364
451
|
|
|
365
|
-
/**
|
|
366
|
-
|
|
367
|
-
|
|
452
|
+
/**
|
|
453
|
+
* Create a new git identity.
|
|
454
|
+
*/
|
|
455
|
+
async createGitIdentity(): Promise<GitIdentity> {
|
|
456
|
+
const response = await sandbox_openapi.handleCreateIdentity({
|
|
457
|
+
client: this.client,
|
|
458
|
+
});
|
|
459
|
+
|
|
460
|
+
if (response.data) {
|
|
461
|
+
return response.data;
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
throw new Error(`Failed to create git identity: ${response.error}`);
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
/**
|
|
468
|
+
* Delete a git identity.
|
|
469
|
+
*
|
|
470
|
+
* @param identityId The ID of the identity to delete.
|
|
471
|
+
*/
|
|
472
|
+
async deleteGitIdentity(
|
|
473
|
+
identityId: string
|
|
474
|
+
): Promise<HandleDeleteIdentityResponse> {
|
|
475
|
+
const response = await sandbox_openapi.handleDeleteIdentity({
|
|
368
476
|
client: this.client,
|
|
369
477
|
path: {
|
|
370
|
-
|
|
478
|
+
identity: identityId,
|
|
479
|
+
},
|
|
480
|
+
});
|
|
481
|
+
|
|
482
|
+
if (response.data) {
|
|
483
|
+
return response.data;
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
throw new Error(`Failed to delete git identity: ${response.error}`);
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
/**
|
|
490
|
+
* Grant a git identity access to a repository.
|
|
491
|
+
*
|
|
492
|
+
* @param repoId The ID of the repository to grant access to.
|
|
493
|
+
* @param identityId The ID of the identity grant access to `repoId`.
|
|
494
|
+
* @param permission The permission to grant.
|
|
495
|
+
*/
|
|
496
|
+
async grantGitPermission(
|
|
497
|
+
repoId: string,
|
|
498
|
+
identityId: string,
|
|
499
|
+
permission: AccessLevel
|
|
500
|
+
) {
|
|
501
|
+
const response = await sandbox_openapi.handleGrantPermission({
|
|
502
|
+
client: this.client,
|
|
503
|
+
path: {
|
|
504
|
+
repo: repoId,
|
|
505
|
+
identity: identityId,
|
|
506
|
+
},
|
|
507
|
+
body: {
|
|
508
|
+
permission,
|
|
371
509
|
},
|
|
372
510
|
});
|
|
373
511
|
|
|
374
512
|
if (response.data) {
|
|
375
513
|
return response.data;
|
|
376
|
-
} else {
|
|
377
|
-
throw new Error(
|
|
378
|
-
`Failed to provision wildcard for domain ${domain}: ${response.error.message}`
|
|
379
|
-
);
|
|
380
514
|
}
|
|
515
|
+
|
|
516
|
+
throw new Error(
|
|
517
|
+
`Failed to grant access to git identity ${identityId} for repository ${repoId}: ${response.error}`
|
|
518
|
+
);
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
/**
|
|
522
|
+
* Update a git identity's permissions on a repository.
|
|
523
|
+
*
|
|
524
|
+
* @param repoId The ID of the repository to update permissions for.
|
|
525
|
+
* @param identityId The ID of the identity to whose access to update.
|
|
526
|
+
* @param permission The permission to grant.
|
|
527
|
+
*/
|
|
528
|
+
async updateGitPermission(
|
|
529
|
+
repoId: string,
|
|
530
|
+
identityId: string,
|
|
531
|
+
permission: AccessLevel
|
|
532
|
+
): Promise<void> {
|
|
533
|
+
const response = await sandbox_openapi.handleUpdatePermission({
|
|
534
|
+
client: this.client,
|
|
535
|
+
path: {
|
|
536
|
+
repo: repoId,
|
|
537
|
+
identity: identityId,
|
|
538
|
+
},
|
|
539
|
+
body: {
|
|
540
|
+
permission,
|
|
541
|
+
},
|
|
542
|
+
});
|
|
543
|
+
|
|
544
|
+
if (response.data) {
|
|
545
|
+
return;
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
throw new Error(
|
|
549
|
+
`Failed to update permission for git identity ${identityId} for repository ${repoId}: ${response.error}`
|
|
550
|
+
);
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
/**
|
|
554
|
+
* Revoke a git identity's access to a repository.
|
|
555
|
+
*
|
|
556
|
+
* @param repoId The ID of the repository revoke access to.
|
|
557
|
+
* @param identityId The ID of the identity to revoke access from.
|
|
558
|
+
*/
|
|
559
|
+
async revokeGitPermission(repoId: string, identityId: string): Promise<void> {
|
|
560
|
+
const response = await sandbox_openapi.handleRevokePermission({
|
|
561
|
+
client: this.client,
|
|
562
|
+
path: {
|
|
563
|
+
repo: repoId,
|
|
564
|
+
identity: identityId,
|
|
565
|
+
},
|
|
566
|
+
});
|
|
567
|
+
|
|
568
|
+
if (response.data) {
|
|
569
|
+
return;
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
throw new Error(
|
|
573
|
+
`Failed to revoke access to git identity ${identityId} for repository ${repoId}: ${response.error}`
|
|
574
|
+
);
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
/**
|
|
578
|
+
* List access permissions for a git identity.
|
|
579
|
+
*
|
|
580
|
+
* @param identityId The ID of the identity to list permissions for.
|
|
581
|
+
*/
|
|
582
|
+
async listGitPermissions(
|
|
583
|
+
identityId: string
|
|
584
|
+
): Promise<ListPermissionResponseSuccess> {
|
|
585
|
+
const response = await sandbox_openapi.handleListPermissions({
|
|
586
|
+
client: this.client,
|
|
587
|
+
path: {
|
|
588
|
+
identity: identityId,
|
|
589
|
+
},
|
|
590
|
+
});
|
|
591
|
+
|
|
592
|
+
if (response.data) {
|
|
593
|
+
return response.data;
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
throw new Error(
|
|
597
|
+
`Failed to list permissions for git identity ${identityId}: ${response.error}`
|
|
598
|
+
);
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
/**
|
|
602
|
+
* Get the permission of a git identity on a repository.
|
|
603
|
+
*
|
|
604
|
+
* @param repoId The ID of the repository to check permissions for.
|
|
605
|
+
* @param identityId The ID of the identity to check permissions for.
|
|
606
|
+
*/
|
|
607
|
+
async getGitPermission(
|
|
608
|
+
repoId: string,
|
|
609
|
+
identityId: string
|
|
610
|
+
): Promise<DescribePermissionResponseSuccess> {
|
|
611
|
+
const response = await sandbox_openapi.handleDescribePermission({
|
|
612
|
+
client: this.client,
|
|
613
|
+
path: {
|
|
614
|
+
repo: repoId,
|
|
615
|
+
identity: identityId,
|
|
616
|
+
},
|
|
617
|
+
});
|
|
618
|
+
|
|
619
|
+
if (response.data) {
|
|
620
|
+
return response.data;
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
throw new Error(
|
|
624
|
+
`Failed to get permission for git identity ${identityId} on repository ${repoId}: ${response.error}`
|
|
625
|
+
);
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
/**
|
|
629
|
+
* Create a new git access token for an identity.
|
|
630
|
+
*
|
|
631
|
+
* @param identityId The ID of the identity to create the token for.
|
|
632
|
+
*/
|
|
633
|
+
async createGitAccessToken(identityId: string): Promise<CreatedToken> {
|
|
634
|
+
const response = await sandbox_openapi.handleCreateGitToken({
|
|
635
|
+
client: this.client,
|
|
636
|
+
path: {
|
|
637
|
+
identity: identityId,
|
|
638
|
+
},
|
|
639
|
+
});
|
|
640
|
+
|
|
641
|
+
if (response.data) {
|
|
642
|
+
return response.data;
|
|
643
|
+
}
|
|
644
|
+
|
|
645
|
+
throw new Error(
|
|
646
|
+
`Failed to create git access token: ${response.error.message}`
|
|
647
|
+
);
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
/**
|
|
651
|
+
* Revoke a git access token.
|
|
652
|
+
*
|
|
653
|
+
* @param identityId The ID of the identity the token belongs to.
|
|
654
|
+
* @param tokenId The ID of the token to revoke.
|
|
655
|
+
*/
|
|
656
|
+
async revokeGitAccessToken(
|
|
657
|
+
identityId: string,
|
|
658
|
+
tokenId: string
|
|
659
|
+
): Promise<void> {
|
|
660
|
+
const response = await sandbox_openapi.handleRevokeGitToken({
|
|
661
|
+
client: this.client,
|
|
662
|
+
body: {
|
|
663
|
+
tokenId,
|
|
664
|
+
},
|
|
665
|
+
path: {
|
|
666
|
+
identity: identityId,
|
|
667
|
+
},
|
|
668
|
+
});
|
|
669
|
+
|
|
670
|
+
if (response.data) {
|
|
671
|
+
return;
|
|
672
|
+
}
|
|
673
|
+
|
|
674
|
+
throw new Error(
|
|
675
|
+
`Failed to revoke git access token ${tokenId}: ${response.error.message}`
|
|
676
|
+
);
|
|
677
|
+
}
|
|
678
|
+
|
|
679
|
+
/**
|
|
680
|
+
* List git access tokens for an identity.
|
|
681
|
+
*
|
|
682
|
+
* @param identityId The ID of the identity to list tokens for.
|
|
683
|
+
*/
|
|
684
|
+
async listGitAccessTokens(
|
|
685
|
+
identityId: string
|
|
686
|
+
): Promise<ListGitTokensResponseSuccess> {
|
|
687
|
+
const response = await sandbox_openapi.handleListGitTokens({
|
|
688
|
+
client: this.client,
|
|
689
|
+
path: {
|
|
690
|
+
identity: identityId,
|
|
691
|
+
},
|
|
692
|
+
});
|
|
693
|
+
|
|
694
|
+
if (response.data) {
|
|
695
|
+
return response.data;
|
|
696
|
+
}
|
|
697
|
+
|
|
698
|
+
throw new Error(
|
|
699
|
+
`Failed to list git access tokens: ${response.error.message}`
|
|
700
|
+
);
|
|
381
701
|
}
|
|
382
702
|
}
|
|
383
703
|
|