v1.0.0
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user