This commit is contained in:
2023-10-23 12:40:54 +03:00
parent b069c31745
commit b666789c7d
73 changed files with 1134 additions and 641 deletions

View File

@@ -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 (lb 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 := "/cloudbroker/lb/get"
res, err := lb.client.DecortApiCall(ctx, http.MethodPost, url, req)
res, err := lb.GetRaw(ctx, req)
if err != nil {
return nil, err
}
@@ -40,3 +31,18 @@ func (lb 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 (lb 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 := "/cloudbroker/lb/get"
res, err := lb.client.DecortApiCall(ctx, http.MethodPost, url, req)
return res, err
}

View File

@@ -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 (lb LB) List(ctx context.Context, req ListRequest) (*ListLB, error) {
url := "/cloudbroker/lb/list"
res, err := lb.client.DecortApiCall(ctx, http.MethodPost, url, req)
res, err := lb.ListRaw(ctx, req)
if err != nil {
return nil, err
}
@@ -70,5 +68,12 @@ func (lb 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 (lb LB) ListRaw(ctx context.Context, req ListRequest) ([]byte, error) {
url := "/cloudbroker/lb/list"
res, err := lb.client.DecortApiCall(ctx, http.MethodPost, url, req)
return res, err
}