v16.3.0
This commit is contained in:
dayterr committed 2026-09-15 17:42:23 +03:00
1 parent dbd979b6f3
commit 4c05d94552
20 files changed
+691 -104

No files matched your search

+41 -1
View File
@@ -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
}