Skip to content

Commit

Permalink
feat(webhosting): edit method to allow user creation (#1655)
Browse files Browse the repository at this point in the history
Co-authored-by: Jonathan R. <jremy@scaleway.com>
  • Loading branch information
scaleway-bot and jremy42 authored Dec 16, 2024
1 parent 71b221b commit 0187c31
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/clients/src/api/webhosting/v1/index.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export type {
CheckUserOwnsDomainResponse,
ControlPanel,
ControlPanelApiListControlPanelsRequest,
CreateDatabaseRequestUser,
CreateHostingRequestDomainConfiguration,
Database,
DatabaseApiAssignDatabaseUserRequest,
Expand Down
20 changes: 20 additions & 0 deletions packages/clients/src/api/webhosting/v1/marshalling.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// If you have any remark or suggestion do not hesitate to open an issue.
import {
isJSONObject,
resolveOneOf,
unmarshalArrayOfObject,
unmarshalDate,
unmarshalMoney,
Expand All @@ -10,6 +11,7 @@ import type { DefaultValues } from '../../../bridge'
import type {
CheckUserOwnsDomainResponse,
ControlPanel,
CreateDatabaseRequestUser,
CreateHostingRequestDomainConfiguration,
Database,
DatabaseApiAssignDatabaseUserRequest,
Expand Down Expand Up @@ -517,11 +519,29 @@ export const marshalDatabaseApiChangeDatabaseUserPasswordRequest = (
password: request.password,
})

const marshalCreateDatabaseRequestUser = (
request: CreateDatabaseRequestUser,
defaults: DefaultValues,
): Record<string, unknown> => ({
password: request.password,
username: request.username,
})

export const marshalDatabaseApiCreateDatabaseRequest = (
request: DatabaseApiCreateDatabaseRequest,
defaults: DefaultValues,
): Record<string, unknown> => ({
database_name: request.databaseName,
...resolveOneOf<Record<string, unknown> | string>([
{
param: 'new_user',
value:
request.newUser !== undefined
? marshalCreateDatabaseRequestUser(request.newUser, defaults)
: undefined,
},
{ param: 'existing_username', value: request.existingUsername },
]),
})

export const marshalDatabaseApiCreateDatabaseUserRequest = (
Expand Down
17 changes: 17 additions & 0 deletions packages/clients/src/api/webhosting/v1/types.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,11 @@ export interface PlatformControlPanel {
urls?: PlatformControlPanelUrls
}

export interface CreateDatabaseRequestUser {
username: string
password: string
}

export interface CreateHostingRequestDomainConfiguration {
updateNameservers: boolean
updateWebRecord: boolean
Expand Down Expand Up @@ -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 = {
Expand Down

0 comments on commit 0187c31

Please sign in to comment.