v16.1.0
v16.1.0
This commit is contained in:
@@ -2,6 +2,7 @@ package disks
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
@@ -19,6 +20,12 @@ type ChangeDiskStoragePolicyRequest struct {
|
||||
StoragePolicyID uint64 `url:"storage_policy_id" json:"storage_policy_id" validate:"required"`
|
||||
}
|
||||
|
||||
type wrapperChangeDiskStoragePolicyRequest struct {
|
||||
ChangeDiskStoragePolicyRequest
|
||||
|
||||
AsyncMode bool `url:"async_mode" json:"async_mode"`
|
||||
}
|
||||
|
||||
// ChangeDiskStoragePolicy changes storage policy for disk
|
||||
func (d Disks) ChangeDiskStoragePolicy(ctx context.Context, req ChangeDiskStoragePolicyRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
@@ -28,7 +35,12 @@ func (d Disks) ChangeDiskStoragePolicy(ctx context.Context, req ChangeDiskStorag
|
||||
|
||||
url := "/cloudbroker/disks/change_disk_storage_policy"
|
||||
|
||||
res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
wrappedReq := wrapperChangeDiskStoragePolicyRequest{
|
||||
ChangeDiskStoragePolicyRequest: req,
|
||||
AsyncMode: false,
|
||||
}
|
||||
|
||||
res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, wrappedReq)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
@@ -40,3 +52,30 @@ func (d Disks) ChangeDiskStoragePolicy(ctx context.Context, req ChangeDiskStorag
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// ChangeDiskStoragePolicyAsync changes storage policy for disk in async mode
|
||||
func (d Disks) ChangeDiskStoragePolicyAsync(ctx context.Context, req ChangeDiskStoragePolicyRequest) (string, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/disks/change_disk_storage_policy"
|
||||
|
||||
wrappedReq := wrapperChangeDiskStoragePolicyRequest{
|
||||
ChangeDiskStoragePolicyRequest: req,
|
||||
AsyncMode: true,
|
||||
}
|
||||
|
||||
res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, wrappedReq)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
var result string
|
||||
if err := json.Unmarshal(res, &result); err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package disks
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
@@ -27,6 +28,12 @@ type DeleteRequest struct {
|
||||
Name string `url:"name,omitempty" json:"name,omitempty"`
|
||||
}
|
||||
|
||||
type wrapperDeleteRequest struct {
|
||||
DeleteRequest
|
||||
|
||||
AsyncMode bool `url:"async_mode" json:"async_mode"`
|
||||
}
|
||||
|
||||
// Delete deletes disk by ID
|
||||
func (d Disks) Delete(ctx context.Context, req DeleteRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
@@ -36,7 +43,12 @@ func (d Disks) Delete(ctx context.Context, req DeleteRequest) (bool, error) {
|
||||
|
||||
url := "/cloudbroker/disks/delete"
|
||||
|
||||
res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
wrappedReq := wrapperDeleteRequest{
|
||||
DeleteRequest: req,
|
||||
AsyncMode: false,
|
||||
}
|
||||
|
||||
res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, wrappedReq)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
@@ -48,3 +60,30 @@ func (d Disks) Delete(ctx context.Context, req DeleteRequest) (bool, error) {
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// Delete deletes disk by ID in async mode
|
||||
func (d Disks) DeleteAsync(ctx context.Context, req DeleteRequest) (string, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/disks/delete"
|
||||
|
||||
wrappedReq := wrapperDeleteRequest{
|
||||
DeleteRequest: req,
|
||||
AsyncMode: true,
|
||||
}
|
||||
|
||||
res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, wrappedReq)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
var result string
|
||||
if err := json.Unmarshal(res, &result); err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package disks
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
@@ -19,6 +20,12 @@ type DeleteDisksRequest struct {
|
||||
Permanently bool `url:"permanently,omitempty" json:"permanently,omitempty"`
|
||||
}
|
||||
|
||||
type wrapperDeleteDisksRequest struct {
|
||||
DeleteDisksRequest
|
||||
|
||||
AsyncMode bool `url:"async_mode" json:"async_mode"`
|
||||
}
|
||||
|
||||
// DeleteDisks deletes multiple disks permanently
|
||||
func (d Disks) DeleteDisks(ctx context.Context, req DeleteDisksRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
@@ -28,7 +35,12 @@ func (d Disks) DeleteDisks(ctx context.Context, req DeleteDisksRequest) (bool, e
|
||||
|
||||
url := "/cloudbroker/disks/deleteDisks"
|
||||
|
||||
res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
wrappedReq := wrapperDeleteDisksRequest{
|
||||
DeleteDisksRequest: req,
|
||||
AsyncMode: false,
|
||||
}
|
||||
|
||||
res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, wrappedReq)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
@@ -40,3 +52,30 @@ func (d Disks) DeleteDisks(ctx context.Context, req DeleteDisksRequest) (bool, e
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// DeleteDisks deletes multiple disks permanently in async mode
|
||||
func (d Disks) DeleteDisksAsync(ctx context.Context, req DeleteDisksRequest) (string, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/disks/deleteDisks"
|
||||
|
||||
wrappedReq := wrapperDeleteDisksRequest{
|
||||
DeleteDisksRequest: req,
|
||||
AsyncMode: true,
|
||||
}
|
||||
|
||||
res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, wrappedReq)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
var result string
|
||||
if err := json.Unmarshal(res, &result); err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package disks
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
@@ -19,6 +20,12 @@ type DepresentRequest struct {
|
||||
NodeID uint64 `url:"nodeId" json:"nodeId" validate:"required"`
|
||||
}
|
||||
|
||||
type wrapperDepresentRequest struct {
|
||||
DepresentRequest
|
||||
|
||||
AsyncMode bool `url:"async_mode" json:"async_mode"`
|
||||
}
|
||||
|
||||
// Depresent depresents disk from node
|
||||
func (d Disks) Depresent(ctx context.Context, req DepresentRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
@@ -28,7 +35,12 @@ func (d Disks) Depresent(ctx context.Context, req DepresentRequest) (bool, error
|
||||
|
||||
url := "/cloudbroker/disks/depresent"
|
||||
|
||||
res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
wrappedReq := wrapperDepresentRequest{
|
||||
DepresentRequest: req,
|
||||
AsyncMode: false,
|
||||
}
|
||||
|
||||
res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, wrappedReq)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
@@ -40,3 +52,30 @@ func (d Disks) Depresent(ctx context.Context, req DepresentRequest) (bool, error
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// Depresent depresents disk from node in async mode
|
||||
func (d Disks) DepresentAsync(ctx context.Context, req DepresentRequest) (string, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/disks/depresent"
|
||||
|
||||
wrappedReq := wrapperDepresentRequest{
|
||||
DepresentRequest: req,
|
||||
AsyncMode: true,
|
||||
}
|
||||
|
||||
res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, wrappedReq)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
var result string
|
||||
if err := json.Unmarshal(res, &result); err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
@@ -17,4 +17,3 @@ func (ldu ListUnattachedDisks) IDs() []uint64 {
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ package disks
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
@@ -71,6 +72,12 @@ type LimitIORequest struct {
|
||||
SizeIOPSSec uint64 `url:"size_iops_sec,omitempty" json:"size_iops_sec,omitempty"`
|
||||
}
|
||||
|
||||
type wrapperLimitIORequest struct {
|
||||
LimitIORequest
|
||||
|
||||
AsyncMode bool `url:"async_mode" json:"async_mode"`
|
||||
}
|
||||
|
||||
// LimitIO limits IO for a certain disk
|
||||
// total and read/write options are not allowed to be combined
|
||||
// see http://libvirt.org/formatdomain.html#elementsDisks iotune section for more details
|
||||
@@ -82,7 +89,12 @@ func (d Disks) LimitIO(ctx context.Context, req LimitIORequest) (bool, error) {
|
||||
|
||||
url := "/cloudbroker/disks/limitIO"
|
||||
|
||||
res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
wrappedReq := wrapperLimitIORequest{
|
||||
LimitIORequest: req,
|
||||
AsyncMode: false,
|
||||
}
|
||||
|
||||
res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, wrappedReq)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
@@ -94,3 +106,32 @@ func (d Disks) LimitIO(ctx context.Context, req LimitIORequest) (bool, error) {
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// LimitIOAsync limits IO for a certain disk in async mode
|
||||
// total and read/write options are not allowed to be combined
|
||||
// see http://libvirt.org/formatdomain.html#elementsDisks iotune section for more details
|
||||
func (d Disks) LimitIOAsync(ctx context.Context, req LimitIORequest) (string, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/disks/limitIO"
|
||||
|
||||
wrappedReq := wrapperLimitIORequest{
|
||||
LimitIORequest: req,
|
||||
AsyncMode: true,
|
||||
}
|
||||
|
||||
res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, wrappedReq)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
var result string
|
||||
if err := json.Unmarshal(res, &result); err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package disks
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
@@ -15,6 +16,12 @@ type MigrateAbortRequest struct {
|
||||
DiskID uint64 `url:"disk_id" json:"disk_id" validate:"required"`
|
||||
}
|
||||
|
||||
type wrapperMigrateAbortRequest struct {
|
||||
MigrateAbortRequest
|
||||
|
||||
AsyncMode bool `url:"async_mode" json:"async_mode"`
|
||||
}
|
||||
|
||||
// MigrateAbort aborts disk migration
|
||||
func (c Disks) MigrateAbort(ctx context.Context, req MigrateAbortRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
@@ -24,7 +31,12 @@ func (c Disks) MigrateAbort(ctx context.Context, req MigrateAbortRequest) (bool,
|
||||
|
||||
url := "/cloudbroker/disks/migrate_abort"
|
||||
|
||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
wrappedReq := wrapperMigrateAbortRequest{
|
||||
MigrateAbortRequest: req,
|
||||
AsyncMode: false,
|
||||
}
|
||||
|
||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, wrappedReq)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
@@ -36,3 +48,30 @@ func (c Disks) MigrateAbort(ctx context.Context, req MigrateAbortRequest) (bool,
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// MigrateAbortAsync aborts disk migration in async mode
|
||||
func (c Disks) MigrateAbortAsync(ctx context.Context, req MigrateAbortRequest) (string, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/disks/migrate_abort"
|
||||
|
||||
wrappedReq := wrapperMigrateAbortRequest{
|
||||
MigrateAbortRequest: req,
|
||||
AsyncMode: true,
|
||||
}
|
||||
|
||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, wrappedReq)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
var result string
|
||||
if err := json.Unmarshal(res, &result); err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package disks
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
@@ -19,6 +20,12 @@ type PresentRequest struct {
|
||||
NodeID uint64 `url:"nodeId" json:"nodeId" validate:"required"`
|
||||
}
|
||||
|
||||
type wrapperPresentRequest struct {
|
||||
PresentRequest
|
||||
|
||||
AsyncMode bool `url:"async_mode" json:"async_mode"`
|
||||
}
|
||||
|
||||
// Present presents disk to node
|
||||
func (d Disks) Present(ctx context.Context, req PresentRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
@@ -28,7 +35,12 @@ func (d Disks) Present(ctx context.Context, req PresentRequest) (bool, error) {
|
||||
|
||||
url := "/cloudbroker/disks/present"
|
||||
|
||||
res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
wrappedReq := wrapperPresentRequest{
|
||||
PresentRequest: req,
|
||||
AsyncMode: false,
|
||||
}
|
||||
|
||||
res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, wrappedReq)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
@@ -40,3 +52,30 @@ func (d Disks) Present(ctx context.Context, req PresentRequest) (bool, error) {
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// PresentAsync presents disk to node in async mode
|
||||
func (d Disks) PresentAsync(ctx context.Context, req PresentRequest) (string, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/disks/present"
|
||||
|
||||
wrappedReq := wrapperPresentRequest{
|
||||
PresentRequest: req,
|
||||
AsyncMode: true,
|
||||
}
|
||||
|
||||
res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, wrappedReq)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
var result string
|
||||
if err := json.Unmarshal(res, &result); err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package disks
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
@@ -19,6 +20,12 @@ type RenameRequest struct {
|
||||
Name string `url:"name" json:"name" validate:"required"`
|
||||
}
|
||||
|
||||
type wrapperRenameRequest struct {
|
||||
RenameRequest
|
||||
|
||||
AsyncMode bool `url:"async_mode" json:"async_mode"`
|
||||
}
|
||||
|
||||
// Rename renames disk
|
||||
func (d Disks) Rename(ctx context.Context, req RenameRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
@@ -28,7 +35,12 @@ func (d Disks) Rename(ctx context.Context, req RenameRequest) (bool, error) {
|
||||
|
||||
url := "/cloudbroker/disks/rename"
|
||||
|
||||
res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
wrappedReq := wrapperRenameRequest{
|
||||
RenameRequest: req,
|
||||
AsyncMode: false,
|
||||
}
|
||||
|
||||
res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, wrappedReq)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
@@ -40,3 +52,30 @@ func (d Disks) Rename(ctx context.Context, req RenameRequest) (bool, error) {
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// RenameAsync renames disk in async mode
|
||||
func (d Disks) RenameAsync(ctx context.Context, req RenameRequest) (string, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/disks/rename"
|
||||
|
||||
wrappedReq := wrapperRenameRequest{
|
||||
RenameRequest: req,
|
||||
AsyncMode: true,
|
||||
}
|
||||
|
||||
res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, wrappedReq)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
var result string
|
||||
if err := json.Unmarshal(res, &result); err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package disks
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
@@ -31,6 +32,12 @@ type ReplicateRequest struct {
|
||||
StoragePolicyID uint64 `url:"storage_policy_id" json:"storage_policy_id" validate:"required"`
|
||||
}
|
||||
|
||||
type wrapperReplicateRequest struct {
|
||||
ReplicateRequest
|
||||
|
||||
AsyncMode bool `url:"async_mode" json:"async_mode"`
|
||||
}
|
||||
|
||||
// Replicate create an empty disk in chosen SEP and pool combination.
|
||||
// Starts replication between chosen disk and newly created disk
|
||||
// Note: only TATLIN type SEP are supported for replications between
|
||||
@@ -42,7 +49,12 @@ func (d Disks) Replicate(ctx context.Context, req ReplicateRequest) (uint64, err
|
||||
|
||||
url := "/cloudbroker/disks/replicate"
|
||||
|
||||
res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
wrappedReq := wrapperReplicateRequest{
|
||||
ReplicateRequest: req,
|
||||
AsyncMode: false,
|
||||
}
|
||||
|
||||
res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, wrappedReq)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
@@ -54,3 +66,32 @@ func (d Disks) Replicate(ctx context.Context, req ReplicateRequest) (uint64, err
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// ReplicateAsync creates an empty disk in chosen SEP and pool combination in async mode.
|
||||
// Starts replication between chosen disk and newly created disk
|
||||
// Note: only TATLIN type SEP are supported for replications between
|
||||
func (d Disks) ReplicateAsync(ctx context.Context, req ReplicateRequest) (string, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/disks/replicate"
|
||||
|
||||
wrappedReq := wrapperReplicateRequest{
|
||||
ReplicateRequest: req,
|
||||
AsyncMode: true,
|
||||
}
|
||||
|
||||
res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, wrappedReq)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
var result string
|
||||
if err := json.Unmarshal(res, &result); err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package disks
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
@@ -15,6 +16,12 @@ type ReplicationResumeRequest struct {
|
||||
DiskID uint64 `url:"diskId" json:"diskId" validate:"required"`
|
||||
}
|
||||
|
||||
type wrapperReplicationResumeRequest struct {
|
||||
ReplicationResumeRequest
|
||||
|
||||
AsyncMode bool `url:"async_mode" json:"async_mode"`
|
||||
}
|
||||
|
||||
// ReplicationResume resume suspended replication
|
||||
func (d Disks) ReplicationResume(ctx context.Context, req ReplicationResumeRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
@@ -24,7 +31,12 @@ func (d Disks) ReplicationResume(ctx context.Context, req ReplicationResumeReque
|
||||
|
||||
url := "/cloudbroker/disks/replicationResume"
|
||||
|
||||
res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
wrappedReq := wrapperReplicationResumeRequest{
|
||||
ReplicationResumeRequest: req,
|
||||
AsyncMode: false,
|
||||
}
|
||||
|
||||
res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, wrappedReq)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
@@ -36,3 +48,30 @@ func (d Disks) ReplicationResume(ctx context.Context, req ReplicationResumeReque
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// ReplicationResumeAsync resumes suspended replication in async mode
|
||||
func (d Disks) ReplicationResumeAsync(ctx context.Context, req ReplicationResumeRequest) (string, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/disks/replicationResume"
|
||||
|
||||
wrappedReq := wrapperReplicationResumeRequest{
|
||||
ReplicationResumeRequest: req,
|
||||
AsyncMode: true,
|
||||
}
|
||||
|
||||
res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, wrappedReq)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
var result string
|
||||
if err := json.Unmarshal(res, &result); err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package disks
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
@@ -15,6 +16,12 @@ type ReplicationReverseRequest struct {
|
||||
DiskID uint64 `url:"diskId" json:"diskId" validate:"required"`
|
||||
}
|
||||
|
||||
type wrapperReplicationReverseRequest struct {
|
||||
ReplicationReverseRequest
|
||||
|
||||
AsyncMode bool `url:"async_mode" json:"async_mode"`
|
||||
}
|
||||
|
||||
// ReplicationReverse change role between disks replications
|
||||
func (d Disks) ReplicationReverse(ctx context.Context, req ReplicationReverseRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
@@ -24,7 +31,12 @@ func (d Disks) ReplicationReverse(ctx context.Context, req ReplicationReverseReq
|
||||
|
||||
url := "/cloudbroker/disks/replicationReverse"
|
||||
|
||||
res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
wrappedReq := wrapperReplicationReverseRequest{
|
||||
ReplicationReverseRequest: req,
|
||||
AsyncMode: false,
|
||||
}
|
||||
|
||||
res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, wrappedReq)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
@@ -36,3 +48,30 @@ func (d Disks) ReplicationReverse(ctx context.Context, req ReplicationReverseReq
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// ReplicationReverseAsync changes role between disks replications in async mode
|
||||
func (d Disks) ReplicationReverseAsync(ctx context.Context, req ReplicationReverseRequest) (string, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/disks/replicationReverse"
|
||||
|
||||
wrappedReq := wrapperReplicationReverseRequest{
|
||||
ReplicationReverseRequest: req,
|
||||
AsyncMode: true,
|
||||
}
|
||||
|
||||
res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, wrappedReq)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
var result string
|
||||
if err := json.Unmarshal(res, &result); err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package disks
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
@@ -19,6 +20,12 @@ type ReplicationStartRequest struct {
|
||||
TargetDiskID uint64 `url:"targetDiskId" json:"targetDiskId" validate:"required"`
|
||||
}
|
||||
|
||||
type wrapperReplicationStartRequest struct {
|
||||
ReplicationStartRequest
|
||||
|
||||
AsyncMode bool `url:"async_mode" json:"async_mode"`
|
||||
}
|
||||
|
||||
// ReplicationStart starts replication between two chosen disks. It's required for both disks to have same size to avoid replication conflicts
|
||||
// Note: Source disk's SEP and target SEP supported only of TATLIN type.
|
||||
func (d Disks) ReplicationStart(ctx context.Context, req ReplicationStartRequest) (bool, error) {
|
||||
@@ -29,7 +36,12 @@ func (d Disks) ReplicationStart(ctx context.Context, req ReplicationStartRequest
|
||||
|
||||
url := "/cloudbroker/disks/replicationStart"
|
||||
|
||||
res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
wrappedReq := wrapperReplicationStartRequest{
|
||||
ReplicationStartRequest: req,
|
||||
AsyncMode: false,
|
||||
}
|
||||
|
||||
res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, wrappedReq)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
@@ -41,3 +53,31 @@ func (d Disks) ReplicationStart(ctx context.Context, req ReplicationStartRequest
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// ReplicationStartAsync starts replication between two chosen disks in async mode. It's required for both disks to have same size to avoid replication conflicts
|
||||
// Note: Source disk's SEP and target SEP supported only of TATLIN type.
|
||||
func (d Disks) ReplicationStartAsync(ctx context.Context, req ReplicationStartRequest) (string, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/disks/replicationStart"
|
||||
|
||||
wrappedReq := wrapperReplicationStartRequest{
|
||||
ReplicationStartRequest: req,
|
||||
AsyncMode: true,
|
||||
}
|
||||
|
||||
res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, wrappedReq)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
var result string
|
||||
if err := json.Unmarshal(res, &result); err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package disks
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
@@ -15,6 +16,12 @@ type ReplicationStopRequest struct {
|
||||
DiskID uint64 `url:"diskId" json:"diskId" validate:"required"`
|
||||
}
|
||||
|
||||
type wrapperReplicationStopRequest struct {
|
||||
ReplicationStopRequest
|
||||
|
||||
AsyncMode bool `url:"async_mode" json:"async_mode"`
|
||||
}
|
||||
|
||||
// ReplicationStop remove replication between disks completely
|
||||
func (d Disks) ReplicationStop(ctx context.Context, req ReplicationStopRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
@@ -24,7 +31,12 @@ func (d Disks) ReplicationStop(ctx context.Context, req ReplicationStopRequest)
|
||||
|
||||
url := "/cloudbroker/disks/replicationStop"
|
||||
|
||||
res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
wrappedReq := wrapperReplicationStopRequest{
|
||||
ReplicationStopRequest: req,
|
||||
AsyncMode: false,
|
||||
}
|
||||
|
||||
res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, wrappedReq)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
@@ -36,3 +48,30 @@ func (d Disks) ReplicationStop(ctx context.Context, req ReplicationStopRequest)
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// ReplicationStopAsync removes replication between disks completely in async mode
|
||||
func (d Disks) ReplicationStopAsync(ctx context.Context, req ReplicationStopRequest) (string, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/disks/replicationStop"
|
||||
|
||||
wrappedReq := wrapperReplicationStopRequest{
|
||||
ReplicationStopRequest: req,
|
||||
AsyncMode: true,
|
||||
}
|
||||
|
||||
res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, wrappedReq)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
var result string
|
||||
if err := json.Unmarshal(res, &result); err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package disks
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
@@ -15,6 +16,12 @@ type ReplicationSuspendRequest struct {
|
||||
DiskID uint64 `url:"diskId" json:"diskId" validate:"required"`
|
||||
}
|
||||
|
||||
type wrapperReplicationSuspendRequest struct {
|
||||
ReplicationSuspendRequest
|
||||
|
||||
AsyncMode bool `url:"async_mode" json:"async_mode"`
|
||||
}
|
||||
|
||||
// ReplicationSuspend pause replication with possibility to resume from pause moment
|
||||
func (d Disks) ReplicationSuspend(ctx context.Context, req ReplicationSuspendRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
@@ -24,7 +31,12 @@ func (d Disks) ReplicationSuspend(ctx context.Context, req ReplicationSuspendReq
|
||||
|
||||
url := "/cloudbroker/disks/replicationSuspend"
|
||||
|
||||
res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
wrappedReq := wrapperReplicationSuspendRequest{
|
||||
ReplicationSuspendRequest: req,
|
||||
AsyncMode: false,
|
||||
}
|
||||
|
||||
res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, wrappedReq)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
@@ -36,3 +48,30 @@ func (d Disks) ReplicationSuspend(ctx context.Context, req ReplicationSuspendReq
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// ReplicationSuspendAsync pauses replication with possibility to resume from pause moment in async mode
|
||||
func (d Disks) ReplicationSuspendAsync(ctx context.Context, req ReplicationSuspendRequest) (string, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/disks/replicationSuspend"
|
||||
|
||||
wrappedReq := wrapperReplicationSuspendRequest{
|
||||
ReplicationSuspendRequest: req,
|
||||
AsyncMode: true,
|
||||
}
|
||||
|
||||
res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, wrappedReq)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
var result string
|
||||
if err := json.Unmarshal(res, &result); err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package disks
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
@@ -19,6 +20,12 @@ type ResizeRequest struct {
|
||||
Size uint64 `url:"size" json:"size" validate:"required"`
|
||||
}
|
||||
|
||||
type wrapperResizeRequest struct {
|
||||
ResizeRequest
|
||||
|
||||
AsyncMode bool `url:"async_mode" json:"async_mode"`
|
||||
}
|
||||
|
||||
// Resize2 resize disk
|
||||
// Returns 200 if disk is resized online, else will return 202,
|
||||
// in that case please stop and start your machine after changing the disk size, for your changes to be reflected.
|
||||
@@ -31,7 +38,12 @@ func (d Disks) Resize2(ctx context.Context, req ResizeRequest) (bool, error) {
|
||||
|
||||
url := "/cloudbroker/disks/resize2"
|
||||
|
||||
res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
wrappedReq := wrapperResizeRequest{
|
||||
ResizeRequest: req,
|
||||
AsyncMode: false,
|
||||
}
|
||||
|
||||
res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, wrappedReq)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
@@ -43,3 +55,33 @@ func (d Disks) Resize2(ctx context.Context, req ResizeRequest) (bool, error) {
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// Resize2Async resizes disk in async mode
|
||||
// Returns 200 if disk is resized online, else will return 202,
|
||||
// in that case please stop and start your machine after changing the disk size, for your changes to be reflected.
|
||||
// This method will not be used for disks, assigned to "old" virtual machines. Only unassigned disks and disks, assigned with computes.
|
||||
func (d Disks) Resize2Async(ctx context.Context, req ResizeRequest) (string, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/disks/resize2"
|
||||
|
||||
wrappedReq := wrapperResizeRequest{
|
||||
ResizeRequest: req,
|
||||
AsyncMode: true,
|
||||
}
|
||||
|
||||
res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, wrappedReq)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
var result string
|
||||
if err := json.Unmarshal(res, &result); err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package disks
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
@@ -15,6 +16,12 @@ type RestoreRequest struct {
|
||||
DiskID uint64 `url:"diskId" json:"diskId" validate:"required"`
|
||||
}
|
||||
|
||||
type wrapperRestoreRequest struct {
|
||||
RestoreRequest
|
||||
|
||||
AsyncMode bool `url:"async_mode" json:"async_mode"`
|
||||
}
|
||||
|
||||
// Restore restores a deleted unattached disk from recycle bin
|
||||
func (d Disks) Restore(ctx context.Context, req RestoreRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
@@ -24,7 +31,12 @@ func (d Disks) Restore(ctx context.Context, req RestoreRequest) (bool, error) {
|
||||
|
||||
url := "/cloudbroker/disks/restore"
|
||||
|
||||
res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
wrappedReq := wrapperRestoreRequest{
|
||||
RestoreRequest: req,
|
||||
AsyncMode: false,
|
||||
}
|
||||
|
||||
res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, wrappedReq)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
@@ -36,3 +48,30 @@ func (d Disks) Restore(ctx context.Context, req RestoreRequest) (bool, error) {
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// RestoreAsync restores a deleted unattached disk from recycle bin in async mode
|
||||
func (d Disks) RestoreAsync(ctx context.Context, req RestoreRequest) (string, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/disks/restore"
|
||||
|
||||
wrappedReq := wrapperRestoreRequest{
|
||||
RestoreRequest: req,
|
||||
AsyncMode: true,
|
||||
}
|
||||
|
||||
res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, wrappedReq)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
var result string
|
||||
if err := json.Unmarshal(res, &result); err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package disks
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
@@ -15,6 +16,12 @@ type ShareRequest struct {
|
||||
DiskID uint64 `url:"diskId" json:"diskId" validate:"required"`
|
||||
}
|
||||
|
||||
type wrapperShareRequest struct {
|
||||
ShareRequest
|
||||
|
||||
AsyncMode bool `url:"async_mode" json:"async_mode"`
|
||||
}
|
||||
|
||||
// Share shares data disk
|
||||
func (d Disks) Share(ctx context.Context, req ShareRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
@@ -24,7 +31,12 @@ func (d Disks) Share(ctx context.Context, req ShareRequest) (bool, error) {
|
||||
|
||||
url := "/cloudbroker/disks/share"
|
||||
|
||||
res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
wrappedReq := wrapperShareRequest{
|
||||
ShareRequest: req,
|
||||
AsyncMode: false,
|
||||
}
|
||||
|
||||
res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, wrappedReq)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
@@ -36,3 +48,30 @@ func (d Disks) Share(ctx context.Context, req ShareRequest) (bool, error) {
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// ShareAsync shares data disk in async mode
|
||||
func (d Disks) ShareAsync(ctx context.Context, req ShareRequest) (string, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/disks/share"
|
||||
|
||||
wrappedReq := wrapperShareRequest{
|
||||
ShareRequest: req,
|
||||
AsyncMode: true,
|
||||
}
|
||||
|
||||
res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, wrappedReq)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
var result string
|
||||
if err := json.Unmarshal(res, &result); err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package disks
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
@@ -19,6 +20,12 @@ type SnapshotDeleteRequest struct {
|
||||
Label string `url:"label" json:"label" validate:"required"`
|
||||
}
|
||||
|
||||
type wrapperSnapshotDeleteRequest struct {
|
||||
SnapshotDeleteRequest
|
||||
|
||||
AsyncMode bool `url:"async_mode" json:"async_mode"`
|
||||
}
|
||||
|
||||
// SnapshotDelete deletes a snapshot
|
||||
func (d Disks) SnapshotDelete(ctx context.Context, req SnapshotDeleteRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
@@ -28,7 +35,12 @@ func (d Disks) SnapshotDelete(ctx context.Context, req SnapshotDeleteRequest) (b
|
||||
|
||||
url := "/cloudbroker/disks/snapshotDelete"
|
||||
|
||||
res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
wrappedReq := wrapperSnapshotDeleteRequest{
|
||||
SnapshotDeleteRequest: req,
|
||||
AsyncMode: false,
|
||||
}
|
||||
|
||||
res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, wrappedReq)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
@@ -40,3 +52,30 @@ func (d Disks) SnapshotDelete(ctx context.Context, req SnapshotDeleteRequest) (b
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// SnapshotDeleteAsync deletes a snapshot in async mode
|
||||
func (d Disks) SnapshotDeleteAsync(ctx context.Context, req SnapshotDeleteRequest) (string, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/disks/snapshotDelete"
|
||||
|
||||
wrappedReq := wrapperSnapshotDeleteRequest{
|
||||
SnapshotDeleteRequest: req,
|
||||
AsyncMode: true,
|
||||
}
|
||||
|
||||
res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, wrappedReq)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
var result string
|
||||
if err := json.Unmarshal(res, &result); err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package disks
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
@@ -23,6 +24,12 @@ type SnapshotRollbackRequest struct {
|
||||
TimeStamp uint64 `url:"timestamp,omitempty" json:"timestamp,omitempty"`
|
||||
}
|
||||
|
||||
type wrapperSnapshotRollbackRequest struct {
|
||||
SnapshotRollbackRequest
|
||||
|
||||
AsyncMode bool `url:"async_mode" json:"async_mode"`
|
||||
}
|
||||
|
||||
// SnapshotRollback rollbacks an individual disk snapshot
|
||||
func (d Disks) SnapshotRollback(ctx context.Context, req SnapshotRollbackRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
@@ -32,7 +39,12 @@ func (d Disks) SnapshotRollback(ctx context.Context, req SnapshotRollbackRequest
|
||||
|
||||
url := "/cloudbroker/disks/snapshotRollback"
|
||||
|
||||
res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
wrappedReq := wrapperSnapshotRollbackRequest{
|
||||
SnapshotRollbackRequest: req,
|
||||
AsyncMode: false,
|
||||
}
|
||||
|
||||
res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, wrappedReq)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
@@ -44,3 +56,30 @@ func (d Disks) SnapshotRollback(ctx context.Context, req SnapshotRollbackRequest
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// SnapshotRollbackAsync rollbacks an individual disk snapshot in async mode
|
||||
func (d Disks) SnapshotRollbackAsync(ctx context.Context, req SnapshotRollbackRequest) (string, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/disks/snapshotRollback"
|
||||
|
||||
wrappedReq := wrapperSnapshotRollbackRequest{
|
||||
SnapshotRollbackRequest: req,
|
||||
AsyncMode: true,
|
||||
}
|
||||
|
||||
res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, wrappedReq)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
var result string
|
||||
if err := json.Unmarshal(res, &result); err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package disks
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
@@ -15,6 +16,12 @@ type UnshareRequest struct {
|
||||
DiskID uint64 `url:"diskId" json:"diskId" validate:"required"`
|
||||
}
|
||||
|
||||
type wrapperUnshareRequest struct {
|
||||
UnshareRequest
|
||||
|
||||
AsyncMode bool `url:"async_mode" json:"async_mode"`
|
||||
}
|
||||
|
||||
// Unshare unshares data disk
|
||||
func (d Disks) Unshare(ctx context.Context, req UnshareRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
@@ -24,7 +31,12 @@ func (d Disks) Unshare(ctx context.Context, req UnshareRequest) (bool, error) {
|
||||
|
||||
url := "/cloudbroker/disks/unshare"
|
||||
|
||||
res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
wrappedReq := wrapperUnshareRequest{
|
||||
UnshareRequest: req,
|
||||
AsyncMode: false,
|
||||
}
|
||||
|
||||
res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, wrappedReq)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
@@ -36,3 +48,30 @@ func (d Disks) Unshare(ctx context.Context, req UnshareRequest) (bool, error) {
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// UnshareAsync unshares data disk in async mode
|
||||
func (d Disks) UnshareAsync(ctx context.Context, req UnshareRequest) (string, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/disks/unshare"
|
||||
|
||||
wrappedReq := wrapperUnshareRequest{
|
||||
UnshareRequest: req,
|
||||
AsyncMode: true,
|
||||
}
|
||||
|
||||
res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, wrappedReq)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
var result string
|
||||
if err := json.Unmarshal(res, &result); err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package disks
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
@@ -27,6 +28,12 @@ type UpdateRequest struct {
|
||||
BlockSize string `url:"block_size,omitempty" json:"block_size,omitempty"`
|
||||
}
|
||||
|
||||
type wrapperUpdateRequest struct {
|
||||
UpdateRequest
|
||||
|
||||
AsyncMode bool `url:"async_mode" json:"async_mode"`
|
||||
}
|
||||
|
||||
// Update updates disk
|
||||
func (d Disks) Update(ctx context.Context, req UpdateRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
@@ -36,7 +43,12 @@ func (d Disks) Update(ctx context.Context, req UpdateRequest) (bool, error) {
|
||||
|
||||
url := "/cloudbroker/disks/update"
|
||||
|
||||
res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
wrappedReq := wrapperUpdateRequest{
|
||||
UpdateRequest: req,
|
||||
AsyncMode: false,
|
||||
}
|
||||
|
||||
res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, wrappedReq)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
@@ -48,3 +60,30 @@ func (d Disks) Update(ctx context.Context, req UpdateRequest) (bool, error) {
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// UpdateAsync updates disk in async mode
|
||||
func (d Disks) UpdateAsync(ctx context.Context, req UpdateRequest) (string, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/disks/update"
|
||||
|
||||
wrappedReq := wrapperUpdateRequest{
|
||||
UpdateRequest: req,
|
||||
AsyncMode: true,
|
||||
}
|
||||
|
||||
res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, wrappedReq)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
var result string
|
||||
if err := json.Unmarshal(res, &result); err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user