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 grid details
// GetRequest struct to get grid details
type GetRequest struct {
// Grid (platform) ID
// Required: true
GID uint64 `url:"gridId" json:"gridId" validate:"required"`
}
// Get gets information about grid by ID
// Get gets information about grid by ID as a RecordGrid struct
func (g Grid) Get(ctx context.Context, req GetRequest) (*RecordGrid, error) {
err := validators.ValidateRequest(req)
if err != nil {
for _, validationError := range validators.GetErrors(err) {
return nil, validators.ValidationError(validationError)
}
}
url := "/cloudbroker/grid/get"
res, err := g.client.DecortApiCall(ctx, http.MethodPost, url, req)
res, err := g.GetRaw(ctx, req)
if err != nil {
return nil, err
}
@@ -40,3 +31,18 @@ func (g Grid) Get(ctx context.Context, req GetRequest) (*RecordGrid, error) {
return &info, nil
}
// GetRaw gets information about grid by ID as an array of bytes
func (g Grid) 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/grid/get"
res, err := g.client.DecortApiCall(ctx, http.MethodPost, url, req)
return res, err
}

View File

@@ -6,7 +6,7 @@ import (
"net/http"
)
// Request struct for get list locations
// ListRequest struct to get list of locations
type ListRequest struct {
// Find by id grid
// Required: false
@@ -25,11 +25,9 @@ type ListRequest struct {
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
}
// List gets list all locations
// List gets list of all locations as a ListGrids struct
func (g Grid) List(ctx context.Context, req ListRequest) (*ListGrids, error) {
url := "/cloudbroker/grid/list"
res, err := g.client.DecortApiCall(ctx, http.MethodPost, url, req)
res, err := g.ListRaw(ctx, req)
if err != nil {
return nil, err
}
@@ -43,3 +41,11 @@ func (g Grid) List(ctx context.Context, req ListRequest) (*ListGrids, error) {
return &list, nil
}
// ListRaw gets list of all locations as an array of bytes
func (g Grid) ListRaw(ctx context.Context, req ListRequest) ([]byte, error) {
url := "/cloudbroker/grid/list"
res, err := g.client.DecortApiCall(ctx, http.MethodPost, url, req)
return res, err
}