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