v1.0.0
This commit is contained in:
@@ -7,21 +7,41 @@ import (
|
||||
"strconv"
|
||||
)
|
||||
|
||||
// Request struct for create VINS in resource group
|
||||
type CreateInRGRequest struct {
|
||||
Name string `url:"name"`
|
||||
RGID uint64 `url:"rgId"`
|
||||
IPCidr string `url:"ipcidr,omitempty"`
|
||||
ExtNetID uint64 `url:"extNetId,omitempty"`
|
||||
ExtIP string `url:"extIp,omitempty"`
|
||||
Description string `url:"desc,omitempty"`
|
||||
PreReservationsNum uint `url:"preReservationsNum,omitempty"`
|
||||
// VINS name
|
||||
// Required: true
|
||||
Name string `url:"name"`
|
||||
|
||||
// Resource group ID
|
||||
// Required: true
|
||||
RGID uint64 `url:"rgId"`
|
||||
|
||||
// Private network IP CIDR
|
||||
// Required: false
|
||||
IPCIDR string `url:"ipcidr,omitempty"`
|
||||
|
||||
// External network ID
|
||||
// Required: false
|
||||
ExtNetID uint64 `url:"extNetId,omitempty"`
|
||||
|
||||
// External IP, related only for extNetId >= 0
|
||||
// Required: false
|
||||
ExtIP string `url:"extIp,omitempty"`
|
||||
|
||||
// Description
|
||||
// Required: false
|
||||
Description string `url:"desc,omitempty"`
|
||||
|
||||
// Number of pre created reservations
|
||||
// Required: false
|
||||
PreReservationsNum uint `url:"preReservationsNum,omitempty"`
|
||||
}
|
||||
|
||||
func (vrq CreateInRGRequest) Validate() error {
|
||||
func (vrq CreateInRGRequest) validate() error {
|
||||
if vrq.Name == "" {
|
||||
return errors.New("validation-error: field Name can not be empty")
|
||||
}
|
||||
|
||||
if vrq.RGID == 0 {
|
||||
return errors.New("validation-error: field RGID can not be empty or equal to 0")
|
||||
}
|
||||
@@ -29,8 +49,9 @@ func (vrq CreateInRGRequest) Validate() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// CreateInRG creates VINS in resource group level
|
||||
func (v VINS) CreateInRG(ctx context.Context, req CreateInRGRequest) (uint64, error) {
|
||||
err := req.Validate()
|
||||
err := req.validate()
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user