Compare commits
2 Commits
v1.6.0-eps
...
v1.5.10
| Author | SHA1 | Date | |
|---|---|---|---|
| 082f577e17 | |||
| 78a4152471 |
31
CHANGELOG.md
31
CHANGELOG.md
@@ -1,32 +1,7 @@
|
|||||||
## Version 1.6.0
|
## Version 1.5.9
|
||||||
|
|
||||||
### Bugfix
|
### Bugfix
|
||||||
- Fix cloudaApi/client and cloudapi/legacy-client, the cyclicity of sending requests has been removed
|
- Refactored clients to fix the problems with retries
|
||||||
- Edit description field SSLSkipVerify in cloudapi/config/config and cloudapi/config/legacy-config
|
|
||||||
- Remove tags required fields ExtNetID VINSID Start in model CreateRequest in cloudapi/lb/create
|
|
||||||
- Add tags required fields BindingName BindingAddress BindingPort in model FrontendBindRequest in cloudapi/lb/frontend_bind
|
|
||||||
- Add tags required fields BindingAddress BindingPort in model FrontendBindUpdateRequest in cloudapi/lb/frontend_bind_update
|
|
||||||
|
|
||||||
### Feature
|
|
||||||
- Add field UserData in cloudapi/bservice/group_add
|
|
||||||
- Add fields VinsId, LbSysctlParams, HighlyAvailable, AdditionalSANs, InitConfiguration, ClusterConfiguration, KubeletConfiguration, KubeProxyConfiguration, JoinConfiguration, UserData, ExtNetOnly, OidcCertificate in model request cloudapi/k8s/create
|
|
||||||
- Add field Externalip in model ItemDetailedInfo in cloudapi/k8s/models
|
|
||||||
- Add fields SysctlParams, HighlyAvailable in model CreateRequest in cloudapi/lb/create
|
|
||||||
- Add fields BackendHAIP, FrontendHAIP, PartK8s, SysctlParams in model RecordLB in cloudapi/lb/models
|
|
||||||
- Add models InfoStack, ItemStack, ListStacks cloudapi/stack/models
|
|
||||||
- Add field Routes and type Route in CreateInAccountRequest and CreateInRGRequest models in cloudapi/vins/create_in_rg and /cloudapi/vins/create_in_account
|
|
||||||
- Add field Enabled in model ItemVNFInterface
|
|
||||||
- Add fields Routes in models RecordNAT, RecordDHCP, RecordGW and add type ListStaticRoutes, ListRoutes, ItemRoutes in cloudapi/vins/models
|
|
||||||
|
|
||||||
- Added new endpoints:
|
|
||||||
- cloudapi/k8s/get_worker_nodes_meta_data
|
|
||||||
- cloudapi/k8s/update_worker_nodes_meta_data
|
|
||||||
- cloudapi/lb/make_highly_available
|
|
||||||
- cloudapi/lb/updateSysctParams
|
|
||||||
- cloudapi/stack/get
|
|
||||||
- cloudapi/stack/list
|
|
||||||
- cloudapi/vins/static_route_list
|
|
||||||
- cloudapi/vins/static_route_access_grant
|
|
||||||
- cloudapi/vins/static_route_access_revoke
|
|
||||||
- cloudapi/vins/static_route_add
|
|
||||||
- cloudapi/vins/static_route_del
|
|
||||||
12
README.md
12
README.md
@@ -10,7 +10,6 @@ Decort SDK - это библиотека, написанная на языке G
|
|||||||
- Версия 1.3.x Decort-SDK соответствует 3.8.5 версии платформы
|
- Версия 1.3.x Decort-SDK соответствует 3.8.5 версии платформы
|
||||||
- Версия 1.4.x Decort-SDK соответствует 3.8.6 версии платформы
|
- Версия 1.4.x Decort-SDK соответствует 3.8.6 версии платформы
|
||||||
- Версия 1.5.x Decort-SDK соответствует 3.8.7 версии платформы
|
- Версия 1.5.x Decort-SDK соответствует 3.8.7 версии платформы
|
||||||
- Версия 1.6.x Decort-SDK соответствует 3.8.8 версии платформы
|
|
||||||
|
|
||||||
## Оглавление
|
## Оглавление
|
||||||
|
|
||||||
@@ -75,7 +74,6 @@ go get -u repository.basistech.ru/BASIS/decort-golang-sdk
|
|||||||
- `Locations` - получение информации о grid площадки;
|
- `Locations` - получение информации о grid площадки;
|
||||||
- `RG` - управление ресурсными группами аккаунта;
|
- `RG` - управление ресурсными группами аккаунта;
|
||||||
- `Sizes` - получение информации о потребляемых ресурсах виртуальными машинами и дисками;
|
- `Sizes` - получение информации о потребляемых ресурсах виртуальными машинами и дисками;
|
||||||
- `Stack` - получение информации о вычислительных узлах;
|
|
||||||
- `Tasks` - получение информации о ходе выполнения асинхронных задач (например, создание кластера);
|
- `Tasks` - получение информации о ходе выполнения асинхронных задач (например, создание кластера);
|
||||||
- `VINS` - управление виртуальными изолированными сетями.
|
- `VINS` - управление виртуальными изолированными сетями.
|
||||||
|
|
||||||
@@ -102,7 +100,7 @@ go get -u repository.basistech.ru/BASIS/decort-golang-sdk
|
|||||||
- `PCIDevice` - управление устройствами;
|
- `PCIDevice` - управление устройствами;
|
||||||
- `RG` - управление ресурсными группами аккаунта;
|
- `RG` - управление ресурсными группами аккаунта;
|
||||||
- `SEP` - управление storage endpoint (sep);
|
- `SEP` - управление storage endpoint (sep);
|
||||||
- `Stack` - получение информации о вычислительных узлах;
|
- `Stack` - получение информации о стеках;
|
||||||
- `Tasks` - получение информации о ходе выполнения асинхронных задач (например, создание кластера);
|
- `Tasks` - получение информации о ходе выполнения асинхронных задач (например, создание кластера);
|
||||||
- `User` - управление пользователями (индивидуально);
|
- `User` - управление пользователями (индивидуально);
|
||||||
- `VGPU` - управление виртуальными графическими процессорами;
|
- `VGPU` - управление виртуальными графическими процессорами;
|
||||||
@@ -252,8 +250,7 @@ func main() {
|
|||||||
- `pkg/cloudapi/lb` - для `LB`
|
- `pkg/cloudapi/lb` - для `LB`
|
||||||
- `pkg/cloudapi/locations` - для `Locations`
|
- `pkg/cloudapi/locations` - для `Locations`
|
||||||
- `pkg/cloudapi/rg` - для `RG`
|
- `pkg/cloudapi/rg` - для `RG`
|
||||||
- `pkg/cloudapi/sizes` - для `Sizes`
|
- `pkg/cloudapi/sizes` - для `RG`
|
||||||
- `pkg/cloudapi/stack` - для `Stack`
|
|
||||||
- `pkg/cloudapi/tasks` - для `Tasks`
|
- `pkg/cloudapi/tasks` - для `Tasks`
|
||||||
- `pkg/cloudapi/vins` - для `VINS`
|
- `pkg/cloudapi/vins` - для `VINS`
|
||||||
- **cloudbroker**:
|
- **cloudbroker**:
|
||||||
@@ -415,7 +412,7 @@ func main() {
|
|||||||
|
|
||||||
Чтобы выполнить запрос, необходимо:
|
Чтобы выполнить запрос, необходимо:
|
||||||
|
|
||||||
1. Вызвать у клиента метод, отвечаеющий за определение группы API для взаимодействия, это может быть `.CloudAPI()`, либо `.CloudBroker()`. Данные методы возвращаеют соответствующие структуры, с помощью которых можно совершать запросы.
|
1. Вызвать у клиента метод, отвечаеющий за определение группы API для взаимодействия, это может быть `.CloudAPI()`, либо `.CloudBroker()`. Данные методы возвращаеют соответствующие структуры, с помощью которых можно соверать запросы.
|
||||||
2. Вызвать у возвращенной структуры метод, определяющий группу ручек для взаимодействия.
|
2. Вызвать у возвращенной структуры метод, определяющий группу ручек для взаимодействия.
|
||||||
|
|
||||||
Доступные методы для `.CloudAPI()`:
|
Доступные методы для `.CloudAPI()`:
|
||||||
@@ -435,7 +432,6 @@ func main() {
|
|||||||
- `.Locations()` - для работы с `Locations`
|
- `.Locations()` - для работы с `Locations`
|
||||||
- `.RG()` - для работы с `RG`
|
- `.RG()` - для работы с `RG`
|
||||||
- `.Sizes()` - для работы с `Sizes`
|
- `.Sizes()` - для работы с `Sizes`
|
||||||
- `.Stack()` - для работы с `Stack`
|
|
||||||
- `.Tasks()` - для работы с `Tasks`
|
- `.Tasks()` - для работы с `Tasks`
|
||||||
- `.VINS()` - для работы с `VINS`
|
- `.VINS()` - для работы с `VINS`
|
||||||
|
|
||||||
@@ -469,7 +465,7 @@ func main() {
|
|||||||
|
|
||||||
- контекст;
|
- контекст;
|
||||||
- структуру запроса.
|
- структуру запроса.
|
||||||
У каждой группы ручек API имеются свои доступные методы, которые определяются платформой.
|
У кождой группы ручек API имеются свои доступные методы, которые определяются платформой.
|
||||||
|
|
||||||
4. Обработать результат и ошибки.
|
4. Обработать результат и ошибки.
|
||||||
|
|
||||||
|
|||||||
@@ -145,7 +145,7 @@ func (dc *DecortClient) do(req *http.Request) (*http.Response, error) {
|
|||||||
buf, _ := io.ReadAll(req.Body)
|
buf, _ := io.ReadAll(req.Body)
|
||||||
|
|
||||||
// for i := uint64(0); i < dc.cfg.Retries; i++ {
|
// for i := uint64(0); i < dc.cfg.Retries; i++ {
|
||||||
req = req.Clone(req.Context())
|
// req = req.Clone(req.Context())
|
||||||
req.Body = io.NopCloser(bytes.NewBuffer(buf))
|
req.Body = io.NopCloser(bytes.NewBuffer(buf))
|
||||||
resp, err := dc.client.Do(req)
|
resp, err := dc.client.Do(req)
|
||||||
|
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ type Config struct {
|
|||||||
// Required: false
|
// Required: false
|
||||||
Retries uint64 `json:"retries" yaml:"retries"`
|
Retries uint64 `json:"retries" yaml:"retries"`
|
||||||
|
|
||||||
// Skip verify
|
// Skip verify, true by default
|
||||||
// Required: false
|
// Required: false
|
||||||
SSLSkipVerify bool `json:"sslSkipVerify" yaml:"sslSkipVerify"`
|
SSLSkipVerify bool `json:"sslSkipVerify" yaml:"sslSkipVerify"`
|
||||||
|
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ type LegacyConfig struct {
|
|||||||
// Required: false
|
// Required: false
|
||||||
Retries uint64 `json:"retries" yaml:"retries"`
|
Retries uint64 `json:"retries" yaml:"retries"`
|
||||||
|
|
||||||
// Skip verify
|
// Skip verify, true by default
|
||||||
// Required: false
|
// Required: false
|
||||||
SSLSkipVerify bool `json:"sslSkipVerify" yaml:"sslSkipVerify"`
|
SSLSkipVerify bool `json:"sslSkipVerify" yaml:"sslSkipVerify"`
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ func (d *Duration) UnmarshalYAML(unmarshal func(interface{}) error) error {
|
|||||||
*d = Duration(tmp)
|
*d = Duration(tmp)
|
||||||
return nil
|
return nil
|
||||||
default:
|
default:
|
||||||
return fmt.Errorf("invalid duration %v", value)
|
return fmt.Errorf("Invalid duration %v", value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -41,7 +41,7 @@ func (d *Duration) UnmarshalJSON(b []byte) error {
|
|||||||
*d = Duration(tmp)
|
*d = Duration(tmp)
|
||||||
return nil
|
return nil
|
||||||
default:
|
default:
|
||||||
return fmt.Errorf("invalid duration %v", value)
|
return fmt.Errorf("Invalid duration %v", value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -142,7 +142,7 @@ func (ldc *LegacyDecortClient) do(req *http.Request) (*http.Response, error) {
|
|||||||
buf, _ := io.ReadAll(req.Body)
|
buf, _ := io.ReadAll(req.Body)
|
||||||
|
|
||||||
// for i := uint64(0); i < ldc.cfg.Retries; i++ {
|
// for i := uint64(0); i < ldc.cfg.Retries; i++ {
|
||||||
req = req.Clone(req.Context())
|
// req = req.Clone(req.Context())
|
||||||
req.Body = io.NopCloser(bytes.NewBuffer(buf))
|
req.Body = io.NopCloser(bytes.NewBuffer(buf))
|
||||||
resp, err := ldc.client.Do(req)
|
resp, err := ldc.client.Do(req)
|
||||||
|
|
||||||
@@ -153,7 +153,7 @@ func (ldc *LegacyDecortClient) do(req *http.Request) (*http.Response, error) {
|
|||||||
respBytes, _ := io.ReadAll(resp.Body)
|
respBytes, _ := io.ReadAll(resp.Body)
|
||||||
err = fmt.Errorf("%s", respBytes)
|
err = fmt.Errorf("%s", respBytes)
|
||||||
resp.Body.Close()
|
resp.Body.Close()
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
return nil, fmt.Errorf("could not execute request: %w", err)
|
return nil, fmt.Errorf("could not execute request: %w", err)
|
||||||
|
|||||||
@@ -68,10 +68,6 @@ type GroupAddRequest struct {
|
|||||||
// Time of Compute Group readiness
|
// Time of Compute Group readiness
|
||||||
// Required: false
|
// Required: false
|
||||||
TimeoutStart uint64 `url:"timeoutStart,omitempty" json:"timeoutStart,omitempty"`
|
TimeoutStart uint64 `url:"timeoutStart,omitempty" json:"timeoutStart,omitempty"`
|
||||||
|
|
||||||
// Meta data for working group computes, format YAML "user_data": 1111
|
|
||||||
// Required: false
|
|
||||||
UserData string `url:"userData,omitempty" json:"userData,omitempty"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// GroupAdd creates new Compute Group within BasicService.
|
// GroupAdd creates new Compute Group within BasicService.
|
||||||
|
|||||||
@@ -8,8 +8,6 @@ import (
|
|||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
)
|
)
|
||||||
|
|
||||||
// type Params []string
|
|
||||||
|
|
||||||
// Request struct for create kubernetes cluster
|
// Request struct for create kubernetes cluster
|
||||||
type CreateRequest struct {
|
type CreateRequest struct {
|
||||||
// Name of Kubernetes cluster
|
// Name of Kubernetes cluster
|
||||||
@@ -100,77 +98,16 @@ type CreateRequest struct {
|
|||||||
// Required: false
|
// Required: false
|
||||||
ExtNetID uint64 `url:"extnetId,omitempty" json:"extnetId,omitempty"`
|
ExtNetID uint64 `url:"extnetId,omitempty" json:"extnetId,omitempty"`
|
||||||
|
|
||||||
// ID of the ViNS to connect k8s cluster. If nothing is specified, ViNS will be created automatically
|
|
||||||
// Required: false
|
|
||||||
VinsId uint64 `url:"vinsId,omitempty" json:"vinsId,omitempty"`
|
|
||||||
|
|
||||||
// Create Kubernetes cluster with masters nodes behind load balancer if true.
|
// Create Kubernetes cluster with masters nodes behind load balancer if true.
|
||||||
// Otherwise give all cluster nodes direct external addresses from selected ExtNet
|
// Otherwise give all cluster nodes direct external addresses from selected ExtNet
|
||||||
// Required: false
|
// Required: false
|
||||||
WithLB bool `url:"withLB" json:"withLB"`
|
WithLB bool `url:"withLB" json:"withLB"`
|
||||||
|
|
||||||
// Custom sysctl values for Load Balancer instance. Applied on boot
|
|
||||||
// Required: false
|
|
||||||
LbSysctlParams string `url:"-" json:"lbSysctlParams,omitempty" validate:"omitempty,dive"`
|
|
||||||
|
|
||||||
// Use Highly Available schema for LB deploy
|
|
||||||
// Required: false
|
|
||||||
HighlyAvailable bool `url:"highlyAvailable,omitempty" json:"highlyAvailable,omitempty"`
|
|
||||||
|
|
||||||
// Optional extra Subject Alternative Names (SANs) to use for the API Server serving certificate. Can be both IP addresses and DNS names
|
|
||||||
// Required: false
|
|
||||||
AdditionalSANs []string `url:"additionalSANs,omitempty" json:"additionalSANs,omitempty"`
|
|
||||||
|
|
||||||
// Is used to define settings and actions that should be performed before any other component in the cluster starts.
|
|
||||||
// It allows you to configure things like node registration, network setup, and other initialization tasks. insert a valid JSON string with all levels of nesting
|
|
||||||
// Required: false
|
|
||||||
InitConfiguration string `url:"initConfiguration,omitempty" json:"initConfiguration,omitempty"`
|
|
||||||
|
|
||||||
// Is used to define global settings and configurations for the entire cluster.
|
|
||||||
// It includes parameters such as cluster name, DNS settings, authentication methods, and other cluster-wide configurations.
|
|
||||||
// Insert a valid JSON string with all levels of nesting
|
|
||||||
// Required: false
|
|
||||||
ClusterConfiguration string `url:"clusterConfiguration,omitempty" json:"clusterConfiguration,omitempty"`
|
|
||||||
|
|
||||||
// Is used to configure the behavior and settings of the Kubelet, which is the primary node agent that runs on each node in the cluster.
|
|
||||||
// It includes parameters such as node IP address, resource allocation, pod eviction policies, and other Kubelet-specific configurations.
|
|
||||||
// Insert a valid JSON string with all levels of nesting
|
|
||||||
// Required: false
|
|
||||||
KubeletConfiguration string `url:"kubeletConfiguration,omitempty" json:"kubeletConfiguration,omitempty"`
|
|
||||||
|
|
||||||
// Is used to configure the behavior and settings of the Kube-proxy, which is responsible for network proxying and load balancing within the cluster.
|
|
||||||
// It includes parameters such as proxy mode, cluster IP ranges, and other Kube-proxy specific configurations.
|
|
||||||
// Insert a valid JSON string with all levels of nesting
|
|
||||||
// Required: false
|
|
||||||
KubeProxyConfiguration string `url:"kubeProxyConfiguration,omitempty" json:"kubeProxyConfiguration,omitempty"`
|
|
||||||
|
|
||||||
// Is used to configure the behavior and settings for joining a node to a cluster.
|
|
||||||
// It includes parameters such as the cluster's control plane endpoint, token, and certificate key. insert a valid JSON string with all levels of nesting
|
|
||||||
// Required: false
|
|
||||||
JoinConfiguration string `url:"joinConfiguration,omitempty" json:"joinConfiguration,omitempty"`
|
|
||||||
|
|
||||||
// Text description of this Kubernetes cluster
|
// Text description of this Kubernetes cluster
|
||||||
// Required: false
|
// Required: false
|
||||||
Description string `url:"desc,omitempty" json:"desc,omitempty"`
|
Description string `url:"desc,omitempty" json:"desc,omitempty"`
|
||||||
|
|
||||||
// Meta data for working group computes, format YAML "user_data": 1111
|
|
||||||
// Required: false
|
|
||||||
UserData string `url:"userData,omitempty" json:"userData,omitempty"`
|
|
||||||
|
|
||||||
// Use only selected ExtNet for infrastructure connections
|
|
||||||
// Required: false
|
|
||||||
ExtNetOnly bool `url:"extnetOnly,omitempty" json:"extnetOnly,omitempty"`
|
|
||||||
|
|
||||||
// Insert ssl certificate in x509 pem format
|
|
||||||
// Required: false
|
|
||||||
OidcCertificate []byte `url:"oidcCertificate,omitempty" json:"oidcCertificate,omitempty"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// type wrapperCreateRequest struct {
|
|
||||||
// CreateRequest
|
|
||||||
// Params []string `url:"lbSysctlParams,omitempty"`
|
|
||||||
// }
|
|
||||||
|
|
||||||
// Create creates a new Kubernetes cluster in the specified Resource Group
|
// Create creates a new Kubernetes cluster in the specified Resource Group
|
||||||
func (k8s K8S) Create(ctx context.Context, req CreateRequest) (string, error) {
|
func (k8s K8S) Create(ctx context.Context, req CreateRequest) (string, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
@@ -180,28 +117,6 @@ func (k8s K8S) Create(ctx context.Context, req CreateRequest) (string, error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// var params []string
|
|
||||||
|
|
||||||
// if len(req.LbSysctlParams) != 0 {
|
|
||||||
// params = make([]string, 0, len(req.LbSysctlParams))
|
|
||||||
|
|
||||||
// for r := range req.LbSysctlParams {
|
|
||||||
// b, err := json.Marshal(req.LbSysctlParams[r])
|
|
||||||
// if err != nil {
|
|
||||||
// return "", err
|
|
||||||
// }
|
|
||||||
|
|
||||||
// params = append(params, string(b))
|
|
||||||
// }
|
|
||||||
// } else {
|
|
||||||
// params = []string{"[]"}
|
|
||||||
// }
|
|
||||||
|
|
||||||
// reqWrapped := wrapperCreateRequest{
|
|
||||||
// CreateRequest: req,
|
|
||||||
// Params: params,
|
|
||||||
// }
|
|
||||||
|
|
||||||
url := "/cloudapi/k8s/create"
|
url := "/cloudapi/k8s/create"
|
||||||
|
|
||||||
res, err := k8s.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
res, err := k8s.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
|||||||
@@ -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
|
|
||||||
}
|
|
||||||
@@ -41,9 +41,6 @@ type ListK8SGroups []ItemK8SGroup
|
|||||||
|
|
||||||
// Detailed information
|
// Detailed information
|
||||||
type ItemDetailedInfo struct {
|
type ItemDetailedInfo struct {
|
||||||
// Externalip
|
|
||||||
Externalip string `json:"externalip"`
|
|
||||||
|
|
||||||
// ID
|
// ID
|
||||||
ID uint64 `json:"id"`
|
ID uint64 `json:"id"`
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
|
||||||
}
|
|
||||||
@@ -2,16 +2,12 @@ package lb
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
|
||||||
"errors"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
"strings"
|
||||||
|
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Params []string
|
|
||||||
|
|
||||||
// Request struct for create load balancer
|
// Request struct for create load balancer
|
||||||
type CreateRequest struct {
|
type CreateRequest struct {
|
||||||
// ID of the resource group where this load balancer instance will be located
|
// ID of the resource group where this load balancer instance will be located
|
||||||
@@ -24,81 +20,39 @@ type CreateRequest struct {
|
|||||||
Name string `url:"name" json:"name" validate:"required"`
|
Name string `url:"name" json:"name" validate:"required"`
|
||||||
|
|
||||||
// External network to connect this load balancer to
|
// External network to connect this load balancer to
|
||||||
// Required: false
|
// Required: true
|
||||||
ExtNetID uint64 `url:"extnetId" json:"extnetId"`
|
ExtNetID uint64 `url:"extnetId" json:"extnetId" validate:"required"`
|
||||||
|
|
||||||
// Internal network (VINS) to connect this load balancer to
|
// Internal network (VINS) to connect this load balancer to
|
||||||
// Required: false
|
// Required: true
|
||||||
VINSID uint64 `url:"vinsId" json:"vinsId"`
|
VINSID uint64 `url:"vinsId" json:"vinsId" validate:"required"`
|
||||||
|
|
||||||
// Custom sysctl values for Load Balancer instance. Applied on boot
|
|
||||||
// Required: false
|
|
||||||
SysctlParams Params `url:"-" json:"sysctlParams,omitempty" validate:"omitempty,dive"`
|
|
||||||
|
|
||||||
// Use Highly Available schema for LB deploy
|
|
||||||
// Required: false
|
|
||||||
HighlyAvailable bool `url:"highlyAvailable,omitempty" json:"highlyAvailable,omitempty"`
|
|
||||||
|
|
||||||
// Start now Load balancer
|
// Start now Load balancer
|
||||||
// Required: false
|
// Required: true
|
||||||
Start bool `url:"start" json:"start"`
|
Start bool `url:"start" json:"start" validate:"required"`
|
||||||
|
|
||||||
// Text description of this load balancer
|
// Text description of this load balancer
|
||||||
// Required: false
|
// Required: false
|
||||||
Description string `url:"desc,omitempty" json:"desc,omitempty"`
|
Description string `url:"desc,omitempty" json:"desc,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type wrapperCreateRequest struct {
|
|
||||||
CreateRequest
|
|
||||||
Params []string `url:"sysctlParams,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create method will create a new load balancer instance
|
// Create method will create a new load balancer instance
|
||||||
func (l LB) Create(ctx context.Context, req CreateRequest) (uint64, error) {
|
func (l LB) Create(ctx context.Context, req CreateRequest) (string, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
for _, validationError := range validators.GetErrors(err) {
|
for _, validationError := range validators.GetErrors(err) {
|
||||||
return 0, validators.ValidationError(validationError)
|
return "", validators.ValidationError(validationError)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if req.ExtNetID == 0 && req.VINSID == 0 {
|
|
||||||
return 0, errors.New("vinsId and extNetId cannot be both in the value 0")
|
|
||||||
}
|
|
||||||
|
|
||||||
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 0, err
|
|
||||||
}
|
|
||||||
|
|
||||||
params = append(params, string(b))
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
params = []string{}
|
|
||||||
}
|
|
||||||
|
|
||||||
reqWrapped := wrapperCreateRequest{
|
|
||||||
CreateRequest: req,
|
|
||||||
Params: params,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/lb/create"
|
url := "/cloudapi/lb/create"
|
||||||
|
|
||||||
res, err := l.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
res, err := l.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
result, err := strconv.ParseUint(string(res), 10, 64)
|
result := strings.ReplaceAll(string(res), "\"", "")
|
||||||
if err != nil {
|
|
||||||
return 0, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,18 +20,18 @@ type FrontendBindRequest struct {
|
|||||||
|
|
||||||
// Name of the binding to update
|
// Name of the binding to update
|
||||||
// Required: true
|
// Required: true
|
||||||
BindingName string `url:"bindingName" json:"bindingName" validate:"required"`
|
BindingName string `url:"bindingName" json:"bindingName"`
|
||||||
|
|
||||||
// If specified must be within the IP range of either Ext Net or ViNS,
|
// If specified must be within the IP range of either Ext Net or ViNS,
|
||||||
// where this load balancer is connected - new IP address to use for this binding.
|
// where this load balancer is connected - new IP address to use for this binding.
|
||||||
// If omitted, current IP address is retained
|
// If omitted, current IP address is retained
|
||||||
// Required: true
|
// Required: false
|
||||||
BindingAddress string `url:"bindingAddress" json:"bindingAddress" validate:"required"`
|
BindingAddress string `url:"bindingAddress,omitempty" json:"bindingAddress,omitempty"`
|
||||||
|
|
||||||
// New port number to use for this binding.
|
// New port number to use for this binding.
|
||||||
// If omitted, current port number is retained
|
// If omitted, current port number is retained
|
||||||
// Required: true
|
// Required: false
|
||||||
BindingPort uint64 `url:"bindingPort" json:"bindingPort" validate:"required"`
|
BindingPort uint64 `url:"bindingPort,omitempty" json:"bindingPort,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// FrontendBind bind frontend from specified load balancer instance
|
// FrontendBind bind frontend from specified load balancer instance
|
||||||
|
|||||||
@@ -25,13 +25,13 @@ type FrontendBindUpdateRequest struct {
|
|||||||
// If specified must be within the IP range of either Ext Net or ViNS,
|
// If specified must be within the IP range of either Ext Net or ViNS,
|
||||||
// where this load balancer is connected - new IP address to use for this binding.
|
// where this load balancer is connected - new IP address to use for this binding.
|
||||||
// If omitted, current IP address is retained
|
// If omitted, current IP address is retained
|
||||||
// Required: true
|
// Required: false
|
||||||
BindingAddress string `url:"bindingAddress" json:"bindingAddress" validate:"required"`
|
BindingAddress string `url:"bindingAddress,omitempty" json:"bindingAddress,omitempty"`
|
||||||
|
|
||||||
// New port number to use for this binding.
|
// New port number to use for this binding.
|
||||||
// If omitted, current port number is retained
|
// If omitted, current port number is retained
|
||||||
// Required: true
|
// Required: false
|
||||||
BindingPort uint64 `url:"bindingPort" json:"bindingPort" validate:"required"`
|
BindingPort uint64 `url:"bindingPort,omitempty" json:"bindingPort,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// FrontendBindUpdate updates binding for the specified load balancer frontend
|
// FrontendBindUpdate updates binding for the specified load balancer frontend
|
||||||
|
|||||||
@@ -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
|
|
||||||
}
|
|
||||||
@@ -6,10 +6,7 @@ type RecordLB struct {
|
|||||||
HAMode bool `json:"HAmode"`
|
HAMode bool `json:"HAmode"`
|
||||||
|
|
||||||
// Access Control List
|
// Access Control List
|
||||||
ACL []interface{} `json:"acl"`
|
ACL interface{} `json:"acl"`
|
||||||
|
|
||||||
// BackendHAIP
|
|
||||||
BackendHAIP string `json:"backendHAIP"`
|
|
||||||
|
|
||||||
// List of load balancer backends
|
// List of load balancer backends
|
||||||
Backends ListBackends `json:"backends"`
|
Backends ListBackends `json:"backends"`
|
||||||
@@ -35,9 +32,6 @@ type RecordLB struct {
|
|||||||
// External network ID
|
// External network ID
|
||||||
ExtNetID uint64 `json:"extnetId"`
|
ExtNetID uint64 `json:"extnetId"`
|
||||||
|
|
||||||
// FrontendHAIP
|
|
||||||
FrontendHAIP string `json:"frontendHAIP"`
|
|
||||||
|
|
||||||
// List of load balancer frontends
|
// List of load balancer frontends
|
||||||
Frontends ListFrontends `json:"frontends"`
|
Frontends ListFrontends `json:"frontends"`
|
||||||
|
|
||||||
@@ -59,9 +53,6 @@ type RecordLB struct {
|
|||||||
// Name
|
// Name
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
|
|
||||||
// Part K8s
|
|
||||||
PartK8s bool `json:"partK8s"`
|
|
||||||
|
|
||||||
// Primary node
|
// Primary node
|
||||||
PrimaryNode RecordNode `json:"primaryNode"`
|
PrimaryNode RecordNode `json:"primaryNode"`
|
||||||
|
|
||||||
@@ -77,9 +68,6 @@ type RecordLB struct {
|
|||||||
// Status
|
// Status
|
||||||
Status string `json:"status"`
|
Status string `json:"status"`
|
||||||
|
|
||||||
// Sysctl Params
|
|
||||||
SysctlParams []interface{} `json:"sysctlParams"`
|
|
||||||
|
|
||||||
// Tech status
|
// Tech status
|
||||||
TechStatus string `json:"techStatus"`
|
TechStatus string `json:"techStatus"`
|
||||||
|
|
||||||
|
|||||||
@@ -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,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -2,24 +2,12 @@ package vins
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Route struct {
|
|
||||||
// Destination network
|
|
||||||
Destination string `url:"destination" json:"destination" validate:"required"`
|
|
||||||
|
|
||||||
//Destination network mask in 255.255.255.255 format
|
|
||||||
Netmask string `url:"netmask" json:"netmask" validate:"required"`
|
|
||||||
|
|
||||||
//Next hop host, IP address from ViNS ID free IP pool
|
|
||||||
Gateway string `url:"gateway" json:"gateway" validate:"required"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// Request struct for create VINS in account
|
// Request struct for create VINS in account
|
||||||
type CreateInAccountRequest struct {
|
type CreateInAccountRequest struct {
|
||||||
// VINS name
|
// VINS name
|
||||||
@@ -45,15 +33,6 @@ type CreateInAccountRequest struct {
|
|||||||
// Number of pre created reservations
|
// Number of pre created reservations
|
||||||
// Required: false
|
// Required: false
|
||||||
PreReservationsNum uint64 `url:"preReservationsNum,omitempty" json:"preReservationsNum,omitempty"`
|
PreReservationsNum uint64 `url:"preReservationsNum,omitempty" json:"preReservationsNum,omitempty"`
|
||||||
|
|
||||||
// List of static routes, each item must have destination, netmask, and gateway fields
|
|
||||||
// Required: false
|
|
||||||
Routes []Route `url:"-" json:"routes,omitempty" validate:"omitempty,dive"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type wrapperCreateRequestInAcc struct {
|
|
||||||
CreateInAccountRequest
|
|
||||||
Routes []string `url:"routes,omitempty"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreateInAccount creates VINS in account level
|
// CreateInAccount creates VINS in account level
|
||||||
@@ -65,31 +44,9 @@ func (v VINS) CreateInAccount(ctx context.Context, req CreateInAccountRequest) (
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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"
|
url := "/cloudapi/vins/createInAccount"
|
||||||
|
|
||||||
res, err := v.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
res, err := v.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package vins
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
@@ -38,15 +37,6 @@ type CreateInRGRequest struct {
|
|||||||
// Number of pre created reservations
|
// Number of pre created reservations
|
||||||
// Required: false
|
// Required: false
|
||||||
PreReservationsNum uint64 `url:"preReservationsNum,omitempty" json:"preReservationsNum,omitempty"`
|
PreReservationsNum uint64 `url:"preReservationsNum,omitempty" json:"preReservationsNum,omitempty"`
|
||||||
|
|
||||||
// List of static routes, each item must have destination, netmask, and gateway fields
|
|
||||||
// Required: false
|
|
||||||
Routes []Route `url:"-" json:"routes,omitempty" validate:"omitempty,dive"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type wrapperCreateRequestInRG struct {
|
|
||||||
CreateInRGRequest
|
|
||||||
Routes []string `url:"routes,omitempty"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreateInRG creates VINS in resource group level
|
// CreateInRG creates VINS in resource group level
|
||||||
@@ -58,31 +48,9 @@ func (v VINS) CreateInRG(ctx context.Context, req CreateInRGRequest) (uint64, er
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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"
|
url := "/cloudapi/vins/createInRG"
|
||||||
|
|
||||||
res, err := v.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
res, err := v.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -252,9 +252,6 @@ type ItemVNFInterface struct {
|
|||||||
// Default GW
|
// Default GW
|
||||||
DefGW string `json:"defGw"`
|
DefGW string `json:"defGw"`
|
||||||
|
|
||||||
// Enabled
|
|
||||||
Enabled bool `json:"enabled"`
|
|
||||||
|
|
||||||
// FLIPGroup ID
|
// FLIPGroup ID
|
||||||
FLIPGroupID uint64 `json:"flipgroupId"`
|
FLIPGroupID uint64 `json:"flipgroupId"`
|
||||||
|
|
||||||
@@ -381,9 +378,6 @@ type RecordNAT struct {
|
|||||||
// Pure virtual
|
// Pure virtual
|
||||||
PureVirtual bool `json:"pureVirtual"`
|
PureVirtual bool `json:"pureVirtual"`
|
||||||
|
|
||||||
// Routes
|
|
||||||
Routes ListRoutes `json:"routes"`
|
|
||||||
|
|
||||||
// Status
|
// Status
|
||||||
Status string `json:"status"`
|
Status string `json:"status"`
|
||||||
|
|
||||||
@@ -449,9 +443,6 @@ type RecordGW struct {
|
|||||||
// Pure virtual
|
// Pure virtual
|
||||||
PureVirtual bool `json:"pureVirtual"`
|
PureVirtual bool `json:"pureVirtual"`
|
||||||
|
|
||||||
// Routes
|
|
||||||
Routes ListRoutes `json:"routes"`
|
|
||||||
|
|
||||||
// Status
|
// Status
|
||||||
Status string `json:"status"`
|
Status string `json:"status"`
|
||||||
|
|
||||||
@@ -539,9 +530,6 @@ type RecordDHCP struct {
|
|||||||
// Pure virtual
|
// Pure virtual
|
||||||
PureVirtual bool `json:"pureVirtual"`
|
PureVirtual bool `json:"pureVirtual"`
|
||||||
|
|
||||||
// Routes
|
|
||||||
Routes ListRoutes `json:"routes"`
|
|
||||||
|
|
||||||
// Status
|
// Status
|
||||||
Status string `json:"status"`
|
Status string `json:"status"`
|
||||||
|
|
||||||
@@ -579,39 +567,6 @@ type RecordDHCPConfig struct {
|
|||||||
Reservations ListReservations `json:"reservations"`
|
Reservations ListReservations `json:"reservations"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// List of static routes
|
|
||||||
type ListStaticRoutes struct {
|
|
||||||
// Data
|
|
||||||
Data []ItemRoutes `json:"data"`
|
|
||||||
|
|
||||||
// Entry count
|
|
||||||
EntryCount uint64 `json:"entryCount"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// List of Routes
|
|
||||||
type ListRoutes []ItemRoutes
|
|
||||||
|
|
||||||
// Detailed information about Routes
|
|
||||||
type ItemRoutes struct {
|
|
||||||
//Compute Id
|
|
||||||
ComputeIds []uint64 `json:"computeIds"`
|
|
||||||
|
|
||||||
// Destination network
|
|
||||||
Destination string `json:"destination"`
|
|
||||||
|
|
||||||
//Next hop host, IP address from ViNS ID free IP pool
|
|
||||||
Gateway string `json:"gateway"`
|
|
||||||
|
|
||||||
// GUID
|
|
||||||
GUID string `json:"guid"`
|
|
||||||
|
|
||||||
// ID
|
|
||||||
ID uint64 `json:"id"`
|
|
||||||
|
|
||||||
//Destination network mask in 255.255.255.255 format
|
|
||||||
Netmask string `json:"netmask"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// Detailed information about VINS
|
// Detailed information about VINS
|
||||||
type RecordVINS struct {
|
type RecordVINS struct {
|
||||||
// Main information about VNF device
|
// Main information about VNF device
|
||||||
|
|||||||
@@ -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
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user