parent
a267d35ddf
commit
f0dee6360a
@ -1,10 +0,0 @@
|
|||||||
package cloudapi
|
|
||||||
|
|
||||||
import (
|
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/stack"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Accessing the Stack method group
|
|
||||||
func (ca *CloudAPI) Stack() *stack.Stack {
|
|
||||||
return stack.New(ca.client)
|
|
||||||
}
|
|
||||||
@ -1,46 +0,0 @@
|
|||||||
package stack
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"encoding/json"
|
|
||||||
"net/http"
|
|
||||||
|
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
|
||||||
)
|
|
||||||
|
|
||||||
// GetRequest struct to get info of stack
|
|
||||||
type GetRequest struct {
|
|
||||||
// Find by ID
|
|
||||||
// Required: true
|
|
||||||
StackId uint64 `url:"stackId" json:"stackId" validate:"required"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get gets stack details by ID as an InfoStack struct
|
|
||||||
func (i Stack) Get(ctx context.Context, req GetRequest) (*InfoStack, error) {
|
|
||||||
res, err := i.GetRaw(ctx, req)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
info := InfoStack{}
|
|
||||||
|
|
||||||
err = json.Unmarshal(res, &info)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return &info, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetRaw gets stack details by ID as an array of bytes
|
|
||||||
func (i Stack) GetRaw(ctx context.Context, req GetRequest) ([]byte, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/stack/get"
|
|
||||||
|
|
||||||
res, err := i.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
|
||||||
return res, err
|
|
||||||
}
|
|
||||||
@ -1,10 +0,0 @@
|
|||||||
package stack
|
|
||||||
|
|
||||||
// IDs gets array of StackIDs from ListStacks struct
|
|
||||||
func (ls ListStacks) IDs() []uint64 {
|
|
||||||
res := make([]uint64, 0, len(ls.Data))
|
|
||||||
for _, s := range ls.Data {
|
|
||||||
res = append(res, s.ID)
|
|
||||||
}
|
|
||||||
return res
|
|
||||||
}
|
|
||||||
@ -1,71 +0,0 @@
|
|||||||
package stack
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"encoding/json"
|
|
||||||
"net/http"
|
|
||||||
|
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
|
||||||
)
|
|
||||||
|
|
||||||
// ListRequest struct to get list of stacks
|
|
||||||
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"`
|
|
||||||
|
|
||||||
// Find by type
|
|
||||||
// Required: false
|
|
||||||
Type string `url:"type,omitempty" json:"type,omitempty"`
|
|
||||||
|
|
||||||
// Find by status
|
|
||||||
// Required: false
|
|
||||||
Status string `url:"status,omitempty" json:"status,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 stacks as a ListStacks struct
|
|
||||||
func (i Stack) List(ctx context.Context, req ListRequest) (*ListStacks, error) {
|
|
||||||
|
|
||||||
res, err := i.ListRaw(ctx, req)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
list := ListStacks{}
|
|
||||||
|
|
||||||
err = json.Unmarshal(res, &list)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return &list, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// ListRaw gets list of stacks as an array of bytes
|
|
||||||
func (i Stack) ListRaw(ctx context.Context, req ListRequest) ([]byte, error) {
|
|
||||||
|
|
||||||
if err := validators.ValidateRequest(req); err != nil {
|
|
||||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/stack/list"
|
|
||||||
|
|
||||||
res, err := i.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
|
||||||
return res, err
|
|
||||||
}
|
|
||||||
@ -1,53 +0,0 @@
|
|||||||
package stack
|
|
||||||
|
|
||||||
// Main information about stack
|
|
||||||
type InfoStack struct {
|
|
||||||
// CPU allocation ratio
|
|
||||||
CPUAllocationRatio float64 `json:"cpu_allocation_ratio"`
|
|
||||||
|
|
||||||
// Descr
|
|
||||||
Descr string `json:"descr"`
|
|
||||||
|
|
||||||
// Drivers
|
|
||||||
Drivers []string `json:"drivers"`
|
|
||||||
|
|
||||||
// ID
|
|
||||||
ID uint64 `json:"id"`
|
|
||||||
|
|
||||||
// Mem allocation ratio
|
|
||||||
MemAllocationRatio float64 `json:"mem_allocation_ratio"`
|
|
||||||
|
|
||||||
// Name
|
|
||||||
Name string `json:"name"`
|
|
||||||
|
|
||||||
// Status
|
|
||||||
Status string `json:"status"`
|
|
||||||
|
|
||||||
// Type
|
|
||||||
Type string `json:"type"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// Information about stack in list
|
|
||||||
type ItemStack struct {
|
|
||||||
// ID
|
|
||||||
ID uint64 `json:"id"`
|
|
||||||
|
|
||||||
// Name
|
|
||||||
Name string `json:"name"`
|
|
||||||
|
|
||||||
// Status
|
|
||||||
Status string `json:"status"`
|
|
||||||
|
|
||||||
// Type
|
|
||||||
Type string `json:"type"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// List of stacks
|
|
||||||
type ListStacks struct {
|
|
||||||
|
|
||||||
//List
|
|
||||||
Data []ItemStack `json:"data"`
|
|
||||||
|
|
||||||
//Entry count
|
|
||||||
EntryCount uint64 `json:"entryCount"`
|
|
||||||
}
|
|
||||||
@ -1,16 +0,0 @@
|
|||||||
// Lists all the stack.
|
|
||||||
package stack
|
|
||||||
|
|
||||||
import "repository.basistech.ru/BASIS/decort-golang-sdk/interfaces"
|
|
||||||
|
|
||||||
// Structure for creating request to stack
|
|
||||||
type Stack struct {
|
|
||||||
client interfaces.Caller
|
|
||||||
}
|
|
||||||
|
|
||||||
// Builder for stack endpoint
|
|
||||||
func New(client interfaces.Caller) *Stack {
|
|
||||||
return &Stack{
|
|
||||||
client: client,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -0,0 +1,41 @@
|
|||||||
|
package compute
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"net/http"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ChangeReadOnlyRequest defines parameters for toggling read-only mode.
|
||||||
|
type ChangeReadOnlyRequest struct {
|
||||||
|
// Compute ID
|
||||||
|
// Required: true
|
||||||
|
ComputeID uint64 `url:"compute_id" json:"compute_id" validate:"required"`
|
||||||
|
|
||||||
|
// ReadOnly indicates whether the read-only mode is enabled
|
||||||
|
// Required: true
|
||||||
|
ReadOnly bool `url:"read_only" json:"read_only" validate:"required"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ChangeReadOnly toggles compute read-only mode.
|
||||||
|
func (c Compute) ChangeReadOnly(ctx context.Context, req ChangeReadOnlyRequest) (bool, error) {
|
||||||
|
if err := validators.ValidateRequest(req); err != nil {
|
||||||
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudbroker/compute/change_read_only"
|
||||||
|
|
||||||
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err := strconv.ParseBool(string(res))
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
@ -1,65 +0,0 @@
|
|||||||
package image
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"encoding/json"
|
|
||||||
"net/http"
|
|
||||||
|
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
|
||||||
)
|
|
||||||
|
|
||||||
// ListStacksRequest struct to get list of stack
|
|
||||||
type ListStacksRequest struct {
|
|
||||||
// Image ID
|
|
||||||
// Required: true
|
|
||||||
ImageID uint64 `url:"imageId" json:"imageId" validate:"required"`
|
|
||||||
|
|
||||||
// Page number
|
|
||||||
// Required: false
|
|
||||||
Page uint64 `url:"page,omitempty" json:"page,omitempty"`
|
|
||||||
|
|
||||||
// Page size
|
|
||||||
// Required: false
|
|
||||||
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
|
||||||
|
|
||||||
// Find by name
|
|
||||||
// Required: false
|
|
||||||
Name string `url:"name,omitempty" json:"name,omitempty"`
|
|
||||||
|
|
||||||
// Find by status
|
|
||||||
// Required: false
|
|
||||||
Status string `url:"status,omitempty" json:"status,omitempty"`
|
|
||||||
|
|
||||||
// Find by type
|
|
||||||
// Required: false
|
|
||||||
Type string `url:"type,omitempty" json:"type,omitempty"`
|
|
||||||
|
|
||||||
// Sort by one of supported fields, format +|-(field)
|
|
||||||
// Required: false
|
|
||||||
SortBy string `url:"sortBy,omitempty" json:"sortBy,omitempty" validate:"omitempty,sortBy"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// ListStacks gets list stack by image ID
|
|
||||||
func (i Image) ListStacks(ctx context.Context, req ListStacksRequest) (*ListStacks, error) {
|
|
||||||
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudbroker/image/listStacks"
|
|
||||||
|
|
||||||
res, err := i.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
list := ListStacks{}
|
|
||||||
|
|
||||||
err = json.Unmarshal(res, &list)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return &list, nil
|
|
||||||
}
|
|
||||||
@ -0,0 +1,36 @@
|
|||||||
|
package node
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
|
)
|
||||||
|
|
||||||
|
// SetCpuAllocationRatioRequest struct to set CPU allocation ratio
|
||||||
|
type SetCpuAllocationRatioRequest struct {
|
||||||
|
// Node ID
|
||||||
|
// Required: true
|
||||||
|
NodeID uint64 `url:"node_id" json:"node_id" validate:"required"`
|
||||||
|
|
||||||
|
// Allocation ratio (zero or positive value)
|
||||||
|
// Required: true
|
||||||
|
Ratio float64 `url:"ratio" json:"ratio" validate:"required"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetCpuAllocationRatio set CPU allocation ratio
|
||||||
|
func (i Node) SetCpuAllocationRatio(ctx context.Context, req SetCpuAllocationRatioRequest) error {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
return validators.ValidationErrors(validators.GetErrors(err))
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudbroker/node/set_cpu_allocation_ratio"
|
||||||
|
|
||||||
|
_, err = i.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
@ -0,0 +1,36 @@
|
|||||||
|
package node
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
|
)
|
||||||
|
|
||||||
|
// SetMemAllocationRatioRequest struct to set memory allocation ratio
|
||||||
|
type SetMemAllocationRatioRequest struct {
|
||||||
|
// Node ID
|
||||||
|
// Required: true
|
||||||
|
NodeID uint64 `url:"node_id" json:"node_id" validate:"required"`
|
||||||
|
|
||||||
|
// Allocation ratio (zero or positive value)
|
||||||
|
// Required: true
|
||||||
|
Ratio float64 `url:"ratio" json:"ratio" validate:"required"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetMemAllocationRatio set memory allocation ratio
|
||||||
|
func (i Node) SetMemAllocationRatio(ctx context.Context, req SetMemAllocationRatioRequest) error {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
return validators.ValidationErrors(validators.GetErrors(err))
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudbroker/node/set_mem_allocation_ratio"
|
||||||
|
|
||||||
|
_, err = i.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
@ -1,10 +0,0 @@
|
|||||||
package cloudbroker
|
|
||||||
|
|
||||||
import (
|
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/stack"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Accessing the Stack method group
|
|
||||||
func (cb *CloudBroker) Stack() *stack.Stack {
|
|
||||||
return stack.New(cb.client)
|
|
||||||
}
|
|
||||||
@ -1,46 +0,0 @@
|
|||||||
package stack
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"encoding/json"
|
|
||||||
"net/http"
|
|
||||||
|
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
|
||||||
)
|
|
||||||
|
|
||||||
// GetRequest struct to get list of stacks
|
|
||||||
type GetRequest struct {
|
|
||||||
// Find by ID
|
|
||||||
// Required: true
|
|
||||||
StackId uint64 `url:"stackId" json:"stackId" validate:"required"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get gets stack details by ID as an InfoStack struct
|
|
||||||
func (i Stack) Get(ctx context.Context, req GetRequest) (*InfoStack, error) {
|
|
||||||
res, err := i.GetRaw(ctx, req)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
info := InfoStack{}
|
|
||||||
|
|
||||||
err = json.Unmarshal(res, &info)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return &info, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetRaw gets stack details by ID as an array of bytes
|
|
||||||
func (i Stack) GetRaw(ctx context.Context, req GetRequest) ([]byte, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudbroker/stack/get"
|
|
||||||
|
|
||||||
res, err := i.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
|
||||||
return res, err
|
|
||||||
}
|
|
||||||
@ -1,10 +0,0 @@
|
|||||||
package stack
|
|
||||||
|
|
||||||
// IDs gets array of StackIDs from ListStacks struct
|
|
||||||
func (ls ListStacks) IDs() []uint64 {
|
|
||||||
res := make([]uint64, 0, len(ls.Data))
|
|
||||||
for _, s := range ls.Data {
|
|
||||||
res = append(res, s.ID)
|
|
||||||
}
|
|
||||||
return res
|
|
||||||
}
|
|
||||||
@ -1,72 +0,0 @@
|
|||||||
package stack
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"encoding/json"
|
|
||||||
"net/http"
|
|
||||||
|
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
|
||||||
)
|
|
||||||
|
|
||||||
// ListRequest struct to get list of stacks
|
|
||||||
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"`
|
|
||||||
|
|
||||||
// Find by type
|
|
||||||
// Required: false
|
|
||||||
Type string `url:"type,omitempty" json:"type,omitempty"`
|
|
||||||
|
|
||||||
// Find by status
|
|
||||||
// Required: false
|
|
||||||
Status string `url:"status,omitempty" json:"status,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 stacks as a ListStacks struct
|
|
||||||
func (i Stack) List(ctx context.Context, req ListRequest) (*ListStacks, error) {
|
|
||||||
|
|
||||||
res, err := i.ListRaw(ctx, req)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
list := ListStacks{}
|
|
||||||
|
|
||||||
err = json.Unmarshal(res, &list)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return &list, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// ListRaw gets list of stacks as an array of bytes
|
|
||||||
func (i Stack) ListRaw(ctx context.Context, req ListRequest) ([]byte, error) {
|
|
||||||
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudbroker/stack/list"
|
|
||||||
|
|
||||||
res, err := i.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
|
||||||
return res, err
|
|
||||||
}
|
|
||||||
@ -1,180 +0,0 @@
|
|||||||
package stack
|
|
||||||
|
|
||||||
// Main information about stack
|
|
||||||
type InfoStack struct {
|
|
||||||
// CKey
|
|
||||||
Ckey string `json:"_ckey"`
|
|
||||||
|
|
||||||
// Meta
|
|
||||||
Meta []interface{} `json:"_meta"`
|
|
||||||
|
|
||||||
//API URL
|
|
||||||
APIURL string `json:"apiUrl"`
|
|
||||||
|
|
||||||
//API key
|
|
||||||
Apikey string `json:"apikey"`
|
|
||||||
|
|
||||||
// App ID
|
|
||||||
AppID string `json:"appId"`
|
|
||||||
|
|
||||||
// CPU allocation ratio
|
|
||||||
CPUAllocationRatio float64 `json:"cpu_allocation_ratio"`
|
|
||||||
|
|
||||||
// Description
|
|
||||||
Description string `json:"desc"`
|
|
||||||
|
|
||||||
// Descr
|
|
||||||
Descr string `json:"descr"`
|
|
||||||
|
|
||||||
// Drivers
|
|
||||||
Drivers []string `json:"drivers"`
|
|
||||||
|
|
||||||
// Eco
|
|
||||||
Eco interface{} `json:"eco"`
|
|
||||||
|
|
||||||
// Error
|
|
||||||
Error uint64 `json:"error"`
|
|
||||||
|
|
||||||
// Grid ID
|
|
||||||
GID uint64 `json:"gid"`
|
|
||||||
|
|
||||||
// GID
|
|
||||||
GUID uint64 `json:"guid"`
|
|
||||||
|
|
||||||
// ID
|
|
||||||
ID uint64 `json:"id"`
|
|
||||||
|
|
||||||
// List image IDs
|
|
||||||
Images []uint64 `json:"images"`
|
|
||||||
|
|
||||||
// Login
|
|
||||||
Login string `json:"login"`
|
|
||||||
|
|
||||||
// Mem allocation ratio
|
|
||||||
MemAllocationRatio float64 `json:"mem_allocation_ratio"`
|
|
||||||
|
|
||||||
// Name
|
|
||||||
Name string `json:"name"`
|
|
||||||
|
|
||||||
// Packegas
|
|
||||||
Packages Packages `json:"packages"`
|
|
||||||
|
|
||||||
//Password
|
|
||||||
Password string `json:"passwd"`
|
|
||||||
|
|
||||||
// Reference ID
|
|
||||||
ReferenceID string `json:"referenceId"`
|
|
||||||
|
|
||||||
// Status
|
|
||||||
Status string `json:"status"`
|
|
||||||
|
|
||||||
// Type
|
|
||||||
Type string `json:"type"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// List of stacks
|
|
||||||
type ListStacks struct {
|
|
||||||
//List
|
|
||||||
Data []InfoStack `json:"data"`
|
|
||||||
|
|
||||||
//Entry count
|
|
||||||
EntryCount uint64 `json:"entryCount"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// Package
|
|
||||||
type Packages struct {
|
|
||||||
// LibGuestFSTools
|
|
||||||
LibGuestFSTools LibGuestFSTools `json:"libguestfs-tools"`
|
|
||||||
|
|
||||||
// LibvirtBin
|
|
||||||
LibvirtBin LibvirtBin `json:"libvirt-bin"`
|
|
||||||
|
|
||||||
// LibvirtDaemon
|
|
||||||
LibvirtDaemon LibvirtDaemon `json:"libvirt-daemon"`
|
|
||||||
|
|
||||||
// Lvm2Lockd
|
|
||||||
Lvm2Lockd Lvm2Lockd `json:"lvm2-lockd"`
|
|
||||||
|
|
||||||
// OpenvswitchCommon
|
|
||||||
OpenvswitchCommon OpenvswitchCommon `json:"openvswitch-common"`
|
|
||||||
|
|
||||||
// OpenvswitchSwitch
|
|
||||||
OpenvswitchSwitch OpenvswitchSwitch `json:"openvswitch-switch"`
|
|
||||||
|
|
||||||
// QemuSystemX86
|
|
||||||
QemuSystemX86 QemuSystemX86 `json:"qemu-system-x86"`
|
|
||||||
|
|
||||||
// Sanlock
|
|
||||||
Sanlock Sanlock `json:"sanlock"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// LibGuestFSTools
|
|
||||||
type LibGuestFSTools struct {
|
|
||||||
// InstalledSize
|
|
||||||
InstalledSize string `json:"installed_size"`
|
|
||||||
|
|
||||||
// Version
|
|
||||||
Ver string `json:"ver"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// LibvirtBin
|
|
||||||
type LibvirtBin struct {
|
|
||||||
// InstalledSize
|
|
||||||
InstalledSize string `json:"installed_size"`
|
|
||||||
|
|
||||||
// Version
|
|
||||||
Ver string `json:"ver"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type LibvirtDaemon struct {
|
|
||||||
// InstalledSize
|
|
||||||
InstalledSize string `json:"installed_size"`
|
|
||||||
|
|
||||||
// Version
|
|
||||||
Ver string `json:"ver"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// Lvm2Lockd
|
|
||||||
type Lvm2Lockd struct {
|
|
||||||
// InstalledSize
|
|
||||||
InstalledSize string `json:"installed_size"`
|
|
||||||
|
|
||||||
// Version
|
|
||||||
Ver string `json:"ver"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// OpenvswitchCommon
|
|
||||||
type OpenvswitchCommon struct {
|
|
||||||
// InstalledSize
|
|
||||||
InstalledSize string `json:"installed_size"`
|
|
||||||
|
|
||||||
// Version
|
|
||||||
Ver string `json:"ver"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// OpenvswitchSwitch
|
|
||||||
type OpenvswitchSwitch struct {
|
|
||||||
// InstalledSize
|
|
||||||
InstalledSize string `json:"installed_size"`
|
|
||||||
|
|
||||||
// Version
|
|
||||||
Ver string `json:"ver"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// QemuSystemX86
|
|
||||||
type QemuSystemX86 struct {
|
|
||||||
// InstalledSize
|
|
||||||
InstalledSize string `json:"installed_size"`
|
|
||||||
|
|
||||||
// Version
|
|
||||||
Ver string `json:"ver"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// Sanlock
|
|
||||||
type Sanlock struct {
|
|
||||||
// InstalledSize
|
|
||||||
InstalledSize string `json:"installed_size"`
|
|
||||||
|
|
||||||
// Version
|
|
||||||
Ver string `json:"ver"`
|
|
||||||
}
|
|
||||||
@ -1,44 +0,0 @@
|
|||||||
package stack
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"encoding/json"
|
|
||||||
"net/http"
|
|
||||||
|
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
|
||||||
)
|
|
||||||
|
|
||||||
// SetCpuAllocationRatioRequest struct to set CPU allocation ratio
|
|
||||||
type SetCpuAllocationRatioRequest struct {
|
|
||||||
// Stack ID
|
|
||||||
// Required: true
|
|
||||||
StackId uint64 `url:"stackId" json:"stackId" validate:"required"`
|
|
||||||
|
|
||||||
// Allocation ratio (zero or positive value)
|
|
||||||
// Required: true
|
|
||||||
Ratio float64 `url:"ratio" json:"ratio" validate:"required"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetCpuAllocationRatio set CPU allocation ratio
|
|
||||||
func (i Stack) SetCpuAllocationRatio(ctx context.Context, req SetCpuAllocationRatioRequest) (*InfoStack, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudbroker/stack/setCpuAllocationRatio"
|
|
||||||
|
|
||||||
res, err := i.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
info := InfoStack{}
|
|
||||||
|
|
||||||
err = json.Unmarshal(res, &info)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return &info, nil
|
|
||||||
}
|
|
||||||
@ -1,44 +0,0 @@
|
|||||||
package stack
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"encoding/json"
|
|
||||||
"net/http"
|
|
||||||
|
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
|
||||||
)
|
|
||||||
|
|
||||||
// SetMemAllocationRatioRequest struct to set memory allocation ratio
|
|
||||||
type SetMemAllocationRatioRequest struct {
|
|
||||||
// Stack ID
|
|
||||||
// Required: true
|
|
||||||
StackId uint64 `url:"stackId" json:"stackId" validate:"required"`
|
|
||||||
|
|
||||||
// Allocation ratio (zero or positive value)
|
|
||||||
// Required: true
|
|
||||||
Ratio float64 `url:"ratio" json:"ratio" validate:"required"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetMemAllocationRatio set memory allocation ratio
|
|
||||||
func (i Stack) SetMemAllocationRatio(ctx context.Context, req SetMemAllocationRatioRequest) (*InfoStack, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudbroker/stack/setMemAllocationRatio"
|
|
||||||
|
|
||||||
res, err := i.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
info := InfoStack{}
|
|
||||||
|
|
||||||
err = json.Unmarshal(res, &info)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return &info, nil
|
|
||||||
}
|
|
||||||
@ -1,15 +0,0 @@
|
|||||||
package stack
|
|
||||||
|
|
||||||
import "repository.basistech.ru/BASIS/decort-golang-sdk/interfaces"
|
|
||||||
|
|
||||||
// Structure for creating request to stack
|
|
||||||
type Stack struct {
|
|
||||||
client interfaces.Caller
|
|
||||||
}
|
|
||||||
|
|
||||||
// Builder for stack endpoint
|
|
||||||
func New(client interfaces.Caller) *Stack {
|
|
||||||
return &Stack{
|
|
||||||
client: client,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Loading…
Reference in new issue