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
75 changes: 75 additions & 0 deletions packages_generated/webhosting/src/v1/api.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import {
marshalDatabaseApiUnassignDatabaseUserRequest,
marshalDnsApiCheckUserOwnsDomainRequest,
marshalDnsApiSyncDomainDnsRecordsRequest,
marshalFreeDomainApiCheckFreeDomainAvailabilityRequest,
marshalFtpAccountApiChangeFtpAccountPasswordRequest,
marshalFtpAccountApiCreateFtpAccountRequest,
marshalHostingApiAddCustomDomainRequest,
Expand All @@ -33,6 +34,7 @@ import {
marshalMailAccountApiCreateMailAccountRequest,
marshalMailAccountApiRemoveMailAccountRequest,
unmarshalBackup,
unmarshalCheckFreeDomainAvailabilityResponse,
unmarshalCheckUserOwnsDomainResponse,
unmarshalDatabase,
unmarshalDatabaseUser,
Expand All @@ -46,6 +48,7 @@ import {
unmarshalListControlPanelsResponse,
unmarshalListDatabasesResponse,
unmarshalListDatabaseUsersResponse,
unmarshalListFreeRootDomainsResponse,
unmarshalListFtpAccountsResponse,
unmarshalListHostingsResponse,
unmarshalListMailAccountsResponse,
Expand All @@ -66,6 +69,7 @@ import type {
BackupApiListBackupsRequest,
BackupApiRestoreBackupItemsRequest,
BackupApiRestoreBackupRequest,
CheckFreeDomainAvailabilityResponse,
CheckUserOwnsDomainResponse,
ControlPanelApiListControlPanelsRequest,
Database,
Expand All @@ -88,6 +92,8 @@ import type {
DnsApiSyncDomainDnsRecordsRequest,
DnsRecords,
Domain,
FreeDomainApiCheckFreeDomainAvailabilityRequest,
FreeDomainApiListFreeRootDomainsRequest,
FtpAccount,
FtpAccountApiChangeFtpAccountPasswordRequest,
FtpAccountApiCreateFtpAccountRequest,
Expand All @@ -110,6 +116,7 @@ import type {
ListControlPanelsResponse,
ListDatabasesResponse,
ListDatabaseUsersResponse,
ListFreeRootDomainsResponse,
ListFtpAccountsResponse,
ListHostingsResponse,
ListMailAccountsResponse,
Expand Down Expand Up @@ -986,6 +993,74 @@ export class HostingAPI extends ParentAPI {
)
}

/**
* Web Hosting free domain API.

This API allows you to list and check a free domain's validity.
*/
export class FreeDomainAPI extends ParentAPI {
/**
* Locality of this API.
* type ∈ {'zone','region','global','unspecified'}
*/
public static readonly LOCALITY: ApiLocality = toApiLocality({
regions: ['fr-par', 'nl-ams', 'pl-waw'],
})

/**
* Check whether a given slug and free domain combination is available.. Check whether a given slug and free domain combination is available.
*
* @param request - The request {@link FreeDomainApiCheckFreeDomainAvailabilityRequest}
* @returns A Promise of CheckFreeDomainAvailabilityResponse
*/
checkFreeDomainAvailability = (
request: Readonly<FreeDomainApiCheckFreeDomainAvailabilityRequest>,
) =>
this.client.fetch<CheckFreeDomainAvailabilityResponse>(
{
body: JSON.stringify(
marshalFreeDomainApiCheckFreeDomainAvailabilityRequest(
request,
this.client.settings,
),
),
headers: jsonContentHeaders,
method: 'POST',
path: `/webhosting/v1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/free-domains/check-availability`,
},
unmarshalCheckFreeDomainAvailabilityResponse,
)

protected pageOfListFreeRootDomains = (
request: Readonly<FreeDomainApiListFreeRootDomainsRequest> = {},
) =>
this.client.fetch<ListFreeRootDomainsResponse>(
{
method: 'GET',
path: `/webhosting/v1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/free-domains/root-domains`,
urlParams: urlParams(
['page', request.page],
[
'page_size',
request.pageSize ?? this.client.settings.defaultPageSize,
],
),
},
unmarshalListFreeRootDomainsResponse,
)

/**
* Retrieve the list of free root domains available for a Web Hosting.. Retrieve the list of free root domains available for a Web Hosting.
*
* @param request - The request {@link FreeDomainApiListFreeRootDomainsRequest}
* @returns A Promise of ListFreeRootDomainsResponse
*/
listFreeRootDomains = (
request: Readonly<FreeDomainApiListFreeRootDomainsRequest> = {},
) =>
enrichForPagination('rootDomains', this.pageOfListFreeRootDomains, request)
}

/**
* Web Hosting FTP Account API.

Expand Down
7 changes: 7 additions & 0 deletions packages_generated/webhosting/src/v1/index.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export {
ControlPanelAPI,
DatabaseAPI,
DnsAPI,
FreeDomainAPI,
FtpAccountAPI,
HostingAPI,
MailAccountAPI,
Expand All @@ -25,6 +26,8 @@ export type {
BackupItemGroup,
BackupItemType,
BackupStatus,
CheckFreeDomainAvailabilityResponse,
CheckFreeDomainAvailabilityResponseUnavailableReason,
CheckUserOwnsDomainResponse,
ControlPanel,
ControlPanelApiListControlPanelsRequest,
Expand Down Expand Up @@ -61,6 +64,9 @@ export type {
DomainDnsAction,
DomainStatus,
DomainZoneOwner,
FreeDomain,
FreeDomainApiCheckFreeDomainAvailabilityRequest,
FreeDomainApiListFreeRootDomainsRequest,
FtpAccount,
FtpAccountApiChangeFtpAccountPasswordRequest,
FtpAccountApiCreateFtpAccountRequest,
Expand Down Expand Up @@ -90,6 +96,7 @@ export type {
ListDatabasesResponse,
ListDatabaseUsersRequestOrderBy,
ListDatabaseUsersResponse,
ListFreeRootDomainsResponse,
ListFtpAccountsRequestOrderBy,
ListFtpAccountsResponse,
ListHostingsRequestOrderBy,
Expand Down
58 changes: 58 additions & 0 deletions packages_generated/webhosting/src/v1/marshalling.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import type {
BackupApiRestoreBackupItemsRequest,
BackupItem,
BackupItemGroup,
CheckFreeDomainAvailabilityResponse,
CheckUserOwnsDomainResponse,
ControlPanel,
CreateDatabaseRequestUser,
Expand All @@ -32,6 +33,8 @@ import type {
DnsRecords,
Domain,
DomainAvailability,
FreeDomain,
FreeDomainApiCheckFreeDomainAvailabilityRequest,
FtpAccount,
FtpAccountApiChangeFtpAccountPasswordRequest,
FtpAccountApiCreateFtpAccountRequest,
Expand All @@ -48,6 +51,7 @@ import type {
ListControlPanelsResponse,
ListDatabasesResponse,
ListDatabaseUsersResponse,
ListFreeRootDomainsResponse,
ListFtpAccountsResponse,
ListHostingsResponse,
ListMailAccountsResponse,
Expand Down Expand Up @@ -217,6 +221,37 @@ export const unmarshalMailAccount = (data: unknown): MailAccount => {
} as MailAccount
}

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

return {
rootDomain: data.root_domain,
slug: data.slug,
} as FreeDomain
}

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

return {
freeDomain: data.free_domain
? unmarshalFreeDomain(data.free_domain)
: undefined,
isAvailable: data.is_available,
reason: data.reason ? data.reason : undefined,
} as CheckFreeDomainAvailabilityResponse
}

export const unmarshalCheckUserOwnsDomainResponse = (
data: unknown,
): CheckUserOwnsDomainResponse => {
Expand Down Expand Up @@ -556,6 +591,21 @@ export const unmarshalListDatabasesResponse = (
} as ListDatabasesResponse
}

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

return {
rootDomains: data.root_domains,
totalCount: data.total_count,
} as ListFreeRootDomainsResponse
}

export const unmarshalListFtpAccountsResponse = (
data: unknown,
): ListFtpAccountsResponse => {
Expand Down Expand Up @@ -855,6 +905,14 @@ export const marshalDnsApiSyncDomainDnsRecordsRequest = (
update_web_records: request.updateWebRecords,
})

export const marshalFreeDomainApiCheckFreeDomainAvailabilityRequest = (
request: FreeDomainApiCheckFreeDomainAvailabilityRequest,
defaults: DefaultValues,
): Record<string, unknown> => ({
root_domain: request.rootDomain,
slug: request.slug,
})

export const marshalFtpAccountApiChangeFtpAccountPasswordRequest = (
request: FtpAccountApiChangeFtpAccountPasswordRequest,
defaults: DefaultValues,
Expand Down
77 changes: 77 additions & 0 deletions packages_generated/webhosting/src/v1/types.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,16 @@ export type BackupStatus =
| 'damaged'
| 'restoring'

export type CheckFreeDomainAvailabilityResponseUnavailableReason =
| 'unavailable_reason_unknown'
| 'unavailable_reason_already_used'
| 'unavailable_reason_too_short'
| 'unavailable_reason_too_long'
| 'unavailable_reason_invalid_characters'
| 'unavailable_reason_starts_or_ends_with_hyphen'
| 'unavailable_reason_contains_dots'
| 'unavailable_reason_contains_reserved_keyword'

export type DnsRecordStatus = 'unknown_status' | 'valid' | 'invalid'

export type DnsRecordType =
Expand Down Expand Up @@ -269,6 +279,17 @@ export interface HostingDomain {
customDomain?: HostingDomainCustomDomain
}

export interface FreeDomain {
/**
* Custom prefix used for the free domain.
*/
slug: string
/**
* Free root domain provided by Web Hosting, selected from the list returned by `ListFreeRootDomains`.
*/
rootDomain: string
}

export interface CreateDatabaseRequestUser {
username: string
password: string
Expand Down Expand Up @@ -701,6 +722,21 @@ export type BackupApiRestoreBackupRequest = {
backupId: string
}

export interface CheckFreeDomainAvailabilityResponse {
/**
* The free domain that was checked.
*/
freeDomain?: FreeDomain
/**
* Whether the free domain is available.
*/
isAvailable: boolean
/**
* Reason the domain is unavailable, if applicable.
*/
reason?: CheckFreeDomainAvailabilityResponseUnavailableReason
}

export interface CheckUserOwnsDomainResponse {
/**
* Indicates whether the specified project owns the domain.
Expand Down Expand Up @@ -1077,6 +1113,36 @@ export interface Domain {
autoConfigDomainDns?: AutoConfigDomainDns
}

export type FreeDomainApiCheckFreeDomainAvailabilityRequest = {
/**
* Region to target. If none is passed will use default region from the config.
*/
region?: ScwRegion
/**
* Custom prefix used for the free domain.
*/
slug: string
/**
* Free root domain provided by Web Hosting, selected from the list returned by `ListFreeRootDomains`.
*/
rootDomain: string
}

export type FreeDomainApiListFreeRootDomainsRequest = {
/**
* Region to target. If none is passed will use default region from the config.
*/
region?: ScwRegion
/**
* Page number to return, from the paginated results (must be a positive integer).
*/
page?: number
/**
* Number of free root domains to return (must be a positive integer lower or equal to 100).
*/
pageSize?: number
}

export type FtpAccountApiChangeFtpAccountPasswordRequest = {
/**
* Region to target. If none is passed will use default region from the config.
Expand Down Expand Up @@ -1493,6 +1559,17 @@ export interface ListDatabasesResponse {
databases: Database[]
}

export interface ListFreeRootDomainsResponse {
/**
* List of free root domains available for the Web Hosting.
*/
rootDomains: string[]
/**
* Total number of free root domains available.
*/
totalCount: number
}

export interface ListFtpAccountsResponse {
/**
* Total number of FTP accounts.
Expand Down
10 changes: 10 additions & 0 deletions packages_generated/webhosting/src/v1/validation-rules.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,16 @@ export const DatabaseApiListDatabasesRequest = {
},
}

export const FreeDomainApiListFreeRootDomainsRequest = {
page: {
greaterThan: 0,
},
pageSize: {
greaterThan: 0,
lessThanOrEqual: 100,
},
}

export const FtpAccountApiListFtpAccountsRequest = {
page: {
greaterThan: 0,
Expand Down
Loading