Files
decort-golang-sdk/pkg/cloudbroker/rg/affinity_group_computes.go

44 lines
1.1 KiB
Go
Raw Normal View History

package rg
import (
"context"
"encoding/json"
"net/http"
2023-03-24 17:09:30 +03:00
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
2023-10-25 17:37:18 +03:00
// AffinityGroupComputesRequest struct to get list of all computes with their relationships
type AffinityGroupComputesRequest struct {
2022-12-22 17:56:47 +03:00
// Resource group ID
// Required: true
2023-03-24 17:09:30 +03:00
RGID uint64 `url:"rgId" json:"rgId" validate:"required"`
2022-12-22 17:56:47 +03:00
// Affinity group label
// Required: true
2023-03-24 17:09:30 +03:00
AffinityGroup string `url:"affinityGroup" json:"affinityGroup" validate:"required"`
}
2022-12-22 17:56:47 +03:00
// AffinityGroupComputes gets list of all computes with their relationships to another computes
func (r RG) AffinityGroupComputes(ctx context.Context, req AffinityGroupComputesRequest) (ListAffinityGroupCompute, 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 nil, validators.ValidationErrors(validators.GetErrors(err))
}
url := "/cloudbroker/rg/affinityGroupComputes"
2022-12-22 17:56:47 +03:00
res, err := r.client.DecortApiCall(ctx, http.MethodPost, url, req)
if err != nil {
return nil, err
}
2022-12-22 17:56:47 +03:00
list := ListAffinityGroupCompute{}
2022-12-22 17:56:47 +03:00
if err := json.Unmarshal(res, &list); err != nil {
return nil, err
}
2022-12-22 17:56:47 +03:00
return list, nil
}