This commit is contained in:
2026-08-21 17:52:28 +04:00
parent d7b8f08b4d
commit 578caa5081
116 changed files with 2721 additions and 1973 deletions

View File

@@ -47,6 +47,12 @@ type CreateRequest struct {
Discard string `url:"discard,omitempty" json:"discard,omitempty"`
}
type wrapperCreateRequest struct {
CreateRequest
AsyncMode bool `url:"async_mode" json:"async_mode"`
}
// Create creates a disk
func (d Disks) Create(ctx context.Context, req CreateRequest) (uint64, error) {
err := validators.ValidateRequest(req)
@@ -56,7 +62,12 @@ func (d Disks) Create(ctx context.Context, req CreateRequest) (uint64, error) {
url := "/cloudbroker/disks/create"
res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, req)
wrappedReq := wrapperCreateRequest{
CreateRequest: req,
AsyncMode: false,
}
res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, wrappedReq)
if err != nil {
return 0, err
}
@@ -68,3 +79,25 @@ func (d Disks) Create(ctx context.Context, req CreateRequest) (uint64, error) {
return result, nil
}
// Create creates a disk in async mode
func (d Disks) CreateAsync(ctx context.Context, req CreateRequest) (string, error) {
err := validators.ValidateRequest(req)
if err != nil {
return "", validators.ValidationErrors(validators.GetErrors(err))
}
url := "/cloudbroker/disks/create"
wrappedReq := wrapperCreateRequest{
CreateRequest: req,
AsyncMode: true,
}
res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, wrappedReq)
if err != nil {
return "", err
}
return string(res), nil
}