v1.8.0
This commit is contained in:
38
pkg/cloudbroker/stack/get_logical_cores_count.go
Normal file
38
pkg/cloudbroker/stack/get_logical_cores_count.go
Normal file
@@ -0,0 +1,38 @@
|
||||
package stack
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// GetLogicalCoresCountRequest struct to get logical cores count by stack
|
||||
type GetLogicalCoresCountRequest struct {
|
||||
// Stack ID
|
||||
// Required: true
|
||||
StackId uint64 `url:"stackId" json:"stackId" validate:"required"`
|
||||
}
|
||||
|
||||
// GetLogicalCoresCount get logical cores count by stack
|
||||
func (i Stack) GetLogicalCoresCount(ctx context.Context, req GetLogicalCoresCountRequest) (uint64, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return 0, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/stack/getLogicalCoresCount"
|
||||
|
||||
res, err := i.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseUint(string(res), 10, 64)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
@@ -4,6 +4,8 @@ import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// ListRequest struct to get list of stacks
|
||||
@@ -24,6 +26,10 @@ type ListRequest struct {
|
||||
// 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"`
|
||||
@@ -35,6 +41,7 @@ type ListRequest struct {
|
||||
|
||||
// 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
|
||||
@@ -52,6 +59,12 @@ func (i Stack) List(ctx context.Context, req ListRequest) (*ListStacks, error) {
|
||||
|
||||
// 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)
|
||||
|
||||
44
pkg/cloudbroker/stack/set_cpu_allocation_ratio.go
Normal file
44
pkg/cloudbroker/stack/set_cpu_allocation_ratio.go
Normal file
@@ -0,0 +1,44 @@
|
||||
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"`
|
||||
}
|
||||
|
||||
// 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
|
||||
}
|
||||
44
pkg/cloudbroker/stack/set_mem_allocation_ratio.go
Normal file
44
pkg/cloudbroker/stack/set_mem_allocation_ratio.go
Normal file
@@ -0,0 +1,44 @@
|
||||
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"`
|
||||
}
|
||||
|
||||
// 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
|
||||
}
|
||||
Reference in New Issue
Block a user