v1.15.0
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user