Skip to content

Commit

Permalink
Generate from OpenAPI
Browse files Browse the repository at this point in the history
  • Loading branch information
Wilson Lin committed Aug 22, 2023
1 parent 675c8ec commit e6257a7
Show file tree
Hide file tree
Showing 8 changed files with 994 additions and 335 deletions.
10 changes: 5 additions & 5 deletions lib/certificates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,10 +178,10 @@ export class Certificates {
account: number,
domain: string,
data: Partial<{
auto_renew?: boolean;
name?: string;
alternate_names?: Array<string>;
signature_algorithm?: string;
auto_renew: boolean;
name: string;
alternate_names: Array<string>;
signature_algorithm: string;
}>,
params: QueryParams & {} = {}
): Promise<{ data: types.LetsencryptCertificatePurchase }> =>
Expand Down Expand Up @@ -239,7 +239,7 @@ export class Certificates {
account: number,
domain: string,
certificate: number,
data: Partial<{ auto_renew?: boolean; signature_algorithm?: string }>,
data: Partial<{ auto_renew: boolean; signature_algorithm: string }>,
params: QueryParams & {} = {}
): Promise<{ data: types.LetsencryptCertificateRenewal }> =>
this._client.request(
Expand Down
12 changes: 6 additions & 6 deletions lib/contacts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,18 +79,18 @@ export class Contacts {
const method = (
account: number,
data: Partial<{
label?: string;
label: string;
first_name: string;
last_name: string;
address1: string;
address2: string | null;
address2: string;
city: string;
state_province: string;
postal_code: string;
country: string;
email: string;
phone: string;
fax: string | null;
fax: string;
organization_name: string;
job_title: string;
}>,
Expand Down Expand Up @@ -142,18 +142,18 @@ export class Contacts {
account: number,
contact: number,
data: Partial<{
label?: string;
label: string;
first_name: string;
last_name: string;
address1: string;
address2: string | null;
address2: string;
city: string;
state_province: string;
postal_code: string;
country: string;
email: string;
phone: string;
fax: string | null;
fax: string;
organization_name: string;
job_title: string;
}>,
Expand Down
4 changes: 4 additions & 0 deletions lib/domains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ export class Domains {
/**
* Creates a domain and the corresponding zone into the account.
*
* When creating a domain using Solo or Teams subscription, the DNS services
* for the zone will be automatically enabled and this will be charged on your
* following subscription renewal invoices.
*
* POST /{account}/domains
*
* @see https://developer.dnsimple.com/v2/domains/#createDomain
Expand Down
170 changes: 160 additions & 10 deletions lib/registrar.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { DNSimple, QueryParams } from "./main";
import { paginate } from "./paginate";
import type * as types from "./types";

export class Registrar {
Expand Down Expand Up @@ -92,6 +93,10 @@ export class Registrar {
*
* Your account must be active for this command to complete successfully. You will be automatically charged the registration fee upon successful registration, so please be careful with this command.
*
* When registering a domain using Solo or Teams subscription, the DNS services
* for the zone will be automatically enabled and this will be charged on your
* following subscription renewal invoices.
*
* POST /{account}/registrar/domains/{domain}/registrations
*
* @see https://developer.dnsimple.com/v2/registrar/#registerDomain
Expand Down Expand Up @@ -155,6 +160,10 @@ export class Registrar {
*
* Your account must be active for this command to complete successfully. You will be automatically charged the 1-year transfer fee upon successful transfer, so please be careful with this command. The transfer may take anywhere from a few minutes up to 7 days.
*
* When transfering a domain using Solo or Teams subscription, the DNS services
* for the zone will be automatically enabled and this will be charged on your
* following subscription renewal invoices.
*
* POST /{account}/registrar/domains/{domain}/transfers
*
* @see https://developer.dnsimple.com/v2/registrar/#transferDomain
Expand Down Expand Up @@ -343,7 +352,7 @@ export class Registrar {
account: number,
domain: string,
params: QueryParams & {} = {}
): Promise<{ data: Array<string> }> =>
): Promise<{ data: Array<types.DomainNameServer> }> =>
this._client.request(
"GET",
`/${account}/registrar/domains/${domain}/delegation`,
Expand All @@ -370,7 +379,7 @@ export class Registrar {
domain: string,
data: Partial<Array<string>>,
params: QueryParams & {} = {}
): Promise<{ data: Array<string> }> =>
): Promise<{ data: Array<types.DomainNameServer> }> =>
this._client.request(
"PUT",
`/${account}/registrar/domains/${domain}/delegation`,
Expand Down Expand Up @@ -594,30 +603,171 @@ export class Registrar {
})();

/**
* Starts a registrant change.
* List registrant changes in the account.
*
* This API is paginated. Call `listRegistrantChanges.iterateAll(account, params)` to get an asynchronous iterator over individual items across all pages. You can also use `await listRegistrantChanges.collectAll(account, params)` to quickly retrieve all items across all pages into an array. We suggest using `iterateAll` when possible, as `collectAll` will make all requests at once, which may increase latency and trigger rate limits.
*
* GET /{account}/registrar/registrant_changes
*
* @see https://developer.dnsimple.com/v2/registrar/#listRegistrantChanges
*
* @param account The account id
* @param params Query parameters
* @param params.sort Sort results. Default sorting is by id.
* @param params.state Only include results with a state field exactly matching the given string
* @param params.domain_id Only include results with a domain_id field exactly matching the given string
* @param params.contact_id Only include results with a contact_id field exactly matching the given string
*/
listRegistrantChanges = (() => {
const method = (
account: number,
params: QueryParams & {
sort?: "id:asc" | "id:desc";
state?: "new" | "pending" | "completed" | "cancelling" | "cancelled";
domain_id?: string;
contact_id?: string;
} = {}
): Promise<{
data: Array<types.RegistrantChange>;
pagination: types.Pagination;
}> =>
this._client.request(
"GET",
`/${account}/registrar/registrant_changes`,
null,
params
);
method.iterateAll = (
account: number,
params: QueryParams & {
sort?: "id:asc" | "id:desc";
state?: "new" | "pending" | "completed" | "cancelling" | "cancelled";
domain_id?: string;
contact_id?: string;
} = {}
) => paginate((page) => method(account, { ...params, page } as any));
method.collectAll = async (
account: number,
params: QueryParams & {
sort?: "id:asc" | "id:desc";
state?: "new" | "pending" | "completed" | "cancelling" | "cancelled";
domain_id?: string;
contact_id?: string;
} = {}
) => {
const items = [];
for await (const item of method.iterateAll(account, params)) {
items.push(item);
}
return items;
};
return method;
})();

/**
* Start registrant change.
*
* POST /{account}/registrar/registrant_changes
*
* @see https://developer.dnsimple.com/v2/registrar/#createRegistrantChange
*
* @param account The account id
* @param change The change details
* @param params Query parameters
*/
createRegistrantChange = (() => {
const method = (
account: number,
change: {
domain_id: string;
contact_id: string;
extended_attributes: Record<string, string>;
},
data: Partial<{
domain_id: string | number;
contact_id: string | number;
extended_attributes: types.TradeExtendedAttributes;
}>,
params: QueryParams & {} = {}
): Promise<{ data: types.RegistrantChange }> =>
this._client.request(
"POST",
`/${account}/registrar/registrant_changes`,
change,
data,
params
);
return method;
})();

/**
* Retrieves the requirements of a registrant change.
*
* POST /{account}/registrar/registrant_changes/check
*
* @see https://developer.dnsimple.com/v2/registrar/#checkRegistrantChange
*
* @param account The account id
* @param params Query parameters
*/
checkRegistrantChange = (() => {
const method = (
account: number,
data: Partial<{
domain_id: string | number;
contact_id: string | number;
}>,
params: QueryParams & {} = {}
): Promise<{ data: types.RegistrantChangeCheck }> =>
this._client.request(
"POST",
`/${account}/registrar/registrant_changes/check`,
data,
params
);
return method;
})();

/**
* Retrieves the details of an existing registrant change.
*
* GET /{account}/registrar/registrant_changes/{registrantchange}
*
* @see https://developer.dnsimple.com/v2/registrar/#getRegistrantChange
*
* @param account The account id
* @param registrantchange The registrant change id
* @param params Query parameters
*/
getRegistrantChange = (() => {
const method = (
account: number,
registrantchange: number,
params: QueryParams & {} = {}
): Promise<{ data: types.RegistrantChange }> =>
this._client.request(
"GET",
`/${account}/registrar/registrant_changes/${registrantchange}`,
null,
params
);
return method;
})();

/**
* Cancel an ongoing registrant change from the account.
*
* DELETE /{account}/registrar/registrant_changes/{registrantchange}
*
* @see https://developer.dnsimple.com/v2/registrar/#deleteRegistrantChange
*
* @param account The account id
* @param registrantchange The registrant change id
* @param params Query parameters
*/
deleteRegistrantChange = (() => {
const method = (
account: number,
registrantchange: number,
params: QueryParams & {} = {}
): Promise<{}> =>
this._client.request(
"DELETE",
`/${account}/registrar/registrant_changes/${registrantchange}`,
null,
params
);
return method;
Expand Down
4 changes: 4 additions & 0 deletions lib/secondary_dns.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,10 @@ export class SecondaryDns {
/**
* Creates a secondary zone into the account.
*
* When creating a secondary zone using Solo or Teams subscription, the DNS
* services for the zone will be automatically enabled and this will be charged
* on your following subscription renewal invoices.
*
* POST /{account}/secondary_dns/zones
*
* @see https://developer.dnsimple.com/v2/secondary-dns/#createSecondaryZone
Expand Down
Loading

0 comments on commit e6257a7

Please sign in to comment.