v1.16.3
This commit is contained in:
@@ -265,7 +265,7 @@ func (r CreateRequest) GetRAM() map[string]uint64 {
|
||||
|
||||
type wrapperCreateRequest struct {
|
||||
CreateRequest
|
||||
AsyncMode bool `json:"asyncMode"`
|
||||
AsyncMode bool `json:"async_mode"`
|
||||
}
|
||||
|
||||
// Create creates KVM x86 VM based on specified OS image
|
||||
|
||||
@@ -43,6 +43,9 @@ type ItemLocation struct {
|
||||
|
||||
// Is BRO enabled
|
||||
BROEnabled bool `json:"bro_enabled"`
|
||||
|
||||
// Are VM Folders enabled
|
||||
VMFoldersEnabled bool `json:"vm_folders_enabled"`
|
||||
}
|
||||
|
||||
// List of locations
|
||||
|
||||
@@ -2,6 +2,7 @@ package vins
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
@@ -69,6 +70,11 @@ type CreateInAccountRequest struct {
|
||||
EnableDefaultGateway interface{} `url:"enable_default_gateway,omitempty" json:"enable_default_gateway,omitempty" validate:"omitempty,isBool"`
|
||||
}
|
||||
|
||||
type asyncWrapperCreateInAccountRequest struct {
|
||||
CreateInAccountRequest
|
||||
AsyncMode bool `url:"asyncMode" json:"asyncMode"`
|
||||
}
|
||||
|
||||
// CreateInAccount creates VINS in account level
|
||||
func (v VINS) CreateInAccount(ctx context.Context, req CreateInAccountRequest) (uint64, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
@@ -78,7 +84,12 @@ func (v VINS) CreateInAccount(ctx context.Context, req CreateInAccountRequest) (
|
||||
|
||||
url := "/cloudapi/vins/createInAccount"
|
||||
|
||||
res, err := v.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
|
||||
syncReq := asyncWrapperCreateInAccountRequest{
|
||||
CreateInAccountRequest: req,
|
||||
AsyncMode: false,
|
||||
}
|
||||
|
||||
res, err := v.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, syncReq)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
@@ -90,3 +101,32 @@ func (v VINS) CreateInAccount(ctx context.Context, req CreateInAccountRequest) (
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// CreateInAccount creates VINS in account level in async mode
|
||||
func (v VINS) AsyncCreateInAccount(ctx context.Context, req CreateInAccountRequest) (string, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
asyncReq := asyncWrapperCreateInAccountRequest{
|
||||
CreateInAccountRequest: req,
|
||||
AsyncMode: true,
|
||||
}
|
||||
|
||||
url := "/cloudapi/vins/createInAccount"
|
||||
|
||||
result, err := v.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, asyncReq)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
var resp string
|
||||
|
||||
err = json.Unmarshal(result, &resp)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package vins
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
@@ -63,6 +64,11 @@ type CreateInRGRequest struct {
|
||||
EnableDefaultGateway interface{} `url:"enable_default_gateway,omitempty" json:"enable_default_gateway,omitempty" validate:"omitempty,isBool"`
|
||||
}
|
||||
|
||||
type asyncWrapperCreateInRgRequest struct {
|
||||
CreateInRGRequest
|
||||
AsyncMode bool `url:"asyncMode" json:"asyncMode"`
|
||||
}
|
||||
|
||||
// CreateInRG creates VINS in resource group level
|
||||
func (v VINS) CreateInRG(ctx context.Context, req CreateInRGRequest) (uint64, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
@@ -72,7 +78,12 @@ func (v VINS) CreateInRG(ctx context.Context, req CreateInRGRequest) (uint64, er
|
||||
|
||||
url := "/cloudapi/vins/createInRG"
|
||||
|
||||
res, err := v.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
|
||||
syncReq := asyncWrapperCreateInRgRequest{
|
||||
CreateInRGRequest: req,
|
||||
AsyncMode: false,
|
||||
}
|
||||
|
||||
res, err := v.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, syncReq)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
@@ -84,3 +95,32 @@ func (v VINS) CreateInRG(ctx context.Context, req CreateInRGRequest) (uint64, er
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// CreateInRG creates VINS in resource group level in async mode
|
||||
func (v VINS) AsyncCreateInRG(ctx context.Context, req CreateInRGRequest) (string, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudapi/vins/createInRG"
|
||||
|
||||
syncReq := asyncWrapperCreateInRgRequest{
|
||||
CreateInRGRequest: req,
|
||||
AsyncMode: true,
|
||||
}
|
||||
|
||||
result, err := v.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, syncReq)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
var resp string
|
||||
|
||||
err = json.Unmarshal(result, &resp)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
39
pkg/cloudapi/vins/disable.go
Normal file
39
pkg/cloudapi/vins/disable.go
Normal file
@@ -0,0 +1,39 @@
|
||||
package vins
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// DisableRequest struct to disable VINS
|
||||
type DisableRequest struct {
|
||||
// VINS ID
|
||||
// Required: true
|
||||
VINSID uint64 `url:"vinsId" json:"vinsId" validate:"required"`
|
||||
}
|
||||
|
||||
// Disable disables VINS
|
||||
func (v VINS) Disable(ctx context.Context, req DisableRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudapi/vins/disable"
|
||||
|
||||
res, err := v.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseBool(string(res))
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
|
||||
}
|
||||
@@ -1,62 +0,0 @@
|
||||
package vins
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// DisableEnableRequest struct to disable/enable VINS
|
||||
type DisableEnableRequest struct {
|
||||
// VINS ID
|
||||
// Required: true
|
||||
VINSID uint64 `url:"vinsId" json:"vinsId" validate:"required"`
|
||||
}
|
||||
|
||||
// Disable disables VINS
|
||||
func (v VINS) Disable(ctx context.Context, req DisableEnableRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudapi/vins/disable"
|
||||
|
||||
res, err := v.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseBool(string(res))
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
|
||||
}
|
||||
|
||||
// Enable enables VINS
|
||||
func (v VINS) Enable(ctx context.Context, req DisableEnableRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudapi/vins/enable"
|
||||
|
||||
res, err := v.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseBool(string(res))
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
|
||||
}
|
||||
78
pkg/cloudapi/vins/enable.go
Normal file
78
pkg/cloudapi/vins/enable.go
Normal file
@@ -0,0 +1,78 @@
|
||||
package vins
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// EnableRequest struct to enable VINS
|
||||
type EnableRequest struct {
|
||||
// VINS ID
|
||||
// Required: true
|
||||
VINSID uint64 `url:"vinsId" json:"vinsId" validate:"required"`
|
||||
}
|
||||
|
||||
type asyncWrapperEnableRequest struct {
|
||||
EnableRequest
|
||||
AsyncMode bool `url:"asyncMode"`
|
||||
}
|
||||
|
||||
// Enable enables VINS
|
||||
func (v VINS) Enable(ctx context.Context, req EnableRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudapi/vins/enable"
|
||||
|
||||
syncReq := asyncWrapperEnableRequest{
|
||||
EnableRequest: req,
|
||||
AsyncMode: false,
|
||||
}
|
||||
|
||||
res, err := v.client.DecortApiCall(ctx, http.MethodPost, url, syncReq)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseBool(string(res))
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// Enable enables VINS by ID in async mode
|
||||
func (v VINS) AsyncEnable(ctx context.Context, req EnableRequest) (string, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudapi/vins/enable"
|
||||
|
||||
asyncReq := asyncWrapperEnableRequest{
|
||||
EnableRequest: 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
|
||||
}
|
||||
@@ -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 := "/cloudapi/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 := "/cloudapi/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
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package vins
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
@@ -15,6 +16,11 @@ type VNFDevRestartRequest struct {
|
||||
VINSID uint64 `url:"vinsId" json:"vinsId" validate:"required"`
|
||||
}
|
||||
|
||||
type asyncWrapperVNFDevRestartRequest struct {
|
||||
VNFDevRestartRequest
|
||||
AsyncMode bool `url:"asyncMode"`
|
||||
}
|
||||
|
||||
// VNFDevRestart reboots VINSes primary VNF device
|
||||
func (v VINS) VNFDevRestart(ctx context.Context, req VNFDevRestartRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
@@ -24,7 +30,12 @@ func (v VINS) VNFDevRestart(ctx context.Context, req VNFDevRestartRequest) (bool
|
||||
|
||||
url := "/cloudapi/vins/vnfdevRestart"
|
||||
|
||||
res, err := v.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
syncReq := asyncWrapperVNFDevRestartRequest{
|
||||
VNFDevRestartRequest: 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) VNFDevRestart(ctx context.Context, req VNFDevRestartRequest) (bool
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// VNFDevRestart reboots VINSes primary VNF device in async mode
|
||||
func (v VINS) AsyncVNFDevRestart(ctx context.Context, req VNFDevRestartRequest) (string, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudapi/vins/vnfdevRestart"
|
||||
|
||||
asyncReq := asyncWrapperVNFDevRestartRequest{
|
||||
VNFDevRestartRequest: 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
|
||||
}
|
||||
|
||||
@@ -116,6 +116,11 @@ type wrapperCreateRequest struct {
|
||||
Routes []string `url:"routes,omitempty"`
|
||||
}
|
||||
|
||||
type asyncWrapperCreateRequest struct {
|
||||
wrapperCreateRequest
|
||||
AsyncMode bool `url:"async_mode"`
|
||||
}
|
||||
|
||||
// Create creates new external network into platform
|
||||
func (e ExtNet) Create(ctx context.Context, req CreateRequest) (uint64, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
@@ -145,9 +150,14 @@ func (e ExtNet) Create(ctx context.Context, req CreateRequest) (uint64, error) {
|
||||
Routes: routes,
|
||||
}
|
||||
|
||||
reqWrappedAsync := asyncWrapperCreateRequest{
|
||||
wrapperCreateRequest: reqWrapped,
|
||||
AsyncMode: true,
|
||||
}
|
||||
|
||||
url := "/cloudbroker/extnet/create"
|
||||
|
||||
res, err := e.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
||||
res, err := e.client.DecortApiCall(ctx, http.MethodPost, url, reqWrappedAsync)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
@@ -159,3 +169,54 @@ func (e ExtNet) Create(ctx context.Context, req CreateRequest) (uint64, error) {
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// AsyncCreate creates new external network into platform in async mode
|
||||
func (e ExtNet) AsyncCreate(ctx context.Context, req CreateRequest) (string, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
var routes []string
|
||||
|
||||
if len(req.Routes) != 0 {
|
||||
routes = make([]string, 0, len(req.Routes))
|
||||
|
||||
for r := range req.Routes {
|
||||
b, err := json.Marshal(req.Routes[r])
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
routes = append(routes, string(b))
|
||||
}
|
||||
} else {
|
||||
routes = []string{}
|
||||
}
|
||||
|
||||
reqWrapped := wrapperCreateRequest{
|
||||
CreateRequest: req,
|
||||
Routes: routes,
|
||||
}
|
||||
|
||||
reqWrappedAsync := asyncWrapperCreateRequest{
|
||||
wrapperCreateRequest: reqWrapped,
|
||||
AsyncMode: true,
|
||||
}
|
||||
|
||||
url := "/cloudbroker/extnet/create"
|
||||
|
||||
result, err := e.client.DecortApiCall(ctx, http.MethodPost, url, reqWrappedAsync)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
var resp string
|
||||
|
||||
err = json.Unmarshal(result, &resp)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package extnet
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
@@ -15,6 +16,11 @@ type DeviceDeployRequest struct {
|
||||
NetID uint64 `url:"net_id" json:"net_id" validate:"required"`
|
||||
}
|
||||
|
||||
type asyncWrapperDeviceDeployRequest struct {
|
||||
DeviceDeployRequest
|
||||
AsyncMode bool `url:"async_mode"`
|
||||
}
|
||||
|
||||
// DeviceDeploy deploys network device for external network (make not virtual, "physical")
|
||||
func (e ExtNet) DeviceDeploy(ctx context.Context, req DeviceDeployRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
@@ -24,7 +30,12 @@ func (e ExtNet) DeviceDeploy(ctx context.Context, req DeviceDeployRequest) (bool
|
||||
|
||||
url := "/cloudbroker/extnet/deviceDeploy"
|
||||
|
||||
res, err := e.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
syncReq := asyncWrapperDeviceDeployRequest{
|
||||
DeviceDeployRequest: req,
|
||||
AsyncMode: false,
|
||||
}
|
||||
|
||||
res, err := e.client.DecortApiCall(ctx, http.MethodPost, url, syncReq)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
@@ -36,3 +47,32 @@ func (e ExtNet) DeviceDeploy(ctx context.Context, req DeviceDeployRequest) (bool
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// AsyncDeviceDeploy deploys network device for external network (make not virtual, "physical") in async mode
|
||||
func (e ExtNet) AsyncDeviceDeploy(ctx context.Context, req DeviceDeployRequest) (string, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/extnet/deviceDeploy"
|
||||
|
||||
syncReq := asyncWrapperDeviceDeployRequest{
|
||||
DeviceDeployRequest: req,
|
||||
AsyncMode: true,
|
||||
}
|
||||
|
||||
result, err := e.client.DecortApiCall(ctx, http.MethodPost, url, syncReq)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
var resp string
|
||||
|
||||
err = json.Unmarshal(result, &resp)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package extnet
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
@@ -19,6 +20,11 @@ type SetHAModeRequest struct {
|
||||
HAMode bool `url:"highly_available" json:"highly_available" validate:"required"`
|
||||
}
|
||||
|
||||
type asyncWrapperSetHAModeRequest struct {
|
||||
SetHAModeRequest
|
||||
AsyncMode bool `url:"async_mode"`
|
||||
}
|
||||
|
||||
// SetHAMode set HA mode for external network
|
||||
func (e ExtNet) SetHAMode(ctx context.Context, req SetHAModeRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
@@ -28,7 +34,12 @@ func (e ExtNet) SetHAMode(ctx context.Context, req SetHAModeRequest) (bool, erro
|
||||
|
||||
url := "/cloudbroker/extnet/set_highly_available"
|
||||
|
||||
res, err := e.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
syncReq := asyncWrapperSetHAModeRequest{
|
||||
SetHAModeRequest: req,
|
||||
AsyncMode: true,
|
||||
}
|
||||
|
||||
res, err := e.client.DecortApiCall(ctx, http.MethodPost, url, syncReq)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
@@ -40,3 +51,32 @@ func (e ExtNet) SetHAMode(ctx context.Context, req SetHAModeRequest) (bool, erro
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// AsyncSetHAMode set HA mode for external network in async mode
|
||||
func (e ExtNet) AsyncSetHAMode(ctx context.Context, req SetHAModeRequest) (string, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/extnet/set_highly_available"
|
||||
|
||||
syncReq := asyncWrapperSetHAModeRequest{
|
||||
SetHAModeRequest: req,
|
||||
AsyncMode: true,
|
||||
}
|
||||
|
||||
result, err := e.client.DecortApiCall(ctx, http.MethodPost, url, syncReq)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
var resp string
|
||||
|
||||
err = json.Unmarshal(result, &resp)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
@@ -288,7 +288,7 @@ func (r CreateRequest) GetRAM() map[string]uint64 {
|
||||
|
||||
type wrapperCreateRequest struct {
|
||||
CreateRequest
|
||||
AsyncMode bool `json:"asyncMode"`
|
||||
AsyncMode bool `json:"async_mode"`
|
||||
}
|
||||
|
||||
// Create creates KVM PowerPC VM based on specified OS image
|
||||
|
||||
@@ -2,6 +2,7 @@ package vins
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
@@ -69,6 +70,11 @@ type CreateInAccountRequest struct {
|
||||
EnableDefaultGateway interface{} `url:"enable_default_gateway,omitempty" json:"enable_default_gateway,omitempty" validate:"omitempty,isBool"`
|
||||
}
|
||||
|
||||
type asyncWrapperCreateInAccountRequest struct {
|
||||
CreateInAccountRequest
|
||||
AsyncMode bool `url:"asyncMode" json:"asyncMode"`
|
||||
}
|
||||
|
||||
// CreateInAccount creates VINS in account level
|
||||
func (v VINS) CreateInAccount(ctx context.Context, req CreateInAccountRequest) (uint64, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
@@ -78,7 +84,12 @@ func (v VINS) CreateInAccount(ctx context.Context, req CreateInAccountRequest) (
|
||||
|
||||
url := "/cloudbroker/vins/createInAccount"
|
||||
|
||||
res, err := v.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
|
||||
syncReq := asyncWrapperCreateInAccountRequest{
|
||||
CreateInAccountRequest: req,
|
||||
AsyncMode: false,
|
||||
}
|
||||
|
||||
res, err := v.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, syncReq)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
@@ -90,3 +101,32 @@ func (v VINS) CreateInAccount(ctx context.Context, req CreateInAccountRequest) (
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// CreateInAccount creates VINS in account level in async mode
|
||||
func (v VINS) AsyncCreateInAccount(ctx context.Context, req CreateInAccountRequest) (string, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
asyncReq := asyncWrapperCreateInAccountRequest{
|
||||
CreateInAccountRequest: req,
|
||||
AsyncMode: true,
|
||||
}
|
||||
|
||||
url := "/cloudbroker/vins/createInAccount"
|
||||
|
||||
result, err := v.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, asyncReq)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
var resp string
|
||||
|
||||
err = json.Unmarshal(result, &resp)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package vins
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
@@ -63,6 +64,11 @@ type CreateInRGRequest struct {
|
||||
EnableDefaultGateway interface{} `url:"enable_default_gateway,omitempty" json:"enable_default_gateway,omitempty" validate:"omitempty,isBool"`
|
||||
}
|
||||
|
||||
type asyncWrapperCreateInRgRequest struct {
|
||||
CreateInRGRequest
|
||||
AsyncMode bool `url:"asyncMode" json:"asyncMode"`
|
||||
}
|
||||
|
||||
// CreateInRG creates VINS in resource group level
|
||||
func (v VINS) CreateInRG(ctx context.Context, req CreateInRGRequest) (uint64, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
@@ -72,7 +78,12 @@ func (v VINS) CreateInRG(ctx context.Context, req CreateInRGRequest) (uint64, er
|
||||
|
||||
url := "/cloudbroker/vins/createInRG"
|
||||
|
||||
res, err := v.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
|
||||
syncReq := asyncWrapperCreateInRgRequest{
|
||||
CreateInRGRequest: req,
|
||||
AsyncMode: false,
|
||||
}
|
||||
|
||||
res, err := v.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, syncReq)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
@@ -84,3 +95,32 @@ func (v VINS) CreateInRG(ctx context.Context, req CreateInRGRequest) (uint64, er
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// CreateInRG creates VINS in resource group level in async mode
|
||||
func (v VINS) AsyncCreateInRG(ctx context.Context, req CreateInRGRequest) (string, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/vins/createInRG"
|
||||
|
||||
syncReq := asyncWrapperCreateInRgRequest{
|
||||
CreateInRGRequest: req,
|
||||
AsyncMode: true,
|
||||
}
|
||||
|
||||
result, err := v.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, syncReq)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
var resp string
|
||||
|
||||
err = json.Unmarshal(result, &resp)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package vins
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
@@ -15,6 +16,11 @@ type EnableRequest struct {
|
||||
VINSID uint64 `url:"vinsId" json:"vinsId" validate:"required"`
|
||||
}
|
||||
|
||||
type asyncWrapperEnableRequest struct {
|
||||
EnableRequest
|
||||
AsyncMode bool `url:"asyncMode"`
|
||||
}
|
||||
|
||||
// Enable enables VINS by ID
|
||||
func (v VINS) Enable(ctx context.Context, req EnableRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
@@ -24,7 +30,12 @@ func (v VINS) Enable(ctx context.Context, req EnableRequest) (bool, error) {
|
||||
|
||||
url := "/cloudbroker/vins/enable"
|
||||
|
||||
res, err := v.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
syncReq := asyncWrapperEnableRequest{
|
||||
EnableRequest: 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) Enable(ctx context.Context, req EnableRequest) (bool, error) {
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// Enable enables VINS by ID in async mode
|
||||
func (v VINS) AsyncEnable(ctx context.Context, req EnableRequest) (string, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/vins/enable"
|
||||
|
||||
asyncReq := asyncWrapperEnableRequest{
|
||||
EnableRequest: 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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package vins
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
@@ -15,6 +16,11 @@ type VNFDevRestartRequest struct {
|
||||
VINSID uint64 `url:"vinsId" json:"vinsId" validate:"required"`
|
||||
}
|
||||
|
||||
type asyncWrapperVNFDevRestartRequest struct {
|
||||
VNFDevRestartRequest
|
||||
AsyncMode bool `url:"asyncMode"`
|
||||
}
|
||||
|
||||
// VNFDevRestart reboots VINSes primary VNF device
|
||||
func (v VINS) VNFDevRestart(ctx context.Context, req VNFDevRestartRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
@@ -24,7 +30,12 @@ func (v VINS) VNFDevRestart(ctx context.Context, req VNFDevRestartRequest) (bool
|
||||
|
||||
url := "/cloudbroker/vins/vnfdevRestart"
|
||||
|
||||
res, err := v.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
syncReq := asyncWrapperVNFDevRestartRequest{
|
||||
VNFDevRestartRequest: 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) VNFDevRestart(ctx context.Context, req VNFDevRestartRequest) (bool
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// VNFDevRestart reboots VINSes primary VNF device in async mode
|
||||
func (v VINS) AsyncVNFDevRestart(ctx context.Context, req VNFDevRestartRequest) (string, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/vins/vnfdevRestart"
|
||||
|
||||
asyncReq := asyncWrapperVNFDevRestartRequest{
|
||||
VNFDevRestartRequest: 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
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package vins
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
@@ -15,6 +16,11 @@ type VNFDevStartRequest struct {
|
||||
VINSID uint64 `url:"vinsId" json:"vinsId" validate:"required"`
|
||||
}
|
||||
|
||||
type asyncWrapperVNFDevStartRequest struct {
|
||||
VNFDevStartRequest
|
||||
AsyncMode bool `url:"asyncMode"`
|
||||
}
|
||||
|
||||
// VNFDevStart starts VINSes primary VNF device
|
||||
func (v VINS) VNFDevStart(ctx context.Context, req VNFDevStartRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
@@ -24,7 +30,12 @@ func (v VINS) VNFDevStart(ctx context.Context, req VNFDevStartRequest) (bool, er
|
||||
|
||||
url := "/cloudbroker/vins/vnfdevStart"
|
||||
|
||||
res, err := v.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
syncReq := asyncWrapperVNFDevStartRequest{
|
||||
VNFDevStartRequest: 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) VNFDevStart(ctx context.Context, req VNFDevStartRequest) (bool, er
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// VNFDevStart starts VINSes primary VNF device
|
||||
func (v VINS) AsyncVNFDevStart(ctx context.Context, req VNFDevStartRequest) (string, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/vins/vnfdevStart"
|
||||
|
||||
asyncReq := asyncWrapperVNFDevStartRequest{
|
||||
VNFDevStartRequest: 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