Compare commits

..

4 Commits

Author SHA1 Message Date
9192f307e1 v1.9.4 2025-05-21 13:24:22 +03:00
asteam
aee072c194 v1.9.3 2025-03-11 11:06:21 +03:00
asteam
88eb9e8898 v1.9.2 2024-12-04 11:50:22 +03:00
9ec34c6bfc v1.9.1 2024-11-22 12:09:50 +03:00
50 changed files with 1255 additions and 226 deletions

View File

@@ -1,131 +1,8 @@
## Version 1.9.0
## Version 1.9.4
### Feature
#### account
- Delete field RecursiveDelete in DeleteUserRequest in cloudapi/account and cloudbroker/account
- Add field UniqPools in UpdateRequest in cloudapi/account
- Add field ClearUniqPools in UpdateRequest in cloudbroker/account
- Add field SortBy in listFlipGroups in cloudapi/account
- Change Ratio field from required to optional in SetCPUAllocationRatioRequest in cloudbroker/compute
#### audit
- Add endpoint Get in cloudapi/audit
- Add endpoint ExportAuditsToFile in cloudbroker/audit
- Delete field Apitask in model RecordAudit in cloudbroker/audit
### Исправлено
#### compute
- Add support DPDK network net type in NetAttach endpoints in cloudapi/compute and cloudbroker/compute
- Add field Force in CloneRequest in cloudapi/compute and cloudbroker/compute
- Change TargetStackID field from required to optional (add default 0 value) in PinToStackRequest in cloudbroker/compute
- Change return value type from bool to string in SnapshotDelete in cloudbroker/compute and cloudapi/compute
- Add field StatusCheck in MigrateStorageAbortRequest in cloudbroker/compute
- Add function SnapshotDeleteAsync in cloudapi/compute and cloudbroker/compute
- Add field StackID in ListRequest in cloudbroker/compute
- Add field NodeID in model RecordCompute in cloudbroker/compute
- Add function SetNetConfig in cloudbroker/compute
- Add field MTU in model RecordNetAttach in cloudapi/compute and cloudbroker/compute
- Change Mode field from required to optional in DiskMigrateRequest in cloudapi/compute
- Add field Chipset in model RecordCompute in cloudapi/compute and cloudbroker/compute
- Add field BusNumber in model RecordCompute, ItemComputeDisk, ItemDisk, InfoDisk in cloudapi/compute and cloudbroker/compute
- Add field ImageID in ListRequest in cloudbroker/compute
- Change Mode field from required to optional in DiskMigrateRequest in cloudbroker/compute
- Add field Chipset in ListRequest in cloudbroker/compute
- Add endpoints ChangeIP in cloudapi/compute and cloudbroker/compute
#### disks
- Change drivers field from optional to required in FromPlatformDiskRequest in cloudapi/disks, cloudbroker/disks
#### dpdknet
- Add endpoints List, Get in cloudapi/dpdk
- Add endpoints Create, Delete, Disable Enable, Get, List, Update in cloudbroker/dpdk
#### extnet
- Change StackId field from required to optional in DeviceMigrateRequest in cloudbroker/extnet
#### flipgroup
- Change ClientIDs field from []uint64 to []string in ListRequest, cloudapi/flipgroup
#### grid
- Change PasswordLength field from required to optional (add default 9 value) in SetPasswordPolicyRequest in cloudbroker/grid
- Set Default value (true) in fields Digits and Uppercase in SetPasswordPolicyRequest in cloudbroker/grid
- Add fields ckey, meta in model RecordGrid in cloudbroker/grid
- Change GID field from uint64 to string in ExecuteMaintenanceScriptRequest in cloudbroker/grid
- Add endpoints GetSettings and GetSettingsRaw in cloudbroker/grid
#### group
- Change StackId field from uint64 to string in ListRequest in cloudbroker/group
#### image:
- Change Drivers field from required to optional in CreateCDROMImageRequest in cloudbroker/image
- Add field Enabled in ListRequest in cloudapi/image and cloudbroker/image
- Delete field GID in SyncCreateRequest in cloudbroker/image
- Delete field Permanently in DeleteRequest in cloudapi/image and cloudbroker/image
- Delete field Permanently in DeleteImagesRequest in cloudbroker/image
#### k8s
- Add fields HighlyAvailableLB, AddressVip, ExtnetOnly, WithLB in model RecordK8S in cloudbroker/k8s and cloudapi/k8s
- Change MasterIds field from a slice of string to a slice of integers in DeleteMasterFromGroupRequest in cloudbroker/k8s and cloudapi/k8s
- Add field Chipset in WorkerAddRequest, WorkersGroupAddRequest in cloudapi/k8s, cloudbroker/k8s
- Add field Chipset in CreateRequest in cloudapi/k8s, cloudbroker/k8s
#### kvmx86
- Add support DPDK network interface in Create endpoints in cloudapi/kvmx86 and cloudbroker/kvmx8
- Add field Chipset in CreateRequest, CreateBlankRequest, MassCreateRequest, CreateBlankRequest in cloudapi/kvmx86 and cloudbroker/kvmx86
- Add function MassCreateAsync in cloudbroker/kvmx86
#### lb
- Change ExtNetID field from uint64 to int64 in CreateRequest, ItemLBList, RecordLB in cloudapi/lb, cloudbroker/lb
- Change ExtNetID, VINSID fields from required to optional in CreateRequest in cloudapi/lb
#### node
- Add field Force in EnableRequest in cloudbroker/node
- Add function EnableAsync in cloudbroker/node
#### rg
- Add endpoints removeDefNet in cloudapi/rg and cloudbroker/rg
- Add field ClearUniqPools in UpdateRequest in cloudbroker/rg and cloudapi/rg
- Add field UniqPools in UpdateRequest in cloudapi/rg
- Delete field IPCIDR in CreateRequest in cloudbroker/rg
#### sep
- Add endpoints SharedLockStart and SharedLockStop in cloudbroker/sep
#### user
- Add field GUID in models ItemAudit in cloudapi/user and cloudbroker/user
- Add fields MaxStatusCode and MinStatusCode in GetAuditRequest in cloudapi/user
#### vins
- Add field Computes in model ListVINS in cloudbroker/vins
- Add fields VNFDevId in ListRequest in cloudapi/vins and in ListDeletedRequest in cloudbroker/vins
- Add field MTU, LibvirtSettings in model ItemInterface in cloudapi/vins and cloudbroker/vins
- Add field BusNumber in model ItemInterface in cloudapi/vins and cloudbroker/vins
### Removed
#### common
- The reason field has been deleted everywhere
#### accounts
- The GetConsumption function was removed in cloudapi/account
#### grid
- The CheckVMs function was removed in cloudbroker/grid
- The CreateSystemSpace function was removed in cloudbroker/grid
#### image
- The Permanently field has been removed from DeleteCDROMImageRequest in cloudbroker/image
#### kvmppc
- The group has been completely deleted
#### sizes
- The group has been completely deleted
#### user
- The StatusCode field has been deleted from GetAuditRequest in cloudapi/user
### Bugfix
#### backup
- Fixed RestoreDisksFromBackupRequest in cloudbroker/backup
| Идентификатор<br>задачи | Описание |
| --- | --- |
| BGOS-485 | Изменен тип параметров `VGPUs` с []uint64 на []VGPUItem в структуре `RecordCompute` в cloudapi/compute и в cloudbroker/compute |

