@scaleway/sdk-tem 2.2.0 → 2.3.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,538 +1,348 @@
1
- import { API as API$1, toApiLocality, validatePathParam, waitForResource, urlParams, enrichForPagination } from "@scaleway/sdk-client";
2
- import { EMAIL_TRANSIENT_STATUSES, DOMAIN_TRANSIENT_STATUSES } from "./content.gen.js";
3
- import { marshalCreateEmailRequest, unmarshalCreateEmailResponse, unmarshalEmail, unmarshalListEmailsResponse, unmarshalStatistics, marshalCreateDomainRequest, unmarshalDomain, unmarshalListDomainsResponse, unmarshalDomainLastStatus, marshalUpdateDomainRequest, marshalCreateWebhookRequest, unmarshalWebhook, unmarshalListWebhooksResponse, marshalUpdateWebhookRequest, unmarshalListWebhookEventsResponse, unmarshalProjectSettings, marshalUpdateProjectSettingsRequest, unmarshalListBlocklistsResponse, marshalBulkCreateBlocklistsRequest, unmarshalBulkCreateBlocklistsResponse, unmarshalListOfferSubscriptionsResponse, marshalUpdateOfferSubscriptionRequest, unmarshalOfferSubscription, unmarshalListOffersResponse, unmarshalListPoolsResponse, unmarshalProjectConsumption } from "./marshalling.gen.js";
4
- const jsonContentHeaders = {
5
- "Content-Type": "application/json; charset=utf-8"
6
- };
7
- class API extends API$1 {
8
- /**
9
- * Locality of this API.
10
- * type {'zone','region','global','unspecified'}
11
- */
12
- static LOCALITY = toApiLocality({
13
- regions: ["fr-par"]
14
- });
15
- /**
16
- * Send an email. You must specify the `region`, the sender and the recipient's information and the `project_id` to send an email from a checked domain.
17
- *
18
- * @param request - The request {@link CreateEmailRequest}
19
- * @returns A Promise of CreateEmailResponse
20
- */
21
- createEmail = (request) => this.client.fetch(
22
- {
23
- body: JSON.stringify(
24
- marshalCreateEmailRequest(request, this.client.settings)
25
- ),
26
- headers: jsonContentHeaders,
27
- method: "POST",
28
- path: `/transactional-email/v1alpha1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/emails`
29
- },
30
- unmarshalCreateEmailResponse
31
- );
32
- /**
33
- * Get an email. Retrieve information about a specific email using the `email_id` and `region` parameters.
34
- *
35
- * @param request - The request {@link GetEmailRequest}
36
- * @returns A Promise of Email
37
- */
38
- getEmail = (request) => this.client.fetch(
39
- {
40
- method: "GET",
41
- path: `/transactional-email/v1alpha1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/emails/${validatePathParam("emailId", request.emailId)}`
42
- },
43
- unmarshalEmail
44
- );
45
- /**
46
- * Waits for {@link Email} to be in a final state.
47
- *
48
- * @param request - The request {@link GetEmailRequest}
49
- * @param options - The waiting options
50
- * @returns A Promise of Email
51
- */
52
- waitForEmail = (request, options) => waitForResource(
53
- options?.stop ?? ((res) => Promise.resolve(!EMAIL_TRANSIENT_STATUSES.includes(res.status))),
54
- this.getEmail,
55
- request,
56
- options
57
- );
58
- pageOfListEmails = (request = {}) => this.client.fetch(
59
- {
60
- method: "GET",
61
- path: `/transactional-email/v1alpha1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/emails`,
62
- urlParams: urlParams(
63
- ["domain_id", request.domainId],
64
- ["flags", request.flags],
65
- ["mail_from", request.mailFrom],
66
- ["mail_rcpt", request.mailRcpt],
67
- ["mail_to", request.mailTo],
68
- ["message_id", request.messageId],
69
- ["order_by", request.orderBy],
70
- ["page", request.page],
71
- [
72
- "page_size",
73
- request.pageSize ?? this.client.settings.defaultPageSize
74
- ],
75
- ["project_id", request.projectId],
76
- ["search", request.search],
77
- ["since", request.since],
78
- ["statuses", request.statuses],
79
- ["subject", request.subject],
80
- ["until", request.until]
81
- )
82
- },
83
- unmarshalListEmailsResponse
84
- );
85
- /**
86
- * List emails. Retrieve the list of emails sent from a specific domain or for a specific Project or Organization. You must specify the `region`.
87
- *
88
- * @param request - The request {@link ListEmailsRequest}
89
- * @returns A Promise of ListEmailsResponse
90
- */
91
- listEmails = (request = {}) => enrichForPagination("emails", this.pageOfListEmails, request);
92
- /**
93
- * Email statuses. Get information on your emails' statuses.
94
- *
95
- * @param request - The request {@link GetStatisticsRequest}
96
- * @returns A Promise of Statistics
97
- */
98
- getStatistics = (request = {}) => this.client.fetch(
99
- {
100
- method: "GET",
101
- path: `/transactional-email/v1alpha1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/statistics`,
102
- urlParams: urlParams(
103
- ["domain_id", request.domainId],
104
- ["mail_from", request.mailFrom],
105
- ["project_id", request.projectId],
106
- ["since", request.since],
107
- ["until", request.until]
108
- )
109
- },
110
- unmarshalStatistics
111
- );
112
- /**
113
- * Cancel an email. You can cancel the sending of an email if it has not been sent yet. You must specify the `region` and the `email_id` of the email you want to cancel.
114
- *
115
- * @param request - The request {@link CancelEmailRequest}
116
- * @returns A Promise of Email
117
- */
118
- cancelEmail = (request) => this.client.fetch(
119
- {
120
- body: "{}",
121
- headers: jsonContentHeaders,
122
- method: "POST",
123
- path: `/transactional-email/v1alpha1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/emails/${validatePathParam("emailId", request.emailId)}/cancel`
124
- },
125
- unmarshalEmail
126
- );
127
- /**
128
- * Register a domain in a project. You must specify the `region`, `project_id` and `domain_name` to register a domain in a specific Project.
129
- *
130
- * @param request - The request {@link CreateDomainRequest}
131
- * @returns A Promise of Domain
132
- */
133
- createDomain = (request) => this.client.fetch(
134
- {
135
- body: JSON.stringify(
136
- marshalCreateDomainRequest(request, this.client.settings)
137
- ),
138
- headers: jsonContentHeaders,
139
- method: "POST",
140
- path: `/transactional-email/v1alpha1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/domains`
141
- },
142
- unmarshalDomain
143
- );
144
- /**
145
- * Get information about a domain. Retrieve information about a specific domain using the `region` and `domain_id` parameters. Monitor your domain's reputation and improve **average** and **bad** reputation statuses, using your domain's **Email activity** tab on the [Scaleway console](https://console.scaleway.com/transactional-email/domains) to get a more detailed report. Check out our [dedicated documentation](https://www.scaleway.com/en/docs/managed-services/transactional-email/reference-content/understanding-tem-reputation-score/) to improve your domain's reputation.
146
- *
147
- * @param request - The request {@link GetDomainRequest}
148
- * @returns A Promise of Domain
149
- */
150
- getDomain = (request) => this.client.fetch(
151
- {
152
- method: "GET",
153
- path: `/transactional-email/v1alpha1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/domains/${validatePathParam("domainId", request.domainId)}`
154
- },
155
- unmarshalDomain
156
- );
157
- /**
158
- * Waits for {@link Domain} to be in a final state.
159
- *
160
- * @param request - The request {@link GetDomainRequest}
161
- * @param options - The waiting options
162
- * @returns A Promise of Domain
163
- */
164
- waitForDomain = (request, options) => waitForResource(
165
- options?.stop ?? ((res) => Promise.resolve(!DOMAIN_TRANSIENT_STATUSES.includes(res.status))),
166
- this.getDomain,
167
- request,
168
- options
169
- );
170
- pageOfListDomains = (request = {}) => this.client.fetch(
171
- {
172
- method: "GET",
173
- path: `/transactional-email/v1alpha1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/domains`,
174
- urlParams: urlParams(
175
- ["name", request.name],
176
- ["organization_id", request.organizationId],
177
- ["page", request.page],
178
- [
179
- "page_size",
180
- request.pageSize ?? this.client.settings.defaultPageSize
181
- ],
182
- ["project_id", request.projectId],
183
- ["status", request.status]
184
- )
185
- },
186
- unmarshalListDomainsResponse
187
- );
188
- /**
189
- * List domains. Retrieve domains in a specific Project or in a specific Organization using the `region` parameter.
190
- *
191
- * @param request - The request {@link ListDomainsRequest}
192
- * @returns A Promise of ListDomainsResponse
193
- */
194
- listDomains = (request = {}) => enrichForPagination("domains", this.pageOfListDomains, request);
195
- /**
196
- * Delete a domain. You must specify the domain you want to delete by the `region` and `domain_id`. Deleting a domain is permanent and cannot be undone.
197
- *
198
- * @param request - The request {@link RevokeDomainRequest}
199
- * @returns A Promise of Domain
200
- */
201
- revokeDomain = (request) => this.client.fetch(
202
- {
203
- body: "{}",
204
- headers: jsonContentHeaders,
205
- method: "POST",
206
- path: `/transactional-email/v1alpha1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/domains/${validatePathParam("domainId", request.domainId)}/revoke`
207
- },
208
- unmarshalDomain
209
- );
210
- /**
211
- * Domain DNS check. Perform an immediate DNS check of a domain using the `region` and `domain_id` parameters.
212
- *
213
- * @param request - The request {@link CheckDomainRequest}
214
- * @returns A Promise of Domain
215
- */
216
- checkDomain = (request) => this.client.fetch(
217
- {
218
- body: "{}",
219
- headers: jsonContentHeaders,
220
- method: "POST",
221
- path: `/transactional-email/v1alpha1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/domains/${validatePathParam("domainId", request.domainId)}/check`
222
- },
223
- unmarshalDomain
224
- );
225
- /**
226
- * Display SPF, DKIM, DMARC and MX records status and potential errors. Display SPF, DKIM, DMARC and MX records status and potential errors, including the found records to make debugging easier.
227
- *
228
- * @param request - The request {@link GetDomainLastStatusRequest}
229
- * @returns A Promise of DomainLastStatus
230
- */
231
- getDomainLastStatus = (request) => this.client.fetch(
232
- {
233
- method: "GET",
234
- path: `/transactional-email/v1alpha1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/domains/${validatePathParam("domainId", request.domainId)}/verification`
235
- },
236
- unmarshalDomainLastStatus
237
- );
238
- /**
239
- * Update a domain. Update a domain auto-configuration.
240
- *
241
- * @param request - The request {@link UpdateDomainRequest}
242
- * @returns A Promise of Domain
243
- */
244
- updateDomain = (request) => this.client.fetch(
245
- {
246
- body: JSON.stringify(
247
- marshalUpdateDomainRequest(request, this.client.settings)
248
- ),
249
- headers: jsonContentHeaders,
250
- method: "PATCH",
251
- path: `/transactional-email/v1alpha1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/domains/${validatePathParam("domainId", request.domainId)}`
252
- },
253
- unmarshalDomain
254
- );
255
- /**
256
- * Create a Webhook. Create a new Webhook triggered by a list of event types and pushed to a Scaleway SNS ARN.
257
- *
258
- * @param request - The request {@link CreateWebhookRequest}
259
- * @returns A Promise of Webhook
260
- */
261
- createWebhook = (request) => this.client.fetch(
262
- {
263
- body: JSON.stringify(
264
- marshalCreateWebhookRequest(request, this.client.settings)
265
- ),
266
- headers: jsonContentHeaders,
267
- method: "POST",
268
- path: `/transactional-email/v1alpha1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/webhooks`
269
- },
270
- unmarshalWebhook
271
- );
272
- pageOfListWebhooks = (request = {}) => this.client.fetch(
273
- {
274
- method: "GET",
275
- path: `/transactional-email/v1alpha1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/webhooks`,
276
- urlParams: urlParams(
277
- ["domain_id", request.domainId],
278
- ["order_by", request.orderBy],
279
- ["organization_id", request.organizationId],
280
- ["page", request.page],
281
- [
282
- "page_size",
283
- request.pageSize ?? this.client.settings.defaultPageSize
284
- ],
285
- ["project_id", request.projectId]
286
- )
287
- },
288
- unmarshalListWebhooksResponse
289
- );
290
- /**
291
- * List Webhooks. Retrieve Webhooks in a specific Project or in a specific Organization using the `region` parameter.
292
- *
293
- * @param request - The request {@link ListWebhooksRequest}
294
- * @returns A Promise of ListWebhooksResponse
295
- */
296
- listWebhooks = (request = {}) => enrichForPagination("webhooks", this.pageOfListWebhooks, request);
297
- /**
298
- * Get information about a Webhook. Retrieve information about a specific Webhook using the `webhook_id` and `region` parameters.
299
- *
300
- * @param request - The request {@link GetWebhookRequest}
301
- * @returns A Promise of Webhook
302
- */
303
- getWebhook = (request) => this.client.fetch(
304
- {
305
- method: "GET",
306
- path: `/transactional-email/v1alpha1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/webhooks/${validatePathParam("webhookId", request.webhookId)}`
307
- },
308
- unmarshalWebhook
309
- );
310
- /**
311
- * Update a Webhook. Update a Webhook events type, SNS ARN or name.
312
- *
313
- * @param request - The request {@link UpdateWebhookRequest}
314
- * @returns A Promise of Webhook
315
- */
316
- updateWebhook = (request) => this.client.fetch(
317
- {
318
- body: JSON.stringify(
319
- marshalUpdateWebhookRequest(request, this.client.settings)
320
- ),
321
- headers: jsonContentHeaders,
322
- method: "PATCH",
323
- path: `/transactional-email/v1alpha1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/webhooks/${validatePathParam("webhookId", request.webhookId)}`
324
- },
325
- unmarshalWebhook
326
- );
327
- /**
328
- * Delete a Webhook. You must specify the Webhook you want to delete by the `region` and `webhook_id`. Deleting a Webhook is permanent and cannot be undone.
329
- *
330
- * @param request - The request {@link DeleteWebhookRequest}
331
- */
332
- deleteWebhook = (request) => this.client.fetch({
333
- method: "DELETE",
334
- path: `/transactional-email/v1alpha1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/webhooks/${validatePathParam("webhookId", request.webhookId)}`
335
- });
336
- pageOfListWebhookEvents = (request) => this.client.fetch(
337
- {
338
- method: "GET",
339
- path: `/transactional-email/v1alpha1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/webhooks/${validatePathParam("webhookId", request.webhookId)}/events`,
340
- urlParams: urlParams(
341
- ["domain_id", request.domainId],
342
- ["email_id", request.emailId],
343
- ["event_types", request.eventTypes],
344
- ["order_by", request.orderBy],
345
- ["organization_id", request.organizationId],
346
- ["page", request.page],
347
- [
348
- "page_size",
349
- request.pageSize ?? this.client.settings.defaultPageSize
350
- ],
351
- ["project_id", request.projectId],
352
- ["statuses", request.statuses]
353
- )
354
- },
355
- unmarshalListWebhookEventsResponse
356
- );
357
- /**
358
- * List Webhook triggered events. Retrieve the list of Webhook events triggered from a specific Webhook or for a specific Project or Organization. You must specify the `region`.
359
- *
360
- * @param request - The request {@link ListWebhookEventsRequest}
361
- * @returns A Promise of ListWebhookEventsResponse
362
- */
363
- listWebhookEvents = (request) => enrichForPagination("webhookEvents", this.pageOfListWebhookEvents, request);
364
- /**
365
- * List project settings. Retrieve the project settings including periodic reports.
366
- *
367
- * @param request - The request {@link GetProjectSettingsRequest}
368
- * @returns A Promise of ProjectSettings
369
- */
370
- getProjectSettings = (request = {}) => this.client.fetch(
371
- {
372
- method: "GET",
373
- path: `/transactional-email/v1alpha1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/project/${validatePathParam("projectId", request.projectId ?? this.client.settings.defaultProjectId)}/settings`
374
- },
375
- unmarshalProjectSettings
376
- );
377
- /**
378
- * Update project settings. Update the project settings including periodic reports.
379
- *
380
- * @param request - The request {@link UpdateProjectSettingsRequest}
381
- * @returns A Promise of ProjectSettings
382
- */
383
- updateProjectSettings = (request = {}) => this.client.fetch(
384
- {
385
- body: JSON.stringify(
386
- marshalUpdateProjectSettingsRequest(request, this.client.settings)
387
- ),
388
- headers: jsonContentHeaders,
389
- method: "PATCH",
390
- path: `/transactional-email/v1alpha1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/project/${validatePathParam("projectId", request.projectId ?? this.client.settings.defaultProjectId)}/settings`
391
- },
392
- unmarshalProjectSettings
393
- );
394
- pageOfListBlocklists = (request) => this.client.fetch(
395
- {
396
- method: "GET",
397
- path: `/transactional-email/v1alpha1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/blocklists`,
398
- urlParams: urlParams(
399
- ["custom", request.custom],
400
- ["domain_id", request.domainId],
401
- ["email", request.email],
402
- ["order_by", request.orderBy],
403
- ["page", request.page],
404
- [
405
- "page_size",
406
- request.pageSize ?? this.client.settings.defaultPageSize
407
- ],
408
- ["type", request.type]
409
- )
410
- },
411
- unmarshalListBlocklistsResponse
412
- );
413
- /**
414
- * List blocklists. Retrieve the list of blocklists.
415
- *
416
- * @param request - The request {@link ListBlocklistsRequest}
417
- * @returns A Promise of ListBlocklistsResponse
418
- */
419
- listBlocklists = (request) => enrichForPagination("blocklists", this.pageOfListBlocklists, request);
420
- /**
421
- * Bulk create blocklists. Create multiple blocklists in a specific Project or Organization using the `region` parameter.
422
- *
423
- * @param request - The request {@link BulkCreateBlocklistsRequest}
424
- * @returns A Promise of BulkCreateBlocklistsResponse
425
- */
426
- bulkCreateBlocklists = (request) => this.client.fetch(
427
- {
428
- body: JSON.stringify(
429
- marshalBulkCreateBlocklistsRequest(request, this.client.settings)
430
- ),
431
- headers: jsonContentHeaders,
432
- method: "POST",
433
- path: `/transactional-email/v1alpha1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/blocklists`
434
- },
435
- unmarshalBulkCreateBlocklistsResponse
436
- );
437
- /**
438
- * Delete a blocklist. You must specify the blocklist you want to delete by the `region` and `blocklist_id`.
439
- *
440
- * @param request - The request {@link DeleteBlocklistRequest}
441
- */
442
- deleteBlocklist = (request) => this.client.fetch({
443
- method: "DELETE",
444
- path: `/transactional-email/v1alpha1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/blocklists/${validatePathParam("blocklistId", request.blocklistId)}`
445
- });
446
- /**
447
- * Get information about subscribed offers. Retrieve information about the offers you are subscribed to using the `project_id` and `region` parameters.
448
- *
449
- * @param request - The request {@link ListOfferSubscriptionsRequest}
450
- * @returns A Promise of ListOfferSubscriptionsResponse
451
- */
452
- listOfferSubscriptions = (request = {}) => this.client.fetch(
453
- {
454
- method: "GET",
455
- path: `/transactional-email/v1alpha1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/offer-subscriptions`,
456
- urlParams: urlParams([
457
- "project_id",
458
- request.projectId ?? this.client.settings.defaultProjectId
459
- ])
460
- },
461
- unmarshalListOfferSubscriptionsResponse
462
- );
463
- /**
464
- * Update a subscribed offer.
465
- *
466
- * @param request - The request {@link UpdateOfferSubscriptionRequest}
467
- * @returns A Promise of OfferSubscription
468
- */
469
- updateOfferSubscription = (request = {}) => this.client.fetch(
470
- {
471
- body: JSON.stringify(
472
- marshalUpdateOfferSubscriptionRequest(request, this.client.settings)
473
- ),
474
- headers: jsonContentHeaders,
475
- method: "PATCH",
476
- path: `/transactional-email/v1alpha1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/offer-subscriptions`
477
- },
478
- unmarshalOfferSubscription
479
- );
480
- /**
481
- * List the available offers.. Retrieve the list of the available and free-of-charge offers you can subscribe to.
482
- *
483
- * @param request - The request {@link ListOffersRequest}
484
- * @returns A Promise of ListOffersResponse
485
- */
486
- listOffers = (request = {}) => this.client.fetch(
487
- {
488
- method: "GET",
489
- path: `/transactional-email/v1alpha1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/offers`
490
- },
491
- unmarshalListOffersResponse
492
- );
493
- pageOfListPools = (request = {}) => this.client.fetch(
494
- {
495
- method: "GET",
496
- path: `/transactional-email/v1alpha1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/pools`,
497
- urlParams: urlParams(
498
- ["page", request.page],
499
- [
500
- "page_size",
501
- request.pageSize ?? this.client.settings.defaultPageSize
502
- ],
503
- [
504
- "project_id",
505
- request.projectId ?? this.client.settings.defaultProjectId
506
- ]
507
- )
508
- },
509
- unmarshalListPoolsResponse
510
- );
511
- /**
512
- * Get information about a sending pool.. Retrieve information about a sending pool, including its creation status and configuration parameters.
513
- *
514
- * @param request - The request {@link ListPoolsRequest}
515
- * @returns A Promise of ListPoolsResponse
516
- */
517
- listPools = (request = {}) => enrichForPagination("pools", this.pageOfListPools, request);
518
- /**
519
- * Get project resource consumption.. Get project resource consumption.
520
- *
521
- * @param request - The request {@link GetProjectConsumptionRequest}
522
- * @returns A Promise of ProjectConsumption
523
- */
524
- getProjectConsumption = (request = {}) => this.client.fetch(
525
- {
526
- method: "GET",
527
- path: `/transactional-email/v1alpha1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/project-consumption`,
528
- urlParams: urlParams([
529
- "project_id",
530
- request.projectId ?? this.client.settings.defaultProjectId
531
- ])
532
- },
533
- unmarshalProjectConsumption
534
- );
535
- }
536
- export {
537
- API
1
+ import { DOMAIN_TRANSIENT_STATUSES, EMAIL_TRANSIENT_STATUSES } from "./content.gen.js";
2
+ import { marshalBulkCreateBlocklistsRequest, marshalCreateDomainRequest, marshalCreateEmailRequest, marshalCreateWebhookRequest, marshalUpdateDomainRequest, marshalUpdateOfferSubscriptionRequest, marshalUpdateProjectSettingsRequest, marshalUpdateWebhookRequest, unmarshalBulkCreateBlocklistsResponse, unmarshalCreateEmailResponse, unmarshalDomain, unmarshalDomainLastStatus, unmarshalEmail, unmarshalListBlocklistsResponse, unmarshalListDomainsResponse, unmarshalListEmailsResponse, unmarshalListOfferSubscriptionsResponse, unmarshalListOffersResponse, unmarshalListPoolsResponse, unmarshalListWebhookEventsResponse, unmarshalListWebhooksResponse, unmarshalOfferSubscription, unmarshalProjectConsumption, unmarshalProjectSettings, unmarshalStatistics, unmarshalWebhook } from "./marshalling.gen.js";
3
+ import { API, enrichForPagination, toApiLocality, urlParams, validatePathParam, waitForResource } from "@scaleway/sdk-client";
4
+ var jsonContentHeaders = { "Content-Type": "application/json; charset=utf-8" };
5
+ /**
6
+ * Transactional Email API.
7
+
8
+ This API allows you to manage your Transactional Email services.
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: ["fr-par"] });
16
+ /**
17
+ * Send an email. You must specify the `region`, the sender and the recipient's information and the `project_id` to send an email from a checked domain.
18
+ *
19
+ * @param request - The request {@link CreateEmailRequest}
20
+ * @returns A Promise of CreateEmailResponse
21
+ */
22
+ createEmail = (request) => this.client.fetch({
23
+ body: JSON.stringify(marshalCreateEmailRequest(request, this.client.settings)),
24
+ headers: jsonContentHeaders,
25
+ method: "POST",
26
+ path: `/transactional-email/v1alpha1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/emails`
27
+ }, unmarshalCreateEmailResponse);
28
+ /**
29
+ * Get an email. Retrieve information about a specific email using the `email_id` and `region` parameters.
30
+ *
31
+ * @param request - The request {@link GetEmailRequest}
32
+ * @returns A Promise of Email
33
+ */
34
+ getEmail = (request) => this.client.fetch({
35
+ method: "GET",
36
+ path: `/transactional-email/v1alpha1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/emails/${validatePathParam("emailId", request.emailId)}`
37
+ }, unmarshalEmail);
38
+ /**
39
+ * Waits for {@link Email} to be in a final state.
40
+ *
41
+ * @param request - The request {@link GetEmailRequest}
42
+ * @param options - The waiting options
43
+ * @returns A Promise of Email
44
+ */
45
+ waitForEmail = (request, options) => waitForResource(options?.stop ?? ((res) => Promise.resolve(!EMAIL_TRANSIENT_STATUSES.includes(res.status))), this.getEmail, request, options);
46
+ pageOfListEmails = (request = {}) => this.client.fetch({
47
+ method: "GET",
48
+ path: `/transactional-email/v1alpha1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/emails`,
49
+ urlParams: urlParams(["domain_id", request.domainId], ["flags", request.flags], ["mail_from", request.mailFrom], ["mail_rcpt", request.mailRcpt], ["mail_to", request.mailTo], ["message_id", request.messageId], ["order_by", request.orderBy], ["page", request.page], ["page_size", request.pageSize ?? this.client.settings.defaultPageSize], ["project_id", request.projectId], ["search", request.search], ["since", request.since], ["statuses", request.statuses], ["subject", request.subject], ["until", request.until])
50
+ }, unmarshalListEmailsResponse);
51
+ /**
52
+ * List emails. Retrieve the list of emails sent from a specific domain or for a specific Project or Organization. You must specify the `region`.
53
+ *
54
+ * @param request - The request {@link ListEmailsRequest}
55
+ * @returns A Promise of ListEmailsResponse
56
+ */
57
+ listEmails = (request = {}) => enrichForPagination("emails", this.pageOfListEmails, request);
58
+ /**
59
+ * Email statuses. Get information on your emails' statuses.
60
+ *
61
+ * @param request - The request {@link GetStatisticsRequest}
62
+ * @returns A Promise of Statistics
63
+ */
64
+ getStatistics = (request = {}) => this.client.fetch({
65
+ method: "GET",
66
+ path: `/transactional-email/v1alpha1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/statistics`,
67
+ urlParams: urlParams(["domain_id", request.domainId], ["mail_from", request.mailFrom], ["project_id", request.projectId], ["since", request.since], ["until", request.until])
68
+ }, unmarshalStatistics);
69
+ /**
70
+ * Cancel an email. You can cancel the sending of an email if it has not been sent yet. You must specify the `region` and the `email_id` of the email you want to cancel.
71
+ *
72
+ * @param request - The request {@link CancelEmailRequest}
73
+ * @returns A Promise of Email
74
+ */
75
+ cancelEmail = (request) => this.client.fetch({
76
+ body: "{}",
77
+ headers: jsonContentHeaders,
78
+ method: "POST",
79
+ path: `/transactional-email/v1alpha1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/emails/${validatePathParam("emailId", request.emailId)}/cancel`
80
+ }, unmarshalEmail);
81
+ /**
82
+ * Register a domain in a project. You must specify the `region`, `project_id` and `domain_name` to register a domain in a specific Project.
83
+ *
84
+ * @param request - The request {@link CreateDomainRequest}
85
+ * @returns A Promise of Domain
86
+ */
87
+ createDomain = (request) => this.client.fetch({
88
+ body: JSON.stringify(marshalCreateDomainRequest(request, this.client.settings)),
89
+ headers: jsonContentHeaders,
90
+ method: "POST",
91
+ path: `/transactional-email/v1alpha1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/domains`
92
+ }, unmarshalDomain);
93
+ /**
94
+ * Get information about a domain. Retrieve information about a specific domain using the `region` and `domain_id` parameters. Monitor your domain's reputation and improve **average** and **bad** reputation statuses, using your domain's **Email activity** tab on the [Scaleway console](https://console.scaleway.com/transactional-email/domains) to get a more detailed report. Check out our [dedicated documentation](https://www.scaleway.com/en/docs/managed-services/transactional-email/reference-content/understanding-tem-reputation-score/) to improve your domain's reputation.
95
+ *
96
+ * @param request - The request {@link GetDomainRequest}
97
+ * @returns A Promise of Domain
98
+ */
99
+ getDomain = (request) => this.client.fetch({
100
+ method: "GET",
101
+ path: `/transactional-email/v1alpha1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/domains/${validatePathParam("domainId", request.domainId)}`
102
+ }, unmarshalDomain);
103
+ /**
104
+ * Waits for {@link Domain} to be in a final state.
105
+ *
106
+ * @param request - The request {@link GetDomainRequest}
107
+ * @param options - The waiting options
108
+ * @returns A Promise of Domain
109
+ */
110
+ waitForDomain = (request, options) => waitForResource(options?.stop ?? ((res) => Promise.resolve(!DOMAIN_TRANSIENT_STATUSES.includes(res.status))), this.getDomain, request, options);
111
+ pageOfListDomains = (request = {}) => this.client.fetch({
112
+ method: "GET",
113
+ path: `/transactional-email/v1alpha1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/domains`,
114
+ urlParams: urlParams(["name", request.name], ["organization_id", request.organizationId], ["page", request.page], ["page_size", request.pageSize ?? this.client.settings.defaultPageSize], ["project_id", request.projectId], ["status", request.status])
115
+ }, unmarshalListDomainsResponse);
116
+ /**
117
+ * List domains. Retrieve domains in a specific Project or in a specific Organization using the `region` parameter.
118
+ *
119
+ * @param request - The request {@link ListDomainsRequest}
120
+ * @returns A Promise of ListDomainsResponse
121
+ */
122
+ listDomains = (request = {}) => enrichForPagination("domains", this.pageOfListDomains, request);
123
+ /**
124
+ * Delete a domain. You must specify the domain you want to delete by the `region` and `domain_id`. Deleting a domain is permanent and cannot be undone.
125
+ *
126
+ * @param request - The request {@link RevokeDomainRequest}
127
+ * @returns A Promise of Domain
128
+ */
129
+ revokeDomain = (request) => this.client.fetch({
130
+ body: "{}",
131
+ headers: jsonContentHeaders,
132
+ method: "POST",
133
+ path: `/transactional-email/v1alpha1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/domains/${validatePathParam("domainId", request.domainId)}/revoke`
134
+ }, unmarshalDomain);
135
+ /**
136
+ * Domain DNS check. Perform an immediate DNS check of a domain using the `region` and `domain_id` parameters.
137
+ *
138
+ * @param request - The request {@link CheckDomainRequest}
139
+ * @returns A Promise of Domain
140
+ */
141
+ checkDomain = (request) => this.client.fetch({
142
+ body: "{}",
143
+ headers: jsonContentHeaders,
144
+ method: "POST",
145
+ path: `/transactional-email/v1alpha1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/domains/${validatePathParam("domainId", request.domainId)}/check`
146
+ }, unmarshalDomain);
147
+ /**
148
+ * Display SPF, DKIM, DMARC and MX records status and potential errors. Display SPF, DKIM, DMARC and MX records status and potential errors, including the found records to make debugging easier.
149
+ *
150
+ * @param request - The request {@link GetDomainLastStatusRequest}
151
+ * @returns A Promise of DomainLastStatus
152
+ */
153
+ getDomainLastStatus = (request) => this.client.fetch({
154
+ method: "GET",
155
+ path: `/transactional-email/v1alpha1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/domains/${validatePathParam("domainId", request.domainId)}/verification`
156
+ }, unmarshalDomainLastStatus);
157
+ /**
158
+ * Update a domain. Update a domain auto-configuration.
159
+ *
160
+ * @param request - The request {@link UpdateDomainRequest}
161
+ * @returns A Promise of Domain
162
+ */
163
+ updateDomain = (request) => this.client.fetch({
164
+ body: JSON.stringify(marshalUpdateDomainRequest(request, this.client.settings)),
165
+ headers: jsonContentHeaders,
166
+ method: "PATCH",
167
+ path: `/transactional-email/v1alpha1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/domains/${validatePathParam("domainId", request.domainId)}`
168
+ }, unmarshalDomain);
169
+ /**
170
+ * Create a Webhook. Create a new Webhook triggered by a list of event types and pushed to a Scaleway SNS ARN.
171
+ *
172
+ * @param request - The request {@link CreateWebhookRequest}
173
+ * @returns A Promise of Webhook
174
+ */
175
+ createWebhook = (request) => this.client.fetch({
176
+ body: JSON.stringify(marshalCreateWebhookRequest(request, this.client.settings)),
177
+ headers: jsonContentHeaders,
178
+ method: "POST",
179
+ path: `/transactional-email/v1alpha1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/webhooks`
180
+ }, unmarshalWebhook);
181
+ pageOfListWebhooks = (request = {}) => this.client.fetch({
182
+ method: "GET",
183
+ path: `/transactional-email/v1alpha1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/webhooks`,
184
+ urlParams: urlParams(["domain_id", request.domainId], ["order_by", request.orderBy], ["organization_id", request.organizationId], ["page", request.page], ["page_size", request.pageSize ?? this.client.settings.defaultPageSize], ["project_id", request.projectId])
185
+ }, unmarshalListWebhooksResponse);
186
+ /**
187
+ * List Webhooks. Retrieve Webhooks in a specific Project or in a specific Organization using the `region` parameter.
188
+ *
189
+ * @param request - The request {@link ListWebhooksRequest}
190
+ * @returns A Promise of ListWebhooksResponse
191
+ */
192
+ listWebhooks = (request = {}) => enrichForPagination("webhooks", this.pageOfListWebhooks, request);
193
+ /**
194
+ * Get information about a Webhook. Retrieve information about a specific Webhook using the `webhook_id` and `region` parameters.
195
+ *
196
+ * @param request - The request {@link GetWebhookRequest}
197
+ * @returns A Promise of Webhook
198
+ */
199
+ getWebhook = (request) => this.client.fetch({
200
+ method: "GET",
201
+ path: `/transactional-email/v1alpha1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/webhooks/${validatePathParam("webhookId", request.webhookId)}`
202
+ }, unmarshalWebhook);
203
+ /**
204
+ * Update a Webhook. Update a Webhook events type, SNS ARN or name.
205
+ *
206
+ * @param request - The request {@link UpdateWebhookRequest}
207
+ * @returns A Promise of Webhook
208
+ */
209
+ updateWebhook = (request) => this.client.fetch({
210
+ body: JSON.stringify(marshalUpdateWebhookRequest(request, this.client.settings)),
211
+ headers: jsonContentHeaders,
212
+ method: "PATCH",
213
+ path: `/transactional-email/v1alpha1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/webhooks/${validatePathParam("webhookId", request.webhookId)}`
214
+ }, unmarshalWebhook);
215
+ /**
216
+ * Delete a Webhook. You must specify the Webhook you want to delete by the `region` and `webhook_id`. Deleting a Webhook is permanent and cannot be undone.
217
+ *
218
+ * @param request - The request {@link DeleteWebhookRequest}
219
+ */
220
+ deleteWebhook = (request) => this.client.fetch({
221
+ method: "DELETE",
222
+ path: `/transactional-email/v1alpha1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/webhooks/${validatePathParam("webhookId", request.webhookId)}`
223
+ });
224
+ pageOfListWebhookEvents = (request) => this.client.fetch({
225
+ method: "GET",
226
+ path: `/transactional-email/v1alpha1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/webhooks/${validatePathParam("webhookId", request.webhookId)}/events`,
227
+ urlParams: urlParams(["domain_id", request.domainId], ["email_id", request.emailId], ["event_types", request.eventTypes], ["order_by", request.orderBy], ["organization_id", request.organizationId], ["page", request.page], ["page_size", request.pageSize ?? this.client.settings.defaultPageSize], ["project_id", request.projectId], ["statuses", request.statuses])
228
+ }, unmarshalListWebhookEventsResponse);
229
+ /**
230
+ * List Webhook triggered events. Retrieve the list of Webhook events triggered from a specific Webhook or for a specific Project or Organization. You must specify the `region`.
231
+ *
232
+ * @param request - The request {@link ListWebhookEventsRequest}
233
+ * @returns A Promise of ListWebhookEventsResponse
234
+ */
235
+ listWebhookEvents = (request) => enrichForPagination("webhookEvents", this.pageOfListWebhookEvents, request);
236
+ /**
237
+ * List project settings. Retrieve the project settings including periodic reports.
238
+ *
239
+ * @param request - The request {@link GetProjectSettingsRequest}
240
+ * @returns A Promise of ProjectSettings
241
+ */
242
+ getProjectSettings = (request = {}) => this.client.fetch({
243
+ method: "GET",
244
+ path: `/transactional-email/v1alpha1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/project/${validatePathParam("projectId", request.projectId ?? this.client.settings.defaultProjectId)}/settings`
245
+ }, unmarshalProjectSettings);
246
+ /**
247
+ * Update project settings. Update the project settings including periodic reports.
248
+ *
249
+ * @param request - The request {@link UpdateProjectSettingsRequest}
250
+ * @returns A Promise of ProjectSettings
251
+ */
252
+ updateProjectSettings = (request = {}) => this.client.fetch({
253
+ body: JSON.stringify(marshalUpdateProjectSettingsRequest(request, this.client.settings)),
254
+ headers: jsonContentHeaders,
255
+ method: "PATCH",
256
+ path: `/transactional-email/v1alpha1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/project/${validatePathParam("projectId", request.projectId ?? this.client.settings.defaultProjectId)}/settings`
257
+ }, unmarshalProjectSettings);
258
+ pageOfListBlocklists = (request) => this.client.fetch({
259
+ method: "GET",
260
+ path: `/transactional-email/v1alpha1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/blocklists`,
261
+ urlParams: urlParams(["custom", request.custom], ["domain_id", request.domainId], ["email", request.email], ["order_by", request.orderBy], ["page", request.page], ["page_size", request.pageSize ?? this.client.settings.defaultPageSize], ["type", request.type])
262
+ }, unmarshalListBlocklistsResponse);
263
+ /**
264
+ * List blocklists. Retrieve the list of blocklists.
265
+ *
266
+ * @param request - The request {@link ListBlocklistsRequest}
267
+ * @returns A Promise of ListBlocklistsResponse
268
+ */
269
+ listBlocklists = (request) => enrichForPagination("blocklists", this.pageOfListBlocklists, request);
270
+ /**
271
+ * Bulk create blocklists. Create multiple blocklists in a specific Project or Organization using the `region` parameter.
272
+ *
273
+ * @param request - The request {@link BulkCreateBlocklistsRequest}
274
+ * @returns A Promise of BulkCreateBlocklistsResponse
275
+ */
276
+ bulkCreateBlocklists = (request) => this.client.fetch({
277
+ body: JSON.stringify(marshalBulkCreateBlocklistsRequest(request, this.client.settings)),
278
+ headers: jsonContentHeaders,
279
+ method: "POST",
280
+ path: `/transactional-email/v1alpha1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/blocklists`
281
+ }, unmarshalBulkCreateBlocklistsResponse);
282
+ /**
283
+ * Delete a blocklist. You must specify the blocklist you want to delete by the `region` and `blocklist_id`.
284
+ *
285
+ * @param request - The request {@link DeleteBlocklistRequest}
286
+ */
287
+ deleteBlocklist = (request) => this.client.fetch({
288
+ method: "DELETE",
289
+ path: `/transactional-email/v1alpha1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/blocklists/${validatePathParam("blocklistId", request.blocklistId)}`
290
+ });
291
+ /**
292
+ * Get information about subscribed offers. Retrieve information about the offers you are subscribed to using the `project_id` and `region` parameters.
293
+ *
294
+ * @param request - The request {@link ListOfferSubscriptionsRequest}
295
+ * @returns A Promise of ListOfferSubscriptionsResponse
296
+ */
297
+ listOfferSubscriptions = (request = {}) => this.client.fetch({
298
+ method: "GET",
299
+ path: `/transactional-email/v1alpha1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/offer-subscriptions`,
300
+ urlParams: urlParams(["project_id", request.projectId ?? this.client.settings.defaultProjectId])
301
+ }, unmarshalListOfferSubscriptionsResponse);
302
+ /**
303
+ * Update a subscribed offer.
304
+ *
305
+ * @param request - The request {@link UpdateOfferSubscriptionRequest}
306
+ * @returns A Promise of OfferSubscription
307
+ */
308
+ updateOfferSubscription = (request = {}) => this.client.fetch({
309
+ body: JSON.stringify(marshalUpdateOfferSubscriptionRequest(request, this.client.settings)),
310
+ headers: jsonContentHeaders,
311
+ method: "PATCH",
312
+ path: `/transactional-email/v1alpha1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/offer-subscriptions`
313
+ }, unmarshalOfferSubscription);
314
+ /**
315
+ * List the available offers.. Retrieve the list of the available and free-of-charge offers you can subscribe to.
316
+ *
317
+ * @param request - The request {@link ListOffersRequest}
318
+ * @returns A Promise of ListOffersResponse
319
+ */
320
+ listOffers = (request = {}) => this.client.fetch({
321
+ method: "GET",
322
+ path: `/transactional-email/v1alpha1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/offers`
323
+ }, unmarshalListOffersResponse);
324
+ pageOfListPools = (request = {}) => this.client.fetch({
325
+ method: "GET",
326
+ path: `/transactional-email/v1alpha1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/pools`,
327
+ urlParams: urlParams(["page", request.page], ["page_size", request.pageSize ?? this.client.settings.defaultPageSize], ["project_id", request.projectId ?? this.client.settings.defaultProjectId])
328
+ }, unmarshalListPoolsResponse);
329
+ /**
330
+ * Get information about a sending pool.. Retrieve information about a sending pool, including its creation status and configuration parameters.
331
+ *
332
+ * @param request - The request {@link ListPoolsRequest}
333
+ * @returns A Promise of ListPoolsResponse
334
+ */
335
+ listPools = (request = {}) => enrichForPagination("pools", this.pageOfListPools, request);
336
+ /**
337
+ * Get project resource consumption.. Get project resource consumption.
338
+ *
339
+ * @param request - The request {@link GetProjectConsumptionRequest}
340
+ * @returns A Promise of ProjectConsumption
341
+ */
342
+ getProjectConsumption = (request = {}) => this.client.fetch({
343
+ method: "GET",
344
+ path: `/transactional-email/v1alpha1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/project-consumption`,
345
+ urlParams: urlParams(["project_id", request.projectId ?? this.client.settings.defaultProjectId])
346
+ }, unmarshalProjectConsumption);
538
347
  };
348
+ export { API$1 as API };