Skip to content

Commit f92fbd0

Browse files
authored
feat(webhosting): add free subdomain support (#2302)
1 parent 6ac8901 commit f92fbd0

File tree

4 files changed

+125
-33
lines changed

4 files changed

+125
-33
lines changed

packages_generated/webhosting/src/v1/api.gen.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -644,6 +644,7 @@ export class HostingAPI extends ParentAPI {
644644
],
645645
['project_id', request.projectId],
646646
['statuses', request.statuses],
647+
['subdomain', request.subdomain],
647648
['tags', request.tags],
648649
),
649650
},

packages_generated/webhosting/src/v1/index.gen.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ export type {
6464
HostingApiListHostingsRequest,
6565
HostingApiResetHostingPasswordRequest,
6666
HostingApiUpdateHostingRequest,
67+
HostingDomain,
68+
HostingDomainCustomDomain,
6769
HostingStatus,
6870
HostingSummary,
6971
HostingUser,

packages_generated/webhosting/src/v1/marshalling.gen.ts

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ import type {
3434
Hosting,
3535
HostingApiCreateHostingRequest,
3636
HostingApiUpdateHostingRequest,
37+
HostingDomain,
38+
HostingDomainCustomDomain,
3739
HostingSummary,
3840
HostingUser,
3941
ListControlPanelsResponse,
@@ -232,6 +234,25 @@ const unmarshalPlatformControlPanelUrls = (
232234
} as PlatformControlPanelUrls
233235
}
234236

237+
const unmarshalHostingDomainCustomDomain = (
238+
data: unknown,
239+
): HostingDomainCustomDomain => {
240+
if (!isJSONObject(data)) {
241+
throw new TypeError(
242+
`Unmarshalling the type 'HostingDomainCustomDomain' failed as data isn't a dictionary.`,
243+
)
244+
}
245+
246+
return {
247+
autoConfigDomainDns: data.auto_config_domain_dns
248+
? unmarshalAutoConfigDomainDns(data.auto_config_domain_dns)
249+
: undefined,
250+
dnsStatus: data.dns_status,
251+
domain: data.domain,
252+
domainStatus: data.domain_status,
253+
} as HostingDomainCustomDomain
254+
}
255+
235256
const unmarshalOfferOption = (data: unknown): OfferOption => {
236257
if (!isJSONObject(data)) {
237258
throw new TypeError(
@@ -264,6 +285,21 @@ const unmarshalPlatformControlPanel = (data: unknown): PlatformControlPanel => {
264285
} as PlatformControlPanel
265286
}
266287

288+
const unmarshalHostingDomain = (data: unknown): HostingDomain => {
289+
if (!isJSONObject(data)) {
290+
throw new TypeError(
291+
`Unmarshalling the type 'HostingDomain' failed as data isn't a dictionary.`,
292+
)
293+
}
294+
295+
return {
296+
customDomain: data.custom_domain
297+
? unmarshalHostingDomainCustomDomain(data.custom_domain)
298+
: undefined,
299+
subdomain: data.subdomain,
300+
} as HostingDomain
301+
}
302+
267303
const unmarshalHostingUser = (data: unknown): HostingUser => {
268304
if (!isJSONObject(data)) {
269305
throw new TypeError(
@@ -329,7 +365,10 @@ export const unmarshalHosting = (data: unknown): Hosting => {
329365
createdAt: unmarshalDate(data.created_at),
330366
dnsStatus: data.dns_status ? data.dns_status : undefined,
331367
domain: data.domain,
332-
domainStatus: data.domain_status,
368+
domainInfo: data.domain_info
369+
? unmarshalHostingDomain(data.domain_info)
370+
: undefined,
371+
domainStatus: data.domain_status ? data.domain_status : undefined,
333372
id: data.id,
334373
ipv4: data.ipv4,
335374
offer: data.offer ? unmarshalOffer(data.offer) : undefined,
@@ -433,7 +472,10 @@ const unmarshalHostingSummary = (data: unknown): HostingSummary => {
433472
createdAt: unmarshalDate(data.created_at),
434473
dnsStatus: data.dns_status ? data.dns_status : undefined,
435474
domain: data.domain,
436-
domainStatus: data.domain_status,
475+
domainInfo: data.domain_info
476+
? unmarshalHostingDomain(data.domain_info)
477+
: undefined,
478+
domainStatus: data.domain_status ? data.domain_status : undefined,
437479
id: data.id,
438480
offerName: data.offer_name,
439481
projectId: data.project_id,
@@ -758,6 +800,7 @@ export const marshalHostingApiCreateHostingRequest = (
758800
: undefined,
759801
project_id: request.projectId ?? defaults.defaultProjectId,
760802
skip_welcome_email: request.skipWelcomeEmail,
803+
subdomain: request.subdomain,
761804
tags: request.tags,
762805
})
763806

packages_generated/webhosting/src/v1/types.gen.ts

Lines changed: 77 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,29 @@ export type OfferOptionWarning =
110110

111111
export type PlatformPlatformGroup = 'unknown_group' | 'default' | 'premium'
112112

113+
export interface AutoConfigDomainDns {
114+
/**
115+
* Whether or not to synchronize domain nameservers.
116+
*/
117+
nameservers: boolean
118+
/**
119+
* Whether or not to synchronize web records.
120+
*/
121+
webRecords: boolean
122+
/**
123+
* Whether or not to synchronize mail records.
124+
*/
125+
mailRecords: boolean
126+
/**
127+
* Whether or not to synchronize all types of records. Takes priority over the other fields.
128+
*/
129+
allRecords: boolean
130+
/**
131+
* No automatic domain configuration. Users must configure their domain for the Web Hosting to work.
132+
*/
133+
none: boolean
134+
}
135+
113136
export interface PlatformControlPanelUrls {
114137
/**
115138
* URL to connect to the hosting control panel dashboard.
@@ -121,6 +144,25 @@ export interface PlatformControlPanelUrls {
121144
webmail: string
122145
}
123146

147+
export interface HostingDomainCustomDomain {
148+
/**
149+
* Custom domain linked to the hosting plan.
150+
*/
151+
domain: string
152+
/**
153+
* Status of the custom domain verification.
154+
*/
155+
domainStatus: DomainStatus
156+
/**
157+
* Status of the DNS configuration for the custom domain.
158+
*/
159+
dnsStatus: DnsRecordsStatus
160+
/**
161+
* Indicates whether to auto-configure DNS for this domain.
162+
*/
163+
autoConfigDomainDns?: AutoConfigDomainDns
164+
}
165+
124166
export interface OfferOption {
125167
/**
126168
* Option ID.
@@ -167,32 +209,20 @@ export interface PlatformControlPanel {
167209
urls?: PlatformControlPanelUrls
168210
}
169211

170-
export interface CreateDatabaseRequestUser {
171-
username: string
172-
password: string
173-
}
174-
175-
export interface AutoConfigDomainDns {
176-
/**
177-
* Whether or not to synchronize domain nameservers.
178-
*/
179-
nameservers: boolean
180-
/**
181-
* Whether or not to synchronize web records.
182-
*/
183-
webRecords: boolean
184-
/**
185-
* Whether or not to synchronize mail records.
186-
*/
187-
mailRecords: boolean
212+
export interface HostingDomain {
188213
/**
189-
* Whether or not to synchronize all types of records. Takes priority over the other fields.
214+
* Optional free subdomain linked to the Web Hosting plan.
190215
*/
191-
allRecords: boolean
216+
subdomain: string
192217
/**
193-
* No automatic domain configuration. Users must configure their domain for the Web Hosting to work.
218+
* Optional custom domain linked to the Web Hosting plan.
194219
*/
195-
none: boolean
220+
customDomain?: HostingDomainCustomDomain
221+
}
222+
223+
export interface CreateDatabaseRequestUser {
224+
username: string
225+
password: string
196226
}
197227

198228
export interface CreateHostingRequestDomainConfiguration {
@@ -423,9 +453,9 @@ export interface HostingSummary {
423453
*/
424454
status: HostingStatus
425455
/**
426-
* Main domain associated with the Web Hosting plan.
456+
* @deprecated Main domain associated with the Web Hosting plan (deprecated, use domain_info).
427457
*/
428-
domain: string
458+
domain?: string
429459
/**
430460
* Whether the hosting is protected or not.
431461
*/
@@ -439,13 +469,17 @@ export interface HostingSummary {
439469
*/
440470
offerName: string
441471
/**
442-
* Main domain status of the Web Hosting plan.
472+
* @deprecated Main domain status of the Web Hosting plan.
443473
*/
444-
domainStatus: DomainStatus
474+
domainStatus?: DomainStatus
445475
/**
446476
* Region where the Web Hosting plan is hosted.
447477
*/
448478
region: ScwRegion
479+
/**
480+
* Domain configuration block (subdomain, optional custom domain, and DNS settings).
481+
*/
482+
domainInfo?: HostingDomain
449483
}
450484

451485
export interface MailAccount {
@@ -983,9 +1017,9 @@ export interface Hosting {
9831017
*/
9841018
status: HostingStatus
9851019
/**
986-
* Main domain associated with the Web Hosting plan.
1020+
* @deprecated Main domain associated with the Web Hosting plan (deprecated, use domain_info).
9871021
*/
988-
domain: string
1022+
domain?: string
9891023
/**
9901024
* Details of the Web Hosting plan offer and options.
9911025
*/
@@ -999,7 +1033,7 @@ export interface Hosting {
9991033
*/
10001034
tags: string[]
10011035
/**
1002-
* @deprecated DNS status of the Web Hosting plan.
1036+
* @deprecated DNS status of the Web Hosting plan (deprecated, use domain_info).
10031037
*/
10041038
dnsStatus?: DnsRecordsStatus
10051039
/**
@@ -1015,13 +1049,17 @@ export interface Hosting {
10151049
*/
10161050
user?: HostingUser
10171051
/**
1018-
* Main domain status of the Web Hosting plan.
1052+
* @deprecated Main domain status of the Web Hosting plan (deprecated, use domain_info).
10191053
*/
1020-
domainStatus: DomainStatus
1054+
domainStatus?: DomainStatus
10211055
/**
10221056
* Region where the Web Hosting plan is hosted.
10231057
*/
10241058
region: ScwRegion
1059+
/**
1060+
* Domain configuration block (subdomain, optional custom domain, and DNS settings).
1061+
*/
1062+
domainInfo?: HostingDomain
10251063
}
10261064

10271065
export type HostingApiCreateHostingRequest = {
@@ -1049,6 +1087,10 @@ export type HostingApiCreateHostingRequest = {
10491087
* Domain name to link to the Web Hosting plan. You must already own this domain name, and have completed the DNS validation process beforehand.
10501088
*/
10511089
domain: string
1090+
/**
1091+
* The name prefix to use as a free subdomain (for example, `mysite`) assigned to the Web Hosting plan. The full domain will be automatically created by adding it to the fixed base domain (e.g. `mysite.scw.site`). You do not need to include the base domain yourself.
1092+
*/
1093+
subdomain?: string
10521094
/**
10531095
* List of the Web Hosting plan options IDs with their quantities.
10541096
*/
@@ -1156,6 +1198,10 @@ export type HostingApiListHostingsRequest = {
11561198
* Name of the control panel to filter for, only Web Hosting plans from this control panel will be returned.
11571199
*/
11581200
controlPanels?: string[]
1201+
/**
1202+
* Optional free subdomain linked to the Web Hosting plan.
1203+
*/
1204+
subdomain?: string
11591205
}
11601206

11611207
export type HostingApiResetHostingPasswordRequest = {

0 commit comments

Comments
 (0)