v1.16.3
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user