v1.8.0
This commit is contained in:
@@ -10,8 +10,6 @@ import (
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
type Params []string
|
||||
|
||||
// CreateRequest struct to create load balancer
|
||||
type CreateRequest struct {
|
||||
// ID of the resource group where this load balancer instance will be located
|
||||
@@ -33,7 +31,7 @@ type CreateRequest struct {
|
||||
|
||||
// Custom sysctl values for Load Balancer instance. Applied on boot
|
||||
// Required: false
|
||||
SysctlParams Params `url:"-" json:"sysctlParams,omitempty" validate:"omitempty,dive"`
|
||||
SysctlParams []map[string]interface{} `url:"-" json:"sysctlParams,omitempty" validate:"omitempty,dive"`
|
||||
|
||||
// Use Highly Available schema for LB deploy
|
||||
// Required: false
|
||||
@@ -68,14 +66,12 @@ func (lb LB) Create(ctx context.Context, req CreateRequest) (uint64, error) {
|
||||
|
||||
if len(req.SysctlParams) != 0 {
|
||||
params = make([]string, 0, len(req.SysctlParams))
|
||||
|
||||
for r := range req.SysctlParams {
|
||||
b, err := json.Marshal(req.SysctlParams[r])
|
||||
for _, m := range req.SysctlParams {
|
||||
encodeStr, err := json.Marshal(m)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
params = append(params, string(b))
|
||||
params = append(params, string(encodeStr))
|
||||
}
|
||||
} else {
|
||||
params = []string{}
|
||||
|
||||
@@ -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 load balancers
|
||||
@@ -18,7 +20,7 @@ type ListRequest struct {
|
||||
|
||||
// Find by account ID
|
||||
// Required: false
|
||||
AccountID uint64 `url:"accountID,omitempty" json:"accountID,omitempty"`
|
||||
AccountID uint64 `url:"accountId,omitempty" json:"accountId,omitempty"`
|
||||
|
||||
// Find by resource group ID
|
||||
// Required: false
|
||||
@@ -44,6 +46,10 @@ type ListRequest struct {
|
||||
// Required: false
|
||||
IncludeDeleted bool `url:"includedeleted,omitempty" json:"includedeleted,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"`
|
||||
@@ -55,6 +61,7 @@ type ListRequest struct {
|
||||
|
||||
// List gets list of all load balancers as a ListLB struct
|
||||
func (lb LB) List(ctx context.Context, req ListRequest) (*ListLB, error) {
|
||||
|
||||
res, err := lb.ListRaw(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -72,6 +79,12 @@ func (lb LB) List(ctx context.Context, req ListRequest) (*ListLB, error) {
|
||||
|
||||
// ListRaw gets list of all load balancers as an array of bytes
|
||||
func (lb LB) ListRaw(ctx context.Context, req ListRequest) ([]byte, error) {
|
||||
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/lb/list"
|
||||
|
||||
res, err := lb.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
|
||||
@@ -4,6 +4,8 @@ import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// ListDeletedRequest struct to get list of deleted load balancers
|
||||
@@ -18,7 +20,7 @@ type ListDeletedRequest struct {
|
||||
|
||||
// Find by account ID
|
||||
// Required: false
|
||||
AccountID uint64 `url:"accountID,omitempty" json:"accountID,omitempty"`
|
||||
AccountID uint64 `url:"accountId,omitempty" json:"accountId,omitempty"`
|
||||
|
||||
// Find by resource group ID
|
||||
// Required: false
|
||||
@@ -36,6 +38,10 @@ type ListDeletedRequest struct {
|
||||
// Required: false
|
||||
BackIP string `url:"backIp,omitempty" json:"backIp,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"`
|
||||
@@ -47,6 +53,12 @@ type ListDeletedRequest struct {
|
||||
|
||||
// ListDeleted gets list of deleted load balancers
|
||||
func (lb LB) ListDeleted(ctx context.Context, req ListDeletedRequest) (*ListLB, error) {
|
||||
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/lb/listDeleted"
|
||||
|
||||
res, err := lb.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
|
||||
@@ -192,6 +192,12 @@ type RecordLB struct {
|
||||
// Image ID
|
||||
ImageID uint64 `json:"imageId"`
|
||||
|
||||
// Manager Id
|
||||
ManagerId uint64 `json:"managerId"`
|
||||
|
||||
// Manager Type
|
||||
ManagerType string `json:"managerType"`
|
||||
|
||||
// Milestones
|
||||
Milestones uint64 `json:"milestones"`
|
||||
|
||||
@@ -219,6 +225,9 @@ type RecordLB struct {
|
||||
// Tech status
|
||||
TechStatus string `json:"techStatus"`
|
||||
|
||||
// User Managed flag
|
||||
UserManaged bool `json:"userManaged"`
|
||||
|
||||
// VINS ID
|
||||
VINSID uint64 `json:"vinsId"`
|
||||
}
|
||||
@@ -276,12 +285,21 @@ type ItemLBList struct {
|
||||
// ID
|
||||
ID uint64 `json:"id"`
|
||||
|
||||
// ManagerId
|
||||
ManagerId uint64 `json:"managerId"`
|
||||
|
||||
// Name
|
||||
ManagerType string `json:"managerType"`
|
||||
|
||||
// Milestones
|
||||
Milestones uint64 `json:"milestones"`
|
||||
|
||||
// Name
|
||||
Name string `json:"name"`
|
||||
|
||||
// PartK8s
|
||||
PartK8s bool `json:"partK8s"`
|
||||
|
||||
// Primary node
|
||||
PrimaryNode Node `json:"primaryNode"`
|
||||
|
||||
@@ -309,6 +327,9 @@ type ItemLBList struct {
|
||||
// Updated time
|
||||
UpdatedTime uint64 `json:"updatedTime"`
|
||||
|
||||
// User managed flag
|
||||
UserManaged bool `json:"userManaged"`
|
||||
|
||||
// VINS ID
|
||||
VINSID uint64 `json:"vinsId"`
|
||||
}
|
||||
|
||||
@@ -13,6 +13,11 @@ type RestartRequest struct {
|
||||
// ID of the load balancer instance to restart
|
||||
// Required: true
|
||||
LBID uint64 `url:"lbId" json:"lbId" validate:"required"`
|
||||
|
||||
// restart secondary and primary nodes sequentially in HA mode
|
||||
// Default: true
|
||||
// Required: false
|
||||
Safe bool `url:"safe" json:"safe"`
|
||||
}
|
||||
|
||||
// Restart restarts specified load balancer instance
|
||||
|
||||
@@ -17,7 +17,7 @@ type UpdateSysctParamsRequest struct {
|
||||
|
||||
// Custom sysctl values for Load Balancer instance. Applied on boot
|
||||
// Required: true
|
||||
SysctlParams Params `url:"-" json:"sysctlParams" validate:"required,dive"`
|
||||
SysctlParams []map[string]interface{} `url:"-" json:"sysctlParams" validate:"required,dive"`
|
||||
}
|
||||
|
||||
type wrapperUpdateSysctParamsRequest struct {
|
||||
@@ -26,24 +26,21 @@ type wrapperUpdateSysctParamsRequest struct {
|
||||
}
|
||||
|
||||
// UpdateSysctParams method will create a new load balancer instance
|
||||
func (l LB) UpdateSysctParams(ctx context.Context, req UpdateSysctParamsRequest) (bool, error) {
|
||||
func (l LB) UpdateSysctlParams(ctx context.Context, req UpdateSysctParamsRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
var params []string
|
||||
|
||||
if len(req.SysctlParams) != 0 {
|
||||
params = make([]string, 0, len(req.SysctlParams))
|
||||
|
||||
for r := range req.SysctlParams {
|
||||
b, err := json.Marshal(req.SysctlParams[r])
|
||||
for _, m := range req.SysctlParams {
|
||||
encodeStr, err := json.Marshal(m)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
params = append(params, string(b))
|
||||
params = append(params, string(encodeStr))
|
||||
}
|
||||
} else {
|
||||
params = []string{}
|
||||
@@ -54,7 +51,7 @@ func (l LB) UpdateSysctParams(ctx context.Context, req UpdateSysctParamsRequest)
|
||||
Params: params,
|
||||
}
|
||||
|
||||
url := "/cloudbroker/lb/updateSysctParams"
|
||||
url := "/cloudbroker/lb/updateSysctlParams"
|
||||
|
||||
res, err := l.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
||||
if err != nil {
|
||||
Reference in New Issue
Block a user