v1.6.6
This commit is contained in:
@@ -8,25 +8,16 @@ import (
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// Request struct for get detailed information about load balancer
|
||||
// GetRequest struct to get detailed information about load balancer
|
||||
type GetRequest struct {
|
||||
// ID of the load balancer to get details for
|
||||
// Required: true
|
||||
LBID uint64 `url:"lbId" json:"lbId" validate:"required"`
|
||||
}
|
||||
|
||||
// Get gets detailed information about load balancer
|
||||
// Get gets detailed information about load balancer as a RecordLB struct
|
||||
func (l LB) Get(ctx context.Context, req GetRequest) (*RecordLB, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
for _, validationError := range validators.GetErrors(err) {
|
||||
return nil, validators.ValidationError(validationError)
|
||||
}
|
||||
}
|
||||
|
||||
url := "/cloudapi/lb/get"
|
||||
|
||||
res, err := l.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
res, err := l.GetRaw(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -40,3 +31,18 @@ func (l LB) Get(ctx context.Context, req GetRequest) (*RecordLB, error) {
|
||||
|
||||
return &info, nil
|
||||
}
|
||||
|
||||
// GetRaw gets detailed information about load balancer as an array of bytes
|
||||
func (l LB) GetRaw(ctx context.Context, req GetRequest) ([]byte, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
for _, validationError := range validators.GetErrors(err) {
|
||||
return nil, validators.ValidationError(validationError)
|
||||
}
|
||||
}
|
||||
|
||||
url := "/cloudapi/lb/get"
|
||||
|
||||
res, err := l.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
return res, err
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
"net/http"
|
||||
)
|
||||
|
||||
// Request struct for get list of load balancers
|
||||
// ListRequest struct to get list of load balancers
|
||||
type ListRequest struct {
|
||||
// Find by ID
|
||||
// Required: false
|
||||
@@ -53,11 +53,9 @@ type ListRequest struct {
|
||||
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
||||
}
|
||||
|
||||
// List gets list all load balancers
|
||||
// List gets list of all load balancers as a ListLB struct
|
||||
func (l LB) List(ctx context.Context, req ListRequest) (*ListLB, error) {
|
||||
url := "/cloudapi/lb/list"
|
||||
|
||||
res, err := l.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
res, err := l.ListRaw(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -71,3 +69,11 @@ func (l LB) List(ctx context.Context, req ListRequest) (*ListLB, error) {
|
||||
|
||||
return &list, nil
|
||||
}
|
||||
|
||||
// ListRaw gets list of all load balancers as an array of bytes
|
||||
func (l LB) ListRaw(ctx context.Context, req ListRequest) ([]byte, error) {
|
||||
url := "/cloudapi/lb/list"
|
||||
|
||||
res, err := l.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
return res, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user