You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
decort-golang-sdk/pkg/cloudbroker/sep/create.go

67 lines
1.5 KiB

package sep
import (
"context"
"net/http"
"strconv"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
// CreateRequest struct to create SEP object
type CreateRequest struct {
// Grid ID
// Required: true
GID uint64 `url:"gid" json:"gid" validate:"required"`
// SEP name
// Required: true
Name string `url:"name" json:"name" validate:"required"`
// Type of storage
// Required: true
SEPType string `url:"sep_type" json:"sep_type" validate:"required"`
// Description
// Required: false
Description string `url:"description,omitempty" json:"description,omitempty"`
// SEP config
// Required: false
Config string `url:"config,omitempty" json:"config,omitempty"`
// List of provider node IDs
// Required: false
ProviderNIDs []uint64 `url:"provider_nids,omitempty" json:"provider_nids,omitempty"`
// List of consumer node IDs
// Required: false
ConsumerNIDs []uint64 `url:"consumer_nids,omitempty" json:"consumer_nids,omitempty"`
// Enable SEP after creation
// Required: false
Enable bool `url:"enable,omitempty" json:"enable,omitempty"`
}
// Create creates SEP object
func (s SEP) Create(ctx context.Context, req CreateRequest) (uint64, error) {
err := validators.ValidateRequest(req)
if err != nil {
return 0, validators.ValidationErrors(validators.GetErrors(err))
}
url := "/cloudbroker/sep/create"
res, err := s.client.DecortApiCall(ctx, http.MethodPost, url, req)
if err != nil {
return 0, err
}
result, err := strconv.ParseUint(string(res), 10, 64)
if err != nil {
return 0, err
}
return result, nil
}