Files
dynamix-golang-sdk/pkg/cloudbroker/resmon/get_by_node.go

54 lines
1.3 KiB
Go
Raw Normal View History

2025-09-23 14:34:24 +03:00
package resmon
import (
"context"
"encoding/json"
"net/http"
2025-12-08 16:30:08 +03:00
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v13/internal/validators"
2025-09-23 14:34:24 +03:00
)
2025-12-08 16:30:08 +03:00
type GetByNodeRequest struct {
// Node ID
2025-09-23 14:34:24 +03:00
// Required: true
2025-12-08 16:30:08 +03:00
NodeID uint64 `url:"nodeId" json:"nodeId" validate:"required"`
2025-09-23 14:34:24 +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:30:08 +03:00
func (r Resmon) GetByNode(ctx context.Context, req GetByNodeRequest) (*GetByNodeData, error) {
res, err := r.GetByNodeRaw(ctx, req)
2025-09-23 14:34:24 +03:00
if err != nil {
return nil, err
}
2025-12-08 16:30:08 +03:00
info := GetByNodeData{}
2025-09-23 14:34:24 +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:30:08 +03:00
func (r Resmon) GetByNodeRaw(ctx context.Context, req GetByNodeRequest) ([]byte, error) {
2025-09-23 14:34:24 +03:00
err := validators.ValidateRequest(req)
if err != nil {
return nil, validators.ValidationErrors(validators.GetErrors(err))
}
2025-12-08 16:30:08 +03:00
url := "/cloudbroker/resmon/get_by_node"
2025-09-23 14:34:24 +03:00
res, err := r.client.DecortApiCall(ctx, http.MethodPost, url, req)
return res, err
}