From 0187c31954bd2ba4c70e63bf891e7dc0245dde5f Mon Sep 17 00:00:00 2001 From: Scaleway Bot Date: Mon, 16 Dec 2024 10:57:39 +0100 Subject: [PATCH] feat(webhosting): edit method to allow user creation (#1655) Co-authored-by: Jonathan R. --- .../src/api/webhosting/v1/index.gen.ts | 1 + .../src/api/webhosting/v1/marshalling.gen.ts | 20 +++++++++++++++++++ .../src/api/webhosting/v1/types.gen.ts | 17 ++++++++++++++++ 3 files changed, 38 insertions(+) diff --git a/packages/clients/src/api/webhosting/v1/index.gen.ts b/packages/clients/src/api/webhosting/v1/index.gen.ts index 47a6ef8f7..9f1ef58ea 100644 --- a/packages/clients/src/api/webhosting/v1/index.gen.ts +++ b/packages/clients/src/api/webhosting/v1/index.gen.ts @@ -15,6 +15,7 @@ export type { CheckUserOwnsDomainResponse, ControlPanel, ControlPanelApiListControlPanelsRequest, + CreateDatabaseRequestUser, CreateHostingRequestDomainConfiguration, Database, DatabaseApiAssignDatabaseUserRequest, diff --git a/packages/clients/src/api/webhosting/v1/marshalling.gen.ts b/packages/clients/src/api/webhosting/v1/marshalling.gen.ts index cdc90bf25..0bf7b9690 100644 --- a/packages/clients/src/api/webhosting/v1/marshalling.gen.ts +++ b/packages/clients/src/api/webhosting/v1/marshalling.gen.ts @@ -2,6 +2,7 @@ // If you have any remark or suggestion do not hesitate to open an issue. import { isJSONObject, + resolveOneOf, unmarshalArrayOfObject, unmarshalDate, unmarshalMoney, @@ -10,6 +11,7 @@ import type { DefaultValues } from '../../../bridge' import type { CheckUserOwnsDomainResponse, ControlPanel, + CreateDatabaseRequestUser, CreateHostingRequestDomainConfiguration, Database, DatabaseApiAssignDatabaseUserRequest, @@ -517,11 +519,29 @@ export const marshalDatabaseApiChangeDatabaseUserPasswordRequest = ( password: request.password, }) +const marshalCreateDatabaseRequestUser = ( + request: CreateDatabaseRequestUser, + defaults: DefaultValues, +): Record => ({ + password: request.password, + username: request.username, +}) + export const marshalDatabaseApiCreateDatabaseRequest = ( request: DatabaseApiCreateDatabaseRequest, defaults: DefaultValues, ): Record => ({ database_name: request.databaseName, + ...resolveOneOf | string>([ + { + param: 'new_user', + value: + request.newUser !== undefined + ? marshalCreateDatabaseRequestUser(request.newUser, defaults) + : undefined, + }, + { param: 'existing_username', value: request.existingUsername }, + ]), }) export const marshalDatabaseApiCreateDatabaseUserRequest = ( diff --git a/packages/clients/src/api/webhosting/v1/types.gen.ts b/packages/clients/src/api/webhosting/v1/types.gen.ts index a1e928ee5..e4fab8a91 100644 --- a/packages/clients/src/api/webhosting/v1/types.gen.ts +++ b/packages/clients/src/api/webhosting/v1/types.gen.ts @@ -106,6 +106,11 @@ export interface PlatformControlPanel { urls?: PlatformControlPanelUrls } +export interface CreateDatabaseRequestUser { + username: string + password: string +} + export interface CreateHostingRequestDomainConfiguration { updateNameservers: boolean updateWebRecord: boolean @@ -316,6 +321,18 @@ export type DatabaseApiCreateDatabaseRequest = { hostingId: string /** Name of the database to be created. */ databaseName: string + /** + * (Optional) Username and password to create a user and link to the database. + * + * One-of ('user'): at most one of 'newUser', 'existingUsername' could be set. + */ + newUser?: CreateDatabaseRequestUser + /** + * (Optional) Username to link an existing user to the database. + * + * One-of ('user'): at most one of 'newUser', 'existingUsername' could be set. + */ + existingUsername?: string } export type DatabaseApiCreateDatabaseUserRequest = {