@@ -31,6 +31,9 @@ type CloudProviderSnapshotRestoreJobsService interface {
3131 Get (context.Context , * SnapshotReqPathParameters ) (* CloudProviderSnapshotRestoreJob , * Response , error )
3232 Create (context.Context , * SnapshotReqPathParameters , * CloudProviderSnapshotRestoreJob ) (* CloudProviderSnapshotRestoreJob , * Response , error )
3333 Delete (context.Context , * SnapshotReqPathParameters ) (* Response , error )
34+ ListForServerlessBackupRestore (context.Context , string , string , * ListOptions ) (* CloudProviderSnapshotRestoreJobs , * Response , error )
35+ GetForServerlessBackupRestore (context.Context , string , string , string ) (* CloudProviderSnapshotRestoreJob , * Response , error )
36+ CreateForServerlessBackupRestore (context.Context , string , string , * CloudProviderSnapshotRestoreJob ) (* CloudProviderSnapshotRestoreJob , * Response , error )
3437}
3538
3639// CloudProviderSnapshotRestoreJobsServiceOp handles communication with the CloudProviderSnapshotRestoreJobs related methods of the
@@ -58,6 +61,8 @@ type CloudProviderSnapshotRestoreJob struct {
5861 OplogTs int64 `json:"oplogTs,omitempty"` //nolint:stylecheck // not changing this // Timestamp in the number of seconds that have elapsed since the UNIX epoch from which to you want to restore this snapshot. This is the first part of an Oplog timestamp.
5962 OplogInc int64 `json:"oplogInc,omitempty"` // Oplog operation number from which to you want to restore this snapshot. This is the second part of an Oplog timestamp.
6063 PointInTimeUTCSeconds int64 `json:"pointInTimeUTCSeconds,omitempty"` // Timestamp in the number of seconds that have elapsed since the UNIX epoch from which you want to restore this snapshot.
64+ SourceClusterName string `json:"sourceClusterName,omitempty"`
65+ Failed * bool `json:"failed,omitempty"`
6166}
6267
6368// CloudProviderSnapshotRestoreJobs represents an array of cloudProviderSnapshotRestoreJob.
@@ -202,3 +207,104 @@ func (s *CloudProviderSnapshotRestoreJobsServiceOp) Delete(ctx context.Context,
202207
203208 return resp , err
204209}
210+
211+ // ListForServerlessBackupRestore gets all cloud provider snapshot serverless restore jobs for the specified cluster.
212+ //
213+ // See more: https://docs.atlas.mongodb.com/reference/api/cloud-backup/restore/return-all-restore-jobs-for-one-serverless-instance/
214+ func (s * CloudProviderSnapshotRestoreJobsServiceOp ) ListForServerlessBackupRestore (ctx context.Context , projectID , instanceName string , listOptions * ListOptions ) (* CloudProviderSnapshotRestoreJobs , * Response , error ) {
215+ if projectID == "" {
216+ return nil , nil , NewArgError ("projectID" , "must be set" )
217+ }
218+ if instanceName == "" {
219+ return nil , nil , NewArgError ("instanceName" , "must be set" )
220+ }
221+
222+ path := fmt .Sprintf ("%s/%s/serverless/%s/backup/restoreJobs" , cloudProviderSnapshotsBasePath , projectID , instanceName )
223+ path , err := setListOptions (path , listOptions )
224+ if err != nil {
225+ return nil , nil , err
226+ }
227+
228+ req , err := s .Client .NewRequest (ctx , http .MethodGet , path , nil )
229+ if err != nil {
230+ return nil , nil , err
231+ }
232+
233+ root := new (CloudProviderSnapshotRestoreJobs )
234+ resp , err := s .Client .Do (ctx , req , root )
235+ if err != nil {
236+ return nil , resp , err
237+ }
238+
239+ if l := root .Links ; l != nil {
240+ resp .Links = l
241+ }
242+
243+ return root , resp , nil
244+ }
245+
246+ // GetForServerlessBackupRestore gets one cloud provider serverless snapshot restore jobs for the specified cluster.
247+ //
248+ // See more: https://docs.atlas.mongodb.com/reference/api/cloud-backup/restore/return-one-restore-job-for-one-serverless-instance/
249+ func (s * CloudProviderSnapshotRestoreJobsServiceOp ) GetForServerlessBackupRestore (ctx context.Context , projectID , instanceName , jobID string ) (* CloudProviderSnapshotRestoreJob , * Response , error ) {
250+ if projectID == "" {
251+ return nil , nil , NewArgError ("projectID" , "must be set" )
252+ }
253+ if instanceName == "" {
254+ return nil , nil , NewArgError ("instanceName" , "must be set" )
255+ }
256+ if jobID == "" {
257+ return nil , nil , NewArgError ("jobID" , "must be set" )
258+ }
259+
260+ path := fmt .Sprintf ("%s/%s/serverless/%s/backup/restoreJobs/%s" , cloudProviderSnapshotsBasePath , projectID , instanceName , jobID )
261+
262+ req , err := s .Client .NewRequest (ctx , http .MethodGet , path , nil )
263+ if err != nil {
264+ return nil , nil , err
265+ }
266+
267+ root := new (CloudProviderSnapshotRestoreJob )
268+ resp , err := s .Client .Do (ctx , req , root )
269+ if err != nil {
270+ return nil , resp , err
271+ }
272+
273+ return root , resp , err
274+ }
275+
276+ // CreateForServerlessBackupRestore creates a new restore job from a serverless cloud provider snapshot associated to the specified cluster.
277+ //
278+ // See more: https://docs.atlas.mongodb.com/reference/api/cloud-backup/restore/restore-one-snapshot-of-one-serverless-instance/
279+ func (s * CloudProviderSnapshotRestoreJobsServiceOp ) CreateForServerlessBackupRestore (ctx context.Context , projectID , instanceName string , createRequest * CloudProviderSnapshotRestoreJob ) (* CloudProviderSnapshotRestoreJob , * Response , error ) {
280+ if projectID == "" {
281+ return nil , nil , NewArgError ("projectID" , "must be set" )
282+ }
283+ if instanceName == "" {
284+ return nil , nil , NewArgError ("instanceName" , "must be set" )
285+ }
286+
287+ if createRequest .DeliveryType == "download" {
288+ createRequest .TargetClusterName = ""
289+ createRequest .TargetGroupID = ""
290+ }
291+
292+ path := fmt .Sprintf ("%s/%s/serverless/%s/backup/restoreJobs" , cloudProviderSnapshotRestoreJobBasePath , projectID , instanceName )
293+
294+ req , err := s .Client .NewRequest (ctx , http .MethodPost , path , createRequest )
295+ if err != nil {
296+ return nil , nil , err
297+ }
298+
299+ root := new (CloudProviderSnapshotRestoreJob )
300+ resp , err := s .Client .Do (ctx , req , root )
301+ if err != nil {
302+ return nil , resp , err
303+ }
304+
305+ if l := root .Links ; l != nil {
306+ resp .Links = l
307+ }
308+
309+ return root , resp , err
310+ }
0 commit comments