Files
decort-golang-sdk/pkg/cloudbroker/resmon/get_by_nodes.go

50 lines
1.2 KiB
Go
Raw Normal View History

2025-03-11 13:09:17 +03:00
package resmon
import (
"context"
"encoding/json"
"net/http"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
2025-12-08 16:16:35 +03:00
type GetByNodesRequest struct {
2025-03-11 13:09:17 +03:00
// Start of time period - unixtime
// Required: false
StartTime uint64 `url:"starttime,omitempty" json:"starttime,omitempty"`
// End of time period - unixtime
// Required: true
EndTime uint64 `url:"endtime,omitempty" json:"endtime,omitempty"`
}
// Get a grid resource monitoring for the specified time period
2025-12-08 16:16:35 +03:00
func (r Resmon) GetByNodes(ctx context.Context, req GetByNodesRequest) (*GetByNodeData, error) {
res, err := r.GetByNodesRaw(ctx, req)
2025-03-11 13:09:17 +03:00
if err != nil {
return nil, err
}
2025-12-08 16:16:35 +03:00
info := GetByNodeData{}
2025-03-11 13:09:17 +03:00
err = json.Unmarshal(res, &info)
if err != nil {
return nil, err
}
return &info, nil
}
// GetRaw gets information about compute as an array of bytes
2025-12-08 16:16:35 +03:00
func (r Resmon) GetByNodesRaw(ctx context.Context, req GetByNodesRequest) ([]byte, error) {
2025-03-11 13:09:17 +03:00
err := validators.ValidateRequest(req)
if err != nil {
return nil, validators.ValidationErrors(validators.GetErrors(err))
}
2025-12-08 16:16:35 +03:00
url := "/cloudbroker/resmon/get_by_nodes"
2025-03-11 13:09:17 +03:00
res, err := r.client.DecortApiCall(ctx, http.MethodPost, url, req)
return res, err
}