Skip to content
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
46 changes: 46 additions & 0 deletions packages_generated/webhosting/src/v1/api.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import {
marshalDnsApiSyncDomainDnsRecordsRequest,
marshalFtpAccountApiChangeFtpAccountPasswordRequest,
marshalFtpAccountApiCreateFtpAccountRequest,
marshalHostingApiAddCustomDomainRequest,
marshalHostingApiCreateHostingRequest,
marshalHostingApiUpdateHostingRequest,
marshalMailAccountApiChangeMailAccountPasswordRequest,
Expand All @@ -39,6 +40,7 @@ import {
unmarshalDomain,
unmarshalFtpAccount,
unmarshalHosting,
unmarshalHostingSummary,
unmarshalListBackupItemsResponse,
unmarshalListBackupsResponse,
unmarshalListControlPanelsResponse,
Expand Down Expand Up @@ -92,14 +94,17 @@ import type {
FtpAccountApiListFtpAccountsRequest,
FtpAccountApiRemoveFtpAccountRequest,
Hosting,
HostingApiAddCustomDomainRequest,
HostingApiCreateHostingRequest,
HostingApiCreateSessionRequest,
HostingApiDeleteHostingRequest,
HostingApiGetHostingRequest,
HostingApiGetResourceSummaryRequest,
HostingApiListHostingsRequest,
HostingApiRemoveCustomDomainRequest,
HostingApiResetHostingPasswordRequest,
HostingApiUpdateHostingRequest,
HostingSummary,
ListBackupItemsResponse,
ListBackupsResponse,
ListControlPanelsResponse,
Expand Down Expand Up @@ -937,6 +942,47 @@ export class HostingAPI extends ParentAPI {
},
unmarshalResourceSummary,
)

/**
* Attach a custom domain to a webhosting.
*
* @param request - The request {@link HostingApiAddCustomDomainRequest}
* @returns A Promise of HostingSummary
*/
addCustomDomain = (request: Readonly<HostingApiAddCustomDomainRequest>) =>
this.client.fetch<HostingSummary>(
{
body: JSON.stringify(
marshalHostingApiAddCustomDomainRequest(
request,
this.client.settings,
),
),
headers: jsonContentHeaders,
method: 'POST',
path: `/webhosting/v1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/hostings/${validatePathParam('hostingId', request.hostingId)}/add-custom-domain`,
},
unmarshalHostingSummary,
)

/**
* Detach a custom domain from a webhosting.
*
* @param request - The request {@link HostingApiRemoveCustomDomainRequest}
* @returns A Promise of HostingSummary
*/
removeCustomDomain = (
request: Readonly<HostingApiRemoveCustomDomainRequest>,
) =>
this.client.fetch<HostingSummary>(
{
body: '{}',
headers: jsonContentHeaders,
method: 'POST',
path: `/webhosting/v1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/hostings/${validatePathParam('hostingId', request.hostingId)}/remove-custom-domain`,
},
unmarshalHostingSummary,
)
}

/**
Expand Down
2 changes: 2 additions & 0 deletions packages_generated/webhosting/src/v1/index.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,14 @@ export type {
FtpAccountApiListFtpAccountsRequest,
FtpAccountApiRemoveFtpAccountRequest,
Hosting,
HostingApiAddCustomDomainRequest,
HostingApiCreateHostingRequest,
HostingApiCreateSessionRequest,
HostingApiDeleteHostingRequest,
HostingApiGetHostingRequest,
HostingApiGetResourceSummaryRequest,
HostingApiListHostingsRequest,
HostingApiRemoveCustomDomainRequest,
HostingApiResetHostingPasswordRequest,
HostingApiUpdateHostingRequest,
HostingDomain,
Expand Down
158 changes: 83 additions & 75 deletions packages_generated/webhosting/src/v1/marshalling.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import type {
FtpAccountApiChangeFtpAccountPasswordRequest,
FtpAccountApiCreateFtpAccountRequest,
Hosting,
HostingApiAddCustomDomainRequest,
HostingApiCreateHostingRequest,
HostingApiUpdateHostingRequest,
HostingDomain,
Expand Down Expand Up @@ -128,6 +129,81 @@ export const unmarshalFtpAccount = (data: unknown): FtpAccount => {
} as FtpAccount
}

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

return {
allRecords: data.all_records,
mailRecords: data.mail_records,
nameservers: data.nameservers,
none: data.none,
webRecords: data.web_records,
} as AutoConfigDomainDns
}

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

return {
autoConfigDomainDns: data.auto_config_domain_dns
? unmarshalAutoConfigDomainDns(data.auto_config_domain_dns)
: undefined,
dnsStatus: data.dns_status,
domain: data.domain,
domainStatus: data.domain_status,
} as HostingDomainCustomDomain
}

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

return {
customDomain: data.custom_domain
? unmarshalHostingDomainCustomDomain(data.custom_domain)
: undefined,
subdomain: data.subdomain,
} as HostingDomain
}

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

return {
createdAt: unmarshalDate(data.created_at),
dnsStatus: data.dns_status ? data.dns_status : undefined,
domain: data.domain,
domainInfo: data.domain_info
? unmarshalHostingDomain(data.domain_info)
: undefined,
domainStatus: data.domain_status ? data.domain_status : undefined,
id: data.id,
offerName: data.offer_name,
projectId: data.project_id,
protected: data.protected,
region: data.region,
status: data.status,
updatedAt: unmarshalDate(data.updated_at),
} as HostingSummary
}

export const unmarshalMailAccount = (data: unknown): MailAccount => {
if (!isJSONObject(data)) {
throw new TypeError(
Expand Down Expand Up @@ -155,22 +231,6 @@ export const unmarshalCheckUserOwnsDomainResponse = (
} as CheckUserOwnsDomainResponse
}

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

return {
allRecords: data.all_records,
mailRecords: data.mail_records,
nameservers: data.nameservers,
none: data.none,
webRecords: data.web_records,
} as AutoConfigDomainDns
}

const unmarshalDnsRecord = (data: unknown): DnsRecord => {
if (!isJSONObject(data)) {
throw new TypeError(
Expand Down Expand Up @@ -258,25 +318,6 @@ const unmarshalPlatformControlPanelUrls = (
} as PlatformControlPanelUrls
}

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

return {
autoConfigDomainDns: data.auto_config_domain_dns
? unmarshalAutoConfigDomainDns(data.auto_config_domain_dns)
: undefined,
dnsStatus: data.dns_status,
domain: data.domain,
domainStatus: data.domain_status,
} as HostingDomainCustomDomain
}

const unmarshalOfferOption = (data: unknown): OfferOption => {
if (!isJSONObject(data)) {
throw new TypeError(
Expand Down Expand Up @@ -309,21 +350,6 @@ const unmarshalPlatformControlPanel = (data: unknown): PlatformControlPanel => {
} as PlatformControlPanel
}

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

return {
customDomain: data.custom_domain
? unmarshalHostingDomainCustomDomain(data.custom_domain)
: undefined,
subdomain: data.subdomain,
} as HostingDomain
}

const unmarshalHostingUser = (data: unknown): HostingUser => {
if (!isJSONObject(data)) {
throw new TypeError(
Expand Down Expand Up @@ -545,31 +571,6 @@ export const unmarshalListFtpAccountsResponse = (
} as ListFtpAccountsResponse
}

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

return {
createdAt: unmarshalDate(data.created_at),
dnsStatus: data.dns_status ? data.dns_status : undefined,
domain: data.domain,
domainInfo: data.domain_info
? unmarshalHostingDomain(data.domain_info)
: undefined,
domainStatus: data.domain_status ? data.domain_status : undefined,
id: data.id,
offerName: data.offer_name,
projectId: data.project_id,
protected: data.protected,
region: data.region,
status: data.status,
updatedAt: unmarshalDate(data.updated_at),
} as HostingSummary
}

export const unmarshalListHostingsResponse = (
data: unknown,
): ListHostingsResponse => {
Expand Down Expand Up @@ -870,6 +871,13 @@ export const marshalFtpAccountApiCreateFtpAccountRequest = (
username: request.username,
})

export const marshalHostingApiAddCustomDomainRequest = (
request: HostingApiAddCustomDomainRequest,
defaults: DefaultValues,
): Record<string, unknown> => ({
domain_name: request.domainName,
})

const marshalCreateHostingRequestDomainConfiguration = (
request: CreateHostingRequestDomainConfiguration,
defaults: DefaultValues,
Expand Down
26 changes: 26 additions & 0 deletions packages_generated/webhosting/src/v1/types.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1228,6 +1228,21 @@ export interface Hosting {
domainInfo?: HostingDomain
}

export type HostingApiAddCustomDomainRequest = {
/**
* Region to target. If none is passed will use default region from the config.
*/
region?: ScwRegion
/**
* Hosting ID to which the custom domain is attached to.
*/
hostingId: string
/**
* The custom domain name to attach to the hosting.
*/
domainName: string
}

export type HostingApiCreateHostingRequest = {
/**
* Region to target. If none is passed will use default region from the config.
Expand Down Expand Up @@ -1370,6 +1385,17 @@ export type HostingApiListHostingsRequest = {
subdomain?: string
}

export type HostingApiRemoveCustomDomainRequest = {
/**
* Region to target. If none is passed will use default region from the config.
*/
region?: ScwRegion
/**
* Hosting ID to which the custom domain is detached from.
*/
hostingId: string
}

export type HostingApiResetHostingPasswordRequest = {
/**
* Region to target. If none is passed will use default region from the config.
Expand Down
Loading