This commit is contained in:
2023-03-24 17:09:30 +03:00
parent 437841c8dd
commit 84b64b7d80
433 changed files with 4246 additions and 6516 deletions

View File

@@ -2,20 +2,21 @@ package vins
import (
"context"
"errors"
"net/http"
"strconv"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
// Request struct for create VINS in resource group
type CreateInRGRequest struct {
// VINS name
// Required: true
Name string `url:"name" json:"name"`
Name string `url:"name" json:"name" validate:"required"`
// Resource group ID
// Required: true
RGID uint64 `url:"rgId" json:"rgId"`
RGID uint64 `url:"rgId" json:"rgId" validate:"required"`
// Private network IP CIDR
// Required: false
@@ -42,22 +43,13 @@ type CreateInRGRequest struct {
Reason string `url:"reason,omitempty" json:"reason,omitempty"`
}
func (vrq CreateInRGRequest) validate() error {
if vrq.Name == "" {
return errors.New("validation-error: field Name must be set")
}
if vrq.RGID == 0 {
return errors.New("validation-error: field RGID must be set")
}
return nil
}
// CreateInRG creates VINS in resource group level
func (v VINS) CreateInRG(ctx context.Context, req CreateInRGRequest) (uint64, error) {
err := req.validate()
err := validators.ValidateRequest(req)
if err != nil {
return 0, err
for _, validationError := range validators.GetErrors(err) {
return 0, validators.ValidationError(validationError)
}
}
url := "/cloudbroker/vins/createInRG"