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/get_resource_consumption.go

41 lines
1008 B

package rg
import (
"context"
"encoding/json"
"net/http"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
// GetResourceConsumptionRequest struct to get detailed information about resource consumption for ResGroup
type GetResourceConsumptionRequest struct {
// Resource group ID
// Required: true
RGID uint64 `url:"rgId" json:"rgId" validate:"required"`
}
// GetResourceConsumption gets resource consumption of the resource group
func (r RG) GetResourceConsumption(ctx context.Context, req GetResourceConsumptionRequest) (*ItemResourceConsumption, error) {
err := validators.ValidateRequest(req)
if err != nil {
return nil, validators.ValidationErrors(validators.GetErrors(err))
}
url := "/cloudbroker/rg/getResourceConsumption"
res, err := r.client.DecortApiCall(ctx, http.MethodPost, url, req)
if err != nil {
return nil, err
}
info := ItemResourceConsumption{}
err = json.Unmarshal(res, &info)
if err != nil {
return nil, err
}
return &info, nil
}