This commit is contained in:
aafetisov committed 2026-09-28 13:41:59 +03:00
1 parent 2c7f0d29df
commit dca445b69a
29 files changed
+1005 -131

No files matched your search

+18 -10
View File
@@ -6,6 +6,7 @@ import (
"net/http"
"strconv"
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v16/internal/constants"
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v16/internal/validators"
)
@@ -53,14 +54,14 @@ type AffinityRuleAddRequest struct {
type wrapperAffinityRuleAddRequest struct {
AffinityRuleAddRequest
AsyncMode bool `url:"async_mode"`
AsyncMode bool `url:"async_mode" json:"async_mode"`
}
// AffinityRuleAdd adds 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 := "/cloudbroker/compute/affinityRuleAdd"
@@ -70,17 +71,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
@@ -97,7 +105,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
}