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
29 changes: 29 additions & 0 deletions packages_generated/mongodb/src/v1/api.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import {
marshalUpgradeInstanceRequest,
unmarshalEndpoint,
unmarshalInstance,
unmarshalListDatabasesResponse,
unmarshalListInstancesResponse,
unmarshalListNodeTypesResponse,
unmarshalListSnapshotsResponse,
Expand All @@ -49,6 +50,8 @@ import type {
GetInstanceRequest,
GetSnapshotRequest,
Instance,
ListDatabasesRequest,
ListDatabasesResponse,
ListInstancesRequest,
ListInstancesResponse,
ListNodeTypesRequest,
Expand Down Expand Up @@ -534,6 +537,32 @@ export class API extends ParentAPI {
unmarshalUser,
)

protected pageOfListDatabases = (request: Readonly<ListDatabasesRequest>) =>
this.client.fetch<ListDatabasesResponse>(
{
method: 'GET',
path: `/mongodb/v1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/instances/${validatePathParam('instanceId', request.instanceId)}/databases`,
urlParams: urlParams(
['order_by', request.orderBy],
['page', request.page],
[
'page_size',
request.pageSize ?? this.client.settings.defaultPageSize,
],
),
},
unmarshalListDatabasesResponse,
)

/**
* List databases in a Database Instance. List all databases of a given Database Instance.
*
* @param request - The request {@link ListDatabasesRequest}
* @returns A Promise of ListDatabasesResponse
*/
listDatabases = (request: Readonly<ListDatabasesRequest>) =>
enrichForPagination('databases', this.pageOfListDatabases, request)

/**
* Delete a Database Instance endpoint. Delete the endpoint of a Database Instance. You must specify the `endpoint_id` parameter of the endpoint you want to delete. Note that you might need to update any environment configurations that point to the deleted endpoint.
*
Expand Down
4 changes: 4 additions & 0 deletions packages_generated/mongodb/src/v1/index.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export type {
CreateInstanceRequest,
CreateSnapshotRequest,
CreateUserRequest,
Database,
DeleteEndpointRequest,
DeleteInstanceRequest,
DeleteSnapshotRequest,
Expand All @@ -24,6 +25,9 @@ export type {
Instance,
InstanceSnapshotSchedule,
InstanceStatus,
ListDatabasesRequest,
ListDatabasesRequestOrderBy,
ListDatabasesResponse,
ListInstancesRequest,
ListInstancesRequestOrderBy,
ListInstancesResponse,
Expand Down
29 changes: 29 additions & 0 deletions packages_generated/mongodb/src/v1/marshalling.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import type {
CreateInstanceRequest,
CreateSnapshotRequest,
CreateUserRequest,
Database,
Endpoint,
EndpointPrivateNetworkDetails,
EndpointPublicNetworkDetails,
Expand All @@ -21,6 +22,7 @@ import type {
EndpointSpecPublicNetworkDetails,
Instance,
InstanceSnapshotSchedule,
ListDatabasesResponse,
ListInstancesResponse,
ListNodeTypesResponse,
ListSnapshotsResponse,
Expand Down Expand Up @@ -195,6 +197,33 @@ export const unmarshalUser = (data: unknown): User => {
} as User
}

const unmarshalDatabase = (data: unknown): Database => {
if (!isJSONObject(data)) {
throw new TypeError(
`Unmarshalling the type 'Database' failed as data isn't a dictionary.`,
)
}

return {
name: data.name,
} as Database
}

export const unmarshalListDatabasesResponse = (
data: unknown,
): ListDatabasesResponse => {
if (!isJSONObject(data)) {
throw new TypeError(
`Unmarshalling the type 'ListDatabasesResponse' failed as data isn't a dictionary.`,
)
}

return {
databases: unmarshalArrayOfObject(data.databases, unmarshalDatabase),
totalCount: data.total_count,
} as ListDatabasesResponse
}

export const unmarshalListInstancesResponse = (
data: unknown,
): ListInstancesResponse => {
Expand Down
34 changes: 34 additions & 0 deletions packages_generated/mongodb/src/v1/types.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ export type InstanceStatus =
| 'locked'
| 'snapshotting'

export type ListDatabasesRequestOrderBy = 'name_asc' | 'name_desc'

export type ListInstancesRequestOrderBy =
| 'created_at_asc'
| 'created_at_desc'
Expand Down Expand Up @@ -180,6 +182,10 @@ export interface EndpointSpec {
privateNetwork?: EndpointSpecPrivateNetworkDetails
}

export interface Database {
name: string
}

export interface Instance {
/**
* UUID of the Database Instance.
Expand Down Expand Up @@ -532,6 +538,34 @@ export type GetSnapshotRequest = {
snapshotId: string
}

export type ListDatabasesRequest = {
/**
* Region to target. If none is passed will use default region from the config.
*/
region?: ScwRegion
/**
* UUID of the Database Instance.
*/
instanceId: string
/**
* Criteria to use when requesting user listing.
*/
orderBy?: ListDatabasesRequestOrderBy
page?: number
pageSize?: number
}

export interface ListDatabasesResponse {
/**
* List of the databases.
*/
databases: Database[]
/**
* Total count of databases present on a Database Instance.
*/
totalCount: number
}

export type ListInstancesRequest = {
/**
* Region to target. If none is passed will use default region from the config.
Expand Down
10 changes: 10 additions & 0 deletions packages_generated/mongodb/src/v1/validation-rules.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,16 @@ export const DeleteUserRequest = {
},
}

export const ListDatabasesRequest = {
page: {
greaterThanOrEqual: 1,
},
pageSize: {
greaterThanOrEqual: 1,
lessThanOrEqual: 100,
},
}

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