v16.1.0
This commit is contained in:
dayterr
2026-08-28 16:47:26 +03:00
parent 3c5157281e
commit fe3c7bf63a
142 changed files with 3160 additions and 479 deletions

View File

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