v1.3.0
This commit is contained in:
@@ -2,38 +2,30 @@ package sep
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// Request struct for add provider nodes
|
||||
type AddProviderNodesRequest struct {
|
||||
// Storage endpoint provider ID
|
||||
// Required: true
|
||||
SEPID uint64 `url:"sep_id" json:"sep_id"`
|
||||
SEPID uint64 `url:"sep_id" json:"sep_id" validate:"required"`
|
||||
|
||||
// List of node IDs
|
||||
// Required: true
|
||||
ProviderNIDs []uint64 `url:"provider_nids" json:"provider_nids"`
|
||||
}
|
||||
|
||||
func (srq AddProviderNodesRequest) validate() error {
|
||||
if srq.SEPID == 0 {
|
||||
return errors.New("validation-error: field SEPID must be set")
|
||||
}
|
||||
if len(srq.ProviderNIDs) == 0 {
|
||||
return errors.New("validation-error: field ProviderNIDs must be set")
|
||||
}
|
||||
|
||||
return nil
|
||||
ProviderNIDs []uint64 `url:"provider_nids" json:"provider_nids" validate:"min=1"`
|
||||
}
|
||||
|
||||
// AddProviderNodes add provider nodes to SEP parameters
|
||||
func (s SEP) AddProviderNodes(ctx context.Context, req AddProviderNodesRequest) (bool, error) {
|
||||
err := req.validate()
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, err
|
||||
for _, validationError := range validators.GetErrors(err) {
|
||||
return false, validators.ValidationError(validationError)
|
||||
}
|
||||
}
|
||||
|
||||
url := "/cloudbroker/sep/addProviderNodes"
|
||||
|
||||
Reference in New Issue
Block a user