Files
dynamix-golang-sdk/pkg/cloudbroker/sep/consumption.go

41 lines
885 B
Go
Raw Normal View History

2025-09-23 14:34:24 +03:00
package sep
import (
"context"
"encoding/json"
"net/http"
2026-06-05 17:30:36 +03:00
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v15/internal/validators"
2025-09-23 14:34:24 +03:00
)
// ConsumptionRequest struct to get consumption info
type ConsumptionRequest struct {
// Storage endpoint provider ID
2026-06-19 16:49:23 +03:00
// Required: false
SEPID uint64 `url:"sep_id,omitempty" json:"sep_id,omitempty"`
2025-09-23 14:34:24 +03:00
}
// Consumption gets SEP consumption info
2026-06-19 16:49:23 +03:00
func (s SEP) Consumption(ctx context.Context, req ConsumptionRequest) (*ListConsumption, error) {
2025-09-23 14:34:24 +03:00
err := validators.ValidateRequest(req)
if err != nil {
return nil, validators.ValidationErrors(validators.GetErrors(err))
}
url := "/cloudbroker/sep/consumption"
res, err := s.client.DecortApiCall(ctx, http.MethodPost, url, req)
if err != nil {
return nil, err
}
2026-06-19 16:49:23 +03:00
info := ListConsumption{}
2025-09-23 14:34:24 +03:00
err = json.Unmarshal(res, &info)
if err != nil {
return nil, err
}
return &info, nil
}