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