You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
decort-golang-sdk/pkg/cloudbroker/rg/affinity_groups_get.go

45 lines
1.0 KiB

package rg
import (
"context"
"encoding/json"
"net/http"
3 years ago
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
2 years ago
// AffinityGroupsGetRequest struct to get list of computes from affinity group
type AffinityGroupsGetRequest struct {
3 years ago
// Resource group ID
// Required: true
3 years ago
RGID uint64 `url:"rgId" json:"rgId" validate:"required"`
3 years ago
// Label affinity group
// Required: true
3 years ago
AffinityGroup string `url:"affinityGroup" json:"affinityGroup" validate:"required"`
}
2 years ago
// AffinityGroupsGet gets list of computes in the specified affinity group
func (r RG) AffinityGroupsGet(ctx context.Context, req AffinityGroupsGetRequest) ([]uint64, error) {
3 years ago
err := validators.ValidateRequest(req)
3 years ago
if err != nil {
2 years ago
return nil, validators.ValidationErrors(validators.GetErrors(err))
}
url := "/cloudbroker/rg/affinityGroupsGet"
3 years ago
res, err := r.client.DecortApiCall(ctx, http.MethodPost, url, req)
if err != nil {
return nil, err
}
3 years ago
list := make([]uint64, 0)
3 years ago
err = json.Unmarshal(res, &list)
if err != nil {
return nil, err
}
3 years ago
return list, nil
}