v1.3.0
This commit is contained in:
@@ -2,45 +2,34 @@ package lb
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// Request struct for delete bind
|
||||
type FrontendBindDeleteRequest struct {
|
||||
// ID of the load balancer instance to FrontendBindDelete
|
||||
// Required: true
|
||||
LBID uint64 `url:"lbId" json:"lbId"`
|
||||
LBID uint64 `url:"lbId" json:"lbId" validate:"required"`
|
||||
|
||||
// Name of the frontend to delete
|
||||
// Required: true
|
||||
FrontendName string `url:"frontendName" json:"frontendName"`
|
||||
FrontendName string `url:"frontendName" json:"frontendName" validate:"required"`
|
||||
|
||||
// Name of the binding to delete
|
||||
// Required: true
|
||||
BindingName string `url:"bindingName" json:"bindingName"`
|
||||
}
|
||||
|
||||
func (lbrq FrontendBindDeleteRequest) 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.BindingName == "" {
|
||||
return errors.New("validation-error: field BindingName can not be empty")
|
||||
}
|
||||
|
||||
return nil
|
||||
BindingName string `url:"bindingName" json:"bindingName" validate:"required"`
|
||||
}
|
||||
|
||||
// FrontendBindDelete deletes binding from the specified load balancer frontend
|
||||
func (l LB) FrontendBindDelete(ctx context.Context, req FrontendBindDeleteRequest) (string, error) {
|
||||
err := req.validate()
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return "", err
|
||||
for _, validationError := range validators.GetErrors(err) {
|
||||
return "", validators.ValidationError(validationError)
|
||||
}
|
||||
}
|
||||
|
||||
url := "/cloudapi/lb/frontendBindDelete"
|
||||
|
||||
Reference in New Issue
Block a user