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
23 changes: 23 additions & 0 deletions packages/clients/src/api/mongodb/v1alpha1/api.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
import {
marshalCreateInstanceRequest,
marshalCreateSnapshotRequest,
marshalCreateUserRequest,
marshalRestoreSnapshotRequest,
marshalUpdateInstanceRequest,
marshalUpdateSnapshotRequest,
Expand All @@ -32,6 +33,7 @@ import {
import type {
CreateInstanceRequest,
CreateSnapshotRequest,
CreateUserRequest,
DeleteInstanceRequest,
DeleteSnapshotRequest,
GetInstanceCertificateRequest,
Expand Down Expand Up @@ -492,6 +494,27 @@ export class API extends ParentAPI {
listUsers = (request: Readonly<ListUsersRequest>) =>
enrichForPagination('users', this.pageOfListUsers, request)

/**
* Create an user on a Database Instance. Create an user on a Database
* Instance. You must define the `name`, `password` of the user and
* `instance_id` parameters in the request.
*
* @param request - The request {@link CreateUserRequest}
* @returns A Promise of User
*/
createUser = (request: Readonly<CreateUserRequest>) =>
this.client.fetch<User>(
{
body: JSON.stringify(
marshalCreateUserRequest(request, this.client.settings),
),
headers: jsonContentHeaders,
method: 'POST',
path: `/mongodb/v1alpha1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/instances/${validatePathParam('instanceId', request.instanceId)}/users/${validatePathParam('name', request.name)}`,
},
unmarshalUser,
)

/**
* Update a user on a Database Instance. Update the parameters of a user on a
* Database Instance. You can update the `password` parameter, but you cannot
Expand Down
1 change: 1 addition & 0 deletions packages/clients/src/api/mongodb/v1alpha1/index.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export type {
CreateInstanceRequest,
CreateInstanceRequestVolumeDetails,
CreateSnapshotRequest,
CreateUserRequest,
DeleteInstanceRequest,
DeleteSnapshotRequest,
Endpoint,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import type {
CreateInstanceRequest,
CreateInstanceRequestVolumeDetails,
CreateSnapshotRequest,
CreateUserRequest,
Endpoint,
EndpointPrivateNetworkDetails,
EndpointPublicDetails,
Expand Down Expand Up @@ -415,6 +416,13 @@ export const marshalCreateSnapshotRequest = (
name: request.name,
})

export const marshalCreateUserRequest = (
request: CreateUserRequest,
defaults: DefaultValues,
): Record<string, unknown> => ({
password: request.password,
})

const marshalRestoreSnapshotRequestVolumeDetails = (
request: RestoreSnapshotRequestVolumeDetails,
defaults: DefaultValues,
Expand Down
14 changes: 14 additions & 0 deletions packages/clients/src/api/mongodb/v1alpha1/types.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,20 @@ export type CreateSnapshotRequest = {
expiresAt?: Date
}

export type CreateUserRequest = {
/**
* Region to target. If none is passed will use default region from the
* config.
*/
region?: Region
/** UUID of the Database Instance the user belongs to. */
instanceId: string
/** Name of the database user. */
name: string
/** Password of the database user. */
password?: string
}

export type DeleteInstanceRequest = {
/**
* Region to target. If none is passed will use default region from the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,18 @@ export const CreateSnapshotRequest = {
},
}

export const CreateUserRequest = {
name: {
maxLength: 63,
minLength: 1,
pattern: /^[a-zA-Z0-9_\-]*$/,
},
password: {
maxLength: 128,
minLength: 8,
},
}

export const ListInstancesRequest = {
name: {
maxLength: 255,
Expand Down