@scaleway/sdk-function 1.2.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.
@@ -0,0 +1,642 @@
1
+ import { API as API$1, urlParams, validatePathParam, enrichForPagination, waitForResource, resolveOneOf } from "@scaleway/sdk-client";
2
+ import { NAMESPACE_TRANSIENT_STATUSES, FUNCTION_TRANSIENT_STATUSES, CRON_TRANSIENT_STATUSES, DOMAIN_TRANSIENT_STATUSES, TOKEN_TRANSIENT_STATUSES, TRIGGER_TRANSIENT_STATUSES } from "./content.gen.js";
3
+ import { unmarshalListNamespacesResponse, unmarshalNamespace, marshalCreateNamespaceRequest, marshalUpdateNamespaceRequest, unmarshalListFunctionsResponse, unmarshalFunction, marshalCreateFunctionRequest, marshalUpdateFunctionRequest, unmarshalListFunctionRuntimesResponse, unmarshalUploadURL, unmarshalDownloadURL, 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
+ /** Lists the available regions of the API. */
9
+ static LOCALITIES = [
10
+ "fr-par",
11
+ "nl-ams",
12
+ "pl-waw"
13
+ ];
14
+ pageOfListNamespaces = (request = {}) => this.client.fetch(
15
+ {
16
+ method: "GET",
17
+ path: `/functions/v1beta1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/namespaces`,
18
+ urlParams: urlParams(
19
+ ["name", request.name],
20
+ ["order_by", request.orderBy],
21
+ ["organization_id", request.organizationId],
22
+ ["page", request.page],
23
+ [
24
+ "page_size",
25
+ request.pageSize ?? this.client.settings.defaultPageSize
26
+ ],
27
+ ["project_id", request.projectId]
28
+ )
29
+ },
30
+ unmarshalListNamespacesResponse
31
+ );
32
+ /**
33
+ * List all your namespaces. List all existing namespaces in the specified region.
34
+ *
35
+ * @param request - The request {@link ListNamespacesRequest}
36
+ * @returns A Promise of ListNamespacesResponse
37
+ */
38
+ listNamespaces = (request = {}) => enrichForPagination("namespaces", this.pageOfListNamespaces, request);
39
+ /**
40
+ * Get a namespace. Get the namespace associated with the specified ID.
41
+ *
42
+ * @param request - The request {@link GetNamespaceRequest}
43
+ * @returns A Promise of Namespace
44
+ */
45
+ getNamespace = (request) => this.client.fetch(
46
+ {
47
+ method: "GET",
48
+ path: `/functions/v1beta1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/namespaces/${validatePathParam("namespaceId", request.namespaceId)}`
49
+ },
50
+ unmarshalNamespace
51
+ );
52
+ /**
53
+ * Waits for {@link Namespace} to be in a final state.
54
+ *
55
+ * @param request - The request {@link GetNamespaceRequest}
56
+ * @param options - The waiting options
57
+ * @returns A Promise of Namespace
58
+ */
59
+ waitForNamespace = (request, options) => waitForResource(
60
+ options?.stop ?? ((res) => Promise.resolve(
61
+ !NAMESPACE_TRANSIENT_STATUSES.includes(res.status)
62
+ )),
63
+ this.getNamespace,
64
+ request,
65
+ options
66
+ );
67
+ /**
68
+ * Create a new namespace. Create a new namespace in a specified Organization or Project.
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: `/functions/v1beta1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/namespaces`
81
+ },
82
+ unmarshalNamespace
83
+ );
84
+ /**
85
+ * Update an existing namespace. Update the namespace 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: `/functions/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: `/functions/v1beta1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/namespaces/${validatePathParam("namespaceId", request.namespaceId)}`
111
+ },
112
+ unmarshalNamespace
113
+ );
114
+ pageOfListFunctions = (request) => this.client.fetch(
115
+ {
116
+ method: "GET",
117
+ path: `/functions/v1beta1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/functions`,
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
+ [
125
+ "page_size",
126
+ request.pageSize ?? this.client.settings.defaultPageSize
127
+ ],
128
+ ["project_id", request.projectId]
129
+ )
130
+ },
131
+ unmarshalListFunctionsResponse
132
+ );
133
+ /**
134
+ * List all your functions.
135
+ *
136
+ * @param request - The request {@link ListFunctionsRequest}
137
+ * @returns A Promise of ListFunctionsResponse
138
+ */
139
+ listFunctions = (request) => enrichForPagination("functions", this.pageOfListFunctions, request);
140
+ /**
141
+ * Get a function. Get the function associated with the specified ID.
142
+ *
143
+ * @param request - The request {@link GetFunctionRequest}
144
+ * @returns A Promise of Function
145
+ */
146
+ getFunction = (request) => this.client.fetch(
147
+ {
148
+ method: "GET",
149
+ path: `/functions/v1beta1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/functions/${validatePathParam("functionId", request.functionId)}`
150
+ },
151
+ unmarshalFunction
152
+ );
153
+ /**
154
+ * Waits for {@link Function} to be in a final state.
155
+ *
156
+ * @param request - The request {@link GetFunctionRequest}
157
+ * @param options - The waiting options
158
+ * @returns A Promise of Function
159
+ */
160
+ waitForFunction = (request, options) => waitForResource(
161
+ options?.stop ?? ((res) => Promise.resolve(
162
+ !FUNCTION_TRANSIENT_STATUSES.includes(res.status)
163
+ )),
164
+ this.getFunction,
165
+ request,
166
+ options
167
+ );
168
+ /**
169
+ * Create a new function. Create a new function in the specified region for a specified Organization or Project.
170
+ *
171
+ * @param request - The request {@link CreateFunctionRequest}
172
+ * @returns A Promise of Function
173
+ */
174
+ createFunction = (request) => this.client.fetch(
175
+ {
176
+ body: JSON.stringify(
177
+ marshalCreateFunctionRequest(request, this.client.settings)
178
+ ),
179
+ headers: jsonContentHeaders,
180
+ method: "POST",
181
+ path: `/functions/v1beta1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/functions`
182
+ },
183
+ unmarshalFunction
184
+ );
185
+ /**
186
+ * Update an existing function. Update the function associated with the specified ID.
187
+ *
188
+ * @param request - The request {@link UpdateFunctionRequest}
189
+ * @returns A Promise of Function
190
+ */
191
+ updateFunction = (request) => this.client.fetch(
192
+ {
193
+ body: JSON.stringify(
194
+ marshalUpdateFunctionRequest(request, this.client.settings)
195
+ ),
196
+ headers: jsonContentHeaders,
197
+ method: "PATCH",
198
+ path: `/functions/v1beta1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/functions/${validatePathParam("functionId", request.functionId)}`
199
+ },
200
+ unmarshalFunction
201
+ );
202
+ /**
203
+ * Delete a function. Delete the function associated with the specified ID.
204
+ *
205
+ * @param request - The request {@link DeleteFunctionRequest}
206
+ * @returns A Promise of Function
207
+ */
208
+ deleteFunction = (request) => this.client.fetch(
209
+ {
210
+ method: "DELETE",
211
+ path: `/functions/v1beta1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/functions/${validatePathParam("functionId", request.functionId)}`
212
+ },
213
+ unmarshalFunction
214
+ );
215
+ /**
216
+ * Deploy a function. Deploy a function associated with the specified ID.
217
+ *
218
+ * @param request - The request {@link DeployFunctionRequest}
219
+ * @returns A Promise of Function
220
+ */
221
+ deployFunction = (request) => this.client.fetch(
222
+ {
223
+ body: "{}",
224
+ headers: jsonContentHeaders,
225
+ method: "POST",
226
+ path: `/functions/v1beta1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/functions/${validatePathParam("functionId", request.functionId)}/deploy`
227
+ },
228
+ unmarshalFunction
229
+ );
230
+ /**
231
+ * List function runtimes. List available function runtimes.
232
+ *
233
+ * @param request - The request {@link ListFunctionRuntimesRequest}
234
+ * @returns A Promise of ListFunctionRuntimesResponse
235
+ */
236
+ listFunctionRuntimes = (request = {}) => this.client.fetch(
237
+ {
238
+ method: "GET",
239
+ path: `/functions/v1beta1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/runtimes`
240
+ },
241
+ unmarshalListFunctionRuntimesResponse
242
+ );
243
+ /**
244
+ * Get an upload URL of a function. Get an upload URL of a function associated with the specified ID.
245
+ *
246
+ * @param request - The request {@link GetFunctionUploadURLRequest}
247
+ * @returns A Promise of UploadURL
248
+ */
249
+ getFunctionUploadURL = (request) => this.client.fetch(
250
+ {
251
+ method: "GET",
252
+ path: `/functions/v1beta1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/functions/${validatePathParam("functionId", request.functionId)}/upload-url`,
253
+ urlParams: urlParams(["content_length", request.contentLength])
254
+ },
255
+ unmarshalUploadURL
256
+ );
257
+ /**
258
+ * Get a download URL of a function. Get a download URL for a function associated with the specified ID.
259
+ *
260
+ * @param request - The request {@link GetFunctionDownloadURLRequest}
261
+ * @returns A Promise of DownloadURL
262
+ */
263
+ getFunctionDownloadURL = (request) => this.client.fetch(
264
+ {
265
+ method: "GET",
266
+ path: `/functions/v1beta1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/functions/${validatePathParam("functionId", request.functionId)}/download-url`
267
+ },
268
+ unmarshalDownloadURL
269
+ );
270
+ pageOfListCrons = (request) => this.client.fetch(
271
+ {
272
+ method: "GET",
273
+ path: `/functions/v1beta1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/crons`,
274
+ urlParams: urlParams(
275
+ ["function_id", request.functionId],
276
+ ["order_by", request.orderBy],
277
+ ["page", request.page],
278
+ [
279
+ "page_size",
280
+ request.pageSize ?? this.client.settings.defaultPageSize
281
+ ]
282
+ )
283
+ },
284
+ unmarshalListCronsResponse
285
+ );
286
+ /**
287
+ * List all crons. List all the cronjobs in a specified region.
288
+ *
289
+ * @param request - The request {@link ListCronsRequest}
290
+ * @returns A Promise of ListCronsResponse
291
+ */
292
+ listCrons = (request) => enrichForPagination("crons", this.pageOfListCrons, request);
293
+ /**
294
+ * Get a cron. Get the cron associated with the specified ID.
295
+ *
296
+ * @param request - The request {@link GetCronRequest}
297
+ * @returns A Promise of Cron
298
+ */
299
+ getCron = (request) => this.client.fetch(
300
+ {
301
+ method: "GET",
302
+ path: `/functions/v1beta1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/crons/${validatePathParam("cronId", request.cronId)}`
303
+ },
304
+ unmarshalCron
305
+ );
306
+ /**
307
+ * Waits for {@link Cron} to be in a final state.
308
+ *
309
+ * @param request - The request {@link GetCronRequest}
310
+ * @param options - The waiting options
311
+ * @returns A Promise of Cron
312
+ */
313
+ waitForCron = (request, options) => waitForResource(
314
+ options?.stop ?? ((res) => Promise.resolve(
315
+ !CRON_TRANSIENT_STATUSES.includes(res.status)
316
+ )),
317
+ this.getCron,
318
+ request,
319
+ options
320
+ );
321
+ /**
322
+ * Create a new cron. Create a new cronjob for a function with the specified ID.
323
+ *
324
+ * @param request - The request {@link CreateCronRequest}
325
+ * @returns A Promise of Cron
326
+ */
327
+ createCron = (request) => this.client.fetch(
328
+ {
329
+ body: JSON.stringify(
330
+ marshalCreateCronRequest(request, this.client.settings)
331
+ ),
332
+ headers: jsonContentHeaders,
333
+ method: "POST",
334
+ path: `/functions/v1beta1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/crons`
335
+ },
336
+ unmarshalCron
337
+ );
338
+ /**
339
+ * Update an existing cron. Update the cron associated with the specified ID.
340
+ *
341
+ * @param request - The request {@link UpdateCronRequest}
342
+ * @returns A Promise of Cron
343
+ */
344
+ updateCron = (request) => this.client.fetch(
345
+ {
346
+ body: JSON.stringify(
347
+ marshalUpdateCronRequest(request, this.client.settings)
348
+ ),
349
+ headers: jsonContentHeaders,
350
+ method: "PATCH",
351
+ path: `/functions/v1beta1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/crons/${validatePathParam("cronId", request.cronId)}`
352
+ },
353
+ unmarshalCron
354
+ );
355
+ /**
356
+ * Delete an existing cron. Delete the cron associated with the specified ID.
357
+ *
358
+ * @param request - The request {@link DeleteCronRequest}
359
+ * @returns A Promise of Cron
360
+ */
361
+ deleteCron = (request) => this.client.fetch(
362
+ {
363
+ method: "DELETE",
364
+ path: `/functions/v1beta1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/crons/${validatePathParam("cronId", request.cronId)}`
365
+ },
366
+ unmarshalCron
367
+ );
368
+ pageOfListDomains = (request) => this.client.fetch(
369
+ {
370
+ method: "GET",
371
+ path: `/functions/v1beta1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/domains`,
372
+ urlParams: urlParams(
373
+ ["function_id", request.functionId],
374
+ ["order_by", request.orderBy],
375
+ ["page", request.page],
376
+ [
377
+ "page_size",
378
+ request.pageSize ?? this.client.settings.defaultPageSize
379
+ ]
380
+ )
381
+ },
382
+ unmarshalListDomainsResponse
383
+ );
384
+ /**
385
+ * List all domain name bindings. List all domain name bindings in a specified region.
386
+ *
387
+ * @param request - The request {@link ListDomainsRequest}
388
+ * @returns A Promise of ListDomainsResponse
389
+ */
390
+ listDomains = (request) => enrichForPagination("domains", this.pageOfListDomains, request);
391
+ /**
392
+ * Get a domain name binding. Get a domain name binding for the function with the specified ID.
393
+ *
394
+ * @param request - The request {@link GetDomainRequest}
395
+ * @returns A Promise of Domain
396
+ */
397
+ getDomain = (request) => this.client.fetch(
398
+ {
399
+ method: "GET",
400
+ path: `/functions/v1beta1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/domains/${validatePathParam("domainId", request.domainId)}`
401
+ },
402
+ unmarshalDomain
403
+ );
404
+ /**
405
+ * Waits for {@link Domain} to be in a final state.
406
+ *
407
+ * @param request - The request {@link GetDomainRequest}
408
+ * @param options - The waiting options
409
+ * @returns A Promise of Domain
410
+ */
411
+ waitForDomain = (request, options) => waitForResource(
412
+ options?.stop ?? ((res) => Promise.resolve(
413
+ !DOMAIN_TRANSIENT_STATUSES.includes(res.status)
414
+ )),
415
+ this.getDomain,
416
+ request,
417
+ options
418
+ );
419
+ /**
420
+ * Create a domain name binding. Create a domain name binding for the function with the specified ID.
421
+ *
422
+ * @param request - The request {@link CreateDomainRequest}
423
+ * @returns A Promise of Domain
424
+ */
425
+ createDomain = (request) => this.client.fetch(
426
+ {
427
+ body: JSON.stringify(
428
+ marshalCreateDomainRequest(request, this.client.settings)
429
+ ),
430
+ headers: jsonContentHeaders,
431
+ method: "POST",
432
+ path: `/functions/v1beta1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/domains`
433
+ },
434
+ unmarshalDomain
435
+ );
436
+ /**
437
+ * Delete a domain name binding. Delete a domain name binding for the function with the specified ID.
438
+ *
439
+ * @param request - The request {@link DeleteDomainRequest}
440
+ * @returns A Promise of Domain
441
+ */
442
+ deleteDomain = (request) => this.client.fetch(
443
+ {
444
+ method: "DELETE",
445
+ path: `/functions/v1beta1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/domains/${validatePathParam("domainId", request.domainId)}`
446
+ },
447
+ unmarshalDomain
448
+ );
449
+ /**
450
+ * Create a new revocable token.
451
+ *
452
+ * @param request - The request {@link CreateTokenRequest}
453
+ * @returns A Promise of Token
454
+ */
455
+ createToken = (request = {}) => this.client.fetch(
456
+ {
457
+ body: JSON.stringify(
458
+ marshalCreateTokenRequest(request, this.client.settings)
459
+ ),
460
+ headers: jsonContentHeaders,
461
+ method: "POST",
462
+ path: `/functions/v1beta1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/tokens`
463
+ },
464
+ unmarshalToken
465
+ );
466
+ /**
467
+ * Get a token.
468
+ *
469
+ * @param request - The request {@link GetTokenRequest}
470
+ * @returns A Promise of Token
471
+ */
472
+ getToken = (request) => this.client.fetch(
473
+ {
474
+ method: "GET",
475
+ path: `/functions/v1beta1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/tokens/${validatePathParam("tokenId", request.tokenId)}`
476
+ },
477
+ unmarshalToken
478
+ );
479
+ /**
480
+ * Waits for {@link Token} to be in a final state.
481
+ *
482
+ * @param request - The request {@link GetTokenRequest}
483
+ * @param options - The waiting options
484
+ * @returns A Promise of Token
485
+ */
486
+ waitForToken = (request, options) => waitForResource(
487
+ options?.stop ?? ((res) => Promise.resolve(
488
+ !TOKEN_TRANSIENT_STATUSES.includes(res.status)
489
+ )),
490
+ this.getToken,
491
+ request,
492
+ options
493
+ );
494
+ pageOfListTokens = (request = {}) => this.client.fetch(
495
+ {
496
+ method: "GET",
497
+ path: `/functions/v1beta1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/tokens`,
498
+ urlParams: urlParams(
499
+ ["function_id", request.functionId],
500
+ ["namespace_id", request.namespaceId],
501
+ ["order_by", request.orderBy],
502
+ ["page", request.page],
503
+ [
504
+ "page_size",
505
+ request.pageSize ?? this.client.settings.defaultPageSize
506
+ ]
507
+ )
508
+ },
509
+ unmarshalListTokensResponse
510
+ );
511
+ /**
512
+ * List all tokens.
513
+ *
514
+ * @param request - The request {@link ListTokensRequest}
515
+ * @returns A Promise of ListTokensResponse
516
+ */
517
+ listTokens = (request = {}) => enrichForPagination("tokens", this.pageOfListTokens, request);
518
+ /**
519
+ * Delete a token.
520
+ *
521
+ * @param request - The request {@link DeleteTokenRequest}
522
+ * @returns A Promise of Token
523
+ */
524
+ deleteToken = (request) => this.client.fetch(
525
+ {
526
+ method: "DELETE",
527
+ path: `/functions/v1beta1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/tokens/${validatePathParam("tokenId", request.tokenId)}`
528
+ },
529
+ unmarshalToken
530
+ );
531
+ /**
532
+ * Create a trigger. Create a new trigger for a specified function.
533
+ *
534
+ * @param request - The request {@link CreateTriggerRequest}
535
+ * @returns A Promise of Trigger
536
+ */
537
+ createTrigger = (request) => this.client.fetch(
538
+ {
539
+ body: JSON.stringify(
540
+ marshalCreateTriggerRequest(request, this.client.settings)
541
+ ),
542
+ headers: jsonContentHeaders,
543
+ method: "POST",
544
+ path: `/functions/v1beta1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/triggers`
545
+ },
546
+ unmarshalTrigger
547
+ );
548
+ /**
549
+ * Get a trigger. Get a trigger with a specified ID.
550
+ *
551
+ * @param request - The request {@link GetTriggerRequest}
552
+ * @returns A Promise of Trigger
553
+ */
554
+ getTrigger = (request) => this.client.fetch(
555
+ {
556
+ method: "GET",
557
+ path: `/functions/v1beta1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/triggers/${validatePathParam("triggerId", request.triggerId)}`
558
+ },
559
+ unmarshalTrigger
560
+ );
561
+ /**
562
+ * Waits for {@link Trigger} to be in a final state.
563
+ *
564
+ * @param request - The request {@link GetTriggerRequest}
565
+ * @param options - The waiting options
566
+ * @returns A Promise of Trigger
567
+ */
568
+ waitForTrigger = (request, options) => waitForResource(
569
+ options?.stop ?? ((res) => Promise.resolve(
570
+ !TRIGGER_TRANSIENT_STATUSES.includes(res.status)
571
+ )),
572
+ this.getTrigger,
573
+ request,
574
+ options
575
+ );
576
+ pageOfListTriggers = (request = {}) => this.client.fetch(
577
+ {
578
+ method: "GET",
579
+ path: `/functions/v1beta1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/triggers`,
580
+ urlParams: urlParams(
581
+ ["order_by", request.orderBy],
582
+ ["page", request.page],
583
+ [
584
+ "page_size",
585
+ request.pageSize ?? this.client.settings.defaultPageSize
586
+ ],
587
+ ...Object.entries(
588
+ resolveOneOf([
589
+ { param: "function_id", value: request.functionId },
590
+ { param: "namespace_id", value: request.namespaceId },
591
+ {
592
+ default: this.client.settings.defaultProjectId,
593
+ param: "project_id",
594
+ value: request.projectId
595
+ }
596
+ ])
597
+ )
598
+ )
599
+ },
600
+ unmarshalListTriggersResponse
601
+ );
602
+ /**
603
+ * List all triggers. List all triggers belonging to a specified Organization or Project.
604
+ *
605
+ * @param request - The request {@link ListTriggersRequest}
606
+ * @returns A Promise of ListTriggersResponse
607
+ */
608
+ listTriggers = (request = {}) => enrichForPagination("triggers", this.pageOfListTriggers, request);
609
+ /**
610
+ * Update a trigger. Update a trigger with a specified ID.
611
+ *
612
+ * @param request - The request {@link UpdateTriggerRequest}
613
+ * @returns A Promise of Trigger
614
+ */
615
+ updateTrigger = (request) => this.client.fetch(
616
+ {
617
+ body: JSON.stringify(
618
+ marshalUpdateTriggerRequest(request, this.client.settings)
619
+ ),
620
+ headers: jsonContentHeaders,
621
+ method: "PATCH",
622
+ path: `/functions/v1beta1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/triggers/${validatePathParam("triggerId", request.triggerId)}`
623
+ },
624
+ unmarshalTrigger
625
+ );
626
+ /**
627
+ * Delete a trigger. Delete a trigger with a specified ID.
628
+ *
629
+ * @param request - The request {@link DeleteTriggerRequest}
630
+ * @returns A Promise of Trigger
631
+ */
632
+ deleteTrigger = (request) => this.client.fetch(
633
+ {
634
+ method: "DELETE",
635
+ path: `/functions/v1beta1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/triggers/${validatePathParam("triggerId", request.triggerId)}`
636
+ },
637
+ unmarshalTrigger
638
+ );
639
+ }
640
+ export {
641
+ API
642
+ };
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const CRON_TRANSIENT_STATUSES = [
4
+ "deleting",
5
+ "creating",
6
+ "pending"
7
+ ];
8
+ const DOMAIN_TRANSIENT_STATUSES = [
9
+ "deleting",
10
+ "creating",
11
+ "pending"
12
+ ];
13
+ const FUNCTION_TRANSIENT_STATUSES = [
14
+ "deleting",
15
+ "creating",
16
+ "pending"
17
+ ];
18
+ const NAMESPACE_TRANSIENT_STATUSES = [
19
+ "deleting",
20
+ "creating",
21
+ "pending"
22
+ ];
23
+ const TOKEN_TRANSIENT_STATUSES = ["deleting", "creating"];
24
+ const TRIGGER_TRANSIENT_STATUSES = [
25
+ "deleting",
26
+ "creating",
27
+ "pending"
28
+ ];
29
+ exports.CRON_TRANSIENT_STATUSES = CRON_TRANSIENT_STATUSES;
30
+ exports.DOMAIN_TRANSIENT_STATUSES = DOMAIN_TRANSIENT_STATUSES;
31
+ exports.FUNCTION_TRANSIENT_STATUSES = FUNCTION_TRANSIENT_STATUSES;
32
+ exports.NAMESPACE_TRANSIENT_STATUSES = NAMESPACE_TRANSIENT_STATUSES;
33
+ exports.TOKEN_TRANSIENT_STATUSES = TOKEN_TRANSIENT_STATUSES;
34
+ exports.TRIGGER_TRANSIENT_STATUSES = TRIGGER_TRANSIENT_STATUSES;
@@ -0,0 +1,13 @@
1
+ import type { CronStatus, DomainStatus, FunctionStatus, NamespaceStatus, TokenStatus, TriggerStatus } from './types.gen';
2
+ /** Lists transient statutes of the enum {@link CronStatus}. */
3
+ export declare const CRON_TRANSIENT_STATUSES: CronStatus[];
4
+ /** Lists transient statutes of the enum {@link DomainStatus}. */
5
+ export declare const DOMAIN_TRANSIENT_STATUSES: DomainStatus[];
6
+ /** Lists transient statutes of the enum {@link FunctionStatus}. */
7
+ export declare const FUNCTION_TRANSIENT_STATUSES: FunctionStatus[];
8
+ /** Lists transient statutes of the enum {@link NamespaceStatus}. */
9
+ export declare const NAMESPACE_TRANSIENT_STATUSES: NamespaceStatus[];
10
+ /** Lists transient statutes of the enum {@link TokenStatus}. */
11
+ export declare const TOKEN_TRANSIENT_STATUSES: TokenStatus[];
12
+ /** Lists transient statutes of the enum {@link TriggerStatus}. */
13
+ export declare const TRIGGER_TRANSIENT_STATUSES: TriggerStatus[];