Compare commits
6 Commits
Author | SHA1 | Date |
---|---|---|
|
0c44daa241 | 1 week ago |
|
650b1c158b | 2 weeks ago |
|
8a101c6fcb | 3 weeks ago |
|
3f21a89e80 | 2 months ago |
|
cbce7f434f | 3 months ago |
|
e04dc42d2b | 4 months ago |
@ -1,14 +1,21 @@
|
||||
## Version 1.9.2
|
||||
## Version 1.11.2
|
||||
|
||||
### Добавлено
|
||||
|
||||
#### kvmvm
|
||||
#### bservice
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-196 | Опциональное поле `MTU` в структуре `CreateRequest/Interface` в cloudapi/kvmvm и cloudbroker/kvmvm |
|
||||
| BGOS-366 | Метод `Get` структура запроса `GetRequest` и структура ответа `RecordBasicService` в cloudbroker/bservice |
|
||||
| BGOS-366 | Метод `List` структура запроса `ListRequest` и структура ответа `ListBasicServices` в cloudbroker/bservice |
|
||||
|
||||
### Удалено
|
||||
#### prometheus
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-406 | Добавлена группа ручек `prometheus` в cloudapi |
|
||||
|
||||
### Исправлено
|
||||
|
||||
#### compute
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-197 | Readme-файл `README_EN.md` |
|
||||
| BGOS-433 | Исправлена ошибка валидации поля LoaderType для всех структур в cloudapi/compute и в cloudbroker/compute |
|
||||
|
@ -0,0 +1,50 @@
|
||||
package extnet
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// GetRequest struct to get information about reserved address or address poll
|
||||
type GetReservedIP struct {
|
||||
// AccountID of the account whose reservation information we want to receive
|
||||
// Required: true
|
||||
AccountID uint64 `url:"accountId" json:"accountId" validate:"required"`
|
||||
|
||||
// Field for specifying the ID of extnet whose reservation information we want to receive
|
||||
// Required: false
|
||||
ExtNetID uint64 `url:"extnetId,omitempty" json:"extnetId,omitempty"`
|
||||
}
|
||||
|
||||
// GetReservedIP gets information about reserved address or address poll as a slice of RecordReservedIP struct
|
||||
func (e ExtNet) GetReservedIP(ctx context.Context, req GetReservedIP) ([]RecordReservedIP, error) {
|
||||
res, err := e.GetReservedIPRaw(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
reservedIP := make([]RecordReservedIP, 0)
|
||||
|
||||
err = json.Unmarshal(res, &reservedIP)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return reservedIP, nil
|
||||
}
|
||||
|
||||
// GetRaw gets detailed information about external network as an array of bytes
|
||||
func (e ExtNet) GetReservedIPRaw(ctx context.Context, req GetReservedIP) ([]byte, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudapi/extnet/getReservedIp"
|
||||
|
||||
res, err := e.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
return res, err
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
package cloudapi
|
||||
|
||||
import "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/prometheus"
|
||||
|
||||
// Accessing the Resmon method group
|
||||
func (ca *CloudAPI) Prometheus() *prometheus.Prometheus {
|
||||
return prometheus.New(ca.client)
|
||||
}
|
@ -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: false
|
||||
Step uint64 `url:"step,omitempty" json:"step,omitempty"`
|
||||
|
||||
// Number of zeros after the decimal point
|
||||
// Required: false
|
||||
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 := "/cloudapi/prometheus/computeCPUload"
|
||||
|
||||
res, err := p.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
return res, err
|
||||
}
|
@ -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: false
|
||||
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 := "/cloudapi/prometheus/computeMemoryAvailable"
|
||||
|
||||
res, err := p.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
return res, err
|
||||
}
|
@ -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: false
|
||||
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 := "/cloudapi/prometheus/computeMemoryUnused"
|
||||
|
||||
res, err := p.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
return res, err
|
||||
}
|
@ -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: false
|
||||
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 := "/cloudapi/prometheus/computeMemoryUsable"
|
||||
|
||||
res, err := p.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
return res, err
|
||||
}
|
@ -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: false
|
||||
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 := "/cloudapi/prometheus/computeMemoryUsage"
|
||||
|
||||
res, err := p.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
return res, err
|
||||
}
|
@ -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: false
|
||||
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 := "/cloudapi/prometheus/computeMemoryUsed"
|
||||
|
||||
res, err := p.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
return res, err
|
||||
}
|
@ -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: false
|
||||
Step uint64 `url:"step,omitempty" json:"step,omitempty"`
|
||||
|
||||
// Number of zeros after the decimal point
|
||||
// Required: false
|
||||
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 := "/cloudapi/prometheus/computeReadBytes"
|
||||
|
||||
res, err := p.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
return res, err
|
||||
}
|
@ -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: false
|
||||
Step uint64 `url:"step,omitempty" json:"step,omitempty"`
|
||||
|
||||
// Number of zeros after the decimal point
|
||||
// Required: false
|
||||
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 := "/cloudapi/prometheus/computeReadRequests"
|
||||
|
||||
res, err := p.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
return res, err
|
||||
}
|
@ -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: false
|
||||
Step uint64 `url:"step,omitempty" json:"step,omitempty"`
|
||||
|
||||
// Number of zeros after the decimal point
|
||||
// Required: false
|
||||
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 := "/cloudapi/prometheus/computeReceiveBytes"
|
||||
|
||||
res, err := p.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
return res, err
|
||||
}
|
@ -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: false
|
||||
Step uint64 `url:"step,omitempty" json:"step,omitempty"`
|
||||
|
||||
// Number of zeros after the decimal point
|
||||
// Required: false
|
||||
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 := "/cloudapi/prometheus/computeReceivePackets"
|
||||
|
||||
res, err := p.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
return res, err
|
||||
}
|
@ -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: false
|
||||
Step uint64 `url:"step,omitempty" json:"step,omitempty"`
|
||||
|
||||
// Number of zeros after the decimal point
|
||||
// Required: false
|
||||
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 := "/cloudapi/prometheus/computeTransmitBytes"
|
||||
|
||||
res, err := p.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
return res, err
|
||||
}
|
@ -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: false
|
||||
Step uint64 `url:"step,omitempty" json:"step,omitempty"`
|
||||
|
||||
// Number of zeros after the decimal point
|
||||
// Required: false
|
||||
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 := "/cloudapi/prometheus/computeTransmitPackets"
|
||||
|
||||
res, err := p.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
return res, err
|
||||
}
|
@ -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: false
|
||||
Step uint64 `url:"step,omitempty" json:"step,omitempty"`
|
||||
|
||||
// Number of zeros after the decimal point
|
||||
// Required: false
|
||||
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 := "/cloudapi/prometheus/computeWriteBytes"
|
||||
|
||||
res, err := p.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
return res, err
|
||||
}
|
@ -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: false
|
||||
Step uint64 `url:"step,omitempty" json:"step,omitempty"`
|
||||
|
||||
// Number of zeros after the decimal point
|
||||
// Required: false
|
||||
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 := "/cloudapi/prometheus/computeWriteRequests"
|
||||
|
||||
res, err := p.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
return res, err
|
||||
}
|
@ -0,0 +1,77 @@
|
||||
package prometheus
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
const (
|
||||
ComputeCPULoad = "computeCPUload"
|
||||
ComputeMemoryUsage = "computeMemoryUsage"
|
||||
ComputeMemoryUsable = "computeMemoryUsable"
|
||||
ComputeMemoryUnused = "computeMemoryUnused"
|
||||
ComputeMemoryUsed = "computeMemoryUsed"
|
||||
ComputeMemoryAvailable = "computeMemoryAvailable"
|
||||
ComputeReadBytes = "computeReadBytes"
|
||||
ComputeReadRequests = "computeReadRequests"
|
||||
ComputeReceiveBytes = "computeReceiveBytes"
|
||||
ComputeTransmitBytes = "computeTransmitBytes"
|
||||
ComputeTransmitPackets = "computeTransmitPackets"
|
||||
ComputeWriteBytes = "computeWriteBytes"
|
||||
ComputeWriteRequests = "computeWriteRequests"
|
||||
)
|
||||
|
||||
type ComputesRequest struct {
|
||||
// List of compute IDs to fetch metrics for
|
||||
// Required: true
|
||||
ComputeIDs []uint64 `url:"computeIds" json:"computeIds" validate:"required"`
|
||||
|
||||
// List of compute IDs to fetch metrics for
|
||||
// Required: true
|
||||
MetricIDs []string `url:"metricIds" json:"metricIds" validate:"required"`
|
||||
|
||||
// Time to loads of statistic in seconds
|
||||
// Required: false
|
||||
ForLast uint64 `url:"forLast,omitempty" json:"forLast,omitempty"`
|
||||
|
||||
// The reading interval in seconds
|
||||
// Required: false
|
||||
Step uint64 `url:"step,omitempty" json:"step,omitempty"`
|
||||
|
||||
// Number of zeros after the decimal point
|
||||
// Required: false
|
||||
DecimalPlaces uint64 `url:"decimalPlaces,omitempty" json:"decimalPlaces,omitempty"`
|
||||
}
|
||||
|
||||
// Get multiple metrics for multiple compute instances
|
||||
func (p Prometheus) Computes(ctx context.Context, req ComputesRequest) (*ComputesData, error) {
|
||||
res, err := p.ComputesRaw(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
info := ComputesData{}
|
||||
|
||||
err = json.Unmarshal(res, &info)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &info, nil
|
||||
}
|
||||
|
||||
// GetRaw gets information about compute as an array of bytes
|
||||
func (p Prometheus) ComputesRaw(ctx context.Context, req ComputesRequest) ([]byte, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudapi/prometheus/computes"
|
||||
|
||||
res, err := p.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
return res, err
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
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"`
|
||||
}
|
||||
|
||||
// ComputesData represents an array of data points for computes
|
||||
type ComputesData []ItemCompute
|
||||
|
||||
// ItemCompute represents a single data of compute
|
||||
type ItemCompute struct {
|
||||
// Compute ID
|
||||
ComputeID uint64 `json:"computeId"`
|
||||
|
||||
// Array of metrics
|
||||
Metrics []ItemMetric `json:"metrics"`
|
||||
|
||||
// Error
|
||||
Error string `json:"error"`
|
||||
}
|
||||
|
||||
// ItemMetric represents a single data point of metric
|
||||
type ItemMetric struct {
|
||||
// Metric ID
|
||||
MetricID string `json:"metricId"`
|
||||
|
||||
// Data represents an array of data points
|
||||
Data PrometheusData `json:"data"`
|
||||
|
||||
// Error
|
||||
Error string `json:"error"`
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
package prometheus
|
||||
|
||||
import (
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/interfaces"
|
||||
)
|
||||
|
||||
type Prometheus struct {
|
||||
client interfaces.Caller
|
||||
}
|
||||
|
||||
func New(client interfaces.Caller) *Prometheus {
|
||||
return &Prometheus{
|
||||
client: client,
|
||||
}
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
package cloudapi
|
||||
|
||||
import "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/sep"
|
||||
|
||||
// Accessing the SEP method group
|
||||
func (cb *CloudAPI) SEP() *sep.SEP {
|
||||
return sep.New(cb.client)
|
||||
}
|
@ -0,0 +1,83 @@
|
||||
package sep
|
||||
|
||||
// FilterBySEPID returns ListAvailableSEP with the specified SEPID.
|
||||
func (sl ListAvailableSEP) FilterBySEPID(sepID uint64) ListAvailableSEP {
|
||||
predicate := func(sd SEPData) bool {
|
||||
return sd.SEPID == sepID
|
||||
}
|
||||
|
||||
return sl.FilterFunc(predicate)
|
||||
}
|
||||
|
||||
// FilterBySEPName returns ListAvailableSEP with the specified SEPName.
|
||||
func (sl ListAvailableSEP) FilterBySEPName(SEPName string) ListAvailableSEP {
|
||||
predicate := func(sd SEPData) bool {
|
||||
return sd.SEPName == SEPName
|
||||
}
|
||||
|
||||
return sl.FilterFunc(predicate)
|
||||
}
|
||||
|
||||
// FilterBySEPType returns ListAvailableSEP with the specified SEPType.
|
||||
func (sl ListAvailableSEP) FilterBySEPType(SEPType string) ListAvailableSEP {
|
||||
predicate := func(sd SEPData) bool {
|
||||
return sd.SEPType == SEPType
|
||||
}
|
||||
|
||||
return sl.FilterFunc(predicate)
|
||||
}
|
||||
|
||||
// FilterByPoolType returns ListAvailableSEP where at least one pool has the specified type.
|
||||
func (sl ListAvailableSEP) FilterByPoolType(poolType string) ListAvailableSEP {
|
||||
predicate := func(sd SEPData) bool {
|
||||
for _, pool := range sd.Pools {
|
||||
for _, pt := range pool.Types {
|
||||
if pt == poolType {
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
return sl.FilterFunc(predicate)
|
||||
}
|
||||
|
||||
// FilterBySystemPool returns ListAvailableSEP where at least one pool is a system pool.
|
||||
func (sl ListAvailableSEP) FilterBySystemPool(isSystem bool) ListAvailableSEP {
|
||||
predicate := func(sd SEPData) bool {
|
||||
for _, pool := range sd.Pools {
|
||||
if pool.System == isSystem {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
return sl.FilterFunc(predicate)
|
||||
}
|
||||
|
||||
// FilterFunc allows filtering ListAvailableSEP based on a user-defined predicate.
|
||||
func (sl ListAvailableSEP) FilterFunc(predicate func(SEPData) bool) ListAvailableSEP {
|
||||
var result ListAvailableSEP
|
||||
|
||||
for _, item := range sl.Data {
|
||||
if predicate(item) {
|
||||
result.Data = append(result.Data, item)
|
||||
}
|
||||
}
|
||||
|
||||
result.EntryCount = uint64(len(result.Data))
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
// FindOne returns the first found SEPData.
|
||||
// If nothing is found, returns an empty struct.
|
||||
func (sl ListAvailableSEP) FindOne() SEPData {
|
||||
if len(sl.Data) == 0 {
|
||||
return SEPData{}
|
||||
}
|
||||
|
||||
return sl.Data[0]
|
||||
}
|
@ -0,0 +1,134 @@
|
||||
package sep
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
var seps = ListAvailableSEP{
|
||||
EntryCount: 3,
|
||||
Data: []SEPData{
|
||||
{
|
||||
SEPID: 1,
|
||||
SEPName: "sep_1",
|
||||
SEPType: "TATLIN",
|
||||
Pools: []Pool{
|
||||
{
|
||||
Name: "pool_1",
|
||||
Types: []string{"DES"},
|
||||
System: false,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
SEPID: 2,
|
||||
SEPName: "sep_2",
|
||||
SEPType: "SHARED",
|
||||
Pools: []Pool{
|
||||
{
|
||||
Name: "pool_2",
|
||||
Types: []string{"DES"},
|
||||
System: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
SEPID: 3,
|
||||
SEPName: "sep_3",
|
||||
SEPType: "DES",
|
||||
Pools: []Pool{
|
||||
{
|
||||
Name: "pool_3",
|
||||
Types: []string{"DES"},
|
||||
System: false,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
func TestFilterBySEPID(t *testing.T) {
|
||||
actual := seps.FilterBySEPID(1).FindOne()
|
||||
|
||||
if actual.SEPID != 1 {
|
||||
t.Fatal("expected SEPID 1, found: ", actual.SEPID)
|
||||
}
|
||||
}
|
||||
|
||||
func TestFilterBySEPName(t *testing.T) {
|
||||
actual := seps.FilterBySEPName("sep_2").FindOne()
|
||||
|
||||
if actual.SEPName != "sep_2" {
|
||||
t.Fatal("expected SEPName 'sep_2', found: ", actual.SEPName)
|
||||
}
|
||||
}
|
||||
|
||||
func TestFilterBySEPType(t *testing.T) {
|
||||
actual := seps.FilterBySEPType("TATLIN").FindOne()
|
||||
|
||||
if actual.SEPType != "TATLIN" {
|
||||
t.Fatal("expected SEPType 'TATLIN', found: ", actual.SEPType)
|
||||
}
|
||||
}
|
||||
|
||||
func TestFilterByPoolType(t *testing.T) {
|
||||
actual := seps.FilterByPoolType("DES")
|
||||
|
||||
if len(actual.Data) != 3 {
|
||||
t.Fatal("expected 3 found, actual: ", len(actual.Data))
|
||||
}
|
||||
|
||||
for _, item := range actual.Data {
|
||||
found := false
|
||||
for _, pool := range item.Pools {
|
||||
for _, poolType := range pool.Types {
|
||||
if poolType == "DES" {
|
||||
found = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if found {
|
||||
break
|
||||
}
|
||||
}
|
||||
if !found {
|
||||
t.Fatal("expected Pool type 'DES', not found in SEP: ", item.SEPID)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestFilterBySystemPool(t *testing.T) {
|
||||
actual := seps.FilterBySystemPool(true)
|
||||
|
||||
if len(actual.Data) != 1 {
|
||||
t.Fatal("expected 1 found, actual: ", len(actual.Data))
|
||||
}
|
||||
|
||||
for _, item := range actual.Data {
|
||||
found := false
|
||||
for _, pool := range item.Pools {
|
||||
if pool.System {
|
||||
found = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if !found {
|
||||
t.Fatal("expected System pool, not found in SEP: ", item.SEPID)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestFilterFunc(t *testing.T) {
|
||||
actual := seps.FilterFunc(func(sd SEPData) bool {
|
||||
return len(sd.Pools) > 0
|
||||
})
|
||||
|
||||
if len(actual.Data) != 3 {
|
||||
t.Fatal("expected 3 found, actual: ", len(actual.Data))
|
||||
}
|
||||
|
||||
for _, item := range actual.Data {
|
||||
if len(item.Pools) == 0 {
|
||||
t.Fatal("expected Pools to contain at least 1 element, found: ", len(item.Pools))
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
package sep
|
||||
|
||||
// IDs gets array of SEPIDs from ListSEP struct
|
||||
func (ls ListAvailableSEP) IDs() []uint64 {
|
||||
res := make([]uint64, 0, len(ls.Data))
|
||||
for _, s := range ls.Data {
|
||||
res = append(res, s.SEPID)
|
||||
}
|
||||
return res
|
||||
}
|
@ -0,0 +1,52 @@
|
||||
package sep
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// ListAvailableSEPAndPoolsRequest struct to get dict with entry count and list of dict with SEPs and pools details accessible by the Account and RG
|
||||
type ListAvailableSEPAndPoolsRequest struct {
|
||||
// Account ID
|
||||
// Required: true
|
||||
AccountID uint64 `url:"account_id" json:"account_id" validate:"required"`
|
||||
|
||||
// RG ID
|
||||
// Required: false
|
||||
RGID uint64 `url:"rg_id,omitempty" json:"rg_id,omitempty"`
|
||||
}
|
||||
|
||||
// ListAvailableSEPAndPools get dict with entry count and list of dict with SEPs and pools details accessible by the Account and RG
|
||||
func (s SEP) ListAvailableSEPAndPools(ctx context.Context, req ListAvailableSEPAndPoolsRequest) (*ListAvailableSEP, error) {
|
||||
|
||||
res, err := s.ListAvailableSEPAndPoolsRaw(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
list := ListAvailableSEP{}
|
||||
|
||||
err = json.Unmarshal(res, &list)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &list, nil
|
||||
}
|
||||
|
||||
// ListRaw gets list as an array of bytes
|
||||
func (s SEP) ListAvailableSEPAndPoolsRaw(ctx context.Context, req ListAvailableSEPAndPoolsRequest) ([]byte, error) {
|
||||
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudapi/sep/listAvailableSepAndPools"
|
||||
|
||||
res, err := s.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
return res, err
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
package sep
|
||||
|
||||
type Pool struct {
|
||||
// Pool name
|
||||
Name string `json:"name"`
|
||||
|
||||
// Pool types
|
||||
Types []string `json:"types"`
|
||||
|
||||
// System
|
||||
System bool `json:"system"`
|
||||
}
|
||||
|
||||
type SEPData struct {
|
||||
// SEP ID
|
||||
SEPID uint64 `json:"sepId"`
|
||||
|
||||
// SEP name
|
||||
SEPName string `json:"sepName"`
|
||||
|
||||
// Sep type
|
||||
SEPType string `json:"sepType"`
|
||||
|
||||
// Pools
|
||||
Pools []Pool `json:"pools"`
|
||||
}
|
||||
|
||||
type ListAvailableSEP struct {
|
||||
// Entry count
|
||||
EntryCount uint64 `json:"entryCount"`
|
||||
|
||||
// Data
|
||||
Data []SEPData `json:"data"`
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
// Operator actions for handling interventions on a storage endpoint provider
|
||||
package sep
|
||||
|
||||
import (
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/interfaces"
|
||||
)
|
||||
|
||||
// Structure for creating request to storage endpoint provider
|
||||
type SEP struct {
|
||||
client interfaces.Caller
|
||||
}
|
||||
|
||||
// Builder for SEP endpoints
|
||||
func New(client interfaces.Caller) *SEP {
|
||||
return &SEP{
|
||||
client: client,
|
||||
}
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
package sep
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/serialization"
|
||||
)
|
||||
|
||||
// Serialize returns JSON-serialized []byte. Used as a wrapper over json.Marshal and json.MarshalIndent functions.
|
||||
//
|
||||
// In order to serialize with indent make sure to follow these guidelines:
|
||||
// - First argument -> prefix
|
||||
// - Second argument -> indent
|
||||
func (lsep ListAvailableSEP) Serialize(params ...string) (serialization.Serialized, error) {
|
||||
if len(lsep.Data) == 0 {
|
||||
return []byte{}, nil
|
||||
}
|
||||
|
||||
if len(params) > 1 {
|
||||
prefix := params[0]
|
||||
indent := params[1]
|
||||
|
||||
return json.MarshalIndent(lsep, prefix, indent)
|
||||
}
|
||||
|
||||
return json.Marshal(lsep)
|
||||
}
|
||||
|
||||
// Serialize returns JSON-serialized []byte. Used as a wrapper over json.Marshal and json.MarshalIndent functions.
|
||||
//
|
||||
// In order to serialize with indent make sure to follow these guidelines:
|
||||
// - First argument -> prefix
|
||||
// - Second argument -> indent
|
||||
func (rsep SEPData) Serialize(params ...string) (serialization.Serialized, error) {
|
||||
if len(params) > 1 {
|
||||
prefix := params[0]
|
||||
indent := params[1]
|
||||
|
||||
return json.MarshalIndent(rsep, prefix, indent)
|
||||
}
|
||||
|
||||
return json.Marshal(rsep)
|
||||
}
|
@ -1,48 +0,0 @@
|
||||
package apiaccess
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// ListDeletedRequest struct for getting list of all deleted apiaccess instances.
|
||||
type ListDeletedRequest struct {
|
||||
// Sort by one of supported fields, format +|-(field)
|
||||
// Required: false
|
||||
SortBy string `url:"sortBy,omitempty" json:"sortBy,omitempty" validate:"omitempty,sortBy"`
|
||||
|
||||
// Page number.
|
||||
// Required: false
|
||||
Page uint64 `url:"page,omitempty" json:"page,omitempty"`
|
||||
|
||||
// Page size.
|
||||
// Required: false
|
||||
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
||||
}
|
||||
|
||||
// ListDeleted gets list of all deleted apiaccess instances.
|
||||
func (a APIAccess) ListDeleted(ctx context.Context, req ListDeletedRequest) (*ListAPIAccess, error) {
|
||||
|
||||
if err := validators.ValidateRequest(req); err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/apiaccess/listDeleted"
|
||||
|
||||
info := ListAPIAccess{}
|
||||
|
||||
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err = json.Unmarshal(res, &info)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &info, nil
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
package cloudbroker
|
||||
|
||||
import "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/bservice"
|
||||
|
||||
// Accessing the BService method group
|
||||
func (ca *CloudBroker) BService() *bservice.BService {
|
||||
return bservice.New(ca.client)
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
package bservice
|
||||
|
||||
import "repository.basistech.ru/BASIS/decort-golang-sdk/interfaces"
|
||||
|
||||
// Structure for creating request to bservice
|
||||
type BService struct {
|
||||
client interfaces.Caller
|
||||
}
|
||||
|
||||
// Builder for bservice endpoints
|
||||
func New(client interfaces.Caller) *BService {
|
||||
return &BService{
|
||||
client,
|
||||
}
|
||||
}
|
@ -0,0 +1,71 @@
|
||||
package bservice
|
||||
|
||||
// FilterByID returns ListBasicServices with specified ID.
|
||||
func (lbs ListBasicServices) FilterByID(id uint64) ListBasicServices {
|
||||
predicate := func(ibs ItemBasicService) bool {
|
||||
return ibs.ID == id
|
||||
}
|
||||
|
||||
return lbs.FilterFunc(predicate)
|
||||
}
|
||||
|
||||
// FilterByName returns ListBasicServices with specified Name.
|
||||
func (lbs ListBasicServices) FilterByName(name string) ListBasicServices {
|
||||
predicate := func(ibs ItemBasicService) bool {
|
||||
return ibs.Name == name
|
||||
}
|
||||
|
||||
return lbs.FilterFunc(predicate)
|
||||
}
|
||||
|
||||
// FilterByRGID returns ListBasicServices with specified RGID.
|
||||
func (lbs ListBasicServices) FilterByRGID(rgID uint64) ListBasicServices {
|
||||
predicate := func(ibs ItemBasicService) bool {
|
||||
return ibs.RGID == rgID
|
||||
}
|
||||
|
||||
return lbs.FilterFunc(predicate)
|
||||
}
|
||||
|
||||
// FilterByStatus returns ListBasicServices with specified Status.
|
||||
func (lbs ListBasicServices) FilterByStatus(status string) ListBasicServices {
|
||||
predicate := func(ibs ItemBasicService) bool {
|
||||
return ibs.Status == status
|
||||
}
|
||||
|
||||
return lbs.FilterFunc(predicate)
|
||||
}
|
||||
|
||||
// FilterByTechStatus returns ListBasicServices with specified TechStatus.
|
||||
func (lbs ListBasicServices) FilterByTechStatus(techStatus string) ListBasicServices {
|
||||
predicate := func(ibs ItemBasicService) bool {
|
||||
return ibs.TechStatus == techStatus
|
||||
}
|
||||
|
||||
return lbs.FilterFunc(predicate)
|
||||
}
|
||||
|
||||
// FilterFunc allows filtering ListResourceGroups based on a user-specified predicate.
|
||||
func (lbs ListBasicServices) FilterFunc(predicate func(ItemBasicService) bool) ListBasicServices {
|
||||
var result ListBasicServices
|
||||
|
||||
for _, item := range lbs.Data {
|
||||
if predicate(item) {
|
||||
result.Data = append(result.Data, item)
|
||||
}
|
||||
}
|
||||
|
||||
result.EntryCount = uint64(len(lbs.Data))
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
// FindOne returns first found ItemBasicService
|
||||
// If none was found, returns an empty struct.
|
||||
func (lbs ListBasicServices) FindOne() ItemBasicService {
|
||||
if lbs.EntryCount == 0 {
|
||||
return ItemBasicService{}
|
||||
}
|
||||
|
||||
return lbs.Data[0]
|
||||
}
|
@ -0,0 +1,155 @@
|
||||
package bservice
|
||||
|
||||
import "testing"
|
||||
|
||||
var bservices = ListBasicServices{
|
||||
Data: []ItemBasicService{
|
||||
{
|
||||
AccountID: 1,
|
||||
AccountName: "std_1",
|
||||
BaseDomain: "",
|
||||
CreatedBy: "sample_user_1@decs3o",
|
||||
CreatedTime: 1677743675,
|
||||
DeletedBy: "",
|
||||
DeletedTime: 0,
|
||||
GID: 212,
|
||||
Groups: []uint64{},
|
||||
GUID: 1,
|
||||
ID: 1,
|
||||
Name: "bservice_1",
|
||||
ParentSrvID: 0,
|
||||
ParentSrvType: "",
|
||||
RGID: 7971,
|
||||
RGName: "rg_1",
|
||||
SSHUser: "",
|
||||
Status: "CREATED",
|
||||
TechStatus: "STOPPED",
|
||||
UpdatedBy: "",
|
||||
UpdatedTime: 0,
|
||||
UserManaged: true,
|
||||
},
|
||||
{
|
||||
AccountID: 2,
|
||||
AccountName: "std_2",
|
||||
BaseDomain: "",
|
||||
CreatedBy: "sample_user_1@decs3o",
|
||||
CreatedTime: 1677743736,
|
||||
DeletedBy: "",
|
||||
DeletedTime: 0,
|
||||
GID: 212,
|
||||
Groups: []uint64{},
|
||||
GUID: 2,
|
||||
ID: 2,
|
||||
Name: "bservice_2",
|
||||
ParentSrvID: 0,
|
||||
ParentSrvType: "",
|
||||
RGID: 7972,
|
||||
RGName: "rg_2",
|
||||
SSHUser: "",
|
||||
Status: "CREATED",
|
||||
TechStatus: "STOPPED",
|
||||
UpdatedBy: "",
|
||||
UpdatedTime: 0,
|
||||
UserManaged: true,
|
||||
},
|
||||
{
|
||||
AccountID: 3,
|
||||
AccountName: "std_3",
|
||||
BaseDomain: "",
|
||||
CreatedBy: "sample_user_2@decs3o",
|
||||
CreatedTime: 1677743830,
|
||||
DeletedBy: "",
|
||||
DeletedTime: 0,
|
||||
GID: 212,
|
||||
Groups: []uint64{},
|
||||
GUID: 3,
|
||||
ID: 3,
|
||||
Name: "bservice_3",
|
||||
ParentSrvID: 0,
|
||||
ParentSrvType: "",
|
||||
RGID: 7973,
|
||||
RGName: "rg_3",
|
||||
SSHUser: "",
|
||||
Status: "ENABLED",
|
||||
TechStatus: "STARTED",
|
||||
UpdatedBy: "",
|
||||
UpdatedTime: 0,
|
||||
UserManaged: true,
|
||||
},
|
||||
},
|
||||
EntryCount: 3,
|
||||
}
|
||||
|
||||
func TestFilterByID(t *testing.T) {
|
||||
actual := bservices.FilterByID(1).FindOne()
|
||||
|
||||
if actual.ID != 1 {
|
||||
t.Fatal("expected ID 1, found: ", actual.ID)
|
||||
}
|
||||
}
|
||||
|
||||
func TestFilterByName(t *testing.T) {
|
||||
actual := bservices.FilterByName("bservice_3").FindOne()
|
||||
|
||||
if actual.Name != "bservice_3" {
|
||||
t.Fatal("expected Name 'bservice_3', found: ", actual.Name)
|
||||
}
|
||||
}
|
||||
|
||||
func TestFilterByRGID(t *testing.T) {
|
||||
actual := bservices.FilterByRGID(7971).FindOne()
|
||||
|
||||
if actual.RGID != 7971 {
|
||||
t.Fatal("expected RGID 7971, found: ", actual.RGID)
|
||||
}
|
||||
}
|
||||
|
||||
func TestFilterByStatus(t *testing.T) {
|
||||
actual := bservices.FilterByStatus("CREATED")
|
||||
|
||||
if len(actual.Data) != 2 {
|
||||
t.Fatal("expected 2 found, actual: ", len(actual.Data))
|
||||
}
|
||||
|
||||
for _, item := range actual.Data {
|
||||
if item.Status != "CREATED" {
|
||||
t.Fatal("expected Status 'CREATED', found: ", item.Status)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestFilterByTechStatus(t *testing.T) {
|
||||
actual := bservices.FilterByTechStatus("STOPPED")
|
||||
|
||||
if len(actual.Data) != 2 {
|
||||
t.Fatal("expected 2 found, actual: ", len(actual.Data))
|
||||
}
|
||||
|
||||
for _, item := range actual.Data {
|
||||
if item.TechStatus != "STOPPED" {
|
||||
t.Fatal("expected TechStatus 'STOPPED', found: ", item.TechStatus)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestFilterFunc(t *testing.T) {
|
||||
actual := bservices.FilterFunc(func(ibs ItemBasicService) bool {
|
||||
return ibs.CreatedBy == "sample_user_2@decs3o"
|
||||
})
|
||||
|
||||
if len(actual.Data) > 1 {
|
||||
t.Fatal("expected 1 found, actual: ", len(actual.Data))
|
||||
}
|
||||
|
||||
if actual.FindOne().CreatedBy != "sample_user_2@decs3o" {
|
||||
t.Fatal("expected 'sample_user_2@decs3o', found: ", actual.FindOne().CreatedBy)
|
||||
}
|
||||
}
|
||||
|
||||
func TestSortByCreatedTime(t *testing.T) {
|
||||
actual := bservices.SortByCreatedTime(true)
|
||||
|
||||
if actual.Data[0].CreatedTime != 1677743830 || actual.Data[2].CreatedTime != 1677743675 {
|
||||
t.Fatal("expected descending order, found ascending")
|
||||
}
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
package bservice
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// GetRequest struct to get detailed information about service
|
||||
type GetRequest struct {
|
||||
// ID of the service to query information
|
||||
// Required: true
|
||||
ServiceID uint64 `url:"serviceId" json:"serviceId" validate:"required"`
|
||||
}
|
||||
|
||||
// Get gets detailed specifications for the BasicService as a RecordBasicService struct
|
||||
func (b BService) Get(ctx context.Context, req GetRequest) (*RecordBasicService, error) {
|
||||
res, err := b.GetRaw(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
info := RecordBasicService{}
|
||||
|
||||
err = json.Unmarshal(res, &info)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &info, nil
|
||||
}
|
||||
|
||||
// GetRaw gets detailed specifications for the BasicService as an array of bytes
|
||||
func (b BService) GetRaw(ctx context.Context, req GetRequest) ([]byte, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/bservice/get"
|
||||
|
||||
res, err := b.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
return res, err
|
||||
}
|
@ -0,0 +1,87 @@
|
||||
package bservice
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// ListRequest struct to get list of BasicService instances
|
||||
type ListRequest struct {
|
||||
// Find by ID
|
||||
// Required: false
|
||||
ByID uint64 `url:"by_id,omitempty" json:"by_id,omitempty"`
|
||||
|
||||
// Find by name
|
||||
// Required: false
|
||||
Name string `url:"name,omitempty" json:"name,omitempty"`
|
||||
|
||||
// ID of the account to query for BasicService instances
|
||||
// Required: false
|
||||
AccountID uint64 `url:"accountId,omitempty" json:"accountId,omitempty"`
|
||||
|
||||
// Find by resource group name
|
||||
// Required: false
|
||||
RGName string `url:"rgName,omitempty" json:"rgName,omitempty"`
|
||||
|
||||
// ID of the resource group to query for BasicService instances
|
||||
// Required: false
|
||||
RGID uint64 `url:"rgId,omitempty" json:"rgId,omitempty"`
|
||||
|
||||
// Find by tech status
|
||||
// Required: false
|
||||
TechStatus string `url:"techStatus,omitempty" json:"techStatus,omitempty"`
|
||||
|
||||
// Find by status
|
||||
// Required: false
|
||||
Status string `url:"status,omitempty" json:"status,omitempty"`
|
||||
|
||||
// Find by account name
|
||||
// Required: false
|
||||
AccountName string `url:"accountName,omitempty" json:"accountName,omitempty"`
|
||||
|
||||
// Sort by one of supported fields, format +|-(field)
|
||||
// Required: false
|
||||
SortBy string `url:"sortBy,omitempty" json:"sortBy,omitempty" validate:"omitempty,sortBy"`
|
||||
|
||||
// Page number
|
||||
// Required: false
|
||||
Page uint64 `url:"page,omitempty" json:"page,omitempty"`
|
||||
|
||||
// Page size
|
||||
// Required: false
|
||||
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
||||
}
|
||||
|
||||
// List gets list of BasicService instances associated with the specified Resource Group as a ListBasicServices struct
|
||||
func (b BService) List(ctx context.Context, req ListRequest) (*ListBasicServices, error) {
|
||||
|
||||
res, err := b.ListRaw(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
list := ListBasicServices{}
|
||||
|
||||
err = json.Unmarshal(res, &list)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &list, nil
|
||||
}
|
||||
|
||||
// ListRaw gets list of BasicService instances associated with the specified Resource Group as an array of bytes
|
||||
func (b BService) ListRaw(ctx context.Context, req ListRequest) ([]byte, error) {
|
||||
|
||||
if err := validators.ValidateRequest(req); err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/bservice/list"
|
||||
|
||||
res, err := b.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
return res, err
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue