v1.0.0
This commit is contained in:
@@ -7,21 +7,30 @@ import (
|
||||
"strconv"
|
||||
)
|
||||
|
||||
// Request struct for create frontend
|
||||
type FrontendCreateRequest struct {
|
||||
LBID uint64 `url:"lbId"`
|
||||
// ID of the load balancer instance to FrontendCreate
|
||||
// Required: true
|
||||
LBID uint64 `url:"lbId"`
|
||||
|
||||
// Must be unique among all frontends of
|
||||
// this load balancer - name of the new frontend to create
|
||||
// Required: true
|
||||
FrontendName string `url:"frontendName"`
|
||||
BackendName string `url:"backendName"`
|
||||
|
||||
// Should be one of the backends existing on
|
||||
// this load balancer - name of the backend to use
|
||||
// Required: true
|
||||
BackendName string `url:"backendName"`
|
||||
}
|
||||
|
||||
func (lbrq FrontendCreateRequest) Validate() error {
|
||||
func (lbrq FrontendCreateRequest) validate() error {
|
||||
if lbrq.LBID == 0 {
|
||||
return errors.New("validation-error: field LBID can not be empty or equal to 0")
|
||||
}
|
||||
|
||||
if lbrq.FrontendName == "" {
|
||||
return errors.New("validation-error: field FrontendName can not be empty")
|
||||
}
|
||||
|
||||
if lbrq.BackendName == "" {
|
||||
return errors.New("validation-error: field BackendName can not be empty")
|
||||
}
|
||||
@@ -29,8 +38,9 @@ func (lbrq FrontendCreateRequest) Validate() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// FrontendCreate creates new frontend on the specified load balancer
|
||||
func (l LB) FrontendCreate(ctx context.Context, req FrontendCreateRequest) (bool, error) {
|
||||
err := req.Validate()
|
||||
err := req.validate()
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user