v1.14.6
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
@@ -2,8 +2,8 @@ package sep
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
@@ -34,23 +34,25 @@ type ConfigFieldEditRequest struct {
|
||||
}
|
||||
|
||||
// ConfigFieldEdit edits SEP config field value
|
||||
func (s SEP) ConfigFieldEdit(ctx context.Context, req ConfigFieldEditRequest) (bool, error) {
|
||||
func (s SEP) ConfigFieldEdit(ctx context.Context, req ConfigFieldEditRequest) (*RecordConfigFieldEdit, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/sep/configFieldEdit"
|
||||
|
||||
res, err := s.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return false, err
|
||||
return nil, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseBool(string(res))
|
||||
info := RecordConfigFieldEdit{}
|
||||
|
||||
err = json.Unmarshal(res, &info)
|
||||
if err != nil {
|
||||
return false, err
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
return &info, nil
|
||||
}
|
||||
|
||||
@@ -2,8 +2,8 @@ package sep
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
@@ -25,22 +25,24 @@ type DelConsumerNodesRequest struct {
|
||||
}
|
||||
|
||||
// DelConsumerNodes excludes consumer nodes from SEP parameters
|
||||
func (s SEP) DelConsumerNodes(ctx context.Context, req DelConsumerNodesRequest) (bool, error) {
|
||||
func (s SEP) DelConsumerNodes(ctx context.Context, req DelConsumerNodesRequest) (interface{}, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/sep/delConsumerNodes"
|
||||
|
||||
res, err := s.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return false, err
|
||||
return nil, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseBool(string(res))
|
||||
var result interface{}
|
||||
|
||||
err = json.Unmarshal(res, &result)
|
||||
if err != nil {
|
||||
return false, err
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package sep
|
||||
|
||||
import "encoding/json"
|
||||
|
||||
// Total resource information
|
||||
type Total struct {
|
||||
// Capacity limit
|
||||
@@ -185,3 +187,93 @@ type ListAvailableSEP struct {
|
||||
// Data
|
||||
Data []SEPData `json:"data"`
|
||||
}
|
||||
|
||||
// Disk clean settings
|
||||
type DiskCleanSettings struct {
|
||||
// Block size
|
||||
BlockSize string `json:"blocksize"`
|
||||
|
||||
// Write bytes per second
|
||||
WBPS uint64 `json:"wbps"`
|
||||
|
||||
// Write I/O operations per second
|
||||
WIOPS uint64 `json:"wiops"`
|
||||
}
|
||||
|
||||
// Pool configuration
|
||||
type PoolConfig struct {
|
||||
// Disk clean
|
||||
DiskClean *string `json:"disk_clean"`
|
||||
|
||||
// Disk clean settings
|
||||
DiskCleanSettings DiskCleanSettings `json:"disk_clean_settings"`
|
||||
|
||||
// Pool name
|
||||
Name string `json:"name"`
|
||||
|
||||
// Usage limit
|
||||
UsageLimit uint64 `json:"usage_limit"`
|
||||
|
||||
// Additional properties
|
||||
AdditionalProperties map[string]interface{} `json:"-"`
|
||||
}
|
||||
|
||||
func (p *PoolConfig) UnmarshalJSON(data []byte) error {
|
||||
type tmpAlias PoolConfig
|
||||
if err := json.Unmarshal(data, (*tmpAlias)(p)); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
all := make(map[string]interface{})
|
||||
if err := json.Unmarshal(data, &all); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
delete(all, "disk_clean")
|
||||
delete(all, "disk_clean_settings")
|
||||
delete(all, "name")
|
||||
delete(all, "usage_limit")
|
||||
|
||||
if len(all) > 0 {
|
||||
p.AdditionalProperties = all
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Sep configuration information
|
||||
type RecordConfigFieldEdit struct {
|
||||
// Format
|
||||
Format string `json:"format"`
|
||||
|
||||
// Pools
|
||||
Pools []PoolConfig `json:"pools"`
|
||||
|
||||
// Protocol
|
||||
Protocol string `json:"protocol"`
|
||||
|
||||
// Additional properties
|
||||
AdditionalProperties map[string]interface{} `json:"-"`
|
||||
}
|
||||
|
||||
func (r *RecordConfigFieldEdit) UnmarshalJSON(data []byte) error {
|
||||
type tmpAlias RecordConfigFieldEdit
|
||||
if err := json.Unmarshal(data, (*tmpAlias)(r)); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
all := make(map[string]interface{})
|
||||
if err := json.Unmarshal(data, &all); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
delete(all, "format")
|
||||
delete(all, "pools")
|
||||
delete(all, "protocol")
|
||||
|
||||
if len(all) > 0 {
|
||||
r.AdditionalProperties = all
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user