diff --git a/packages_generated/webhosting/src/v1/api.gen.ts b/packages_generated/webhosting/src/v1/api.gen.ts index 61b6ec2dc..127dcd920 100644 --- a/packages_generated/webhosting/src/v1/api.gen.ts +++ b/packages_generated/webhosting/src/v1/api.gen.ts @@ -24,6 +24,7 @@ import { marshalDatabaseApiUnassignDatabaseUserRequest, marshalDnsApiCheckUserOwnsDomainRequest, marshalDnsApiSyncDomainDnsRecordsRequest, + marshalFreeDomainApiCheckFreeDomainAvailabilityRequest, marshalFtpAccountApiChangeFtpAccountPasswordRequest, marshalFtpAccountApiCreateFtpAccountRequest, marshalHostingApiAddCustomDomainRequest, @@ -33,6 +34,7 @@ import { marshalMailAccountApiCreateMailAccountRequest, marshalMailAccountApiRemoveMailAccountRequest, unmarshalBackup, + unmarshalCheckFreeDomainAvailabilityResponse, unmarshalCheckUserOwnsDomainResponse, unmarshalDatabase, unmarshalDatabaseUser, @@ -46,6 +48,7 @@ import { unmarshalListControlPanelsResponse, unmarshalListDatabasesResponse, unmarshalListDatabaseUsersResponse, + unmarshalListFreeRootDomainsResponse, unmarshalListFtpAccountsResponse, unmarshalListHostingsResponse, unmarshalListMailAccountsResponse, @@ -66,6 +69,7 @@ import type { BackupApiListBackupsRequest, BackupApiRestoreBackupItemsRequest, BackupApiRestoreBackupRequest, + CheckFreeDomainAvailabilityResponse, CheckUserOwnsDomainResponse, ControlPanelApiListControlPanelsRequest, Database, @@ -88,6 +92,8 @@ import type { DnsApiSyncDomainDnsRecordsRequest, DnsRecords, Domain, + FreeDomainApiCheckFreeDomainAvailabilityRequest, + FreeDomainApiListFreeRootDomainsRequest, FtpAccount, FtpAccountApiChangeFtpAccountPasswordRequest, FtpAccountApiCreateFtpAccountRequest, @@ -110,6 +116,7 @@ import type { ListControlPanelsResponse, ListDatabasesResponse, ListDatabaseUsersResponse, + ListFreeRootDomainsResponse, ListFtpAccountsResponse, ListHostingsResponse, ListMailAccountsResponse, @@ -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, + ) => + this.client.fetch( + { + 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 = {}, + ) => + this.client.fetch( + { + 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 = {}, + ) => + enrichForPagination('rootDomains', this.pageOfListFreeRootDomains, request) +} + /** * Web Hosting FTP Account API. diff --git a/packages_generated/webhosting/src/v1/index.gen.ts b/packages_generated/webhosting/src/v1/index.gen.ts index fc01d5d4b..c09415f93 100644 --- a/packages_generated/webhosting/src/v1/index.gen.ts +++ b/packages_generated/webhosting/src/v1/index.gen.ts @@ -5,6 +5,7 @@ export { ControlPanelAPI, DatabaseAPI, DnsAPI, + FreeDomainAPI, FtpAccountAPI, HostingAPI, MailAccountAPI, @@ -25,6 +26,8 @@ export type { BackupItemGroup, BackupItemType, BackupStatus, + CheckFreeDomainAvailabilityResponse, + CheckFreeDomainAvailabilityResponseUnavailableReason, CheckUserOwnsDomainResponse, ControlPanel, ControlPanelApiListControlPanelsRequest, @@ -61,6 +64,9 @@ export type { DomainDnsAction, DomainStatus, DomainZoneOwner, + FreeDomain, + FreeDomainApiCheckFreeDomainAvailabilityRequest, + FreeDomainApiListFreeRootDomainsRequest, FtpAccount, FtpAccountApiChangeFtpAccountPasswordRequest, FtpAccountApiCreateFtpAccountRequest, @@ -90,6 +96,7 @@ export type { ListDatabasesResponse, ListDatabaseUsersRequestOrderBy, ListDatabaseUsersResponse, + ListFreeRootDomainsResponse, ListFtpAccountsRequestOrderBy, ListFtpAccountsResponse, ListHostingsRequestOrderBy, diff --git a/packages_generated/webhosting/src/v1/marshalling.gen.ts b/packages_generated/webhosting/src/v1/marshalling.gen.ts index d34081085..a9fe05a61 100644 --- a/packages_generated/webhosting/src/v1/marshalling.gen.ts +++ b/packages_generated/webhosting/src/v1/marshalling.gen.ts @@ -15,6 +15,7 @@ import type { BackupApiRestoreBackupItemsRequest, BackupItem, BackupItemGroup, + CheckFreeDomainAvailabilityResponse, CheckUserOwnsDomainResponse, ControlPanel, CreateDatabaseRequestUser, @@ -32,6 +33,8 @@ import type { DnsRecords, Domain, DomainAvailability, + FreeDomain, + FreeDomainApiCheckFreeDomainAvailabilityRequest, FtpAccount, FtpAccountApiChangeFtpAccountPasswordRequest, FtpAccountApiCreateFtpAccountRequest, @@ -48,6 +51,7 @@ import type { ListControlPanelsResponse, ListDatabasesResponse, ListDatabaseUsersResponse, + ListFreeRootDomainsResponse, ListFtpAccountsResponse, ListHostingsResponse, ListMailAccountsResponse, @@ -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 => { @@ -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 => { @@ -855,6 +905,14 @@ export const marshalDnsApiSyncDomainDnsRecordsRequest = ( update_web_records: request.updateWebRecords, }) +export const marshalFreeDomainApiCheckFreeDomainAvailabilityRequest = ( + request: FreeDomainApiCheckFreeDomainAvailabilityRequest, + defaults: DefaultValues, +): Record => ({ + root_domain: request.rootDomain, + slug: request.slug, +}) + export const marshalFtpAccountApiChangeFtpAccountPasswordRequest = ( request: FtpAccountApiChangeFtpAccountPasswordRequest, defaults: DefaultValues, diff --git a/packages_generated/webhosting/src/v1/types.gen.ts b/packages_generated/webhosting/src/v1/types.gen.ts index 7b379d1a1..e6ee21f38 100644 --- a/packages_generated/webhosting/src/v1/types.gen.ts +++ b/packages_generated/webhosting/src/v1/types.gen.ts @@ -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 = @@ -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 @@ -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. @@ -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. @@ -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. diff --git a/packages_generated/webhosting/src/v1/validation-rules.gen.ts b/packages_generated/webhosting/src/v1/validation-rules.gen.ts index bbadc1ac2..427f36ee7 100644 --- a/packages_generated/webhosting/src/v1/validation-rules.gen.ts +++ b/packages_generated/webhosting/src/v1/validation-rules.gen.ts @@ -41,6 +41,16 @@ export const DatabaseApiListDatabasesRequest = { }, } +export const FreeDomainApiListFreeRootDomainsRequest = { + page: { + greaterThan: 0, + }, + pageSize: { + greaterThan: 0, + lessThanOrEqual: 100, + }, +} + export const FtpAccountApiListFtpAccountsRequest = { page: { greaterThan: 0,