diff --git a/packages/clients/src/api/tem/v1alpha1/api.gen.ts b/packages/clients/src/api/tem/v1alpha1/api.gen.ts index 3a0594d25..b01c77aee 100644 --- a/packages/clients/src/api/tem/v1alpha1/api.gen.ts +++ b/packages/clients/src/api/tem/v1alpha1/api.gen.ts @@ -18,6 +18,7 @@ import { marshalCreateEmailRequest, marshalCreateWebhookRequest, marshalUpdateDomainRequest, + marshalUpdateOfferSubscriptionRequest, marshalUpdateProjectSettingsRequest, marshalUpdateWebhookRequest, unmarshalBulkCreateBlocklistsResponse, @@ -28,8 +29,13 @@ import { unmarshalListBlocklistsResponse, unmarshalListDomainsResponse, unmarshalListEmailsResponse, + unmarshalListOfferSubscriptionsResponse, + unmarshalListOffersResponse, + unmarshalListPoolsResponse, unmarshalListWebhookEventsResponse, unmarshalListWebhooksResponse, + unmarshalOfferSubscription, + unmarshalProjectConsumption, unmarshalProjectSettings, unmarshalStatistics, unmarshalWebhook, @@ -51,6 +57,7 @@ import type { GetDomainLastStatusRequest, GetDomainRequest, GetEmailRequest, + GetProjectConsumptionRequest, GetProjectSettingsRequest, GetStatisticsRequest, GetWebhookRequest, @@ -60,14 +67,23 @@ import type { ListDomainsResponse, ListEmailsRequest, ListEmailsResponse, + ListOfferSubscriptionsRequest, + ListOfferSubscriptionsResponse, + ListOffersRequest, + ListOffersResponse, + ListPoolsRequest, + ListPoolsResponse, ListWebhookEventsRequest, ListWebhookEventsResponse, ListWebhooksRequest, ListWebhooksResponse, + OfferSubscription, + ProjectConsumption, ProjectSettings, RevokeDomainRequest, Statistics, UpdateDomainRequest, + UpdateOfferSubscriptionRequest, UpdateProjectSettingsRequest, UpdateWebhookRequest, Webhook, @@ -624,4 +640,115 @@ export class API extends ParentAPI { method: 'DELETE', path: `/transactional-email/v1alpha1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/blocklists/${validatePathParam('blocklistId', request.blocklistId)}`, }) + + /** + * Get information about subscribed offers. Retrieve information about the + * offers you are subscribed to using the `project_id` and `region` + * parameters. + * + * @param request - The request {@link ListOfferSubscriptionsRequest} + * @returns A Promise of ListOfferSubscriptionsResponse + */ + listOfferSubscriptions = ( + request: Readonly = {}, + ) => + this.client.fetch( + { + method: 'GET', + path: `/transactional-email/v1alpha1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/offer-subscriptions`, + urlParams: urlParams([ + 'project_id', + request.projectId ?? this.client.settings.defaultProjectId, + ]), + }, + unmarshalListOfferSubscriptionsResponse, + ) + + /** + * Update a subscribed offer. + * + * @param request - The request {@link UpdateOfferSubscriptionRequest} + * @returns A Promise of OfferSubscription + */ + updateOfferSubscription = ( + request: Readonly = {}, + ) => + this.client.fetch( + { + body: JSON.stringify( + marshalUpdateOfferSubscriptionRequest(request, this.client.settings), + ), + headers: jsonContentHeaders, + method: 'PATCH', + path: `/transactional-email/v1alpha1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/offer-subscriptions`, + }, + unmarshalOfferSubscription, + ) + + /** + * List the available offers.. Retrieve the list of the available and + * free-of-charge offers you can subscribe to. + * + * @param request - The request {@link ListOffersRequest} + * @returns A Promise of ListOffersResponse + */ + listOffers = (request: Readonly = {}) => + this.client.fetch( + { + method: 'GET', + path: `/transactional-email/v1alpha1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/offers`, + }, + unmarshalListOffersResponse, + ) + + protected pageOfListPools = (request: Readonly = {}) => + this.client.fetch( + { + method: 'GET', + path: `/transactional-email/v1alpha1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/pools`, + urlParams: urlParams( + ['page', request.page], + [ + 'page_size', + request.pageSize ?? this.client.settings.defaultPageSize, + ], + [ + 'project_id', + request.projectId ?? this.client.settings.defaultProjectId, + ], + ), + }, + unmarshalListPoolsResponse, + ) + + /** + * Get information about a sending pool.. Retrieve information about a sending + * pool, including its creation status and configuration parameters. + * + * @param request - The request {@link ListPoolsRequest} + * @returns A Promise of ListPoolsResponse + */ + listPools = (request: Readonly = {}) => + enrichForPagination('pools', this.pageOfListPools, request) + + /** + * Get project resource consumption.. Get project resource consumption. + * + * @param request - The request {@link GetProjectConsumptionRequest} + * @returns A Promise of ProjectConsumption + */ + getProjectConsumption = ( + request: Readonly = {}, + ) => + this.client.fetch( + { + method: 'GET', + path: `/transactional-email/v1alpha1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/project-consumption`, + urlParams: urlParams([ + 'project_id', + request.projectId ?? this.client.settings.defaultProjectId, + ]), + }, + unmarshalProjectConsumption, + ) } diff --git a/packages/clients/src/api/tem/v1alpha1/index.gen.ts b/packages/clients/src/api/tem/v1alpha1/index.gen.ts index b041f760d..3cb5fe98e 100644 --- a/packages/clients/src/api/tem/v1alpha1/index.gen.ts +++ b/packages/clients/src/api/tem/v1alpha1/index.gen.ts @@ -40,6 +40,7 @@ export type { GetDomainLastStatusRequest, GetDomainRequest, GetEmailRequest, + GetProjectConsumptionRequest, GetProjectSettingsRequest, GetStatisticsRequest, GetWebhookRequest, @@ -51,18 +52,31 @@ export type { ListEmailsRequest, ListEmailsRequestOrderBy, ListEmailsResponse, + ListOfferSubscriptionsRequest, + ListOfferSubscriptionsResponse, + ListOffersRequest, + ListOffersResponse, + ListPoolsRequest, + ListPoolsResponse, ListWebhookEventsRequest, ListWebhookEventsRequestOrderBy, ListWebhookEventsResponse, ListWebhooksRequest, ListWebhooksRequestOrderBy, ListWebhooksResponse, + Offer, + OfferName, + OfferSubscription, + Pool, + PoolStatus, + ProjectConsumption, ProjectSettings, ProjectSettingsPeriodicReport, ProjectSettingsPeriodicReportFrequency, RevokeDomainRequest, Statistics, UpdateDomainRequest, + UpdateOfferSubscriptionRequest, UpdateProjectSettingsRequest, UpdateProjectSettingsRequestUpdatePeriodicReport, UpdateWebhookRequest, diff --git a/packages/clients/src/api/tem/v1alpha1/marshalling.gen.ts b/packages/clients/src/api/tem/v1alpha1/marshalling.gen.ts index 8e1d76bd6..a7ab3c7db 100644 --- a/packages/clients/src/api/tem/v1alpha1/marshalling.gen.ts +++ b/packages/clients/src/api/tem/v1alpha1/marshalling.gen.ts @@ -32,12 +32,20 @@ import type { ListBlocklistsResponse, ListDomainsResponse, ListEmailsResponse, + ListOfferSubscriptionsResponse, + ListOffersResponse, + ListPoolsResponse, ListWebhookEventsResponse, ListWebhooksResponse, + Offer, + OfferSubscription, + Pool, + ProjectConsumption, ProjectSettings, ProjectSettingsPeriodicReport, Statistics, UpdateDomainRequest, + UpdateOfferSubscriptionRequest, UpdateProjectSettingsRequest, UpdateProjectSettingsRequestUpdatePeriodicReport, UpdateWebhookRequest, @@ -174,6 +182,30 @@ export const unmarshalDomain = (data: unknown): Domain => { } as Domain } +export const unmarshalOfferSubscription = ( + data: unknown, +): OfferSubscription => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'OfferSubscription' failed as data isn't a dictionary.`, + ) + } + + return { + cancellationAvailableAt: unmarshalDate(data.cancellation_available_at), + includedMonthlyEmails: data.included_monthly_emails, + maxCustomBlocklistsPerDomain: data.max_custom_blocklists_per_domain, + maxDedicatedIps: data.max_dedicated_ips, + maxDomains: data.max_domains, + maxWebhooksPerDomain: data.max_webhooks_per_domain, + offerName: data.offer_name, + organizationId: data.organization_id, + projectId: data.project_id, + sla: data.sla, + subscribedAt: unmarshalDate(data.subscribed_at), + } as OfferSubscription +} + export const unmarshalWebhook = (data: unknown): Webhook => { if (!isJSONObject(data)) { throw new TypeError( @@ -376,6 +408,91 @@ export const unmarshalListEmailsResponse = ( } as ListEmailsResponse } +export const unmarshalListOfferSubscriptionsResponse = ( + data: unknown, +): ListOfferSubscriptionsResponse => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'ListOfferSubscriptionsResponse' failed as data isn't a dictionary.`, + ) + } + + return { + offerSubscriptions: unmarshalArrayOfObject( + data.offer_subscriptions, + unmarshalOfferSubscription, + ), + totalCount: data.total_count, + } as ListOfferSubscriptionsResponse +} + +const unmarshalOffer = (data: unknown): Offer => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'Offer' failed as data isn't a dictionary.`, + ) + } + + return { + commitmentPeriod: data.commitment_period, + createdAt: unmarshalDate(data.created_at), + includedMonthlyEmails: data.included_monthly_emails, + maxCustomBlocklistsPerDomain: data.max_custom_blocklists_per_domain, + maxDedicatedIps: data.max_dedicated_ips, + maxDomains: data.max_domains, + maxWebhooksPerDomain: data.max_webhooks_per_domain, + name: data.name, + sla: data.sla, + } as Offer +} + +export const unmarshalListOffersResponse = ( + data: unknown, +): ListOffersResponse => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'ListOffersResponse' failed as data isn't a dictionary.`, + ) + } + + return { + offers: unmarshalArrayOfObject(data.offers, unmarshalOffer), + totalCount: data.total_count, + } as ListOffersResponse +} + +const unmarshalPool = (data: unknown): Pool => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'Pool' failed as data isn't a dictionary.`, + ) + } + + return { + details: data.details, + ips: data.ips, + projectId: data.project_id, + reverse: data.reverse, + status: data.status, + zone: data.zone, + } as Pool +} + +export const unmarshalListPoolsResponse = ( + data: unknown, +): ListPoolsResponse => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'ListPoolsResponse' failed as data isn't a dictionary.`, + ) + } + + return { + pools: unmarshalArrayOfObject(data.pools, unmarshalPool), + totalCount: data.total_count, + } as ListPoolsResponse +} + const unmarshalWebhookEvent = (data: unknown): WebhookEvent => { if (!isJSONObject(data)) { throw new TypeError( @@ -431,6 +548,25 @@ export const unmarshalListWebhooksResponse = ( } as ListWebhooksResponse } +export const unmarshalProjectConsumption = ( + data: unknown, +): ProjectConsumption => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'ProjectConsumption' failed as data isn't a dictionary.`, + ) + } + + return { + customBlocklistsCount: data.custom_blocklists_count, + dedicatedIpsCount: data.dedicated_ips_count, + domainsCount: data.domains_count, + monthlyEmailsCount: data.monthly_emails_count, + projectId: data.project_id, + webhooksCount: data.webhooks_count, + } as ProjectConsumption +} + const unmarshalProjectSettingsPeriodicReport = ( data: unknown, ): ProjectSettingsPeriodicReport => { @@ -579,6 +715,14 @@ export const marshalUpdateDomainRequest = ( autoconfig: request.autoconfig, }) +export const marshalUpdateOfferSubscriptionRequest = ( + request: UpdateOfferSubscriptionRequest, + defaults: DefaultValues, +): Record => ({ + name: request.name, + project_id: request.projectId ?? defaults.defaultProjectId, +}) + const marshalUpdateProjectSettingsRequestUpdatePeriodicReport = ( request: UpdateProjectSettingsRequestUpdatePeriodicReport, defaults: DefaultValues, diff --git a/packages/clients/src/api/tem/v1alpha1/types.gen.ts b/packages/clients/src/api/tem/v1alpha1/types.gen.ts index df48abaa4..9f7bdbfb4 100644 --- a/packages/clients/src/api/tem/v1alpha1/types.gen.ts +++ b/packages/clients/src/api/tem/v1alpha1/types.gen.ts @@ -1,6 +1,6 @@ // This file was automatically generated. DO NOT EDIT. // If you have any remark or suggestion do not hesitate to open an issue. -import type { Region as ScwRegion } from '../../../bridge' +import type { Region as ScwRegion, Zone as ScwZone } from '../../../bridge' export type BlocklistType = | 'unknown_type' @@ -82,6 +82,15 @@ export type ListWebhookEventsRequestOrderBy = export type ListWebhooksRequestOrderBy = 'created_at_desc' | 'created_at_asc' +export type OfferName = 'unknown_name' | 'essential' | 'scale' + +export type PoolStatus = + | 'unknown_status' + | 'disabled' + | 'creating' + | 'ready' + | 'error' + export type ProjectSettingsPeriodicReportFrequency = | 'unknown_frequency' | 'monthly' @@ -320,6 +329,82 @@ export interface Domain { region: ScwRegion } +export interface OfferSubscription { + /** ID of the offer-subscription Organization. */ + organizationId: string + /** ID of the offer-subscription Project. */ + projectId: string + /** Name of the offer associated with the Project. */ + offerName: OfferName + /** Date and time of the subscription. */ + subscribedAt?: Date + /** Date and time of the end of the offer-subscription commitment. */ + cancellationAvailableAt?: Date + /** Service Level Agreement percentage of the offer-subscription. */ + sla: number + /** + * Max number of domains that can be associated with the offer-subscription + * for a particular Project. + */ + maxDomains: number + /** + * Max number of dedicated IPs that can be associated with the + * offer-subscription for a particular Project. + */ + maxDedicatedIps: number + /** + * Max number of webhooks that can be associated with the offer-subscription + * for a particular Project. + */ + maxWebhooksPerDomain: number + /** + * Max number of custom blocklists that can be associated with the + * offer-subscription for a particular Project. + */ + maxCustomBlocklistsPerDomain: number + /** Number of emails included in the offer-subscription per month. */ + includedMonthlyEmails: number +} + +export interface Offer { + /** Name of the offer. */ + name: OfferName + /** Date and time of the offer creation. */ + createdAt?: Date + /** Period of commitment. */ + commitmentPeriod?: string + /** Service Level Agreement percentage of the offer. */ + sla: number + /** Max number of checked domains that can be associated with the offer. */ + maxDomains: number + /** Max number of dedicated IPs that can be associated with the offer. */ + maxDedicatedIps: number + /** Number of emails included in the offer per month. */ + includedMonthlyEmails: number + /** Max number of webhooks that can be associated with the offer. */ + maxWebhooksPerDomain: number + /** + * Max number of active custom blocklists that can be associated with the + * offer. + */ + maxCustomBlocklistsPerDomain: number +} + +export interface Pool { + /** ID of the Project. */ + projectId: string + /** Status of the pool. */ + status: PoolStatus + /** Details of the pool. */ + details?: string + /** Zone of the pool. */ + zone?: ScwZone + /** IPs of the pool. */ + ips: string[] + /** Reverse hostname of all IPs of the pool. */ + reverse?: string +} + export interface WebhookEvent { /** ID of the Webhook Event. */ id: string @@ -569,6 +654,16 @@ export type GetEmailRequest = { emailId: string } +export type GetProjectConsumptionRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: ScwRegion + /** ID of the project. */ + projectId?: string +} + export type GetProjectSettingsRequest = { /** * Region to target. If none is passed will use default region from the @@ -712,6 +807,59 @@ export interface ListEmailsResponse { emails: Email[] } +export type ListOfferSubscriptionsRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: ScwRegion + /** ID of the Project. */ + projectId?: string +} + +export interface ListOfferSubscriptionsResponse { + /** Number of offer-subscriptions matching the requested criteria. */ + totalCount: number + /** Single page of offer-subscriptions matching the requested criteria. */ + offerSubscriptions: OfferSubscription[] +} + +export type ListOffersRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: ScwRegion +} + +export interface ListOffersResponse { + /** Number of offers matching the requested criteria. */ + totalCount: number + /** Single page of offers matching the requested criteria. */ + offers: Offer[] +} + +export type ListPoolsRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: ScwRegion + /** Requested page number. Value must be greater or equal to 1. */ + page?: number + /** Requested page size. Value must be between 1 and 1000. */ + pageSize?: number + /** ID of the Project. */ + projectId?: string +} + +export interface ListPoolsResponse { + /** Number of pools matching the requested criteria. */ + totalCount: number + /** Single page of pools matching the requested criteria. */ + pools: Pool[] +} + export type ListWebhookEventsRequest = { /** * Region to target. If none is passed will use default region from the @@ -774,6 +922,21 @@ export interface ListWebhooksResponse { webhooks: Webhook[] } +export interface ProjectConsumption { + /** ID of the project. */ + projectId: string + /** Number of domains in the project. */ + domainsCount: number + /** Number of dedicated IP in the project. */ + dedicatedIpsCount: number + /** Number of emails sent during the current month in the project. */ + monthlyEmailsCount: number + /** Number of webhooks in the project. */ + webhooksCount: number + /** Number of custom blocklists in the project. */ + customBlocklistsCount: number +} + export interface ProjectSettings { /** Information about your periodic report. */ periodicReport?: ProjectSettingsPeriodicReport @@ -834,6 +997,18 @@ export type UpdateDomainRequest = { autoconfig?: boolean } +export type UpdateOfferSubscriptionRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: ScwRegion + /** ID of the Project. */ + projectId?: string + /** Name of the offer-subscription. */ + name?: OfferName +} + export type UpdateProjectSettingsRequest = { /** * Region to target. If none is passed will use default region from the diff --git a/packages/clients/src/api/tem/v1alpha1/validation-rules.gen.ts b/packages/clients/src/api/tem/v1alpha1/validation-rules.gen.ts index e54e23186..7c3e4296a 100644 --- a/packages/clients/src/api/tem/v1alpha1/validation-rules.gen.ts +++ b/packages/clients/src/api/tem/v1alpha1/validation-rules.gen.ts @@ -92,6 +92,16 @@ export const ListEmailsRequest = { }, } +export const ListPoolsRequest = { + page: { + greaterThanOrEqual: 1, + }, + pageSize: { + greaterThanOrEqual: 1, + lessThanOrEqual: 1000, + }, +} + export const ListWebhookEventsRequest = { page: { greaterThan: 0,