This commit is contained in:
stSolo
2022-12-22 17:56:47 +03:00
parent 8712561853
commit d4b1ab7133
672 changed files with 28509 additions and 4419 deletions

View File

@@ -7,16 +7,21 @@ import (
"net/http"
)
// Request struct for get list of all computes with their relationships
type AffinityGroupComputesRequest struct {
RGID uint64 `url:"rgId"`
// Resource group ID
// Required: true
RGID uint64 `url:"rgId"`
// Affinity group label
// Required: true
AffinityGroup string `url:"affinityGroup"`
}
func (rgrq AffinityGroupComputesRequest) Validate() error {
func (rgrq AffinityGroupComputesRequest) validate() error {
if rgrq.RGID == 0 {
return errors.New("field RGID can not be empty or equal to 0")
}
if rgrq.AffinityGroup == "" {
return errors.New("field AffinityGroup cat not be empty")
}
@@ -24,21 +29,26 @@ func (rgrq AffinityGroupComputesRequest) Validate() error {
return nil
}
func (r RG) AffinityGroupComputes(ctx context.Context, req AffinityGroupComputesRequest) (AffinityGroupComputeList, error) {
if err := req.Validate(); err != nil {
return nil, err
}
url := "/cloudapi/rg/affinityGroupComputes"
agcListRaw, err := r.client.DecortApiCall(ctx, http.MethodPost, url, req)
// AffinityGroupComputes gets list of all computes with their relationships to another computes
func (r RG) AffinityGroupComputes(ctx context.Context, req AffinityGroupComputesRequest) (ListAffinityGroups, error) {
err := req.validate()
if err != nil {
return nil, err
}
agcList := AffinityGroupComputeList{}
if err := json.Unmarshal(agcListRaw, &agcList); err != nil {
url := "/cloudapi/rg/affinityGroupComputes"
res, err := r.client.DecortApiCall(ctx, http.MethodPost, url, req)
if err != nil {
return nil, err
}
return agcList, nil
list := ListAffinityGroups{}
err = json.Unmarshal(res, &list)
if err != nil {
return nil, err
}
return list, nil
}