package storagepolicy 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 []AccessSepPool `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 StoragePolicy) 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 }