Compare commits
1 Commits
main
...
1.5.9branc
Author | SHA1 | Date |
---|---|---|
|
082f577e17 | 1 year ago |
@ -1,38 +0,0 @@
|
|||||||
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
|
|
||||||
}
|
|
@ -1,48 +0,0 @@
|
|||||||
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
|
|
||||||
}
|
|
@ -1,40 +0,0 @@
|
|||||||
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
|
|
||||||
}
|
|
@ -1,72 +0,0 @@
|
|||||||
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
|
|
||||||
}
|
|
@ -1,10 +0,0 @@
|
|||||||
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)
|
|
||||||
}
|
|
@ -1,42 +0,0 @@
|
|||||||
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
|
|
||||||
}
|
|
@ -1,53 +0,0 @@
|
|||||||
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
|
|
||||||
}
|
|
@ -1,53 +0,0 @@
|
|||||||
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"`
|
|
||||||
}
|
|
@ -1,16 +0,0 @@
|
|||||||
// 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,
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,48 +0,0 @@
|
|||||||
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
|
|
||||||
}
|
|
@ -1,48 +0,0 @@
|
|||||||
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
|
|
||||||
}
|
|
@ -1,56 +0,0 @@
|
|||||||
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
|
|
||||||
}
|
|
@ -1,44 +0,0 @@
|
|||||||
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
|
|
||||||
}
|
|
@ -1,42 +0,0 @@
|
|||||||
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
|
|
||||||
}
|
|
@ -1,43 +0,0 @@
|
|||||||
package compute
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"net/http"
|
|
||||||
"strconv"
|
|
||||||
|
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
|
||||||
)
|
|
||||||
// Request struct for setting customFields values for the Compute
|
|
||||||
type SetCustomFieldsRequest struct {
|
|
||||||
// ID of the compute
|
|
||||||
// Required: true
|
|
||||||
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
|
|
||||||
|
|
||||||
// Custom fields for Compute. Must be dict.
|
|
||||||
// Required: true
|
|
||||||
CustomFields string `url:"customFields" json:"customFields" validate:"required"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetCustomFields sets customFields values for the Compute
|
|
||||||
func (c Compute) SetCustomFields(ctx context.Context, req SetCustomFieldsRequest) (bool, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
for _, validationError := range validators.GetErrors(err) {
|
|
||||||
return false, validators.ValidationError(validationError)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudbroker/compute/setCustomFields"
|
|
||||||
|
|
||||||
res, err := c.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,48 +0,0 @@
|
|||||||
package extnet
|
|
||||||
|
|
||||||
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 {
|
|
||||||
// ExtNet ID to grant access
|
|
||||||
// Required: true
|
|
||||||
ExtNetID uint64 `url:"extnetId" json:"extnetId" 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 ExtNet) 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 := "/cloudbroker/extnet/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
|
|
||||||
}
|
|
@ -1,48 +0,0 @@
|
|||||||
package extnet
|
|
||||||
|
|
||||||
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 {
|
|
||||||
// ExtNet ID to revoke access
|
|
||||||
// Required: true
|
|
||||||
ExtNetID uint64 `url:"extnetId" json:"extnetId" 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 ExtNet) 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 := "/cloudbroker/extnet/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
|
|
||||||
}
|
|
@ -1,56 +0,0 @@
|
|||||||
package extnet
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"net/http"
|
|
||||||
"strconv"
|
|
||||||
|
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Request struct for add static route
|
|
||||||
type StaticRouteAddRequest struct {
|
|
||||||
// ExtNet ID to add static route
|
|
||||||
// Required: true
|
|
||||||
ExtNetId uint64 `url:"extnetId" json:"extnetId" 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 ExtNet) 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 := "/cloudbroker/extnet/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
|
|
||||||
}
|
|
@ -1,44 +0,0 @@
|
|||||||
package extnet
|
|
||||||
|
|
||||||
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 {
|
|
||||||
// ExtNet ID to remove static route from
|
|
||||||
// Required: true
|
|
||||||
ExtNetID uint64 `url:"extnetId" json:"extnetId" 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 ExtNet) 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 := "/cloudbroker/extnet/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
|
|
||||||
}
|
|
@ -1,42 +0,0 @@
|
|||||||
package extnet
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"encoding/json"
|
|
||||||
"net/http"
|
|
||||||
|
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Request struct for static route list
|
|
||||||
type StaticRouteListRequest struct {
|
|
||||||
// ExtNet ID to show list of static routes
|
|
||||||
// Required: true
|
|
||||||
ExtNetID uint64 `url:"extnetId" json:"extnetId" validate:"required"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// Show list of static routes for ViNS
|
|
||||||
func (v ExtNet) 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 := "/cloudbroker/extnet/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
|
|
||||||
}
|
|
@ -1,38 +0,0 @@
|
|||||||
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 := "/cloudbroker/k8s/getWorkerNodesMetaData"
|
|
||||||
|
|
||||||
res, err := k.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
return string(res), nil
|
|
||||||
}
|
|
@ -1,48 +0,0 @@
|
|||||||
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 := "/cloudbroker/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
|
|
||||||
}
|
|
@ -1,40 +0,0 @@
|
|||||||
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 := "/cloudbroker/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
|
|
||||||
}
|
|
@ -1,72 +0,0 @@
|
|||||||
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 := "/cloudbroker/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
|
|
||||||
}
|
|
@ -1,48 +0,0 @@
|
|||||||
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 := "/cloudbroker/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
|
|
||||||
}
|
|
@ -1,48 +0,0 @@
|
|||||||
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 := "/cloudbroker/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
|
|
||||||
}
|
|
@ -1,56 +0,0 @@
|
|||||||
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 := "/cloudbroker/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
|
|
||||||
}
|
|
@ -1,44 +0,0 @@
|
|||||||
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 := "/cloudbroker/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
|
|
||||||
}
|
|
@ -1,42 +0,0 @@
|
|||||||
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 := "/cloudbroker/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
|
|
||||||
}
|
|
Loading…
Reference in new issue