Skip to content

Commit 5a3468a

Browse files
feat(webhosting): add SyncDomainDnsRecords method (#1673)
Co-authored-by: Jules Castéran <[email protected]>
1 parent 5b56e6a commit 5a3468a

File tree

6 files changed

+79
-0
lines changed

6 files changed

+79
-0
lines changed

packages/clients/src/api/secret/v1beta1/marshalling.gen.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ export const unmarshalSecretVersion = (data: unknown): SecretVersion => {
5050

5151
return {
5252
createdAt: unmarshalDate(data.created_at),
53+
deletedAt: unmarshalDate(data.deleted_at),
5354
description: data.description,
5455
ephemeralProperties: data.ephemeral_properties
5556
? unmarshalEphemeralProperties(data.ephemeral_properties)

packages/clients/src/api/secret/v1beta1/types.gen.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,8 @@ export interface SecretVersion {
103103
createdAt?: Date
104104
/** Last update of the version. */
105105
updatedAt?: Date
106+
/** Date and time of the version's deletion. */
107+
deletedAt?: Date
106108
/** Description of the version. */
107109
description?: string
108110
/** Returns `true` if the version is the latest. */

packages/clients/src/api/webhosting/v1/api.gen.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {
1616
marshalDatabaseApiCreateDatabaseUserRequest,
1717
marshalDatabaseApiUnassignDatabaseUserRequest,
1818
marshalDnsApiCheckUserOwnsDomainRequest,
19+
marshalDnsApiSyncDomainDnsRecordsRequest,
1920
marshalFtpAccountApiChangeFtpAccountPasswordRequest,
2021
marshalFtpAccountApiCreateFtpAccountRequest,
2122
marshalHostingApiCreateHostingRequest,
@@ -60,6 +61,7 @@ import type {
6061
DatabaseUser,
6162
DnsApiCheckUserOwnsDomainRequest,
6263
DnsApiGetDomainDnsRecordsRequest,
64+
DnsApiSyncDomainDnsRecordsRequest,
6365
DnsRecords,
6466
FtpAccount,
6567
FtpAccountApiChangeFtpAccountPasswordRequest,
@@ -433,6 +435,30 @@ export class DnsAPI extends ParentAPI {
433435
},
434436
unmarshalCheckUserOwnsDomainResponse,
435437
)
438+
439+
/**
440+
* "Synchronize your DNS records on the Elements Console and on cPanel.".
441+
*
442+
* @param request - The request {@link DnsApiSyncDomainDnsRecordsRequest}
443+
* @returns A Promise of DnsRecords
444+
*/
445+
syncDomainDnsRecords = (
446+
request: Readonly<DnsApiSyncDomainDnsRecordsRequest>,
447+
) =>
448+
this.client.fetch<DnsRecords>(
449+
{
450+
body: JSON.stringify(
451+
marshalDnsApiSyncDomainDnsRecordsRequest(
452+
request,
453+
this.client.settings,
454+
),
455+
),
456+
headers: jsonContentHeaders,
457+
method: 'POST',
458+
path: `/webhosting/v1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/domains/${validatePathParam('domain', request.domain)}/sync-domain-dns-records`,
459+
},
460+
unmarshalDnsRecords,
461+
)
436462
}
437463

438464
/**

packages/clients/src/api/webhosting/v1/index.gen.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ export type {
3232
DatabaseUser,
3333
DnsApiCheckUserOwnsDomainRequest,
3434
DnsApiGetDomainDnsRecordsRequest,
35+
DnsApiSyncDomainDnsRecordsRequest,
3536
DnsRecord,
3637
DnsRecordStatus,
3738
DnsRecordType,
@@ -90,6 +91,7 @@ export type {
9091
ResetHostingPasswordResponse,
9192
ResourceSummary,
9293
Session,
94+
SyncDomainDnsRecordsRequestRecord,
9395
Website,
9496
WebsiteApiListWebsitesRequest,
9597
} from './types.gen'

packages/clients/src/api/webhosting/v1/marshalling.gen.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import type {
2121
DatabaseApiUnassignDatabaseUserRequest,
2222
DatabaseUser,
2323
DnsApiCheckUserOwnsDomainRequest,
24+
DnsApiSyncDomainDnsRecordsRequest,
2425
DnsRecord,
2526
DnsRecords,
2627
FtpAccount,
@@ -53,6 +54,7 @@ import type {
5354
ResetHostingPasswordResponse,
5455
ResourceSummary,
5556
Session,
57+
SyncDomainDnsRecordsRequestRecord,
5658
Website,
5759
} from './types.gen'
5860

@@ -568,6 +570,29 @@ export const marshalDnsApiCheckUserOwnsDomainRequest = (
568570
project_id: request.projectId ?? defaults.defaultProjectId,
569571
})
570572

573+
const marshalSyncDomainDnsRecordsRequestRecord = (
574+
request: SyncDomainDnsRecordsRequestRecord,
575+
defaults: DefaultValues,
576+
): Record<string, unknown> => ({
577+
name: request.name,
578+
type: request.type,
579+
})
580+
581+
export const marshalDnsApiSyncDomainDnsRecordsRequest = (
582+
request: DnsApiSyncDomainDnsRecordsRequest,
583+
defaults: DefaultValues,
584+
): Record<string, unknown> => ({
585+
custom_records:
586+
request.customRecords !== undefined
587+
? request.customRecords.map(elt =>
588+
marshalSyncDomainDnsRecordsRequestRecord(elt, defaults),
589+
)
590+
: undefined,
591+
update_all_records: request.updateAllRecords,
592+
update_mail_records: request.updateMailRecords,
593+
update_web_records: request.updateWebRecords,
594+
})
595+
571596
export const marshalFtpAccountApiChangeFtpAccountPasswordRequest = (
572597
request: FtpAccountApiChangeFtpAccountPasswordRequest,
573598
defaults: DefaultValues,

packages/clients/src/api/webhosting/v1/types.gen.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,11 @@ export interface OfferOptionRequest {
125125
quantity: number
126126
}
127127

128+
export interface SyncDomainDnsRecordsRequestRecord {
129+
name: string
130+
type: DnsRecordType
131+
}
132+
128133
export interface DnsRecord {
129134
/** Record name. */
130135
name: string
@@ -475,6 +480,24 @@ export type DnsApiGetDomainDnsRecordsRequest = {
475480
domain: string
476481
}
477482

483+
export type DnsApiSyncDomainDnsRecordsRequest = {
484+
/**
485+
* Region to target. If none is passed will use default region from the
486+
* config.
487+
*/
488+
region?: Region
489+
/** Domain for which the DNS records will be synchronized. */
490+
domain: string
491+
/** Whether or not to synchronize the web records. */
492+
updateWebRecords: boolean
493+
/** Whether or not to synchronize the mail records. */
494+
updateMailRecords: boolean
495+
/** Whether or not to synchronize all types of records. This one has priority. */
496+
updateAllRecords: boolean
497+
/** Custom records to synchronize. */
498+
customRecords?: SyncDomainDnsRecordsRequestRecord[]
499+
}
500+
478501
export interface DnsRecords {
479502
/** List of DNS records. */
480503
records: DnsRecord[]

0 commit comments

Comments
 (0)