v1.16.4
This commit is contained in:
dayterr
2026-09-18 16:49:20 +03:00
parent b39021820a
commit bf932e5ef9
161 changed files with 2375 additions and 227 deletions

View File

@@ -2,6 +2,7 @@ package compute
import (
"context"
"encoding/json"
"net/http"
"strconv"
@@ -40,6 +41,17 @@ type AffinityRuleAddRequest struct {
// Value that must match the key to be taken into account when analyzing this rule
// Required: true
Value string `url:"value" json:"value" validate:"required"`
// Migrate compute according to the rule
// Default: false
// Required: false
Migrate bool `url:"migrate" json:"migrate"`
}
type wrapperAffinityRuleAddRequest struct {
AffinityRuleAddRequest
AsyncMode bool `url:"async_mode"`
}
// AffinityRuleAdd add affinity rule
@@ -51,7 +63,12 @@ func (c Compute) AffinityRuleAdd(ctx context.Context, req AffinityRuleAddRequest
url := "/cloudapi/compute/affinityRuleAdd"
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
aReq := wrapperAffinityRuleAddRequest{
AffinityRuleAddRequest: req,
AsyncMode: false,
}
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, aReq)
if err != nil {
return false, err
}
@@ -63,3 +80,32 @@ func (c Compute) AffinityRuleAdd(ctx context.Context, req AffinityRuleAddRequest
return result, nil
}
// AsyncAffinityRuleAdd add affinity rule in async mode
func (c Compute) AsyncAffinityRuleAdd(ctx context.Context, req AffinityRuleAddRequest) (string, error) {
err := validators.ValidateRequest(req)
if err != nil {
return "", validators.ValidationErrors(validators.GetErrors(err))
}
url := "/cloudapi/compute/affinityRuleAdd"
aReq := wrapperAffinityRuleAddRequest{
AffinityRuleAddRequest: req,
AsyncMode: true,
}
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, aReq)
if err != nil {
return "", err
}
var resp string
err = json.Unmarshal(res, &resp)
if err != nil {
return "", err
}
return resp, nil
}