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 info of stack
// GetRequest struct to get info of stack
type GetRequest struct {
// Find by ID
// Required: true
StackId uint64 `url:"stackId" json:"stackId" validate:"required"`
}
// Get stack details by ID
// Get gets stack details by ID as an InfoStack struct
func (i Stack) Get(ctx context.Context, req GetRequest) (*InfoStack, error) {
err := validators.ValidateRequest(req)
if err != nil {
for _, validationError := range validators.GetErrors(err) {
return nil, validators.ValidationError(validationError)
}
}
url := "/cloudapi/stack/get"
res, err := i.client.DecortApiCall(ctx, http.MethodPost, url, req)
res, err := i.GetRaw(ctx, req)
if err != nil {
return nil, err
}
@@ -40,3 +31,18 @@ func (i Stack) Get(ctx context.Context, req GetRequest) (*InfoStack, error) {
return &info, nil
}
// GetRaw gets stack details by ID as an array of bytes
func (i Stack) 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/stack/get"
res, err := i.client.DecortApiCall(ctx, http.MethodPost, url, req)
return res, err
}

View File

@@ -6,7 +6,7 @@ import (
"net/http"
)
// Request struct for get list stack
// ListRequest struct to get list of stacks
type ListRequest struct {
// Find by ID
// Required: false
@@ -33,11 +33,9 @@ type ListRequest struct {
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
}
// ListStacks gets list stack
// List gets list of stacks as a ListStacks struct
func (i Stack) List(ctx context.Context, req ListRequest) (*ListStacks, error) {
url := "/cloudapi/stack/list"
res, err := i.client.DecortApiCall(ctx, http.MethodPost, url, req)
res, err := i.ListRaw(ctx, req)
if err != nil {
return nil, err
}
@@ -51,3 +49,11 @@ func (i Stack) List(ctx context.Context, req ListRequest) (*ListStacks, error) {
return &list, nil
}
// ListRaw gets list of stacks as an array of bytes
func (i Stack) ListRaw(ctx context.Context, req ListRequest) ([]byte, error) {
url := "/cloudapi/stack/list"
res, err := i.client.DecortApiCall(ctx, http.MethodPost, url, req)
return res, err
}