v1.0.0
This commit is contained in:
@@ -7,17 +7,25 @@ import (
|
||||
"strconv"
|
||||
)
|
||||
|
||||
// Request struct for detach and delete disk from compute
|
||||
type DiskDelRequest struct {
|
||||
ComputeID uint64 `url:"computeId"`
|
||||
DiskID uint64 `url:"diskId"`
|
||||
Permanently bool `url:"permanently"`
|
||||
// ID of compute instance
|
||||
// Required: true
|
||||
ComputeID uint64 `url:"computeId"`
|
||||
|
||||
// ID of disk instance
|
||||
// Required: true
|
||||
DiskID uint64 `url:"diskId"`
|
||||
|
||||
// False if disk is to be deleted to recycle bin
|
||||
// Required: true
|
||||
Permanently bool `url:"permanently"`
|
||||
}
|
||||
|
||||
func (crq DiskDelRequest) Validate() error {
|
||||
func (crq DiskDelRequest) validate() error {
|
||||
if crq.ComputeID == 0 {
|
||||
return errors.New("validation-error: field ComputeID can not be empty or equal to 0")
|
||||
}
|
||||
|
||||
if crq.DiskID == 0 {
|
||||
return errors.New("validation-error: field DiskID can not be empty or equal to 0")
|
||||
}
|
||||
@@ -25,8 +33,9 @@ func (crq DiskDelRequest) Validate() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// DiskDel delete disk and detach from compute
|
||||
func (c Compute) DiskDel(ctx context.Context, req DiskDelRequest) (bool, error) {
|
||||
err := req.Validate()
|
||||
err := req.validate()
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user