Skip to content

Commit 4cff719

Browse files
authored
feat(webhosting): update v1 uuid and add offer option price (#1639)
1 parent 56c0717 commit 4cff719

File tree

4 files changed

+214
-2
lines changed

4 files changed

+214
-2
lines changed

packages/clients/src/api/webhosting/v1/api.gen.ts

Lines changed: 57 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,18 @@ import {
1515
marshalDatabaseApiCreateDatabaseRequest,
1616
marshalDatabaseApiCreateDatabaseUserRequest,
1717
marshalDatabaseApiUnassignDatabaseUserRequest,
18+
marshalDnsApiCheckUserOwnsDomainRequest,
1819
marshalFtpAccountApiChangeFtpAccountPasswordRequest,
1920
marshalFtpAccountApiCreateFtpAccountRequest,
2021
marshalHostingApiCreateHostingRequest,
2122
marshalHostingApiUpdateHostingRequest,
2223
marshalMailAccountApiChangeMailAccountPasswordRequest,
2324
marshalMailAccountApiCreateMailAccountRequest,
2425
marshalMailAccountApiRemoveMailAccountRequest,
26+
unmarshalCheckUserOwnsDomainResponse,
2527
unmarshalDatabase,
2628
unmarshalDatabaseUser,
29+
unmarshalDnsRecords,
2730
unmarshalFtpAccount,
2831
unmarshalHosting,
2932
unmarshalListControlPanelsResponse,
@@ -40,6 +43,7 @@ import {
4043
unmarshalSession,
4144
} from './marshalling.gen'
4245
import type {
46+
CheckUserOwnsDomainResponse,
4347
ControlPanelApiListControlPanelsRequest,
4448
Database,
4549
DatabaseApiAssignDatabaseUserRequest,
@@ -54,6 +58,9 @@ import type {
5458
DatabaseApiListDatabasesRequest,
5559
DatabaseApiUnassignDatabaseUserRequest,
5660
DatabaseUser,
61+
DnsApiCheckUserOwnsDomainRequest,
62+
DnsApiGetDomainDnsRecordsRequest,
63+
DnsRecords,
5764
FtpAccount,
5865
FtpAccountApiChangeFtpAccountPasswordRequest,
5966
FtpAccountApiCreateFtpAccountRequest,
@@ -93,13 +100,13 @@ const jsonContentHeaders = {
93100
}
94101

95102
/**
96-
* Web Hosting API.
103+
* Web Hosting Control Panel API.
97104
*
98105
* This API allows you to manage your Web Hosting services.
99106
*/
100107
export class ControlPanelAPI extends ParentAPI {
101108
/** Lists the available regions of the API. */
102-
public static readonly LOCALITIES: Region[] = ['fr-par', 'nl-ams']
109+
public static readonly LOCALITIES: Region[] = ['fr-par', 'nl-ams', 'pl-waw']
103110

104111
protected pageOfListControlPanels = (
105112
request: Readonly<ControlPanelApiListControlPanelsRequest> = {},
@@ -380,6 +387,54 @@ export class DatabaseAPI extends ParentAPI {
380387
)
381388
}
382389

390+
/**
391+
* Web Hosting Dns API.
392+
*
393+
* This API allows you to manage your Web Hosting services.
394+
*/
395+
export class DnsAPI extends ParentAPI {
396+
/** Lists the available regions of the API. */
397+
public static readonly LOCALITIES: Region[] = ['fr-par', 'nl-ams', 'pl-waw']
398+
399+
/**
400+
* Get DNS records. Get the set of DNS records of a specified domain
401+
* associated with a Web Hosting plan's domain.
402+
*
403+
* @param request - The request {@link DnsApiGetDomainDnsRecordsRequest}
404+
* @returns A Promise of DnsRecords
405+
*/
406+
getDomainDnsRecords = (request: Readonly<DnsApiGetDomainDnsRecordsRequest>) =>
407+
this.client.fetch<DnsRecords>(
408+
{
409+
method: 'GET',
410+
path: `/webhosting/v1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/domains/${validatePathParam('domain', request.domain)}/dns-records`,
411+
},
412+
unmarshalDnsRecords,
413+
)
414+
415+
/**
416+
* "Check whether you own this domain or not.".
417+
*
418+
* @param request - The request {@link DnsApiCheckUserOwnsDomainRequest}
419+
* @returns A Promise of CheckUserOwnsDomainResponse
420+
*/
421+
checkUserOwnsDomain = (request: Readonly<DnsApiCheckUserOwnsDomainRequest>) =>
422+
this.client.fetch<CheckUserOwnsDomainResponse>(
423+
{
424+
body: JSON.stringify(
425+
marshalDnsApiCheckUserOwnsDomainRequest(
426+
request,
427+
this.client.settings,
428+
),
429+
),
430+
headers: jsonContentHeaders,
431+
method: 'POST',
432+
path: `/webhosting/v1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/domains/${validatePathParam('domain', request.domain)}/check-ownership`,
433+
},
434+
unmarshalCheckUserOwnsDomainResponse,
435+
)
436+
}
437+
383438
/**
384439
* Web Hosting Offer API.
385440
*

packages/clients/src/api/webhosting/v1/index.gen.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
export {
44
ControlPanelAPI,
55
DatabaseAPI,
6+
DnsAPI,
67
FtpAccountAPI,
78
HostingAPI,
89
MailAccountAPI,
@@ -11,6 +12,7 @@ export {
1112
} from './api.gen'
1213
export * from './content.gen'
1314
export type {
15+
CheckUserOwnsDomainResponse,
1416
ControlPanel,
1517
ControlPanelApiListControlPanelsRequest,
1618
CreateHostingRequestDomainConfiguration,
@@ -27,6 +29,12 @@ export type {
2729
DatabaseApiListDatabasesRequest,
2830
DatabaseApiUnassignDatabaseUserRequest,
2931
DatabaseUser,
32+
DnsApiCheckUserOwnsDomainRequest,
33+
DnsApiGetDomainDnsRecordsRequest,
34+
DnsRecord,
35+
DnsRecordStatus,
36+
DnsRecordType,
37+
DnsRecords,
3038
DnsRecordsStatus,
3139
FtpAccount,
3240
FtpAccountApiChangeFtpAccountPasswordRequest,
@@ -66,6 +74,8 @@ export type {
6674
MailAccountApiCreateMailAccountRequest,
6775
MailAccountApiListMailAccountsRequest,
6876
MailAccountApiRemoveMailAccountRequest,
77+
Nameserver,
78+
NameserverStatus,
6979
Offer,
7080
OfferApiListOffersRequest,
7181
OfferOption,

packages/clients/src/api/webhosting/v1/marshalling.gen.ts

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
} from '../../../bridge'
99
import type { DefaultValues } from '../../../bridge'
1010
import type {
11+
CheckUserOwnsDomainResponse,
1112
ControlPanel,
1213
CreateHostingRequestDomainConfiguration,
1314
Database,
@@ -17,6 +18,9 @@ import type {
1718
DatabaseApiCreateDatabaseUserRequest,
1819
DatabaseApiUnassignDatabaseUserRequest,
1920
DatabaseUser,
21+
DnsApiCheckUserOwnsDomainRequest,
22+
DnsRecord,
23+
DnsRecords,
2024
FtpAccount,
2125
FtpAccountApiChangeFtpAccountPasswordRequest,
2226
FtpAccountApiCreateFtpAccountRequest,
@@ -37,6 +41,7 @@ import type {
3741
MailAccountApiChangeMailAccountPasswordRequest,
3842
MailAccountApiCreateMailAccountRequest,
3943
MailAccountApiRemoveMailAccountRequest,
44+
Nameserver,
4045
Offer,
4146
OfferOption,
4247
OfferOptionRequest,
@@ -101,6 +106,65 @@ export const unmarshalMailAccount = (data: unknown): MailAccount => {
101106
} as MailAccount
102107
}
103108

109+
export const unmarshalCheckUserOwnsDomainResponse = (
110+
data: unknown,
111+
): CheckUserOwnsDomainResponse => {
112+
if (!isJSONObject(data)) {
113+
throw new TypeError(
114+
`Unmarshalling the type 'CheckUserOwnsDomainResponse' failed as data isn't a dictionary.`,
115+
)
116+
}
117+
118+
return {
119+
ownsDomain: data.owns_domain,
120+
} as CheckUserOwnsDomainResponse
121+
}
122+
123+
const unmarshalDnsRecord = (data: unknown): DnsRecord => {
124+
if (!isJSONObject(data)) {
125+
throw new TypeError(
126+
`Unmarshalling the type 'DnsRecord' failed as data isn't a dictionary.`,
127+
)
128+
}
129+
130+
return {
131+
name: data.name,
132+
priority: data.priority,
133+
status: data.status,
134+
ttl: data.ttl,
135+
type: data.type,
136+
value: data.value,
137+
} as DnsRecord
138+
}
139+
140+
const unmarshalNameserver = (data: unknown): Nameserver => {
141+
if (!isJSONObject(data)) {
142+
throw new TypeError(
143+
`Unmarshalling the type 'Nameserver' failed as data isn't a dictionary.`,
144+
)
145+
}
146+
147+
return {
148+
hostname: data.hostname,
149+
isDefault: data.is_default,
150+
status: data.status,
151+
} as Nameserver
152+
}
153+
154+
export const unmarshalDnsRecords = (data: unknown): DnsRecords => {
155+
if (!isJSONObject(data)) {
156+
throw new TypeError(
157+
`Unmarshalling the type 'DnsRecords' failed as data isn't a dictionary.`,
158+
)
159+
}
160+
161+
return {
162+
nameServers: unmarshalArrayOfObject(data.name_servers, unmarshalNameserver),
163+
records: unmarshalArrayOfObject(data.records, unmarshalDnsRecord),
164+
status: data.status,
165+
} as DnsRecords
166+
}
167+
104168
const unmarshalPlatformControlPanelUrls = (
105169
data: unknown,
106170
): PlatformControlPanelUrls => {
@@ -130,6 +194,7 @@ const unmarshalOfferOption = (data: unknown): OfferOption => {
130194
maxValue: data.max_value,
131195
minValue: data.min_value,
132196
name: data.name,
197+
price: data.price ? unmarshalMoney(data.price) : undefined,
133198
quotaWarning: data.quota_warning,
134199
} as OfferOption
135200
}
@@ -474,6 +539,13 @@ export const marshalDatabaseApiUnassignDatabaseUserRequest = (
474539
username: request.username,
475540
})
476541

542+
export const marshalDnsApiCheckUserOwnsDomainRequest = (
543+
request: DnsApiCheckUserOwnsDomainRequest,
544+
defaults: DefaultValues,
545+
): Record<string, unknown> => ({
546+
project_id: request.projectId ?? defaults.defaultProjectId,
547+
})
548+
477549
export const marshalFtpAccountApiChangeFtpAccountPasswordRequest = (
478550
request: FtpAccountApiChangeFtpAccountPasswordRequest,
479551
defaults: DefaultValues,

packages/clients/src/api/webhosting/v1/types.gen.ts

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,17 @@
33
import type { Money, Region } from '../../../bridge'
44
import type { LanguageCode as StdLanguageCode } from '../../std/types.gen'
55

6+
export type DnsRecordStatus = 'unknown_status' | 'valid' | 'invalid'
7+
8+
export type DnsRecordType =
9+
| 'unknown_type'
10+
| 'a'
11+
| 'cname'
12+
| 'mx'
13+
| 'txt'
14+
| 'ns'
15+
| 'aaaa'
16+
617
export type DnsRecordsStatus = 'unknown_status' | 'valid' | 'invalid'
718

819
export type HostingStatus =
@@ -43,6 +54,8 @@ export type ListOffersRequestOrderBy = 'price_asc'
4354

4455
export type ListWebsitesRequestOrderBy = 'domain_asc' | 'domain_desc'
4556

57+
export type NameserverStatus = 'unknown_status' | 'valid' | 'invalid'
58+
4659
export type OfferOptionName =
4760
| 'unknown_name'
4861
| 'domain_count'
@@ -82,6 +95,8 @@ export interface OfferOption {
8295
maxValue: number
8396
/** Defines a warning if the maximum value for the option has been reached. */
8497
quotaWarning: OfferOptionWarning
98+
/** Price of the option for 1 value. */
99+
price?: Money
85100
}
86101

87102
export interface PlatformControlPanel {
@@ -105,6 +120,30 @@ export interface OfferOptionRequest {
105120
quantity: number
106121
}
107122

123+
export interface DnsRecord {
124+
/** Record name. */
125+
name: string
126+
/** Record type. */
127+
type: DnsRecordType
128+
/** Record time-to-live. */
129+
ttl: number
130+
/** Record value. */
131+
value: string
132+
/** Record priority level. */
133+
priority?: number
134+
/** Record status. */
135+
status: DnsRecordStatus
136+
}
137+
138+
export interface Nameserver {
139+
/** Hostname of the nameserver. */
140+
hostname: string
141+
/** Status of the nameserver. */
142+
status: NameserverStatus
143+
/** Defines whether the nameserver is the default one. */
144+
isDefault: boolean
145+
}
146+
108147
export interface HostingUser {
109148
/** Main Web Hosting cPanel username. */
110149
username: string
@@ -219,6 +258,11 @@ export interface Website {
219258
sslStatus: boolean
220259
}
221260

261+
export interface CheckUserOwnsDomainResponse {
262+
/** Indicates whether the specified project owns the domain. */
263+
ownsDomain: boolean
264+
}
265+
222266
export type ControlPanelApiListControlPanelsRequest = {
223267
/**
224268
* Region to target. If none is passed will use default region from the
@@ -388,6 +432,37 @@ export type DatabaseApiUnassignDatabaseUserRequest = {
388432
username: string
389433
}
390434

435+
export type DnsApiCheckUserOwnsDomainRequest = {
436+
/**
437+
* Region to target. If none is passed will use default region from the
438+
* config.
439+
*/
440+
region?: Region
441+
/** Domain for which ownership is to be verified. */
442+
domain: string
443+
/** ID of the project currently in use. */
444+
projectId?: string
445+
}
446+
447+
export type DnsApiGetDomainDnsRecordsRequest = {
448+
/**
449+
* Region to target. If none is passed will use default region from the
450+
* config.
451+
*/
452+
region?: Region
453+
/** Domain associated with the DNS records. */
454+
domain: string
455+
}
456+
457+
export interface DnsRecords {
458+
/** List of DNS records. */
459+
records: DnsRecord[]
460+
/** List of nameservers. */
461+
nameServers: Nameserver[]
462+
/** Status of the records. */
463+
status: DnsRecordsStatus
464+
}
465+
391466
export type FtpAccountApiChangeFtpAccountPasswordRequest = {
392467
/**
393468
* Region to target. If none is passed will use default region from the

0 commit comments

Comments
 (0)