v1.16.1
This commit is contained in:
dayterr
2026-08-28 16:36:41 +03:00
parent eb195dd992
commit b3fccfb000
131 changed files with 3204 additions and 478 deletions

View File

@@ -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 := "/cloudapi/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 := "/cloudapi/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
}