This commit is contained in:
dayterr
2026-09-15 17:23:58 +03:00
parent 71b53b743d
commit b39021820a
21 changed files with 692 additions and 105 deletions

View File

@@ -2,6 +2,7 @@ package vins
import (
"context"
"encoding/json"
"net/http"
"strconv"
@@ -15,6 +16,11 @@ type VNFDevRedeployRequest struct {
VINSID uint64 `url:"vinsId" json:"vinsId" validate:"required"`
}
type asyncWrapperVNFDevRedeployRequest struct {
VNFDevRedeployRequest
AsyncMode bool `url:"asyncMode"`
}
// VNFDevRedeploy redeploys VINS VNFDevs
func (v VINS) VNFDevRedeploy(ctx context.Context, req VNFDevRedeployRequest) (bool, error) {
err := validators.ValidateRequest(req)
@@ -24,7 +30,12 @@ func (v VINS) VNFDevRedeploy(ctx context.Context, req VNFDevRedeployRequest) (bo
url := "/cloudbroker/vins/vnfdevRedeploy"
res, err := v.client.DecortApiCall(ctx, http.MethodPost, url, req)
syncReq := asyncWrapperVNFDevRedeployRequest{
VNFDevRedeployRequest: req,
AsyncMode: false,
}
res, err := v.client.DecortApiCall(ctx, http.MethodPost, url, syncReq)
if err != nil {
return false, err
}
@@ -36,3 +47,32 @@ func (v VINS) VNFDevRedeploy(ctx context.Context, req VNFDevRedeployRequest) (bo
return result, nil
}
// VNFDevRedeploy redeploys VINS VNFDevs in async mode
func (v VINS) AsyncVNFDevRedeploy(ctx context.Context, req VNFDevRedeployRequest) (string, error) {
err := validators.ValidateRequest(req)
if err != nil {
return "", validators.ValidationErrors(validators.GetErrors(err))
}
url := "/cloudbroker/vins/vnfdevRedeploy"
asyncReq := asyncWrapperVNFDevRedeployRequest{
VNFDevRedeployRequest: req,
AsyncMode: true,
}
result, err := v.client.DecortApiCall(ctx, http.MethodPost, url, asyncReq)
if err != nil {
return "", err
}
var resp string
err = json.Unmarshal(result, &resp)
if err != nil {
return "", err
}
return resp, nil
}