From 05fe0cd39da451b5c17a3e39b445e0c3d3b75968 Mon Sep 17 00:00:00 2001 From: scaleway-bot Date: Tue, 4 Feb 2025 15:14:34 +0000 Subject: [PATCH] feat: update generated APIs --- .../clients/src/api/webhosting/v1/api.gen.ts | 82 +++++++++++++- .../src/api/webhosting/v1/content.gen.ts | 14 ++- .../src/api/webhosting/v1/index.gen.ts | 11 ++ .../src/api/webhosting/v1/marshalling.gen.ts | 54 +++++++++ .../src/api/webhosting/v1/types.gen.ts | 106 ++++++++++++++++++ .../src/api/webhosting/v1alpha1/api.gen.ts | 2 +- 6 files changed, 264 insertions(+), 5 deletions(-) diff --git a/packages/clients/src/api/webhosting/v1/api.gen.ts b/packages/clients/src/api/webhosting/v1/api.gen.ts index 01438b567..4c2fd7c70 100644 --- a/packages/clients/src/api/webhosting/v1/api.gen.ts +++ b/packages/clients/src/api/webhosting/v1/api.gen.ts @@ -8,7 +8,10 @@ import { waitForResource, } from '../../../bridge' import type { Region as ScwRegion, WaitForOptions } from '../../../bridge' -import { HOSTING_TRANSIENT_STATUSES } from './content.gen' +import { + DOMAIN_TRANSIENT_STATUSES, + HOSTING_TRANSIENT_STATUSES, +} from './content.gen' import { marshalDatabaseApiAssignDatabaseUserRequest, marshalDatabaseApiChangeDatabaseUserPasswordRequest, @@ -28,6 +31,7 @@ import { unmarshalDatabase, unmarshalDatabaseUser, unmarshalDnsRecords, + unmarshalDomain, unmarshalFtpAccount, unmarshalHosting, unmarshalListControlPanelsResponse, @@ -41,6 +45,7 @@ import { unmarshalMailAccount, unmarshalResetHostingPasswordResponse, unmarshalResourceSummary, + unmarshalSearchDomainsResponse, unmarshalSession, } from './marshalling.gen' import type { @@ -61,8 +66,11 @@ import type { DatabaseUser, DnsApiCheckUserOwnsDomainRequest, DnsApiGetDomainDnsRecordsRequest, + DnsApiGetDomainRequest, + DnsApiSearchDomainsRequest, DnsApiSyncDomainDnsRecordsRequest, DnsRecords, + Domain, FtpAccount, FtpAccountApiChangeFtpAccountPasswordRequest, FtpAccountApiCreateFtpAccountRequest, @@ -93,6 +101,7 @@ import type { OfferApiListOffersRequest, ResetHostingPasswordResponse, ResourceSummary, + SearchDomainsResponse, Session, WebsiteApiListWebsitesRequest, } from './types.gen' @@ -427,7 +436,8 @@ export class DnsAPI extends ParentAPI { ) /** - * "Check whether you own this domain or not.". + * Check whether you own this domain or not.. Check whether you own this + * domain or not. * * @param request - The request {@link DnsApiCheckUserOwnsDomainRequest} * @returns A Promise of CheckUserOwnsDomainResponse @@ -449,7 +459,8 @@ export class DnsAPI extends ParentAPI { ) /** - * "Synchronize your DNS records on the Elements Console and on cPanel.". + * Synchronize your DNS records on the Elements Console and on cPanel.. + * Synchronize your DNS records on the Elements Console and on cPanel. * * @param request - The request {@link DnsApiSyncDomainDnsRecordsRequest} * @returns A Promise of DnsRecords @@ -471,6 +482,71 @@ export class DnsAPI extends ParentAPI { }, unmarshalDnsRecords, ) + + /** + * Search for available domains based on domain name.. Search for available + * domains based on domain name. + * + * @param request - The request {@link DnsApiSearchDomainsRequest} + * @returns A Promise of SearchDomainsResponse + */ + searchDomains = (request: Readonly) => + this.client.fetch( + { + method: 'GET', + path: `/webhosting/v1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/search-domains`, + urlParams: urlParams( + ['domain_name', request.domainName], + [ + 'project_id', + request.projectId ?? this.client.settings.defaultProjectId, + ], + ), + }, + unmarshalSearchDomainsResponse, + ) + + /** + * Retrieve detailed information about a specific domain, including its + * status, DNS configuration, and ownership.. Retrieve detailed information + * about a specific domain, including its status, DNS configuration, and + * ownership. + * + * @param request - The request {@link DnsApiGetDomainRequest} + * @returns A Promise of Domain + */ + getDomain = (request: Readonly) => + this.client.fetch( + { + method: 'GET', + path: `/webhosting/v1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/domains/${validatePathParam('domainName', request.domainName)}`, + urlParams: urlParams([ + 'project_id', + request.projectId ?? this.client.settings.defaultProjectId, + ]), + }, + unmarshalDomain, + ) + + /** + * Waits for {@link Domain} to be in a final state. + * + * @param request - The request {@link DnsApiGetDomainRequest} + * @param options - The waiting options + * @returns A Promise of Domain + */ + waitForDomain = ( + request: Readonly, + options?: Readonly>, + ) => + waitForResource( + options?.stop ?? + (res => + Promise.resolve(!DOMAIN_TRANSIENT_STATUSES.includes(res.status))), + this.getDomain, + request, + options, + ) } /** diff --git a/packages/clients/src/api/webhosting/v1/content.gen.ts b/packages/clients/src/api/webhosting/v1/content.gen.ts index d4b6b3eb5..2ec23fbde 100644 --- a/packages/clients/src/api/webhosting/v1/content.gen.ts +++ b/packages/clients/src/api/webhosting/v1/content.gen.ts @@ -1,6 +1,18 @@ // This file was automatically generated. DO NOT EDIT. // If you have any remark or suggestion do not hesitate to open an issue. -import type { HostingStatus, HostingSummaryStatus } from './types.gen' +import type { + DomainAvailabilityStatus, + DomainStatus, + HostingStatus, + HostingSummaryStatus, +} from './types.gen' + +/** Lists transient statutes of the enum {@link DomainAvailabilityStatus}. */ +export const DOMAIN_AVAILABILITY_TRANSIENT_STATUSES: DomainAvailabilityStatus[] = + ['validating'] + +/** Lists transient statutes of the enum {@link DomainStatus}. */ +export const DOMAIN_TRANSIENT_STATUSES: DomainStatus[] = ['validating'] /** Lists transient statutes of the enum {@link HostingStatus}. */ export const HOSTING_TRANSIENT_STATUSES: HostingStatus[] = [ diff --git a/packages/clients/src/api/webhosting/v1/index.gen.ts b/packages/clients/src/api/webhosting/v1/index.gen.ts index f82f79689..bf28767b8 100644 --- a/packages/clients/src/api/webhosting/v1/index.gen.ts +++ b/packages/clients/src/api/webhosting/v1/index.gen.ts @@ -32,12 +32,22 @@ export type { DatabaseUser, DnsApiCheckUserOwnsDomainRequest, DnsApiGetDomainDnsRecordsRequest, + DnsApiGetDomainRequest, + DnsApiSearchDomainsRequest, DnsApiSyncDomainDnsRecordsRequest, DnsRecord, DnsRecordStatus, DnsRecordType, DnsRecords, DnsRecordsStatus, + Domain, + DomainAction, + DomainAvailability, + DomainAvailabilityAction, + DomainAvailabilityStatus, + DomainDnsAction, + DomainStatus, + DomainZoneOwner, FtpAccount, FtpAccountApiChangeFtpAccountPasswordRequest, FtpAccountApiCreateFtpAccountRequest, @@ -90,6 +100,7 @@ export type { PlatformPlatformGroup, ResetHostingPasswordResponse, ResourceSummary, + SearchDomainsResponse, Session, SyncDomainDnsRecordsRequestRecord, Website, diff --git a/packages/clients/src/api/webhosting/v1/marshalling.gen.ts b/packages/clients/src/api/webhosting/v1/marshalling.gen.ts index 1751c9adf..cc7e962c3 100644 --- a/packages/clients/src/api/webhosting/v1/marshalling.gen.ts +++ b/packages/clients/src/api/webhosting/v1/marshalling.gen.ts @@ -24,6 +24,8 @@ import type { DnsApiSyncDomainDnsRecordsRequest, DnsRecord, DnsRecords, + Domain, + DomainAvailability, FtpAccount, FtpAccountApiChangeFtpAccountPasswordRequest, FtpAccountApiCreateFtpAccountRequest, @@ -53,6 +55,7 @@ import type { PlatformControlPanelUrls, ResetHostingPasswordResponse, ResourceSummary, + SearchDomainsResponse, Session, SyncDomainDnsRecordsRequestRecord, Website, @@ -170,6 +173,22 @@ export const unmarshalDnsRecords = (data: unknown): DnsRecords => { } as DnsRecords } +export const unmarshalDomain = (data: unknown): Domain => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'Domain' failed as data isn't a dictionary.`, + ) + } + + return { + availableActions: data.available_actions, + availableDnsActions: data.available_dns_actions, + name: data.name, + owner: data.owner, + status: data.status, + } as Domain +} + const unmarshalPlatformControlPanelUrls = ( data: unknown, ): PlatformControlPanelUrls => { @@ -500,6 +519,40 @@ export const unmarshalResourceSummary = (data: unknown): ResourceSummary => { } as ResourceSummary } +const unmarshalDomainAvailability = (data: unknown): DomainAvailability => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'DomainAvailability' failed as data isn't a dictionary.`, + ) + } + + return { + availableActions: data.available_actions, + canCreateHosting: data.can_create_hosting, + name: data.name, + price: data.price ? unmarshalMoney(data.price) : undefined, + status: data.status, + zoneName: data.zone_name, + } as DomainAvailability +} + +export const unmarshalSearchDomainsResponse = ( + data: unknown, +): SearchDomainsResponse => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'SearchDomainsResponse' failed as data isn't a dictionary.`, + ) + } + + return { + domainsAvailable: unmarshalArrayOfObject( + data.domains_available, + unmarshalDomainAvailability, + ), + } as SearchDomainsResponse +} + export const unmarshalSession = (data: unknown): Session => { if (!isJSONObject(data)) { throw new TypeError( @@ -593,6 +646,7 @@ export const marshalDnsApiSyncDomainDnsRecordsRequest = ( : undefined, update_all_records: request.updateAllRecords, update_mail_records: request.updateMailRecords, + update_nameservers: request.updateNameservers, update_web_records: request.updateWebRecords, }) diff --git a/packages/clients/src/api/webhosting/v1/types.gen.ts b/packages/clients/src/api/webhosting/v1/types.gen.ts index c0703c62b..14b96d2cf 100644 --- a/packages/clients/src/api/webhosting/v1/types.gen.ts +++ b/packages/clients/src/api/webhosting/v1/types.gen.ts @@ -16,6 +16,47 @@ export type DnsRecordType = export type DnsRecordsStatus = 'unknown_status' | 'valid' | 'invalid' +export type DomainAction = + | 'unknown_action' + | 'transfer' + | 'manage_external' + | 'renew' + +export type DomainAvailabilityAction = + | 'unknown_action' + | 'register' + | 'transfer' + | 'manage_external' + +export type DomainAvailabilityStatus = + | 'unknown_status' + | 'available' + | 'not_available' + | 'owned' + | 'validating' + | 'error' + +export type DomainDnsAction = + | 'unknown_dns_action' + | 'auto_config_all_records' + | 'auto_config_web_records' + | 'auto_config_mail_records' + | 'auto_config_nameservers' + +export type DomainStatus = + | 'unknown_status' + | 'valid' + | 'invalid' + | 'validating' + | 'error' + +export type DomainZoneOwner = + | 'unknown_zone_owner' + | 'external' + | 'scaleway' + | 'online' + | 'webhosting' + export type HostingStatus = | 'unknown_status' | 'delivering' @@ -290,6 +331,21 @@ export interface Website { sslStatus: boolean } +export interface DomainAvailability { + /** Fully qualified domain name (FQDN). */ + name: string + /** DNS zone associated with the domain. */ + zoneName: string + /** Availability status of the domain. */ + status: DomainAvailabilityStatus + /** A list of actions that can be performed on the domain. */ + availableActions: DomainAvailabilityAction[] + /** Whether a hosting can be created for this domain. */ + canCreateHosting: boolean + /** Price for registering the domain. */ + price?: Money +} + export interface CheckUserOwnsDomainResponse { /** Indicates whether the specified project owns the domain. */ ownsDomain: boolean @@ -498,6 +554,36 @@ export type DnsApiGetDomainDnsRecordsRequest = { domain: string } +export type DnsApiGetDomainRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: ScwRegion + /** Domain name to get. */ + domainName: string + /** + * ID of the Scaleway Project in which to get the domain to create the Web + * Hosting plan. + */ + projectId?: string +} + +export type DnsApiSearchDomainsRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: ScwRegion + /** Domain name to search. */ + domainName: string + /** + * ID of the Scaleway Project in which to search the domain to create the Web + * Hosting plan. + */ + projectId?: string +} + export type DnsApiSyncDomainDnsRecordsRequest = { /** * Region to target. If none is passed will use default region from the @@ -512,6 +598,8 @@ export type DnsApiSyncDomainDnsRecordsRequest = { updateMailRecords: boolean /** Whether or not to synchronize all types of records. This one has priority. */ updateAllRecords: boolean + /** Whether or not to synchronize domain nameservers. */ + updateNameservers: boolean /** Custom records to synchronize. */ customRecords?: SyncDomainDnsRecordsRequestRecord[] } @@ -525,6 +613,19 @@ export interface DnsRecords { status: DnsRecordsStatus } +export interface Domain { + /** Name of the domain. */ + name: string + /** Current status of the domain. */ + status: DomainStatus + /** Zone owner of the domain. */ + owner: DomainZoneOwner + /** A list of actions that can be performed on the domain. */ + availableActions: DomainAction[] + /** A list of DNS-related actions that can be auto configured for the domain. */ + availableDnsActions: DomainDnsAction[] +} + export type FtpAccountApiChangeFtpAccountPasswordRequest = { /** * Region to target. If none is passed will use default region from the @@ -934,6 +1035,11 @@ export interface ResourceSummary { websitesCount: number } +export interface SearchDomainsResponse { + /** List of domains availability. */ + domainsAvailable: DomainAvailability[] +} + export interface Session { /** Logged user's session URL. */ url: string diff --git a/packages/clients/src/api/webhosting/v1alpha1/api.gen.ts b/packages/clients/src/api/webhosting/v1alpha1/api.gen.ts index b6f9ebb4d..bdf7355ff 100644 --- a/packages/clients/src/api/webhosting/v1alpha1/api.gen.ts +++ b/packages/clients/src/api/webhosting/v1alpha1/api.gen.ts @@ -252,7 +252,7 @@ export class API extends ParentAPI { ), headers: jsonContentHeaders, method: 'POST', - path: `/webhosting/v1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/domains/${validatePathParam('domain', request.domain)}/check-ownership`, + path: `/webhosting/v1alpha1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/domains/${validatePathParam('domain', request.domain)}/check-ownership`, }, unmarshalCheckUserOwnsDomainResponse, )