This commit is contained in:
2024-04-16 14:26:06 +03:00
parent bc264c4d90
commit e7c968797b
298 changed files with 11066 additions and 398 deletions

View File

@@ -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 (l 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{}

View File

@@ -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
@@ -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 (l LB) List(ctx context.Context, req ListRequest) (*ListLB, error) {
res, err := l.ListRaw(ctx, req)
if err != nil {
return nil, err
@@ -72,6 +79,11 @@ func (l LB) List(ctx context.Context, req ListRequest) (*ListLB, error) {
// ListRaw gets list of all load balancers as an array of bytes
func (l LB) ListRaw(ctx context.Context, req ListRequest) ([]byte, error) {
if err := validators.ValidateRequest(req); err != nil {
return nil, validators.ValidationErrors(validators.GetErrors(err))
}
url := "/cloudapi/lb/list"
res, err := l.client.DecortApiCall(ctx, http.MethodPost, url, req)

View File

@@ -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,11 @@ type ListDeletedRequest struct {
// ListDeleted gets list of deleted load balancers
func (l LB) ListDeleted(ctx context.Context, req ListDeletedRequest) (*ListLB, error) {
if err := validators.ValidateRequest(req); err != nil {
return nil, validators.ValidationErrors(validators.GetErrors(err))
}
url := "/cloudapi/lb/listDeleted"
res, err := l.client.DecortApiCall(ctx, http.MethodPost, url, req)

View File

@@ -50,6 +50,12 @@ type RecordLB struct {
// ID
ID uint64 `json:"id"`
// ManagerId
ManagerId uint64 `json:"managerId"`
// ManagerType
ManagerType string `json:"managerType"`
// Image ID
ImageID uint64 `json:"imageId"`
@@ -89,6 +95,9 @@ type RecordLB struct {
// Updated time
UpdatedTime uint64 `json:"updatedTime"`
// UserManaged
UserManaged bool `json:"userManaged"`
// VINS ID
VINSID uint64 `json:"vinsId"`
}

View File

@@ -22,7 +22,7 @@ func (l LB) Stop(ctx context.Context, req StopRequest) (bool, error) {
return false, validators.ValidationErrors(validators.GetErrors(err))
}
url := "/cloudapi/lb/start"
url := "/cloudapi/lb/stop"
res, err := l.client.DecortApiCall(ctx, http.MethodPost, url, req)
if err != nil {

View File

@@ -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,7 +26,7 @@ type wrapperUpdateSysctParamsRequest struct {
}
// UpdateSysctParams updates sysct paarams for lb
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))
@@ -36,14 +36,12 @@ func (l LB) UpdateSysctParams(ctx context.Context, req UpdateSysctParamsRequest)
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 +52,7 @@ func (l LB) UpdateSysctParams(ctx context.Context, req UpdateSysctParamsRequest)
Params: params,
}
url := "/cloudapi/lb/updateSysctParams"
url := "/cloudapi/lb/updateSysctlParams"
res, err := l.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
if err != nil {