Skip to content

Commit

Permalink
feat(webhosting): add SyncDomainDnsRecords method (#1673)
Browse files Browse the repository at this point in the history
Co-authored-by: Jules Castéran <[email protected]>
  • Loading branch information
scaleway-bot and Codelax authored Dec 24, 2024
1 parent 5b56e6a commit 5a3468a
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/clients/src/api/secret/v1beta1/marshalling.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export const unmarshalSecretVersion = (data: unknown): SecretVersion => {

return {
createdAt: unmarshalDate(data.created_at),
deletedAt: unmarshalDate(data.deleted_at),
description: data.description,
ephemeralProperties: data.ephemeral_properties
? unmarshalEphemeralProperties(data.ephemeral_properties)
Expand Down
2 changes: 2 additions & 0 deletions packages/clients/src/api/secret/v1beta1/types.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ export interface SecretVersion {
createdAt?: Date
/** Last update of the version. */
updatedAt?: Date
/** Date and time of the version's deletion. */
deletedAt?: Date
/** Description of the version. */
description?: string
/** Returns `true` if the version is the latest. */
Expand Down
26 changes: 26 additions & 0 deletions packages/clients/src/api/webhosting/v1/api.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
marshalDatabaseApiCreateDatabaseUserRequest,
marshalDatabaseApiUnassignDatabaseUserRequest,
marshalDnsApiCheckUserOwnsDomainRequest,
marshalDnsApiSyncDomainDnsRecordsRequest,
marshalFtpAccountApiChangeFtpAccountPasswordRequest,
marshalFtpAccountApiCreateFtpAccountRequest,
marshalHostingApiCreateHostingRequest,
Expand Down Expand Up @@ -60,6 +61,7 @@ import type {
DatabaseUser,
DnsApiCheckUserOwnsDomainRequest,
DnsApiGetDomainDnsRecordsRequest,
DnsApiSyncDomainDnsRecordsRequest,
DnsRecords,
FtpAccount,
FtpAccountApiChangeFtpAccountPasswordRequest,
Expand Down Expand Up @@ -433,6 +435,30 @@ export class DnsAPI extends ParentAPI {
},
unmarshalCheckUserOwnsDomainResponse,
)

/**
* "Synchronize your DNS records on the Elements Console and on cPanel.".
*
* @param request - The request {@link DnsApiSyncDomainDnsRecordsRequest}
* @returns A Promise of DnsRecords
*/
syncDomainDnsRecords = (
request: Readonly<DnsApiSyncDomainDnsRecordsRequest>,
) =>
this.client.fetch<DnsRecords>(
{
body: JSON.stringify(
marshalDnsApiSyncDomainDnsRecordsRequest(
request,
this.client.settings,
),
),
headers: jsonContentHeaders,
method: 'POST',
path: `/webhosting/v1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/domains/${validatePathParam('domain', request.domain)}/sync-domain-dns-records`,
},
unmarshalDnsRecords,
)
}

/**
Expand Down
2 changes: 2 additions & 0 deletions packages/clients/src/api/webhosting/v1/index.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export type {
DatabaseUser,
DnsApiCheckUserOwnsDomainRequest,
DnsApiGetDomainDnsRecordsRequest,
DnsApiSyncDomainDnsRecordsRequest,
DnsRecord,
DnsRecordStatus,
DnsRecordType,
Expand Down Expand Up @@ -90,6 +91,7 @@ export type {
ResetHostingPasswordResponse,
ResourceSummary,
Session,
SyncDomainDnsRecordsRequestRecord,
Website,
WebsiteApiListWebsitesRequest,
} from './types.gen'
Expand Down
25 changes: 25 additions & 0 deletions packages/clients/src/api/webhosting/v1/marshalling.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import type {
DatabaseApiUnassignDatabaseUserRequest,
DatabaseUser,
DnsApiCheckUserOwnsDomainRequest,
DnsApiSyncDomainDnsRecordsRequest,
DnsRecord,
DnsRecords,
FtpAccount,
Expand Down Expand Up @@ -53,6 +54,7 @@ import type {
ResetHostingPasswordResponse,
ResourceSummary,
Session,
SyncDomainDnsRecordsRequestRecord,
Website,
} from './types.gen'

Expand Down Expand Up @@ -568,6 +570,29 @@ export const marshalDnsApiCheckUserOwnsDomainRequest = (
project_id: request.projectId ?? defaults.defaultProjectId,
})

const marshalSyncDomainDnsRecordsRequestRecord = (
request: SyncDomainDnsRecordsRequestRecord,
defaults: DefaultValues,
): Record<string, unknown> => ({
name: request.name,
type: request.type,
})

export const marshalDnsApiSyncDomainDnsRecordsRequest = (
request: DnsApiSyncDomainDnsRecordsRequest,
defaults: DefaultValues,
): Record<string, unknown> => ({
custom_records:
request.customRecords !== undefined
? request.customRecords.map(elt =>
marshalSyncDomainDnsRecordsRequestRecord(elt, defaults),
)
: undefined,
update_all_records: request.updateAllRecords,
update_mail_records: request.updateMailRecords,
update_web_records: request.updateWebRecords,
})

export const marshalFtpAccountApiChangeFtpAccountPasswordRequest = (
request: FtpAccountApiChangeFtpAccountPasswordRequest,
defaults: DefaultValues,
Expand Down
23 changes: 23 additions & 0 deletions packages/clients/src/api/webhosting/v1/types.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,11 @@ export interface OfferOptionRequest {
quantity: number
}

export interface SyncDomainDnsRecordsRequestRecord {
name: string
type: DnsRecordType
}

export interface DnsRecord {
/** Record name. */
name: string
Expand Down Expand Up @@ -475,6 +480,24 @@ export type DnsApiGetDomainDnsRecordsRequest = {
domain: string
}

export type DnsApiSyncDomainDnsRecordsRequest = {
/**
* Region to target. If none is passed will use default region from the
* config.
*/
region?: Region
/** Domain for which the DNS records will be synchronized. */
domain: string
/** Whether or not to synchronize the web records. */
updateWebRecords: boolean
/** Whether or not to synchronize the mail records. */
updateMailRecords: boolean
/** Whether or not to synchronize all types of records. This one has priority. */
updateAllRecords: boolean
/** Custom records to synchronize. */
customRecords?: SyncDomainDnsRecordsRequestRecord[]
}

export interface DnsRecords {
/** List of DNS records. */
records: DnsRecord[]
Expand Down

0 comments on commit 5a3468a

Please sign in to comment.