Skip to content

Commit 7aae721

Browse files
authored
feat(tem): generate offers cli (#1918)
1 parent 3508637 commit 7aae721

File tree

5 files changed

+471
-1
lines changed

5 files changed

+471
-1
lines changed

packages/clients/src/api/tem/v1alpha1/api.gen.ts

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import {
1818
marshalCreateEmailRequest,
1919
marshalCreateWebhookRequest,
2020
marshalUpdateDomainRequest,
21+
marshalUpdateOfferSubscriptionRequest,
2122
marshalUpdateProjectSettingsRequest,
2223
marshalUpdateWebhookRequest,
2324
unmarshalBulkCreateBlocklistsResponse,
@@ -28,8 +29,13 @@ import {
2829
unmarshalListBlocklistsResponse,
2930
unmarshalListDomainsResponse,
3031
unmarshalListEmailsResponse,
32+
unmarshalListOfferSubscriptionsResponse,
33+
unmarshalListOffersResponse,
34+
unmarshalListPoolsResponse,
3135
unmarshalListWebhookEventsResponse,
3236
unmarshalListWebhooksResponse,
37+
unmarshalOfferSubscription,
38+
unmarshalProjectConsumption,
3339
unmarshalProjectSettings,
3440
unmarshalStatistics,
3541
unmarshalWebhook,
@@ -51,6 +57,7 @@ import type {
5157
GetDomainLastStatusRequest,
5258
GetDomainRequest,
5359
GetEmailRequest,
60+
GetProjectConsumptionRequest,
5461
GetProjectSettingsRequest,
5562
GetStatisticsRequest,
5663
GetWebhookRequest,
@@ -60,14 +67,23 @@ import type {
6067
ListDomainsResponse,
6168
ListEmailsRequest,
6269
ListEmailsResponse,
70+
ListOfferSubscriptionsRequest,
71+
ListOfferSubscriptionsResponse,
72+
ListOffersRequest,
73+
ListOffersResponse,
74+
ListPoolsRequest,
75+
ListPoolsResponse,
6376
ListWebhookEventsRequest,
6477
ListWebhookEventsResponse,
6578
ListWebhooksRequest,
6679
ListWebhooksResponse,
80+
OfferSubscription,
81+
ProjectConsumption,
6782
ProjectSettings,
6883
RevokeDomainRequest,
6984
Statistics,
7085
UpdateDomainRequest,
86+
UpdateOfferSubscriptionRequest,
7187
UpdateProjectSettingsRequest,
7288
UpdateWebhookRequest,
7389
Webhook,
@@ -624,4 +640,115 @@ export class API extends ParentAPI {
624640
method: 'DELETE',
625641
path: `/transactional-email/v1alpha1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/blocklists/${validatePathParam('blocklistId', request.blocklistId)}`,
626642
})
643+
644+
/**
645+
* Get information about subscribed offers. Retrieve information about the
646+
* offers you are subscribed to using the `project_id` and `region`
647+
* parameters.
648+
*
649+
* @param request - The request {@link ListOfferSubscriptionsRequest}
650+
* @returns A Promise of ListOfferSubscriptionsResponse
651+
*/
652+
listOfferSubscriptions = (
653+
request: Readonly<ListOfferSubscriptionsRequest> = {},
654+
) =>
655+
this.client.fetch<ListOfferSubscriptionsResponse>(
656+
{
657+
method: 'GET',
658+
path: `/transactional-email/v1alpha1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/offer-subscriptions`,
659+
urlParams: urlParams([
660+
'project_id',
661+
request.projectId ?? this.client.settings.defaultProjectId,
662+
]),
663+
},
664+
unmarshalListOfferSubscriptionsResponse,
665+
)
666+
667+
/**
668+
* Update a subscribed offer.
669+
*
670+
* @param request - The request {@link UpdateOfferSubscriptionRequest}
671+
* @returns A Promise of OfferSubscription
672+
*/
673+
updateOfferSubscription = (
674+
request: Readonly<UpdateOfferSubscriptionRequest> = {},
675+
) =>
676+
this.client.fetch<OfferSubscription>(
677+
{
678+
body: JSON.stringify(
679+
marshalUpdateOfferSubscriptionRequest(request, this.client.settings),
680+
),
681+
headers: jsonContentHeaders,
682+
method: 'PATCH',
683+
path: `/transactional-email/v1alpha1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/offer-subscriptions`,
684+
},
685+
unmarshalOfferSubscription,
686+
)
687+
688+
/**
689+
* List the available offers.. Retrieve the list of the available and
690+
* free-of-charge offers you can subscribe to.
691+
*
692+
* @param request - The request {@link ListOffersRequest}
693+
* @returns A Promise of ListOffersResponse
694+
*/
695+
listOffers = (request: Readonly<ListOffersRequest> = {}) =>
696+
this.client.fetch<ListOffersResponse>(
697+
{
698+
method: 'GET',
699+
path: `/transactional-email/v1alpha1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/offers`,
700+
},
701+
unmarshalListOffersResponse,
702+
)
703+
704+
protected pageOfListPools = (request: Readonly<ListPoolsRequest> = {}) =>
705+
this.client.fetch<ListPoolsResponse>(
706+
{
707+
method: 'GET',
708+
path: `/transactional-email/v1alpha1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/pools`,
709+
urlParams: urlParams(
710+
['page', request.page],
711+
[
712+
'page_size',
713+
request.pageSize ?? this.client.settings.defaultPageSize,
714+
],
715+
[
716+
'project_id',
717+
request.projectId ?? this.client.settings.defaultProjectId,
718+
],
719+
),
720+
},
721+
unmarshalListPoolsResponse,
722+
)
723+
724+
/**
725+
* Get information about a sending pool.. Retrieve information about a sending
726+
* pool, including its creation status and configuration parameters.
727+
*
728+
* @param request - The request {@link ListPoolsRequest}
729+
* @returns A Promise of ListPoolsResponse
730+
*/
731+
listPools = (request: Readonly<ListPoolsRequest> = {}) =>
732+
enrichForPagination('pools', this.pageOfListPools, request)
733+
734+
/**
735+
* Get project resource consumption.. Get project resource consumption.
736+
*
737+
* @param request - The request {@link GetProjectConsumptionRequest}
738+
* @returns A Promise of ProjectConsumption
739+
*/
740+
getProjectConsumption = (
741+
request: Readonly<GetProjectConsumptionRequest> = {},
742+
) =>
743+
this.client.fetch<ProjectConsumption>(
744+
{
745+
method: 'GET',
746+
path: `/transactional-email/v1alpha1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/project-consumption`,
747+
urlParams: urlParams([
748+
'project_id',
749+
request.projectId ?? this.client.settings.defaultProjectId,
750+
]),
751+
},
752+
unmarshalProjectConsumption,
753+
)
627754
}

packages/clients/src/api/tem/v1alpha1/index.gen.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ export type {
4040
GetDomainLastStatusRequest,
4141
GetDomainRequest,
4242
GetEmailRequest,
43+
GetProjectConsumptionRequest,
4344
GetProjectSettingsRequest,
4445
GetStatisticsRequest,
4546
GetWebhookRequest,
@@ -51,18 +52,31 @@ export type {
5152
ListEmailsRequest,
5253
ListEmailsRequestOrderBy,
5354
ListEmailsResponse,
55+
ListOfferSubscriptionsRequest,
56+
ListOfferSubscriptionsResponse,
57+
ListOffersRequest,
58+
ListOffersResponse,
59+
ListPoolsRequest,
60+
ListPoolsResponse,
5461
ListWebhookEventsRequest,
5562
ListWebhookEventsRequestOrderBy,
5663
ListWebhookEventsResponse,
5764
ListWebhooksRequest,
5865
ListWebhooksRequestOrderBy,
5966
ListWebhooksResponse,
67+
Offer,
68+
OfferName,
69+
OfferSubscription,
70+
Pool,
71+
PoolStatus,
72+
ProjectConsumption,
6073
ProjectSettings,
6174
ProjectSettingsPeriodicReport,
6275
ProjectSettingsPeriodicReportFrequency,
6376
RevokeDomainRequest,
6477
Statistics,
6578
UpdateDomainRequest,
79+
UpdateOfferSubscriptionRequest,
6680
UpdateProjectSettingsRequest,
6781
UpdateProjectSettingsRequestUpdatePeriodicReport,
6882
UpdateWebhookRequest,

packages/clients/src/api/tem/v1alpha1/marshalling.gen.ts

Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,20 @@ import type {
3232
ListBlocklistsResponse,
3333
ListDomainsResponse,
3434
ListEmailsResponse,
35+
ListOfferSubscriptionsResponse,
36+
ListOffersResponse,
37+
ListPoolsResponse,
3538
ListWebhookEventsResponse,
3639
ListWebhooksResponse,
40+
Offer,
41+
OfferSubscription,
42+
Pool,
43+
ProjectConsumption,
3744
ProjectSettings,
3845
ProjectSettingsPeriodicReport,
3946
Statistics,
4047
UpdateDomainRequest,
48+
UpdateOfferSubscriptionRequest,
4149
UpdateProjectSettingsRequest,
4250
UpdateProjectSettingsRequestUpdatePeriodicReport,
4351
UpdateWebhookRequest,
@@ -174,6 +182,30 @@ export const unmarshalDomain = (data: unknown): Domain => {
174182
} as Domain
175183
}
176184

185+
export const unmarshalOfferSubscription = (
186+
data: unknown,
187+
): OfferSubscription => {
188+
if (!isJSONObject(data)) {
189+
throw new TypeError(
190+
`Unmarshalling the type 'OfferSubscription' failed as data isn't a dictionary.`,
191+
)
192+
}
193+
194+
return {
195+
cancellationAvailableAt: unmarshalDate(data.cancellation_available_at),
196+
includedMonthlyEmails: data.included_monthly_emails,
197+
maxCustomBlocklistsPerDomain: data.max_custom_blocklists_per_domain,
198+
maxDedicatedIps: data.max_dedicated_ips,
199+
maxDomains: data.max_domains,
200+
maxWebhooksPerDomain: data.max_webhooks_per_domain,
201+
offerName: data.offer_name,
202+
organizationId: data.organization_id,
203+
projectId: data.project_id,
204+
sla: data.sla,
205+
subscribedAt: unmarshalDate(data.subscribed_at),
206+
} as OfferSubscription
207+
}
208+
177209
export const unmarshalWebhook = (data: unknown): Webhook => {
178210
if (!isJSONObject(data)) {
179211
throw new TypeError(
@@ -376,6 +408,91 @@ export const unmarshalListEmailsResponse = (
376408
} as ListEmailsResponse
377409
}
378410

411+
export const unmarshalListOfferSubscriptionsResponse = (
412+
data: unknown,
413+
): ListOfferSubscriptionsResponse => {
414+
if (!isJSONObject(data)) {
415+
throw new TypeError(
416+
`Unmarshalling the type 'ListOfferSubscriptionsResponse' failed as data isn't a dictionary.`,
417+
)
418+
}
419+
420+
return {
421+
offerSubscriptions: unmarshalArrayOfObject(
422+
data.offer_subscriptions,
423+
unmarshalOfferSubscription,
424+
),
425+
totalCount: data.total_count,
426+
} as ListOfferSubscriptionsResponse
427+
}
428+
429+
const unmarshalOffer = (data: unknown): Offer => {
430+
if (!isJSONObject(data)) {
431+
throw new TypeError(
432+
`Unmarshalling the type 'Offer' failed as data isn't a dictionary.`,
433+
)
434+
}
435+
436+
return {
437+
commitmentPeriod: data.commitment_period,
438+
createdAt: unmarshalDate(data.created_at),
439+
includedMonthlyEmails: data.included_monthly_emails,
440+
maxCustomBlocklistsPerDomain: data.max_custom_blocklists_per_domain,
441+
maxDedicatedIps: data.max_dedicated_ips,
442+
maxDomains: data.max_domains,
443+
maxWebhooksPerDomain: data.max_webhooks_per_domain,
444+
name: data.name,
445+
sla: data.sla,
446+
} as Offer
447+
}
448+
449+
export const unmarshalListOffersResponse = (
450+
data: unknown,
451+
): ListOffersResponse => {
452+
if (!isJSONObject(data)) {
453+
throw new TypeError(
454+
`Unmarshalling the type 'ListOffersResponse' failed as data isn't a dictionary.`,
455+
)
456+
}
457+
458+
return {
459+
offers: unmarshalArrayOfObject(data.offers, unmarshalOffer),
460+
totalCount: data.total_count,
461+
} as ListOffersResponse
462+
}
463+
464+
const unmarshalPool = (data: unknown): Pool => {
465+
if (!isJSONObject(data)) {
466+
throw new TypeError(
467+
`Unmarshalling the type 'Pool' failed as data isn't a dictionary.`,
468+
)
469+
}
470+
471+
return {
472+
details: data.details,
473+
ips: data.ips,
474+
projectId: data.project_id,
475+
reverse: data.reverse,
476+
status: data.status,
477+
zone: data.zone,
478+
} as Pool
479+
}
480+
481+
export const unmarshalListPoolsResponse = (
482+
data: unknown,
483+
): ListPoolsResponse => {
484+
if (!isJSONObject(data)) {
485+
throw new TypeError(
486+
`Unmarshalling the type 'ListPoolsResponse' failed as data isn't a dictionary.`,
487+
)
488+
}
489+
490+
return {
491+
pools: unmarshalArrayOfObject(data.pools, unmarshalPool),
492+
totalCount: data.total_count,
493+
} as ListPoolsResponse
494+
}
495+
379496
const unmarshalWebhookEvent = (data: unknown): WebhookEvent => {
380497
if (!isJSONObject(data)) {
381498
throw new TypeError(
@@ -431,6 +548,25 @@ export const unmarshalListWebhooksResponse = (
431548
} as ListWebhooksResponse
432549
}
433550

551+
export const unmarshalProjectConsumption = (
552+
data: unknown,
553+
): ProjectConsumption => {
554+
if (!isJSONObject(data)) {
555+
throw new TypeError(
556+
`Unmarshalling the type 'ProjectConsumption' failed as data isn't a dictionary.`,
557+
)
558+
}
559+
560+
return {
561+
customBlocklistsCount: data.custom_blocklists_count,
562+
dedicatedIpsCount: data.dedicated_ips_count,
563+
domainsCount: data.domains_count,
564+
monthlyEmailsCount: data.monthly_emails_count,
565+
projectId: data.project_id,
566+
webhooksCount: data.webhooks_count,
567+
} as ProjectConsumption
568+
}
569+
434570
const unmarshalProjectSettingsPeriodicReport = (
435571
data: unknown,
436572
): ProjectSettingsPeriodicReport => {
@@ -579,6 +715,14 @@ export const marshalUpdateDomainRequest = (
579715
autoconfig: request.autoconfig,
580716
})
581717

718+
export const marshalUpdateOfferSubscriptionRequest = (
719+
request: UpdateOfferSubscriptionRequest,
720+
defaults: DefaultValues,
721+
): Record<string, unknown> => ({
722+
name: request.name,
723+
project_id: request.projectId ?? defaults.defaultProjectId,
724+
})
725+
582726
const marshalUpdateProjectSettingsRequestUpdatePeriodicReport = (
583727
request: UpdateProjectSettingsRequestUpdatePeriodicReport,
584728
defaults: DefaultValues,

0 commit comments

Comments
 (0)