parent
df8b045e77
commit
9f5e76aee4
@ -1,3 +1,5 @@
|
|||||||
cmd/
|
cmd/
|
||||||
.idea/
|
.idea/
|
||||||
.vscode/
|
.vscode/
|
||||||
|
.fleet/
|
||||||
|
.DS_Store
|
||||||
|
@ -1,13 +1 @@
|
|||||||
## Version 1.5.8
|
## Version 1.6.0-delta
|
||||||
|
|
||||||
### Bugfix
|
|
||||||
- Fix model the RecordK8CI to cloudbroker/k8ci/models to correctly receive information on get request
|
|
||||||
- Add model the RecordK8CIList to cloudbroker/k8ci/models to correctly receive information on list request
|
|
||||||
- Refactored clients to fix the problems with concurrency safety
|
|
||||||
- Add the Routes field in the CreateInRGRequest and CreateInAccountRequest models in cb/vins. The fields for creating the resource are matched
|
|
||||||
|
|
||||||
For get request to work correctly:
|
|
||||||
- Fix the Rules field (fix type) in the NATConfig model in cb/vins/models and ca/vins/models
|
|
||||||
- Fix the InfoVNF model (remove the excess field, add the Routes field) in cb/vins/models
|
|
||||||
- Add the ItemRoutes model in cb/vins/models
|
|
||||||
- Fix the RecordVINS model (remove the excess fields) in cb/vins/models
|
|
||||||
|
@ -0,0 +1,38 @@
|
|||||||
|
package k8s
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Request struct for get worker group metadata by ID
|
||||||
|
type GetWorkerNodesMetaDataRequest struct {
|
||||||
|
// Kubernetes cluster ID
|
||||||
|
// Required: true
|
||||||
|
K8SID uint64 `url:"k8sId" json:"k8sId" validate:"required"`
|
||||||
|
|
||||||
|
// ID of the workers compute group
|
||||||
|
// Required: true
|
||||||
|
WorkersGroupID uint64 `url:"workersGroupId" json:"workersGroupId" validate:"required"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get worker group metadata by ID
|
||||||
|
func (k K8S) GetWorkerNodesMetaData(ctx context.Context, req GetWorkerNodesMetaDataRequest) (string, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
for _, validationError := range validators.GetErrors(err) {
|
||||||
|
return "", validators.ValidationError(validationError)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudapi/k8s/getWorkerNodesMetaData"
|
||||||
|
|
||||||
|
res, err := k.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
|
||||||
|
return string(res), nil
|
||||||
|
}
|
@ -0,0 +1,48 @@
|
|||||||
|
package k8s
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"net/http"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Request struct for add worker to a kubernetes cluster
|
||||||
|
type UpdateWorkerNodesMetaDataRequest struct {
|
||||||
|
// Kubernetes cluster ID
|
||||||
|
// Required: true
|
||||||
|
K8SID uint64 `url:"k8sId" json:"k8sId" validate:"required"`
|
||||||
|
|
||||||
|
// ID of the workers compute group
|
||||||
|
// Required: true
|
||||||
|
WorkersGroupID uint64 `url:"workersGroupId" json:"workersGroupId" validate:"required"`
|
||||||
|
|
||||||
|
// Meta data for working group computes, format YAML "user_data": 1111
|
||||||
|
// Required: true
|
||||||
|
UserData string `url:"userData" json:"userData" validate:"required"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// WorkerAdd adds worker nodes to a kubernetes cluster
|
||||||
|
func (k K8S) UpdateWorkerNodesMetaData(ctx context.Context, req UpdateWorkerNodesMetaDataRequest) (bool, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
for _, validationError := range validators.GetErrors(err) {
|
||||||
|
return false, validators.ValidationError(validationError)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudapi/k8s/updateWorkerNodesMetaData"
|
||||||
|
|
||||||
|
res, err := k.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
|
||||||
|
}
|
@ -0,0 +1,40 @@
|
|||||||
|
package lb
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"net/http"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Request struct for make Load Balancer Highly available
|
||||||
|
type HighlyAvailableRequest struct {
|
||||||
|
// ID of the LB instance
|
||||||
|
// Required: true
|
||||||
|
LBID uint64 `url:"lbId" json:"lbId" validate:"required"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Make Load Balancer Highly available
|
||||||
|
func (l LB) HighlyAvailable(ctx context.Context, req HighlyAvailableRequest) (uint64, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
for _, validationError := range validators.GetErrors(err) {
|
||||||
|
return 0, validators.ValidationError(validationError)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudapi/lb/makeHighlyAvailable"
|
||||||
|
|
||||||
|
res, err := l.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err := strconv.ParseUint(string(res), 10, 64)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return result, nil
|
||||||
|
}
|
@ -0,0 +1,72 @@
|
|||||||
|
package lb
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"encoding/json"
|
||||||
|
"net/http"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Request struct for update sysct params for lb
|
||||||
|
type UpdateSysctParamsRequest struct {
|
||||||
|
// ID of the LB instance
|
||||||
|
// Required: true
|
||||||
|
LBID uint64 `url:"lbId" json:"lbId" validate:"required"`
|
||||||
|
|
||||||
|
// Custom sysctl values for Load Balancer instance. Applied on boot
|
||||||
|
// Required: true
|
||||||
|
SysctlParams Params `url:"-" json:"sysctlParams" validate:"required,dive"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type wrapperUpdateSysctParamsRequest struct {
|
||||||
|
UpdateSysctParamsRequest
|
||||||
|
Params []string `url:"sysctlParams" validate:"required"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create method will create a new load balancer instance
|
||||||
|
func (l LB) UpdateSysctParams(ctx context.Context, req UpdateSysctParamsRequest) (bool, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
for _, validationError := range validators.GetErrors(err) {
|
||||||
|
return false, validators.ValidationError(validationError)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var params []string
|
||||||
|
|
||||||
|
if len(req.SysctlParams) != 0 {
|
||||||
|
params = make([]string, 0, len(req.SysctlParams))
|
||||||
|
|
||||||
|
for r := range req.SysctlParams {
|
||||||
|
b, err := json.Marshal(req.SysctlParams[r])
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
|
||||||
|
params = append(params, string(b))
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
params = []string{}
|
||||||
|
}
|
||||||
|
|
||||||
|
reqWrapped := wrapperUpdateSysctParamsRequest{
|
||||||
|
UpdateSysctParamsRequest: req,
|
||||||
|
Params: params,
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudapi/lb/updateSysctParams"
|
||||||
|
|
||||||
|
res, err := l.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err := strconv.ParseBool(string(res))
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return result, nil
|
||||||
|
}
|
@ -0,0 +1,10 @@
|
|||||||
|
package cloudapi
|
||||||
|
|
||||||
|
import (
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/stack"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Accessing the Stack method group
|
||||||
|
func (ca *CloudAPI) Stack() *stack.Stack {
|
||||||
|
return stack.New(ca.client)
|
||||||
|
}
|
@ -0,0 +1,42 @@
|
|||||||
|
package stack
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"encoding/json"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Request struct for get info of stack
|
||||||
|
type GetRequest struct {
|
||||||
|
// Find by ID
|
||||||
|
// Required: true
|
||||||
|
StackId uint64 `url:"stackId" json:"stackId" validate:"required"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get stack details by ID
|
||||||
|
func (i Stack) Get(ctx context.Context, req GetRequest) (*InfoStack, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
for _, validationError := range validators.GetErrors(err) {
|
||||||
|
return nil, validators.ValidationError(validationError)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudapi/stack/get"
|
||||||
|
|
||||||
|
res, err := i.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
info := InfoStack{}
|
||||||
|
|
||||||
|
err = json.Unmarshal(res, &info)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return &info, nil
|
||||||
|
}
|
@ -0,0 +1,53 @@
|
|||||||
|
package stack
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"encoding/json"
|
||||||
|
"net/http"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Request struct for get list stack
|
||||||
|
type ListRequest struct {
|
||||||
|
// Find by ID
|
||||||
|
// Required: false
|
||||||
|
ByID uint64 `url:"by_id,omitempty" json:"by_id,omitempty"`
|
||||||
|
|
||||||
|
// Find by name
|
||||||
|
// Required: false
|
||||||
|
Name string `url:"name,omitempty" json:"name,omitempty"`
|
||||||
|
|
||||||
|
// Find by type
|
||||||
|
// Required: false
|
||||||
|
Type string `url:"type,omitempty" json:"type,omitempty"`
|
||||||
|
|
||||||
|
// Find by status
|
||||||
|
// Required: false
|
||||||
|
Status string `url:"status,omitempty" json:"status,omitempty"`
|
||||||
|
|
||||||
|
// Page number
|
||||||
|
// Required: false
|
||||||
|
Page uint64 `url:"page,omitempty" json:"page,omitempty"`
|
||||||
|
|
||||||
|
// Page size
|
||||||
|
// Required: false
|
||||||
|
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListStacks gets list stack
|
||||||
|
func (i Stack) List(ctx context.Context, req ListRequest) (*ListStacks, error) {
|
||||||
|
url := "/cloudapi/stack/list"
|
||||||
|
|
||||||
|
res, err := i.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
list := ListStacks{}
|
||||||
|
|
||||||
|
err = json.Unmarshal(res, &list)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return &list, nil
|
||||||
|
}
|
@ -0,0 +1,53 @@
|
|||||||
|
package stack
|
||||||
|
|
||||||
|
// Main information about stack
|
||||||
|
type InfoStack struct {
|
||||||
|
// CPU allocation ratio
|
||||||
|
CPUAllocationRatio float64 `json:"cpu_allocation_ratio"`
|
||||||
|
|
||||||
|
// Descr
|
||||||
|
Descr string `json:"descr"`
|
||||||
|
|
||||||
|
// Drivers
|
||||||
|
Drivers []string `json:"drivers"`
|
||||||
|
|
||||||
|
// ID
|
||||||
|
ID uint64 `json:"id"`
|
||||||
|
|
||||||
|
// Mem allocation ratio
|
||||||
|
MemAllocationRatio float64 `json:"mem_allocation_ratio"`
|
||||||
|
|
||||||
|
// Name
|
||||||
|
Name string `json:"name"`
|
||||||
|
|
||||||
|
// Status
|
||||||
|
Status string `json:"status"`
|
||||||
|
|
||||||
|
// Type
|
||||||
|
Type string `json:"type"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Information about stack in list
|
||||||
|
type ItemStack struct {
|
||||||
|
// ID
|
||||||
|
ID uint64 `json:"id"`
|
||||||
|
|
||||||
|
// Name
|
||||||
|
Name string `json:"name"`
|
||||||
|
|
||||||
|
// Status
|
||||||
|
Status string `json:"status"`
|
||||||
|
|
||||||
|
// Type
|
||||||
|
Type string `json:"type"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// List of stacks
|
||||||
|
type ListStacks struct {
|
||||||
|
|
||||||
|
//List
|
||||||
|
Data []ItemStack `json:"data"`
|
||||||
|
|
||||||
|
//Entry count
|
||||||
|
EntryCount uint64 `json:"entryCount"`
|
||||||
|
}
|
@ -0,0 +1,16 @@
|
|||||||
|
// Lists all the stack.
|
||||||
|
package stack
|
||||||
|
|
||||||
|
import "repository.basistech.ru/BASIS/decort-golang-sdk/interfaces"
|
||||||
|
|
||||||
|
// Structure for creating request to stack
|
||||||
|
type Stack struct {
|
||||||
|
client interfaces.Caller
|
||||||
|
}
|
||||||
|
|
||||||
|
// Builder for stack endpoint
|
||||||
|
func New(client interfaces.Caller) *Stack {
|
||||||
|
return &Stack{
|
||||||
|
client: client,
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,42 @@
|
|||||||
|
package vins
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"encoding/json"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Request struct for static route list
|
||||||
|
type StaticRouteListRequest struct {
|
||||||
|
// ViNS ID to show list of static routes
|
||||||
|
// Required: true
|
||||||
|
VINSID uint64 `url:"vinsId" json:"vinsId" validate:"required"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Show list of static routes for ViNS
|
||||||
|
func (v VINS) StaticRouteList(ctx context.Context, req StaticRouteListRequest) (*ListStaticRoutes, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
for _, validationError := range validators.GetErrors(err) {
|
||||||
|
return nil, validators.ValidationError(validationError)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudapi/vins/staticRouteList"
|
||||||
|
|
||||||
|
res, err := v.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
list := ListStaticRoutes{}
|
||||||
|
|
||||||
|
err = json.Unmarshal(res, &list)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return &list, nil
|
||||||
|
}
|
@ -0,0 +1,48 @@
|
|||||||
|
package vins
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"net/http"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Request struct for grant access to static route to Compute/ViNS
|
||||||
|
type StaticRouteAccessGrantRequest struct {
|
||||||
|
// ViNS ID to grant access
|
||||||
|
// Required: true
|
||||||
|
VINSID uint64 `url:"vinsId" json:"vinsId" validate:"required"`
|
||||||
|
|
||||||
|
// Route ID to grant access, can be found in staticRouteList
|
||||||
|
// Required: true
|
||||||
|
RouteId uint64 `url:"routeId" json:"routeId" validate:"required"`
|
||||||
|
|
||||||
|
// List of Compute IDs to grant access to this route
|
||||||
|
// Required: false
|
||||||
|
ComputeIds []uint64 `url:"computeIds,omitempty" json:"computeIds,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Grant access to static route to Compute/ViNS
|
||||||
|
func (v VINS) StaticRouteAccessGrant(ctx context.Context, req StaticRouteAccessGrantRequest) (bool, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
for _, validationError := range validators.GetErrors(err) {
|
||||||
|
return false, validators.ValidationError(validationError)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudapi/vins/staticRouteAccessGrant"
|
||||||
|
|
||||||
|
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
|
||||||
|
}
|
@ -0,0 +1,48 @@
|
|||||||
|
package vins
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"net/http"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Request struct for revoke access to static route to Compute/ViNS
|
||||||
|
type StaticRouteAccessRevokeRequest struct {
|
||||||
|
// ViNS ID to revoke access
|
||||||
|
// Required: true
|
||||||
|
VINSID uint64 `url:"vinsId" json:"vinsId" validate:"required"`
|
||||||
|
|
||||||
|
// Route ID to revoke access, can be found in staticRouteList
|
||||||
|
// Required: true
|
||||||
|
RouteId uint64 `url:"routeId" json:"routeId" validate:"required"`
|
||||||
|
|
||||||
|
// List of Compute IDs to revoke access to this route
|
||||||
|
// Required: false
|
||||||
|
ComputeIds []uint64 `url:"computeIds,omitempty" json:"computeIds,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Revoke access to static route to Compute/ViNS
|
||||||
|
func (v VINS) StaticRouteAccessRevoke(ctx context.Context, req StaticRouteAccessRevokeRequest) (bool, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
for _, validationError := range validators.GetErrors(err) {
|
||||||
|
return false, validators.ValidationError(validationError)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudapi/vins/staticRouteAccessRevoke"
|
||||||
|
|
||||||
|
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
|
||||||
|
}
|
@ -0,0 +1,56 @@
|
|||||||
|
package vins
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"net/http"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Request struct for add static route
|
||||||
|
type StaticRouteAddRequest struct {
|
||||||
|
// VINS ID
|
||||||
|
// Required: true
|
||||||
|
VINSID uint64 `url:"vinsId" json:"vinsId" validate:"required"`
|
||||||
|
|
||||||
|
// Destination network
|
||||||
|
// Required: true
|
||||||
|
Destination string `url:"destination" json:"destination" validate:"required"`
|
||||||
|
|
||||||
|
// Destination network mask in 255.255.255.255 format
|
||||||
|
// Required: true
|
||||||
|
Netmask string `url:"netmask" json:"netmask" validate:"required"`
|
||||||
|
|
||||||
|
// Next hop host, IP address from ViNS ID free IP pool
|
||||||
|
// Required: true
|
||||||
|
Gateway string `url:"gateway" json:"gateway" validate:"required"`
|
||||||
|
|
||||||
|
// List of Compute IDs which have access to this route
|
||||||
|
// Required: false
|
||||||
|
ComputeIds []uint64 `url:"computeIds,omitempty" json:"computeIds,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// StaticRouteAdd add new static route to ViNS
|
||||||
|
func (v VINS) StaticRouteAdd(ctx context.Context, req StaticRouteAddRequest) (bool, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
for _, validationError := range validators.GetErrors(err) {
|
||||||
|
return false, validators.ValidationError(validationError)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudapi/vins/staticRouteAdd"
|
||||||
|
|
||||||
|
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
|
||||||
|
}
|
@ -0,0 +1,44 @@
|
|||||||
|
package vins
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"net/http"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Request struct for remove static route from ViNS
|
||||||
|
type StaticRouteDelRequest struct {
|
||||||
|
// ViNS ID to remove static route from
|
||||||
|
// Required: true
|
||||||
|
VINSID uint64 `url:"vinsId" json:"vinsId" validate:"required"`
|
||||||
|
|
||||||
|
// Route ID to remove, can be found in staticRouteList
|
||||||
|
// Required: true
|
||||||
|
RouteId uint64 `url:"routeId" json:"routeId" validate:"required"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Remove static route from ViNS
|
||||||
|
func (v VINS) StaticRouteDel(ctx context.Context, req StaticRouteDelRequest) (bool, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
for _, validationError := range validators.GetErrors(err) {
|
||||||
|
return false, validators.ValidationError(validationError)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudapi/vins/staticRouteDel"
|
||||||
|
|
||||||
|
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
|
||||||
|
}
|
Loading…
Reference in new issue