v1.16.5
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
@@ -51,14 +52,14 @@ type AffinityRuleAddRequest struct {
|
||||
type wrapperAffinityRuleAddRequest struct {
|
||||
AffinityRuleAddRequest
|
||||
|
||||
AsyncMode bool `url:"async_mode"`
|
||||
AsyncMode bool `url:"async_mode" json:"async_mode"`
|
||||
}
|
||||
|
||||
// AffinityRuleAdd add affinity rule
|
||||
func (c Compute) AffinityRuleAdd(ctx context.Context, req AffinityRuleAddRequest) (bool, error) {
|
||||
func (c Compute) AffinityRuleAdd(ctx context.Context, req AffinityRuleAddRequest) (AffinityRuleAddResult, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
return AffinityRuleAddResult{}, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudapi/compute/affinityRuleAdd"
|
||||
@@ -68,17 +69,24 @@ func (c Compute) AffinityRuleAdd(ctx context.Context, req AffinityRuleAddRequest
|
||||
AsyncMode: false,
|
||||
}
|
||||
|
||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, aReq)
|
||||
res, err := c.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, aReq)
|
||||
if err != nil {
|
||||
return false, err
|
||||
return AffinityRuleAddResult{}, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseBool(string(res))
|
||||
if err != nil {
|
||||
return false, err
|
||||
if !req.Migrate {
|
||||
result, err := strconv.ParseBool(string(res))
|
||||
return AffinityRuleAddResult{Ok: result}, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
var report MigrationReport
|
||||
|
||||
err = json.Unmarshal(res, &report)
|
||||
if err != nil {
|
||||
return AffinityRuleAddResult{}, err
|
||||
}
|
||||
|
||||
return AffinityRuleAddResult{Ok: report.Applied, MigrationReport: &report}, nil
|
||||
}
|
||||
|
||||
// AsyncAffinityRuleAdd add affinity rule in async mode
|
||||
@@ -95,7 +103,7 @@ func (c Compute) AsyncAffinityRuleAdd(ctx context.Context, req AffinityRuleAddRe
|
||||
AsyncMode: true,
|
||||
}
|
||||
|
||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, aReq)
|
||||
res, err := c.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, aReq)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user