From 0b3de4df7fb840336acb968230410e72e930194b Mon Sep 17 00:00:00 2001 From: Nikita Sorokin Date: Mon, 11 Sep 2023 13:11:33 +0300 Subject: [PATCH] 1.6.0-alfa --- pkg/cloudapi/lb/create.go | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/pkg/cloudapi/lb/create.go b/pkg/cloudapi/lb/create.go index e437882..04d81ed 100644 --- a/pkg/cloudapi/lb/create.go +++ b/pkg/cloudapi/lb/create.go @@ -2,6 +2,7 @@ package lb import ( "context" + "errors" "net/http" "strings" @@ -20,16 +21,16 @@ type CreateRequest struct { Name string `url:"name" json:"name" validate:"required"` // External network to connect this load balancer to - // Required: true - ExtNetID uint64 `url:"extnetId" json:"extnetId" validate:"required"` + // Required: false + ExtNetID uint64 `url:"extnetId" json:"extnetId"` // Internal network (VINS) to connect this load balancer to - // Required: true - VINSID uint64 `url:"vinsId" json:"vinsId" validate:"required"` + // Required: false + VINSID uint64 `url:"vinsId" json:"vinsId"` // Start now Load balancer - // Required: true - Start bool `url:"start" json:"start" validate:"required"` + // Required: false + Start bool `url:"start" json:"start"` // Text description of this load balancer // Required: false @@ -45,6 +46,10 @@ func (l LB) Create(ctx context.Context, req CreateRequest) (string, error) { } } + if req.ExtNetID == 0 && req.VINSID == 0 { + return "", errors.New ("vinsId and extNetId cannot be both in the value 0") + } + url := "/cloudapi/lb/create" res, err := l.client.DecortApiCall(ctx, http.MethodPost, url, req)