v1.15.0
This commit is contained in:
@@ -17,6 +17,16 @@ type SnapshotRollbackRequest struct {
|
||||
// Text label of snapshot to rollback
|
||||
// Required: true
|
||||
Label string `url:"label" json:"label" validate:"required"`
|
||||
|
||||
// Rollback with memory dump restore
|
||||
// Required: false
|
||||
// Default: true
|
||||
WithMemory interface{} `url:"with_memory,omitempty" json:"with_memory,omitempty" validate:"omitempty,isBool"`
|
||||
}
|
||||
|
||||
type wrapperSnapshotRollbackRequest struct {
|
||||
SnapshotRollbackRequest
|
||||
AsyncMode bool `url:"asyncMode"`
|
||||
}
|
||||
|
||||
// SnapshotRollback rollbacks specified compute snapshot
|
||||
@@ -26,9 +36,14 @@ func (c Compute) SnapshotRollback(ctx context.Context, req SnapshotRollbackReque
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
reqWrapped := wrapperSnapshotRollbackRequest{
|
||||
SnapshotRollbackRequest: req,
|
||||
AsyncMode: false,
|
||||
}
|
||||
|
||||
url := "/cloudapi/compute/snapshotRollback"
|
||||
|
||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
@@ -40,3 +55,25 @@ func (c Compute) SnapshotRollback(ctx context.Context, req SnapshotRollbackReque
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// SnapshotRollbackAsync rollbacks specified compute snapshot in async mode
|
||||
func (c Compute) SnapshotRollbackAsync(ctx context.Context, req SnapshotRollbackRequest) (string, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
reqWrapped := wrapperSnapshotRollbackRequest{
|
||||
SnapshotRollbackRequest: req,
|
||||
AsyncMode: true,
|
||||
}
|
||||
|
||||
url := "/cloudapi/compute/snapshotRollback"
|
||||
|
||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return string(res), nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user