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,9 +2,11 @@ package disks
import (
"context"
"encoding/json"
"net/http"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
"strconv"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
// DepresentRequest struct to depresent disk from node
@@ -18,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)
@@ -27,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
}
@@ -39,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
}