parent
3f21a89e80
commit
8a101c6fcb
@ -0,0 +1,8 @@
|
||||
package cloudapi
|
||||
|
||||
import "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/sep"
|
||||
|
||||
// Accessing the SEP method group
|
||||
func (cb *CloudAPI) SEP() *sep.SEP {
|
||||
return sep.New(cb.client)
|
||||
}
|
@ -0,0 +1,83 @@
|
||||
package sep
|
||||
|
||||
// FilterBySEPID returns ListAvailableSEP with the specified SEPID.
|
||||
func (sl ListAvailableSEP) FilterBySEPID(sepID uint64) ListAvailableSEP {
|
||||
predicate := func(sd SEPData) bool {
|
||||
return sd.SEPID == sepID
|
||||
}
|
||||
|
||||
return sl.FilterFunc(predicate)
|
||||
}
|
||||
|
||||
// FilterBySEPName returns ListAvailableSEP with the specified SEPName.
|
||||
func (sl ListAvailableSEP) FilterBySEPName(SEPName string) ListAvailableSEP {
|
||||
predicate := func(sd SEPData) bool {
|
||||
return sd.SEPName == SEPName
|
||||
}
|
||||
|
||||
return sl.FilterFunc(predicate)
|
||||
}
|
||||
|
||||
// FilterBySEPType returns ListAvailableSEP with the specified SEPType.
|
||||
func (sl ListAvailableSEP) FilterBySEPType(SEPType string) ListAvailableSEP {
|
||||
predicate := func(sd SEPData) bool {
|
||||
return sd.SEPType == SEPType
|
||||
}
|
||||
|
||||
return sl.FilterFunc(predicate)
|
||||
}
|
||||
|
||||
// FilterByPoolType returns ListAvailableSEP where at least one pool has the specified type.
|
||||
func (sl ListAvailableSEP) FilterByPoolType(poolType string) ListAvailableSEP {
|
||||
predicate := func(sd SEPData) bool {
|
||||
for _, pool := range sd.Pools {
|
||||
for _, pt := range pool.Types {
|
||||
if pt == poolType {
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
return sl.FilterFunc(predicate)
|
||||
}
|
||||
|
||||
// FilterBySystemPool returns ListAvailableSEP where at least one pool is a system pool.
|
||||
func (sl ListAvailableSEP) FilterBySystemPool(isSystem bool) ListAvailableSEP {
|
||||
predicate := func(sd SEPData) bool {
|
||||
for _, pool := range sd.Pools {
|
||||
if pool.System == isSystem {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
return sl.FilterFunc(predicate)
|
||||
}
|
||||
|
||||
// FilterFunc allows filtering ListAvailableSEP based on a user-defined predicate.
|
||||
func (sl ListAvailableSEP) FilterFunc(predicate func(SEPData) bool) ListAvailableSEP {
|
||||
var result ListAvailableSEP
|
||||
|
||||
for _, item := range sl.Data {
|
||||
if predicate(item) {
|
||||
result.Data = append(result.Data, item)
|
||||
}
|
||||
}
|
||||
|
||||
result.EntryCount = uint64(len(result.Data))
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
// FindOne returns the first found SEPData.
|
||||
// If nothing is found, returns an empty struct.
|
||||
func (sl ListAvailableSEP) FindOne() SEPData {
|
||||
if len(sl.Data) == 0 {
|
||||
return SEPData{}
|
||||
}
|
||||
|
||||
return sl.Data[0]
|
||||
}
|
@ -0,0 +1,134 @@
|
||||
package sep
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
var seps = ListAvailableSEP{
|
||||
EntryCount: 3,
|
||||
Data: []SEPData{
|
||||
{
|
||||
SEPID: 1,
|
||||
SEPName: "sep_1",
|
||||
SEPType: "TATLIN",
|
||||
Pools: []Pool{
|
||||
{
|
||||
Name: "pool_1",
|
||||
Types: []string{"DES"},
|
||||
System: false,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
SEPID: 2,
|
||||
SEPName: "sep_2",
|
||||
SEPType: "SHARED",
|
||||
Pools: []Pool{
|
||||
{
|
||||
Name: "pool_2",
|
||||
Types: []string{"DES"},
|
||||
System: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
SEPID: 3,
|
||||
SEPName: "sep_3",
|
||||
SEPType: "DES",
|
||||
Pools: []Pool{
|
||||
{
|
||||
Name: "pool_3",
|
||||
Types: []string{"DES"},
|
||||
System: false,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
func TestFilterBySEPID(t *testing.T) {
|
||||
actual := seps.FilterBySEPID(1).FindOne()
|
||||
|
||||
if actual.SEPID != 1 {
|
||||
t.Fatal("expected SEPID 1, found: ", actual.SEPID)
|
||||
}
|
||||
}
|
||||
|
||||
func TestFilterBySEPName(t *testing.T) {
|
||||
actual := seps.FilterBySEPName("sep_2").FindOne()
|
||||
|
||||
if actual.SEPName != "sep_2" {
|
||||
t.Fatal("expected SEPName 'sep_2', found: ", actual.SEPName)
|
||||
}
|
||||
}
|
||||
|
||||
func TestFilterBySEPType(t *testing.T) {
|
||||
actual := seps.FilterBySEPType("TATLIN").FindOne()
|
||||
|
||||
if actual.SEPType != "TATLIN" {
|
||||
t.Fatal("expected SEPType 'TATLIN', found: ", actual.SEPType)
|
||||
}
|
||||
}
|
||||
|
||||
func TestFilterByPoolType(t *testing.T) {
|
||||
actual := seps.FilterByPoolType("DES")
|
||||
|
||||
if len(actual.Data) != 3 {
|
||||
t.Fatal("expected 3 found, actual: ", len(actual.Data))
|
||||
}
|
||||
|
||||
for _, item := range actual.Data {
|
||||
found := false
|
||||
for _, pool := range item.Pools {
|
||||
for _, poolType := range pool.Types {
|
||||
if poolType == "DES" {
|
||||
found = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if found {
|
||||
break
|
||||
}
|
||||
}
|
||||
if !found {
|
||||
t.Fatal("expected Pool type 'DES', not found in SEP: ", item.SEPID)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestFilterBySystemPool(t *testing.T) {
|
||||
actual := seps.FilterBySystemPool(true)
|
||||
|
||||
if len(actual.Data) != 1 {
|
||||
t.Fatal("expected 1 found, actual: ", len(actual.Data))
|
||||
}
|
||||
|
||||
for _, item := range actual.Data {
|
||||
found := false
|
||||
for _, pool := range item.Pools {
|
||||
if pool.System {
|
||||
found = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if !found {
|
||||
t.Fatal("expected System pool, not found in SEP: ", item.SEPID)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestFilterFunc(t *testing.T) {
|
||||
actual := seps.FilterFunc(func(sd SEPData) bool {
|
||||
return len(sd.Pools) > 0
|
||||
})
|
||||
|
||||
if len(actual.Data) != 3 {
|
||||
t.Fatal("expected 3 found, actual: ", len(actual.Data))
|
||||
}
|
||||
|
||||
for _, item := range actual.Data {
|
||||
if len(item.Pools) == 0 {
|
||||
t.Fatal("expected Pools to contain at least 1 element, found: ", len(item.Pools))
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
package sep
|
||||
|
||||
// IDs gets array of SEPIDs from ListSEP struct
|
||||
func (ls ListAvailableSEP) IDs() []uint64 {
|
||||
res := make([]uint64, 0, len(ls.Data))
|
||||
for _, s := range ls.Data {
|
||||
res = append(res, s.SEPID)
|
||||
}
|
||||
return res
|
||||
}
|
@ -0,0 +1,52 @@
|
||||
package sep
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// ListAvailableSEPAndPoolsRequest struct to get dict with entry count and list of dict with SEPs and pools details accessible by the Account and RG
|
||||
type ListAvailableSEPAndPoolsRequest struct {
|
||||
// Account ID
|
||||
// Required: true
|
||||
AccountID uint64 `url:"account_id" json:"account_id" validate:"required"`
|
||||
|
||||
// RG ID
|
||||
// Required: false
|
||||
RGID uint64 `url:"rg_id,omitempty" json:"rg_id,omitempty"`
|
||||
}
|
||||
|
||||
// ListAvailableSEPAndPools get dict with entry count and list of dict with SEPs and pools details accessible by the Account and RG
|
||||
func (s SEP) ListAvailableSEPAndPools(ctx context.Context, req ListAvailableSEPAndPoolsRequest) (*ListAvailableSEP, error) {
|
||||
|
||||
res, err := s.ListAvailableSEPAndPoolsRaw(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
list := ListAvailableSEP{}
|
||||
|
||||
err = json.Unmarshal(res, &list)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &list, nil
|
||||
}
|
||||
|
||||
// ListRaw gets list as an array of bytes
|
||||
func (s SEP) ListAvailableSEPAndPoolsRaw(ctx context.Context, req ListAvailableSEPAndPoolsRequest) ([]byte, error) {
|
||||
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudapi/sep/listAvailableSepAndPools"
|
||||
|
||||
res, err := s.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
return res, err
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
package sep
|
||||
|
||||
type Pool struct {
|
||||
// Pool name
|
||||
Name string `json:"name"`
|
||||
|
||||
// Pool types
|
||||
Types []string `json:"types"`
|
||||
|
||||
// System
|
||||
System bool `json:"system"`
|
||||
}
|
||||
|
||||
type SEPData struct {
|
||||
// SEP ID
|
||||
SEPID uint64 `json:"sepId"`
|
||||
|
||||
// SEP name
|
||||
SEPName string `json:"sepName"`
|
||||
|
||||
// Sep type
|
||||
SEPType string `json:"sepType"`
|
||||
|
||||
// Pools
|
||||
Pools []Pool `json:"pools"`
|
||||
}
|
||||
|
||||
type ListAvailableSEP struct {
|
||||
// Entry count
|
||||
EntryCount uint64 `json:"entryCount"`
|
||||
|
||||
// Data
|
||||
Data []SEPData `json:"data"`
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
// Operator actions for handling interventions on a storage endpoint provider
|
||||
package sep
|
||||
|
||||
import (
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/interfaces"
|
||||
)
|
||||
|
||||
// Structure for creating request to storage endpoint provider
|
||||
type SEP struct {
|
||||
client interfaces.Caller
|
||||
}
|
||||
|
||||
// Builder for SEP endpoints
|
||||
func New(client interfaces.Caller) *SEP {
|
||||
return &SEP{
|
||||
client: client,
|
||||
}
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
package sep
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/serialization"
|
||||
)
|
||||
|
||||
// Serialize returns JSON-serialized []byte. Used as a wrapper over json.Marshal and json.MarshalIndent functions.
|
||||
//
|
||||
// In order to serialize with indent make sure to follow these guidelines:
|
||||
// - First argument -> prefix
|
||||
// - Second argument -> indent
|
||||
func (lsep ListAvailableSEP) Serialize(params ...string) (serialization.Serialized, error) {
|
||||
if len(lsep.Data) == 0 {
|
||||
return []byte{}, nil
|
||||
}
|
||||
|
||||
if len(params) > 1 {
|
||||
prefix := params[0]
|
||||
indent := params[1]
|
||||
|
||||
return json.MarshalIndent(lsep, prefix, indent)
|
||||
}
|
||||
|
||||
return json.Marshal(lsep)
|
||||
}
|
||||
|
||||
// Serialize returns JSON-serialized []byte. Used as a wrapper over json.Marshal and json.MarshalIndent functions.
|
||||
//
|
||||
// In order to serialize with indent make sure to follow these guidelines:
|
||||
// - First argument -> prefix
|
||||
// - Second argument -> indent
|
||||
func (rsep SEPData) Serialize(params ...string) (serialization.Serialized, error) {
|
||||
if len(params) > 1 {
|
||||
prefix := params[0]
|
||||
indent := params[1]
|
||||
|
||||
return json.MarshalIndent(rsep, prefix, indent)
|
||||
}
|
||||
|
||||
return json.Marshal(rsep)
|
||||
}
|
@ -1,48 +0,0 @@
|
||||
package apiaccess
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// ListDeletedRequest struct for getting list of all deleted apiaccess instances.
|
||||
type ListDeletedRequest struct {
|
||||
// Sort by one of supported fields, format +|-(field)
|
||||
// Required: false
|
||||
SortBy string `url:"sortBy,omitempty" json:"sortBy,omitempty" validate:"omitempty,sortBy"`
|
||||
|
||||
// Page number.
|
||||
// Required: false
|
||||
Page uint64 `url:"page,omitempty" json:"page,omitempty"`
|
||||
|
||||
// Page size.
|
||||
// Required: false
|
||||
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
||||
}
|
||||
|
||||
// ListDeleted gets list of all deleted apiaccess instances.
|
||||
func (a APIAccess) ListDeleted(ctx context.Context, req ListDeletedRequest) (*ListAPIAccess, error) {
|
||||
|
||||
if err := validators.ValidateRequest(req); err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/apiaccess/listDeleted"
|
||||
|
||||
info := ListAPIAccess{}
|
||||
|
||||
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err = json.Unmarshal(res, &info)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &info, nil
|
||||
}
|
@ -1,38 +0,0 @@
|
||||
package compute
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// MassRepairBootFSRequest struct to repair boot disk filesystem on several computes
|
||||
type MassRepairBootFSRequest struct {
|
||||
// IDs of compute instances which boot file systems will be repaired
|
||||
// Required: true
|
||||
ComputeIDs []uint64 `url:"computeIds" json:"computeIds" validate:"min=1"`
|
||||
}
|
||||
|
||||
// MassRepairBootFS repairs boot disk filesystem on several computes
|
||||
func (c Compute) MassRepairBootFS(ctx context.Context, req MassRepairBootFSRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/compute/massRepairBootFs"
|
||||
|
||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseBool(string(res))
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
@ -1,42 +0,0 @@
|
||||
package compute
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// RegistrationRequest struct to set compute registered in RT
|
||||
type RegistrationRequest struct {
|
||||
// ID of the Compute
|
||||
// Required: true
|
||||
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
|
||||
|
||||
// Unique compute registration key
|
||||
// Required: true
|
||||
RegistrationKey string `url:"registrationKey" json:"registrationKey" validate:"required"`
|
||||
}
|
||||
|
||||
// Registration sets compute registered in RT
|
||||
func (c Compute) Registration(ctx context.Context, req RegistrationRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/compute/registration"
|
||||
|
||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseBool(string(res))
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
@ -1,38 +0,0 @@
|
||||
package compute
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// RepairBootFSRequest struct to repair filesystem
|
||||
type RepairBootFSRequest struct {
|
||||
// ID of compute instance
|
||||
// Required: true
|
||||
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
|
||||
}
|
||||
|
||||
// RepairBootFS repairs compute boot disk filesystem
|
||||
func (c Compute) RepairBootFS(ctx context.Context, req RepairBootFSRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/compute/repairBootFs"
|
||||
|
||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseBool(string(res))
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
@ -0,0 +1,61 @@
|
||||
package node
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
type VFParam struct {
|
||||
// Number of VF to assign
|
||||
// Required: true
|
||||
VFNum uint64 `url:"vfNum" json:"vfNum" validate:"required"`
|
||||
|
||||
// Trust
|
||||
// Required: true
|
||||
Trust bool `url:"trust" json:"trust" validate:"required"`
|
||||
|
||||
// Enable spoof checking
|
||||
// Required: true
|
||||
SpoofChk bool `url:"spoofchk" json:"spoofchk" validate:"required"`
|
||||
}
|
||||
|
||||
// SetVFsParamsRequest struct to set params of VFs for individual NIC on node
|
||||
type SetVFsParamsRequest struct {
|
||||
// Node ID
|
||||
// Required: true
|
||||
NID uint64 `url:"nid" json:"nid" validate:"required"`
|
||||
|
||||
// PCI address or NIC name
|
||||
// Required: true
|
||||
NICID string `url:"nicId" json:"nicId" validate:"required"`
|
||||
|
||||
// Number of VF to assign
|
||||
// Required: true
|
||||
VFParams []VFParam `url:"vfParams" json:"vfParams" validate:"required"`
|
||||
}
|
||||
|
||||
// SetVFsParams sets params of VFs for individual NIC on node
|
||||
func (n Node) SetVFsParams(ctx context.Context, req SetVFsParamsRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/node/setVFsParams"
|
||||
|
||||
res, err := n.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseBool(string(res))
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
@ -0,0 +1,77 @@
|
||||
package prometheus
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
const (
|
||||
ComputeCPULoad = "computeCPUload"
|
||||
ComputeMemoryUsage = "computeMemoryUsage"
|
||||
ComputeMemoryUsable = "computeMemoryUsable"
|
||||
ComputeMemoryUnused = "computeMemoryUnused"
|
||||
ComputeMemoryUsed = "computeMemoryUsed"
|
||||
ComputeMemoryAvailable = "computeMemoryAvailable"
|
||||
ComputeReadBytes = "computeReadBytes"
|
||||
ComputeReadRequests = "computeReadRequests"
|
||||
ComputeReceiveBytes = "computeReceiveBytes"
|
||||
ComputeTransmitBytes = "computeTransmitBytes"
|
||||
ComputeTransmitPackets = "computeTransmitPackets"
|
||||
ComputeWriteBytes = "computeWriteBytes"
|
||||
ComputeWriteRequests = "computeWriteRequests"
|
||||
)
|
||||
|
||||
type ComputesRequest struct {
|
||||
// List of compute IDs to fetch metrics for
|
||||
// Required: true
|
||||
ComputeIDs []uint64 `url:"computeIds" json:"computeIds" validate:"required"`
|
||||
|
||||
// List of compute IDs to fetch metrics for
|
||||
// Required: true
|
||||
MetricIDs []string `url:"metricIds" json:"metricIds" validate:"required"`
|
||||
|
||||
// Time to loads of statistic in seconds
|
||||
// Required: false
|
||||
ForLast uint64 `url:"forLast,omitempty" json:"forLast,omitempty"`
|
||||
|
||||
// The reading interval in seconds
|
||||
// Required: true
|
||||
Step uint64 `url:"step,omitempty" json:"step,omitempty"`
|
||||
|
||||
// Number of zeros after the decimal point
|
||||
// Required: true
|
||||
DecimalPlaces uint64 `url:"decimalPlaces,omitempty" json:"decimalPlaces,omitempty"`
|
||||
}
|
||||
|
||||
// Get multiple metrics for multiple compute instances
|
||||
func (p Prometheus) Computes(ctx context.Context, req ComputesRequest) (*ComputesData, error) {
|
||||
res, err := p.ComputesRaw(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
info := ComputesData{}
|
||||
|
||||
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 (p Prometheus) ComputesRaw(ctx context.Context, req ComputesRequest) ([]byte, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/prometheus/computes"
|
||||
|
||||
res, err := p.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
return res, err
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue