Files
decort-golang-sdk/pkg/cloudbroker/compute/affinity_rule_remove.go

66 lines
1.7 KiB
Go
Raw Normal View History

2022-12-22 17:56:47 +03:00
package compute
import (
"context"
"net/http"
"strconv"
2023-03-17 12:54:34 +03:00
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
2022-12-22 17:56:47 +03:00
)
2023-10-25 17:37:18 +03:00
// AffinityRuleRemoveRequest struct to remove affinity rule
2022-12-22 17:56:47 +03:00
type AffinityRuleRemoveRequest struct {
// IDs of the compute instances
// Required: true
2023-03-24 17:09:30 +03:00
ComputeIDs []uint64 `url:"computeIds" json:"computeIds" validate:"min=1"`
2022-12-22 17:56:47 +03:00
// Compute or node, for whom rule applies
// Required: true
2023-03-24 17:09:30 +03:00
Topology string `url:"topology" json:"topology" validate:"computeTopology"`
2022-12-22 17:56:47 +03:00
// The degree of 'strictness' of this rule
// Should be one of:
// - RECOMMENDED
// - REQUIRED
// Required: true
2023-03-24 17:09:30 +03:00
Policy string `url:"policy" json:"policy" validate:"computePolicy"`
2022-12-22 17:56:47 +03:00
// The comparison mode is 'value', recorded by the specified 'key'
// Should be one of:
// - EQ
// - EN
// - ANY
// Required: true
2023-03-24 17:09:30 +03:00
Mode string `url:"mode" json:"mode" validate:"computeMode"`
2022-12-22 17:56:47 +03:00
// Key that are taken into account when analyzing this rule will be identified
// Required: true
2023-03-24 17:09:30 +03:00
Key string `url:"key" json:"key" validate:"required"`
2022-12-22 17:56:47 +03:00
// Value that must match the key to be taken into account when analyzing this rule
2025-12-23 17:39:58 +03:00
// Required: true
Value string `url:"value" json:"value" validate:"required"`
2022-12-22 17:56:47 +03:00
}
// AffinityRuleRemove remove affinity rule
func (c Compute) AffinityRuleRemove(ctx context.Context, req AffinityRuleRemoveRequest) (bool, error) {
2023-03-24 17:09:30 +03:00
err := validators.ValidateRequest(req)
2022-12-22 17:56:47 +03:00
if err != nil {
2023-10-25 17:37:18 +03:00
return false, validators.ValidationErrors(validators.GetErrors(err))
2022-12-22 17:56:47 +03:00
}
url := "/cloudbroker/compute/affinityRuleRemove"
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
if err != nil {
return false, err
}
result, err := strconv.ParseBool(string(res))
if err != nil {
return false, err
}
return result, nil
}