View File

@@ -141,6 +141,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` - получение информации о вычислительных узлах;
@@ -318,6 +320,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`
@@ -479,6 +483,7 @@ func main() {
- `.LB()` - для работы с `LB`
- `.Locations()` - для работы с `Locations`
- `.RG()` - для работы с `RG`
- `.Resmon()` - для работы с `Resmon`
- `.Stack()` - для работы с `Stack`
- `.Tasks()` - для работы с `Tasks`
- `.VFPool()` - для работы с `VFPool`
@@ -504,6 +509,8 @@ func main() {
- `.LB()` - для работы с `LB`
- `.Node()` - для работы с `Node`
- `.PCIDevice()` - для работы с `PCIDevice`
- `.Prometheus()` - для работы с `Prometheus`
- `.Resmon()` - для работы с `Resmon`
- `.RG()` - для работы с `RG`
- `.SEP()` - для работы с `SEP`
- `.Stack()` - для работы с `Stack`

View File

@@ -1,62 +0,0 @@
# Decort SDK
Decort SDK is a library, written in GO (Golang) for interact with the **DECORT** API.
The library contents structures and methods for requesting to an user (cloudapi) and admin (cloudbroker) groups of API.
Also the library have structures for responses.
## Contents
- [Install](#install)
- [API List](#api-list)
- [Examples](#examples)
- [Examples2](#examples2)
## Install
```bash
go get -u repository.basistech.ru/BASIS/decort-golang-sdk
```
## API List
## Examples
```go
package main
import (
"context"
"fmt"
"log"
"repository.basistech.ru/BASIS/decort-golang-sdk/config"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/kvmx86"
)
func main() {
cfg := config.Config{
AppID: "<APPID>",
AppSecret: "<APPSECRET>",
SSOURL: "https://sso.digitalenergy.online",
DecortURL: "https://mr4.digitalenergy.online",
Retries: 5,
}
client := decort.New(cfg)
req := kvmx86.CreateRequest{
RGID: 123,
Name: "compute",
CPU: 4,
RAM: 4096,
ImageID: 321,
}
res, err := client.KVMX86().Create(context.Background(), req)
if err != nil {
log.Fatal(err)
}
fmt.Println(res)
}
```
## Examples2

View File

@@ -372,6 +372,13 @@ func urlValidartor(fl validator.FieldLevel) bool {
return err == nil
}
func chipsetValidator(fe validator.FieldLevel) bool {
fieldValue := fe.Field().String()
fieldValue = strings.ToLower(fieldValue)
return IsInSlice(fieldValue, chipsetValues)
}
// 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 {

View File

@@ -299,6 +299,12 @@ func errorMessage(fe validator.FieldError) string {
prefix,
fe.Field(),
joinValues(kvmx86NetTypeValues))
case "chipset":
return fmt.Sprintf("%s %s must be one of the following: %s",
prefix,
fe.Field(),
joinValues(chipsetValues))
}
return fe.Error()

View File

@@ -256,5 +256,10 @@ func registerAllValidators(validate *validator.Validate) error {
return err
}
err = validate.RegisterValidation("chipset", chipsetValidator)
if err != nil {
return err
}
return nil
}

View File

@@ -62,6 +62,8 @@ var (
ioEventFDValues = []string{"on", "off", "selected by hypervisor"}
eventIDxValues = []string{"on", "off", "selected by hypervisor"}
chipsetValues = []string{"i440fx", "Q35"}
)
const (

View File

@@ -476,8 +476,8 @@ type RecordCompute struct {
// Userdata
Userdata interface{} `json:"userdata"`
// vGPU IDs
VGPUs []uint64 `json:"vgpus"`
// vGPU list
VGPUs []ItemVGPU `json:"vgpus"`
// Virtual image ID
VirtualImageID uint64 `json:"virtualImageId"`

View File

@@ -37,7 +37,7 @@ type UpdateRequest struct {
// Type of the emulated system, Q35 or i440fx
// Required: false
Chipset string `url:"chipset,omitempty" json:"chipset,omitempty"`
Chipset string `url:"chipset,omitempty" json:"chipset,omitempty" validate:"omitempty,chipset"`
// Use Huge Pages to allocate RAM of the virtual machine. The system must be pre-configured by allocating Huge Pages on the physical node
// Required: false

View File

@@ -44,7 +44,7 @@ type ListRequest struct {
// Find by list of clientIds
// Required: false
ClientIDs []string `url:"clientIds,omitempty" json:"clientIds,omitempty"`
ClientIDs []uint64 `url:"clientIds,omitempty" json:"clientIds,omitempty"`
// Page number
// Required: false

View File

@@ -165,7 +165,7 @@ type CreateRequest struct {
// Type of the emulated system, Q35 or i440fx
// Required: false
Chipset string `url:"chipset,omitempty" json:"chipset,omitempty"`
Chipset string `url:"chipset,omitempty" json:"chipset,omitempty" validate:"omitempty,chipset"`
}
// GetRAM returns RAM field values

View File

@@ -24,7 +24,7 @@ type WorkerAddRequest struct {
// Type of the emulated system, Q35 or i440fx
// Required: false
Chipset string `url:"chipset,omitempty" json:"chipset,omitempty"`
Chipset string `url:"chipset,omitempty" json:"chipset,omitempty" validate:"omitempty,chipset"`
}
// WorkerAdd adds worker nodes to a Kubernetes cluster

View File

@@ -3,7 +3,6 @@ package k8s
import (
"context"
"net/http"
"strconv"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
@@ -63,7 +62,7 @@ type WorkersGroupAddRequest struct {
// Type of the emulated system, Q35 or i440fx
// Required: false
Chipset string `url:"chipset,omitempty" json:"chipset,omitempty"`
Chipset string `url:"chipset,omitempty" json:"chipset,omitempty" validate:"omitempty,chipset"`
}
// GetRAM returns RAM field values
@@ -77,23 +76,18 @@ func (r WorkersGroupAddRequest) GetRAM() map[string]uint64 {
}
// WorkersGroupAdd adds workers group to Kubernetes cluster
func (k8s K8S) WorkersGroupAdd(ctx context.Context, req WorkersGroupAddRequest) (uint64, error) {
func (k8s K8S) WorkersGroupAdd(ctx context.Context, req WorkersGroupAddRequest) (string, error) {
err := validators.ValidateRequest(req)
if err != nil {
return 0, validators.ValidationErrors(validators.GetErrors(err))
return "", validators.ValidationErrors(validators.GetErrors(err))
}
url := "/cloudapi/k8s/workersGroupAdd"
res, err := k8s.client.DecortApiCall(ctx, http.MethodPost, url, req)
if err != nil {
return 0, err
return "", err
}
result, err := strconv.ParseUint(string(res), 10, 64)
if err != nil {
return 0, err
}
return result, nil
return string(res), nil
}

View File

@@ -26,6 +26,11 @@ type Interface struct {
// IP address to assign to this VM when connecting to the specified network
// Required: false
IPAddr string `url:"ipAddr,omitempty" json:"ipAddr,omitempty"`
// Maximum transmission unit, must be 1-9216
// Used only to DPDK net type
// Required: false
MTU uint64 `url:"mtu,omitempty" json:"mtu,omitempty" validate:"omitempty,mtu"`
}
// DataDisk detailed struct for DataDisks field in CreateRequest and CreateBlankRequest
@@ -153,7 +158,7 @@ type CreateRequest struct {
// Type of the emulated system, Q35 or i440fx
// Required: false
Chipset string `url:"chipset,omitempty" json:"chipset,omitempty"`
Chipset string `url:"chipset,omitempty" json:"chipset,omitempty" validate:"omitempty,chipset"`
// Use Huge Pages to allocate RAM of the virtual machine. The system must be pre-configured by allocating Huge Pages on the physical node
// Required: false

View File

@@ -63,7 +63,7 @@ type CreateBlankRequest struct {
// Type of the emulated system, Q35 or i440fx
// Required: false
Chipset string `url:"chipset,omitempty" json:"chipset,omitempty"`
Chipset string `url:"chipset,omitempty" json:"chipset,omitempty" validate:"omitempty,chipset"`
// Text description of this VM
// Required: false

View File

@@ -22,12 +22,12 @@ type CreateRequest struct {
Name string `url:"name" json:"name" validate:"required"`
// External network to connect this load balancer to
// Required: true
ExtNetID uint64 `url:"extnetId" json:"extnetId" validate:"required"`
// Required: true, can be 0
ExtNetID uint64 `url:"extnetId" json:"extnetId"`
// Internal network (VINS) to connect this load balancer to
// Required: true
VINSID uint64 `url:"vinsId" json:"vinsId" validate:"required"`
// Required: true, can be 0
VINSID uint64 `url:"vinsId" json:"vinsId"`
// Custom sysctl values for Load Balancer instance. Applied on boot
// Required: false

View File

@@ -1035,8 +1035,8 @@ type RecordCompute struct {
// Userdata
Userdata interface{} `json:"userdata"`
// List VGPU IDs
VGPUs []uint64 `json:"vgpus"`
// List VGPUs
VGPUs []ItemVGPU `json:"vgpus"`
// Virtual image ID
VirtualImageID uint64 `json:"virtualImageId"`

View File

@@ -37,7 +37,7 @@ type UpdateRequest struct {
// Type of the emulated system, Q35 or i440fx
// Required: false
Chipset string `url:"chipset,omitempty" json:"chipset,omitempty"`
Chipset string `url:"chipset,omitempty" json:"chipset,omitempty" validate:"omitempty,chipset"`
// Use Huge Pages to allocate RAM of the virtual machine. The system must be pre-configured by allocating Huge Pages on the physical node
// Required: false

View File

@@ -167,7 +167,7 @@ type CreateRequest struct {
// Type of the emulated system, Q35 or i440fx
// Required: false
Chipset string `url:"chipset,omitempty" json:"chipset,omitempty"`
Chipset string `url:"chipset,omitempty" json:"chipset,omitempty" validate:"omitempty,chipset"`
}
// GetRAM returns RAM values

View File

@@ -24,7 +24,7 @@ type WorkerAddRequest struct {
// Type of the emulated system, Q35 or i440fx
// Required: false
Chipset string `url:"chipset,omitempty" json:"chipset,omitempty"`
Chipset string `url:"chipset,omitempty" json:"chipset,omitempty" validate:"omitempty,chipset"`
}
// WorkerAdd adds worker nodes to a kubernetes cluster

View File

@@ -65,7 +65,7 @@ type WorkersGroupAddRequest struct {
// Type of the emulated system, Q35 or i440fx
// Required: false
Chipset string `url:"chipset,omitempty" json:"chipset,omitempty"`
Chipset string `url:"chipset,omitempty" json:"chipset,omitempty" validate:"omitempty,chipset"`
}
// GetRAM returns RAM field values

View File

@@ -26,6 +26,11 @@ type Interface struct {
// IP address to assign to this VM when connecting to the specified network
// Required: false
IPAddr string `url:"ipAddr,omitempty" json:"ipAddr,omitempty"`
// Maximum transmission unit, must be 1-9216
// Used only to DPDK net type
// Required: false
MTU uint64 `url:"mtu,omitempty" json:"mtu,omitempty" validate:"omitempty,mtu"`
}
// DataDisk detailed struct for DataDisks field in CreateRequest, CreateBlankRequest and MassCreateRequest
@@ -157,7 +162,7 @@ type CreateRequest struct {
// Type of the emulated system, Q35 or i440fx
// Required: false
Chipset string `url:"chipset,omitempty" json:"chipset,omitempty"`
Chipset string `url:"chipset,omitempty" json:"chipset,omitempty" validate:"omitempty,chipset"`
// Use Huge Pages to allocate RAM of the virtual machine. The system must be pre-configured by allocating Huge Pages on the physical node
// Required: false

View File

@@ -67,7 +67,7 @@ type CreateBlankRequest struct {
// Type of the emulated system, Q35 or i440fx
// Required: false
Chipset string `url:"chipset,omitempty" json:"chipset,omitempty"`
Chipset string `url:"chipset,omitempty" json:"chipset,omitempty" validate:"omitempty,chipset"`
}
// GetRAM returns RAM field values

View File

@@ -78,7 +78,7 @@ type MassCreateRequest struct {
// Type of the emulated system, Q35 or i440fx
// Required: false
Chipset string `url:"chipset,omitempty" json:"chipset,omitempty"`
Chipset string `url:"chipset,omitempty" json:"chipset,omitempty" validate:"omitempty,chipset"`
}
type asyncWrapperMassCreateRequest struct {

View File

@@ -22,12 +22,12 @@ type CreateRequest struct {
Name string `url:"name" json:"name" validate:"required"`
// External network to connect this load balancer to
// Required: true
ExtNetID int64 `url:"extnetId" json:"extnetId" validate:"required"`
// Required: true, can be 0
ExtNetID int64 `url:"extnetId" json:"extnetId"`
// Internal network (VINS) to connect this load balancer to
// Required: true
VINSID uint64 `url:"vinsId" json:"vinsId" validate:"required"`
// Required: true, can be 0
VINSID uint64 `url:"vinsId" json:"vinsId"`
// Start now Load balancer
// Required: true

View 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)
}

View 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
}

View 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
}

View 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
}

View 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
}

View 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
}

View 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
}

View 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
}

View 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
}

View 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
}

View 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
}

View 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
}

View 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
}

View 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
}

View 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
}

View 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"`
}

View 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
View 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)
}

View 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
}

View 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
}

View 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
}

View 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
}

View 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
}

View 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"`
}

View 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,
}
}