@scaleway/sdk-container 2.3.1 → 2.4.0

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.
@@ -1,607 +1,411 @@
1
- import { API as API$1, toApiLocality, urlParams, validatePathParam, enrichForPagination, waitForResource, resolveOneOf } from "@scaleway/sdk-client";
2
- import { NAMESPACE_TRANSIENT_STATUSES, CONTAINER_TRANSIENT_STATUSES, CRON_TRANSIENT_STATUSES, DOMAIN_TRANSIENT_STATUSES, TOKEN_TRANSIENT_STATUSES, TRIGGER_TRANSIENT_STATUSES } from "./content.gen.js";
3
- import { unmarshalListNamespacesResponse, unmarshalNamespace, marshalCreateNamespaceRequest, marshalUpdateNamespaceRequest, unmarshalListContainersResponse, unmarshalContainer, marshalCreateContainerRequest, marshalUpdateContainerRequest, unmarshalListCronsResponse, unmarshalCron, marshalCreateCronRequest, marshalUpdateCronRequest, unmarshalListDomainsResponse, unmarshalDomain, marshalCreateDomainRequest, marshalCreateTokenRequest, unmarshalToken, unmarshalListTokensResponse, marshalCreateTriggerRequest, unmarshalTrigger, unmarshalListTriggersResponse, marshalUpdateTriggerRequest } from "./marshalling.gen.js";
4
- const jsonContentHeaders = {
5
- "Content-Type": "application/json; charset=utf-8"
6
- };
7
- class API extends API$1 {
8
- /**
9
- * Locality of this API.
10
- * type {'zone','region','global','unspecified'}
11
- */
12
- static LOCALITY = toApiLocality({
13
- regions: ["fr-par", "nl-ams", "pl-waw"]
14
- });
15
- pageOfListNamespaces = (request = {}) => this.client.fetch(
16
- {
17
- method: "GET",
18
- path: `/containers/v1beta1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/namespaces`,
19
- urlParams: urlParams(
20
- ["name", request.name],
21
- ["order_by", request.orderBy],
22
- ["organization_id", request.organizationId],
23
- ["page", request.page],
24
- [
25
- "page_size",
26
- request.pageSize ?? this.client.settings.defaultPageSize
27
- ],
28
- ["project_id", request.projectId]
29
- )
30
- },
31
- unmarshalListNamespacesResponse
32
- );
33
- /**
34
- * List all your namespaces. List all namespaces in a specified region.
35
- *
36
- * @param request - The request {@link ListNamespacesRequest}
37
- * @returns A Promise of ListNamespacesResponse
38
- */
39
- listNamespaces = (request = {}) => enrichForPagination("namespaces", this.pageOfListNamespaces, request);
40
- /**
41
- * Get a namespace. Get the namespace associated with the specified ID.
42
- *
43
- * @param request - The request {@link GetNamespaceRequest}
44
- * @returns A Promise of Namespace
45
- */
46
- getNamespace = (request) => this.client.fetch(
47
- {
48
- method: "GET",
49
- path: `/containers/v1beta1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/namespaces/${validatePathParam("namespaceId", request.namespaceId)}`
50
- },
51
- unmarshalNamespace
52
- );
53
- /**
54
- * Waits for {@link Namespace} to be in a final state.
55
- *
56
- * @param request - The request {@link GetNamespaceRequest}
57
- * @param options - The waiting options
58
- * @returns A Promise of Namespace
59
- */
60
- waitForNamespace = (request, options) => waitForResource(
61
- options?.stop ?? ((res) => Promise.resolve(
62
- !NAMESPACE_TRANSIENT_STATUSES.includes(res.status)
63
- )),
64
- this.getNamespace,
65
- request,
66
- options
67
- );
68
- /**
69
- * Create a new namespace. Create a new namespace in a specified region.
70
- *
71
- * @param request - The request {@link CreateNamespaceRequest}
72
- * @returns A Promise of Namespace
73
- */
74
- createNamespace = (request = {}) => this.client.fetch(
75
- {
76
- body: JSON.stringify(
77
- marshalCreateNamespaceRequest(request, this.client.settings)
78
- ),
79
- headers: jsonContentHeaders,
80
- method: "POST",
81
- path: `/containers/v1beta1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/namespaces`
82
- },
83
- unmarshalNamespace
84
- );
85
- /**
86
- * Update an existing namespace. Update the space associated with the specified ID.
87
- *
88
- * @param request - The request {@link UpdateNamespaceRequest}
89
- * @returns A Promise of Namespace
90
- */
91
- updateNamespace = (request) => this.client.fetch(
92
- {
93
- body: JSON.stringify(
94
- marshalUpdateNamespaceRequest(request, this.client.settings)
95
- ),
96
- headers: jsonContentHeaders,
97
- method: "PATCH",
98
- path: `/containers/v1beta1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/namespaces/${validatePathParam("namespaceId", request.namespaceId)}`
99
- },
100
- unmarshalNamespace
101
- );
102
- /**
103
- * Delete an existing namespace. Delete the namespace associated with the specified ID.
104
- *
105
- * @param request - The request {@link DeleteNamespaceRequest}
106
- * @returns A Promise of Namespace
107
- */
108
- deleteNamespace = (request) => this.client.fetch(
109
- {
110
- method: "DELETE",
111
- path: `/containers/v1beta1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/namespaces/${validatePathParam("namespaceId", request.namespaceId)}`
112
- },
113
- unmarshalNamespace
114
- );
115
- pageOfListContainers = (request) => this.client.fetch(
116
- {
117
- method: "GET",
118
- path: `/containers/v1beta1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/containers`,
119
- urlParams: urlParams(
120
- ["name", request.name],
121
- ["namespace_id", request.namespaceId],
122
- ["order_by", request.orderBy],
123
- ["organization_id", request.organizationId],
124
- ["page", request.page],
125
- [
126
- "page_size",
127
- request.pageSize ?? this.client.settings.defaultPageSize
128
- ],
129
- ["project_id", request.projectId]
130
- )
131
- },
132
- unmarshalListContainersResponse
133
- );
134
- /**
135
- * List all your containers. List all containers for a specified region.
136
- *
137
- * @param request - The request {@link ListContainersRequest}
138
- * @returns A Promise of ListContainersResponse
139
- */
140
- listContainers = (request) => enrichForPagination("containers", this.pageOfListContainers, request);
141
- /**
142
- * Get a container. Get the container associated with the specified ID.
143
- *
144
- * @param request - The request {@link GetContainerRequest}
145
- * @returns A Promise of Container
146
- */
147
- getContainer = (request) => this.client.fetch(
148
- {
149
- method: "GET",
150
- path: `/containers/v1beta1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/containers/${validatePathParam("containerId", request.containerId)}`
151
- },
152
- unmarshalContainer
153
- );
154
- /**
155
- * Waits for {@link Container} to be in a final state.
156
- *
157
- * @param request - The request {@link GetContainerRequest}
158
- * @param options - The waiting options
159
- * @returns A Promise of Container
160
- */
161
- waitForContainer = (request, options) => waitForResource(
162
- options?.stop ?? ((res) => Promise.resolve(
163
- !CONTAINER_TRANSIENT_STATUSES.includes(res.status)
164
- )),
165
- this.getContainer,
166
- request,
167
- options
168
- );
169
- /**
170
- * Create a new container. Create a new container in the specified region.
171
- *
172
- * @param request - The request {@link CreateContainerRequest}
173
- * @returns A Promise of Container
174
- */
175
- createContainer = (request) => this.client.fetch(
176
- {
177
- body: JSON.stringify(
178
- marshalCreateContainerRequest(request, this.client.settings)
179
- ),
180
- headers: jsonContentHeaders,
181
- method: "POST",
182
- path: `/containers/v1beta1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/containers`
183
- },
184
- unmarshalContainer
185
- );
186
- /**
187
- * Update an existing container. Update the container associated with the specified ID.
188
-
189
- When updating a container, the container is automatically redeployed to apply the changes.
190
- This behavior can be changed by setting the `redeploy` field to `false` in the request.
191
- *
192
- * @param request - The request {@link UpdateContainerRequest}
193
- * @returns A Promise of Container
194
- */
195
- updateContainer = (request) => this.client.fetch(
196
- {
197
- body: JSON.stringify(
198
- marshalUpdateContainerRequest(request, this.client.settings)
199
- ),
200
- headers: jsonContentHeaders,
201
- method: "PATCH",
202
- path: `/containers/v1beta1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/containers/${validatePathParam("containerId", request.containerId)}`
203
- },
204
- unmarshalContainer
205
- );
206
- /**
207
- * Delete a container. Delete the container associated with the specified ID.
208
- *
209
- * @param request - The request {@link DeleteContainerRequest}
210
- * @returns A Promise of Container
211
- */
212
- deleteContainer = (request) => this.client.fetch(
213
- {
214
- method: "DELETE",
215
- path: `/containers/v1beta1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/containers/${validatePathParam("containerId", request.containerId)}`
216
- },
217
- unmarshalContainer
218
- );
219
- /**
220
- * Deploy a container. Deploy a container associated with the specified ID.
221
- *
222
- * @param request - The request {@link DeployContainerRequest}
223
- * @returns A Promise of Container
224
- */
225
- deployContainer = (request) => this.client.fetch(
226
- {
227
- body: "{}",
228
- headers: jsonContentHeaders,
229
- method: "POST",
230
- path: `/containers/v1beta1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/containers/${validatePathParam("containerId", request.containerId)}/deploy`
231
- },
232
- unmarshalContainer
233
- );
234
- pageOfListCrons = (request) => this.client.fetch(
235
- {
236
- method: "GET",
237
- path: `/containers/v1beta1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/crons`,
238
- urlParams: urlParams(
239
- ["container_id", request.containerId],
240
- ["order_by", request.orderBy],
241
- ["page", request.page],
242
- [
243
- "page_size",
244
- request.pageSize ?? this.client.settings.defaultPageSize
245
- ]
246
- )
247
- },
248
- unmarshalListCronsResponse
249
- );
250
- /**
251
- * List all your crons.
252
- *
253
- * @param request - The request {@link ListCronsRequest}
254
- * @returns A Promise of ListCronsResponse
255
- */
256
- listCrons = (request) => enrichForPagination("crons", this.pageOfListCrons, request);
257
- /**
258
- * Get a cron. Get the cron associated with the specified ID.
259
- *
260
- * @param request - The request {@link GetCronRequest}
261
- * @returns A Promise of Cron
262
- */
263
- getCron = (request) => this.client.fetch(
264
- {
265
- method: "GET",
266
- path: `/containers/v1beta1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/crons/${validatePathParam("cronId", request.cronId)}`
267
- },
268
- unmarshalCron
269
- );
270
- /**
271
- * Waits for {@link Cron} to be in a final state.
272
- *
273
- * @param request - The request {@link GetCronRequest}
274
- * @param options - The waiting options
275
- * @returns A Promise of Cron
276
- */
277
- waitForCron = (request, options) => waitForResource(
278
- options?.stop ?? ((res) => Promise.resolve(
279
- !CRON_TRANSIENT_STATUSES.includes(res.status)
280
- )),
281
- this.getCron,
282
- request,
283
- options
284
- );
285
- /**
286
- * Create a new cron.
287
- *
288
- * @param request - The request {@link CreateCronRequest}
289
- * @returns A Promise of Cron
290
- */
291
- createCron = (request) => this.client.fetch(
292
- {
293
- body: JSON.stringify(
294
- marshalCreateCronRequest(request, this.client.settings)
295
- ),
296
- headers: jsonContentHeaders,
297
- method: "POST",
298
- path: `/containers/v1beta1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/crons`
299
- },
300
- unmarshalCron
301
- );
302
- /**
303
- * Update an existing cron. Update the cron associated with the specified ID.
304
- *
305
- * @param request - The request {@link UpdateCronRequest}
306
- * @returns A Promise of Cron
307
- */
308
- updateCron = (request) => this.client.fetch(
309
- {
310
- body: JSON.stringify(
311
- marshalUpdateCronRequest(request, this.client.settings)
312
- ),
313
- headers: jsonContentHeaders,
314
- method: "PATCH",
315
- path: `/containers/v1beta1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/crons/${validatePathParam("cronId", request.cronId)}`
316
- },
317
- unmarshalCron
318
- );
319
- /**
320
- * Delete an existing cron. Delete the cron associated with the specified ID.
321
- *
322
- * @param request - The request {@link DeleteCronRequest}
323
- * @returns A Promise of Cron
324
- */
325
- deleteCron = (request) => this.client.fetch(
326
- {
327
- method: "DELETE",
328
- path: `/containers/v1beta1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/crons/${validatePathParam("cronId", request.cronId)}`
329
- },
330
- unmarshalCron
331
- );
332
- pageOfListDomains = (request) => this.client.fetch(
333
- {
334
- method: "GET",
335
- path: `/containers/v1beta1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/domains`,
336
- urlParams: urlParams(
337
- ["container_id", request.containerId],
338
- ["order_by", request.orderBy],
339
- ["page", request.page],
340
- [
341
- "page_size",
342
- request.pageSize ?? this.client.settings.defaultPageSize
343
- ]
344
- )
345
- },
346
- unmarshalListDomainsResponse
347
- );
348
- /**
349
- * List all custom domains. List all custom domains in a specified region.
350
- *
351
- * @param request - The request {@link ListDomainsRequest}
352
- * @returns A Promise of ListDomainsResponse
353
- */
354
- listDomains = (request) => enrichForPagination("domains", this.pageOfListDomains, request);
355
- /**
356
- * Get a custom domain. Get a custom domain for the container with the specified ID.
357
- *
358
- * @param request - The request {@link GetDomainRequest}
359
- * @returns A Promise of Domain
360
- */
361
- getDomain = (request) => this.client.fetch(
362
- {
363
- method: "GET",
364
- path: `/containers/v1beta1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/domains/${validatePathParam("domainId", request.domainId)}`
365
- },
366
- unmarshalDomain
367
- );
368
- /**
369
- * Waits for {@link Domain} to be in a final state.
370
- *
371
- * @param request - The request {@link GetDomainRequest}
372
- * @param options - The waiting options
373
- * @returns A Promise of Domain
374
- */
375
- waitForDomain = (request, options) => waitForResource(
376
- options?.stop ?? ((res) => Promise.resolve(
377
- !DOMAIN_TRANSIENT_STATUSES.includes(res.status)
378
- )),
379
- this.getDomain,
380
- request,
381
- options
382
- );
383
- /**
384
- * Create a custom domain. Create a custom domain for the container with the specified ID.
385
- *
386
- * @param request - The request {@link CreateDomainRequest}
387
- * @returns A Promise of Domain
388
- */
389
- createDomain = (request) => this.client.fetch(
390
- {
391
- body: JSON.stringify(
392
- marshalCreateDomainRequest(request, this.client.settings)
393
- ),
394
- headers: jsonContentHeaders,
395
- method: "POST",
396
- path: `/containers/v1beta1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/domains`
397
- },
398
- unmarshalDomain
399
- );
400
- /**
401
- * Delete a custom domain. Delete the custom domain with the specific ID.
402
- *
403
- * @param request - The request {@link DeleteDomainRequest}
404
- * @returns A Promise of Domain
405
- */
406
- deleteDomain = (request) => this.client.fetch(
407
- {
408
- method: "DELETE",
409
- path: `/containers/v1beta1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/domains/${validatePathParam("domainId", request.domainId)}`
410
- },
411
- unmarshalDomain
412
- );
413
- /**
414
- * Create a new revocable token. Deprecated in favor of IAM authentication.
415
- *
416
- * @deprecated
417
- * @param request - The request {@link CreateTokenRequest}
418
- * @returns A Promise of Token
419
- */
420
- createToken = (request = {}) => this.client.fetch(
421
- {
422
- body: JSON.stringify(
423
- marshalCreateTokenRequest(request, this.client.settings)
424
- ),
425
- headers: jsonContentHeaders,
426
- method: "POST",
427
- path: `/containers/v1beta1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/tokens`
428
- },
429
- unmarshalToken
430
- );
431
- /**
432
- * Get a token. Get a token with a specified ID.
433
- *
434
- * @param request - The request {@link GetTokenRequest}
435
- * @returns A Promise of Token
436
- */
437
- getToken = (request) => this.client.fetch(
438
- {
439
- method: "GET",
440
- path: `/containers/v1beta1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/tokens/${validatePathParam("tokenId", request.tokenId)}`
441
- },
442
- unmarshalToken
443
- );
444
- /**
445
- * Waits for {@link Token} to be in a final state.
446
- *
447
- * @param request - The request {@link GetTokenRequest}
448
- * @param options - The waiting options
449
- * @returns A Promise of Token
450
- */
451
- waitForToken = (request, options) => waitForResource(
452
- options?.stop ?? ((res) => Promise.resolve(
453
- !TOKEN_TRANSIENT_STATUSES.includes(res.status)
454
- )),
455
- this.getToken,
456
- request,
457
- options
458
- );
459
- pageOfListTokens = (request = {}) => this.client.fetch(
460
- {
461
- method: "GET",
462
- path: `/containers/v1beta1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/tokens`,
463
- urlParams: urlParams(
464
- ["container_id", request.containerId],
465
- ["namespace_id", request.namespaceId],
466
- ["order_by", request.orderBy],
467
- ["page", request.page],
468
- [
469
- "page_size",
470
- request.pageSize ?? this.client.settings.defaultPageSize
471
- ]
472
- )
473
- },
474
- unmarshalListTokensResponse
475
- );
476
- /**
477
- * List all tokens. List all tokens belonging to a specified Organization or Project.
478
- *
479
- * @param request - The request {@link ListTokensRequest}
480
- * @returns A Promise of ListTokensResponse
481
- */
482
- listTokens = (request = {}) => enrichForPagination("tokens", this.pageOfListTokens, request);
483
- /**
484
- * Delete a token. Delete a token with a specified ID.
485
- *
486
- * @param request - The request {@link DeleteTokenRequest}
487
- * @returns A Promise of Token
488
- */
489
- deleteToken = (request) => this.client.fetch(
490
- {
491
- method: "DELETE",
492
- path: `/containers/v1beta1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/tokens/${validatePathParam("tokenId", request.tokenId)}`
493
- },
494
- unmarshalToken
495
- );
496
- /**
497
- * Create a trigger. Create a new trigger for a specified container.
498
- *
499
- * @param request - The request {@link CreateTriggerRequest}
500
- * @returns A Promise of Trigger
501
- */
502
- createTrigger = (request) => this.client.fetch(
503
- {
504
- body: JSON.stringify(
505
- marshalCreateTriggerRequest(request, this.client.settings)
506
- ),
507
- headers: jsonContentHeaders,
508
- method: "POST",
509
- path: `/containers/v1beta1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/triggers`
510
- },
511
- unmarshalTrigger
512
- );
513
- /**
514
- * Get a trigger. Get a trigger with a specified ID.
515
- *
516
- * @param request - The request {@link GetTriggerRequest}
517
- * @returns A Promise of Trigger
518
- */
519
- getTrigger = (request) => this.client.fetch(
520
- {
521
- method: "GET",
522
- path: `/containers/v1beta1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/triggers/${validatePathParam("triggerId", request.triggerId)}`
523
- },
524
- unmarshalTrigger
525
- );
526
- /**
527
- * Waits for {@link Trigger} to be in a final state.
528
- *
529
- * @param request - The request {@link GetTriggerRequest}
530
- * @param options - The waiting options
531
- * @returns A Promise of Trigger
532
- */
533
- waitForTrigger = (request, options) => waitForResource(
534
- options?.stop ?? ((res) => Promise.resolve(
535
- !TRIGGER_TRANSIENT_STATUSES.includes(res.status)
536
- )),
537
- this.getTrigger,
538
- request,
539
- options
540
- );
541
- pageOfListTriggers = (request = {}) => this.client.fetch(
542
- {
543
- method: "GET",
544
- path: `/containers/v1beta1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/triggers`,
545
- urlParams: urlParams(
546
- ["order_by", request.orderBy],
547
- ["page", request.page],
548
- [
549
- "page_size",
550
- request.pageSize ?? this.client.settings.defaultPageSize
551
- ],
552
- ...Object.entries(
553
- resolveOneOf([
554
- { param: "container_id", value: request.containerId },
555
- { param: "namespace_id", value: request.namespaceId },
556
- {
557
- default: this.client.settings.defaultProjectId,
558
- param: "project_id",
559
- value: request.projectId
560
- }
561
- ])
562
- )
563
- )
564
- },
565
- unmarshalListTriggersResponse
566
- );
567
- /**
568
- * List all triggers. List all triggers belonging to a specified Organization or Project.
569
- *
570
- * @param request - The request {@link ListTriggersRequest}
571
- * @returns A Promise of ListTriggersResponse
572
- */
573
- listTriggers = (request = {}) => enrichForPagination("triggers", this.pageOfListTriggers, request);
574
- /**
575
- * Update a trigger. Update a trigger with a specified ID.
576
- *
577
- * @param request - The request {@link UpdateTriggerRequest}
578
- * @returns A Promise of Trigger
579
- */
580
- updateTrigger = (request) => this.client.fetch(
581
- {
582
- body: JSON.stringify(
583
- marshalUpdateTriggerRequest(request, this.client.settings)
584
- ),
585
- headers: jsonContentHeaders,
586
- method: "PATCH",
587
- path: `/containers/v1beta1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/triggers/${validatePathParam("triggerId", request.triggerId)}`
588
- },
589
- unmarshalTrigger
590
- );
591
- /**
592
- * Delete a trigger. Delete a trigger with a specified ID.
593
- *
594
- * @param request - The request {@link DeleteTriggerRequest}
595
- * @returns A Promise of Trigger
596
- */
597
- deleteTrigger = (request) => this.client.fetch(
598
- {
599
- method: "DELETE",
600
- path: `/containers/v1beta1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/triggers/${validatePathParam("triggerId", request.triggerId)}`
601
- },
602
- unmarshalTrigger
603
- );
604
- }
605
- export {
606
- API
1
+ import { CONTAINER_TRANSIENT_STATUSES, CRON_TRANSIENT_STATUSES, DOMAIN_TRANSIENT_STATUSES, NAMESPACE_TRANSIENT_STATUSES, TOKEN_TRANSIENT_STATUSES, TRIGGER_TRANSIENT_STATUSES } from "./content.gen.js";
2
+ import { marshalCreateContainerRequest, marshalCreateCronRequest, marshalCreateDomainRequest, marshalCreateNamespaceRequest, marshalCreateTokenRequest, marshalCreateTriggerRequest, marshalUpdateContainerRequest, marshalUpdateCronRequest, marshalUpdateNamespaceRequest, marshalUpdateTriggerRequest, unmarshalContainer, unmarshalCron, unmarshalDomain, unmarshalListContainersResponse, unmarshalListCronsResponse, unmarshalListDomainsResponse, unmarshalListNamespacesResponse, unmarshalListTokensResponse, unmarshalListTriggersResponse, unmarshalNamespace, unmarshalToken, unmarshalTrigger } from "./marshalling.gen.js";
3
+ import { API, enrichForPagination, resolveOneOf, toApiLocality, urlParams, validatePathParam, waitForResource } from "@scaleway/sdk-client";
4
+ var jsonContentHeaders = { "Content-Type": "application/json; charset=utf-8" };
5
+ /**
6
+ * Serverless Containers API.
7
+
8
+ This API allows you to manage your Serverless Containers.
9
+ */
10
+ var API$1 = class extends API {
11
+ /**
12
+ * Locality of this API.
13
+ * type ∈ {'zone','region','global','unspecified'}
14
+ */
15
+ static LOCALITY = toApiLocality({ regions: [
16
+ "fr-par",
17
+ "nl-ams",
18
+ "pl-waw"
19
+ ] });
20
+ pageOfListNamespaces = (request = {}) => this.client.fetch({
21
+ method: "GET",
22
+ path: `/containers/v1beta1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/namespaces`,
23
+ urlParams: urlParams(["name", request.name], ["order_by", request.orderBy], ["organization_id", request.organizationId], ["page", request.page], ["page_size", request.pageSize ?? this.client.settings.defaultPageSize], ["project_id", request.projectId])
24
+ }, unmarshalListNamespacesResponse);
25
+ /**
26
+ * List all your namespaces. List all namespaces in a specified region.
27
+ *
28
+ * @param request - The request {@link ListNamespacesRequest}
29
+ * @returns A Promise of ListNamespacesResponse
30
+ */
31
+ listNamespaces = (request = {}) => enrichForPagination("namespaces", this.pageOfListNamespaces, request);
32
+ /**
33
+ * Get a namespace. Get the namespace associated with the specified ID.
34
+ *
35
+ * @param request - The request {@link GetNamespaceRequest}
36
+ * @returns A Promise of Namespace
37
+ */
38
+ getNamespace = (request) => this.client.fetch({
39
+ method: "GET",
40
+ path: `/containers/v1beta1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/namespaces/${validatePathParam("namespaceId", request.namespaceId)}`
41
+ }, unmarshalNamespace);
42
+ /**
43
+ * Waits for {@link Namespace} to be in a final state.
44
+ *
45
+ * @param request - The request {@link GetNamespaceRequest}
46
+ * @param options - The waiting options
47
+ * @returns A Promise of Namespace
48
+ */
49
+ waitForNamespace = (request, options) => waitForResource(options?.stop ?? ((res) => Promise.resolve(!NAMESPACE_TRANSIENT_STATUSES.includes(res.status))), this.getNamespace, request, options);
50
+ /**
51
+ * Create a new namespace. Create a new namespace in a specified region.
52
+ *
53
+ * @param request - The request {@link CreateNamespaceRequest}
54
+ * @returns A Promise of Namespace
55
+ */
56
+ createNamespace = (request) => this.client.fetch({
57
+ body: JSON.stringify(marshalCreateNamespaceRequest(request, this.client.settings)),
58
+ headers: jsonContentHeaders,
59
+ method: "POST",
60
+ path: `/containers/v1beta1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/namespaces`
61
+ }, unmarshalNamespace);
62
+ /**
63
+ * Update an existing namespace. Update the space associated with the specified ID.
64
+ *
65
+ * @param request - The request {@link UpdateNamespaceRequest}
66
+ * @returns A Promise of Namespace
67
+ */
68
+ updateNamespace = (request) => this.client.fetch({
69
+ body: JSON.stringify(marshalUpdateNamespaceRequest(request, this.client.settings)),
70
+ headers: jsonContentHeaders,
71
+ method: "PATCH",
72
+ path: `/containers/v1beta1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/namespaces/${validatePathParam("namespaceId", request.namespaceId)}`
73
+ }, unmarshalNamespace);
74
+ /**
75
+ * Delete an existing namespace. Delete the namespace associated with the specified ID.
76
+ *
77
+ * @param request - The request {@link DeleteNamespaceRequest}
78
+ * @returns A Promise of Namespace
79
+ */
80
+ deleteNamespace = (request) => this.client.fetch({
81
+ method: "DELETE",
82
+ path: `/containers/v1beta1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/namespaces/${validatePathParam("namespaceId", request.namespaceId)}`
83
+ }, unmarshalNamespace);
84
+ pageOfListContainers = (request) => this.client.fetch({
85
+ method: "GET",
86
+ path: `/containers/v1beta1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/containers`,
87
+ urlParams: urlParams(["name", request.name], ["namespace_id", request.namespaceId], ["order_by", request.orderBy], ["organization_id", request.organizationId], ["page", request.page], ["page_size", request.pageSize ?? this.client.settings.defaultPageSize], ["project_id", request.projectId])
88
+ }, unmarshalListContainersResponse);
89
+ /**
90
+ * List all your containers. List all containers for a specified region.
91
+ *
92
+ * @param request - The request {@link ListContainersRequest}
93
+ * @returns A Promise of ListContainersResponse
94
+ */
95
+ listContainers = (request) => enrichForPagination("containers", this.pageOfListContainers, request);
96
+ /**
97
+ * Get a container. Get the container associated with the specified ID.
98
+ *
99
+ * @param request - The request {@link GetContainerRequest}
100
+ * @returns A Promise of Container
101
+ */
102
+ getContainer = (request) => this.client.fetch({
103
+ method: "GET",
104
+ path: `/containers/v1beta1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/containers/${validatePathParam("containerId", request.containerId)}`
105
+ }, unmarshalContainer);
106
+ /**
107
+ * Waits for {@link Container} to be in a final state.
108
+ *
109
+ * @param request - The request {@link GetContainerRequest}
110
+ * @param options - The waiting options
111
+ * @returns A Promise of Container
112
+ */
113
+ waitForContainer = (request, options) => waitForResource(options?.stop ?? ((res) => Promise.resolve(!CONTAINER_TRANSIENT_STATUSES.includes(res.status))), this.getContainer, request, options);
114
+ /**
115
+ * Create a new container. Create a new container in the specified region.
116
+ *
117
+ * @param request - The request {@link CreateContainerRequest}
118
+ * @returns A Promise of Container
119
+ */
120
+ createContainer = (request) => this.client.fetch({
121
+ body: JSON.stringify(marshalCreateContainerRequest(request, this.client.settings)),
122
+ headers: jsonContentHeaders,
123
+ method: "POST",
124
+ path: `/containers/v1beta1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/containers`
125
+ }, unmarshalContainer);
126
+ /**
127
+ * Update an existing container. Update the container associated with the specified ID.
128
+
129
+ When updating a container, the container is automatically redeployed to apply the changes.
130
+ This behavior can be changed by setting the `redeploy` field to `false` in the request.
131
+ *
132
+ * @param request - The request {@link UpdateContainerRequest}
133
+ * @returns A Promise of Container
134
+ */
135
+ updateContainer = (request) => this.client.fetch({
136
+ body: JSON.stringify(marshalUpdateContainerRequest(request, this.client.settings)),
137
+ headers: jsonContentHeaders,
138
+ method: "PATCH",
139
+ path: `/containers/v1beta1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/containers/${validatePathParam("containerId", request.containerId)}`
140
+ }, unmarshalContainer);
141
+ /**
142
+ * Delete a container. Delete the container associated with the specified ID.
143
+ *
144
+ * @param request - The request {@link DeleteContainerRequest}
145
+ * @returns A Promise of Container
146
+ */
147
+ deleteContainer = (request) => this.client.fetch({
148
+ method: "DELETE",
149
+ path: `/containers/v1beta1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/containers/${validatePathParam("containerId", request.containerId)}`
150
+ }, unmarshalContainer);
151
+ /**
152
+ * Deploy a container. Deploy a container associated with the specified ID.
153
+ *
154
+ * @param request - The request {@link DeployContainerRequest}
155
+ * @returns A Promise of Container
156
+ */
157
+ deployContainer = (request) => this.client.fetch({
158
+ body: "{}",
159
+ headers: jsonContentHeaders,
160
+ method: "POST",
161
+ path: `/containers/v1beta1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/containers/${validatePathParam("containerId", request.containerId)}/deploy`
162
+ }, unmarshalContainer);
163
+ pageOfListCrons = (request) => this.client.fetch({
164
+ method: "GET",
165
+ path: `/containers/v1beta1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/crons`,
166
+ urlParams: urlParams(["container_id", request.containerId], ["order_by", request.orderBy], ["page", request.page], ["page_size", request.pageSize ?? this.client.settings.defaultPageSize])
167
+ }, unmarshalListCronsResponse);
168
+ /**
169
+ * List all your crons.
170
+ *
171
+ * @param request - The request {@link ListCronsRequest}
172
+ * @returns A Promise of ListCronsResponse
173
+ */
174
+ listCrons = (request) => enrichForPagination("crons", this.pageOfListCrons, request);
175
+ /**
176
+ * Get a cron. Get the cron associated with the specified ID.
177
+ *
178
+ * @param request - The request {@link GetCronRequest}
179
+ * @returns A Promise of Cron
180
+ */
181
+ getCron = (request) => this.client.fetch({
182
+ method: "GET",
183
+ path: `/containers/v1beta1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/crons/${validatePathParam("cronId", request.cronId)}`
184
+ }, unmarshalCron);
185
+ /**
186
+ * Waits for {@link Cron} to be in a final state.
187
+ *
188
+ * @param request - The request {@link GetCronRequest}
189
+ * @param options - The waiting options
190
+ * @returns A Promise of Cron
191
+ */
192
+ waitForCron = (request, options) => waitForResource(options?.stop ?? ((res) => Promise.resolve(!CRON_TRANSIENT_STATUSES.includes(res.status))), this.getCron, request, options);
193
+ /**
194
+ * Create a new cron.
195
+ *
196
+ * @param request - The request {@link CreateCronRequest}
197
+ * @returns A Promise of Cron
198
+ */
199
+ createCron = (request) => this.client.fetch({
200
+ body: JSON.stringify(marshalCreateCronRequest(request, this.client.settings)),
201
+ headers: jsonContentHeaders,
202
+ method: "POST",
203
+ path: `/containers/v1beta1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/crons`
204
+ }, unmarshalCron);
205
+ /**
206
+ * Update an existing cron. Update the cron associated with the specified ID.
207
+ *
208
+ * @param request - The request {@link UpdateCronRequest}
209
+ * @returns A Promise of Cron
210
+ */
211
+ updateCron = (request) => this.client.fetch({
212
+ body: JSON.stringify(marshalUpdateCronRequest(request, this.client.settings)),
213
+ headers: jsonContentHeaders,
214
+ method: "PATCH",
215
+ path: `/containers/v1beta1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/crons/${validatePathParam("cronId", request.cronId)}`
216
+ }, unmarshalCron);
217
+ /**
218
+ * Delete an existing cron. Delete the cron associated with the specified ID.
219
+ *
220
+ * @param request - The request {@link DeleteCronRequest}
221
+ * @returns A Promise of Cron
222
+ */
223
+ deleteCron = (request) => this.client.fetch({
224
+ method: "DELETE",
225
+ path: `/containers/v1beta1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/crons/${validatePathParam("cronId", request.cronId)}`
226
+ }, unmarshalCron);
227
+ pageOfListDomains = (request) => this.client.fetch({
228
+ method: "GET",
229
+ path: `/containers/v1beta1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/domains`,
230
+ urlParams: urlParams(["container_id", request.containerId], ["order_by", request.orderBy], ["page", request.page], ["page_size", request.pageSize ?? this.client.settings.defaultPageSize])
231
+ }, unmarshalListDomainsResponse);
232
+ /**
233
+ * List all custom domains. List all custom domains in a specified region.
234
+ *
235
+ * @param request - The request {@link ListDomainsRequest}
236
+ * @returns A Promise of ListDomainsResponse
237
+ */
238
+ listDomains = (request) => enrichForPagination("domains", this.pageOfListDomains, request);
239
+ /**
240
+ * Get a custom domain. Get a custom domain for the container with the specified ID.
241
+ *
242
+ * @param request - The request {@link GetDomainRequest}
243
+ * @returns A Promise of Domain
244
+ */
245
+ getDomain = (request) => this.client.fetch({
246
+ method: "GET",
247
+ path: `/containers/v1beta1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/domains/${validatePathParam("domainId", request.domainId)}`
248
+ }, unmarshalDomain);
249
+ /**
250
+ * Waits for {@link Domain} to be in a final state.
251
+ *
252
+ * @param request - The request {@link GetDomainRequest}
253
+ * @param options - The waiting options
254
+ * @returns A Promise of Domain
255
+ */
256
+ waitForDomain = (request, options) => waitForResource(options?.stop ?? ((res) => Promise.resolve(!DOMAIN_TRANSIENT_STATUSES.includes(res.status))), this.getDomain, request, options);
257
+ /**
258
+ * Create a custom domain. Create a custom domain for the container with the specified ID.
259
+ *
260
+ * @param request - The request {@link CreateDomainRequest}
261
+ * @returns A Promise of Domain
262
+ */
263
+ createDomain = (request) => this.client.fetch({
264
+ body: JSON.stringify(marshalCreateDomainRequest(request, this.client.settings)),
265
+ headers: jsonContentHeaders,
266
+ method: "POST",
267
+ path: `/containers/v1beta1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/domains`
268
+ }, unmarshalDomain);
269
+ /**
270
+ * Delete a custom domain. Delete the custom domain with the specific ID.
271
+ *
272
+ * @param request - The request {@link DeleteDomainRequest}
273
+ * @returns A Promise of Domain
274
+ */
275
+ deleteDomain = (request) => this.client.fetch({
276
+ method: "DELETE",
277
+ path: `/containers/v1beta1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/domains/${validatePathParam("domainId", request.domainId)}`
278
+ }, unmarshalDomain);
279
+ /**
280
+ * Create a new revocable token. Deprecated in favor of IAM authentication.
281
+ *
282
+ * @deprecated
283
+ * @param request - The request {@link CreateTokenRequest}
284
+ * @returns A Promise of Token
285
+ */
286
+ createToken = (request = {}) => this.client.fetch({
287
+ body: JSON.stringify(marshalCreateTokenRequest(request, this.client.settings)),
288
+ headers: jsonContentHeaders,
289
+ method: "POST",
290
+ path: `/containers/v1beta1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/tokens`
291
+ }, unmarshalToken);
292
+ /**
293
+ * Get a token. Get a token with a specified ID.
294
+ *
295
+ * @param request - The request {@link GetTokenRequest}
296
+ * @returns A Promise of Token
297
+ */
298
+ getToken = (request) => this.client.fetch({
299
+ method: "GET",
300
+ path: `/containers/v1beta1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/tokens/${validatePathParam("tokenId", request.tokenId)}`
301
+ }, unmarshalToken);
302
+ /**
303
+ * Waits for {@link Token} to be in a final state.
304
+ *
305
+ * @param request - The request {@link GetTokenRequest}
306
+ * @param options - The waiting options
307
+ * @returns A Promise of Token
308
+ */
309
+ waitForToken = (request, options) => waitForResource(options?.stop ?? ((res) => Promise.resolve(!TOKEN_TRANSIENT_STATUSES.includes(res.status))), this.getToken, request, options);
310
+ pageOfListTokens = (request = {}) => this.client.fetch({
311
+ method: "GET",
312
+ path: `/containers/v1beta1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/tokens`,
313
+ urlParams: urlParams(["container_id", request.containerId], ["namespace_id", request.namespaceId], ["order_by", request.orderBy], ["page", request.page], ["page_size", request.pageSize ?? this.client.settings.defaultPageSize])
314
+ }, unmarshalListTokensResponse);
315
+ /**
316
+ * List all tokens. List all tokens belonging to a specified Organization or Project.
317
+ *
318
+ * @param request - The request {@link ListTokensRequest}
319
+ * @returns A Promise of ListTokensResponse
320
+ */
321
+ listTokens = (request = {}) => enrichForPagination("tokens", this.pageOfListTokens, request);
322
+ /**
323
+ * Delete a token. Delete a token with a specified ID.
324
+ *
325
+ * @param request - The request {@link DeleteTokenRequest}
326
+ * @returns A Promise of Token
327
+ */
328
+ deleteToken = (request) => this.client.fetch({
329
+ method: "DELETE",
330
+ path: `/containers/v1beta1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/tokens/${validatePathParam("tokenId", request.tokenId)}`
331
+ }, unmarshalToken);
332
+ /**
333
+ * Create a trigger. Create a new trigger for a specified container.
334
+ *
335
+ * @param request - The request {@link CreateTriggerRequest}
336
+ * @returns A Promise of Trigger
337
+ */
338
+ createTrigger = (request) => this.client.fetch({
339
+ body: JSON.stringify(marshalCreateTriggerRequest(request, this.client.settings)),
340
+ headers: jsonContentHeaders,
341
+ method: "POST",
342
+ path: `/containers/v1beta1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/triggers`
343
+ }, unmarshalTrigger);
344
+ /**
345
+ * Get a trigger. Get a trigger with a specified ID.
346
+ *
347
+ * @param request - The request {@link GetTriggerRequest}
348
+ * @returns A Promise of Trigger
349
+ */
350
+ getTrigger = (request) => this.client.fetch({
351
+ method: "GET",
352
+ path: `/containers/v1beta1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/triggers/${validatePathParam("triggerId", request.triggerId)}`
353
+ }, unmarshalTrigger);
354
+ /**
355
+ * Waits for {@link Trigger} to be in a final state.
356
+ *
357
+ * @param request - The request {@link GetTriggerRequest}
358
+ * @param options - The waiting options
359
+ * @returns A Promise of Trigger
360
+ */
361
+ waitForTrigger = (request, options) => waitForResource(options?.stop ?? ((res) => Promise.resolve(!TRIGGER_TRANSIENT_STATUSES.includes(res.status))), this.getTrigger, request, options);
362
+ pageOfListTriggers = (request = {}) => this.client.fetch({
363
+ method: "GET",
364
+ path: `/containers/v1beta1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/triggers`,
365
+ urlParams: urlParams(["order_by", request.orderBy], ["page", request.page], ["page_size", request.pageSize ?? this.client.settings.defaultPageSize], ...Object.entries(resolveOneOf([
366
+ {
367
+ param: "container_id",
368
+ value: request.containerId
369
+ },
370
+ {
371
+ param: "namespace_id",
372
+ value: request.namespaceId
373
+ },
374
+ {
375
+ default: this.client.settings.defaultProjectId,
376
+ param: "project_id",
377
+ value: request.projectId
378
+ }
379
+ ])))
380
+ }, unmarshalListTriggersResponse);
381
+ /**
382
+ * List all triggers. List all triggers belonging to a specified Organization or Project.
383
+ *
384
+ * @param request - The request {@link ListTriggersRequest}
385
+ * @returns A Promise of ListTriggersResponse
386
+ */
387
+ listTriggers = (request = {}) => enrichForPagination("triggers", this.pageOfListTriggers, request);
388
+ /**
389
+ * Update a trigger. Update a trigger with a specified ID.
390
+ *
391
+ * @param request - The request {@link UpdateTriggerRequest}
392
+ * @returns A Promise of Trigger
393
+ */
394
+ updateTrigger = (request) => this.client.fetch({
395
+ body: JSON.stringify(marshalUpdateTriggerRequest(request, this.client.settings)),
396
+ headers: jsonContentHeaders,
397
+ method: "PATCH",
398
+ path: `/containers/v1beta1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/triggers/${validatePathParam("triggerId", request.triggerId)}`
399
+ }, unmarshalTrigger);
400
+ /**
401
+ * Delete a trigger. Delete a trigger with a specified ID.
402
+ *
403
+ * @param request - The request {@link DeleteTriggerRequest}
404
+ * @returns A Promise of Trigger
405
+ */
406
+ deleteTrigger = (request) => this.client.fetch({
407
+ method: "DELETE",
408
+ path: `/containers/v1beta1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/triggers/${validatePathParam("triggerId", request.triggerId)}`
409
+ }, unmarshalTrigger);
607
410
  };
411
+ export { API$1 as API };