This commit is contained in:
stSolo
2022-12-22 17:56:47 +03:00
parent 8712561853
commit d4b1ab7133
672 changed files with 28509 additions and 4419 deletions

View File

@@ -7,17 +7,25 @@ import (
"strconv"
)
// Request struct for rollback snapshot
type SnapshotRollbackRequest struct {
DiskID uint64 `url:"diskId"`
Label string `url:"label"`
// ID of the disk
// Required: true
DiskID uint64 `url:"diskId"`
// Label of the snapshot to rollback
// Required: true
Label string `url:"label"`
// Timestamp of the snapshot to rollback
// Required: true
TimeStamp uint64 `url:"timestamp"`
}
func (drq SnapshotRollbackRequest) Validate() error {
func (drq SnapshotRollbackRequest) validate() error {
if drq.DiskID == 0 {
return errors.New("validation-error: field DiskID can not be empty or equal to 0")
}
if drq.Label == "" && drq.TimeStamp == 0 {
return errors.New("validation-error: field Label or field TimeStamp can not be empty")
}
@@ -25,8 +33,9 @@ func (drq SnapshotRollbackRequest) Validate() error {
return nil
}
// SnapshotRollback rollback an individual disk snapshot
func (d Disks) SnapshotRollback(ctx context.Context, req SnapshotRollbackRequest) (bool, error) {
err := req.Validate()
err := req.validate()
if err != nil {
return false, err
}