v1.0.0
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user