Compare commits
2 Commits
Author | SHA1 | Date |
---|---|---|
|
9192f307e1 | 3 weeks ago |
|
aee072c194 | 3 months ago |
@ -1,50 +0,0 @@
|
|||||||
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
|
|
||||||
}
|
|
@ -1,8 +0,0 @@
|
|||||||
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)
|
|
||||||
}
|
|
@ -1,57 +0,0 @@
|
|||||||
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
|
|
||||||
}
|
|
@ -1,53 +0,0 @@
|
|||||||
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
|
|
||||||
}
|
|
@ -1,53 +0,0 @@
|
|||||||
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
|
|
||||||
}
|
|
@ -1,53 +0,0 @@
|
|||||||
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
|
|
||||||
}
|
|
@ -1,53 +0,0 @@
|
|||||||
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
|
|
||||||
}
|
|
@ -1,53 +0,0 @@
|
|||||||
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
|
|
||||||
}
|
|
@ -1,57 +0,0 @@
|
|||||||
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
|
|
||||||
}
|
|
@ -1,57 +0,0 @@
|
|||||||
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
|
|
||||||
}
|
|
@ -1,57 +0,0 @@
|
|||||||
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
|
|
||||||
}
|
|
@ -1,57 +0,0 @@
|
|||||||
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
|
|
||||||
}
|
|
@ -1,57 +0,0 @@
|
|||||||
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
|
|
||||||
}
|
|
@ -1,57 +0,0 @@
|
|||||||
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
|
|
||||||
}
|
|
@ -1,57 +0,0 @@
|
|||||||
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
|
|
||||||
}
|
|
@ -1,57 +0,0 @@
|
|||||||
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
|
|
||||||
}
|
|
@ -1,77 +0,0 @@
|
|||||||
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
|
|
||||||
}
|
|
@ -1,40 +0,0 @@
|
|||||||
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"`
|
|
||||||
}
|
|
@ -1,15 +0,0 @@
|
|||||||
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,
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,8 +0,0 @@
|
|||||||
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)
|
|
||||||
}
|
|
@ -1,83 +0,0 @@
|
|||||||
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]
|
|
||||||
}
|
|
@ -1,134 +0,0 @@
|
|||||||
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))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,10 +0,0 @@
|
|||||||
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
|
|
||||||
}
|
|
@ -1,52 +0,0 @@
|
|||||||
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
|
|
||||||
}
|
|
@ -1,34 +0,0 @@
|
|||||||
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"`
|
|
||||||
}
|
|
@ -1,18 +0,0 @@
|
|||||||
// 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,
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,43 +0,0 @@
|
|||||||
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)
|
|
||||||
}
|
|
@ -0,0 +1,48 @@
|
|||||||
|
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
|
||||||
|
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue