This commit is contained in:
2026-06-26 16:39:51 +04:00
parent cd5d1c9d0b
commit 118b48c3bc
26 changed files with 614 additions and 151 deletions

View File

@@ -2,10 +2,10 @@ package vins
import (
"context"
"encoding/json"
"net/http"
"strconv"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
@@ -62,11 +62,11 @@ type CreateInAccountRequest struct {
// Required: false
// Default: false
EnableSecGroups interface{} `url:"enable_secgroups,omitempty" json:"enable_secgroups,omitempty" validate:"omitempty,isBool"`
}
type wrapperCreateRequestInAcc struct {
CreateInAccountRequest
Routes []string `url:"routes,omitempty"`
// Flag indicating whether default gateway is enabled for this VINS
// Required: false
// Default: true
EnableDefaultGateway interface{} `url:"enable_default_gateway,omitempty" json:"enable_default_gateway,omitempty" validate:"omitempty,isBool"`
}
// CreateInAccount creates VINS in account level
@@ -76,31 +76,9 @@ func (v VINS) CreateInAccount(ctx context.Context, req CreateInAccountRequest) (
return 0, 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 0, err
}
routes = append(routes, string(b))
}
} else {
routes = []string{}
}
reqWrapped := wrapperCreateRequestInAcc{
CreateInAccountRequest: req,
Routes: routes,
}
url := "/cloudapi/vins/createInAccount"
res, err := v.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
res, err := v.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
if err != nil {
return 0, err
}

View File

@@ -2,10 +2,10 @@ package vins
import (
"context"
"encoding/json"
"net/http"
"strconv"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
@@ -56,11 +56,11 @@ type CreateInRGRequest struct {
// Required: false
// Default: false
EnableSecGroups interface{} `url:"enable_secgroups,omitempty" json:"enable_secgroups,omitempty" validate:"omitempty,isBool"`
}
type wrapperCreateRequestInRG struct {
CreateInRGRequest
Routes []string `url:"routes,omitempty"`
// Flag indicating whether default gateway is enabled for this VINS
// Required: false
// Default: true
EnableDefaultGateway interface{} `url:"enable_default_gateway,omitempty" json:"enable_default_gateway,omitempty" validate:"omitempty,isBool"`
}
// CreateInRG creates VINS in resource group level
@@ -70,31 +70,9 @@ func (v VINS) CreateInRG(ctx context.Context, req CreateInRGRequest) (uint64, er
return 0, 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 0, err
}
routes = append(routes, string(b))
}
} else {
routes = []string{}
}
reqWrapped := wrapperCreateRequestInRG{
CreateInRGRequest: req,
Routes: routes,
}
url := "/cloudapi/vins/createInRG"
res, err := v.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
res, err := v.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
if err != nil {
return 0, err
}

View File

@@ -694,6 +694,9 @@ type RecordVINS struct {
// Description
Description string `json:"desc"`
// Enable Default Gateway
EnableDefaultGateway bool `json:"enable_default_gateway"`
// Enable Security Groups
EnableSecGroups bool `json:"enable_secgroups"`