From 7c273c8d3008d9c5eda4ef2fd666cb8a18987d2f Mon Sep 17 00:00:00 2001 From: scaleway-bot Date: Tue, 28 Oct 2025 14:42:34 +0000 Subject: [PATCH] feat: update generated APIs --- .../webhosting/src/v1/api.gen.ts | 37 ++++++++++++++++++- .../webhosting/src/v1/index.gen.ts | 2 + .../webhosting/src/v1/marshalling.gen.ts | 36 +++++++++++------- .../webhosting/src/v1/types.gen.ts | 30 +++++++++++++++ 4 files changed, 90 insertions(+), 15 deletions(-) diff --git a/packages_generated/webhosting/src/v1/api.gen.ts b/packages_generated/webhosting/src/v1/api.gen.ts index 720cf5a60..14291aec4 100644 --- a/packages_generated/webhosting/src/v1/api.gen.ts +++ b/packages_generated/webhosting/src/v1/api.gen.ts @@ -33,6 +33,7 @@ import { marshalMailAccountApiChangeMailAccountPasswordRequest, marshalMailAccountApiCreateMailAccountRequest, marshalMailAccountApiRemoveMailAccountRequest, + marshalWebsiteApiCreateWebsiteRequest, unmarshalBackup, unmarshalCheckFreeDomainAvailabilityResponse, unmarshalCheckUserOwnsDomainResponse, @@ -63,6 +64,7 @@ import { unmarshalRestoreBackupResponse, unmarshalSearchDomainsResponse, unmarshalSession, + unmarshalWebsite, } from './marshalling.gen.js' import type { Backup, @@ -140,6 +142,9 @@ import type { RestoreBackupResponse, SearchDomainsResponse, Session, + Website, + WebsiteApiCreateWebsiteRequest, + WebsiteApiDeleteWebsiteRequest, WebsiteApiListWebsitesRequest, } from './types.gen.js' @@ -990,7 +995,7 @@ export class HostingAPI extends ParentAPI { ) /** - * Attach a custom domain to a webhosting. + * Attach a custom domain to a webhosting as an alias to the main domain. * * @param request - The request {@link HostingApiAddCustomDomainRequest} * @returns A Promise of HostingSummary @@ -1365,4 +1370,34 @@ export class WebsiteAPI extends ParentAPI { */ listWebsites = (request: Readonly) => enrichForPagination('websites', this.pageOfListWebsites, request) + + /** + * Create a new website and attach it to a webhosting. + * + * @param request - The request {@link WebsiteApiCreateWebsiteRequest} + * @returns A Promise of Website + */ + createWebsite = (request: Readonly) => + this.client.fetch( + { + body: JSON.stringify( + marshalWebsiteApiCreateWebsiteRequest(request, this.client.settings), + ), + headers: jsonContentHeaders, + method: 'POST', + path: `/webhosting/v1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/hostings/${validatePathParam('hostingId', request.hostingId)}/websites`, + }, + unmarshalWebsite, + ) + + /** + * Delete a website from a webhosting. + * + * @param request - The request {@link WebsiteApiDeleteWebsiteRequest} + */ + deleteWebsite = (request: Readonly) => + this.client.fetch({ + method: 'DELETE', + path: `/webhosting/v1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/hostings/${validatePathParam('hostingId', request.hostingId)}/websites/${validatePathParam('domainName', request.domainName)}`, + }) } diff --git a/packages_generated/webhosting/src/v1/index.gen.ts b/packages_generated/webhosting/src/v1/index.gen.ts index 800ac811f..d07a695c5 100644 --- a/packages_generated/webhosting/src/v1/index.gen.ts +++ b/packages_generated/webhosting/src/v1/index.gen.ts @@ -138,6 +138,8 @@ export type { Session, SyncDomainDnsRecordsRequestRecord, Website, + WebsiteApiCreateWebsiteRequest, + WebsiteApiDeleteWebsiteRequest, WebsiteApiListWebsitesRequest, } from './types.gen.js' export * as ValidationRules from './validation-rules.gen.js' diff --git a/packages_generated/webhosting/src/v1/marshalling.gen.ts b/packages_generated/webhosting/src/v1/marshalling.gen.ts index 28120efe9..73e2e4653 100644 --- a/packages_generated/webhosting/src/v1/marshalling.gen.ts +++ b/packages_generated/webhosting/src/v1/marshalling.gen.ts @@ -79,6 +79,7 @@ import type { Session, SyncDomainDnsRecordsRequestRecord, Website, + WebsiteApiCreateWebsiteRequest, } from './types.gen.js' export const unmarshalBackup = (data: unknown): Backup => { @@ -224,6 +225,20 @@ export const unmarshalMailAccount = (data: unknown): MailAccount => { } as MailAccount } +export const unmarshalWebsite = (data: unknown): Website => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'Website' failed as data isn't a dictionary.`, + ) + } + + return { + domain: data.domain, + path: data.path, + sslStatus: data.ssl_status, + } as Website +} + const unmarshalFreeDomain = (data: unknown): FreeDomain => { if (!isJSONObject(data)) { throw new TypeError( @@ -705,20 +720,6 @@ export const unmarshalListRecentProgressesResponse = ( } as ListRecentProgressesResponse } -const unmarshalWebsite = (data: unknown): Website => { - if (!isJSONObject(data)) { - throw new TypeError( - `Unmarshalling the type 'Website' failed as data isn't a dictionary.`, - ) - } - - return { - domain: data.domain, - path: data.path, - sslStatus: data.ssl_status, - } as Website -} - export const unmarshalListWebsitesResponse = ( data: unknown, ): ListWebsitesResponse => { @@ -1091,3 +1092,10 @@ export const marshalMailAccountApiRemoveMailAccountRequest = ( domain: request.domain, username: request.username, }) + +export const marshalWebsiteApiCreateWebsiteRequest = ( + request: WebsiteApiCreateWebsiteRequest, + defaults: DefaultValues, +): Record => ({ + domain_name: request.domainName, +}) diff --git a/packages_generated/webhosting/src/v1/types.gen.ts b/packages_generated/webhosting/src/v1/types.gen.ts index b2a251f86..9a502f6b4 100644 --- a/packages_generated/webhosting/src/v1/types.gen.ts +++ b/packages_generated/webhosting/src/v1/types.gen.ts @@ -1891,6 +1891,36 @@ export interface Session { url: string } +export type WebsiteApiCreateWebsiteRequest = { + /** + * Region to target. If none is passed will use default region from the config. + */ + region?: ScwRegion + /** + * Hosting ID to which the website is attached to. + */ + hostingId: string + /** + * The new domain name or subdomain to use for the website. + */ + domainName: string +} + +export type WebsiteApiDeleteWebsiteRequest = { + /** + * Region to target. If none is passed will use default region from the config. + */ + region?: ScwRegion + /** + * Hosting ID to which the website is detached from. + */ + hostingId: string + /** + * The new domain name or subdomain attached to the website. + */ + domainName: string +} + export type WebsiteApiListWebsitesRequest = { /** * Region to target. If none is passed will use default region from the config.