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 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
}