v1.16.7
This commit is contained in:
dayterr
2026-10-09 16:23:35 +03:00
parent 25e2242360
commit 8cde0e9371
80 changed files with 2303 additions and 606 deletions

View File

@@ -2,6 +2,7 @@ package vgpu
import (
"context"
"encoding/json"
"net/http"
"strconv"
@@ -15,6 +16,11 @@ type DestroyRequest struct {
VGPUID uint64 `url:"vgpu_id" json:"vgpu_id" validate:"required"`
}
type asyncWrapperDestroyRequest struct {
DestroyRequest
AsyncMode bool `url:"async_mode"`
}
// Destroy destroys VGPU
func (v VGPU) Destroy(ctx context.Context, req DestroyRequest) (bool, error) {
err := validators.ValidateRequest(req)
@@ -24,7 +30,12 @@ func (v VGPU) Destroy(ctx context.Context, req DestroyRequest) (bool, error) {
url := "/cloudbroker/vgpu/destroy"
res, err := v.client.DecortApiCall(ctx, http.MethodPost, url, req)
aReq := asyncWrapperDestroyRequest{
DestroyRequest: req,
AsyncMode: false,
}
res, err := v.client.DecortApiCall(ctx, http.MethodPost, url, aReq)
if err != nil {
return false, err
}
@@ -36,3 +47,32 @@ func (v VGPU) Destroy(ctx context.Context, req DestroyRequest) (bool, error) {
return result, nil
}
// Destroy destroys VGPU in async mode
func (v VGPU) DestroyAsync(ctx context.Context, req DestroyRequest) (string, error) {
err := validators.ValidateRequest(req)
if err != nil {
return "", validators.ValidationErrors(validators.GetErrors(err))
}
url := "/cloudbroker/vgpu/destroy"
aReq := asyncWrapperDestroyRequest{
DestroyRequest: req,
AsyncMode: true,
}
res, err := v.client.DecortApiCall(ctx, http.MethodPost, url, aReq)
if err != nil {
return "", err
}
var resp string
err = json.Unmarshal(res, &resp)
if err != nil {
return "", err
}
return resp, nil
}