v1.0.0
This commit is contained in:
@@ -7,25 +7,69 @@ import (
|
||||
"strconv"
|
||||
)
|
||||
|
||||
// Request struct for create backend
|
||||
type BackendCreateRequest struct {
|
||||
LBID uint64 `url:"lbId"`
|
||||
// ID of the load balancer instance to backendCreate
|
||||
// Required: true
|
||||
LBID uint64 `url:"lbId"`
|
||||
|
||||
// Must be unique among all backends of this load balancer - name of the new backend to create
|
||||
// Required: true
|
||||
BackendName string `url:"backendName"`
|
||||
Algorithm string `url:"algorithm,omitempty"`
|
||||
Inter uint64 `url:"inter,omitempty"`
|
||||
DownInter uint64 `url:"downinter,omitempty"`
|
||||
Rise uint `url:"rise,omitempty"`
|
||||
Fall uint `url:"fall,omitempty"`
|
||||
SlowStart uint64 `url:"slowstart,omitempty"`
|
||||
MaxConn uint `url:"maxconn,omitempty"`
|
||||
MaxQueue uint `url:"maxqueue,omitempty"`
|
||||
Weight uint `url:"weight,omitempty"`
|
||||
|
||||
// Algorithm
|
||||
// Should be one of:
|
||||
// - roundrobin
|
||||
// - static-rr
|
||||
// - leastconn
|
||||
// Required: false
|
||||
Algorithm string `url:"algorithm,omitempty"`
|
||||
|
||||
// Interval in milliseconds between two consecutive availability
|
||||
// checks of the server that is considered available
|
||||
// Required: false
|
||||
Inter uint64 `url:"inter,omitempty"`
|
||||
|
||||
// Interval in milliseconds between two consecutive checks to
|
||||
// restore the availability of a server that is currently considered unavailable
|
||||
// Required: false
|
||||
DownInter uint64 `url:"downinter,omitempty"`
|
||||
|
||||
// Number of checks that the server must pass in order to get the available status
|
||||
// and be included in the balancing scheme again
|
||||
// Required: false
|
||||
Rise uint64 `url:"rise,omitempty"`
|
||||
|
||||
// Number of consecutive failed availability checks,
|
||||
// after which the previously considered available server receives the status of
|
||||
// unavailable and is temporarily excluded from the balancing scheme
|
||||
// Required: false
|
||||
Fall uint64 `url:"fall,omitempty"`
|
||||
|
||||
// Interval in milliseconds from the moment the server receives the available status,
|
||||
// after which the number of actually allowed connections to this server will be returned to 100% of the set limit
|
||||
// Required: false
|
||||
SlowStart uint64 `url:"slowstart,omitempty"`
|
||||
|
||||
// Limit of simultaneous connections to the server. When this limit is reached,
|
||||
// the server is temporarily excluded from the balancing scheme
|
||||
// Required: false
|
||||
MaxConn uint64 `url:"maxconn,omitempty"`
|
||||
|
||||
// Limit of connections waiting in the queue.
|
||||
// When this limit is reached, all subsequent connections will be forwarded to other servers
|
||||
// Required: false
|
||||
MaxQueue uint64 `url:"maxqueue,omitempty"`
|
||||
|
||||
// Server weight for use in weight balancing algorithms
|
||||
// Required: false
|
||||
Weight uint64 `url:"weight,omitempty"`
|
||||
}
|
||||
|
||||
func (lbrq BackendCreateRequest) Validate() error {
|
||||
func (lbrq BackendCreateRequest) validate() error {
|
||||
if lbrq.LBID == 0 {
|
||||
return errors.New("validation-error: field LBID can not be empty or equal to 0")
|
||||
}
|
||||
|
||||
if lbrq.BackendName == "" {
|
||||
return errors.New("validation-error: field BackendName can not be empty")
|
||||
}
|
||||
@@ -33,8 +77,9 @@ func (lbrq BackendCreateRequest) Validate() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// BackendCreate creates new backend on the specified load balancer
|
||||
func (l LB) BackendCreate(ctx context.Context, req BackendCreateRequest) (bool, error) {
|
||||
err := req.Validate()
|
||||
err := req.validate()
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
@@ -7,16 +7,21 @@ import (
|
||||
"strconv"
|
||||
)
|
||||
|
||||
// Request struct for delete backend
|
||||
type BackendDeleteRequest struct {
|
||||
LBID uint64 `url:"lbId"`
|
||||
// ID of the load balancer instance to BackendDelete
|
||||
// Required: true
|
||||
LBID uint64 `url:"lbId"`
|
||||
|
||||
// Cannot be emtpy string - name of the backend to delete
|
||||
// Required: true
|
||||
BackendName string `url:"backendName"`
|
||||
}
|
||||
|
||||
func (lbrq BackendDeleteRequest) Validate() error {
|
||||
func (lbrq BackendDeleteRequest) validate() error {
|
||||
if lbrq.LBID == 0 {
|
||||
return errors.New("validation-error: field LBID can not be empty or equal to 0")
|
||||
}
|
||||
|
||||
if lbrq.BackendName == "" {
|
||||
return errors.New("validation-error: field BackendName can not be empty")
|
||||
}
|
||||
@@ -24,8 +29,10 @@ func (lbrq BackendDeleteRequest) Validate() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// BackendDelete deletes backend from the specified load balancer.
|
||||
// Warning: you cannot undo this action!
|
||||
func (l LB) BackendDelete(ctx context.Context, req BackendDeleteRequest) (bool, error) {
|
||||
err := req.Validate()
|
||||
err := req.validate()
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
@@ -7,40 +7,83 @@ import (
|
||||
"strconv"
|
||||
)
|
||||
|
||||
// Request struct for add server definition to the backend
|
||||
type BackendServerAddRequest struct {
|
||||
LBID uint64 `url:"lbId"`
|
||||
// ID of the load balancer instance to BackendServerAdd
|
||||
// Required: true
|
||||
LBID uint64 `url:"lbId"`
|
||||
|
||||
// Must match one of the existing backens - name of the backend to add servers to
|
||||
// Required: true
|
||||
BackendName string `url:"backendName"`
|
||||
ServerName string `url:"serverName"`
|
||||
Address string `url:"address"`
|
||||
Port uint `url:"port"`
|
||||
Check string `url:"check,omitempty"`
|
||||
Inter uint64 `url:"inter,omitempty"`
|
||||
DownInter uint64 `url:"downinter,omitempty"`
|
||||
Rise uint `url:"rise,omitempty"`
|
||||
Fall uint `url:"fall,omitempty"`
|
||||
SlowStart uint64 `url:"slowstart,omitempty"`
|
||||
MaxConn uint `url:"maxconn,omitempty"`
|
||||
MaxQueue uint `url:"maxqueue,omitempty"`
|
||||
Weight uint `url:"weight,omitempty"`
|
||||
|
||||
// Must be unique among all servers defined for this backend - name of the server definition to add
|
||||
// Required: true
|
||||
ServerName string `url:"serverName"`
|
||||
|
||||
// IP address of the server
|
||||
// Required: true
|
||||
Address string `url:"address"`
|
||||
|
||||
// Port number on the server
|
||||
// Required: true
|
||||
Port uint64 `url:"port"`
|
||||
|
||||
// Set to disabled if this server should be used regardless of its state
|
||||
// Required: false
|
||||
Check string `url:"check,omitempty"`
|
||||
|
||||
// Interval in milliseconds between two consecutive availability checks of the server that is considered available
|
||||
// Required: false
|
||||
Inter uint64 `url:"inter,omitempty"`
|
||||
|
||||
// Interval in milliseconds between two consecutive checks to restore
|
||||
// the availability of a server that is currently considered unavailable
|
||||
// Required: false
|
||||
DownInter uint64 `url:"downinter,omitempty"`
|
||||
|
||||
// Number of checks that the server must pass in order to get
|
||||
// the available status and be included in the balancing scheme again
|
||||
// Required: false
|
||||
Rise uint64 `url:"rise,omitempty"`
|
||||
|
||||
// Number of consecutive failed availability checks,
|
||||
// after which the previously considered available server receives the status of unavailable and
|
||||
// is temporarily excluded from the balancing scheme
|
||||
// Required: false
|
||||
Fall uint64 `url:"fall,omitempty"`
|
||||
|
||||
// Interval in milliseconds from the moment the server receives the available status,
|
||||
// after which the number of actually allowed connections to this server will be returned to 100% of the set limit
|
||||
// Required: false
|
||||
SlowStart uint64 `url:"slowstart,omitempty"`
|
||||
|
||||
// Limit of simultaneous connections to the server. When this limit is reached, the server is temporarily excluded from the balancing scheme
|
||||
// Required: false
|
||||
MaxConn uint64 `url:"maxconn,omitempty"`
|
||||
|
||||
// Limit of connections waiting in the queue. When this limit is reached, all subsequent connections will be forwarded to other servers
|
||||
// Required: false
|
||||
MaxQueue uint64 `url:"maxqueue,omitempty"`
|
||||
|
||||
// Server weight for use in weight balancing algorithms
|
||||
// Required: false
|
||||
Weight uint64 `url:"weight,omitempty"`
|
||||
}
|
||||
|
||||
func (lbrq BackendServerAddRequest) Validate() error {
|
||||
func (lbrq BackendServerAddRequest) validate() error {
|
||||
if lbrq.LBID == 0 {
|
||||
return errors.New("validation-error: field LBID can not be empty or equal to 0")
|
||||
}
|
||||
|
||||
if lbrq.BackendName == "" {
|
||||
return errors.New("validation-error: field BackendName can not be empty")
|
||||
}
|
||||
|
||||
if lbrq.ServerName == "" {
|
||||
return errors.New("validation-error: field ServerName can not be empty")
|
||||
}
|
||||
|
||||
if lbrq.Address == "" {
|
||||
return errors.New("validation-error: field Address can not be empty")
|
||||
}
|
||||
|
||||
if lbrq.Port == 0 {
|
||||
return errors.New("validation-error: field Port can not be empty or equal to 0")
|
||||
}
|
||||
@@ -48,8 +91,9 @@ func (lbrq BackendServerAddRequest) Validate() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// BackendServerAdd adds server definition to the backend on the specified load balancer
|
||||
func (l LB) BackendServerAdd(ctx context.Context, req BackendServerAddRequest) (bool, error) {
|
||||
err := req.Validate()
|
||||
err := req.validate()
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
@@ -7,21 +7,28 @@ import (
|
||||
"strconv"
|
||||
)
|
||||
|
||||
// Request struct for delete server definition
|
||||
type BackendServerDeleteRequest struct {
|
||||
LBID uint64 `url:"lbId"`
|
||||
// ID of the load balancer instance to BackendServerDelete
|
||||
// Required: true
|
||||
LBID uint64 `url:"lbId"`
|
||||
|
||||
// Must match one of the existing backens - name of the backend to add servers to
|
||||
// Required: true
|
||||
BackendName string `url:"backendName"`
|
||||
ServerName string `url:"serverName"`
|
||||
|
||||
// Must be unique among all servers defined for this backend - name of the server definition to add
|
||||
// Required: true
|
||||
ServerName string `url:"serverName"`
|
||||
}
|
||||
|
||||
func (lbrq BackendServerDeleteRequest) Validate() error {
|
||||
func (lbrq BackendServerDeleteRequest) validate() error {
|
||||
if lbrq.LBID == 0 {
|
||||
return errors.New("validation-error: field LBID can not be empty or equal to 0")
|
||||
}
|
||||
|
||||
if lbrq.BackendName == "" {
|
||||
return errors.New("validation-error: field BackendName can not be empty")
|
||||
}
|
||||
|
||||
if lbrq.ServerName == "" {
|
||||
return errors.New("validation-error: field ServerName can not be empty")
|
||||
}
|
||||
@@ -29,8 +36,10 @@ func (lbrq BackendServerDeleteRequest) Validate() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// BackendServerDelete deletes server definition from the backend on the specified load balancer.
|
||||
// Warning: you cannot undo this action!
|
||||
func (l LB) BackendServerDelete(ctx context.Context, req BackendServerDeleteRequest) (bool, error) {
|
||||
err := req.Validate()
|
||||
err := req.validate()
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
@@ -7,40 +7,83 @@ import (
|
||||
"strconv"
|
||||
)
|
||||
|
||||
// Request struct for update server
|
||||
type BackendServerUpdateRequest struct {
|
||||
LBID uint64 `url:"lbId"`
|
||||
// ID of the load balancer instance to BackendServerAdd
|
||||
// Required: true
|
||||
LBID uint64 `url:"lbId"`
|
||||
|
||||
// Must match one of the existing backens - name of the backend to add servers to
|
||||
// Required: true
|
||||
BackendName string `url:"backendName"`
|
||||
ServerName string `url:"serverName"`
|
||||
Address string `url:"address"`
|
||||
Port uint `url:"port"`
|
||||
Check string `url:"check,omitempty"`
|
||||
Inter uint64 `url:"inter,omitempty"`
|
||||
DownInter uint64 `url:"downinter,omitempty"`
|
||||
Rise uint `url:"rise,omitempty"`
|
||||
Fall uint `url:"fall,omitempty"`
|
||||
SlowStart uint64 `url:"slowstart,omitempty"`
|
||||
MaxConn uint `url:"maxconn,omitempty"`
|
||||
MaxQueue uint `url:"maxqueue,omitempty"`
|
||||
Weight uint `url:"weight,omitempty"`
|
||||
|
||||
// Must be unique among all servers defined for this backend - name of the server definition to add
|
||||
// Required: true
|
||||
ServerName string `url:"serverName"`
|
||||
|
||||
// IP address of the server
|
||||
// Required: true
|
||||
Address string `url:"address"`
|
||||
|
||||
// Port number on the server
|
||||
// Required: true
|
||||
Port uint64 `url:"port"`
|
||||
|
||||
// Set to disabled if this server should be used regardless of its state
|
||||
// Required: false
|
||||
Check string `url:"check,omitempty"`
|
||||
|
||||
// Interval in milliseconds between two consecutive availability checks of the server that is considered available
|
||||
// Required: false
|
||||
Inter uint64 `url:"inter,omitempty"`
|
||||
|
||||
// Interval in milliseconds between two consecutive checks to restore
|
||||
// the availability of a server that is currently considered unavailable
|
||||
// Required: false
|
||||
DownInter uint64 `url:"downinter,omitempty"`
|
||||
|
||||
// Number of checks that the server must pass in order to get
|
||||
// the available status and be included in the balancing scheme again
|
||||
// Required: false
|
||||
Rise uint64 `url:"rise,omitempty"`
|
||||
|
||||
// Number of consecutive failed availability checks,
|
||||
// after which the previously considered available server receives the status of unavailable and
|
||||
// is temporarily excluded from the balancing scheme
|
||||
// Required: false
|
||||
Fall uint64 `url:"fall,omitempty"`
|
||||
|
||||
// Interval in milliseconds from the moment the server receives the available status,
|
||||
// after which the number of actually allowed connections to this server will be returned to 100% of the set limit
|
||||
// Required: false
|
||||
SlowStart uint64 `url:"slowstart,omitempty"`
|
||||
|
||||
// Limit of simultaneous connections to the server. When this limit is reached, the server is temporarily excluded from the balancing scheme
|
||||
// Required: false
|
||||
MaxConn uint64 `url:"maxconn,omitempty"`
|
||||
|
||||
// Limit of connections waiting in the queue. When this limit is reached, all subsequent connections will be forwarded to other servers
|
||||
// Required: false
|
||||
MaxQueue uint64 `url:"maxqueue,omitempty"`
|
||||
|
||||
// Server weight for use in weight balancing algorithms
|
||||
// Required: false
|
||||
Weight uint64 `url:"weight,omitempty"`
|
||||
}
|
||||
|
||||
func (lbrq BackendServerUpdateRequest) Validate() error {
|
||||
func (lbrq BackendServerUpdateRequest) validate() error {
|
||||
if lbrq.LBID == 0 {
|
||||
return errors.New("validation-error: field LBID can not be empty or equal to 0")
|
||||
}
|
||||
|
||||
if lbrq.BackendName == "" {
|
||||
return errors.New("validation-error: field BackendName can not be empty")
|
||||
}
|
||||
|
||||
if lbrq.ServerName == "" {
|
||||
return errors.New("validation-error: field ServerName can not be empty")
|
||||
}
|
||||
|
||||
if lbrq.Address == "" {
|
||||
return errors.New("validation-error: field Address can not be empty")
|
||||
}
|
||||
|
||||
if lbrq.Port == 0 {
|
||||
return errors.New("validation-error: field Port can not be empty or equal to 0")
|
||||
}
|
||||
@@ -48,8 +91,9 @@ func (lbrq BackendServerUpdateRequest) Validate() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// BackendServerUpdate updates server definition on the backend of load balancer
|
||||
func (l LB) BackendServerUpdate(ctx context.Context, req BackendServerUpdateRequest) (bool, error) {
|
||||
err := req.Validate()
|
||||
err := req.validate()
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
@@ -7,25 +7,69 @@ import (
|
||||
"strconv"
|
||||
)
|
||||
|
||||
// Request struct for update backend
|
||||
type BackendUpdateRequest struct {
|
||||
LBID uint64 `url:"lbId"`
|
||||
// ID of the load balancer instance to backendCreate
|
||||
// Required: true
|
||||
LBID uint64 `url:"lbId"`
|
||||
|
||||
// Must be unique among all backends of this load balancer - name of the new backend to create
|
||||
// Required: true
|
||||
BackendName string `url:"backendName"`
|
||||
Algorithm string `url:"algorithm,omitempty"`
|
||||
Inter uint64 `url:"inter,omitempty"`
|
||||
DownInter uint64 `url:"downinter,omitempty"`
|
||||
Rise uint `url:"rise,omitempty"`
|
||||
Fall uint `url:"fall,omitempty"`
|
||||
SlowStart uint64 `url:"slowstart,omitempty"`
|
||||
MaxConn uint `url:"maxconn,omitempty"`
|
||||
MaxQueue uint `url:"maxqueue,omitempty"`
|
||||
Weight uint `url:"weight,omitempty"`
|
||||
|
||||
// Algorithm
|
||||
// Should be one of:
|
||||
// - roundrobin
|
||||
// - static-rr
|
||||
// - leastconn
|
||||
// Required: false
|
||||
Algorithm string `url:"algorithm,omitempty"`
|
||||
|
||||
// Interval in milliseconds between two consecutive availability
|
||||
// checks of the server that is considered available
|
||||
// Required: false
|
||||
Inter uint64 `url:"inter,omitempty"`
|
||||
|
||||
// Interval in milliseconds between two consecutive checks to
|
||||
// restore the availability of a server that is currently considered unavailable
|
||||
// Required: false
|
||||
DownInter uint64 `url:"downinter,omitempty"`
|
||||
|
||||
// Number of checks that the server must pass in order to get the available status
|
||||
// and be included in the balancing scheme again
|
||||
// Required: false
|
||||
Rise uint64 `url:"rise,omitempty"`
|
||||
|
||||
// Number of consecutive failed availability checks,
|
||||
// after which the previously considered available server receives the status of
|
||||
// unavailable and is temporarily excluded from the balancing scheme
|
||||
// Required: false
|
||||
Fall uint64 `url:"fall,omitempty"`
|
||||
|
||||
// Interval in milliseconds from the moment the server receives the available status,
|
||||
// after which the number of actually allowed connections to this server will be returned to 100% of the set limit
|
||||
// Required: false
|
||||
SlowStart uint64 `url:"slowstart,omitempty"`
|
||||
|
||||
// Limit of simultaneous connections to the server. When this limit is reached,
|
||||
// the server is temporarily excluded from the balancing scheme
|
||||
// Required: false
|
||||
MaxConn uint64 `url:"maxconn,omitempty"`
|
||||
|
||||
// Limit of connections waiting in the queue.
|
||||
// When this limit is reached, all subsequent connections will be forwarded to other servers
|
||||
// Required: false
|
||||
MaxQueue uint64 `url:"maxqueue,omitempty"`
|
||||
|
||||
// Server weight for use in weight balancing algorithms
|
||||
// Required: false
|
||||
Weight uint64 `url:"weight,omitempty"`
|
||||
}
|
||||
|
||||
func (lbrq BackendUpdateRequest) Validate() error {
|
||||
func (lbrq BackendUpdateRequest) validate() error {
|
||||
if lbrq.LBID == 0 {
|
||||
return errors.New("validation-error: field LBID can not be empty or equal to 0")
|
||||
}
|
||||
|
||||
if lbrq.BackendName == "" {
|
||||
return errors.New("validation-error: field BackendName can not be empty")
|
||||
}
|
||||
@@ -33,8 +77,9 @@ func (lbrq BackendUpdateRequest) Validate() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// BackendUpdate updates existing backend on the specified load balancer. Note that backend name cannot be changed
|
||||
func (l LB) BackendUpdate(ctx context.Context, req BackendUpdateRequest) (bool, error) {
|
||||
err := req.Validate()
|
||||
err := req.validate()
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
@@ -7,11 +7,14 @@ import (
|
||||
"strconv"
|
||||
)
|
||||
|
||||
// Request struct for reset config
|
||||
type ConfigResetRequest struct {
|
||||
// ID of the load balancer instance to ConfigReset
|
||||
// Required: true
|
||||
LBID uint64 `url:"lbId"`
|
||||
}
|
||||
|
||||
func (lbrq ConfigResetRequest) Validate() error {
|
||||
func (lbrq ConfigResetRequest) validate() error {
|
||||
if lbrq.LBID == 0 {
|
||||
return errors.New("validation-error: field LBID can not be empty or equal to 0")
|
||||
}
|
||||
@@ -19,8 +22,10 @@ func (lbrq ConfigResetRequest) Validate() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// ConfigReset reset current software configuration of the specified load balancer.
|
||||
// Warning: this action cannot be undone!
|
||||
func (l LB) ConfigReset(ctx context.Context, req ConfigResetRequest) (bool, error) {
|
||||
err := req.Validate()
|
||||
err := req.validate()
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
@@ -7,28 +7,44 @@ import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
// Request struct for create load balancer
|
||||
type CreateRequest struct {
|
||||
RGID uint64 `url:"rgId"`
|
||||
Name string `url:"name"`
|
||||
ExtNetID uint64 `url:"extnetId"`
|
||||
VINSID uint64 `url:"vinsId"`
|
||||
Start bool `url:"start"`
|
||||
// ID of the resource group where this load balancer instance will be located
|
||||
// Required: true
|
||||
RGID uint64 `url:"rgId"`
|
||||
|
||||
// Name of the load balancer.
|
||||
// Must be unique among all load balancers in this Resource Group
|
||||
// Required: true
|
||||
Name string `url:"name"`
|
||||
|
||||
// External network to connect this load balancer to
|
||||
// Required: true
|
||||
ExtNetID uint64 `url:"extnetId"`
|
||||
|
||||
// Internal network (VINS) to connect this load balancer to
|
||||
// Required: true
|
||||
VINSID uint64 `url:"vinsId"`
|
||||
|
||||
// Start now Load balancer
|
||||
// Required: false
|
||||
Start bool `url:"start"`
|
||||
|
||||
// Text description of this load balancer
|
||||
// Required: false
|
||||
Description string `url:"desc,omitempty"`
|
||||
}
|
||||
|
||||
func (lbrq CreateRequest) Validate() error {
|
||||
func (lbrq CreateRequest) validate() error {
|
||||
if lbrq.RGID == 0 {
|
||||
return errors.New("validation-error: field RGID can not be empty or equal to 0")
|
||||
}
|
||||
|
||||
if lbrq.Name == "" {
|
||||
return errors.New("validation-error: field Name can not be empty")
|
||||
}
|
||||
|
||||
if lbrq.ExtNetID == 0 {
|
||||
return errors.New("validation-error: field ExtNetID can not be empty or equal to 0")
|
||||
}
|
||||
|
||||
if lbrq.VINSID == 0 {
|
||||
return errors.New("validation-error: field VINSID can not be empty or equal to 0")
|
||||
}
|
||||
@@ -36,8 +52,9 @@ func (lbrq CreateRequest) Validate() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Create method will create a new load balancer instance
|
||||
func (l LB) Create(ctx context.Context, req CreateRequest) (string, error) {
|
||||
err := req.Validate()
|
||||
err := req.validate()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
@@ -49,5 +66,7 @@ func (l LB) Create(ctx context.Context, req CreateRequest) (string, error) {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return strings.ReplaceAll(string(res), "\"", ""), nil
|
||||
result := strings.ReplaceAll(string(res), "\"", "")
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
@@ -7,12 +7,18 @@ import (
|
||||
"strconv"
|
||||
)
|
||||
|
||||
// Request struct for delete load balancer
|
||||
type DeleteRequest struct {
|
||||
LBID uint64 `url:"lbId"`
|
||||
Permanently bool `url:"permanently"`
|
||||
// ID of the load balancer instance to delete
|
||||
// Required: true
|
||||
LBID uint64 `url:"lbId"`
|
||||
|
||||
// Set to true to delete load balancer immediately bypassing recycle bin
|
||||
// Required: false
|
||||
Permanently bool `url:"permanently,omitempty"`
|
||||
}
|
||||
|
||||
func (lbrq DeleteRequest) Validate() error {
|
||||
func (lbrq DeleteRequest) validate() error {
|
||||
if lbrq.LBID == 0 {
|
||||
return errors.New("validation-error: field LBID can not be empty or equal to 0")
|
||||
}
|
||||
@@ -20,8 +26,9 @@ func (lbrq DeleteRequest) Validate() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Delete deletes specified load balancer
|
||||
func (l LB) Delete(ctx context.Context, req DeleteRequest) (bool, error) {
|
||||
err := req.Validate()
|
||||
err := req.validate()
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
@@ -7,11 +7,14 @@ import (
|
||||
"strconv"
|
||||
)
|
||||
|
||||
type DisabelEnableRequest struct {
|
||||
// Request struct for disable/enable load balancer
|
||||
type DisableEnableRequest struct {
|
||||
// ID of the load balancer instance to disable/enable
|
||||
// Required: true
|
||||
LBID uint64 `url:"lbId"`
|
||||
}
|
||||
|
||||
func (lbrq DisabelEnableRequest) Validate() error {
|
||||
func (lbrq DisableEnableRequest) validate() error {
|
||||
if lbrq.LBID == 0 {
|
||||
return errors.New("validation-error: field LBID can not be empty or equal to 0")
|
||||
}
|
||||
@@ -19,8 +22,9 @@ func (lbrq DisabelEnableRequest) Validate() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (l LB) Disable(ctx context.Context, req DisabelEnableRequest) (bool, error) {
|
||||
err := req.Validate()
|
||||
// Disable disables specified load balancer instance
|
||||
func (l LB) Disable(ctx context.Context, req DisableEnableRequest) (bool, error) {
|
||||
err := req.validate()
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
@@ -40,8 +44,9 @@ func (l LB) Disable(ctx context.Context, req DisabelEnableRequest) (bool, error)
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (l LB) Enable(ctx context.Context, req DisabelEnableRequest) (bool, error) {
|
||||
err := req.Validate()
|
||||
// Enable enables specified load balancer instance
|
||||
func (l LB) Enable(ctx context.Context, req DisableEnableRequest) (bool, error) {
|
||||
err := req.validate()
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
@@ -7,23 +7,39 @@ import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
// Request struct for frontend bind
|
||||
type FrontendBindRequest struct {
|
||||
LBID uint64 `url:"lbId"`
|
||||
FrontendName string `url:"frontendName"`
|
||||
BindingName string `url:"bindingName"`
|
||||
// ID of the load balancer instance to FrontendBind
|
||||
// Required: true
|
||||
LBID uint64 `url:"lbId"`
|
||||
|
||||
// Name of the frontend to update
|
||||
// Required: true
|
||||
FrontendName string `url:"frontendName"`
|
||||
|
||||
// Name of the binding to update
|
||||
// Required: true
|
||||
BindingName string `url:"bindingName"`
|
||||
|
||||
// If specified must be within the IP range of either Ext Net or ViNS,
|
||||
// where this load balancer is connected - new IP address to use for this binding.
|
||||
// If omitted, current IP address is retained
|
||||
// Required: false
|
||||
BindingAddress string `url:"bindingAddress,omitempty"`
|
||||
BindingPort uint `url:"bindingPort,omitempty"`
|
||||
|
||||
// New port number to use for this binding.
|
||||
// If omitted, current port number is retained
|
||||
// Required: false
|
||||
BindingPort uint64 `url:"bindingPort,omitempty"`
|
||||
}
|
||||
|
||||
func (lbrq FrontendBindRequest) Validate() error {
|
||||
func (lbrq FrontendBindRequest) validate() error {
|
||||
if lbrq.LBID == 0 {
|
||||
return errors.New("validation-error: field LBID can not be empty or equal to 0")
|
||||
}
|
||||
|
||||
if lbrq.FrontendName == "" {
|
||||
return errors.New("validation-error: field FrontendName can not be empty")
|
||||
}
|
||||
|
||||
if lbrq.BindingName == "" {
|
||||
return errors.New("validation-error: field BindingName can not be empty")
|
||||
}
|
||||
@@ -31,8 +47,9 @@ func (lbrq FrontendBindRequest) Validate() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// FrontendBind bind frontend from specified load balancer instance
|
||||
func (l LB) FrontendBind(ctx context.Context, req FrontendBindRequest) (string, error) {
|
||||
err := req.Validate()
|
||||
err := req.validate()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
@@ -44,5 +61,7 @@ func (l LB) FrontendBind(ctx context.Context, req FrontendBindRequest) (string,
|
||||
return "", err
|
||||
}
|
||||
|
||||
return strings.ReplaceAll(string(res), "\"", ""), nil
|
||||
result := strings.ReplaceAll(string(res), "\"", "")
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
@@ -7,21 +7,28 @@ import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
// Request struct for delete bind
|
||||
type FrontendBindDeleteRequest struct {
|
||||
LBID uint64 `url:"lbId"`
|
||||
// ID of the load balancer instance to FrontendBindDelete
|
||||
// Required: true
|
||||
LBID uint64 `url:"lbId"`
|
||||
|
||||
// Name of the frontend to delete
|
||||
// Required: true
|
||||
FrontendName string `url:"frontendName"`
|
||||
BindingName string `url:"bindingName"`
|
||||
|
||||
// Name of the binding to delete
|
||||
// Required: true
|
||||
BindingName string `url:"bindingName"`
|
||||
}
|
||||
|
||||
func (lbrq FrontendBindDeleteRequest) Validate() error {
|
||||
func (lbrq FrontendBindDeleteRequest) validate() error {
|
||||
if lbrq.LBID == 0 {
|
||||
return errors.New("validation-error: field LBID can not be empty or equal to 0")
|
||||
}
|
||||
|
||||
if lbrq.FrontendName == "" {
|
||||
return errors.New("validation-error: field FrontendName can not be empty")
|
||||
}
|
||||
|
||||
if lbrq.BindingName == "" {
|
||||
return errors.New("validation-error: field BindingName can not be empty")
|
||||
}
|
||||
@@ -29,8 +36,9 @@ func (lbrq FrontendBindDeleteRequest) Validate() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// FrontendBindDelete deletes binding from the specified load balancer frontend
|
||||
func (l LB) FrontendBindDelete(ctx context.Context, req FrontendBindDeleteRequest) (string, error) {
|
||||
err := req.Validate()
|
||||
err := req.validate()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
@@ -42,5 +50,7 @@ func (l LB) FrontendBindDelete(ctx context.Context, req FrontendBindDeleteReques
|
||||
return "", err
|
||||
}
|
||||
|
||||
return strings.ReplaceAll(string(res), "\"", ""), nil
|
||||
result := strings.ReplaceAll(string(res), "\"", "")
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
@@ -7,23 +7,39 @@ import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
// Request struct for update binding
|
||||
type FrontendBindUpdateRequest struct {
|
||||
LBID uint64 `url:"lbId"`
|
||||
FrontendName string `url:"frontendName"`
|
||||
BindingName string `url:"bindingName"`
|
||||
// ID of the load balancer instance to FrontendBindUpdate
|
||||
// Required: true
|
||||
LBID uint64 `url:"lbId"`
|
||||
|
||||
// Name of the frontend to update
|
||||
// Required: true
|
||||
FrontendName string `url:"frontendName"`
|
||||
|
||||
// Name of the binding to update
|
||||
// Required: true
|
||||
BindingName string `url:"bindingName"`
|
||||
|
||||
// If specified must be within the IP range of either Ext Net or ViNS,
|
||||
// where this load balancer is connected - new IP address to use for this binding.
|
||||
// If omitted, current IP address is retained
|
||||
// Required: false
|
||||
BindingAddress string `url:"bindingAddress,omitempty"`
|
||||
BindingPort uint `url:"bindingPort,omitempty"`
|
||||
|
||||
// New port number to use for this binding.
|
||||
// If omitted, current port number is retained
|
||||
// Required: false
|
||||
BindingPort uint64 `url:"bindingPort,omitempty"`
|
||||
}
|
||||
|
||||
func (lbrq FrontendBindUpdateRequest) Validate() error {
|
||||
func (lbrq FrontendBindUpdateRequest) validate() error {
|
||||
if lbrq.LBID == 0 {
|
||||
return errors.New("validation-error: field LBID can not be empty or equal to 0")
|
||||
}
|
||||
|
||||
if lbrq.FrontendName == "" {
|
||||
return errors.New("validation-error: field FrontendName can not be empty")
|
||||
}
|
||||
|
||||
if lbrq.BindingName == "" {
|
||||
return errors.New("validation-error: field BindingName can not be empty")
|
||||
}
|
||||
@@ -31,8 +47,9 @@ func (lbrq FrontendBindUpdateRequest) Validate() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// FrontendBindUpdate updates binding for the specified load balancer frontend
|
||||
func (l LB) FrontendBindUpdate(ctx context.Context, req FrontendBindUpdateRequest) (string, error) {
|
||||
err := req.Validate()
|
||||
err := req.validate()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
@@ -44,5 +61,7 @@ func (l LB) FrontendBindUpdate(ctx context.Context, req FrontendBindUpdateReques
|
||||
return "", err
|
||||
}
|
||||
|
||||
return strings.ReplaceAll(string(res), "\"", ""), nil
|
||||
result := strings.ReplaceAll(string(res), "\"", "")
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
@@ -7,21 +7,30 @@ import (
|
||||
"strconv"
|
||||
)
|
||||
|
||||
// Request struct for create frontend
|
||||
type FrontendCreateRequest struct {
|
||||
LBID uint64 `url:"lbId"`
|
||||
// ID of the load balancer instance to FrontendCreate
|
||||
// Required: true
|
||||
LBID uint64 `url:"lbId"`
|
||||
|
||||
// Must be unique among all frontends of
|
||||
// this load balancer - name of the new frontend to create
|
||||
// Required: true
|
||||
FrontendName string `url:"frontendName"`
|
||||
BackendName string `url:"backendName"`
|
||||
|
||||
// Should be one of the backends existing on
|
||||
// this load balancer - name of the backend to use
|
||||
// Required: true
|
||||
BackendName string `url:"backendName"`
|
||||
}
|
||||
|
||||
func (lbrq FrontendCreateRequest) Validate() error {
|
||||
func (lbrq FrontendCreateRequest) validate() error {
|
||||
if lbrq.LBID == 0 {
|
||||
return errors.New("validation-error: field LBID can not be empty or equal to 0")
|
||||
}
|
||||
|
||||
if lbrq.FrontendName == "" {
|
||||
return errors.New("validation-error: field FrontendName can not be empty")
|
||||
}
|
||||
|
||||
if lbrq.BackendName == "" {
|
||||
return errors.New("validation-error: field BackendName can not be empty")
|
||||
}
|
||||
@@ -29,8 +38,9 @@ func (lbrq FrontendCreateRequest) Validate() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// FrontendCreate creates new frontend on the specified load balancer
|
||||
func (l LB) FrontendCreate(ctx context.Context, req FrontendCreateRequest) (bool, error) {
|
||||
err := req.Validate()
|
||||
err := req.validate()
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
@@ -7,16 +7,21 @@ import (
|
||||
"strconv"
|
||||
)
|
||||
|
||||
// Request struct for delete frontend
|
||||
type FrontendDeleteRequest struct {
|
||||
LBID uint64 `url:"lbId"`
|
||||
// ID of the load balancer instance to FrontendDelete
|
||||
// Required: true
|
||||
LBID uint64 `url:"lbId"`
|
||||
|
||||
// Name of the frontend to delete
|
||||
// Required: true
|
||||
FrontendName string `url:"frontendName"`
|
||||
}
|
||||
|
||||
func (lbrq FrontendDeleteRequest) Validate() error {
|
||||
func (lbrq FrontendDeleteRequest) validate() error {
|
||||
if lbrq.LBID == 0 {
|
||||
return errors.New("validation-error: field LBID can not be empty or equal to 0")
|
||||
}
|
||||
|
||||
if lbrq.FrontendName == "" {
|
||||
return errors.New("validation-error: field FrontendName can not be empty")
|
||||
}
|
||||
@@ -24,8 +29,10 @@ func (lbrq FrontendDeleteRequest) Validate() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// FrontendDelete deletes frontend from the specified load balancer.
|
||||
// Warning: you cannot undo this action!
|
||||
func (l LB) FrontendDelete(ctx context.Context, req FrontendDeleteRequest) (bool, error) {
|
||||
err := req.Validate()
|
||||
err := req.validate()
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
@@ -7,11 +7,14 @@ import (
|
||||
"net/http"
|
||||
)
|
||||
|
||||
// Request struct for get detailed information about load balancer
|
||||
type GetRequest struct {
|
||||
// ID of the load balancer to get details for
|
||||
// Required: true
|
||||
LBID uint64 `url:"lbId"`
|
||||
}
|
||||
|
||||
func (lbrq GetRequest) Validate() error {
|
||||
func (lbrq GetRequest) validate() error {
|
||||
if lbrq.LBID == 0 {
|
||||
return errors.New("validation-error: field LBID can not be empty or equal to 0")
|
||||
}
|
||||
@@ -19,25 +22,26 @@ func (lbrq GetRequest) Validate() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (l LB) Get(ctx context.Context, req GetRequest) (*LoadBalancer, error) {
|
||||
err := req.Validate()
|
||||
// Get gets detailed information about load balancer
|
||||
func (l LB) Get(ctx context.Context, req GetRequest) (*RecordLB, error) {
|
||||
err := req.validate()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
url := "/cloudapi/lb/get"
|
||||
|
||||
lbRaw, err := l.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
res, err := l.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
lb := &LoadBalancer{}
|
||||
err = json.Unmarshal(lbRaw, lb)
|
||||
info := RecordLB{}
|
||||
|
||||
err = json.Unmarshal(res, &info)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return lb, nil
|
||||
|
||||
return &info, nil
|
||||
}
|
||||
|
||||
@@ -1,13 +1,16 @@
|
||||
// API to manage load balancer instance
|
||||
package lb
|
||||
|
||||
import (
|
||||
"github.com/rudecs/decort-sdk/interfaces"
|
||||
)
|
||||
|
||||
// Structure for creating request to load balancer
|
||||
type LB struct {
|
||||
client interfaces.Caller
|
||||
}
|
||||
|
||||
// Builder for load balancer
|
||||
func New(client interfaces.Caller) *LB {
|
||||
return &LB{
|
||||
client,
|
||||
|
||||
@@ -6,26 +6,36 @@ import (
|
||||
"net/http"
|
||||
)
|
||||
|
||||
// Request struct for get list of load balancers
|
||||
type ListRequest struct {
|
||||
IncludeDeleted bool `url:"includedeleted"`
|
||||
Page uint64 `url:"page"`
|
||||
Size uint64 `url:"size"`
|
||||
// Included deleted load balancers
|
||||
// Required: false
|
||||
IncludeDeleted bool `url:"includedeleted,omitempty"`
|
||||
|
||||
// Page number
|
||||
// Required: false
|
||||
Page uint64 `url:"page,omitempty"`
|
||||
|
||||
// Page size
|
||||
// Required: false
|
||||
Size uint64 `url:"size,omitempty"`
|
||||
}
|
||||
|
||||
func (l LB) List(ctx context.Context, req ListRequest) (LBList, error) {
|
||||
// List gets list all load balancers
|
||||
func (l LB) List(ctx context.Context, req ListRequest) (ListLB, error) {
|
||||
url := "/cloudapi/lb/list"
|
||||
|
||||
lbListRaw, err := l.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
res, err := l.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
lbList := LBList{}
|
||||
err = json.Unmarshal(lbListRaw, &lbList)
|
||||
list := ListLB{}
|
||||
|
||||
err = json.Unmarshal(res, &list)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return lbList, nil
|
||||
|
||||
return list, nil
|
||||
}
|
||||
|
||||
@@ -6,25 +6,32 @@ import (
|
||||
"net/http"
|
||||
)
|
||||
|
||||
// Request struct for get list of deleted load balancers
|
||||
type ListDeletedRequest struct {
|
||||
Page uint64 `url:"page"`
|
||||
Size uint64 `url:"size"`
|
||||
// Page number
|
||||
// Required: false
|
||||
Page uint64 `url:"page,omitempty"`
|
||||
|
||||
// Page size
|
||||
// Required: true
|
||||
Size uint64 `url:"size,omitempty"`
|
||||
}
|
||||
|
||||
func (l LB) ListDeleted(ctx context.Context, req ListDeletedRequest) (LBList, error) {
|
||||
// ListDeleted gets list of deleted load balancers
|
||||
func (l LB) ListDeleted(ctx context.Context, req ListDeletedRequest) (ListLB, error) {
|
||||
url := "/cloudapi/lb/listDeleted"
|
||||
|
||||
lbListRaw, err := l.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
res, err := l.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
lbList := LBList{}
|
||||
err = json.Unmarshal(lbListRaw, &lbList)
|
||||
list := ListLB{}
|
||||
|
||||
err = json.Unmarshal(res, &list)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return lbList, nil
|
||||
|
||||
return list, nil
|
||||
}
|
||||
|
||||
@@ -1,89 +1,226 @@
|
||||
package lb
|
||||
|
||||
type LoadBalancer struct {
|
||||
HAMode bool `json:"HAmode"`
|
||||
ACL interface{} `json:"acl"`
|
||||
Backends []Backend `json:"backends"`
|
||||
CreatedBy string `json:"createdBy"`
|
||||
CreatedTime uint64 `json:"createdTime"`
|
||||
DeletedBy string `json:"deletedBy"`
|
||||
DeletedTime uint64 `json:"deletedTime"`
|
||||
Description string `json:"desc"`
|
||||
DPAPIUser string `json:"dpApiUser"`
|
||||
ExtNetID uint64 `json:"extnetId"`
|
||||
Frontends []Frontend `json:"frontends"`
|
||||
GID uint64 `json:"gid"`
|
||||
GUID uint64 `json:"guid"`
|
||||
ID uint64 `json:"id"`
|
||||
ImageID uint64 `json:"imageId"`
|
||||
Milestones uint64 `json:"milestones"`
|
||||
Name string `json:"name"`
|
||||
PrimaryNode Node `json:"primaryNode"`
|
||||
RGID uint64 `json:"rgId"`
|
||||
RGName string `json:"rgName"`
|
||||
SecondaryNode Node `json:"secondaryNode"`
|
||||
Status string `json:"status"`
|
||||
TechStatus string `json:"techStatus"`
|
||||
UpdatedBy string `json:"updatedBy"`
|
||||
UpdatedTime uint64 `json:"updatedTime"`
|
||||
VINSID uint64 `json:"vinsId"`
|
||||
// Detailed information about load balancer
|
||||
type RecordLB struct {
|
||||
//HAMode
|
||||
HAMode bool `json:"HAmode"`
|
||||
|
||||
// Access Control List
|
||||
ACL interface{} `json:"acl"`
|
||||
|
||||
// List of load balancer backends
|
||||
Backends ListBackends `json:"backends"`
|
||||
|
||||
// Created by
|
||||
CreatedBy string `json:"createdBy"`
|
||||
|
||||
// Created time
|
||||
CreatedTime uint64 `json:"createdTime"`
|
||||
|
||||
// Deleted by
|
||||
DeletedBy string `json:"deletedBy"`
|
||||
|
||||
// Deleted time
|
||||
DeletedTime uint64 `json:"deletedTime"`
|
||||
|
||||
// Description
|
||||
Description string `json:"desc"`
|
||||
|
||||
// DPAPIUser
|
||||
DPAPIUser string `json:"dpApiUser"`
|
||||
|
||||
// External network ID
|
||||
ExtNetID uint64 `json:"extnetId"`
|
||||
|
||||
// List of load balancer frontends
|
||||
Frontends ListFrontends `json:"frontends"`
|
||||
|
||||
// Grid ID
|
||||
GID uint64 `json:"gid"`
|
||||
|
||||
// GUID
|
||||
GUID uint64 `json:"guid"`
|
||||
|
||||
// ID
|
||||
ID uint64 `json:"id"`
|
||||
|
||||
// Image ID
|
||||
ImageID uint64 `json:"imageId"`
|
||||
|
||||
// Milestones
|
||||
Milestones uint64 `json:"milestones"`
|
||||
|
||||
// Name
|
||||
Name string `json:"name"`
|
||||
|
||||
// Primary node
|
||||
PrimaryNode RecordNode `json:"primaryNode"`
|
||||
|
||||
// Resource group ID
|
||||
RGID uint64 `json:"rgId"`
|
||||
|
||||
// Resource group name
|
||||
RGName string `json:"rgName"`
|
||||
|
||||
// Secondary node
|
||||
SecondaryNode RecordNode `json:"secondaryNode"`
|
||||
|
||||
// Status
|
||||
Status string `json:"status"`
|
||||
|
||||
// Tech status
|
||||
TechStatus string `json:"techStatus"`
|
||||
|
||||
// Updated by
|
||||
UpdatedBy string `json:"updatedBy"`
|
||||
|
||||
// Updated time
|
||||
UpdatedTime uint64 `json:"updatedTime"`
|
||||
|
||||
// VINS ID
|
||||
VINSID uint64 `json:"vinsId"`
|
||||
}
|
||||
|
||||
type LoadBalancerDetailed struct {
|
||||
// Main information about load balancer
|
||||
type ItemLoadBalancer struct {
|
||||
// DPAPIPassword
|
||||
DPAPIPassword string `json:"dpApiPassword"`
|
||||
LoadBalancer
|
||||
// Detailed information about load balancer
|
||||
RecordLB
|
||||
}
|
||||
|
||||
type Backend struct {
|
||||
Algorithm string `json:"algorithm"`
|
||||
GUID string `json:"guid"`
|
||||
Name string `json:"name"`
|
||||
ServerDefaultSettings ServerSettings `json:"serverDefaultSettings"`
|
||||
Servers []Server `json:"servers"`
|
||||
// List of load balancers
|
||||
type ListLB []ItemLoadBalancer
|
||||
|
||||
// Main information about backend
|
||||
type ItemBackend struct {
|
||||
// Algorithm
|
||||
Algorithm string `json:"algorithm"`
|
||||
|
||||
// GUID
|
||||
GUID string `json:"guid"`
|
||||
|
||||
// Name
|
||||
Name string `json:"name"`
|
||||
|
||||
// Server settings
|
||||
ServerDefaultSettings RecordServerSettings `json:"serverDefaultSettings"`
|
||||
|
||||
// List of servers
|
||||
Servers ListServers `json:"servers"`
|
||||
}
|
||||
|
||||
type LBList []LoadBalancerDetailed
|
||||
// List of backends
|
||||
type ListBackends []ItemBackend
|
||||
|
||||
type ServerSettings struct {
|
||||
Inter uint64 `json:"inter"`
|
||||
GUID string `json:"guid"`
|
||||
// Server settings
|
||||
type RecordServerSettings struct {
|
||||
// Inter
|
||||
Inter uint64 `json:"inter"`
|
||||
|
||||
// GUID
|
||||
GUID string `json:"guid"`
|
||||
|
||||
// DownInter
|
||||
DownInter uint64 `json:"downinter"`
|
||||
Rise uint64 `json:"rise"`
|
||||
Fall uint64 `json:"fall"`
|
||||
|
||||
// Rise
|
||||
Rise uint64 `json:"rise"`
|
||||
|
||||
// Fall
|
||||
Fall uint64 `json:"fall"`
|
||||
|
||||
// SlowStart
|
||||
SlowStart uint64 `json:"slowstart"`
|
||||
MaxConn uint64 `json:"maxconn"`
|
||||
MaxQueue uint64 `json:"maxqueue"`
|
||||
Weight uint64 `json:"weight"`
|
||||
|
||||
// Max connections
|
||||
MaxConn uint64 `json:"maxconn"`
|
||||
|
||||
// Max queue
|
||||
MaxQueue uint64 `json:"maxqueue"`
|
||||
|
||||
// Weight
|
||||
Weight uint64 `json:"weight"`
|
||||
}
|
||||
|
||||
type Server struct {
|
||||
Address string `json:"address"`
|
||||
Check string `json:"check"`
|
||||
GUID string `json:"guid"`
|
||||
Name string `json:"name"`
|
||||
Port uint64 `json:"port"`
|
||||
ServerSettings ServerSettings `json:"serverSettings"`
|
||||
}
|
||||
// Main information about server
|
||||
type ItemServer struct {
|
||||
|
||||
type Node struct {
|
||||
BackendIP string `json:"backendIp"`
|
||||
ComputeID uint64 `json:"computeId"`
|
||||
FrontendIP string `json:"frontendIp"`
|
||||
GUID string `json:"guid"`
|
||||
MGMTIP string `json:"mgmtIp"`
|
||||
NetworkID uint64 `json:"networkId"`
|
||||
}
|
||||
|
||||
type Frontend struct {
|
||||
Backend string `json:"backend"`
|
||||
Bindings []Binding `json:"bindings"`
|
||||
GUID string `json:"guid"`
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
type Binding struct {
|
||||
// Address
|
||||
Address string `json:"address"`
|
||||
GUID string `json:"guid"`
|
||||
Name string `json:"name"`
|
||||
Port uint64 `json:"port"`
|
||||
|
||||
// Check
|
||||
Check string `json:"check"`
|
||||
|
||||
// GUID
|
||||
GUID string `json:"guid"`
|
||||
|
||||
// Name
|
||||
Name string `json:"name"`
|
||||
|
||||
// Port
|
||||
Port uint64 `json:"port"`
|
||||
|
||||
// Server settings
|
||||
ServerSettings RecordServerSettings `json:"serverSettings"`
|
||||
}
|
||||
|
||||
// List of servers
|
||||
type ListServers []ItemServer
|
||||
|
||||
// Main information about node
|
||||
type RecordNode struct {
|
||||
// Backend IP
|
||||
BackendIP string `json:"backendIp"`
|
||||
|
||||
// Compute ID
|
||||
ComputeID uint64 `json:"computeId"`
|
||||
|
||||
// Frontend IP
|
||||
FrontendIP string `json:"frontendIp"`
|
||||
|
||||
// GUID
|
||||
GUID string `json:"guid"`
|
||||
|
||||
// MGMTIP
|
||||
MGMTIP string `json:"mgmtIp"`
|
||||
|
||||
// Network ID
|
||||
NetworkID uint64 `json:"networkId"`
|
||||
}
|
||||
|
||||
// Main information about frontend
|
||||
type ItemFrontend struct {
|
||||
// Backend
|
||||
Backend string `json:"backend"`
|
||||
|
||||
// List of bindings
|
||||
Bindings ListBindings `json:"bindings"`
|
||||
|
||||
// GUID
|
||||
GUID string `json:"guid"`
|
||||
|
||||
// Name
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
// List of frontends
|
||||
type ListFrontends []ItemFrontend
|
||||
|
||||
// Main information about bindings
|
||||
type ItemBinding struct {
|
||||
// Address
|
||||
Address string `json:"address"`
|
||||
|
||||
// GUID
|
||||
GUID string `json:"guid"`
|
||||
|
||||
// Name
|
||||
Name string `json:"name"`
|
||||
|
||||
// Port
|
||||
Port uint64 `json:"port"`
|
||||
}
|
||||
|
||||
// List of bindings
|
||||
type ListBindings []ItemBinding
|
||||
|
||||
@@ -7,11 +7,14 @@ import (
|
||||
"strconv"
|
||||
)
|
||||
|
||||
// Request struct for restart load balancer
|
||||
type RestartRequest struct {
|
||||
// ID of the load balancer instance to restart
|
||||
// Required: true
|
||||
LBID uint64 `url:"lbId"`
|
||||
}
|
||||
|
||||
func (lbrq RestartRequest) Validate() error {
|
||||
func (lbrq RestartRequest) validate() error {
|
||||
if lbrq.LBID == 0 {
|
||||
return errors.New("validation-error: field LBID can not be empty or equal to 0")
|
||||
}
|
||||
@@ -19,8 +22,9 @@ func (lbrq RestartRequest) Validate() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Restart restarts specified load balancer instance
|
||||
func (l LB) Restart(ctx context.Context, req RestartRequest) (bool, error) {
|
||||
err := req.Validate()
|
||||
err := req.validate()
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
@@ -7,11 +7,14 @@ import (
|
||||
"strconv"
|
||||
)
|
||||
|
||||
// Request struct for restore load balancer
|
||||
type RestoreRequest struct {
|
||||
// ID of the load balancer instance to restore
|
||||
// Required: true
|
||||
LBID uint64 `url:"lbId"`
|
||||
}
|
||||
|
||||
func (lbrq RestoreRequest) Validate() error {
|
||||
func (lbrq RestoreRequest) validate() error {
|
||||
if lbrq.LBID == 0 {
|
||||
return errors.New("validation-error: field LBID can not be empty or equal to 0")
|
||||
}
|
||||
@@ -19,8 +22,9 @@ func (lbrq RestoreRequest) Validate() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Restore restore load balancer from recycle bin
|
||||
func (l LB) Restore(ctx context.Context, req RestoreRequest) (bool, error) {
|
||||
err := req.Validate()
|
||||
err := req.validate()
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
@@ -7,12 +7,19 @@ import (
|
||||
"strconv"
|
||||
)
|
||||
|
||||
// Request struct for update load balancer
|
||||
type UpdateRequest struct {
|
||||
LBID uint64 `url:"lbId"`
|
||||
// ID of the load balancer to update
|
||||
// Required: true
|
||||
LBID uint64 `url:"lbId"`
|
||||
|
||||
// New description of this load balancer.
|
||||
// If omitted, current description is retained
|
||||
// Required: true
|
||||
Description string `url:"desc"`
|
||||
}
|
||||
|
||||
func (lbrq UpdateRequest) Validate() error {
|
||||
func (lbrq UpdateRequest) validate() error {
|
||||
if lbrq.LBID == 0 {
|
||||
return errors.New("validation-error: field LBID can not be empty or equal to 0")
|
||||
}
|
||||
@@ -23,8 +30,9 @@ func (lbrq UpdateRequest) Validate() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Update updates some of load balancer attributes
|
||||
func (l LB) Update(ctx context.Context, req UpdateRequest) (bool, error) {
|
||||
err := req.Validate()
|
||||
err := req.validate()
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user