@@ -8,7 +8,10 @@ import {
88 waitForResource ,
99} from '../../../bridge'
1010import type { Region as ScwRegion , WaitForOptions } from '../../../bridge'
11- import { HOSTING_TRANSIENT_STATUSES } from './content.gen'
11+ import {
12+ DOMAIN_TRANSIENT_STATUSES ,
13+ HOSTING_TRANSIENT_STATUSES ,
14+ } from './content.gen'
1215import {
1316 marshalDatabaseApiAssignDatabaseUserRequest ,
1417 marshalDatabaseApiChangeDatabaseUserPasswordRequest ,
@@ -28,6 +31,7 @@ import {
2831 unmarshalDatabase ,
2932 unmarshalDatabaseUser ,
3033 unmarshalDnsRecords ,
34+ unmarshalDomain ,
3135 unmarshalFtpAccount ,
3236 unmarshalHosting ,
3337 unmarshalListControlPanelsResponse ,
@@ -41,6 +45,7 @@ import {
4145 unmarshalMailAccount ,
4246 unmarshalResetHostingPasswordResponse ,
4347 unmarshalResourceSummary ,
48+ unmarshalSearchDomainsResponse ,
4449 unmarshalSession ,
4550} from './marshalling.gen'
4651import type {
@@ -61,8 +66,11 @@ import type {
6166 DatabaseUser ,
6267 DnsApiCheckUserOwnsDomainRequest ,
6368 DnsApiGetDomainDnsRecordsRequest ,
69+ DnsApiGetDomainRequest ,
70+ DnsApiSearchDomainsRequest ,
6471 DnsApiSyncDomainDnsRecordsRequest ,
6572 DnsRecords ,
73+ Domain ,
6674 FtpAccount ,
6775 FtpAccountApiChangeFtpAccountPasswordRequest ,
6876 FtpAccountApiCreateFtpAccountRequest ,
@@ -93,6 +101,7 @@ import type {
93101 OfferApiListOffersRequest ,
94102 ResetHostingPasswordResponse ,
95103 ResourceSummary ,
104+ SearchDomainsResponse ,
96105 Session ,
97106 WebsiteApiListWebsitesRequest ,
98107} from './types.gen'
@@ -427,7 +436,8 @@ export class DnsAPI extends ParentAPI {
427436 )
428437
429438 /**
430- * "Check whether you own this domain or not.".
439+ * Check whether you own this domain or not.. Check whether you own this
440+ * domain or not.
431441 *
432442 * @param request - The request {@link DnsApiCheckUserOwnsDomainRequest}
433443 * @returns A Promise of CheckUserOwnsDomainResponse
@@ -449,7 +459,8 @@ export class DnsAPI extends ParentAPI {
449459 )
450460
451461 /**
452- * "Synchronize your DNS records on the Elements Console and on cPanel.".
462+ * Synchronize your DNS records on the Elements Console and on cPanel..
463+ * Synchronize your DNS records on the Elements Console and on cPanel.
453464 *
454465 * @param request - The request {@link DnsApiSyncDomainDnsRecordsRequest}
455466 * @returns A Promise of DnsRecords
@@ -471,6 +482,71 @@ export class DnsAPI extends ParentAPI {
471482 } ,
472483 unmarshalDnsRecords ,
473484 )
485+
486+ /**
487+ * Search for available domains based on domain name.. Search for available
488+ * domains based on domain name.
489+ *
490+ * @param request - The request {@link DnsApiSearchDomainsRequest}
491+ * @returns A Promise of SearchDomainsResponse
492+ */
493+ searchDomains = ( request : Readonly < DnsApiSearchDomainsRequest > ) =>
494+ this . client . fetch < SearchDomainsResponse > (
495+ {
496+ method : 'GET' ,
497+ path : `/webhosting/v1/regions/${ validatePathParam ( 'region' , request . region ?? this . client . settings . defaultRegion ) } /search-domains` ,
498+ urlParams : urlParams (
499+ [ 'domain_name' , request . domainName ] ,
500+ [
501+ 'project_id' ,
502+ request . projectId ?? this . client . settings . defaultProjectId ,
503+ ] ,
504+ ) ,
505+ } ,
506+ unmarshalSearchDomainsResponse ,
507+ )
508+
509+ /**
510+ * Retrieve detailed information about a specific domain, including its
511+ * status, DNS configuration, and ownership.. Retrieve detailed information
512+ * about a specific domain, including its status, DNS configuration, and
513+ * ownership.
514+ *
515+ * @param request - The request {@link DnsApiGetDomainRequest}
516+ * @returns A Promise of Domain
517+ */
518+ getDomain = ( request : Readonly < DnsApiGetDomainRequest > ) =>
519+ this . client . fetch < Domain > (
520+ {
521+ method : 'GET' ,
522+ path : `/webhosting/v1/regions/${ validatePathParam ( 'region' , request . region ?? this . client . settings . defaultRegion ) } /domains/${ validatePathParam ( 'domainName' , request . domainName ) } ` ,
523+ urlParams : urlParams ( [
524+ 'project_id' ,
525+ request . projectId ?? this . client . settings . defaultProjectId ,
526+ ] ) ,
527+ } ,
528+ unmarshalDomain ,
529+ )
530+
531+ /**
532+ * Waits for {@link Domain} to be in a final state.
533+ *
534+ * @param request - The request {@link DnsApiGetDomainRequest}
535+ * @param options - The waiting options
536+ * @returns A Promise of Domain
537+ */
538+ waitForDomain = (
539+ request : Readonly < DnsApiGetDomainRequest > ,
540+ options ?: Readonly < WaitForOptions < Domain > > ,
541+ ) =>
542+ waitForResource (
543+ options ?. stop ??
544+ ( res =>
545+ Promise . resolve ( ! DOMAIN_TRANSIENT_STATUSES . includes ( res . status ) ) ) ,
546+ this . getDomain ,
547+ request ,
548+ options ,
549+ )
474550}
475551
476552/**
0 commit comments