This commit is contained in:
dayterr
2025-09-11 15:56:44 +03:00
parent 825b1a0a00
commit abd35f858c
87 changed files with 930 additions and 571 deletions

View File

@@ -0,0 +1,63 @@
package stpolicy
import (
"context"
"net/http"
"strconv"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
type AccessSEPsPool struct {
// Storage endpoint provider ID
// Required: true
SEPID uint64 `url:"sep_id" json:"sep_id" validate:"required"`
// Names of pools
// Required: true
PoolNames []string `url:"pool_names" json:"pool_names" validate:"required"`
}
type CreateRequest struct {
// Name of the storage policy
// Required: true
Name string `url:"name" json:"name" validate:"required"`
// List of storage endpoint access objects
// Required: true
AccessSEPsPools []AccessSEPsPool `url:"access_seps_pools" json:"access_seps_pools" validate:"required"`
// Description of the storage policy
// Required: false
Description string `url:"description,omitempty" json:"description,omitempty"`
// Maximum IOPS limit
// Default: 2000
// Required: false
LimitIOPS uint64 `url:"limit_iops,omitempty" json:"limit_iops,omitempty"`
}
// Create creates a new storage policy
func (sp StPolicy) Create(ctx context.Context, req CreateRequest) (uint64, error) {
err := validators.ValidateRequest(req)
if err != nil {
return 0, validators.ValidationErrors(validators.GetErrors(err))
}
url := "/cloudbroker/storage_policy/create"
res, err := sp.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
if err != nil {
return 0, err
}
result, err := strconv.ParseUint(string(res), 10, 64)
if err != nil {
return 0, err
}
return result, nil
}