diff --git a/packages/clients/src/api/mongodb/v1alpha1/api.gen.ts b/packages/clients/src/api/mongodb/v1alpha1/api.gen.ts index ed5383009..c41746982 100644 --- a/packages/clients/src/api/mongodb/v1alpha1/api.gen.ts +++ b/packages/clients/src/api/mongodb/v1alpha1/api.gen.ts @@ -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, @@ -33,6 +36,7 @@ import type { DeleteSnapshotRequest, GetInstanceCertificateRequest, GetInstanceRequest, + GetSnapshotRequest, Instance, ListInstancesRequest, ListInstancesResponse, @@ -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) => + this.client.fetch( + { + 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, + options?: Readonly>, + ) => + waitForResource( + options?.stop ?? + (res => + Promise.resolve(!SNAPSHOT_TRANSIENT_STATUSES.includes(res.status))), + this.getSnapshot, + request, + options, + ) + updateSnapshot = (request: Readonly) => this.client.fetch( { diff --git a/packages/clients/src/api/mongodb/v1alpha1/index.gen.ts b/packages/clients/src/api/mongodb/v1alpha1/index.gen.ts index 097cb493b..77915a46b 100644 --- a/packages/clients/src/api/mongodb/v1alpha1/index.gen.ts +++ b/packages/clients/src/api/mongodb/v1alpha1/index.gen.ts @@ -16,6 +16,7 @@ export type { EndpointSpecPublicDetails, GetInstanceCertificateRequest, GetInstanceRequest, + GetSnapshotRequest, Instance, InstanceSetting, InstanceStatus, diff --git a/packages/clients/src/api/mongodb/v1alpha1/types.gen.ts b/packages/clients/src/api/mongodb/v1alpha1/types.gen.ts index 9ab5c41e2..7bcb5285e 100644 --- a/packages/clients/src/api/mongodb/v1alpha1/types.gen.ts +++ b/packages/clients/src/api/mongodb/v1alpha1/types.gen.ts @@ -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