v1.0.0
This commit is contained in:
@@ -7,23 +7,36 @@ import (
|
||||
"strconv"
|
||||
)
|
||||
|
||||
// Request for delete disk
|
||||
type DeleteRequest struct {
|
||||
DiskID uint64 `url:"diskId"`
|
||||
Detach bool `url:"detach,omitempty"`
|
||||
Permanently bool `url:"permanently,omitempty"`
|
||||
Reason string `url:"reason,omitempty"`
|
||||
// ID of disk to delete
|
||||
// Required: true
|
||||
DiskID uint64 `url:"diskId"`
|
||||
|
||||
// Detach disk from machine first
|
||||
// Required: false
|
||||
Detach bool `url:"detach,omitempty"`
|
||||
|
||||
// Whether to completely delete the disk, works only with non attached disks
|
||||
// Required: false
|
||||
Permanently bool `url:"permanently,omitempty"`
|
||||
|
||||
// Reason to delete
|
||||
// Required: false
|
||||
Reason string `url:"reason,omitempty"`
|
||||
}
|
||||
|
||||
func (d DeleteRequest) Validate() error {
|
||||
|
||||
func (d DeleteRequest) validate() error {
|
||||
if d.DiskID == 0 {
|
||||
return errors.New("validation-error: field DiskID must be set")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Delete deletes disk by ID
|
||||
func (d Disks) Delete(ctx context.Context, req DeleteRequest) (bool, error) {
|
||||
err := req.Validate()
|
||||
err := req.validate()
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
@@ -39,5 +52,6 @@ func (d Disks) Delete(ctx context.Context, req DeleteRequest) (bool, error) {
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user