@@ -8,7 +8,10 @@ import {
88 waitForResource ,
99} from '../../../bridge'
1010import type { Region , WaitForOptions } from '../../../bridge'
11- import { INSTANCE_TRANSIENT_STATUSES } from './content.gen'
11+ import {
12+ INSTANCE_TRANSIENT_STATUSES ,
13+ SNAPSHOT_TRANSIENT_STATUSES ,
14+ } from './content.gen'
1215import {
1316 marshalCreateInstanceRequest ,
1417 marshalCreateSnapshotRequest ,
@@ -33,6 +36,7 @@ import type {
3336 DeleteSnapshotRequest ,
3437 GetInstanceCertificateRequest ,
3538 GetInstanceRequest ,
39+ GetSnapshotRequest ,
3640 Instance ,
3741 ListInstancesRequest ,
3842 ListInstancesResponse ,
@@ -320,6 +324,43 @@ export class API extends ParentAPI {
320324 unmarshalSnapshot ,
321325 )
322326
327+ /**
328+ * Get a Database Instance snapshot. Retrieve information about a given
329+ * snapshot of a Database Instance. You must specify, in the endpoint, the
330+ * `snapshot_id` parameter of the snapshot you want to retrieve.
331+ *
332+ * @param request - The request {@link GetSnapshotRequest}
333+ * @returns A Promise of Snapshot
334+ */
335+ getSnapshot = ( request : Readonly < GetSnapshotRequest > ) =>
336+ this . client . fetch < Snapshot > (
337+ {
338+ method : 'GET' ,
339+ path : `/mongodb/v1alpha1/regions/${ validatePathParam ( 'region' , request . region ?? this . client . settings . defaultRegion ) } /snapshots/${ validatePathParam ( 'snapshotId' , request . snapshotId ) } ` ,
340+ } ,
341+ unmarshalSnapshot ,
342+ )
343+
344+ /**
345+ * Waits for {@link Snapshot} to be in a final state.
346+ *
347+ * @param request - The request {@link GetSnapshotRequest}
348+ * @param options - The waiting options
349+ * @returns A Promise of Snapshot
350+ */
351+ waitForSnapshot = (
352+ request : Readonly < GetSnapshotRequest > ,
353+ options ?: Readonly < WaitForOptions < Snapshot > > ,
354+ ) =>
355+ waitForResource (
356+ options ?. stop ??
357+ ( res =>
358+ Promise . resolve ( ! SNAPSHOT_TRANSIENT_STATUSES . includes ( res . status ) ) ) ,
359+ this . getSnapshot ,
360+ request ,
361+ options ,
362+ )
363+
323364 updateSnapshot = ( request : Readonly < UpdateSnapshotRequest > ) =>
324365 this . client . fetch < Snapshot > (
325366 {
0 commit comments