Skip to content

Commit a293ad3

Browse files
authored
feat(webhosting): add domain api (#1368)
1 parent 08b8433 commit a293ad3

File tree

4 files changed

+56
-0
lines changed

4 files changed

+56
-0
lines changed

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

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { HOSTING_TRANSIENT_STATUSES } from './content.gen'
1212
import {
1313
marshalCreateHostingRequest,
1414
marshalUpdateHostingRequest,
15+
unmarshalCheckUserOwnsDomainResponse,
1516
unmarshalDnsRecords,
1617
unmarshalHosting,
1718
unmarshalListControlPanelsResponse,
@@ -21,6 +22,8 @@ import {
2122
unmarshalSession,
2223
} from './marshalling.gen'
2324
import type {
25+
CheckUserOwnsDomainRequest,
26+
CheckUserOwnsDomainResponse,
2427
CreateHostingRequest,
2528
CreateSessionRequest,
2629
DeleteHostingRequest,
@@ -223,6 +226,25 @@ export class API extends ParentAPI {
223226
unmarshalDnsRecords,
224227
)
225228

229+
/**
230+
* "Check whether you own this domain or not.".
231+
*
232+
* @param request - The request {@link CheckUserOwnsDomainRequest}
233+
* @returns A Promise of CheckUserOwnsDomainResponse
234+
*/
235+
checkUserOwnsDomain = (request: Readonly<CheckUserOwnsDomainRequest>) =>
236+
this.client.fetch<CheckUserOwnsDomainResponse>(
237+
{
238+
method: 'POST',
239+
path: `/webhosting/v1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/domains/${validatePathParam('domain', request.domain)}/check-ownership`,
240+
urlParams: urlParams([
241+
'project_id',
242+
request.projectId ?? this.client.settings.defaultProjectId,
243+
]),
244+
},
245+
unmarshalCheckUserOwnsDomainResponse,
246+
)
247+
226248
/**
227249
* List all offers. List the different Web Hosting offers, and their options,
228250
* available to order from Scaleway.

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
export { API } from './api.gen'
44
export * from './content.gen'
55
export type {
6+
CheckUserOwnsDomainRequest,
7+
CheckUserOwnsDomainResponse,
68
ControlPanel,
79
CreateHostingRequest,
810
CreateHostingRequestDomainConfiguration,

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

Lines changed: 15 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
CreateHostingRequest,
1314
CreateHostingRequestDomainConfiguration,
@@ -90,6 +91,20 @@ export const unmarshalHosting = (data: unknown): Hosting => {
9091
} as Hosting
9192
}
9293

94+
export const unmarshalCheckUserOwnsDomainResponse = (
95+
data: unknown,
96+
): CheckUserOwnsDomainResponse => {
97+
if (!isJSONObject(data)) {
98+
throw new TypeError(
99+
`Unmarshalling the type 'CheckUserOwnsDomainResponse' failed as data isn't a dictionary.`,
100+
)
101+
}
102+
103+
return {
104+
ownsDomain: data.owns_domain,
105+
} as CheckUserOwnsDomainResponse
106+
}
107+
93108
const unmarshalDnsRecord = (data: unknown): DnsRecord => {
94109
if (!isJSONObject(data)) {
95110
throw new TypeError(

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,23 @@ export interface Offer {
192192
controlPanelName: string
193193
}
194194

195+
export type CheckUserOwnsDomainRequest = {
196+
/**
197+
* Region to target. If none is passed will use default region from the
198+
* config.
199+
*/
200+
region?: Region
201+
/** Domain for which ownership is to be verified. */
202+
domain: string
203+
/** ID of the project currently in use. */
204+
projectId?: string
205+
}
206+
207+
export interface CheckUserOwnsDomainResponse {
208+
/** Indicates whether the specified project owns the domain. */
209+
ownsDomain: boolean
210+
}
211+
195212
export type CreateHostingRequest = {
196213
/**
197214
* Region to target. If none is passed will use default region from the

0 commit comments

Comments
 (0)