v1.4.0
This commit is contained in:
45
pkg/cloudbroker/grid/set_cpu_allocation_parameter.go
Normal file
45
pkg/cloudbroker/grid/set_cpu_allocation_parameter.go
Normal file
@@ -0,0 +1,45 @@
|
||||
package grid
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
// Request for setting CPU allocation parameter
|
||||
type SetCPUAllocationParameterRequest struct {
|
||||
// Grid ID
|
||||
// Required: true
|
||||
GridID uint64 `url:"gridId" json:"gridId" validate:"required"`
|
||||
|
||||
// CPU allocation parameter.
|
||||
// If "strict" VM can't be run if not enough CPU resources.
|
||||
// "loose" allow running VM if not enough resources.
|
||||
// Required: true
|
||||
StrictLoose string `url:"strict_loose" json:"strict_loose" validate:"required,strict_loose"`
|
||||
}
|
||||
|
||||
// SetCPUAllocationParameter sets CPU allocation parameter
|
||||
func (g Grid) SetCPUAllocationParameter(ctx context.Context, req SetCPUAllocationParameterRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
for _, validationError := range validators.GetErrors(err) {
|
||||
return false, validators.ValidationError(validationError)
|
||||
}
|
||||
}
|
||||
|
||||
url := "/cloudbroker/grid/setCpuAllocationParameter"
|
||||
|
||||
res, err := g.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
|
||||
}
|
||||
43
pkg/cloudbroker/grid/set_cpu_allocation_ratio_for_vm.go
Normal file
43
pkg/cloudbroker/grid/set_cpu_allocation_ratio_for_vm.go
Normal file
@@ -0,0 +1,43 @@
|
||||
package grid
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
// Request for setting CPU allocation ratio for computes
|
||||
type SetCPUAllocationRatioForVMRequest struct {
|
||||
// Grid ID
|
||||
// Required: true
|
||||
GridID uint64 `url:"gridId" json:"gridId" validate:"required"`
|
||||
|
||||
// Default CPU allocation ratio for computes
|
||||
// Required: true
|
||||
Ratio float64 `url:"ratio" json:"ratio" validate:"required"`
|
||||
}
|
||||
|
||||
// SetCPUAllocationRatio sets CPU allocation ratio for computes
|
||||
func (g Grid) SetCPUAllocationRatioForVM(ctx context.Context, req SetCPUAllocationRatioForVMRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
for _, validationError := range validators.GetErrors(err) {
|
||||
return false, validators.ValidationError(validationError)
|
||||
}
|
||||
}
|
||||
|
||||
url := "/cloudbroker/grid/setCpuAllocationRatioForVM"
|
||||
|
||||
res, err := g.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
|
||||
}
|
||||
Reference in New Issue
Block a user