Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
127 changes: 127 additions & 0 deletions packages/clients/src/api/tem/v1alpha1/api.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
marshalCreateEmailRequest,
marshalCreateWebhookRequest,
marshalUpdateDomainRequest,
marshalUpdateOfferSubscriptionRequest,
marshalUpdateProjectSettingsRequest,
marshalUpdateWebhookRequest,
unmarshalBulkCreateBlocklistsResponse,
Expand All @@ -28,8 +29,13 @@ import {
unmarshalListBlocklistsResponse,
unmarshalListDomainsResponse,
unmarshalListEmailsResponse,
unmarshalListOfferSubscriptionsResponse,
unmarshalListOffersResponse,
unmarshalListPoolsResponse,
unmarshalListWebhookEventsResponse,
unmarshalListWebhooksResponse,
unmarshalOfferSubscription,
unmarshalProjectConsumption,
unmarshalProjectSettings,
unmarshalStatistics,
unmarshalWebhook,
Expand All @@ -51,6 +57,7 @@ import type {
GetDomainLastStatusRequest,
GetDomainRequest,
GetEmailRequest,
GetProjectConsumptionRequest,
GetProjectSettingsRequest,
GetStatisticsRequest,
GetWebhookRequest,
Expand All @@ -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,
Expand Down Expand Up @@ -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<ListOfferSubscriptionsRequest> = {},
) =>
this.client.fetch<ListOfferSubscriptionsResponse>(
{
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<UpdateOfferSubscriptionRequest> = {},
) =>
this.client.fetch<OfferSubscription>(
{
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<ListOffersRequest> = {}) =>
this.client.fetch<ListOffersResponse>(
{
method: 'GET',
path: `/transactional-email/v1alpha1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/offers`,
},
unmarshalListOffersResponse,
)

protected pageOfListPools = (request: Readonly<ListPoolsRequest> = {}) =>
this.client.fetch<ListPoolsResponse>(
{
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<ListPoolsRequest> = {}) =>
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<GetProjectConsumptionRequest> = {},
) =>
this.client.fetch<ProjectConsumption>(
{
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,
)
}
14 changes: 14 additions & 0 deletions packages/clients/src/api/tem/v1alpha1/index.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export type {
GetDomainLastStatusRequest,
GetDomainRequest,
GetEmailRequest,
GetProjectConsumptionRequest,
GetProjectSettingsRequest,
GetStatisticsRequest,
GetWebhookRequest,
Expand All @@ -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,
Expand Down
144 changes: 144 additions & 0 deletions packages/clients/src/api/tem/v1alpha1/marshalling.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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 => {
Expand Down Expand Up @@ -579,6 +715,14 @@ export const marshalUpdateDomainRequest = (
autoconfig: request.autoconfig,
})

export const marshalUpdateOfferSubscriptionRequest = (
request: UpdateOfferSubscriptionRequest,
defaults: DefaultValues,
): Record<string, unknown> => ({
name: request.name,
project_id: request.projectId ?? defaults.defaultProjectId,
})

const marshalUpdateProjectSettingsRequestUpdatePeriodicReport = (
request: UpdateProjectSettingsRequestUpdatePeriodicReport,
defaults: DefaultValues,
Expand Down
Loading
Loading