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,20 +7,37 @@ import (
"strconv"
)
// Request struct for create VINS in account
type CreateInAccountRequest struct {
Name string `url:"name"`
AccountID uint64 `url:"accountId"`
GID uint64 `url:"gid,omitempty"`
IPCidr string `url:"ipcidr,omitempty"`
Description string `url:"desc,omitempty"`
PreReservationsNum uint `url:"preReservationsNum,omitempty"`
// VINS name
// Required: true
Name string `url:"name"`
// ID of account
// Required: true
AccountID uint64 `url:"accountId"`
// Grid ID
// Required: false
GID uint64 `url:"gid,omitempty"`
// Private network IP CIDR
// Required: false
IPCIDR string `url:"ipcidr,omitempty"`
// Description
// Required: false
Description string `url:"desc,omitempty"`
// Number of pre created reservations
// Required: false
PreReservationsNum uint64 `url:"preReservationsNum,omitempty"`
}
func (vrq CreateInAccountRequest) Validate() error {
func (vrq CreateInAccountRequest) validate() error {
if vrq.Name == "" {
return errors.New("validation-error: field Name can not be empty")
}
if vrq.AccountID == 0 {
return errors.New("validation-error: field AccountID can not be empty or equal to 0")
}
@@ -28,8 +45,9 @@ func (vrq CreateInAccountRequest) Validate() error {
return nil
}
// CreateInAccount creates VINS in account level
func (v VINS) CreateInAccount(ctx context.Context, req CreateInAccountRequest) (uint64, error) {
err := req.Validate()
err := req.validate()
if err != nil {
return 0, err
}