Skip to content

Commit 9ffd698

Browse files
authored
fix(domain): add SSL certificate and domain waiters (#232)
1 parent 2d03235 commit 9ffd698

File tree

3 files changed

+90
-3
lines changed

3 files changed

+90
-3
lines changed

packages/clients/src/api/domain/v2beta1/api.gen.ts

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,13 @@ import {
66
unmarshalScwFile,
77
urlParams,
88
validatePathParam,
9+
waitForResource,
910
} from '../../../bridge'
10-
import type { ScwFile } from '../../../bridge'
11+
import type { ScwFile, WaitForOptions } from '../../../bridge'
12+
import {
13+
DOMAIN_TRANSIENT_STATUSES,
14+
SSL_CERTIFICATE_TRANSIENT_STATUSES,
15+
} from './content.gen'
1116
import {
1217
marshalCloneDNSZoneRequest,
1318
marshalCreateDNSZoneRequest,
@@ -636,6 +641,28 @@ export class DomainV2Beta1GenAPI extends API {
636641
unmarshalSSLCertificate,
637642
)
638643

644+
/**
645+
* Waits for {@link SSLCertificate} to be in a final state.
646+
*
647+
* @param request - The request {@link GetSSLCertificateRequest}
648+
* @param options - The waiting options
649+
* @returns A Promise of SSLCertificate
650+
*/
651+
waitForSSLCertificate = (
652+
request: Readonly<GetSSLCertificateRequest>,
653+
options?: Readonly<WaitForOptions<SSLCertificate>>,
654+
) =>
655+
waitForResource(
656+
options?.stop ??
657+
(res =>
658+
Promise.resolve(
659+
!SSL_CERTIFICATE_TRANSIENT_STATUSES.includes(res.status),
660+
)),
661+
this.getSSLCertificate,
662+
request,
663+
options,
664+
)
665+
639666
/**
640667
* Create or return the zone TLS certificate
641668
*
@@ -1119,6 +1146,26 @@ export class DomainRegistrarV2Beta1GenAPI extends API {
11191146
unmarshalDomain,
11201147
)
11211148

1149+
/**
1150+
* Waits for {@link Domain} to be in a final state.
1151+
*
1152+
* @param request - The request {@link GetDomainRequest}
1153+
* @param options - The waiting options
1154+
* @returns A Promise of Domain
1155+
*/
1156+
waitForDomain = (
1157+
request: Readonly<RegistrarApiGetDomainRequest>,
1158+
options?: Readonly<WaitForOptions<Domain>>,
1159+
) =>
1160+
waitForResource(
1161+
options?.stop ??
1162+
(res =>
1163+
Promise.resolve(!DOMAIN_TRANSIENT_STATUSES.includes(res.status))),
1164+
this.getDomain,
1165+
request,
1166+
options,
1167+
)
1168+
11221169
/**
11231170
* Update the domain contacts or create a new one.<br/> If you add the same
11241171
* contact for multiple roles. Only one ID will be created and used for all of
Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,49 @@
11
// This file was automatically generated. DO NOT EDIT.
22
// If you have any remark or suggestion do not hesitate to open an issue.
3-
import type { DNSZoneStatus, HostStatus } from './types.gen'
3+
import type {
4+
DNSZoneStatus,
5+
DomainFeatureStatus,
6+
DomainRegistrationStatusTransferStatus,
7+
DomainStatus,
8+
HostStatus,
9+
SSLCertificateStatus,
10+
TaskStatus,
11+
} from './types.gen'
412

513
/** Lists transient statutes of the enum {@link DNSZoneStatus}. */
614
export const DNS_ZONE_TRANSIENT_STATUSES: DNSZoneStatus[] = ['pending']
715

16+
/** Lists transient statutes of the enum {@link DomainFeatureStatus}. */
17+
export const DOMAIN_FEATURE_TRANSIENT_STATUSES: DomainFeatureStatus[] = [
18+
'enabling',
19+
'disabling',
20+
]
21+
22+
/**
23+
* Lists transient statutes of the enum
24+
* {@link DomainRegistrationStatusTransferStatus}.
25+
*/
26+
export const DOMAIN_REGISTRATION_STATUS_TRANSFER_TRANSIENT_STATUSES: DomainRegistrationStatusTransferStatus[] =
27+
['pending', 'processing']
28+
29+
/** Lists transient statutes of the enum {@link DomainStatus}. */
30+
export const DOMAIN_TRANSIENT_STATUSES: DomainStatus[] = [
31+
'creating',
32+
'renewing',
33+
'xfering',
34+
'expiring',
35+
'updating',
36+
'checking',
37+
'deleting',
38+
]
39+
840
/** Lists transient statutes of the enum {@link HostStatus}. */
941
export const HOST_TRANSIENT_STATUSES: HostStatus[] = ['updating', 'deleting']
42+
43+
/** Lists transient statutes of the enum {@link SSLCertificateStatus}. */
44+
export const SSL_CERTIFICATE_TRANSIENT_STATUSES: SSLCertificateStatus[] = [
45+
'pending',
46+
]
47+
48+
/** Lists transient statutes of the enum {@link TaskStatus}. */
49+
export const TASK_TRANSIENT_STATUSES: TaskStatus[] = ['pending']

packages/clients/src/api/domain/v2beta1/types.gen.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ export type DomainStatus =
131131

132132
export type HostStatus = 'unknown_status' | 'active' | 'updating' | 'deleting'
133133

134-
export type LanguageCode = 'unknown_language_code' | 'en_US' | 'fr_FR'
134+
export type LanguageCode = 'unknown_language_code' | 'en_US' | 'fr_FR' | 'de_DE'
135135

136136
export type ListDNSZoneRecordsRequestOrderBy = 'name_asc' | 'name_desc'
137137

0 commit comments

Comments
 (0)