This commit is contained in:
2026-06-05 17:14:39 +03:00
parent e9adcfec1c
commit fea00bbb42
157 changed files with 4837 additions and 251 deletions

View File

@@ -19,6 +19,12 @@ type DiskDetachRequest struct {
DiskID uint64 `url:"diskId" json:"diskId" validate:"required"`
}
type wrapperDiskDetachRequest struct {
DiskDetachRequest
AsyncMode bool `url:"asyncMode"`
}
// DiskDetach detach disk from compute
func (c Compute) DiskDetach(ctx context.Context, req DiskDetachRequest) (bool, error) {
err := validators.ValidateRequest(req)
@@ -26,9 +32,14 @@ func (c Compute) DiskDetach(ctx context.Context, req DiskDetachRequest) (bool, e
return false, validators.ValidationErrors(validators.GetErrors(err))
}
reqWrapped := wrapperDiskDetachRequest{
DiskDetachRequest: req,
AsyncMode: false,
}
url := "/cloudapi/compute/diskDetach"
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
if err != nil {
return false, err
}
@@ -40,3 +51,25 @@ func (c Compute) DiskDetach(ctx context.Context, req DiskDetachRequest) (bool, e
return result, nil
}
// DiskDetachAsync detaches disk from compute with AsyncMode
func (c Compute) DiskDetachAsync(ctx context.Context, req DiskDetachRequest) (string, error) {
err := validators.ValidateRequest(req)
if err != nil {
return "", validators.ValidationErrors(validators.GetErrors(err))
}
reqWrapped := wrapperDiskDetachRequest{
DiskDetachRequest: req,
AsyncMode: true,
}
url := "/cloudapi/compute/diskDetach"
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
if err != nil {
return "", err
}
return string(res), nil
}