Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3f21a89e80 | ||
| cbce7f434f |
61
CHANGELOG.md
61
CHANGELOG.md
@@ -1,64 +1,13 @@
|
||||
## Version 1.10.0
|
||||
## Version 1.10.2
|
||||
|
||||
### Добавлено
|
||||
|
||||
#### compute
|
||||
#### prometheus
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-204 | Вычисляемое поле `VNCPassword` в моделях `RecordCompute` в cloudapi/compute и cloudbroker/compute |
|
||||
| BGOS-204 | Опциональное поле `CDImageID` в структуре `ListRequest` в cloudbroker/compute |
|
||||
| BGOS-211 | Вычисляемое поле `AutoStart` в моделях `RecordCompute, ItemCompute, InfoCompute` в cloudapi/compute и cloudbroker/compute |
|
||||
| BGOS-211 | Опциональное поле `AutoStart` в структурах `PinToStackRequest, UpdateRequest` в cloudapi/compute и cloudbroker/compute |
|
||||
| BGOS-335 | Группа ручек cloudbroker/prometheus |
|
||||
|
||||
#### extnet
|
||||
#### resmon
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-204 | Вычисляемое поле `AccountID` в модели `ItemReservation` в cloudapi/extnet и cloudbroker/extnet |
|
||||
| BGOS-205 | Методы API `cloudbroker/extnet/addReservedIp, cloudbroker/extnet/getReservedIp, cloudapi/extnet/getReservedIp, cloudbroker/extnet/delReservedIp` в cloudapi/extnet и cloudbroker/extnet |
|
||||
|
||||
#### image
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-214 | Вычисляемое поле `SnapshotID` в модели `RecordImage, ItemImage` в cloudbroker/image |
|
||||
|
||||
#### node
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-204 | Обязательное поле `Spoofchk` в структуре `SetVFsNumberRequest` в cloudbroker/node |
|
||||
| BGOS-213 | Вычисляемое поле `NetAddr` в модели `RecordNode` в cloudbroker/node |
|
||||
|
||||
#### vgpu
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-204 | Опциональное поле `NID` в структуре `ListRequest` в cloudbroker/vgpu |
|
||||
|
||||
#### vins
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-204 | Вычисляемое поле `VNCPassword` в модели `RecordVNFDev` в cloudapi/vins и cloudbroker/vins |
|
||||
| BGOS-204 | Вычисляемое поле `AccoundID` в модели `ItemReservation` в cloudapi/vins |
|
||||
|
||||
### Удалено
|
||||
|
||||
#### disks
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-206 | Метод `Resize` в cloudapi/disks и cloudbroker/disks |
|
||||
|
||||
#### sep
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-206 | Метод `UpdateCapacityLimit` cloudbroker/sep |
|
||||
|
||||
#### vins
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-204 | Вычисляемые поля `ClientType,Description,DomainName,Hostname` в модели `ItemReservation` в cloudapi/vins и cloudbroker/vins |
|
||||
| BGOS-204 | Вычисляемое поле `СomputeIds` в структуре `StaticRouteAddRequest` в cloudapi/vins и cloudbroker/vins |
|
||||
|
||||
### Исправлено
|
||||
|
||||
#### compute
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| BATF-215 | Изменены возвращаемые параметры метода `PinToStack` на `bool,error` в cloudapi/compute |
|
||||
| BGOS-336 | Группа ручек cloudbroker/resmon |
|
||||
@@ -142,6 +142,8 @@ go get -u repository.basistech.ru/BASIS/decort-golang-sdk
|
||||
- `LB` - управление балансировщиками нагрузки;
|
||||
- `Node` - управление нодами платформы;
|
||||
- `PCIDevice` - управление устройствами;
|
||||
- `Prometheus` - получение статистики prometheus;
|
||||
- `Resmon` - получение статистики resource monitoring;
|
||||
- `RG` - управление ресурсными группами аккаунта;
|
||||
- `SEP` - управление storage endpoint (sep);
|
||||
- `Stack` - получение информации о вычислительных узлах;
|
||||
@@ -319,6 +321,8 @@ func main() {
|
||||
- `pkg/cloudbroker/lb` - для `LB`
|
||||
- `pkg/cloudbroker/node` - для `Node`
|
||||
- `pkg/cloudbroker/pcidevice` - для `PCIDevice`
|
||||
- `pkg/cloudbroker/prometheus` - для `Prometheus`
|
||||
- `pkg/cloudbroker/resmon` - для `Resmon`
|
||||
- `pkg/cloudbroker/rg` - для `RG`
|
||||
- `pkg/cloudbroker/sep` - для `SEP`
|
||||
- `pkg/cloudbroker/stack` - для `Stack`
|
||||
@@ -505,6 +509,8 @@ func main() {
|
||||
- `.LB()` - для работы с `LB`
|
||||
- `.Node()` - для работы с `Node`
|
||||
- `.PCIDevice()` - для работы с `PCIDevice`
|
||||
- `.Prometheus()` - для работы с `Prometheus`
|
||||
- `.Resmon()` - для работы с `Resmon`
|
||||
- `.RG()` - для работы с `RG`
|
||||
- `.SEP()` - для работы с `SEP`
|
||||
- `.Stack()` - для работы с `Stack`
|
||||
|
||||
@@ -378,6 +378,21 @@ func chipsetValidator(fe validator.FieldLevel) bool {
|
||||
return IsInSlice(fieldValue, chipsetValues)
|
||||
}
|
||||
|
||||
func preferredCPUValidator(fe validator.FieldLevel) bool {
|
||||
fieldSlice, ok := fe.Field().Interface().([]int64)
|
||||
if !ok {
|
||||
return false
|
||||
}
|
||||
|
||||
for _, value := range fieldSlice {
|
||||
if value < -1 {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// ValidateRAM checks if request contains RAM value that is positive integer divisible by divisibility passed.
|
||||
// It is recommended to pass constants.RAM_DIVISIBILITY as divisility arguement
|
||||
func ValidateRAM(r interfaces.RequestWithRAM, divisibility uint64) error {
|
||||
|
||||
@@ -94,6 +94,9 @@ func errorMessage(fe validator.FieldError) string {
|
||||
case "mtu":
|
||||
return fmt.Sprint(prefix, fe.Field(), "must be ", mtuMin, "-", mtuMax)
|
||||
|
||||
case "preferredCPU":
|
||||
return fmt.Sprint(prefix, fe.Field(), "must be equal to or greater than", -1)
|
||||
|
||||
case "computex86NetType":
|
||||
return fmt.Sprintf("%s %s must be one of the following: %s",
|
||||
prefix,
|
||||
|
||||
@@ -261,5 +261,10 @@ func registerAllValidators(validate *validator.Validate) error {
|
||||
return err
|
||||
}
|
||||
|
||||
err = validate.RegisterValidation("preferredCPU", preferredCPUValidator)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -428,6 +428,9 @@ type RecordCompute struct {
|
||||
// Pinned or not
|
||||
Pinned bool `json:"pinned"`
|
||||
|
||||
// PreferredCPU
|
||||
PreferredCPU []int64 `json:"preferredCpu"`
|
||||
|
||||
// Number of RAM
|
||||
RAM uint64 `json:"ram"`
|
||||
|
||||
@@ -980,6 +983,9 @@ type ItemCompute struct {
|
||||
// Pinned or not
|
||||
Pinned bool `json:"pinned"`
|
||||
|
||||
// PreferredCPU
|
||||
PreferredCPU []int64 `json:"preferredCpu"`
|
||||
|
||||
// Number of RAM
|
||||
RAM uint64 `json:"ram"`
|
||||
|
||||
|
||||
@@ -27,6 +27,10 @@ type ResizeRequest struct {
|
||||
// Force compute resize
|
||||
// Required: false
|
||||
Force bool `url:"force,omitempty" json:"force,omitempty"`
|
||||
|
||||
// Recommended isolated CPUs. Field is ignored if compute.cpupin=False or compute.pinned=False
|
||||
// Required: false
|
||||
PreferredCPU []int64 `url:"preferredCpu,omitempty" json:"preferredCpu,omitempty" validate:"omitempty,preferredCPU"`
|
||||
}
|
||||
|
||||
// GetRAM returns RAM field values
|
||||
|
||||
@@ -48,6 +48,10 @@ type UpdateRequest struct {
|
||||
// Required: false
|
||||
// Default: false
|
||||
AutoStart bool `url:"autoStart" json:"autoStart"`
|
||||
|
||||
// Recommended isolated CPUs. Field is ignored if compute.cpupin=False or compute.pinned=False
|
||||
// Required: false
|
||||
PreferredCPU []int64 `url:"preferredCpu,omitempty" json:"preferredCpu,omitempty" validate:"omitempty,preferredCPU"`
|
||||
}
|
||||
|
||||
// Update updates some properties of the compute
|
||||
|
||||
@@ -164,6 +164,10 @@ type CreateRequest struct {
|
||||
// Required: false
|
||||
// Default: false
|
||||
HPBacked bool `url:"hpBacked" json:"hpBacked"`
|
||||
|
||||
// Recommended isolated CPUs. Field is ignored if compute.cpupin=False or compute.pinned=False
|
||||
// Required: false
|
||||
PreferredCPU []int64 `url:"preferredCpu,omitempty" json:"preferredCpu,omitempty" validate:"omitempty,preferredCPU"`
|
||||
}
|
||||
|
||||
// GetRAM returns RAM field values
|
||||
|
||||
@@ -68,6 +68,10 @@ type CreateBlankRequest struct {
|
||||
// Text description of this VM
|
||||
// Required: false
|
||||
Description string `url:"desc,omitempty" json:"desc,omitempty"`
|
||||
|
||||
// Recommended isolated CPUs. Field is ignored if compute.cpupin=False or compute.pinned=False
|
||||
// Required: false
|
||||
PreferredCPU []int64 `url:"preferredCpu,omitempty" json:"preferredCpu,omitempty" validate:"omitempty,preferredCPU"`
|
||||
}
|
||||
|
||||
// GetRAM returns RAM field values
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
func (a Audit) ExportAuditsToFile(ctx context.Context) ([]byte, error) {
|
||||
url := "/cloudbroker/audit/exportAuditsToFile"
|
||||
|
||||
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, nil)
|
||||
res, err := a.client.DecortApiCall(ctx, http.MethodGet, url, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -732,6 +732,9 @@ type InfoCompute struct {
|
||||
// Pinned
|
||||
Pinned bool `json:"pinned"`
|
||||
|
||||
// PreferredCPU
|
||||
PreferredCPU []int64 `json:"preferredCpu"`
|
||||
|
||||
// Number of RAM
|
||||
RAM uint64 `json:"ram"`
|
||||
|
||||
@@ -981,6 +984,9 @@ type RecordCompute struct {
|
||||
// Pinned
|
||||
Pinned bool `json:"pinned"`
|
||||
|
||||
// PreferredCPU
|
||||
PreferredCPU []int64 `json:"preferredCpu"`
|
||||
|
||||
// Number of RAM
|
||||
RAM uint64 `json:"ram"`
|
||||
|
||||
|
||||
@@ -27,6 +27,10 @@ type ResizeRequest struct {
|
||||
// Force compute resize
|
||||
// Required: false
|
||||
Force bool `url:"force,omitempty" json:"force,omitempty"`
|
||||
|
||||
// Recommended isolated CPUs. Field is ignored if compute.cpupin=False or compute.pinned=False
|
||||
// Required: false
|
||||
PreferredCPU []int64 `url:"preferredCpu,omitempty" json:"preferredCpu,omitempty" validate:"omitempty,preferredCPU"`
|
||||
}
|
||||
|
||||
// GetRAM returns RAM field values
|
||||
|
||||
@@ -48,6 +48,10 @@ type UpdateRequest struct {
|
||||
// Required: false
|
||||
// Default: false
|
||||
AutoStart bool `url:"autoStart" json:"autoStart"`
|
||||
|
||||
// Recommended isolated CPUs. Field is ignored if compute.cpupin=False or compute.pinned=False
|
||||
// Required: false
|
||||
PreferredCPU []int64 `url:"preferredCpu,omitempty" json:"preferredCpu,omitempty" validate:"omitempty,preferredCPU"`
|
||||
}
|
||||
|
||||
// Update updates some properties of the compute
|
||||
|
||||
@@ -168,6 +168,10 @@ type CreateRequest struct {
|
||||
// Required: false
|
||||
// Default: false
|
||||
HPBacked bool `url:"hpBacked" json:"hpBacked"`
|
||||
|
||||
// Recommended isolated CPUs. Field is ignored if compute.cpupin=False or compute.pinned=False
|
||||
// Required: false
|
||||
PreferredCPU []int64 `url:"preferredCpu,omitempty" json:"preferredCpu,omitempty" validate:"omitempty,preferredCPU"`
|
||||
}
|
||||
|
||||
// GetRAM returns RAM field values
|
||||
|
||||
@@ -68,6 +68,10 @@ type CreateBlankRequest struct {
|
||||
// Type of the emulated system, Q35 or i440fx
|
||||
// Required: false
|
||||
Chipset string `url:"chipset,omitempty" json:"chipset,omitempty" validate:"omitempty,chipset"`
|
||||
|
||||
// Recommended isolated CPUs. Field is ignored if compute.cpupin=False or compute.pinned=False
|
||||
// Required: false
|
||||
PreferredCPU []int64 `url:"preferredCpu,omitempty" json:"preferredCpu,omitempty" validate:"omitempty,preferredCPU"`
|
||||
}
|
||||
|
||||
// GetRAM returns RAM field values
|
||||
|
||||
@@ -11,6 +11,9 @@ type RecordNode struct {
|
||||
// CPU Allocation Ratio
|
||||
CPUAllocationRatio float64 `json:"cpu_allocation_ratio"`
|
||||
|
||||
// DPDK info
|
||||
DPDK DPDK `json:"dpdk"`
|
||||
|
||||
// GID
|
||||
GID uint64 `json:"gid"`
|
||||
|
||||
@@ -32,6 +35,9 @@ type RecordNode struct {
|
||||
// Netaddr
|
||||
NetAddr NetAddr `json:"netaddr"`
|
||||
|
||||
// Network mode
|
||||
NetworkMode string `json:"networkmode"`
|
||||
|
||||
// Nic Info
|
||||
NicInfo ListNicInfo `json:"nicInfo"`
|
||||
|
||||
@@ -53,6 +59,18 @@ type RecordNode struct {
|
||||
// Status
|
||||
Status string `json:"status"`
|
||||
|
||||
// To active
|
||||
ToActive Role `json:"to_active"`
|
||||
|
||||
// To installing
|
||||
ToInstalling Role `json:"to_installing"`
|
||||
|
||||
// To maintenance
|
||||
ToMaintenance Role `json:"to_maintenance"`
|
||||
|
||||
// To restricted
|
||||
ToRestricted Role `json:"to_restricted"`
|
||||
|
||||
// Version
|
||||
Version string `json:"version"`
|
||||
}
|
||||
@@ -125,6 +143,9 @@ type ItemNode struct {
|
||||
// Description
|
||||
Description string `json:"description"`
|
||||
|
||||
// DPDK
|
||||
DPDK DPDK `json:"dpdk"`
|
||||
|
||||
// GID
|
||||
GID uint64 `json:"gid"`
|
||||
|
||||
@@ -227,6 +248,9 @@ type ItemNode struct {
|
||||
// Type
|
||||
Type string `json:"type"`
|
||||
|
||||
//UEFI Firmware File
|
||||
UEFIFirmwareFile string `json:"uefiFirmwareFile"`
|
||||
|
||||
// Version
|
||||
Version string `json:"version"`
|
||||
}
|
||||
@@ -326,3 +350,33 @@ type NetAddr struct {
|
||||
// IP list backplane1 node
|
||||
IP []string `json:"ip"`
|
||||
}
|
||||
|
||||
// DPDK info
|
||||
type DPDK struct {
|
||||
// Bridges
|
||||
Bridges Bridges `json:"bridges"`
|
||||
|
||||
// hp memory
|
||||
HPMemory map[string]uint64 `json:"hp_memory"`
|
||||
|
||||
// pmd cpu
|
||||
PMDCPU []uint64 `json:"pmd_cpu"`
|
||||
}
|
||||
|
||||
// Bridges
|
||||
type Bridges struct {
|
||||
Backplane1 Backplane1 `json:"backplane1"`
|
||||
}
|
||||
|
||||
// Backplane1
|
||||
type Backplane1 struct {
|
||||
Interfaces []string `json:"interfaces"`
|
||||
NumaNode uint64 `json:"numa_node"`
|
||||
}
|
||||
|
||||
// Role
|
||||
type Role struct {
|
||||
Actor string `json:"actor"`
|
||||
Reason string `json:"reason"`
|
||||
Time uint64 `json:"time"`
|
||||
}
|
||||
|
||||
8
pkg/cloudbroker/prometheus.go
Normal file
8
pkg/cloudbroker/prometheus.go
Normal file
@@ -0,0 +1,8 @@
|
||||
package cloudbroker
|
||||
|
||||
import "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/prometheus"
|
||||
|
||||
// Accessing the Prometheus method group
|
||||
func (cb *CloudBroker) Prometheus() *prometheus.Prometheus {
|
||||
return prometheus.New(cb.client)
|
||||
}
|
||||
57
pkg/cloudbroker/prometheus/compute_cpu_load.go
Normal file
57
pkg/cloudbroker/prometheus/compute_cpu_load.go
Normal file
@@ -0,0 +1,57 @@
|
||||
package prometheus
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
type ComputeCPULoadRequest struct {
|
||||
// Compute ID
|
||||
// Required: true
|
||||
ComputeID uint64 `url:"computeId" json:"computeId" 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"`
|
||||
}
|
||||
|
||||
// Per-second CPU time consumed by Compute in percent, average over the time step specified
|
||||
func (p Prometheus) ComputeCPULoad(ctx context.Context, req ComputeCPULoadRequest) (*PrometheusData, error) {
|
||||
res, err := p.ComputeCPULoadRaw(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
info := PrometheusData{}
|
||||
|
||||
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) ComputeCPULoadRaw(ctx context.Context, req ComputeCPULoadRequest) ([]byte, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/prometheus/computeCPUload"
|
||||
|
||||
res, err := p.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
return res, err
|
||||
}
|
||||
53
pkg/cloudbroker/prometheus/compute_memory_available.go
Normal file
53
pkg/cloudbroker/prometheus/compute_memory_available.go
Normal file
@@ -0,0 +1,53 @@
|
||||
package prometheus
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
type ComputeMemoryAvailableRequest struct {
|
||||
// Compute ID
|
||||
// Required: true
|
||||
ComputeID uint64 `url:"computeId" json:"computeId" 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"`
|
||||
}
|
||||
|
||||
// Available Memory
|
||||
func (p Prometheus) ComputeMemoryAvailable(ctx context.Context, req ComputeMemoryAvailableRequest) (*PrometheusData, error) {
|
||||
res, err := p.ComputeMemoryAvailableRaw(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
info := PrometheusData{}
|
||||
|
||||
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) ComputeMemoryAvailableRaw(ctx context.Context, req ComputeMemoryAvailableRequest) ([]byte, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/prometheus/computeMemoryAvailable"
|
||||
|
||||
res, err := p.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
return res, err
|
||||
}
|
||||
53
pkg/cloudbroker/prometheus/compute_memory_unused.go
Normal file
53
pkg/cloudbroker/prometheus/compute_memory_unused.go
Normal file
@@ -0,0 +1,53 @@
|
||||
package prometheus
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
type ComputeMemoryUnusedRequest struct {
|
||||
// Compute ID
|
||||
// Required: true
|
||||
ComputeID uint64 `url:"computeId" json:"computeId" 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"`
|
||||
}
|
||||
|
||||
// Unused Memory
|
||||
func (p Prometheus) ComputeMemoryUnused(ctx context.Context, req ComputeMemoryUnusedRequest) (*PrometheusData, error) {
|
||||
res, err := p.ComputeMemoryUnusedRaw(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
info := PrometheusData{}
|
||||
|
||||
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) ComputeMemoryUnusedRaw(ctx context.Context, req ComputeMemoryUnusedRequest) ([]byte, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/prometheus/computeMemoryUnused"
|
||||
|
||||
res, err := p.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
return res, err
|
||||
}
|
||||
53
pkg/cloudbroker/prometheus/compute_memory_usable.go
Normal file
53
pkg/cloudbroker/prometheus/compute_memory_usable.go
Normal file
@@ -0,0 +1,53 @@
|
||||
package prometheus
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
type ComputeMemoryUsableRequest struct {
|
||||
// Compute ID
|
||||
// Required: true
|
||||
ComputeID uint64 `url:"computeId" json:"computeId" 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"`
|
||||
}
|
||||
|
||||
// Usable Memory
|
||||
func (p Prometheus) ComputeMemoryUsable(ctx context.Context, req ComputeMemoryUsableRequest) (*PrometheusData, error) {
|
||||
res, err := p.ComputeMemoryUsableRaw(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
info := PrometheusData{}
|
||||
|
||||
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) ComputeMemoryUsableRaw(ctx context.Context, req ComputeMemoryUsableRequest) ([]byte, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/prometheus/computeMemoryUsable"
|
||||
|
||||
res, err := p.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
return res, err
|
||||
}
|
||||
53
pkg/cloudbroker/prometheus/compute_memory_usage.go
Normal file
53
pkg/cloudbroker/prometheus/compute_memory_usage.go
Normal file
@@ -0,0 +1,53 @@
|
||||
package prometheus
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
type ComputeMemoryUsageRequest struct {
|
||||
// Compute ID
|
||||
// Required: true
|
||||
ComputeID uint64 `url:"computeId" json:"computeId" 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"`
|
||||
}
|
||||
|
||||
// Memory Usage
|
||||
func (p Prometheus) ComputeMemoryUsage(ctx context.Context, req ComputeMemoryUsageRequest) (*PrometheusData, error) {
|
||||
res, err := p.ComputeMemoryUsageRaw(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
info := PrometheusData{}
|
||||
|
||||
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) ComputeMemoryUsageRaw(ctx context.Context, req ComputeMemoryUsageRequest) ([]byte, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/prometheus/computeMemoryUsage"
|
||||
|
||||
res, err := p.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
return res, err
|
||||
}
|
||||
53
pkg/cloudbroker/prometheus/compute_memory_used.go
Normal file
53
pkg/cloudbroker/prometheus/compute_memory_used.go
Normal file
@@ -0,0 +1,53 @@
|
||||
package prometheus
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
type ComputeMemoryUsedRequest struct {
|
||||
// Compute ID
|
||||
// Required: true
|
||||
ComputeID uint64 `url:"computeId" json:"computeId" 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"`
|
||||
}
|
||||
|
||||
// Used Memory
|
||||
func (p Prometheus) ComputeMemoryUsed(ctx context.Context, req ComputeMemoryUsedRequest) (*PrometheusData, error) {
|
||||
res, err := p.ComputeMemoryUsedRaw(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
info := PrometheusData{}
|
||||
|
||||
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) ComputeMemoryUsedRaw(ctx context.Context, req ComputeMemoryUsedRequest) ([]byte, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/prometheus/computeMemoryUsed"
|
||||
|
||||
res, err := p.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
return res, err
|
||||
}
|
||||
57
pkg/cloudbroker/prometheus/compute_read_bytes.go
Normal file
57
pkg/cloudbroker/prometheus/compute_read_bytes.go
Normal file
@@ -0,0 +1,57 @@
|
||||
package prometheus
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
type ComputeReadBytesRequest struct {
|
||||
// Compute ID
|
||||
// Required: true
|
||||
ComputeID uint64 `url:"computeId" json:"computeId" 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"`
|
||||
}
|
||||
|
||||
// Read Bytes
|
||||
func (p Prometheus) ComputeReadBytes(ctx context.Context, req ComputeReadBytesRequest) (*PrometheusData, error) {
|
||||
res, err := p.ComputeReadBytesRaw(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
info := PrometheusData{}
|
||||
|
||||
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) ComputeReadBytesRaw(ctx context.Context, req ComputeReadBytesRequest) ([]byte, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/prometheus/computeReadBytes"
|
||||
|
||||
res, err := p.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
return res, err
|
||||
}
|
||||
57
pkg/cloudbroker/prometheus/compute_read_requests.go
Normal file
57
pkg/cloudbroker/prometheus/compute_read_requests.go
Normal file
@@ -0,0 +1,57 @@
|
||||
package prometheus
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
type ComputeReadRequestsRequest struct {
|
||||
// Compute ID
|
||||
// Required: true
|
||||
ComputeID uint64 `url:"computeId" json:"computeId" 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"`
|
||||
}
|
||||
|
||||
// Read Requests
|
||||
func (p Prometheus) ComputeReadRequests(ctx context.Context, req ComputeReadRequestsRequest) (*PrometheusData, error) {
|
||||
res, err := p.ComputeReadRequestsRaw(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
info := PrometheusData{}
|
||||
|
||||
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) ComputeReadRequestsRaw(ctx context.Context, req ComputeReadRequestsRequest) ([]byte, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/prometheus/computeReadRequests"
|
||||
|
||||
res, err := p.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
return res, err
|
||||
}
|
||||
57
pkg/cloudbroker/prometheus/compute_receive_bytes.go
Normal file
57
pkg/cloudbroker/prometheus/compute_receive_bytes.go
Normal file
@@ -0,0 +1,57 @@
|
||||
package prometheus
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
type ComputeReceiveBytesRequest struct {
|
||||
// Compute ID
|
||||
// Required: true
|
||||
ComputeID uint64 `url:"computeId" json:"computeId" 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"`
|
||||
}
|
||||
|
||||
// Receive Bytes
|
||||
func (p Prometheus) ComputeReceiveBytes(ctx context.Context, req ComputeReceiveBytesRequest) (*PrometheusData, error) {
|
||||
res, err := p.ComputeReceiveBytesRaw(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
info := PrometheusData{}
|
||||
|
||||
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) ComputeReceiveBytesRaw(ctx context.Context, req ComputeReceiveBytesRequest) ([]byte, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/prometheus/computeReceiveBytes"
|
||||
|
||||
res, err := p.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
return res, err
|
||||
}
|
||||
57
pkg/cloudbroker/prometheus/compute_receive_packets.go
Normal file
57
pkg/cloudbroker/prometheus/compute_receive_packets.go
Normal file
@@ -0,0 +1,57 @@
|
||||
package prometheus
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
type ComputeReceivePacketsRequest struct {
|
||||
// Compute ID
|
||||
// Required: true
|
||||
ComputeID uint64 `url:"computeId" json:"computeId" 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"`
|
||||
}
|
||||
|
||||
// Receive Packets
|
||||
func (p Prometheus) ComputeReceivePackets(ctx context.Context, req ComputeReceivePacketsRequest) (*PrometheusData, error) {
|
||||
res, err := p.ComputeReceivePacketsRaw(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
info := PrometheusData{}
|
||||
|
||||
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) ComputeReceivePacketsRaw(ctx context.Context, req ComputeReceivePacketsRequest) ([]byte, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/prometheus/computeReceivePackets"
|
||||
|
||||
res, err := p.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
return res, err
|
||||
}
|
||||
57
pkg/cloudbroker/prometheus/compute_transmit_bytes.go
Normal file
57
pkg/cloudbroker/prometheus/compute_transmit_bytes.go
Normal file
@@ -0,0 +1,57 @@
|
||||
package prometheus
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
type ComputeTransmitBytesRequest struct {
|
||||
// Compute ID
|
||||
// Required: true
|
||||
ComputeID uint64 `url:"computeId" json:"computeId" 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"`
|
||||
}
|
||||
|
||||
// Transmit Bytes
|
||||
func (p Prometheus) ComputeTransmitBytes(ctx context.Context, req ComputeTransmitBytesRequest) (*PrometheusData, error) {
|
||||
res, err := p.ComputeTransmitBytesRaw(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
info := PrometheusData{}
|
||||
|
||||
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) ComputeTransmitBytesRaw(ctx context.Context, req ComputeTransmitBytesRequest) ([]byte, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/prometheus/computeTransmitBytes"
|
||||
|
||||
res, err := p.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
return res, err
|
||||
}
|
||||
57
pkg/cloudbroker/prometheus/compute_transmit_packets.go
Normal file
57
pkg/cloudbroker/prometheus/compute_transmit_packets.go
Normal file
@@ -0,0 +1,57 @@
|
||||
package prometheus
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
type ComputeTransmitPacketsRequest struct {
|
||||
// Compute ID
|
||||
// Required: true
|
||||
ComputeID uint64 `url:"computeId" json:"computeId" 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"`
|
||||
}
|
||||
|
||||
// Transmit Packets
|
||||
func (p Prometheus) ComputeTransmitPackets(ctx context.Context, req ComputeTransmitPacketsRequest) (*PrometheusData, error) {
|
||||
res, err := p.ComputeTransmitPacketsRaw(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
info := PrometheusData{}
|
||||
|
||||
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) ComputeTransmitPacketsRaw(ctx context.Context, req ComputeTransmitPacketsRequest) ([]byte, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/prometheus/computeTransmitPackets"
|
||||
|
||||
res, err := p.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
return res, err
|
||||
}
|
||||
57
pkg/cloudbroker/prometheus/compute_write_bytes.go
Normal file
57
pkg/cloudbroker/prometheus/compute_write_bytes.go
Normal file
@@ -0,0 +1,57 @@
|
||||
package prometheus
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
type ComputeWriteBytesRequest struct {
|
||||
// Compute ID
|
||||
// Required: true
|
||||
ComputeID uint64 `url:"computeId" json:"computeId" 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"`
|
||||
}
|
||||
|
||||
// Write Bytes
|
||||
func (p Prometheus) ComputeWriteBytes(ctx context.Context, req ComputeWriteBytesRequest) (*PrometheusData, error) {
|
||||
res, err := p.ComputeWriteBytesRaw(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
info := PrometheusData{}
|
||||
|
||||
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) ComputeWriteBytesRaw(ctx context.Context, req ComputeWriteBytesRequest) ([]byte, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/prometheus/computeWriteBytes"
|
||||
|
||||
res, err := p.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
return res, err
|
||||
}
|
||||
57
pkg/cloudbroker/prometheus/compute_write_requests.go
Normal file
57
pkg/cloudbroker/prometheus/compute_write_requests.go
Normal file
@@ -0,0 +1,57 @@
|
||||
package prometheus
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
type ComputeWriteRequestsRequest struct {
|
||||
// Compute ID
|
||||
// Required: true
|
||||
ComputeID uint64 `url:"computeId" json:"computeId" 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"`
|
||||
}
|
||||
|
||||
// Write Requests
|
||||
func (p Prometheus) ComputeWriteRequests(ctx context.Context, req ComputeWriteRequestsRequest) (*PrometheusData, error) {
|
||||
res, err := p.ComputeWriteRequestsRaw(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
info := PrometheusData{}
|
||||
|
||||
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) ComputeWriteRequestsRaw(ctx context.Context, req ComputeWriteRequestsRequest) ([]byte, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/prometheus/computeWriteRequests"
|
||||
|
||||
res, err := p.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
return res, err
|
||||
}
|
||||
13
pkg/cloudbroker/prometheus/models.go
Normal file
13
pkg/cloudbroker/prometheus/models.go
Normal file
@@ -0,0 +1,13 @@
|
||||
package prometheus
|
||||
|
||||
// PrometheusData represents an array of data points
|
||||
type PrometheusData []PrometheusPoint
|
||||
|
||||
// PrometheusPoint represents a single data point
|
||||
type PrometheusPoint struct {
|
||||
// Value of the metric at a specific point in time
|
||||
Value float64 `json:"value"`
|
||||
|
||||
// Timestamp the Unix timestamp.
|
||||
Timestamp uint64 `json:"timestamp"`
|
||||
}
|
||||
17
pkg/cloudbroker/prometheus/prometheus.go
Normal file
17
pkg/cloudbroker/prometheus/prometheus.go
Normal file
@@ -0,0 +1,17 @@
|
||||
package prometheus
|
||||
|
||||
import (
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/interfaces"
|
||||
)
|
||||
|
||||
// Structure for creating request to prometheus
|
||||
type Prometheus struct {
|
||||
client interfaces.Caller
|
||||
}
|
||||
|
||||
// Builder for prometheus endpoints
|
||||
func New(client interfaces.Caller) *Prometheus {
|
||||
return &Prometheus{
|
||||
client: client,
|
||||
}
|
||||
}
|
||||
10
pkg/cloudbroker/resmon.go
Normal file
10
pkg/cloudbroker/resmon.go
Normal file
@@ -0,0 +1,10 @@
|
||||
package cloudbroker
|
||||
|
||||
import (
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/resmon"
|
||||
)
|
||||
|
||||
// Accessing the Resmon method group
|
||||
func (cb *CloudBroker) Resmon() *resmon.Resmon {
|
||||
return resmon.New(cb.client)
|
||||
}
|
||||
53
pkg/cloudbroker/resmon/get_by_compute.go
Normal file
53
pkg/cloudbroker/resmon/get_by_compute.go
Normal file
@@ -0,0 +1,53 @@
|
||||
package resmon
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
type GetByComputeRequest struct {
|
||||
// Compute ID
|
||||
// Required: true
|
||||
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
|
||||
|
||||
// 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 resource monitoring for the specified time period for the concrete compute instance
|
||||
func (r Resmon) GetByCompute(ctx context.Context, req GetByComputeRequest) (*GetByComputeData, error) {
|
||||
res, err := r.GetByComputeRaw(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) GetByComputeRaw(ctx context.Context, req GetByComputeRequest) ([]byte, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/resmon/getByCompute"
|
||||
|
||||
res, err := r.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
return res, err
|
||||
}
|
||||
49
pkg/cloudbroker/resmon/get_by_computes.go
Normal file
49
pkg/cloudbroker/resmon/get_by_computes.go
Normal file
@@ -0,0 +1,49 @@
|
||||
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
|
||||
}
|
||||
49
pkg/cloudbroker/resmon/get_by_grid.go
Normal file
49
pkg/cloudbroker/resmon/get_by_grid.go
Normal file
@@ -0,0 +1,49 @@
|
||||
package resmon
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
type GetByGRIDRequest 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 a grid resource monitoring for the specified time period
|
||||
func (r Resmon) GetByGRID(ctx context.Context, req GetByGRIDRequest) (*GetByGRIDData, error) {
|
||||
res, err := r.GetByGRIDRaw(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
info := GetByGRIDData{}
|
||||
|
||||
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) GetByGRIDRaw(ctx context.Context, req GetByGRIDRequest) ([]byte, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/resmon/getByGrid"
|
||||
|
||||
res, err := r.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
return res, err
|
||||
}
|
||||
53
pkg/cloudbroker/resmon/get_by_stack.go
Normal file
53
pkg/cloudbroker/resmon/get_by_stack.go
Normal file
@@ -0,0 +1,53 @@
|
||||
package resmon
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
type GetByStackRequest struct {
|
||||
// Stack ID
|
||||
// Required: true
|
||||
StackID uint64 `url:"stackId" json:"stackId" validate:"required"`
|
||||
|
||||
// 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
|
||||
func (r Resmon) GetByStack(ctx context.Context, req GetByStackRequest) (*GetByStackData, error) {
|
||||
res, err := r.GetByStackRaw(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
info := GetByStackData{}
|
||||
|
||||
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) GetByStackRaw(ctx context.Context, req GetByStackRequest) ([]byte, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/resmon/getByStack"
|
||||
|
||||
res, err := r.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
return res, err
|
||||
}
|
||||
49
pkg/cloudbroker/resmon/get_by_stacks.go
Normal file
49
pkg/cloudbroker/resmon/get_by_stacks.go
Normal file
@@ -0,0 +1,49 @@
|
||||
package resmon
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
type GetByStacksRequest 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 a grid resource monitoring for the specified time period
|
||||
func (r Resmon) GetByStacks(ctx context.Context, req GetByStacksRequest) (*GetByStackData, error) {
|
||||
res, err := r.GetByStacksRaw(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
info := GetByStackData{}
|
||||
|
||||
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) GetByStacksRaw(ctx context.Context, req GetByStacksRequest) ([]byte, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/resmon/getByStacks"
|
||||
|
||||
res, err := r.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
return res, err
|
||||
}
|
||||
89
pkg/cloudbroker/resmon/models.go
Normal file
89
pkg/cloudbroker/resmon/models.go
Normal file
@@ -0,0 +1,89 @@
|
||||
package resmon
|
||||
|
||||
// GetByComputeData represents an array of data points
|
||||
type GetByComputeData []GetByComputePoint
|
||||
|
||||
type GetByComputePoint struct {
|
||||
ID uint64 `json:"id"`
|
||||
Name string `json:"name"`
|
||||
ComputeID uint64 `json:"computeId"`
|
||||
AccountID uint64 `json:"accountId"`
|
||||
RGID uint64 `json:"rgId"`
|
||||
Usage ComputeUsage `json:"usage"`
|
||||
Disks []ItemDisk `json:"disks"`
|
||||
UID string `json:"uid"`
|
||||
StackID uint64 `json:"stackId"`
|
||||
}
|
||||
|
||||
type ComputeUsage struct {
|
||||
VCPUsConsumed uint64 `json:"vcpusConsumed"`
|
||||
Storage uint64 `json:"storage"`
|
||||
CPUTime uint64 `json:"cpuTime"`
|
||||
ExtIPs uint64 `json:"extips"`
|
||||
RAMConsumed uint64 `json:"ramConsumed"`
|
||||
VCPUsReserved uint64 `json:"vcpusReserved"`
|
||||
IsUp uint64 `json:"isUp"`
|
||||
RAMConsumedReal uint64 `json:"ramConsumedReal"`
|
||||
RAMReserved uint64 `json:"ramReserved"`
|
||||
}
|
||||
|
||||
type ItemDisk struct {
|
||||
Pool string `json:"pool"`
|
||||
ResID string `json:"resId"`
|
||||
SizeUsed uint64 `json:"sizeUsed"`
|
||||
SizeMax uint64 `json:"sizeMax"`
|
||||
}
|
||||
|
||||
// GetByGRIDData represents an array of data points
|
||||
type GetByGRIDData []GetByGRIDPoint
|
||||
|
||||
type GetByGRIDPoint struct {
|
||||
UID string `json:"uid"`
|
||||
Total ItemTotalByGRID `json:"total"`
|
||||
Storages map[string]ItemStorage `json:"storages"`
|
||||
}
|
||||
|
||||
type ItemTotalByGRID struct {
|
||||
StacksCPU uint64 `json:"stacksCPU"`
|
||||
StorageCapacity uint64 `json:"storageCapacity"`
|
||||
CPUPower uint64 `json:"cpuPower"`
|
||||
CPUUtil uint64 `json:"cpuUtil"`
|
||||
TotalMem uint64 `json:"totalMem"`
|
||||
ReservedMem uint64 `json:"reservedMem"`
|
||||
UsedMem uint64 `json:"usedMem"`
|
||||
FreeMem uint64 `json:"freeMem"`
|
||||
VCPUConsumed uint64 `json:"vcpuConsumed"`
|
||||
}
|
||||
|
||||
type ItemStorage struct {
|
||||
CapacityLimit uint64 `json:"capacityLimit"`
|
||||
Consumed uint64 `json:"consumed"`
|
||||
Type string `json:"type"`
|
||||
UID string `json:"uid"`
|
||||
}
|
||||
|
||||
// GetByStackData represents an array of data points
|
||||
type GetByStackData []GetByStackPoint
|
||||
|
||||
type GetByStackPoint struct {
|
||||
Usage StackUsage `json:"usage"`
|
||||
CPUInfo CPUinfoByStack `json:"cpuInfo"`
|
||||
Name string `json:"name"`
|
||||
ID uint64 `json:"id"`
|
||||
}
|
||||
|
||||
type StackUsage struct {
|
||||
CPUPower uint64 `json:"cpuPower"`
|
||||
UsedVCPUs uint64 `json:"usedVcpus"`
|
||||
PCPU uint64 `json:"pcpu"`
|
||||
UsedMem uint64 `json:"usedMem"`
|
||||
CPUUtil uint64 `json:"cpuUtil"`
|
||||
ReservedMem uint64 `json:"reservedMem"`
|
||||
FreeMem uint64 `json:"freeMem"`
|
||||
}
|
||||
|
||||
type CPUinfoByStack struct {
|
||||
ClockSpeed uint64 `json:"clockSpeed"`
|
||||
CoreCount uint64 `json:"coreCount"`
|
||||
PhysCount uint64 `json:"physCount"`
|
||||
}
|
||||
15
pkg/cloudbroker/resmon/resmon.go
Normal file
15
pkg/cloudbroker/resmon/resmon.go
Normal file
@@ -0,0 +1,15 @@
|
||||
package resmon
|
||||
|
||||
import "repository.basistech.ru/BASIS/decort-golang-sdk/interfaces"
|
||||
|
||||
// Structure for creating request to resource monitoring
|
||||
type Resmon struct {
|
||||
client interfaces.Caller
|
||||
}
|
||||
|
||||
// Builder for resource monitoring endpoints
|
||||
func New(client interfaces.Caller) *Resmon {
|
||||
return &Resmon{
|
||||
client: client,
|
||||
}
|
||||
}
|
||||
@@ -25,7 +25,7 @@ type Total struct {
|
||||
}
|
||||
|
||||
type ByPool struct {
|
||||
|
||||
|
||||
// Disk count
|
||||
DiskCount uint64 `json:"disk_count"`
|
||||
|
||||
@@ -101,12 +101,6 @@ type SEPConfig map[string]interface{}
|
||||
|
||||
// Detailed information about SEP
|
||||
type RecordSEP struct {
|
||||
// CKey
|
||||
CKey string `json:"_ckey"`
|
||||
|
||||
// Meta
|
||||
Meta []interface{} `json:"_meta"`
|
||||
|
||||
// Config
|
||||
Config SEPConfig `json:"config"`
|
||||
|
||||
@@ -128,6 +122,9 @@ type RecordSEP struct {
|
||||
// Milestones
|
||||
Milestones uint64 `json:"milestones"`
|
||||
|
||||
// MultipathNum
|
||||
MultipathNum uint64 `json:"multipathNum"`
|
||||
|
||||
// Name
|
||||
Name string `json:"name"`
|
||||
|
||||
|
||||
@@ -242,6 +242,9 @@ type VNFDev struct {
|
||||
|
||||
// Main information about reservation
|
||||
type ItemReservation struct {
|
||||
// Account ID
|
||||
AccountID uint64 `json:"account_id"`
|
||||
|
||||
// IP
|
||||
IP string `json:"ip"`
|
||||
|
||||
|
||||
Reference in New Issue
Block a user