This commit is contained in:
2026-04-03 16:26:42 +03:00
parent 9258a1574b
commit 30e464e4d2
22 changed files with 251 additions and 100 deletions

View File

@@ -3,6 +3,8 @@ package sep
import (
"context"
"net/http"
"strconv"
"strings"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
@@ -13,32 +15,66 @@ type AddPoolRequest struct {
// Required: true
SEPID uint64 `url:"sep_id" json:"sep_id" validate:"required"`
// Method Async/Sync
// Default: true
// Required: false
Sync bool `url:"sync" json:"sync"`
// Pool structure which contains fields such as "name", "usage_limit", "types", "system", "accessAccountIds", "accessResGroupIds". Added fields for other pool types: Des, Ovs - "uris" list of "ip, port".
// Dorado, Tatlin no additional fields required. Hitachi - "id", "snapshotable", "snapshot_pool_id", "minLdevId", "maxLdevId", "clone_technology". Shared - "description", "wwns", "allocate_type", "stripes", "metadata_size", "metadatatalun". Local - "description", "node_consumer", "block_disk".
// Required: true
Pool string `url:"pool" json:"pool" validate:"required"`
}
// AddPool adds pool to SEP
func (s SEP) AddPool(ctx context.Context, req AddPoolRequest) (string, error) {
type wrapperAddPoolRequest struct {
AddPoolRequest
AsyncMode bool `url:"asyncMode"`
}
// AddPool adds pool to SEP in sync mode.
// It returns result of operation and error.
func (s SEP) AddPool(ctx context.Context, req AddPoolRequest) (bool, error) {
err := validators.ValidateRequest(req)
if err != nil {
return false, validators.ValidationErrors(validators.GetErrors(err))
}
reqWrapped := wrapperAddPoolRequest{
AddPoolRequest: req,
AsyncMode: false,
}
url := "/cloudbroker/sep/addPool"
res, err := s.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
if err != nil {
return false, err
}
result, err := strconv.ParseBool(string(res))
if err != nil {
return false, err
}
return result, nil
}
// AddPoolAsync adds pool to SEP in async mode.
// It returns guid of task and error.
func (s SEP) AddPoolAsync(ctx context.Context, req AddPoolRequest) (string, error) {
err := validators.ValidateRequest(req)
if err != nil {
return "", validators.ValidationErrors(validators.GetErrors(err))
}
reqWrapped := wrapperAddPoolRequest{
AddPoolRequest: req,
AsyncMode: true,
}
url := "/cloudbroker/sep/addPool"
res, err := s.client.DecortApiCall(ctx, http.MethodPost, url, req)
res, err := s.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
if err != nil {
return "", err
}
result := string(res)
result := strings.ReplaceAll(string(res), "\"", "")
return result, nil
}