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
43 changes: 42 additions & 1 deletion packages/clients/src/api/mongodb/v1alpha1/api.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ import {
waitForResource,
} from '../../../bridge'
import type { Region, WaitForOptions } from '../../../bridge'
import { INSTANCE_TRANSIENT_STATUSES } from './content.gen'
import {
INSTANCE_TRANSIENT_STATUSES,
SNAPSHOT_TRANSIENT_STATUSES,
} from './content.gen'
import {
marshalCreateInstanceRequest,
marshalCreateSnapshotRequest,
Expand All @@ -33,6 +36,7 @@ import type {
DeleteSnapshotRequest,
GetInstanceCertificateRequest,
GetInstanceRequest,
GetSnapshotRequest,
Instance,
ListInstancesRequest,
ListInstancesResponse,
Expand Down Expand Up @@ -320,6 +324,43 @@ export class API extends ParentAPI {
unmarshalSnapshot,
)

/**
* Get a Database Instance snapshot. Retrieve information about a given
* snapshot of a Database Instance. You must specify, in the endpoint, the
* `snapshot_id` parameter of the snapshot you want to retrieve.
*
* @param request - The request {@link GetSnapshotRequest}
* @returns A Promise of Snapshot
*/
getSnapshot = (request: Readonly<GetSnapshotRequest>) =>
this.client.fetch<Snapshot>(
{
method: 'GET',
path: `/mongodb/v1alpha1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/snapshots/${validatePathParam('snapshotId', request.snapshotId)}`,
},
unmarshalSnapshot,
)

/**
* Waits for {@link Snapshot} to be in a final state.
*
* @param request - The request {@link GetSnapshotRequest}
* @param options - The waiting options
* @returns A Promise of Snapshot
*/
waitForSnapshot = (
request: Readonly<GetSnapshotRequest>,
options?: Readonly<WaitForOptions<Snapshot>>,
) =>
waitForResource(
options?.stop ??
(res =>
Promise.resolve(!SNAPSHOT_TRANSIENT_STATUSES.includes(res.status))),
this.getSnapshot,
request,
options,
)

updateSnapshot = (request: Readonly<UpdateSnapshotRequest>) =>
this.client.fetch<Snapshot>(
{
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 @@ -16,6 +16,7 @@ export type {
EndpointSpecPublicDetails,
GetInstanceCertificateRequest,
GetInstanceRequest,
GetSnapshotRequest,
Instance,
InstanceSetting,
InstanceStatus,
Expand Down
10 changes: 10 additions & 0 deletions packages/clients/src/api/mongodb/v1alpha1/types.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,16 @@ export type GetInstanceRequest = {
instanceId: string
}

export type GetSnapshotRequest = {
/**
* Region to target. If none is passed will use default region from the
* config.
*/
region?: Region
/** UUID of the snapshot. */
snapshotId: string
}

export type ListInstancesRequest = {
/**
* Region to target. If none is passed will use default region from the
Expand Down