Skip to content

feat(dom): add endpoint to list Tlds Offers #895

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 28, 2023
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
32 changes: 32 additions & 0 deletions packages/clients/src/api/domain/v2beta1/api.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ import {
unmarshalListRenewableDomainsResponse,
unmarshalListSSLCertificatesResponse,
unmarshalListTasksResponse,
unmarshalListTldsResponse,
unmarshalOrderResponse,
unmarshalRefreshDNSZoneResponse,
unmarshalRegisterExternalDomainResponse,
Expand Down Expand Up @@ -112,6 +113,7 @@ import type {
ListSSLCertificatesRequest,
ListSSLCertificatesResponse,
ListTasksResponse,
ListTldsResponse,
OrderResponse,
RefreshDNSZoneRequest,
RefreshDNSZoneResponse,
Expand All @@ -133,6 +135,7 @@ import type {
RegistrarApiListDomainsRequest,
RegistrarApiListRenewableDomainsRequest,
RegistrarApiListTasksRequest,
RegistrarApiListTldsRequest,
RegistrarApiLockDomainTransferRequest,
RegistrarApiRegisterExternalDomainRequest,
RegistrarApiRenewDomainsRequest,
Expand Down Expand Up @@ -1380,6 +1383,35 @@ export class RegistrarAPI extends ParentAPI {
unmarshalSearchAvailableDomainsResponse,
)

protected pageOfListTlds = (
request: Readonly<RegistrarApiListTldsRequest> = {},
) =>
this.client.fetch<ListTldsResponse>(
{
method: 'GET',
path: `/domain/v2beta1/tlds`,
urlParams: urlParams(
['order_by', request.orderBy ?? 'name_asc'],
['page', request.page],
[
'page_size',
request.pageSize ?? this.client.settings.defaultPageSize,
],
['tlds', request.tlds],
),
},
unmarshalListTldsResponse,
)

/**
* List TLD offers. Retrieve the list of TLDs and offers associated with them.
*
* @param request - The request {@link RegistrarApiListTldsRequest}
* @returns A Promise of ListTldsResponse
*/
listTlds = (request: Readonly<RegistrarApiListTldsRequest> = {}) =>
enrichForPagination('tlds', this.pageOfListTlds, request)

/**
* Create a hostname for a domain. Create a hostname for a domain with glue
* IPs.
Expand Down
3 changes: 3 additions & 0 deletions packages/clients/src/api/domain/v2beta1/index.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ export type {
ListSSLCertificatesResponse,
ListTasksRequestOrderBy,
ListTasksResponse,
ListTldsRequestOrderBy,
ListTldsResponse,
Nameserver,
NewContact,
OrderResponse,
Expand Down Expand Up @@ -130,6 +132,7 @@ export type {
RegistrarApiListDomainsRequest,
RegistrarApiListRenewableDomainsRequest,
RegistrarApiListTasksRequest,
RegistrarApiListTldsRequest,
RegistrarApiLockDomainTransferRequest,
RegistrarApiRegisterExternalDomainRequest,
RegistrarApiRenewDomainsRequest,
Expand Down
14 changes: 14 additions & 0 deletions packages/clients/src/api/domain/v2beta1/marshalling.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ import type {
ListRenewableDomainsResponse,
ListSSLCertificatesResponse,
ListTasksResponse,
ListTldsResponse,
Nameserver,
NewContact,
OrderResponse,
Expand Down Expand Up @@ -1126,6 +1127,19 @@ export const unmarshalListTasksResponse = (data: unknown) => {
} as ListTasksResponse
}

export const unmarshalListTldsResponse = (data: unknown) => {
if (!isJSONObject(data)) {
throw new TypeError(
`Unmarshalling the type 'ListTldsResponse' failed as data isn't a dictionary.`,
)
}

return {
tlds: unmarshalArrayOfObject(data.tlds, unmarshalTld),
totalCount: data.total_count,
} as ListTldsResponse
}

export const unmarshalOrderResponse = (data: unknown) => {
if (!isJSONObject(data)) {
throw new TypeError(
Expand Down
21 changes: 21 additions & 0 deletions packages/clients/src/api/domain/v2beta1/types.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,8 @@ export type ListTasksRequestOrderBy =
| 'updated_at_asc'
| 'updated_at_desc'

export type ListTldsRequestOrderBy = 'name_asc' | 'name_desc'

export type RawFormat = 'unknown_raw_format' | 'bind'

export type RenewableDomainStatus =
Expand Down Expand Up @@ -652,6 +654,14 @@ export interface ListTasksResponse {
tasks: Task[]
}

/** List tlds response. */
export interface ListTldsResponse {
/** Array of TLDs. */
tlds: Tld[]
/** Total count of TLDs returned. */
totalCount: number
}

export interface Nameserver {
name: string
ip: string[]
Expand Down Expand Up @@ -1333,6 +1343,17 @@ export type RegistrarApiSearchAvailableDomainsRequest = {
strictSearch: boolean
}

export type RegistrarApiListTldsRequest = {
/** Array of TLDs to return. */
tlds?: string[]
/** Page number for the returned Projects. */
page?: number
/** Maximum number of Project per page. */
pageSize?: number
/** Sort order of the returned TLDs. */
orderBy?: ListTldsRequestOrderBy
}

export type RegistrarApiCreateDomainHostRequest = {
domain: string
name: string
Expand Down