diff --git a/packages/clients/src/api/webhosting/index.gen.ts b/packages/clients/src/api/webhosting/index.gen.ts index 3c605af8e..a86d42c0b 100644 --- a/packages/clients/src/api/webhosting/index.gen.ts +++ b/packages/clients/src/api/webhosting/index.gen.ts @@ -4,4 +4,3 @@ */ export * as v1 from './v1/index.gen' -export * as v1alpha1 from './v1alpha1/index.gen' diff --git a/packages/clients/src/api/webhosting/v1alpha1/api.gen.ts b/packages/clients/src/api/webhosting/v1alpha1/api.gen.ts deleted file mode 100644 index bdf7355ff..000000000 --- a/packages/clients/src/api/webhosting/v1alpha1/api.gen.ts +++ /dev/null @@ -1,451 +0,0 @@ -// This file was automatically generated. DO NOT EDIT. -// If you have any remark or suggestion do not hesitate to open an issue. -import { - API as ParentAPI, - enrichForPagination, - urlParams, - validatePathParam, - waitForResource, -} from '../../../bridge' -import type { Region as ScwRegion, WaitForOptions } from '../../../bridge' -import { HOSTING_TRANSIENT_STATUSES } from './content.gen' -import { - marshalCheckUserOwnsDomainRequest, - marshalClassicMailApiCreateMailboxRequest, - marshalClassicMailApiUpdateMailboxRequest, - marshalCreateHostingRequest, - marshalUpdateHostingRequest, - unmarshalCheckUserOwnsDomainResponse, - unmarshalDnsRecords, - unmarshalHosting, - unmarshalListControlPanelsResponse, - unmarshalListHostingsResponse, - unmarshalListMailboxesResponse, - unmarshalListOffersResponse, - unmarshalMailbox, - unmarshalResetHostingPasswordResponse, - unmarshalSession, -} from './marshalling.gen' -import type { - CheckUserOwnsDomainRequest, - CheckUserOwnsDomainResponse, - ClassicMailApiCreateMailboxRequest, - ClassicMailApiDeleteMailboxRequest, - ClassicMailApiGetMailboxRequest, - ClassicMailApiListMailboxesRequest, - ClassicMailApiUpdateMailboxRequest, - CreateHostingRequest, - CreateSessionRequest, - DeleteHostingRequest, - DnsRecords, - GetDomainDnsRecordsRequest, - GetHostingRequest, - Hosting, - ListControlPanelsRequest, - ListControlPanelsResponse, - ListHostingsRequest, - ListHostingsResponse, - ListMailboxesResponse, - ListOffersRequest, - ListOffersResponse, - Mailbox, - ResetHostingPasswordRequest, - ResetHostingPasswordResponse, - RestoreHostingRequest, - Session, - UpdateHostingRequest, -} from './types.gen' - -const jsonContentHeaders = { - 'Content-Type': 'application/json; charset=utf-8', -} - -/** - * Web Hosting API. - * - * This API allows you to manage your Web Hosting services. - */ -export class API extends ParentAPI { - /** Lists the available regions of the API. */ - public static readonly LOCALITIES: ScwRegion[] = ['fr-par', 'nl-ams'] - - /** - * Order a Web Hosting plan. Order a Web Hosting plan, specifying the offer - * type required via the `offer_id` parameter. - * - * @param request - The request {@link CreateHostingRequest} - * @returns A Promise of Hosting - */ - createHosting = (request: Readonly) => - this.client.fetch( - { - body: JSON.stringify( - marshalCreateHostingRequest(request, this.client.settings), - ), - headers: jsonContentHeaders, - method: 'POST', - path: `/webhosting/v1alpha1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/hostings`, - }, - unmarshalHosting, - ) - - protected pageOfListHostings = ( - request: Readonly = {}, - ) => - this.client.fetch( - { - method: 'GET', - path: `/webhosting/v1alpha1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/hostings`, - urlParams: urlParams( - ['control_panels', request.controlPanels], - ['domain', request.domain], - ['order_by', request.orderBy], - ['organization_id', request.organizationId], - ['page', request.page], - [ - 'page_size', - request.pageSize ?? this.client.settings.defaultPageSize, - ], - ['project_id', request.projectId], - ['statuses', request.statuses], - ['tags', request.tags], - ), - }, - unmarshalListHostingsResponse, - ) - - /** - * List all Web Hosting plans. List all of your existing Web Hosting plans. - * Various filters are available to limit the results, including filtering by - * domain, status, tag and Project ID. - * - * @param request - The request {@link ListHostingsRequest} - * @returns A Promise of ListHostingsResponse - */ - listHostings = (request: Readonly = {}) => - enrichForPagination('hostings', this.pageOfListHostings, request) - - /** - * Get a Web Hosting plan. Get the details of one of your existing Web Hosting - * plans, specified by its `hosting_id`. - * - * @param request - The request {@link GetHostingRequest} - * @returns A Promise of Hosting - */ - getHosting = (request: Readonly) => - this.client.fetch( - { - method: 'GET', - path: `/webhosting/v1alpha1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/hostings/${validatePathParam('hostingId', request.hostingId)}`, - }, - unmarshalHosting, - ) - - /** - * Waits for {@link Hosting} to be in a final state. - * - * @param request - The request {@link GetHostingRequest} - * @param options - The waiting options - * @returns A Promise of Hosting - */ - waitForHosting = ( - request: Readonly, - options?: Readonly>, - ) => - waitForResource( - options?.stop ?? - (res => - Promise.resolve(!HOSTING_TRANSIENT_STATUSES.includes(res.status))), - this.getHosting, - request, - options, - ) - - /** - * Update a Web Hosting plan. Update the details of one of your existing Web - * Hosting plans, specified by its `hosting_id`. You can update parameters - * including the contact email address, tags, options and offer. - * - * @param request - The request {@link UpdateHostingRequest} - * @returns A Promise of Hosting - */ - updateHosting = (request: Readonly) => - this.client.fetch( - { - body: JSON.stringify( - marshalUpdateHostingRequest(request, this.client.settings), - ), - headers: jsonContentHeaders, - method: 'PATCH', - path: `/webhosting/v1alpha1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/hostings/${validatePathParam('hostingId', request.hostingId)}`, - }, - unmarshalHosting, - ) - - /** - * Delete a Web Hosting plan. Delete a Web Hosting plan, specified by its - * `hosting_id`. Note that deletion is not immediate: it will take place at - * the end of the calendar month, after which time your Web Hosting plan and - * all its data (files and emails) will be irreversibly lost. - * - * @param request - The request {@link DeleteHostingRequest} - * @returns A Promise of Hosting - */ - deleteHosting = (request: Readonly) => - this.client.fetch( - { - method: 'DELETE', - path: `/webhosting/v1alpha1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/hostings/${validatePathParam('hostingId', request.hostingId)}`, - }, - unmarshalHosting, - ) - - /** - * Restore a Web Hosting plan. When you [delete a Web Hosting - * plan](#path-hostings-delete-a-hosting), definitive deletion does not take - * place until the end of the calendar month. In the time between initiating - * the deletion, and definitive deletion at the end of the month, you can - * choose to **restore** the Web Hosting plan, using this endpoint and - * specifying its `hosting_id`. - * - * @param request - The request {@link RestoreHostingRequest} - * @returns A Promise of Hosting - */ - restoreHosting = (request: Readonly) => - this.client.fetch( - { - body: '{}', - headers: jsonContentHeaders, - method: 'POST', - path: `/webhosting/v1alpha1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/hostings/${validatePathParam('hostingId', request.hostingId)}/restore`, - }, - unmarshalHosting, - ) - - /** - * Get DNS records. Get the set of DNS records of a specified domain - * associated with a Web Hosting plan. - * - * @param request - The request {@link GetDomainDnsRecordsRequest} - * @returns A Promise of DnsRecords - */ - getDomainDnsRecords = (request: Readonly) => - this.client.fetch( - { - method: 'GET', - path: `/webhosting/v1alpha1/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 CheckUserOwnsDomainRequest} - * @returns A Promise of CheckUserOwnsDomainResponse - */ - checkUserOwnsDomain = (request: Readonly) => - this.client.fetch( - { - body: JSON.stringify( - marshalCheckUserOwnsDomainRequest(request, this.client.settings), - ), - headers: jsonContentHeaders, - method: 'POST', - path: `/webhosting/v1alpha1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/domains/${validatePathParam('domain', request.domain)}/check-ownership`, - }, - unmarshalCheckUserOwnsDomainResponse, - ) - - /** - * List all offers. List the different Web Hosting offers, and their options, - * available to order from Scaleway. - * - * @param request - The request {@link ListOffersRequest} - * @returns A Promise of ListOffersResponse - */ - listOffers = (request: Readonly) => - this.client.fetch( - { - method: 'GET', - path: `/webhosting/v1alpha1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/offers`, - urlParams: urlParams( - ['control_panels', request.controlPanels], - ['hosting_id', request.hostingId], - ['only_options', request.onlyOptions], - ['order_by', request.orderBy], - ['without_options', request.withoutOptions], - ), - }, - unmarshalListOffersResponse, - ) - - protected pageOfListControlPanels = ( - request: Readonly = {}, - ) => - this.client.fetch( - { - method: 'GET', - path: `/webhosting/v1alpha1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/control-panels`, - urlParams: urlParams( - ['page', request.page], - [ - 'page_size', - request.pageSize ?? this.client.settings.defaultPageSize, - ], - ), - }, - unmarshalListControlPanelsResponse, - ) - - /** - * "List the control panels type: cpanel or plesk.". - * - * @param request - The request {@link ListControlPanelsRequest} - * @returns A Promise of ListControlPanelsResponse - */ - listControlPanels = (request: Readonly = {}) => - enrichForPagination('controlPanels', this.pageOfListControlPanels, request) - - /** - * Create a user session. - * - * @param request - The request {@link CreateSessionRequest} - * @returns A Promise of Session - */ - createSession = (request: Readonly) => - this.client.fetch( - { - body: '{}', - headers: jsonContentHeaders, - method: 'POST', - path: `/webhosting/v1alpha1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/hostings/${validatePathParam('hostingId', request.hostingId)}/sessions`, - }, - unmarshalSession, - ) - - resetHostingPassword = (request: Readonly) => - this.client.fetch( - { - body: '{}', - headers: jsonContentHeaders, - method: 'POST', - path: `/webhosting/v1alpha1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/hostings/${validatePathParam('hostingId', request.hostingId)}/reset-password`, - }, - unmarshalResetHostingPasswordResponse, - ) -} - -/** - * Web Hosting Classic Mailbox API. - * - * This API allows you to manage your mailboxes for your Web Hosting services. - */ -export class ClassicMailAPI extends ParentAPI { - /** Lists the available regions of the API. */ - public static readonly LOCALITIES: ScwRegion[] = [ - 'fr-par', - 'nl-ams', - 'pl-waw', - ] - - /** - * Create a new mailbox within your hosting plan.. Create a new mailbox within - * your hosting plan. - * - * @param request - The request {@link ClassicMailApiCreateMailboxRequest} - * @returns A Promise of Mailbox - */ - createMailbox = (request: Readonly) => - this.client.fetch( - { - body: JSON.stringify( - marshalClassicMailApiCreateMailboxRequest( - request, - this.client.settings, - ), - ), - headers: jsonContentHeaders, - method: 'POST', - path: `/webhosting/v1alpha1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/classic-hostings/${validatePathParam('onlineId', request.onlineId)}/mailboxes`, - }, - unmarshalMailbox, - ) - - /** - * Get a mailbox by id within your hosting plan.. Get a mailbox by id within - * your hosting plan. - * - * @param request - The request {@link ClassicMailApiGetMailboxRequest} - * @returns A Promise of Mailbox - */ - getMailbox = (request: Readonly) => - this.client.fetch( - { - method: 'GET', - path: `/webhosting/v1alpha1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/classic-hostings/${validatePathParam('onlineId', request.onlineId)}/mailboxes/${validatePathParam('mailboxId', request.mailboxId)}`, - }, - unmarshalMailbox, - ) - - protected pageOfListMailboxes = ( - request: Readonly, - ) => - this.client.fetch( - { - method: 'GET', - path: `/webhosting/v1alpha1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/classic-hostings/${validatePathParam('onlineId', request.onlineId)}/mailboxes`, - urlParams: urlParams( - ['domain', request.domain], - ['page', request.page], - [ - 'page_size', - request.pageSize ?? this.client.settings.defaultPageSize, - ], - ), - }, - unmarshalListMailboxesResponse, - ) - - /** - * List all mailboxes within your hosting plan.. List all mailboxes within - * your hosting plan. - * - * @param request - The request {@link ClassicMailApiListMailboxesRequest} - * @returns A Promise of ListMailboxesResponse - */ - listMailboxes = (request: Readonly) => - enrichForPagination('mailboxes', this.pageOfListMailboxes, request) - - deleteMailbox = (request: Readonly) => - this.client.fetch( - { - method: 'DELETE', - path: `/webhosting/v1alpha1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/classic-hostings/${validatePathParam('onlineId', request.onlineId)}/mailboxes/${validatePathParam('mailboxId', request.mailboxId)}`, - }, - unmarshalMailbox, - ) - - /** - * Update the mailbox within your hosting plan.. Update the mailbox within - * your hosting plan. - * - * @param request - The request {@link ClassicMailApiUpdateMailboxRequest} - * @returns A Promise of Mailbox - */ - updateMailbox = (request: Readonly) => - this.client.fetch( - { - body: JSON.stringify( - marshalClassicMailApiUpdateMailboxRequest( - request, - this.client.settings, - ), - ), - headers: jsonContentHeaders, - method: 'PATCH', - path: `/webhosting/v1alpha1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/classic-hostings/${validatePathParam('onlineId', request.onlineId)}/mailboxes/${validatePathParam('mailboxId', request.mailboxId)}`, - }, - unmarshalMailbox, - ) -} diff --git a/packages/clients/src/api/webhosting/v1alpha1/content.gen.ts b/packages/clients/src/api/webhosting/v1alpha1/content.gen.ts deleted file mode 100644 index c055c434d..000000000 --- a/packages/clients/src/api/webhosting/v1alpha1/content.gen.ts +++ /dev/null @@ -1,10 +0,0 @@ -// This file was automatically generated. DO NOT EDIT. -// If you have any remark or suggestion do not hesitate to open an issue. -import type { HostingStatus } from './types.gen' - -/** Lists transient statutes of the enum {@link HostingStatus}. */ -export const HOSTING_TRANSIENT_STATUSES: HostingStatus[] = [ - 'delivering', - 'deleting', - 'migrating', -] diff --git a/packages/clients/src/api/webhosting/v1alpha1/index.gen.ts b/packages/clients/src/api/webhosting/v1alpha1/index.gen.ts deleted file mode 100644 index 0d5e5f1c1..000000000 --- a/packages/clients/src/api/webhosting/v1alpha1/index.gen.ts +++ /dev/null @@ -1,52 +0,0 @@ -// This file was automatically generated. DO NOT EDIT. -// If you have any remark or suggestion do not hesitate to open an issue. -export { API, ClassicMailAPI } from './api.gen' -export * from './content.gen' -export type { - CheckUserOwnsDomainRequest, - CheckUserOwnsDomainResponse, - ClassicMailApiCreateMailboxRequest, - ClassicMailApiDeleteMailboxRequest, - ClassicMailApiGetMailboxRequest, - ClassicMailApiListMailboxesRequest, - ClassicMailApiUpdateMailboxRequest, - ControlPanel, - CreateHostingRequest, - CreateHostingRequestDomainConfiguration, - CreateSessionRequest, - DeleteHostingRequest, - DnsRecord, - DnsRecordStatus, - DnsRecordType, - DnsRecords, - DnsRecordsStatus, - EmailAddress, - GetDomainDnsRecordsRequest, - GetHostingRequest, - Hosting, - HostingCpanelUrls, - HostingDnsStatus, - HostingOption, - HostingStatus, - ListControlPanelsRequest, - ListControlPanelsResponse, - ListHostingsRequest, - ListHostingsRequestOrderBy, - ListHostingsResponse, - ListMailboxesResponse, - ListOffersRequest, - ListOffersRequestOrderBy, - ListOffersResponse, - Mailbox, - Nameserver, - NameserverStatus, - Offer, - OfferProduct, - OfferQuotaWarning, - ResetHostingPasswordRequest, - ResetHostingPasswordResponse, - RestoreHostingRequest, - Session, - UpdateHostingRequest, -} from './types.gen' -export * as ValidationRules from './validation-rules.gen' diff --git a/packages/clients/src/api/webhosting/v1alpha1/marshalling.gen.ts b/packages/clients/src/api/webhosting/v1alpha1/marshalling.gen.ts deleted file mode 100644 index 01f05994b..000000000 --- a/packages/clients/src/api/webhosting/v1alpha1/marshalling.gen.ts +++ /dev/null @@ -1,400 +0,0 @@ -// This file was automatically generated. DO NOT EDIT. -// If you have any remark or suggestion do not hesitate to open an issue. -import { - isJSONObject, - unmarshalArrayOfObject, - unmarshalDate, - unmarshalMoney, -} from '../../../bridge' -import type { DefaultValues } from '../../../bridge' -import type { - CheckUserOwnsDomainRequest, - CheckUserOwnsDomainResponse, - ClassicMailApiCreateMailboxRequest, - ClassicMailApiUpdateMailboxRequest, - ControlPanel, - CreateHostingRequest, - CreateHostingRequestDomainConfiguration, - DnsRecord, - DnsRecords, - EmailAddress, - Hosting, - HostingCpanelUrls, - HostingOption, - ListControlPanelsResponse, - ListHostingsResponse, - ListMailboxesResponse, - ListOffersResponse, - Mailbox, - Nameserver, - Offer, - OfferProduct, - ResetHostingPasswordResponse, - Session, - UpdateHostingRequest, -} from './types.gen' - -const unmarshalHostingCpanelUrls = (data: unknown): HostingCpanelUrls => { - if (!isJSONObject(data)) { - throw new TypeError( - `Unmarshalling the type 'HostingCpanelUrls' failed as data isn't a dictionary.`, - ) - } - - return { - dashboard: data.dashboard, - webmail: data.webmail, - } as HostingCpanelUrls -} - -const unmarshalHostingOption = (data: unknown): HostingOption => { - if (!isJSONObject(data)) { - throw new TypeError( - `Unmarshalling the type 'HostingOption' failed as data isn't a dictionary.`, - ) - } - - return { - id: data.id, - name: data.name, - } as HostingOption -} - -export const unmarshalHosting = (data: unknown): Hosting => { - if (!isJSONObject(data)) { - throw new TypeError( - `Unmarshalling the type 'Hosting' failed as data isn't a dictionary.`, - ) - } - - return { - controlPanelName: data.control_panel_name, - cpanelUrls: data.cpanel_urls - ? unmarshalHostingCpanelUrls(data.cpanel_urls) - : undefined, - createdAt: unmarshalDate(data.created_at), - dnsStatus: data.dns_status, - domain: data.domain, - id: data.id, - ipv4: data.ipv4, - ipv6: data.ipv6, - offerEndOfLife: data.offer_end_of_life, - offerId: data.offer_id, - offerName: data.offer_name, - oneTimePassword: data.one_time_password, - options: unmarshalArrayOfObject(data.options, unmarshalHostingOption), - organizationId: data.organization_id, - platformGroup: data.platform_group, - platformHostname: data.platform_hostname, - platformNumber: data.platform_number, - projectId: data.project_id, - protected: data.protected, - region: data.region, - status: data.status, - tags: data.tags, - updatedAt: unmarshalDate(data.updated_at), - username: data.username, - } as Hosting -} - -const unmarshalEmailAddress = (data: unknown): EmailAddress => { - if (!isJSONObject(data)) { - throw new TypeError( - `Unmarshalling the type 'EmailAddress' failed as data isn't a dictionary.`, - ) - } - - return { - domain: data.domain, - login: data.login, - } as EmailAddress -} - -export const unmarshalMailbox = (data: unknown): Mailbox => { - if (!isJSONObject(data)) { - throw new TypeError( - `Unmarshalling the type 'Mailbox' failed as data isn't a dictionary.`, - ) - } - - return { - email: data.email ? unmarshalEmailAddress(data.email) : undefined, - mailboxId: data.mailbox_id, - } as Mailbox -} - -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 unmarshalControlPanel = (data: unknown): ControlPanel => { - if (!isJSONObject(data)) { - throw new TypeError( - `Unmarshalling the type 'ControlPanel' failed as data isn't a dictionary.`, - ) - } - - return { - available: data.available, - availableLanguages: data.available_languages, - logoUrl: data.logo_url, - name: data.name, - } as ControlPanel -} - -export const unmarshalListControlPanelsResponse = ( - data: unknown, -): ListControlPanelsResponse => { - if (!isJSONObject(data)) { - throw new TypeError( - `Unmarshalling the type 'ListControlPanelsResponse' failed as data isn't a dictionary.`, - ) - } - - return { - controlPanels: unmarshalArrayOfObject( - data.control_panels, - unmarshalControlPanel, - ), - totalCount: data.total_count, - } as ListControlPanelsResponse -} - -export const unmarshalListHostingsResponse = ( - data: unknown, -): ListHostingsResponse => { - if (!isJSONObject(data)) { - throw new TypeError( - `Unmarshalling the type 'ListHostingsResponse' failed as data isn't a dictionary.`, - ) - } - - return { - hostings: unmarshalArrayOfObject(data.hostings, unmarshalHosting), - totalCount: data.total_count, - } as ListHostingsResponse -} - -export const unmarshalListMailboxesResponse = ( - data: unknown, -): ListMailboxesResponse => { - if (!isJSONObject(data)) { - throw new TypeError( - `Unmarshalling the type 'ListMailboxesResponse' failed as data isn't a dictionary.`, - ) - } - - return { - mailboxes: unmarshalArrayOfObject(data.mailboxes, unmarshalMailbox), - totalCount: data.total_count, - } as ListMailboxesResponse -} - -const unmarshalOfferProduct = (data: unknown): OfferProduct => { - if (!isJSONObject(data)) { - throw new TypeError( - `Unmarshalling the type 'OfferProduct' failed as data isn't a dictionary.`, - ) - } - - return { - databasesQuota: data.databases_quota, - emailAccountsQuota: data.email_accounts_quota, - emailStorageQuota: data.email_storage_quota, - hostingStorageQuota: data.hosting_storage_quota, - maxAddonDomains: data.max_addon_domains, - name: data.name, - option: data.option, - ram: data.ram, - supportIncluded: data.support_included, - vCpu: data.v_cpu, - } as OfferProduct -} - -const unmarshalOffer = (data: unknown): Offer => { - if (!isJSONObject(data)) { - throw new TypeError( - `Unmarshalling the type 'Offer' failed as data isn't a dictionary.`, - ) - } - - return { - available: data.available, - billingOperationPath: data.billing_operation_path, - controlPanelName: data.control_panel_name, - endOfLife: data.end_of_life, - id: data.id, - price: data.price ? unmarshalMoney(data.price) : undefined, - product: data.product ? unmarshalOfferProduct(data.product) : undefined, - quotaWarnings: data.quota_warnings, - } as Offer -} - -export const unmarshalListOffersResponse = ( - data: unknown, -): ListOffersResponse => { - if (!isJSONObject(data)) { - throw new TypeError( - `Unmarshalling the type 'ListOffersResponse' failed as data isn't a dictionary.`, - ) - } - - return { - offers: unmarshalArrayOfObject(data.offers, unmarshalOffer), - } as ListOffersResponse -} - -export const unmarshalResetHostingPasswordResponse = ( - data: unknown, -): ResetHostingPasswordResponse => { - if (!isJSONObject(data)) { - throw new TypeError( - `Unmarshalling the type 'ResetHostingPasswordResponse' failed as data isn't a dictionary.`, - ) - } - - return { - password: data.password, - } as ResetHostingPasswordResponse -} - -export const unmarshalSession = (data: unknown): Session => { - if (!isJSONObject(data)) { - throw new TypeError( - `Unmarshalling the type 'Session' failed as data isn't a dictionary.`, - ) - } - - return { - url: data.url, - } as Session -} - -export const marshalCheckUserOwnsDomainRequest = ( - request: CheckUserOwnsDomainRequest, - defaults: DefaultValues, -): Record => ({ - project_id: request.projectId ?? defaults.defaultProjectId, -}) - -const marshalEmailAddress = ( - request: EmailAddress, - defaults: DefaultValues, -): Record => ({ - domain: request.domain, - login: request.login, -}) - -export const marshalClassicMailApiCreateMailboxRequest = ( - request: ClassicMailApiCreateMailboxRequest, - defaults: DefaultValues, -): Record => ({ - email: - request.email !== undefined - ? marshalEmailAddress(request.email, defaults) - : undefined, - password: request.password, -}) - -export const marshalClassicMailApiUpdateMailboxRequest = ( - request: ClassicMailApiUpdateMailboxRequest, - defaults: DefaultValues, -): Record => ({ - password: request.password, -}) - -const marshalCreateHostingRequestDomainConfiguration = ( - request: CreateHostingRequestDomainConfiguration, - defaults: DefaultValues, -): Record => ({ - update_all_records: request.updateAllRecords, - update_mail_record: request.updateMailRecord, - update_nameservers: request.updateNameservers, - update_web_record: request.updateWebRecord, -}) - -export const marshalCreateHostingRequest = ( - request: CreateHostingRequest, - defaults: DefaultValues, -): Record => ({ - domain: request.domain, - domain_configuration: - request.domainConfiguration !== undefined - ? marshalCreateHostingRequestDomainConfiguration( - request.domainConfiguration, - defaults, - ) - : undefined, - email: request.email, - language: request.language, - offer_id: request.offerId, - option_ids: request.optionIds, - project_id: request.projectId ?? defaults.defaultProjectId, - tags: request.tags, -}) - -export const marshalUpdateHostingRequest = ( - request: UpdateHostingRequest, - defaults: DefaultValues, -): Record => ({ - email: request.email, - offer_id: request.offerId, - option_ids: request.optionIds, - protected: request.protected, - tags: request.tags, -}) diff --git a/packages/clients/src/api/webhosting/v1alpha1/types.gen.ts b/packages/clients/src/api/webhosting/v1alpha1/types.gen.ts deleted file mode 100644 index 61e2af21d..000000000 --- a/packages/clients/src/api/webhosting/v1alpha1/types.gen.ts +++ /dev/null @@ -1,546 +0,0 @@ -// This file was automatically generated. DO NOT EDIT. -// If you have any remark or suggestion do not hesitate to open an issue. -import type { Money, Region as ScwRegion } 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' | 'valid' | 'invalid' - -export type HostingDnsStatus = 'unknown_dns_status' | 'valid' | 'invalid' - -export type HostingStatus = - | 'unknown_status' - | 'delivering' - | 'ready' - | 'deleting' - | 'error' - | 'locked' - | 'migrating' - -export type ListHostingsRequestOrderBy = 'created_at_asc' | 'created_at_desc' - -export type ListOffersRequestOrderBy = 'price_asc' - -export type NameserverStatus = 'unknown_status' | 'valid' | 'invalid' - -export type OfferQuotaWarning = - | 'unknown_quota_warning' - | 'email_count_exceeded' - | 'database_count_exceeded' - | 'disk_usage_exceeded' - | 'addon_domain_count_exceeded' - -export interface HostingCpanelUrls { - dashboard: string - webmail: string -} - -export interface HostingOption { - /** Option ID. */ - id: string - /** Option name. */ - name: string -} - -export interface EmailAddress { - /** Domain part of the mailbox address. */ - domain: string - /** Username part address of the mailbox address. */ - login: string -} - -export interface OfferProduct { - /** Product name. */ - name: string - /** Product option. */ - option: boolean - /** Limit number of email accounts. */ - emailAccountsQuota: number - /** Limit quantity of email storage in gigabytes. */ - emailStorageQuota: number - /** Limit number of databases. */ - databasesQuota: number - /** Limit quantity of hosting storage in gigabytes. */ - hostingStorageQuota: number - /** Whether or not support is included. */ - supportIncluded: boolean - /** Limit number of virtual CPU. */ - vCpu: number - /** Limit quantity of memory in gigabytes. */ - ram: number - /** Limit number of add-on domains. */ - maxAddonDomains: number -} - -export interface CreateHostingRequestDomainConfiguration { - updateNameservers: boolean - updateWebRecord: boolean - updateMailRecord: boolean - updateAllRecords: boolean -} - -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 ControlPanel { - /** Control panel name. */ - name: string - /** Define if the control panel type is available to order. */ - available: boolean - /** URL of this control panel's logo. */ - logoUrl: string - /** List of available languages for the control panel. */ - availableLanguages: StdLanguageCode[] -} - -export interface Hosting { - /** ID of the Web Hosting plan. */ - id: string - /** ID of the Scaleway Organization the Web Hosting plan belongs to. */ - organizationId: string - /** ID of the Scaleway Project the Web Hosting plan belongs to. */ - projectId: string - /** Date on which the Web Hosting plan was last updated. */ - updatedAt?: Date - /** Date on which the Web Hosting plan was created. */ - createdAt?: Date - /** Status of the Web Hosting plan. */ - status: HostingStatus - /** Hostname of the host platform. */ - platformHostname: string - /** Number of the host platform. */ - platformNumber?: number - /** ID of the active offer for the Web Hosting plan. */ - offerId: string - /** Name of the active offer for the Web Hosting plan. */ - offerName: string - /** Main domain associated with the Web Hosting plan. */ - domain: string - /** List of tags associated with the Web Hosting plan. */ - tags: string[] - /** Array of any options activated for the Web Hosting plan. */ - options: HostingOption[] - /** DNS status of the Web Hosting plan. */ - dnsStatus: HostingDnsStatus - /** URL to connect to cPanel dashboard and to Webmail interface. */ - cpanelUrls?: HostingCpanelUrls - /** Main Web Hosting cPanel username. */ - username: string - /** Indicates if the hosting offer has reached its end of life. */ - offerEndOfLife: boolean - /** Name of the control panel. */ - controlPanelName: string - /** Group of the hosting's host server/platform. */ - platformGroup: string - /** IPv4 address of the hosting's host server. */ - ipv4: string - /** IPv6 address of the hosting's host server. */ - ipv6: string - /** Whether the hosting is protected or not. */ - protected: boolean - /** - * One-time-password used for the first login or reset password, empty after - * first use. - */ - oneTimePassword: string - /** Region where the Web Hosting plan is hosted. */ - region: ScwRegion -} - -export interface Mailbox { - /** The ID of the mailbox. */ - mailboxId: number - /** The email address of the mailbox. */ - email?: EmailAddress -} - -export interface Offer { - /** Offer ID. */ - id: string - /** Unique identifier used for billing. */ - billingOperationPath: string - /** Product constituting this offer. */ - product?: OfferProduct - /** Price of this offer. */ - price?: Money - /** - * If a hosting_id was specified in the call, defines whether this offer is - * available for that Web Hosting plan to migrate (update) to. - */ - available: boolean - /** Quota warnings, if the offer is not available for the specified hosting_id. */ - quotaWarnings: OfferQuotaWarning[] - /** Indicates if the offer has reached its end of life. */ - endOfLife: boolean - /** Name of the control panel. */ - controlPanelName: string -} - -export type CheckUserOwnsDomainRequest = { - /** - * Region to target. If none is passed will use default region from the - * config. - */ - region?: ScwRegion - /** Domain for which ownership is to be verified. */ - domain: string - /** ID of the project currently in use. */ - projectId?: string -} - -export interface CheckUserOwnsDomainResponse { - /** Indicates whether the specified project owns the domain. */ - ownsDomain: boolean -} - -export type ClassicMailApiCreateMailboxRequest = { - /** - * Region to target. If none is passed will use default region from the - * config. - */ - region?: ScwRegion - /** The Online hosting ID. */ - onlineId: number - /** The email address of the mailbox. */ - email?: EmailAddress - /** Password for the new mailbox. */ - password: string -} - -export type ClassicMailApiDeleteMailboxRequest = { - /** - * Region to target. If none is passed will use default region from the - * config. - */ - region?: ScwRegion - /** The Online hosting ID. */ - onlineId: number - /** The ID of the mailbox to delete. */ - mailboxId: number -} - -export type ClassicMailApiGetMailboxRequest = { - /** - * Region to target. If none is passed will use default region from the - * config. - */ - region?: ScwRegion - /** The Online hosting ID. */ - onlineId: number - /** The ID of the mailbox to get. */ - mailboxId: number -} - -export type ClassicMailApiListMailboxesRequest = { - /** - * Region to target. If none is passed will use default region from the - * config. - */ - region?: ScwRegion - /** The Online hosting ID. */ - onlineId: number - /** Page number (must be a positive integer). */ - page?: number - /** - * Number of mailboxes to return (must be a positive integer lower or equal to - * 100). - */ - pageSize?: number - /** Domain to filter the mailboxes. */ - domain?: string -} - -export type ClassicMailApiUpdateMailboxRequest = { - /** - * Region to target. If none is passed will use default region from the - * config. - */ - region?: ScwRegion - /** The Online hosting ID. */ - onlineId: number - /** The ID of the mailbox to update. */ - mailboxId: number - /** New password for the mailbox. */ - password?: string -} - -export type CreateHostingRequest = { - /** - * Region to target. If none is passed will use default region from the - * config. - */ - region?: ScwRegion - /** ID of the selected offer for the Web Hosting plan. */ - offerId: string - /** ID of the Scaleway Project in which to create the Web Hosting plan. */ - projectId?: string - /** Contact email for the Web Hosting client. */ - email?: string - /** List of tags for the Web Hosting plan. */ - tags?: string[] - /** - * Domain name to link to the Web Hosting plan. You must already own this - * domain name, and have completed the DNS validation process beforehand. - */ - domain: string - /** IDs of any selected additional options for the Web Hosting plan. */ - optionIds?: string[] - /** Default language for the control panel interface. */ - language?: StdLanguageCode - /** - * Indicates whether to update hosting domain name servers and DNS records for - * domains managed by Scaleway Elements. - */ - domainConfiguration?: CreateHostingRequestDomainConfiguration -} - -export type CreateSessionRequest = { - /** - * Region to target. If none is passed will use default region from the - * config. - */ - region?: ScwRegion - /** Hosting ID. */ - hostingId: string -} - -export type DeleteHostingRequest = { - /** - * Region to target. If none is passed will use default region from the - * config. - */ - region?: ScwRegion - /** Hosting ID. */ - hostingId: string -} - -export interface DnsRecords { - /** List of DNS records. */ - records: DnsRecord[] - /** List of nameservers. */ - nameServers: Nameserver[] - /** Status of the records. */ - status: DnsRecordsStatus -} - -export type GetDomainDnsRecordsRequest = { - /** - * Region to target. If none is passed will use default region from the - * config. - */ - region?: ScwRegion - /** Domain associated with the DNS records. */ - domain: string -} - -export type GetHostingRequest = { - /** - * Region to target. If none is passed will use default region from the - * config. - */ - region?: ScwRegion - /** Hosting ID. */ - hostingId: string -} - -export type ListControlPanelsRequest = { - /** - * Region to target. If none is passed will use default region from the - * config. - */ - region?: ScwRegion - /** - * Page number to return, from the paginated results (must be a positive - * integer). - */ - page?: number - /** - * Number of control panels to return (must be a positive integer lower or - * equal to 100). - */ - pageSize?: number -} - -export interface ListControlPanelsResponse { - /** Number of control panels returned. */ - totalCount: number - /** List of control panels. */ - controlPanels: ControlPanel[] -} - -export type ListHostingsRequest = { - /** - * Region to target. If none is passed will use default region from the - * config. - */ - region?: ScwRegion - /** - * Page number to return, from the paginated results (must be a positive - * integer). - */ - page?: number - /** - * Number of Web Hosting plans to return (must be a positive integer lower or - * equal to 100). - */ - pageSize?: number - /** Sort order for Web Hosting plans in the response. */ - orderBy?: ListHostingsRequestOrderBy - /** - * Tags to filter for, only Web Hosting plans with matching tags will be - * returned. - */ - tags?: string[] - /** - * Statuses to filter for, only Web Hosting plans with matching statuses will - * be returned. - */ - statuses?: HostingStatus[] - /** - * Domain to filter for, only Web Hosting plans associated with this domain - * will be returned. - */ - domain?: string - /** - * Project ID to filter for, only Web Hosting plans from this Project will be - * returned. - */ - projectId?: string - /** - * Organization ID to filter for, only Web Hosting plans from this - * Organization will be returned. - */ - organizationId?: string - /** - * Name of the control panel to filter for, only Web Hosting plans from this - * control panel will be returned. - */ - controlPanels?: string[] -} - -export interface ListHostingsResponse { - /** Number of Web Hosting plans returned. */ - totalCount: number - /** List of Web Hosting plans. */ - hostings: Hosting[] -} - -export interface ListMailboxesResponse { - /** Total number of mailboxes. */ - totalCount: number - /** List of mailboxes. */ - mailboxes: Mailbox[] -} - -export type ListOffersRequest = { - /** - * Region to target. If none is passed will use default region from the - * config. - */ - region?: ScwRegion - /** Sort order of offers in the response. */ - orderBy?: ListOffersRequestOrderBy - /** - * Defines whether the response should consist of offers only, without - * options. - */ - withoutOptions: boolean - /** - * Defines whether the response should consist of options only, without - * offers. - */ - onlyOptions: boolean - /** - * ID of a Web Hosting plan, to check compatibility with returned offers (in - * case of wanting to update the plan). - */ - hostingId?: string - /** Name of the control panel to filter for. */ - controlPanels?: string[] -} - -export interface ListOffersResponse { - /** List of offers. */ - offers: Offer[] -} - -export type ResetHostingPasswordRequest = { - /** - * Region to target. If none is passed will use default region from the - * config. - */ - region?: ScwRegion - /** UUID of the hosting. */ - hostingId: string -} - -export interface ResetHostingPasswordResponse { - /** New password. */ - password: string -} - -export type RestoreHostingRequest = { - /** - * Region to target. If none is passed will use default region from the - * config. - */ - region?: ScwRegion - /** Hosting ID. */ - hostingId: string -} - -export interface Session { - /** Logged user's session URL. */ - url: string -} - -export type UpdateHostingRequest = { - /** - * Region to target. If none is passed will use default region from the - * config. - */ - region?: ScwRegion - /** Hosting ID. */ - hostingId: string - /** New contact email for the Web Hosting plan. */ - email?: string - /** New tags for the Web Hosting plan. */ - tags?: string[] - /** IDs of the new options for the Web Hosting plan. */ - optionIds?: string[] - /** ID of the new offer for the Web Hosting plan. */ - offerId?: string - /** Whether the hosting is protected or not. */ - protected?: boolean -} diff --git a/packages/clients/src/api/webhosting/v1alpha1/validation-rules.gen.ts b/packages/clients/src/api/webhosting/v1alpha1/validation-rules.gen.ts deleted file mode 100644 index c886d2e84..000000000 --- a/packages/clients/src/api/webhosting/v1alpha1/validation-rules.gen.ts +++ /dev/null @@ -1,32 +0,0 @@ -// This file was automatically generated. DO NOT EDIT. -// If you have any remark or suggestion do not hesitate to open an issue. - -export const ClassicMailApiListMailboxesRequest = { - page: { - greaterThan: 0, - }, - pageSize: { - greaterThan: 0, - lessThanOrEqual: 100, - }, -} - -export const ListControlPanelsRequest = { - page: { - greaterThan: 0, - }, - pageSize: { - greaterThan: 0, - lessThanOrEqual: 100, - }, -} - -export const ListHostingsRequest = { - page: { - greaterThan: 0, - }, - pageSize: { - greaterThan: 0, - lessThanOrEqual: 100, - }, -}