v1.14.5
This commit is contained in:
42
pkg/cloudbroker/resource_optimizer/drs_add_nodes.go
Normal file
42
pkg/cloudbroker/resource_optimizer/drs_add_nodes.go
Normal file
@@ -0,0 +1,42 @@
|
||||
package resource_optimizer
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// DRSAddNodesRequest struct to add nodes to DRS
|
||||
type DRSAddNodesRequest struct {
|
||||
// ID of the zone
|
||||
// Required: true
|
||||
ZoneID uint64 `url:"zone_id" json:"zone_id" validate:"required"`
|
||||
|
||||
// IDs of the nodes to add
|
||||
// Required: true
|
||||
NodeIDs []uint64 `url:"node_ids" json:"node_ids" validate:"required"`
|
||||
}
|
||||
|
||||
// DRSAddNodes adds nodes to DRS in the specified zone
|
||||
func (ro ResourceOptimizer) DRSAddNodes(ctx context.Context, req DRSAddNodesRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/resource_optimizer/drs_add_nodes"
|
||||
|
||||
res, err := ro.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
|
||||
}
|
||||
58
pkg/cloudbroker/resource_optimizer/drs_create.go
Normal file
58
pkg/cloudbroker/resource_optimizer/drs_create.go
Normal file
@@ -0,0 +1,58 @@
|
||||
package resource_optimizer
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// DRSCreateRequest struct to create DRS
|
||||
type DRSCreateRequest struct {
|
||||
// ID of the zone
|
||||
// Required: true
|
||||
ZoneID uint64 `url:"zone_id" json:"zone_id" validate:"required"`
|
||||
|
||||
// Application ID
|
||||
// Required: true
|
||||
AppID string `url:"app_id" json:"app_id" validate:"required"`
|
||||
|
||||
// Application secret
|
||||
// Required: true
|
||||
AppSecret string `url:"app_secret" json:"app_secret" validate:"required"`
|
||||
|
||||
// Decort URL
|
||||
// Required: true
|
||||
DecortURL string `url:"decort_url" json:"decort_url" validate:"required"`
|
||||
|
||||
// SSO URL
|
||||
// Required: true
|
||||
SSOURL string `url:"sso_url" json:"sso_url" validate:"required"`
|
||||
|
||||
// DRS name
|
||||
// Required: true
|
||||
DRSName string `url:"drs_name" json:"drs_name" validate:"required"`
|
||||
}
|
||||
|
||||
// DRSCreate creates a new DRS in the specified zone
|
||||
func (ro ResourceOptimizer) DRSCreate(ctx context.Context, req DRSCreateRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/resource_optimizer/drs_create"
|
||||
|
||||
res, err := ro.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
|
||||
}
|
||||
42
pkg/cloudbroker/resource_optimizer/drs_del_nodes.go
Normal file
42
pkg/cloudbroker/resource_optimizer/drs_del_nodes.go
Normal file
@@ -0,0 +1,42 @@
|
||||
package resource_optimizer
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// DRSDelNodesRequest struct to delete nodes from DRS
|
||||
type DRSDelNodesRequest struct {
|
||||
// ID of the zone
|
||||
// Required: true
|
||||
ZoneID uint64 `url:"zone_id" json:"zone_id" validate:"required"`
|
||||
|
||||
// IDs of the nodes to delete
|
||||
// Required: true
|
||||
NodeIDs []uint64 `url:"node_ids" json:"node_ids" validate:"required"`
|
||||
}
|
||||
|
||||
// DRSDelNodes removes nodes from DRS in the specified zone
|
||||
func (ro ResourceOptimizer) DRSDelNodes(ctx context.Context, req DRSDelNodesRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/resource_optimizer/drs_del_nodes"
|
||||
|
||||
res, err := ro.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
|
||||
}
|
||||
38
pkg/cloudbroker/resource_optimizer/drs_remove.go
Normal file
38
pkg/cloudbroker/resource_optimizer/drs_remove.go
Normal file
@@ -0,0 +1,38 @@
|
||||
package resource_optimizer
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// DRSRemoveRequest struct to remove DRS
|
||||
type DRSRemoveRequest struct {
|
||||
// ID of the zone
|
||||
// Required: true
|
||||
ZoneID uint64 `url:"zone_id" json:"zone_id" validate:"required"`
|
||||
}
|
||||
|
||||
// DRSRemove removes DRS from the specified zone
|
||||
func (ro ResourceOptimizer) DRSRemove(ctx context.Context, req DRSRemoveRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/resource_optimizer/drs_remove"
|
||||
|
||||
res, err := ro.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
|
||||
}
|
||||
38
pkg/cloudbroker/resource_optimizer/drs_start.go
Normal file
38
pkg/cloudbroker/resource_optimizer/drs_start.go
Normal file
@@ -0,0 +1,38 @@
|
||||
package resource_optimizer
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// DRSStartRequest struct to start DRS
|
||||
type DRSStartRequest struct {
|
||||
// ID of the zone
|
||||
// Required: true
|
||||
ZoneID uint64 `url:"zone_id" json:"zone_id" validate:"required"`
|
||||
}
|
||||
|
||||
// DRSStart starts DRS in the specified zone
|
||||
func (ro ResourceOptimizer) DRSStart(ctx context.Context, req DRSStartRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/resource_optimizer/drs_start"
|
||||
|
||||
res, err := ro.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
|
||||
}
|
||||
38
pkg/cloudbroker/resource_optimizer/drs_stop.go
Normal file
38
pkg/cloudbroker/resource_optimizer/drs_stop.go
Normal file
@@ -0,0 +1,38 @@
|
||||
package resource_optimizer
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// DRSStopRequest struct to stop DRS
|
||||
type DRSStopRequest struct {
|
||||
// ID of the zone
|
||||
// Required: true
|
||||
ZoneID uint64 `url:"zone_id" json:"zone_id" validate:"required"`
|
||||
}
|
||||
|
||||
// DRSStop stops DRS in the specified zone
|
||||
func (ro ResourceOptimizer) DRSStop(ctx context.Context, req DRSStopRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/resource_optimizer/drs_stop"
|
||||
|
||||
res, err := ro.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
|
||||
}
|
||||
58
pkg/cloudbroker/resource_optimizer/drs_update.go
Normal file
58
pkg/cloudbroker/resource_optimizer/drs_update.go
Normal file
@@ -0,0 +1,58 @@
|
||||
package resource_optimizer
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// DRSUpdateRequest struct to update DRS
|
||||
type DRSUpdateRequest struct {
|
||||
// ID of the zone
|
||||
// Required: true
|
||||
ZoneID uint64 `url:"zone_id" json:"zone_id" validate:"required"`
|
||||
|
||||
// Application ID
|
||||
// Required: false
|
||||
AppID string `url:"app_id,omitempty" json:"app_id,omitempty"`
|
||||
|
||||
// Application secret
|
||||
// Required: false
|
||||
AppSecret string `url:"app_secret,omitempty" json:"app_secret,omitempty"`
|
||||
|
||||
// Decort URL
|
||||
// Required: false
|
||||
DecortURL string `url:"decort_url,omitempty" json:"decort_url,omitempty"`
|
||||
|
||||
// SSO URL
|
||||
// Required: false
|
||||
SSOURL string `url:"sso_url,omitempty" json:"sso_url,omitempty"`
|
||||
|
||||
// DRS name
|
||||
// Required: false
|
||||
DRSName string `url:"drs_name,omitempty" json:"drs_name,omitempty"`
|
||||
}
|
||||
|
||||
// DRSUpdate updates DRS configuration in the specified zone
|
||||
func (ro ResourceOptimizer) DRSUpdate(ctx context.Context, req DRSUpdateRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/resource_optimizer/drs_update"
|
||||
|
||||
res, err := ro.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
|
||||
}
|
||||
16
pkg/cloudbroker/resource_optimizer/resource_optimizer.go
Normal file
16
pkg/cloudbroker/resource_optimizer/resource_optimizer.go
Normal file
@@ -0,0 +1,16 @@
|
||||
// API Actor API for managing resource optimizer
|
||||
package resource_optimizer
|
||||
|
||||
import "repository.basistech.ru/BASIS/decort-golang-sdk/interfaces"
|
||||
|
||||
// Structure for creating request to resource_optimizer
|
||||
type ResourceOptimizer struct {
|
||||
client interfaces.Caller
|
||||
}
|
||||
|
||||
// Builder for resource_optimizer endpoints
|
||||
func New(client interfaces.Caller) *ResourceOptimizer {
|
||||
return &ResourceOptimizer{
|
||||
client: client,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user