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