v1.3.0
This commit is contained in:
@@ -2,16 +2,17 @@ package vins
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// Request struct for delete VINS
|
||||
type DeleteRequest struct {
|
||||
// VINS ID
|
||||
// Required: true
|
||||
VINSID uint64 `url:"vinsId" json:"vinsId"`
|
||||
VINSID uint64 `url:"vinsId" json:"vinsId" validate:"required"`
|
||||
|
||||
// Set to True if you want force delete non-empty VINS.
|
||||
// Primarily, VINS is considered non-empty if it has virtual machines connected to it,
|
||||
@@ -26,19 +27,13 @@ type DeleteRequest struct {
|
||||
Permanently bool `url:"permanently,omitempty" json:"permanently,omitempty"`
|
||||
}
|
||||
|
||||
func (vrq DeleteRequest) validate() error {
|
||||
if vrq.VINSID == 0 {
|
||||
return errors.New("validation-error: field VINSID can not be empty or equal to 0")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Delete deletes VINS
|
||||
func (v VINS) Delete(ctx context.Context, req DeleteRequest) (bool, error) {
|
||||
err := req.validate()
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, err
|
||||
for _, validationError := range validators.GetErrors(err) {
|
||||
return false, validators.ValidationError(validationError)
|
||||
}
|
||||
}
|
||||
|
||||
url := "/cloudapi/vins/delete"
|
||||
|
||||
Reference in New Issue
Block a user