Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 57 additions & 2 deletions packages/clients/src/api/webhosting/v1/api.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,18 @@ import {
marshalDatabaseApiCreateDatabaseRequest,
marshalDatabaseApiCreateDatabaseUserRequest,
marshalDatabaseApiUnassignDatabaseUserRequest,
marshalDnsApiCheckUserOwnsDomainRequest,
marshalFtpAccountApiChangeFtpAccountPasswordRequest,
marshalFtpAccountApiCreateFtpAccountRequest,
marshalHostingApiCreateHostingRequest,
marshalHostingApiUpdateHostingRequest,
marshalMailAccountApiChangeMailAccountPasswordRequest,
marshalMailAccountApiCreateMailAccountRequest,
marshalMailAccountApiRemoveMailAccountRequest,
unmarshalCheckUserOwnsDomainResponse,
unmarshalDatabase,
unmarshalDatabaseUser,
unmarshalDnsRecords,
unmarshalFtpAccount,
unmarshalHosting,
unmarshalListControlPanelsResponse,
Expand All @@ -40,6 +43,7 @@ import {
unmarshalSession,
} from './marshalling.gen'
import type {
CheckUserOwnsDomainResponse,
ControlPanelApiListControlPanelsRequest,
Database,
DatabaseApiAssignDatabaseUserRequest,
Expand All @@ -54,6 +58,9 @@ import type {
DatabaseApiListDatabasesRequest,
DatabaseApiUnassignDatabaseUserRequest,
DatabaseUser,
DnsApiCheckUserOwnsDomainRequest,
DnsApiGetDomainDnsRecordsRequest,
DnsRecords,
FtpAccount,
FtpAccountApiChangeFtpAccountPasswordRequest,
FtpAccountApiCreateFtpAccountRequest,
Expand Down Expand Up @@ -93,13 +100,13 @@ const jsonContentHeaders = {
}

/**
* Web Hosting API.
* Web Hosting Control Panel API.
*
* This API allows you to manage your Web Hosting services.
*/
export class ControlPanelAPI extends ParentAPI {
/** Lists the available regions of the API. */
public static readonly LOCALITIES: Region[] = ['fr-par', 'nl-ams']
public static readonly LOCALITIES: Region[] = ['fr-par', 'nl-ams', 'pl-waw']

protected pageOfListControlPanels = (
request: Readonly<ControlPanelApiListControlPanelsRequest> = {},
Expand Down Expand Up @@ -380,6 +387,54 @@ export class DatabaseAPI extends ParentAPI {
)
}

/**
* Web Hosting Dns API.
*
* This API allows you to manage your Web Hosting services.
*/
export class DnsAPI extends ParentAPI {
/** Lists the available regions of the API. */
public static readonly LOCALITIES: Region[] = ['fr-par', 'nl-ams', 'pl-waw']

/**
* Get DNS records. Get the set of DNS records of a specified domain
* associated with a Web Hosting plan's domain.
*
* @param request - The request {@link DnsApiGetDomainDnsRecordsRequest}
* @returns A Promise of DnsRecords
*/
getDomainDnsRecords = (request: Readonly<DnsApiGetDomainDnsRecordsRequest>) =>
this.client.fetch<DnsRecords>(
{
method: 'GET',
path: `/webhosting/v1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/domains/${validatePathParam('domain', request.domain)}/dns-records`,
},
unmarshalDnsRecords,
)

/**
* "Check whether you own this domain or not.".
*
* @param request - The request {@link DnsApiCheckUserOwnsDomainRequest}
* @returns A Promise of CheckUserOwnsDomainResponse
*/
checkUserOwnsDomain = (request: Readonly<DnsApiCheckUserOwnsDomainRequest>) =>
this.client.fetch<CheckUserOwnsDomainResponse>(
{
body: JSON.stringify(
marshalDnsApiCheckUserOwnsDomainRequest(
request,
this.client.settings,
),
),
headers: jsonContentHeaders,
method: 'POST',
path: `/webhosting/v1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/domains/${validatePathParam('domain', request.domain)}/check-ownership`,
},
unmarshalCheckUserOwnsDomainResponse,
)
}

/**
* Web Hosting Offer API.
*
Expand Down
10 changes: 10 additions & 0 deletions packages/clients/src/api/webhosting/v1/index.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
export {
ControlPanelAPI,
DatabaseAPI,
DnsAPI,
FtpAccountAPI,
HostingAPI,
MailAccountAPI,
Expand All @@ -11,6 +12,7 @@ export {
} from './api.gen'
export * from './content.gen'
export type {
CheckUserOwnsDomainResponse,
ControlPanel,
ControlPanelApiListControlPanelsRequest,
CreateHostingRequestDomainConfiguration,
Expand All @@ -27,6 +29,12 @@ export type {
DatabaseApiListDatabasesRequest,
DatabaseApiUnassignDatabaseUserRequest,
DatabaseUser,
DnsApiCheckUserOwnsDomainRequest,
DnsApiGetDomainDnsRecordsRequest,
DnsRecord,
DnsRecordStatus,
DnsRecordType,
DnsRecords,
DnsRecordsStatus,
FtpAccount,
FtpAccountApiChangeFtpAccountPasswordRequest,
Expand Down Expand Up @@ -66,6 +74,8 @@ export type {
MailAccountApiCreateMailAccountRequest,
MailAccountApiListMailAccountsRequest,
MailAccountApiRemoveMailAccountRequest,
Nameserver,
NameserverStatus,
Offer,
OfferApiListOffersRequest,
OfferOption,
Expand Down
72 changes: 72 additions & 0 deletions packages/clients/src/api/webhosting/v1/marshalling.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
} from '../../../bridge'
import type { DefaultValues } from '../../../bridge'
import type {
CheckUserOwnsDomainResponse,
ControlPanel,
CreateHostingRequestDomainConfiguration,
Database,
Expand All @@ -17,6 +18,9 @@ import type {
DatabaseApiCreateDatabaseUserRequest,
DatabaseApiUnassignDatabaseUserRequest,
DatabaseUser,
DnsApiCheckUserOwnsDomainRequest,
DnsRecord,
DnsRecords,
FtpAccount,
FtpAccountApiChangeFtpAccountPasswordRequest,
FtpAccountApiCreateFtpAccountRequest,
Expand All @@ -37,6 +41,7 @@ import type {
MailAccountApiChangeMailAccountPasswordRequest,
MailAccountApiCreateMailAccountRequest,
MailAccountApiRemoveMailAccountRequest,
Nameserver,
Offer,
OfferOption,
OfferOptionRequest,
Expand Down Expand Up @@ -101,6 +106,65 @@ export const unmarshalMailAccount = (data: unknown): MailAccount => {
} as MailAccount
}

export const unmarshalCheckUserOwnsDomainResponse = (
data: unknown,
): CheckUserOwnsDomainResponse => {
if (!isJSONObject(data)) {
throw new TypeError(
`Unmarshalling the type 'CheckUserOwnsDomainResponse' failed as data isn't a dictionary.`,
)
}

return {
ownsDomain: data.owns_domain,
} as CheckUserOwnsDomainResponse
}

const unmarshalDnsRecord = (data: unknown): DnsRecord => {
if (!isJSONObject(data)) {
throw new TypeError(
`Unmarshalling the type 'DnsRecord' failed as data isn't a dictionary.`,
)
}

return {
name: data.name,
priority: data.priority,
status: data.status,
ttl: data.ttl,
type: data.type,
value: data.value,
} as DnsRecord
}

const unmarshalNameserver = (data: unknown): Nameserver => {
if (!isJSONObject(data)) {
throw new TypeError(
`Unmarshalling the type 'Nameserver' failed as data isn't a dictionary.`,
)
}

return {
hostname: data.hostname,
isDefault: data.is_default,
status: data.status,
} as Nameserver
}

export const unmarshalDnsRecords = (data: unknown): DnsRecords => {
if (!isJSONObject(data)) {
throw new TypeError(
`Unmarshalling the type 'DnsRecords' failed as data isn't a dictionary.`,
)
}

return {
nameServers: unmarshalArrayOfObject(data.name_servers, unmarshalNameserver),
records: unmarshalArrayOfObject(data.records, unmarshalDnsRecord),
status: data.status,
} as DnsRecords
}

const unmarshalPlatformControlPanelUrls = (
data: unknown,
): PlatformControlPanelUrls => {
Expand Down Expand Up @@ -130,6 +194,7 @@ const unmarshalOfferOption = (data: unknown): OfferOption => {
maxValue: data.max_value,
minValue: data.min_value,
name: data.name,
price: data.price ? unmarshalMoney(data.price) : undefined,
quotaWarning: data.quota_warning,
} as OfferOption
}
Expand Down Expand Up @@ -474,6 +539,13 @@ export const marshalDatabaseApiUnassignDatabaseUserRequest = (
username: request.username,
})

export const marshalDnsApiCheckUserOwnsDomainRequest = (
request: DnsApiCheckUserOwnsDomainRequest,
defaults: DefaultValues,
): Record<string, unknown> => ({
project_id: request.projectId ?? defaults.defaultProjectId,
})

export const marshalFtpAccountApiChangeFtpAccountPasswordRequest = (
request: FtpAccountApiChangeFtpAccountPasswordRequest,
defaults: DefaultValues,
Expand Down
75 changes: 75 additions & 0 deletions packages/clients/src/api/webhosting/v1/types.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,17 @@
import type { Money, Region } from '../../../bridge'
import type { LanguageCode as StdLanguageCode } from '../../std/types.gen'

export type DnsRecordStatus = 'unknown_status' | 'valid' | 'invalid'

export type DnsRecordType =
| 'unknown_type'
| 'a'
| 'cname'
| 'mx'
| 'txt'
| 'ns'
| 'aaaa'

export type DnsRecordsStatus = 'unknown_status' | 'valid' | 'invalid'

export type HostingStatus =
Expand Down Expand Up @@ -43,6 +54,8 @@ export type ListOffersRequestOrderBy = 'price_asc'

export type ListWebsitesRequestOrderBy = 'domain_asc' | 'domain_desc'

export type NameserverStatus = 'unknown_status' | 'valid' | 'invalid'

export type OfferOptionName =
| 'unknown_name'
| 'domain_count'
Expand Down Expand Up @@ -82,6 +95,8 @@ export interface OfferOption {
maxValue: number
/** Defines a warning if the maximum value for the option has been reached. */
quotaWarning: OfferOptionWarning
/** Price of the option for 1 value. */
price?: Money
}

export interface PlatformControlPanel {
Expand All @@ -105,6 +120,30 @@ export interface OfferOptionRequest {
quantity: number
}

export interface DnsRecord {
/** Record name. */
name: string
/** Record type. */
type: DnsRecordType
/** Record time-to-live. */
ttl: number
/** Record value. */
value: string
/** Record priority level. */
priority?: number
/** Record status. */
status: DnsRecordStatus
}

export interface Nameserver {
/** Hostname of the nameserver. */
hostname: string
/** Status of the nameserver. */
status: NameserverStatus
/** Defines whether the nameserver is the default one. */
isDefault: boolean
}

export interface HostingUser {
/** Main Web Hosting cPanel username. */
username: string
Expand Down Expand Up @@ -219,6 +258,11 @@ export interface Website {
sslStatus: boolean
}

export interface CheckUserOwnsDomainResponse {
/** Indicates whether the specified project owns the domain. */
ownsDomain: boolean
}

export type ControlPanelApiListControlPanelsRequest = {
/**
* Region to target. If none is passed will use default region from the
Expand Down Expand Up @@ -388,6 +432,37 @@ export type DatabaseApiUnassignDatabaseUserRequest = {
username: string
}

export type DnsApiCheckUserOwnsDomainRequest = {
/**
* Region to target. If none is passed will use default region from the
* config.
*/
region?: Region
/** Domain for which ownership is to be verified. */
domain: string
/** ID of the project currently in use. */
projectId?: string
}

export type DnsApiGetDomainDnsRecordsRequest = {
/**
* Region to target. If none is passed will use default region from the
* config.
*/
region?: Region
/** Domain associated with the DNS records. */
domain: string
}

export interface DnsRecords {
/** List of DNS records. */
records: DnsRecord[]
/** List of nameservers. */
nameServers: Nameserver[]
/** Status of the records. */
status: DnsRecordsStatus
}

export type FtpAccountApiChangeFtpAccountPasswordRequest = {
/**
* Region to target. If none is passed will use default region from the
Expand Down
Loading