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