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"
@@ -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
}