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.
50 lines
1.2 KiB
50 lines
1.2 KiB
package resmon
|
|
|
|
import (
|
|
"context"
|
|
"encoding/json"
|
|
"net/http"
|
|
|
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
|
)
|
|
|
|
type GetByComputesRequest struct {
|
|
// 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 compute instances resource monitoring for the specified time period
|
|
func (r Resmon) GetByComputes(ctx context.Context, req GetByComputesRequest) (*GetByComputeData, error) {
|
|
res, err := r.GetByComputesRaw(ctx, req)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
info := GetByComputeData{}
|
|
|
|
err = json.Unmarshal(res, &info)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return &info, nil
|
|
}
|
|
|
|
// GetRaw gets information about compute as an array of bytes
|
|
func (r Resmon) GetByComputesRaw(ctx context.Context, req GetByComputesRequest) ([]byte, error) {
|
|
err := validators.ValidateRequest(req)
|
|
if err != nil {
|
|
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
|
}
|
|
|
|
url := "/cloudbroker/resmon/getByComputes"
|
|
|
|
res, err := r.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
|
return res, err
|
|
}
|