v1.16.3
This commit is contained in:
@@ -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