Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 082f577e17 |
13
CHANGELOG.md
13
CHANGELOG.md
@@ -1,10 +1,7 @@
|
|||||||
## Version 1.6.6
|
## Version 1.5.9
|
||||||
|
|
||||||
|
### Bugfix
|
||||||
|
- Refactored clients to fix the problems with retries
|
||||||
|
|
||||||
|
|
||||||
## Bugfix
|
|
||||||
- Fixed model RecordExtNet in cloudbroker/extnet/models for correct work of get request
|
|
||||||
- Fixed json tags in ItemResourceConsumption model and delete extra model Consumed in cloudbroker/account/models
|
|
||||||
- Fixed statelessSepId field type from uint64 to int64 in cloudbroker/compute/models for correct work of list request
|
|
||||||
|
|
||||||
## Feature
|
|
||||||
- Added GetRaw and ListRaw methods that give response as an array of bytes for cloudAPI groups: account, compute, k8s, disks, rg, bservice, disks,extnet, flipgroup, image, k8ci, lb, locations(list), sizes(list), stack, tasks, vins
|
|
||||||
- Added GetRaw and ListRaw methods that give response as an array of bytes for cloudbroker groups: account, apiaccess, compute, disks, extnet, flipgroup, grid, group, image, k8ci, k8s, lb, rg, sep, stack, tasks, user, vgpu, vins
|
|
||||||
62
README.md
62
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. Обработать результат и ошибки.
|
||||||
|
|
||||||
@@ -527,56 +523,6 @@ func main() {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
Для запросов Get и List реализованы запросы GetRaw и ListRaw, которые возвращают ответ не в виде соответствующей структуры, а в виде массива байт (JSON).
|
|
||||||
Выполнение таких запросов происходит аналогично.
|
|
||||||
|
|
||||||
#### Пример выполнения GetRaw и ListRaw запросов
|
|
||||||
|
|
||||||
```go
|
|
||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"log"
|
|
||||||
"fmt"
|
|
||||||
|
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/config"
|
|
||||||
decort "repository.basistech.ru/BASIS/decort-golang-sdk"
|
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/account"
|
|
||||||
)
|
|
||||||
|
|
||||||
func main() {
|
|
||||||
// Настройка конфигурации
|
|
||||||
cfg := config.Config{
|
|
||||||
AppID: "<APPID>",
|
|
||||||
AppSecret: "<APPSECRET>",
|
|
||||||
SSOURL: "https://sso.digitalenergy.online",
|
|
||||||
DecortURL: "https://mr4.digitalenergy.online",
|
|
||||||
Retries: 5,
|
|
||||||
}
|
|
||||||
|
|
||||||
// Создание клиента
|
|
||||||
client := decort.New(cfg)
|
|
||||||
|
|
||||||
// 1. Создание структуры запроса GetRequest на создание аккаунта и выполнение GetRaw запроса с помощью конвейера
|
|
||||||
req1 := account.GetRequest{
|
|
||||||
AccountID: 123,
|
|
||||||
}
|
|
||||||
res1, err := client.CloudAPI().Account().GetRaw(context.Background(), req1)
|
|
||||||
if err != nil {
|
|
||||||
log.Fatal(err)
|
|
||||||
}
|
|
||||||
fmt.Println(string(res1))
|
|
||||||
|
|
||||||
// 2. Создание структуры запроса ListRequest на получение аккаунтов и выполнение ListRaw запроса с помощью конвейера
|
|
||||||
req2 := account.ListRequest{}
|
|
||||||
res2, err := client.CloudAPI().Account().ListRaw(context.Background(), req2)
|
|
||||||
if err != nil {
|
|
||||||
log.Fatal(err)
|
|
||||||
}
|
|
||||||
fmt.Println(string(res2))
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
### Фильтрация
|
### Фильтрация
|
||||||
|
|
||||||
Для каждого `ListRequest` в SDK есть группа функций для фильтрации ответа платформы. Для того чтобы произвести фильтрацию по заданным полям, достаточно описать анонимную функцию (предикат) в `.FilterFunc()`, например:
|
Для каждого `ListRequest` в SDK есть группа функций для фильтрации ответа платформы. Для того чтобы произвести фильтрацию по заданным полям, достаточно описать анонимную функцию (предикат) в `.FilterFunc()`, например:
|
||||||
|
|||||||
331
client.go
331
client.go
@@ -7,17 +7,14 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"mime/multipart"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi"
|
||||||
k8s_ca "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/k8s"
|
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker"
|
||||||
k8s_cb"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/k8s"
|
|
||||||
"github.com/google/go-querystring/query"
|
"github.com/google/go-querystring/query"
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/config"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/config"
|
||||||
)
|
)
|
||||||
@@ -71,283 +68,6 @@ func (dc *DecortClient) CloudBroker() *cloudbroker.CloudBroker {
|
|||||||
|
|
||||||
// DecortApiCall method for sending requests to the platform
|
// DecortApiCall method for sending requests to the platform
|
||||||
func (dc *DecortClient) DecortApiCall(ctx context.Context, method, url string, params interface{}) ([]byte, error) {
|
func (dc *DecortClient) DecortApiCall(ctx context.Context, method, url string, params interface{}) ([]byte, error) {
|
||||||
k8sCaCreateReq, okCa := params.(k8s_ca.CreateRequest)
|
|
||||||
k8sCbCreateReq, okCb := params.(k8s_cb.CreateRequest)
|
|
||||||
|
|
||||||
if okCa {
|
|
||||||
reqBody := &bytes.Buffer{}
|
|
||||||
writer := multipart.NewWriter(reqBody)
|
|
||||||
if k8sCaCreateReq.OidcCertificate != "" {
|
|
||||||
part, _ := writer.CreateFormFile("oidcCertificate", "ca.crt")
|
|
||||||
_, _ = io.Copy(part, strings.NewReader(k8sCaCreateReq.OidcCertificate))
|
|
||||||
}
|
|
||||||
|
|
||||||
_ = writer.WriteField("name", k8sCaCreateReq.Name)
|
|
||||||
_ = writer.WriteField("rgId", strconv.FormatUint(k8sCaCreateReq.RGID, 10))
|
|
||||||
_ = writer.WriteField("k8ciId", strconv.FormatUint(k8sCaCreateReq.K8SCIID, 10))
|
|
||||||
_ = writer.WriteField("workerGroupName", k8sCaCreateReq.WorkerGroupName)
|
|
||||||
_ = writer.WriteField("networkPlugin", k8sCaCreateReq.NetworkPlugin)
|
|
||||||
|
|
||||||
if k8sCaCreateReq.MasterSEPID != 0 {
|
|
||||||
_ = writer.WriteField("masterSepId", strconv.FormatUint(k8sCaCreateReq.MasterSEPID, 10))
|
|
||||||
}
|
|
||||||
if k8sCaCreateReq.MasterSEPPool != "" {
|
|
||||||
_ = writer.WriteField("masterSepPool", k8sCaCreateReq.MasterSEPPool)
|
|
||||||
}
|
|
||||||
if k8sCaCreateReq.WorkerSEPID != 0 {
|
|
||||||
_ = writer.WriteField("workerSepId", strconv.FormatUint(k8sCaCreateReq.WorkerSEPID, 10))
|
|
||||||
}
|
|
||||||
if k8sCaCreateReq.WorkerSEPPool != "" {
|
|
||||||
_ = writer.WriteField("workerSepPool", k8sCaCreateReq.WorkerSEPPool)
|
|
||||||
}
|
|
||||||
|
|
||||||
if k8sCaCreateReq.Labels != nil {
|
|
||||||
for _, v := range k8sCaCreateReq.Labels {
|
|
||||||
_ = writer.WriteField("labels", v)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if k8sCaCreateReq.Taints != nil {
|
|
||||||
for _, v := range k8sCaCreateReq.Taints {
|
|
||||||
_ = writer.WriteField("taints", v)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if k8sCaCreateReq.Annotations != nil {
|
|
||||||
for _, v := range k8sCaCreateReq.Annotations {
|
|
||||||
_ = writer.WriteField("annotations", v)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if k8sCaCreateReq.MasterCPU != 0 {
|
|
||||||
_ = writer.WriteField("masterCpu", strconv.FormatUint(uint64(k8sCaCreateReq.MasterCPU), 10))
|
|
||||||
}
|
|
||||||
if k8sCaCreateReq.MasterNum != 0 {
|
|
||||||
_ = writer.WriteField("masterNum", strconv.FormatUint(uint64(k8sCaCreateReq.MasterNum), 10))
|
|
||||||
}
|
|
||||||
if k8sCaCreateReq.MasterRAM != 0 {
|
|
||||||
_ = writer.WriteField("masterRam", strconv.FormatUint(uint64(k8sCaCreateReq.MasterRAM), 10))
|
|
||||||
}
|
|
||||||
if k8sCaCreateReq.MasterDisk != 0 {
|
|
||||||
_ = writer.WriteField("masterDisk", strconv.FormatUint(uint64(k8sCaCreateReq.MasterDisk), 10))
|
|
||||||
}
|
|
||||||
if k8sCaCreateReq.WorkerCPU != 0 {
|
|
||||||
_ = writer.WriteField("workerCpu", strconv.FormatUint(uint64(k8sCaCreateReq.WorkerCPU), 10))
|
|
||||||
}
|
|
||||||
if k8sCaCreateReq.WorkerNum != 0 {
|
|
||||||
_ = writer.WriteField("workerNum", strconv.FormatUint(uint64(k8sCaCreateReq.WorkerNum), 10))
|
|
||||||
}
|
|
||||||
if k8sCaCreateReq.WorkerRAM != 0 {
|
|
||||||
_ = writer.WriteField("workerRam", strconv.FormatUint(uint64(k8sCaCreateReq.WorkerRAM), 10))
|
|
||||||
}
|
|
||||||
if k8sCaCreateReq.WorkerDisk != 0 {
|
|
||||||
_ = writer.WriteField("workerDisk", strconv.FormatUint(uint64(k8sCaCreateReq.WorkerDisk), 10))
|
|
||||||
}
|
|
||||||
if k8sCaCreateReq.ExtNetID != 0 {
|
|
||||||
_ = writer.WriteField("extnetId", strconv.FormatUint(k8sCaCreateReq.ExtNetID, 10))
|
|
||||||
}
|
|
||||||
if k8sCaCreateReq.VinsId != 0 {
|
|
||||||
_ = writer.WriteField("vinsId", strconv.FormatUint(k8sCaCreateReq.VinsId, 10))
|
|
||||||
}
|
|
||||||
if !k8sCaCreateReq.WithLB {
|
|
||||||
_ = writer.WriteField("withLB", strconv.FormatBool(k8sCaCreateReq.WithLB))
|
|
||||||
}
|
|
||||||
|
|
||||||
_ = writer.WriteField("highlyAvailableLB", strconv.FormatBool(k8sCaCreateReq.HighlyAvailable))
|
|
||||||
|
|
||||||
if k8sCaCreateReq.AdditionalSANs != nil {
|
|
||||||
for _, v := range k8sCaCreateReq.AdditionalSANs {
|
|
||||||
_ = writer.WriteField("additionalSANs", v)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if k8sCaCreateReq.InitConfiguration != "" {
|
|
||||||
_ = writer.WriteField("initConfiguration", k8sCaCreateReq.InitConfiguration)
|
|
||||||
}
|
|
||||||
if k8sCaCreateReq.ClusterConfiguration != "" {
|
|
||||||
_ = writer.WriteField("clusterConfiguration", k8sCaCreateReq.ClusterConfiguration)
|
|
||||||
}
|
|
||||||
if k8sCaCreateReq.KubeletConfiguration != "" {
|
|
||||||
_ = writer.WriteField("kubeletConfiguration", k8sCaCreateReq.KubeletConfiguration)
|
|
||||||
}
|
|
||||||
if k8sCaCreateReq.KubeProxyConfiguration != "" {
|
|
||||||
_ = writer.WriteField("kubeProxyConfiguration", k8sCaCreateReq.KubeProxyConfiguration)
|
|
||||||
}
|
|
||||||
if k8sCaCreateReq.JoinConfiguration != "" {
|
|
||||||
_ = writer.WriteField("joinConfiguration", k8sCaCreateReq.JoinConfiguration)
|
|
||||||
}
|
|
||||||
if k8sCaCreateReq.Description != "" {
|
|
||||||
_ = writer.WriteField("desc", k8sCaCreateReq.Description)
|
|
||||||
}
|
|
||||||
if k8sCaCreateReq.UserData != "" {
|
|
||||||
_ = writer.WriteField("userData", k8sCaCreateReq.UserData)
|
|
||||||
}
|
|
||||||
|
|
||||||
_ = writer.WriteField("extnetOnly", strconv.FormatBool(k8sCaCreateReq.ExtNetOnly))
|
|
||||||
_ = writer.FormDataContentType()
|
|
||||||
|
|
||||||
ct := writer.FormDataContentType()
|
|
||||||
|
|
||||||
writer.Close()
|
|
||||||
req, err := http.NewRequestWithContext(ctx, method, dc.decortURL+"/restmachine"+url, reqBody)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
if err = dc.getToken(ctx); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
resp, err := dc.domp(req, ct)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
defer resp.Body.Close()
|
|
||||||
|
|
||||||
respBytes, err := io.ReadAll(resp.Body)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
if resp.StatusCode != 200 {
|
|
||||||
return nil, errors.New(string(respBytes))
|
|
||||||
}
|
|
||||||
|
|
||||||
return respBytes, nil
|
|
||||||
} else if okCb {
|
|
||||||
reqBody := &bytes.Buffer{}
|
|
||||||
writer := multipart.NewWriter(reqBody)
|
|
||||||
if k8sCbCreateReq.OidcCertificate != "" {
|
|
||||||
part, _ := writer.CreateFormFile("oidcCertificate", "ca.crt")
|
|
||||||
_, _ = io.Copy(part, strings.NewReader(k8sCbCreateReq.OidcCertificate))
|
|
||||||
}
|
|
||||||
|
|
||||||
_ = writer.WriteField("name", k8sCbCreateReq.Name)
|
|
||||||
_ = writer.WriteField("rgId", strconv.FormatUint(k8sCbCreateReq.RGID, 10))
|
|
||||||
_ = writer.WriteField("k8ciId", strconv.FormatUint(k8sCbCreateReq.K8CIID, 10))
|
|
||||||
_ = writer.WriteField("workerGroupName", k8sCbCreateReq.WorkerGroupName)
|
|
||||||
_ = writer.WriteField("networkPlugin", k8sCbCreateReq.NetworkPlugin)
|
|
||||||
|
|
||||||
if k8sCbCreateReq.MasterSEPID != 0 {
|
|
||||||
_ = writer.WriteField("masterSepId", strconv.FormatUint(k8sCbCreateReq.MasterSEPID, 10))
|
|
||||||
}
|
|
||||||
if k8sCbCreateReq.MasterSEPPool != "" {
|
|
||||||
_ = writer.WriteField("masterSepPool", k8sCbCreateReq.MasterSEPPool)
|
|
||||||
}
|
|
||||||
if k8sCbCreateReq.WorkerSEPID != 0 {
|
|
||||||
_ = writer.WriteField("workerSepId", strconv.FormatUint(k8sCbCreateReq.WorkerSEPID, 10))
|
|
||||||
}
|
|
||||||
if k8sCbCreateReq.WorkerSEPPool != "" {
|
|
||||||
_ = writer.WriteField("workerSepPool", k8sCbCreateReq.WorkerSEPPool)
|
|
||||||
}
|
|
||||||
|
|
||||||
if k8sCbCreateReq.Labels != nil {
|
|
||||||
for _, v := range k8sCbCreateReq.Labels {
|
|
||||||
_ = writer.WriteField("labels", v)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if k8sCbCreateReq.Taints != nil {
|
|
||||||
for _, v := range k8sCbCreateReq.Taints {
|
|
||||||
_ = writer.WriteField("taints", v)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if k8sCbCreateReq.Annotations != nil {
|
|
||||||
for _, v := range k8sCbCreateReq.Annotations {
|
|
||||||
_ = writer.WriteField("annotations", v)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if k8sCbCreateReq.MasterCPU != 0 {
|
|
||||||
_ = writer.WriteField("masterCpu", strconv.FormatUint(k8sCbCreateReq.MasterCPU, 10))
|
|
||||||
}
|
|
||||||
if k8sCbCreateReq.MasterNum != 0 {
|
|
||||||
_ = writer.WriteField("masterNum", strconv.FormatUint(k8sCbCreateReq.MasterNum, 10))
|
|
||||||
}
|
|
||||||
if k8sCbCreateReq.MasterRAM != 0 {
|
|
||||||
_ = writer.WriteField("masterRam", strconv.FormatUint(k8sCbCreateReq.MasterRAM, 10))
|
|
||||||
}
|
|
||||||
if k8sCbCreateReq.MasterDisk != 0 {
|
|
||||||
_ = writer.WriteField("masterDisk", strconv.FormatUint(k8sCbCreateReq.MasterDisk, 10))
|
|
||||||
}
|
|
||||||
if k8sCbCreateReq.WorkerCPU != 0 {
|
|
||||||
_ = writer.WriteField("workerCpu", strconv.FormatUint(k8sCbCreateReq.WorkerCPU, 10))
|
|
||||||
}
|
|
||||||
if k8sCbCreateReq.WorkerNum != 0 {
|
|
||||||
_ = writer.WriteField("workerNum", strconv.FormatUint(k8sCbCreateReq.WorkerNum, 10))
|
|
||||||
}
|
|
||||||
if k8sCbCreateReq.WorkerRAM != 0 {
|
|
||||||
_ = writer.WriteField("workerRam", strconv.FormatUint(k8sCbCreateReq.WorkerRAM, 10))
|
|
||||||
}
|
|
||||||
if k8sCbCreateReq.WorkerDisk != 0 {
|
|
||||||
_ = writer.WriteField("workerDisk", strconv.FormatUint(k8sCbCreateReq.WorkerDisk, 10))
|
|
||||||
}
|
|
||||||
if k8sCbCreateReq.ExtNetID != 0 {
|
|
||||||
_ = writer.WriteField("extnetId", strconv.FormatUint(k8sCbCreateReq.ExtNetID, 10))
|
|
||||||
}
|
|
||||||
if k8sCbCreateReq.VinsId != 0 {
|
|
||||||
_ = writer.WriteField("vinsId", strconv.FormatUint(k8sCbCreateReq.VinsId, 10))
|
|
||||||
}
|
|
||||||
if !k8sCbCreateReq.WithLB {
|
|
||||||
_ = writer.WriteField("withLB", strconv.FormatBool(k8sCbCreateReq.WithLB))
|
|
||||||
}
|
|
||||||
|
|
||||||
_ = writer.WriteField("highlyAvailableLB", strconv.FormatBool(k8sCbCreateReq.HighlyAvailable))
|
|
||||||
|
|
||||||
if k8sCbCreateReq.AdditionalSANs != nil {
|
|
||||||
for _, v := range k8sCbCreateReq.AdditionalSANs {
|
|
||||||
_ = writer.WriteField("additionalSANs", v)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if k8sCbCreateReq.InitConfiguration != "" {
|
|
||||||
_ = writer.WriteField("initConfiguration", k8sCbCreateReq.InitConfiguration)
|
|
||||||
}
|
|
||||||
if k8sCbCreateReq.ClusterConfiguration != "" {
|
|
||||||
_ = writer.WriteField("clusterConfiguration", k8sCbCreateReq.ClusterConfiguration)
|
|
||||||
}
|
|
||||||
if k8sCbCreateReq.KubeletConfiguration != "" {
|
|
||||||
_ = writer.WriteField("kubeletConfiguration", k8sCbCreateReq.KubeletConfiguration)
|
|
||||||
}
|
|
||||||
if k8sCbCreateReq.KubeProxyConfiguration != "" {
|
|
||||||
_ = writer.WriteField("kubeProxyConfiguration", k8sCbCreateReq.KubeProxyConfiguration)
|
|
||||||
}
|
|
||||||
if k8sCbCreateReq.JoinConfiguration != "" {
|
|
||||||
_ = writer.WriteField("joinConfiguration", k8sCbCreateReq.JoinConfiguration)
|
|
||||||
}
|
|
||||||
if k8sCbCreateReq.Description != "" {
|
|
||||||
_ = writer.WriteField("desc", k8sCbCreateReq.Description)
|
|
||||||
}
|
|
||||||
if k8sCbCreateReq.UserData != "" {
|
|
||||||
_ = writer.WriteField("userData", k8sCbCreateReq.UserData)
|
|
||||||
}
|
|
||||||
|
|
||||||
_ = writer.WriteField("extnetOnly", strconv.FormatBool(k8sCbCreateReq.ExtNetOnly))
|
|
||||||
_ = writer.FormDataContentType()
|
|
||||||
|
|
||||||
ct := writer.FormDataContentType()
|
|
||||||
|
|
||||||
writer.Close()
|
|
||||||
req, err := http.NewRequestWithContext(ctx, method, dc.decortURL+"/restmachine"+url, reqBody)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
if err = dc.getToken(ctx); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
resp, err := dc.domp(req, ct)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
defer resp.Body.Close()
|
|
||||||
|
|
||||||
respBytes, err := io.ReadAll(resp.Body)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
if resp.StatusCode != 200 {
|
|
||||||
return nil, errors.New(string(respBytes))
|
|
||||||
}
|
|
||||||
|
|
||||||
return respBytes, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
values, err := query.Values(params)
|
values, err := query.Values(params)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -423,47 +143,20 @@ func (dc *DecortClient) do(req *http.Request) (*http.Response, error) {
|
|||||||
// var resp *http.Response
|
// var resp *http.Response
|
||||||
// var err error
|
// var err error
|
||||||
buf, _ := io.ReadAll(req.Body)
|
buf, _ := io.ReadAll(req.Body)
|
||||||
// req = req.Clone(req.Context())
|
|
||||||
|
|
||||||
// for i := uint64(0); i < dc.cfg.Retries; i++ {
|
// for i := uint64(0); i < dc.cfg.Retries; i++ {
|
||||||
req.Body = io.NopCloser(bytes.NewBuffer(buf))
|
// req = req.Clone(req.Context())
|
||||||
resp, err := dc.client.Do(req)
|
req.Body = io.NopCloser(bytes.NewBuffer(buf))
|
||||||
|
resp, err := dc.client.Do(req)
|
||||||
|
|
||||||
// if err == nil {
|
// if err == nil {
|
||||||
if resp.StatusCode == 200 {
|
if resp.StatusCode == 200 {
|
||||||
return resp, err
|
return resp, err
|
||||||
}
|
}
|
||||||
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)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (dc *DecortClient) domp(req *http.Request, ctype string) (*http.Response, error) {
|
|
||||||
req.Header.Add("Content-Type", ctype)
|
|
||||||
req.Header.Add("Authorization", "bearer "+dc.cfg.Token)
|
|
||||||
req.Header.Set("Accept", "application/json")
|
|
||||||
|
|
||||||
// var resp *http.Response
|
|
||||||
// var err error
|
|
||||||
buf, _ := io.ReadAll(req.Body)
|
|
||||||
// req = req.Clone(req.Context())
|
|
||||||
|
|
||||||
// for i := uint64(0); i < dc.cfg.Retries; i++ {
|
|
||||||
req.Body = io.NopCloser(bytes.NewBuffer(buf))
|
|
||||||
resp, err := dc.client.Do(req)
|
|
||||||
|
|
||||||
// if err == nil {
|
|
||||||
if resp.StatusCode == 200 {
|
|
||||||
return resp, err
|
|
||||||
}
|
|
||||||
respBytes, _ := io.ReadAll(resp.Body)
|
|
||||||
err = fmt.Errorf("%s", respBytes)
|
|
||||||
resp.Body.Close()
|
|
||||||
// }
|
|
||||||
// }
|
// }
|
||||||
|
|
||||||
return nil, fmt.Errorf("could not execute request: %w", err)
|
return nil, fmt.Errorf("could not execute request: %w", err)
|
||||||
|
|||||||
@@ -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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
195
legacy-client.go
195
legacy-client.go
@@ -7,10 +7,8 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"mime/multipart"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
"strconv"
|
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
@@ -18,7 +16,6 @@ import (
|
|||||||
"github.com/google/go-querystring/query"
|
"github.com/google/go-querystring/query"
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/config"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/config"
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi"
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/k8s"
|
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -71,148 +68,6 @@ func (ldc *LegacyDecortClient) CloudBroker() *cloudbroker.CloudBroker {
|
|||||||
|
|
||||||
// DecortApiCall method for sending requests to the platform
|
// DecortApiCall method for sending requests to the platform
|
||||||
func (ldc *LegacyDecortClient) DecortApiCall(ctx context.Context, method, url string, params interface{}) ([]byte, error) {
|
func (ldc *LegacyDecortClient) DecortApiCall(ctx context.Context, method, url string, params interface{}) ([]byte, error) {
|
||||||
if k8sCreateReq, ok := params.(k8s.CreateRequest); ok {
|
|
||||||
reqBody := &bytes.Buffer{}
|
|
||||||
writer := multipart.NewWriter(reqBody)
|
|
||||||
if k8sCreateReq.OidcCertificate != "" {
|
|
||||||
part, _ := writer.CreateFormFile("oidcCertificate", "ca.crt")
|
|
||||||
_, _ = io.Copy(part, strings.NewReader(k8sCreateReq.OidcCertificate))
|
|
||||||
}
|
|
||||||
|
|
||||||
_ = writer.WriteField("name", k8sCreateReq.Name)
|
|
||||||
_ = writer.WriteField("rgId", strconv.FormatUint(k8sCreateReq.RGID, 10))
|
|
||||||
_ = writer.WriteField("k8ciId", strconv.FormatUint(k8sCreateReq.K8SCIID, 10))
|
|
||||||
_ = writer.WriteField("workerGroupName", k8sCreateReq.WorkerGroupName)
|
|
||||||
_ = writer.WriteField("networkPlugin", k8sCreateReq.NetworkPlugin)
|
|
||||||
|
|
||||||
if k8sCreateReq.MasterSEPID != 0 {
|
|
||||||
_ = writer.WriteField("masterSepId", strconv.FormatUint(k8sCreateReq.MasterSEPID, 10))
|
|
||||||
}
|
|
||||||
if k8sCreateReq.MasterSEPPool != "" {
|
|
||||||
_ = writer.WriteField("masterSepPool", k8sCreateReq.MasterSEPPool)
|
|
||||||
}
|
|
||||||
if k8sCreateReq.WorkerSEPID != 0 {
|
|
||||||
_ = writer.WriteField("workerSepId", strconv.FormatUint(k8sCreateReq.WorkerSEPID, 10))
|
|
||||||
}
|
|
||||||
if k8sCreateReq.WorkerSEPPool != "" {
|
|
||||||
_ = writer.WriteField("workerSepPool", k8sCreateReq.WorkerSEPPool)
|
|
||||||
}
|
|
||||||
|
|
||||||
if k8sCreateReq.Labels != nil {
|
|
||||||
for _, v := range k8sCreateReq.Labels {
|
|
||||||
_ = writer.WriteField("labels", v)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if k8sCreateReq.Taints != nil {
|
|
||||||
for _, v := range k8sCreateReq.Taints {
|
|
||||||
_ = writer.WriteField("taints", v)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if k8sCreateReq.Annotations != nil {
|
|
||||||
for _, v := range k8sCreateReq.Annotations {
|
|
||||||
_ = writer.WriteField("annotations", v)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if k8sCreateReq.MasterCPU != 0 {
|
|
||||||
_ = writer.WriteField("masterCpu", strconv.FormatUint(uint64(k8sCreateReq.MasterCPU), 10))
|
|
||||||
}
|
|
||||||
if k8sCreateReq.MasterNum != 0 {
|
|
||||||
_ = writer.WriteField("masterNum", strconv.FormatUint(uint64(k8sCreateReq.MasterNum), 10))
|
|
||||||
}
|
|
||||||
if k8sCreateReq.MasterRAM != 0 {
|
|
||||||
_ = writer.WriteField("masterRam", strconv.FormatUint(uint64(k8sCreateReq.MasterRAM), 10))
|
|
||||||
}
|
|
||||||
if k8sCreateReq.MasterDisk != 0 {
|
|
||||||
_ = writer.WriteField("masterDisk", strconv.FormatUint(uint64(k8sCreateReq.MasterDisk), 10))
|
|
||||||
}
|
|
||||||
if k8sCreateReq.WorkerCPU != 0 {
|
|
||||||
_ = writer.WriteField("workerCpu", strconv.FormatUint(uint64(k8sCreateReq.WorkerCPU), 10))
|
|
||||||
}
|
|
||||||
if k8sCreateReq.WorkerNum != 0 {
|
|
||||||
_ = writer.WriteField("workerNum", strconv.FormatUint(uint64(k8sCreateReq.WorkerNum), 10))
|
|
||||||
}
|
|
||||||
if k8sCreateReq.WorkerRAM != 0 {
|
|
||||||
_ = writer.WriteField("workerRam", strconv.FormatUint(uint64(k8sCreateReq.WorkerRAM), 10))
|
|
||||||
}
|
|
||||||
if k8sCreateReq.WorkerDisk != 0 {
|
|
||||||
_ = writer.WriteField("workerDisk", strconv.FormatUint(uint64(k8sCreateReq.WorkerDisk), 10))
|
|
||||||
}
|
|
||||||
if k8sCreateReq.ExtNetID != 0 {
|
|
||||||
_ = writer.WriteField("extnetId", strconv.FormatUint(k8sCreateReq.ExtNetID, 10))
|
|
||||||
}
|
|
||||||
if k8sCreateReq.VinsId != 0 {
|
|
||||||
_ = writer.WriteField("vinsId", strconv.FormatUint(k8sCreateReq.VinsId, 10))
|
|
||||||
}
|
|
||||||
if !k8sCreateReq.WithLB {
|
|
||||||
_ = writer.WriteField("withLB", strconv.FormatBool(k8sCreateReq.WithLB))
|
|
||||||
}
|
|
||||||
|
|
||||||
_ = writer.WriteField("highlyAvailableLB", strconv.FormatBool(k8sCreateReq.HighlyAvailable))
|
|
||||||
|
|
||||||
if k8sCreateReq.AdditionalSANs != nil {
|
|
||||||
for _, v := range k8sCreateReq.AdditionalSANs {
|
|
||||||
_ = writer.WriteField("additionalSANs", v)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if k8sCreateReq.InitConfiguration != "" {
|
|
||||||
_ = writer.WriteField("initConfiguration", k8sCreateReq.InitConfiguration)
|
|
||||||
}
|
|
||||||
if k8sCreateReq.ClusterConfiguration != "" {
|
|
||||||
_ = writer.WriteField("clusterConfiguration", k8sCreateReq.ClusterConfiguration)
|
|
||||||
}
|
|
||||||
if k8sCreateReq.KubeletConfiguration != "" {
|
|
||||||
_ = writer.WriteField("kubeletConfiguration", k8sCreateReq.KubeletConfiguration)
|
|
||||||
}
|
|
||||||
if k8sCreateReq.KubeProxyConfiguration != "" {
|
|
||||||
_ = writer.WriteField("kubeProxyConfiguration", k8sCreateReq.KubeProxyConfiguration)
|
|
||||||
}
|
|
||||||
if k8sCreateReq.JoinConfiguration != "" {
|
|
||||||
_ = writer.WriteField("joinConfiguration", k8sCreateReq.JoinConfiguration)
|
|
||||||
}
|
|
||||||
if k8sCreateReq.Description != "" {
|
|
||||||
_ = writer.WriteField("desc", k8sCreateReq.Description)
|
|
||||||
}
|
|
||||||
if k8sCreateReq.UserData != "" {
|
|
||||||
_ = writer.WriteField("userData", k8sCreateReq.UserData)
|
|
||||||
}
|
|
||||||
|
|
||||||
_ = writer.WriteField("extnetOnly", strconv.FormatBool(k8sCreateReq.ExtNetOnly))
|
|
||||||
_ = writer.FormDataContentType()
|
|
||||||
|
|
||||||
ct := writer.FormDataContentType()
|
|
||||||
|
|
||||||
if err := ldc.getToken(ctx); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
_ = writer.WriteField("authkey", ldc.cfg.Token)
|
|
||||||
|
|
||||||
writer.Close()
|
|
||||||
|
|
||||||
req, err := http.NewRequestWithContext(ctx, method, ldc.decortURL+"/restmachine"+url, reqBody)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
resp, err := ldc.domp(req, ct)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
defer resp.Body.Close()
|
|
||||||
|
|
||||||
respBytes, err := io.ReadAll(resp.Body)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
if resp.StatusCode != 200 {
|
|
||||||
return nil, errors.New(string(respBytes))
|
|
||||||
}
|
|
||||||
|
|
||||||
return respBytes, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
values, err := query.Values(params)
|
values, err := query.Values(params)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -285,48 +140,20 @@ func (ldc *LegacyDecortClient) do(req *http.Request) (*http.Response, error) {
|
|||||||
// var resp *http.Response
|
// var resp *http.Response
|
||||||
// var err error
|
// var err error
|
||||||
buf, _ := io.ReadAll(req.Body)
|
buf, _ := io.ReadAll(req.Body)
|
||||||
// req = req.Clone(req.Context())
|
|
||||||
|
|
||||||
// for i := uint64(0); i < ldc.cfg.Retries; i++ {
|
// for i := uint64(0); i < ldc.cfg.Retries; i++ {
|
||||||
|
// req = req.Clone(req.Context())
|
||||||
|
req.Body = io.NopCloser(bytes.NewBuffer(buf))
|
||||||
|
resp, err := ldc.client.Do(req)
|
||||||
|
|
||||||
req.Body = io.NopCloser(bytes.NewBuffer(buf))
|
// if err == nil {
|
||||||
resp, err := ldc.client.Do(req)
|
if resp.StatusCode == 200 {
|
||||||
|
return resp, err
|
||||||
// if err == nil {
|
}
|
||||||
if resp.StatusCode == 200 {
|
respBytes, _ := io.ReadAll(resp.Body)
|
||||||
return resp, err
|
err = fmt.Errorf("%s", respBytes)
|
||||||
}
|
resp.Body.Close()
|
||||||
respBytes, _ := io.ReadAll(resp.Body)
|
// }
|
||||||
err = fmt.Errorf("%s", respBytes)
|
|
||||||
resp.Body.Close()
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
return nil, fmt.Errorf("could not execute request: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (ldc *LegacyDecortClient) domp(req *http.Request, ctype string) (*http.Response, error) {
|
|
||||||
req.Header.Add("Content-Type", ctype)
|
|
||||||
req.Header.Add("Authorization", "bearer "+ldc.cfg.Token)
|
|
||||||
req.Header.Set("Accept", "application/json")
|
|
||||||
|
|
||||||
// var resp *http.Response
|
|
||||||
// var err error
|
|
||||||
buf, _ := io.ReadAll(req.Body)
|
|
||||||
// req = req.Clone(req.Context())
|
|
||||||
|
|
||||||
// for i := uint64(0); i < ldc.cfg.Retries; i++ {
|
|
||||||
req.Body = io.NopCloser(bytes.NewBuffer(buf))
|
|
||||||
resp, err := ldc.client.Do(req)
|
|
||||||
|
|
||||||
// if err == nil {
|
|
||||||
if resp.StatusCode == 200 {
|
|
||||||
return resp, err
|
|
||||||
}
|
|
||||||
respBytes, _ := io.ReadAll(resp.Body)
|
|
||||||
err = fmt.Errorf("%s", respBytes)
|
|
||||||
resp.Body.Close()
|
|
||||||
// }
|
|
||||||
// }
|
// }
|
||||||
|
|
||||||
return nil, fmt.Errorf("could not execute request: %w", err)
|
return nil, fmt.Errorf("could not execute request: %w", err)
|
||||||
|
|||||||
@@ -8,16 +8,25 @@ import (
|
|||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
)
|
)
|
||||||
|
|
||||||
// GetRequest struct to get information about account
|
// Request struct for get information about account
|
||||||
type GetRequest struct {
|
type GetRequest struct {
|
||||||
// ID an account
|
// ID an account
|
||||||
// Required: true
|
// Required: true
|
||||||
AccountID uint64 `url:"accountId" json:"accountId" validate:"required"`
|
AccountID uint64 `url:"accountId" json:"accountId" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get gets account details as a RecordAccount struct
|
// Get gets account details
|
||||||
func (a Account) Get(ctx context.Context, req GetRequest) (*RecordAccount, error) {
|
func (a Account) Get(ctx context.Context, req GetRequest) (*RecordAccount, error) {
|
||||||
res, err := a.GetRaw(ctx, req)
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
for _, validationError := range validators.GetErrors(err) {
|
||||||
|
return nil, validators.ValidationError(validationError)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudapi/account/get"
|
||||||
|
|
||||||
|
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -32,18 +41,3 @@ func (a Account) Get(ctx context.Context, req GetRequest) (*RecordAccount, error
|
|||||||
return &info, nil
|
return &info, nil
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetRaw gets account details as an array of bytes
|
|
||||||
func (a Account) GetRaw(ctx context.Context, req GetRequest) ([]byte, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
for _, validationError := range validators.GetErrors(err) {
|
|
||||||
return nil, validators.ValidationError(validationError)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/account/get"
|
|
||||||
|
|
||||||
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
|
||||||
return res, err
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ListRequest struct to get list of accounts
|
// Request struct for get list of accounts
|
||||||
type ListRequest struct {
|
type ListRequest struct {
|
||||||
// Find by ID
|
// Find by ID
|
||||||
// Required: false
|
// Required: false
|
||||||
@@ -33,9 +33,11 @@ type ListRequest struct {
|
|||||||
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// List gets a list of all accounts the user has access to a ListAccounts struct
|
// List gets list all accounts the user has access to
|
||||||
func (a Account) List(ctx context.Context, req ListRequest) (*ListAccounts, error) {
|
func (a Account) List(ctx context.Context, req ListRequest) (*ListAccounts, error) {
|
||||||
res, err := a.ListRaw(ctx, req)
|
url := "/cloudapi/account/list"
|
||||||
|
|
||||||
|
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -49,11 +51,3 @@ func (a Account) List(ctx context.Context, req ListRequest) (*ListAccounts, erro
|
|||||||
|
|
||||||
return &list, nil
|
return &list, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// ListRaw gets a list of all accounts the user has access to as an array of bytes
|
|
||||||
func (a Account) ListRaw(ctx context.Context, req ListRequest) ([]byte, error) {
|
|
||||||
url := "/cloudapi/account/list"
|
|
||||||
|
|
||||||
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
|
||||||
return res, err
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ type Resource struct {
|
|||||||
DiskSize float64 `json:"disksize"`
|
DiskSize float64 `json:"disksize"`
|
||||||
|
|
||||||
// Max disk size
|
// Max disk size
|
||||||
DiskSizeMax float64 `json:"disksizemax"`
|
DiskSizeMax uint64 `json:"disksizemax"`
|
||||||
|
|
||||||
// Number of External IPs
|
// Number of External IPs
|
||||||
ExtIPs int64 `json:"extips"`
|
ExtIPs int64 `json:"extips"`
|
||||||
@@ -126,10 +126,10 @@ type RecordResourceConsumption struct {
|
|||||||
// Information about resources
|
// Information about resources
|
||||||
type ItemResourceConsumption struct {
|
type ItemResourceConsumption struct {
|
||||||
// Current information about resources
|
// Current information about resources
|
||||||
Consumed Resource `json:"consumed"`
|
Current Resource `json:"Current"`
|
||||||
|
|
||||||
// Reserved information about resources
|
// Reserved information about resources
|
||||||
Reserved Resource `json:"reserved"`
|
Reserved Resource `json:"Reserved"`
|
||||||
|
|
||||||
// Account ID
|
// Account ID
|
||||||
AccountID uint64 `json:"id"`
|
AccountID uint64 `json:"id"`
|
||||||
|
|||||||
@@ -8,32 +8,15 @@ import (
|
|||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
)
|
)
|
||||||
|
|
||||||
// GetRequest struct to get detailed information about service
|
// Request struct for get detailed information about service
|
||||||
type GetRequest struct {
|
type GetRequest struct {
|
||||||
// ID of the service to query information
|
// ID of the service to query information
|
||||||
// Required: true
|
// Required: true
|
||||||
ServiceID uint64 `url:"serviceId" json:"serviceId" validate:"required"`
|
ServiceID uint64 `url:"serviceId" json:"serviceId" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get gets detailed specifications for the BasicService as a RecordBasicService struct
|
// Get gets detailed specifications for the BasicService.
|
||||||
func (b BService) Get(ctx context.Context, req GetRequest) (*RecordBasicService, error) {
|
func (b BService) Get(ctx context.Context, req GetRequest) (*RecordBasicService, error) {
|
||||||
res, err := b.GetRaw(ctx, req)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
info := RecordBasicService{}
|
|
||||||
|
|
||||||
err = json.Unmarshal(res, &info)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return &info, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetRaw gets detailed specifications for the BasicService as an array of bytes
|
|
||||||
func (b BService) GetRaw(ctx context.Context, req GetRequest) ([]byte, 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) {
|
||||||
@@ -43,6 +26,17 @@ func (b BService) GetRaw(ctx context.Context, req GetRequest) ([]byte, error) {
|
|||||||
|
|
||||||
url := "/cloudapi/bservice/get"
|
url := "/cloudapi/bservice/get"
|
||||||
|
|
||||||
res, err := b.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
bsRaw, err := b.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
return res, err
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
info := RecordBasicService{}
|
||||||
|
|
||||||
|
err = json.Unmarshal(bsRaw, &info)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return &info, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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.
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ListRequest struct to get list of BasicService instances
|
// Request struct for get list BasicService instances
|
||||||
type ListRequest struct {
|
type ListRequest struct {
|
||||||
// Find by ID
|
// Find by ID
|
||||||
// Required: false
|
// Required: false
|
||||||
@@ -49,9 +49,11 @@ type ListRequest struct {
|
|||||||
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// List gets list of BasicService instances associated with the specified Resource Group as a ListBasicServices struct
|
// List gets list BasicService instances associated with the specified Resource Group
|
||||||
func (b BService) List(ctx context.Context, req ListRequest) (*ListBasicServices, error) {
|
func (b BService) List(ctx context.Context, req ListRequest) (*ListBasicServices, error) {
|
||||||
res, err := b.ListRaw(ctx, req)
|
url := "/cloudapi/bservice/list"
|
||||||
|
|
||||||
|
res, err := b.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -65,11 +67,3 @@ func (b BService) List(ctx context.Context, req ListRequest) (*ListBasicServices
|
|||||||
|
|
||||||
return &list, nil
|
return &list, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// ListRaw gets list of BasicService instances associated with the specified Resource Group as an array of bytes
|
|
||||||
func (b BService) ListRaw(ctx context.Context, req ListRequest) ([]byte, error) {
|
|
||||||
url := "/cloudapi/bservice/list"
|
|
||||||
|
|
||||||
res, err := b.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
|
||||||
return res, err
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -8,16 +8,25 @@ import (
|
|||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
)
|
)
|
||||||
|
|
||||||
// GetRequest struct to get information about compute
|
// Request for get information about compute
|
||||||
type GetRequest struct {
|
type GetRequest struct {
|
||||||
// ID of compute instance
|
// ID of compute instance
|
||||||
// Required: true
|
// Required: true
|
||||||
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
|
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get gets information about compute as a RecordCompute struct
|
// Get Gets information about compute
|
||||||
func (c Compute) Get(ctx context.Context, req GetRequest) (*RecordCompute, error) {
|
func (c Compute) Get(ctx context.Context, req GetRequest) (*RecordCompute, error) {
|
||||||
res, err := c.GetRaw(ctx, req)
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
for _, validationError := range validators.GetErrors(err) {
|
||||||
|
return nil, validators.ValidationError(validationError)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudapi/compute/get"
|
||||||
|
|
||||||
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -31,18 +40,3 @@ func (c Compute) Get(ctx context.Context, req GetRequest) (*RecordCompute, error
|
|||||||
|
|
||||||
return &info, nil
|
return &info, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetRaw gets information about compute as an array of bytes
|
|
||||||
func (c Compute) GetRaw(ctx context.Context, req GetRequest) ([]byte, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
for _, validationError := range validators.GetErrors(err) {
|
|
||||||
return nil, validators.ValidationError(validationError)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/get"
|
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
|
||||||
return res, err
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ListRequest struct to get list of available computes
|
// Request struct for get list available computes
|
||||||
type ListRequest struct {
|
type ListRequest struct {
|
||||||
// Find by ID
|
// Find by ID
|
||||||
// Required: false
|
// Required: false
|
||||||
@@ -64,7 +64,9 @@ type ListRequest struct {
|
|||||||
// List gets list of the available computes.
|
// List gets list of the available computes.
|
||||||
// Filtering based on status is possible
|
// Filtering based on status is possible
|
||||||
func (c Compute) List(ctx context.Context, req ListRequest) (*ListComputes, error) {
|
func (c Compute) List(ctx context.Context, req ListRequest) (*ListComputes, error) {
|
||||||
res, err := c.ListRaw(ctx, req)
|
url := "/cloudapi/compute/list"
|
||||||
|
|
||||||
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -78,11 +80,3 @@ func (c Compute) List(ctx context.Context, req ListRequest) (*ListComputes, erro
|
|||||||
|
|
||||||
return &list, nil
|
return &list, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// ListRaw gets list of the available computes.
|
|
||||||
func (c Compute) ListRaw(ctx context.Context, req ListRequest) ([]byte, error) {
|
|
||||||
url := "/cloudapi/compute/list"
|
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
|
||||||
return res, err
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -22,9 +22,9 @@ type ListPCIDeviceRequest struct {
|
|||||||
// Required: false
|
// Required: false
|
||||||
DevID uint64 `url:"devId,omitempty" json:"devId,omitempty"`
|
DevID uint64 `url:"devId,omitempty" json:"devId,omitempty"`
|
||||||
|
|
||||||
// Find by name
|
// Find by type
|
||||||
// Required: false
|
// Required: false
|
||||||
Name string `url:"name,omitempty" json:"name,omitempty"`
|
Type string `url:"type,omitempty" json:"type,omitempty"`
|
||||||
|
|
||||||
// Find by status
|
// Find by status
|
||||||
// Required: false
|
// Required: false
|
||||||
|
|||||||
@@ -8,17 +8,26 @@ import (
|
|||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
)
|
)
|
||||||
|
|
||||||
// GetRequest struct to get information about disk
|
// Request struct for get information about disk
|
||||||
type GetRequest struct {
|
type GetRequest struct {
|
||||||
// ID of the disk
|
// ID of the disk
|
||||||
// Required: true
|
// Required: true
|
||||||
DiskID uint64 `url:"diskId" json:"diskId" validate:"required"`
|
DiskID uint64 `url:"diskId" json:"diskId" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get gets disk details as a RecordDisk struct
|
// Get gets disk details
|
||||||
// Notice: the devicename field is the name as it is passed to the kernel (kname in linux) for unattached disks this field has no relevant value
|
// Notice: the devicename field is the name as it is passed to the kernel (kname in linux) for unattached disks this field has no relevant value
|
||||||
func (d Disks) Get(ctx context.Context, req GetRequest) (*RecordDisk, error) {
|
func (d Disks) Get(ctx context.Context, req GetRequest) (*RecordDisk, error) {
|
||||||
res, err := d.GetRaw(ctx, req)
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
for _, validationError := range validators.GetErrors(err) {
|
||||||
|
return nil, validators.ValidationError(validationError)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudapi/disks/get"
|
||||||
|
|
||||||
|
res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -32,19 +41,3 @@ func (d Disks) Get(ctx context.Context, req GetRequest) (*RecordDisk, error) {
|
|||||||
|
|
||||||
return &info, nil
|
return &info, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetRaw gets disk details as an array of bytes
|
|
||||||
// Notice: the devicename field is the name as it is passed to the kernel (kname in linux) for unattached disks this field has no relevant value
|
|
||||||
func (d Disks) GetRaw(ctx context.Context, req GetRequest) ([]byte, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
for _, validationError := range validators.GetErrors(err) {
|
|
||||||
return nil, validators.ValidationError(validationError)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/disks/get"
|
|
||||||
|
|
||||||
res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
|
||||||
return res, err
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ListRequest struct to get list of disks
|
// Request struct for get list of disks
|
||||||
type ListRequest struct {
|
type ListRequest struct {
|
||||||
// Find by id
|
// Find by id
|
||||||
// Required: false
|
// Required: false
|
||||||
@@ -57,9 +57,11 @@ type ListRequest struct {
|
|||||||
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// List gets list of the created disks belonging to an account as a ListDisks struct
|
// List gets list the created disks belonging to an account
|
||||||
func (d Disks) List(ctx context.Context, req ListRequest) (*ListDisks, error) {
|
func (d Disks) List(ctx context.Context, req ListRequest) (*ListDisks, error) {
|
||||||
res, err := d.ListRaw(ctx, req)
|
url := "/cloudapi/disks/list"
|
||||||
|
|
||||||
|
res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -73,11 +75,3 @@ func (d Disks) List(ctx context.Context, req ListRequest) (*ListDisks, error) {
|
|||||||
|
|
||||||
return &list, nil
|
return &list, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// ListRaw gets list of the created disks belonging to an account as an array of bytes
|
|
||||||
func (d Disks) ListRaw(ctx context.Context, req ListRequest) ([]byte, error) {
|
|
||||||
url := "/cloudapi/disks/list"
|
|
||||||
|
|
||||||
res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
|
||||||
return res, err
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -8,16 +8,25 @@ import (
|
|||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
)
|
)
|
||||||
|
|
||||||
// GetRequest struct to get detailed information about external network
|
// Request struct for get detailed information about external network
|
||||||
type GetRequest struct {
|
type GetRequest struct {
|
||||||
// ID of external network
|
// ID of external network
|
||||||
// Required: true
|
// Required: true
|
||||||
NetID uint64 `url:"net_id" json:"net_id" validate:"required"`
|
NetID uint64 `url:"net_id" json:"net_id" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get gets detailed information about external network as a RecordExtNet struct
|
// Get gets detailed information about external network
|
||||||
func (e ExtNet) Get(ctx context.Context, req GetRequest) (*RecordExtNet, error) {
|
func (e ExtNet) Get(ctx context.Context, req GetRequest) (*RecordExtNet, error) {
|
||||||
res, err := e.GetRaw(ctx, req)
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
for _, validationError := range validators.GetErrors(err) {
|
||||||
|
return nil, validators.ValidationError(validationError)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudapi/extnet/get"
|
||||||
|
|
||||||
|
res, err := e.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -31,18 +40,3 @@ func (e ExtNet) Get(ctx context.Context, req GetRequest) (*RecordExtNet, error)
|
|||||||
|
|
||||||
return &info, nil
|
return &info, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetRaw gets detailed information about external network as an array of bytes
|
|
||||||
func (e ExtNet) GetRaw(ctx context.Context, req GetRequest) ([]byte, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
for _, validationError := range validators.GetErrors(err) {
|
|
||||||
return nil, validators.ValidationError(validationError)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/extnet/get"
|
|
||||||
|
|
||||||
res, err := e.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
|
||||||
return res, err
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ListRequest struct to get list of external network
|
// Request struct for get list external network
|
||||||
type ListRequest struct {
|
type ListRequest struct {
|
||||||
// Find by account ID
|
// Find by account ID
|
||||||
// Required: false
|
// Required: false
|
||||||
@@ -45,9 +45,11 @@ type ListRequest struct {
|
|||||||
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// List gets list of all available external networks as a ListExtNets struct
|
// List gets list all available external networks
|
||||||
func (e ExtNet) List(ctx context.Context, req ListRequest) (*ListExtNets, error) {
|
func (e ExtNet) List(ctx context.Context, req ListRequest) (*ListExtNets, error) {
|
||||||
res, err := e.ListRaw(ctx, req)
|
url := "/cloudapi/extnet/list"
|
||||||
|
|
||||||
|
res, err := e.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -61,11 +63,3 @@ func (e ExtNet) List(ctx context.Context, req ListRequest) (*ListExtNets, error)
|
|||||||
|
|
||||||
return &list, nil
|
return &list, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// ListRaw gets list of all available external networks as an array of bytes
|
|
||||||
func (e ExtNet) ListRaw(ctx context.Context, req ListRequest) ([]byte, error) {
|
|
||||||
url := "/cloudapi/extnet/list"
|
|
||||||
|
|
||||||
res, err := e.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
|
||||||
return res, err
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -8,16 +8,25 @@ import (
|
|||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
)
|
)
|
||||||
|
|
||||||
// GetRequest struct to get information about FLIPGroup
|
// Request struct for get information about FLIPGroup
|
||||||
type GetRequest struct {
|
type GetRequest struct {
|
||||||
// FLIPGroup ID
|
// FLIPGroup ID
|
||||||
// Required: true
|
// Required: true
|
||||||
FLIPGroupID uint64 `url:"flipgroupId" json:"flipgroupId" validate:"required"`
|
FLIPGroupID uint64 `url:"flipgroupId" json:"flipgroupId" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get gets details of the specified Floating IP group as a RecordFLIPGroup struct
|
// Get gets details of the specified Floating IP group
|
||||||
func (f FLIPGroup) Get(ctx context.Context, req GetRequest) (*RecordFLIPGroup, error) {
|
func (f FLIPGroup) Get(ctx context.Context, req GetRequest) (*RecordFLIPGroup, error) {
|
||||||
res, err := f.GetRaw(ctx, req)
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
for _, validationError := range validators.GetErrors(err) {
|
||||||
|
return nil, validators.ValidationError(validationError)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudapi/flipgroup/get"
|
||||||
|
|
||||||
|
res, err := f.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -31,18 +40,3 @@ func (f FLIPGroup) Get(ctx context.Context, req GetRequest) (*RecordFLIPGroup, e
|
|||||||
|
|
||||||
return &info, nil
|
return &info, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetRaw gets details of the specified Floating IP group as an array of bytes
|
|
||||||
func (f FLIPGroup) GetRaw(ctx context.Context, req GetRequest) ([]byte, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
for _, validationError := range validators.GetErrors(err) {
|
|
||||||
return nil, validators.ValidationError(validationError)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/flipgroup/get"
|
|
||||||
|
|
||||||
res, err := f.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
|
||||||
return res, err
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ListRequest struct to get list of FLIPGroup available to the current user
|
// Request struct for get list FLIPGroup available to the current user
|
||||||
type ListRequest struct {
|
type ListRequest struct {
|
||||||
// Find by name
|
// Find by name
|
||||||
// Required: false
|
// Required: false
|
||||||
@@ -25,11 +25,11 @@ type ListRequest struct {
|
|||||||
ExtNetID uint64 `url:"extnetId,omitempty" json:"extnetId,omitempty"`
|
ExtNetID uint64 `url:"extnetId,omitempty" json:"extnetId,omitempty"`
|
||||||
|
|
||||||
// Find by IP
|
// Find by IP
|
||||||
// Required: false
|
// Reuqired: false
|
||||||
ByIP string `url:"byIp,omitempty" json:"byIp,omitempty"`
|
ByIP string `url:"byIp,omitempty" json:"byIp,omitempty"`
|
||||||
|
|
||||||
// Find by resource group ID
|
// Find by resource group ID
|
||||||
// Required: false
|
// Reuqired: false
|
||||||
RGID uint64 `url:"rgId,omitempty" json:"rgId,omitempty"`
|
RGID uint64 `url:"rgId,omitempty" json:"rgId,omitempty"`
|
||||||
|
|
||||||
// Find by id
|
// Find by id
|
||||||
@@ -45,9 +45,11 @@ type ListRequest struct {
|
|||||||
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// List gets list of FLIPGroup managed cluster instances available to the current user as a ListFLIPGroups struct
|
// List gets list FLIPGroup managed cluster instances available to the current user
|
||||||
func (f FLIPGroup) List(ctx context.Context, req ListRequest) (*ListFLIPGroups, error) {
|
func (f FLIPGroup) List(ctx context.Context, req ListRequest) (*ListFLIPGroups, error) {
|
||||||
res, err := f.ListRaw(ctx, req)
|
url := "/cloudapi/flipgroup/list"
|
||||||
|
|
||||||
|
res, err := f.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -61,11 +63,3 @@ func (f FLIPGroup) List(ctx context.Context, req ListRequest) (*ListFLIPGroups,
|
|||||||
|
|
||||||
return &list, nil
|
return &list, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// ListRaw gets list of FLIPGroup managed cluster instances available to the current user as an array of bytes
|
|
||||||
func (f FLIPGroup) ListRaw(ctx context.Context, req ListRequest) ([]byte, error) {
|
|
||||||
url := "/cloudapi/flipgroup/list"
|
|
||||||
|
|
||||||
res, err := f.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
|
||||||
return res, err
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import (
|
|||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
)
|
)
|
||||||
|
|
||||||
// GetRequest struct to get detailed information about image
|
// Request struct for get detailed information about image
|
||||||
type GetRequest struct {
|
type GetRequest struct {
|
||||||
// ID of image to get
|
// ID of image to get
|
||||||
// Required: true
|
// Required: true
|
||||||
@@ -20,9 +20,18 @@ type GetRequest struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get gets image by ID.
|
// Get gets image by ID.
|
||||||
// Returns image as a RecordImage struct if user has rights on it
|
// Returns image if user has rights on it
|
||||||
func (i Image) Get(ctx context.Context, req GetRequest) (*RecordImage, error) {
|
func (i Image) Get(ctx context.Context, req GetRequest) (*RecordImage, error) {
|
||||||
res, err := i.GetRaw(ctx, req)
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
for _, validationError := range validators.GetErrors(err) {
|
||||||
|
return nil, validators.ValidationError(validationError)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudapi/image/get"
|
||||||
|
|
||||||
|
res, err := i.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -36,19 +45,3 @@ func (i Image) Get(ctx context.Context, req GetRequest) (*RecordImage, error) {
|
|||||||
|
|
||||||
return &info, nil
|
return &info, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetRaw gets image by ID.
|
|
||||||
// Returns image as an array of bytes if user has rights on it
|
|
||||||
func (i Image) GetRaw(ctx context.Context, req GetRequest) ([]byte, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
for _, validationError := range validators.GetErrors(err) {
|
|
||||||
return nil, validators.ValidationError(validationError)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/image/get"
|
|
||||||
|
|
||||||
res, err := i.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
|
||||||
return res, err
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ListRequest struct to get list of available images
|
// Request struct for get list available images
|
||||||
type ListRequest struct {
|
type ListRequest struct {
|
||||||
// Find by storage endpoint provider ID
|
// Find by storage endpoint provider ID
|
||||||
// Required: false
|
// Required: false
|
||||||
@@ -65,9 +65,11 @@ type ListRequest struct {
|
|||||||
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// List gets list of available images as a ListImages struct, optionally filtering by account ID
|
// List gets list available images, optionally filtering by account ID
|
||||||
func (i Image) List(ctx context.Context, req ListRequest) (*ListImages, error) {
|
func (i Image) List(ctx context.Context, req ListRequest) (*ListImages, error) {
|
||||||
res, err := i.ListRaw(ctx, req)
|
url := "/cloudapi/image/list"
|
||||||
|
|
||||||
|
res, err := i.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -81,11 +83,3 @@ func (i Image) List(ctx context.Context, req ListRequest) (*ListImages, error) {
|
|||||||
|
|
||||||
return &list, nil
|
return &list, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// ListRaw gets list of available images as an array of bytes
|
|
||||||
func (i Image) ListRaw(ctx context.Context, req ListRequest) ([]byte, error) {
|
|
||||||
url := "/cloudapi/image/list"
|
|
||||||
|
|
||||||
res, err := i.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
|
||||||
return res, err
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -8,16 +8,25 @@ import (
|
|||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
)
|
)
|
||||||
|
|
||||||
// GetRequest struct to get information about K8CI
|
// Request struct for get information about K8CI
|
||||||
type GetRequest struct {
|
type GetRequest struct {
|
||||||
// ID of the K8 catalog item to get
|
// ID of the K8 catalog item to get
|
||||||
// Required: true
|
// Required: true
|
||||||
K8CIID uint64 `url:"k8ciId" json:"k8ciId" validate:"required"`
|
K8CIID uint64 `url:"k8ciId" json:"k8ciId" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get gets details of the specified K8 catalog item as a RecordK8CI struct
|
// Get gets details of the specified K8 catalog item
|
||||||
func (k K8CI) Get(ctx context.Context, req GetRequest) (*RecordK8CI, error) {
|
func (k K8CI) Get(ctx context.Context, req GetRequest) (*RecordK8CI, error) {
|
||||||
res, err := k.GetRaw(ctx, req)
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
for _, validationError := range validators.GetErrors(err) {
|
||||||
|
return nil, validators.ValidationError(validationError)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudapi/k8ci/get"
|
||||||
|
|
||||||
|
res, err := k.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -30,18 +39,3 @@ func (k K8CI) Get(ctx context.Context, req GetRequest) (*RecordK8CI, error) {
|
|||||||
|
|
||||||
return &info, nil
|
return &info, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetRaw gets details of the specified K8 catalog item as an array of bytes
|
|
||||||
func (k K8CI) GetRaw(ctx context.Context, req GetRequest) ([]byte, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
for _, validationError := range validators.GetErrors(err) {
|
|
||||||
return nil, validators.ValidationError(validationError)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/k8ci/get"
|
|
||||||
|
|
||||||
res, err := k.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
|
||||||
return res, err
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ListRequest struct to get list of information about images
|
// Request struct for get list information about images
|
||||||
type ListRequest struct {
|
type ListRequest struct {
|
||||||
// Find by ID
|
// Find by ID
|
||||||
// Required: false
|
// Required: false
|
||||||
@@ -45,9 +45,11 @@ type ListRequest struct {
|
|||||||
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// List gets list of all k8ci catalog items available to the current user as a ListK8CI struct
|
// List gets list all k8ci catalog items available to the current user
|
||||||
func (k K8CI) List(ctx context.Context, req ListRequest) (*ListK8CI, error) {
|
func (k K8CI) List(ctx context.Context, req ListRequest) (*ListK8CI, error) {
|
||||||
res, err := k.ListRaw(ctx, req)
|
url := "/cloudapi/k8ci/list"
|
||||||
|
|
||||||
|
res, err := k.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -61,11 +63,3 @@ func (k K8CI) List(ctx context.Context, req ListRequest) (*ListK8CI, error) {
|
|||||||
|
|
||||||
return &list, nil
|
return &list, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// ListRaw gets list of all k8ci catalog items available to the current user as an array of bytes
|
|
||||||
func (k K8CI) ListRaw(ctx context.Context, req ListRequest) ([]byte, error) {
|
|
||||||
url := "/cloudapi/k8ci/list"
|
|
||||||
|
|
||||||
res, err := k.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
|
||||||
return res, err
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -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,80 +98,18 @@ 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:"lbSysctlParams,omitempty" json:"lbSysctlParams,omitempty"`
|
|
||||||
|
|
||||||
// Use Highly Available schema for LB deploy
|
|
||||||
// Required: false
|
|
||||||
HighlyAvailable bool `url:"highlyAvailableLB,omitempty" json:"highlyAvailableLB,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 string `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)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
for _, validationError := range validators.GetErrors(err) {
|
for _, validationError := range validators.GetErrors(err) {
|
||||||
@@ -181,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)
|
||||||
|
|||||||
@@ -8,16 +8,25 @@ import (
|
|||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
)
|
)
|
||||||
|
|
||||||
// GetRequest struct to get detailed information about kubernetes cluster
|
// Request struct for get detailed information about kubernetes cluster
|
||||||
type GetRequest struct {
|
type GetRequest struct {
|
||||||
// Kubernetes cluster ID
|
// Kubernetes cluster ID
|
||||||
// Required: true
|
// Required: true
|
||||||
K8SID uint64 `url:"k8sId" json:"k8sId" validate:"required"`
|
K8SID uint64 `url:"k8sId" json:"k8sId" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get gets information about Kubernetes cluster as a RecordK8S struct
|
// Get gets information about Kubernetes cluster
|
||||||
func (k8s K8S) Get(ctx context.Context, req GetRequest) (*RecordK8S, error) {
|
func (k8s K8S) Get(ctx context.Context, req GetRequest) (*RecordK8S, error) {
|
||||||
res, err := k8s.GetRaw(ctx, req)
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
for _, validationError := range validators.GetErrors(err) {
|
||||||
|
return nil, validators.ValidationError(validationError)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudapi/k8s/get"
|
||||||
|
|
||||||
|
res, err := k8s.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -31,18 +40,3 @@ func (k8s K8S) Get(ctx context.Context, req GetRequest) (*RecordK8S, error) {
|
|||||||
|
|
||||||
return &info, nil
|
return &info, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetRaw gets information about Kubernetes cluster as an array of bytes
|
|
||||||
func (k8s K8S) GetRaw(ctx context.Context, req GetRequest) ([]byte, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
for _, validationError := range validators.GetErrors(err) {
|
|
||||||
return nil, validators.ValidationError(validationError)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/k8s/get"
|
|
||||||
|
|
||||||
res, err := k8s.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
|
||||||
return res, err
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -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
|
|
||||||
}
|
|
||||||
@@ -6,7 +6,7 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ListRequest struct to get list information K8S
|
// Request struct for get list information K8S
|
||||||
type ListRequest struct {
|
type ListRequest struct {
|
||||||
// Find by ID
|
// Find by ID
|
||||||
// Required: false
|
// Required: false
|
||||||
@@ -53,9 +53,11 @@ type ListRequest struct {
|
|||||||
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// List gets list of all kubernetes clusters the user has access to as a ListK8SClusters
|
// List gets list all kubernetes clusters the user has access to
|
||||||
func (k8s K8S) List(ctx context.Context, req ListRequest) (*ListK8SClusters, error) {
|
func (k8s K8S) List(ctx context.Context, req ListRequest) (*ListK8SClusters, error) {
|
||||||
res, err := k8s.ListRaw(ctx, req)
|
url := "/cloudapi/k8s/list"
|
||||||
|
|
||||||
|
res, err := k8s.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -69,11 +71,3 @@ func (k8s K8S) List(ctx context.Context, req ListRequest) (*ListK8SClusters, err
|
|||||||
|
|
||||||
return &list, nil
|
return &list, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// ListRaw gets list of all kubernetes clusters the user has access to as an array of bytes
|
|
||||||
func (k8s K8S) ListRaw(ctx context.Context, req ListRequest) ([]byte, error) {
|
|
||||||
url := "/cloudapi/k8s/list"
|
|
||||||
|
|
||||||
res, err := k8s.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
|
||||||
return res, err
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -32,6 +32,10 @@ type ListDeletedRequest struct {
|
|||||||
// Required: false
|
// Required: false
|
||||||
BasicServiceID uint64 `url:"basicServiceId,omitempty" json:"basicServiceId,omitempty"`
|
BasicServiceID uint64 `url:"basicServiceId,omitempty" json:"basicServiceId,omitempty"`
|
||||||
|
|
||||||
|
// Find by status
|
||||||
|
// Required: false
|
||||||
|
Status string `url:"status,omitempty" json:"status,omitempty"`
|
||||||
|
|
||||||
// Find by techStatus
|
// Find by techStatus
|
||||||
// Required: false
|
// Required: false
|
||||||
TechStatus string `url:"techStatus,omitempty" json:"techStatus,omitempty"`
|
TechStatus string `url:"techStatus,omitempty" json:"techStatus,omitempty"`
|
||||||
|
|||||||
@@ -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
|
|
||||||
}
|
|
||||||
@@ -56,10 +56,6 @@ type WorkersGroupAddRequest struct {
|
|||||||
// Worker node boot disk size in GB If 0 is specified, size is defined by the OS image size
|
// Worker node boot disk size in GB If 0 is specified, size is defined by the OS image size
|
||||||
// Required: false
|
// Required: false
|
||||||
WorkerDisk uint64 `url:"workerDisk,omitempty" json:"workerDisk,omitempty"`
|
WorkerDisk uint64 `url:"workerDisk,omitempty" json:"workerDisk,omitempty"`
|
||||||
|
|
||||||
// Meta data for working group computes, format YAML "user_data": 1111
|
|
||||||
// Required: false
|
|
||||||
UserData string `url:"userData,omitempty" json:"userData,omitempty"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// WorkersGroupAdd adds workers group to Kubernetes cluster
|
// WorkersGroupAdd adds workers group to Kubernetes cluster
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ type CreateRequest struct {
|
|||||||
|
|
||||||
// Start VM upon success
|
// Start VM upon success
|
||||||
// Required: false
|
// Required: false
|
||||||
Start bool `url:"start" json:"start"`
|
Start bool `url:"start,omitempty" json:"start,omitempty"`
|
||||||
|
|
||||||
// System name
|
// System name
|
||||||
// Required: false
|
// Required: false
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ type CreateRequest struct {
|
|||||||
|
|
||||||
// Start VM upon success
|
// Start VM upon success
|
||||||
// Required: false
|
// Required: false
|
||||||
Start bool `url:"start" json:"start"`
|
Start bool `url:"start,omitempty" json:"start,omitempty"`
|
||||||
|
|
||||||
// System name
|
// System name
|
||||||
// Required: false
|
// Required: false
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -8,16 +8,25 @@ import (
|
|||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
)
|
)
|
||||||
|
|
||||||
// GetRequest struct to get detailed information about load balancer
|
// Request struct for get detailed information about load balancer
|
||||||
type GetRequest struct {
|
type GetRequest struct {
|
||||||
// ID of the load balancer to get details for
|
// ID of the load balancer to get details for
|
||||||
// Required: true
|
// Required: true
|
||||||
LBID uint64 `url:"lbId" json:"lbId" validate:"required"`
|
LBID uint64 `url:"lbId" json:"lbId" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get gets detailed information about load balancer as a RecordLB struct
|
// Get gets detailed information about load balancer
|
||||||
func (l LB) Get(ctx context.Context, req GetRequest) (*RecordLB, error) {
|
func (l LB) Get(ctx context.Context, req GetRequest) (*RecordLB, error) {
|
||||||
res, err := l.GetRaw(ctx, req)
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
for _, validationError := range validators.GetErrors(err) {
|
||||||
|
return nil, validators.ValidationError(validationError)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudapi/lb/get"
|
||||||
|
|
||||||
|
res, err := l.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -31,18 +40,3 @@ func (l LB) Get(ctx context.Context, req GetRequest) (*RecordLB, error) {
|
|||||||
|
|
||||||
return &info, nil
|
return &info, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetRaw gets detailed information about load balancer as an array of bytes
|
|
||||||
func (l LB) GetRaw(ctx context.Context, req GetRequest) ([]byte, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
for _, validationError := range validators.GetErrors(err) {
|
|
||||||
return nil, validators.ValidationError(validationError)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/lb/get"
|
|
||||||
|
|
||||||
res, err := l.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
|
||||||
return res, err
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ListRequest struct to get list of load balancers
|
// Request struct for get list of load balancers
|
||||||
type ListRequest struct {
|
type ListRequest struct {
|
||||||
// Find by ID
|
// Find by ID
|
||||||
// Required: false
|
// Required: false
|
||||||
@@ -53,9 +53,11 @@ type ListRequest struct {
|
|||||||
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// List gets list of all load balancers as a ListLB struct
|
// List gets list all load balancers
|
||||||
func (l LB) List(ctx context.Context, req ListRequest) (*ListLB, error) {
|
func (l LB) List(ctx context.Context, req ListRequest) (*ListLB, error) {
|
||||||
res, err := l.ListRaw(ctx, req)
|
url := "/cloudapi/lb/list"
|
||||||
|
|
||||||
|
res, err := l.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -69,11 +71,3 @@ func (l LB) List(ctx context.Context, req ListRequest) (*ListLB, error) {
|
|||||||
|
|
||||||
return &list, nil
|
return &list, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// ListRaw gets list of all load balancers as an array of bytes
|
|
||||||
func (l LB) ListRaw(ctx context.Context, req ListRequest) ([]byte, error) {
|
|
||||||
url := "/cloudapi/lb/list"
|
|
||||||
|
|
||||||
res, err := l.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
|
||||||
return res, err
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -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
|
|
||||||
}
|
|
||||||
@@ -8,9 +8,6 @@ type RecordLB struct {
|
|||||||
// 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
|
|
||||||
}
|
|
||||||
@@ -6,7 +6,7 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ListRequest struct to get list of locations
|
// Request struct for get list of locations
|
||||||
type ListRequest struct {
|
type ListRequest struct {
|
||||||
// Page number
|
// Page number
|
||||||
// Required: false
|
// Required: false
|
||||||
@@ -33,9 +33,11 @@ type ListRequest struct {
|
|||||||
LocationCode string `url:"locationCode,omitempty" json:"locationCode,omitempty"`
|
LocationCode string `url:"locationCode,omitempty" json:"locationCode,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// List gets list of all locations as a ListLocations struct
|
// List gets list all locations
|
||||||
func (l Locations) List(ctx context.Context, req ListRequest) (*ListLocations, error) {
|
func (l Locations) List(ctx context.Context, req ListRequest) (*ListLocations, error) {
|
||||||
res, err := l.ListRaw(ctx, req)
|
url := "/cloudapi/locations/list"
|
||||||
|
|
||||||
|
res, err := l.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -49,11 +51,3 @@ func (l Locations) List(ctx context.Context, req ListRequest) (*ListLocations, e
|
|||||||
|
|
||||||
return &list, nil
|
return &list, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// ListRaw gets list of all locations as an array of bytes
|
|
||||||
func (l Locations) ListRaw(ctx context.Context, req ListRequest) ([]byte, error) {
|
|
||||||
url := "/cloudapi/locations/list"
|
|
||||||
|
|
||||||
res, err := l.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
|
||||||
return res, err
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -13,14 +13,6 @@ type AffinityGroupsListRequest struct {
|
|||||||
// Resource group ID
|
// Resource group ID
|
||||||
// Required: true
|
// Required: true
|
||||||
RGID uint64 `url:"rgId" json:"rgId" validate:"required"`
|
RGID uint64 `url:"rgId" json:"rgId" validate:"required"`
|
||||||
|
|
||||||
// Page number
|
|
||||||
// Required: false
|
|
||||||
Page uint64 `url:"page,omitempty" json:"page,omitempty"`
|
|
||||||
|
|
||||||
// Page size
|
|
||||||
// Required: false
|
|
||||||
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// AffinityGroupsList gets all currently defined affinity groups in this resource group with compute IDs
|
// AffinityGroupsList gets all currently defined affinity groups in this resource group with compute IDs
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import (
|
|||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
)
|
)
|
||||||
|
|
||||||
// GetRequest struct to get detailed information about resource group
|
// Request struct for get detailed information about resource group
|
||||||
type GetRequest struct {
|
type GetRequest struct {
|
||||||
// Resource group ID
|
// Resource group ID
|
||||||
// Required: true
|
// Required: true
|
||||||
@@ -19,9 +19,18 @@ type GetRequest struct {
|
|||||||
Reason string `url:"reason,omitempty" json:"reason,omitempty"`
|
Reason string `url:"reason,omitempty" json:"reason,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get gets current configuration of the resource group as a RecordResourceGroup struct
|
// Get gets current configuration of the resource group
|
||||||
func (r RG) Get(ctx context.Context, req GetRequest) (*RecordResourceGroup, error) {
|
func (r RG) Get(ctx context.Context, req GetRequest) (*RecordResourceGroup, error) {
|
||||||
res, err := r.GetRaw(ctx, req)
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
for _, validationError := range validators.GetErrors(err) {
|
||||||
|
return nil, validators.ValidationError(validationError)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudapi/rg/get"
|
||||||
|
|
||||||
|
res, err := r.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -35,18 +44,3 @@ func (r RG) Get(ctx context.Context, req GetRequest) (*RecordResourceGroup, erro
|
|||||||
|
|
||||||
return &info, nil
|
return &info, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetRaw gets current configuration of the resource group as an array of bytes
|
|
||||||
func (r RG) GetRaw(ctx context.Context, req GetRequest) ([]byte, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
for _, validationError := range validators.GetErrors(err) {
|
|
||||||
return nil, validators.ValidationError(validationError)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/rg/get"
|
|
||||||
|
|
||||||
res, err := r.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
|
||||||
return res, err
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ListRequest struct to get list of resource groups
|
// Request struct for get list of resource groups
|
||||||
type ListRequest struct {
|
type ListRequest struct {
|
||||||
// Find by ID
|
// Find by ID
|
||||||
// Required: false
|
// Required: false
|
||||||
@@ -53,9 +53,11 @@ type ListRequest struct {
|
|||||||
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// List gets list of all resource groups the user has access to as a ListResourceGroups struct
|
// List gets list of all resource groups the user has access to
|
||||||
func (r RG) List(ctx context.Context, req ListRequest) (*ListResourceGroups, error) {
|
func (r RG) List(ctx context.Context, req ListRequest) (*ListResourceGroups, error) {
|
||||||
res, err := r.ListRaw(ctx, req)
|
url := "/cloudapi/rg/list"
|
||||||
|
|
||||||
|
res, err := r.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -69,11 +71,3 @@ func (r RG) List(ctx context.Context, req ListRequest) (*ListResourceGroups, err
|
|||||||
|
|
||||||
return &list, nil
|
return &list, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// ListRaw gets list of all resource groups the user has access to as an array of bytes
|
|
||||||
func (r RG) ListRaw(ctx context.Context, req ListRequest) ([]byte, error) {
|
|
||||||
url := "/cloudapi/rg/list"
|
|
||||||
|
|
||||||
res, err := r.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
|
||||||
return res, err
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -48,10 +48,10 @@ type Resources struct {
|
|||||||
// Detailed information about resource consumption
|
// Detailed information about resource consumption
|
||||||
type ItemResourceConsumption struct {
|
type ItemResourceConsumption struct {
|
||||||
// Consumed information about resources
|
// Consumed information about resources
|
||||||
Consumed Resource `json:"consumed"`
|
Consumed Resource `json:"Consumed"`
|
||||||
|
|
||||||
// Reserved information about resources
|
// Reserved information about resources
|
||||||
Reserved Resource `json:"reserved"`
|
Reserved Resource `json:"Reserved"`
|
||||||
|
|
||||||
// Resource limits
|
// Resource limits
|
||||||
ResourceLimits ResourceLimits `json:"resourceLimits"`
|
ResourceLimits ResourceLimits `json:"resourceLimits"`
|
||||||
@@ -333,7 +333,7 @@ type ListAffinityGroupsComputes []ItemAffinityGroupComputes
|
|||||||
|
|
||||||
type ListAffinityGroups struct {
|
type ListAffinityGroups struct {
|
||||||
// Data
|
// Data
|
||||||
Data []map[string][]uint64 `json:"data"`
|
Data map[string][]uint64 `json:"data"`
|
||||||
|
|
||||||
// Entry count
|
// Entry count
|
||||||
EntryCount uint64 `json:"entryCount"`
|
EntryCount uint64 `json:"entryCount"`
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ListRequest struct for list of the available flavors
|
// Request struct for list the available flavors
|
||||||
type ListRequest struct {
|
type ListRequest struct {
|
||||||
// ID of the cloudspace
|
// ID of the cloudspace
|
||||||
// Required: false
|
// Required: false
|
||||||
@@ -25,9 +25,11 @@ type ListRequest struct {
|
|||||||
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// List gets list of the available flavors as a ListSizes struct, filtering can be based on the user which is doing the request
|
// List gets list the available flavors, filtering can be based on the user which is doing the request
|
||||||
func (s Sizes) List(ctx context.Context, req ListRequest) (*ListSizes, error) {
|
func (s Sizes) List(ctx context.Context, req ListRequest) (*ListSizes, error) {
|
||||||
res, err := s.ListRaw(ctx, req)
|
url := "/cloudapi/sizes/list"
|
||||||
|
|
||||||
|
res, err := s.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -41,11 +43,3 @@ func (s Sizes) List(ctx context.Context, req ListRequest) (*ListSizes, error) {
|
|||||||
|
|
||||||
return list, nil
|
return list, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// ListRaw gets list of the available flavors as an array of bytes
|
|
||||||
func (s Sizes) ListRaw(ctx context.Context, req ListRequest) ([]byte, error) {
|
|
||||||
url := "/cloudapi/sizes/list"
|
|
||||||
|
|
||||||
res, err := s.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
|
||||||
return res, err
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -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,48 +0,0 @@
|
|||||||
package stack
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"encoding/json"
|
|
||||||
"net/http"
|
|
||||||
|
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
|
||||||
)
|
|
||||||
|
|
||||||
// GetRequest struct to get info of stack
|
|
||||||
type GetRequest struct {
|
|
||||||
// Find by ID
|
|
||||||
// Required: true
|
|
||||||
StackId uint64 `url:"stackId" json:"stackId" validate:"required"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get gets stack details by ID as an InfoStack struct
|
|
||||||
func (i Stack) Get(ctx context.Context, req GetRequest) (*InfoStack, error) {
|
|
||||||
res, err := i.GetRaw(ctx, req)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
info := InfoStack{}
|
|
||||||
|
|
||||||
err = json.Unmarshal(res, &info)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return &info, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetRaw gets stack details by ID as an array of bytes
|
|
||||||
func (i Stack) GetRaw(ctx context.Context, req GetRequest) ([]byte, 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)
|
|
||||||
return res, err
|
|
||||||
}
|
|
||||||
@@ -1,59 +0,0 @@
|
|||||||
package stack
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"encoding/json"
|
|
||||||
"net/http"
|
|
||||||
)
|
|
||||||
|
|
||||||
// ListRequest struct to get list of stacks
|
|
||||||
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"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// List gets list of stacks as a ListStacks struct
|
|
||||||
func (i Stack) List(ctx context.Context, req ListRequest) (*ListStacks, error) {
|
|
||||||
res, err := i.ListRaw(ctx, req)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
list := ListStacks{}
|
|
||||||
|
|
||||||
err = json.Unmarshal(res, &list)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return &list, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// ListRaw gets list of stacks as an array of bytes
|
|
||||||
func (i Stack) ListRaw(ctx context.Context, req ListRequest) ([]byte, error) {
|
|
||||||
url := "/cloudapi/stack/list"
|
|
||||||
|
|
||||||
res, err := i.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
|
||||||
return res, err
|
|
||||||
}
|
|
||||||
@@ -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,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -8,16 +8,25 @@ import (
|
|||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
)
|
)
|
||||||
|
|
||||||
// GetRequest struct to get information about task
|
// Request struct for get infromation about task
|
||||||
type GetRequest struct {
|
type GetRequest struct {
|
||||||
// ID of audit
|
// ID of audit
|
||||||
// Required: true
|
// Required: true
|
||||||
AuditID string `url:"auditId" json:"auditId" validate:"required"`
|
AuditID string `url:"auditId" json:"auditId" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get gets background API task status and result as a RecordAsyncTask struct
|
// Get gets background API task status and result
|
||||||
func (t Tasks) Get(ctx context.Context, req GetRequest) (*RecordAsyncTask, error) {
|
func (t Tasks) Get(ctx context.Context, req GetRequest) (*RecordAsyncTask, error) {
|
||||||
res, err := t.GetRaw(ctx, req)
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
for _, validationError := range validators.GetErrors(err) {
|
||||||
|
return nil, validators.ValidationError(validationError)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudapi/tasks/get"
|
||||||
|
|
||||||
|
res, err := t.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -32,18 +41,3 @@ func (t Tasks) Get(ctx context.Context, req GetRequest) (*RecordAsyncTask, error
|
|||||||
return &info, nil
|
return &info, nil
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetRaw gets background API task status and result as an array of bytes
|
|
||||||
func (t Tasks) GetRaw(ctx context.Context, req GetRequest) ([]byte, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
for _, validationError := range validators.GetErrors(err) {
|
|
||||||
return nil, validators.ValidationError(validationError)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/tasks/get"
|
|
||||||
|
|
||||||
res, err := t.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
|
||||||
return res, err
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ListRequest struct to get list of tasks
|
// Request struct for get list of tasks
|
||||||
type ListRequest struct {
|
type ListRequest struct {
|
||||||
// Page number
|
// Page number
|
||||||
// Required: false
|
// Required: false
|
||||||
@@ -17,9 +17,11 @@ type ListRequest struct {
|
|||||||
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// List gets list of user API tasks with status PROCESSING as a ListTasks struct
|
// List gets list user API tasks with status PROCESSING
|
||||||
func (t Tasks) List(ctx context.Context, req ListRequest) (*ListTasks, error) {
|
func (t Tasks) List(ctx context.Context, req ListRequest) (*ListTasks, error) {
|
||||||
res, err := t.ListRaw(ctx, req)
|
url := "/cloudapi/tasks/list"
|
||||||
|
|
||||||
|
res, err := t.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -33,11 +35,3 @@ func (t Tasks) List(ctx context.Context, req ListRequest) (*ListTasks, error) {
|
|||||||
|
|
||||||
return &list, nil
|
return &list, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// ListRaw gets list of user API tasks with status PROCESSING as an array of bytes
|
|
||||||
func (t Tasks) ListRaw(ctx context.Context, req ListRequest) ([]byte, error) {
|
|
||||||
url := "/cloudapi/tasks/list"
|
|
||||||
|
|
||||||
res, err := t.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
|
||||||
return res, err
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -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
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,16 +8,25 @@ import (
|
|||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
)
|
)
|
||||||
|
|
||||||
// GetRequest struct to get information about VINS
|
// Request struct for get information about VINS
|
||||||
type GetRequest struct {
|
type GetRequest struct {
|
||||||
// VINS ID
|
// VINS ID
|
||||||
// Required: true
|
// Required: true
|
||||||
VINSID uint64 `url:"vinsId" json:"vinsId" validate:"required"`
|
VINSID uint64 `url:"vinsId" json:"vinsId" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get gets information about VINS by ID as a RecordVINS struct
|
// Get gets information about VINS by ID
|
||||||
func (v VINS) Get(ctx context.Context, req GetRequest) (*RecordVINS, error) {
|
func (v VINS) Get(ctx context.Context, req GetRequest) (*RecordVINS, error) {
|
||||||
res, err := v.GetRaw(ctx, req)
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
for _, validationError := range validators.GetErrors(err) {
|
||||||
|
return nil, validators.ValidationError(validationError)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudapi/vins/get"
|
||||||
|
|
||||||
|
res, err := v.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -30,19 +39,5 @@ func (v VINS) Get(ctx context.Context, req GetRequest) (*RecordVINS, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return &info, nil
|
return &info, nil
|
||||||
}
|
|
||||||
|
|
||||||
// GetRaw gets information about VINS by ID as an array of bytes
|
|
||||||
func (v VINS) GetRaw(ctx context.Context, req GetRequest) ([]byte, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
for _, validationError := range validators.GetErrors(err) {
|
|
||||||
return nil, validators.ValidationError(validationError)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/vins/get"
|
|
||||||
|
|
||||||
res, err := v.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
|
||||||
return res, err
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ListRequest struct to get list of VINSes
|
// Request struct for get list of VINSes
|
||||||
type ListRequest struct {
|
type ListRequest struct {
|
||||||
// Find by ID
|
// Find by ID
|
||||||
// Required: false
|
// Required: false
|
||||||
@@ -41,9 +41,11 @@ type ListRequest struct {
|
|||||||
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// List gets list of VINSes available for current user as a ListVINS struct
|
// List gets list of VINSes available for current user
|
||||||
func (v VINS) List(ctx context.Context, req ListRequest) (*ListVINS, error) {
|
func (v VINS) List(ctx context.Context, req ListRequest) (*ListVINS, error) {
|
||||||
res, err := v.ListRaw(ctx, req)
|
url := "/cloudapi/vins/list"
|
||||||
|
|
||||||
|
res, err := v.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -57,11 +59,3 @@ func (v VINS) List(ctx context.Context, req ListRequest) (*ListVINS, error) {
|
|||||||
|
|
||||||
return &list, nil
|
return &list, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// ListRaw gets list of VINSes available for current user as an array of bytes
|
|
||||||
func (v VINS) ListRaw(ctx context.Context, req ListRequest) ([]byte, error) {
|
|
||||||
url := "/cloudapi/vins/list"
|
|
||||||
|
|
||||||
res, err := v.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
|
||||||
return res, 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
|
|
||||||
}
|
|
||||||
@@ -8,32 +8,15 @@ import (
|
|||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
)
|
)
|
||||||
|
|
||||||
// GetRequest struct to get information about account
|
// Request struct for get information about account
|
||||||
type GetRequest struct {
|
type GetRequest struct {
|
||||||
// ID an account
|
// ID an account
|
||||||
// Required: true
|
// Required: true
|
||||||
AccountID uint64 `url:"accountId" json:"accountId" validate:"required"`
|
AccountID uint64 `url:"accountId" json:"accountId" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get gets information about account as a RecordAccount struct
|
// Get gets information about account
|
||||||
func (a Account) Get(ctx context.Context, req GetRequest) (*RecordAccount, error) {
|
func (a Account) Get(ctx context.Context, req GetRequest) (*RecordAccount, error) {
|
||||||
res, err := a.GetRaw(ctx, req)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
info := RecordAccount{}
|
|
||||||
|
|
||||||
err = json.Unmarshal(res, &info)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return &info, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetRaw gets information about account as an array of bytes
|
|
||||||
func (a Account) GetRaw(ctx context.Context, req GetRequest) ([]byte, 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) {
|
||||||
@@ -43,6 +26,17 @@ func (a Account) GetRaw(ctx context.Context, req GetRequest) ([]byte, error) {
|
|||||||
|
|
||||||
url := "/cloudbroker/account/get"
|
url := "/cloudbroker/account/get"
|
||||||
|
|
||||||
|
info := RecordAccount{}
|
||||||
|
|
||||||
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
return res, err
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
err = json.Unmarshal(res, &info)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return &info, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ListRequest struct to get list of accounts
|
// Request struct for get list of accounts
|
||||||
type ListRequest struct {
|
type ListRequest struct {
|
||||||
// Find by ID
|
// Find by ID
|
||||||
// Required: false
|
// Required: false
|
||||||
@@ -33,9 +33,11 @@ type ListRequest struct {
|
|||||||
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// List gets list of all accounts the user has access to as a ListAccounts struct
|
// List gets list all accounts the user has access to
|
||||||
func (a Account) List(ctx context.Context, req ListRequest) (*ListAccounts, error) {
|
func (a Account) List(ctx context.Context, req ListRequest) (*ListAccounts, error) {
|
||||||
res, err := a.ListRaw(ctx, req)
|
url := "/cloudbroker/account/list"
|
||||||
|
|
||||||
|
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -49,11 +51,3 @@ func (a Account) List(ctx context.Context, req ListRequest) (*ListAccounts, erro
|
|||||||
|
|
||||||
return &list, nil
|
return &list, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// ListRaw gets list of all accounts the user has access to as an array of bytes
|
|
||||||
func (a Account) ListRaw(ctx context.Context, req ListRequest) ([]byte, error) {
|
|
||||||
url := "/cloudbroker/account/list"
|
|
||||||
|
|
||||||
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
|
||||||
return res, err
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -29,10 +29,10 @@ type RecordResourceConsumption struct {
|
|||||||
|
|
||||||
type ItemResourceConsumption struct {
|
type ItemResourceConsumption struct {
|
||||||
// Current information about resources
|
// Current information about resources
|
||||||
Consumed Resource `json:"consumed"`
|
Current Resource `json:"Current"`
|
||||||
|
|
||||||
// Reserved information about resources
|
// Reserved information about resources
|
||||||
Reserved Resource `json:"reserved"`
|
Reserved Resource `json:"Reserved"`
|
||||||
|
|
||||||
// ID of account
|
// ID of account
|
||||||
AccountID uint64 `json:"id"`
|
AccountID uint64 `json:"id"`
|
||||||
@@ -54,7 +54,7 @@ type Resource struct {
|
|||||||
DiskSize float64 `json:"disksize"`
|
DiskSize float64 `json:"disksize"`
|
||||||
|
|
||||||
// Disk size max
|
// Disk size max
|
||||||
DiskSizeMax float64 `json:"disksizemax"`
|
DiskSizeMax uint64 `json:"disksizemax"`
|
||||||
|
|
||||||
// Number of External IPs
|
// Number of External IPs
|
||||||
ExtIPs int64 `json:"extips"`
|
ExtIPs int64 `json:"extips"`
|
||||||
@@ -414,6 +414,33 @@ type Computes struct {
|
|||||||
Stopped uint64 `json:"Stopped"`
|
Stopped uint64 `json:"Stopped"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Consumed
|
||||||
|
type Consumed struct {
|
||||||
|
// Number of CPU
|
||||||
|
CPU uint64 `json:"cpu"`
|
||||||
|
|
||||||
|
// Disk size
|
||||||
|
DiskSize float64 `json:"disksize"`
|
||||||
|
|
||||||
|
// Disk size max
|
||||||
|
DiskSizeMax int64 `json:"disksizemax"`
|
||||||
|
|
||||||
|
// External IPs
|
||||||
|
ExtIPs uint64 `json:"extips"`
|
||||||
|
|
||||||
|
// External traffic
|
||||||
|
ExtTraffic uint64 `json:"exttraffic"`
|
||||||
|
|
||||||
|
// Number of GPU
|
||||||
|
GPU uint64 `json:"gpu"`
|
||||||
|
|
||||||
|
// Number of RAM
|
||||||
|
RAM uint64 `json:"ram"`
|
||||||
|
|
||||||
|
// SEPs
|
||||||
|
SEPs map[string]map[string]DiskUsage `json:"seps"`
|
||||||
|
}
|
||||||
|
|
||||||
// Limits
|
// Limits
|
||||||
type Limits struct {
|
type Limits struct {
|
||||||
// Number of CPU
|
// Number of CPU
|
||||||
@@ -444,7 +471,7 @@ type Limits struct {
|
|||||||
// Resources of resource group
|
// Resources of resource group
|
||||||
type RGResuorces struct {
|
type RGResuorces struct {
|
||||||
// Consumed
|
// Consumed
|
||||||
Consumed Resource `json:"Consumed"`
|
Consumed Consumed `json:"Consumed"`
|
||||||
|
|
||||||
// Limits
|
// Limits
|
||||||
Limits Limits `json:"Limits"`
|
Limits Limits `json:"Limits"`
|
||||||
|
|||||||
@@ -8,32 +8,15 @@ import (
|
|||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
)
|
)
|
||||||
|
|
||||||
// GetRequest struct to get apiaccess group.
|
// Request struct for getting apiaccess group.
|
||||||
type GetRequest struct {
|
type GetRequest struct {
|
||||||
// APIAccess group ID.
|
// APIAccess group ID.
|
||||||
// Required: true
|
// Required: true
|
||||||
APIAccessID uint64 `url:"apiaccessId" json:"apiaccessId" validate:"required"`
|
APIAccessID uint64 `url:"apiaccessId" json:"apiaccessId" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get gets apiaccess group as an ItemAPIAccess struct
|
// Get gets apiaccess group.
|
||||||
func (a APIAccess) Get(ctx context.Context, req GetRequest) (*ItemAPIAccess, error) {
|
func (a APIAccess) Get(ctx context.Context, req GetRequest) (*ItemAPIAccess, error) {
|
||||||
res, err := a.GetRaw(ctx, req)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
info := ItemAPIAccess{}
|
|
||||||
|
|
||||||
err = json.Unmarshal(res, &info)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return &info, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetRaw gets apiaccess group as an array of bytes
|
|
||||||
func (a APIAccess) GetRaw(ctx context.Context, req GetRequest) ([]byte, 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) {
|
||||||
@@ -43,6 +26,17 @@ func (a APIAccess) GetRaw(ctx context.Context, req GetRequest) ([]byte, error) {
|
|||||||
|
|
||||||
url := "/cloudbroker/apiaccess/get"
|
url := "/cloudbroker/apiaccess/get"
|
||||||
|
|
||||||
|
info := ItemAPIAccess{}
|
||||||
|
|
||||||
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
return res, err
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
err = json.Unmarshal(res, &info)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return &info, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import (
|
|||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ListRequest struct to get list of all non deleted apiaccess instances.
|
// Request struct for getting list of all non deleted apiaccess instances.
|
||||||
type ListRequest struct {
|
type ListRequest struct {
|
||||||
// Find by ID
|
// Find by ID
|
||||||
// Required: false
|
// Required: false
|
||||||
@@ -43,25 +43,8 @@ type ListRequest struct {
|
|||||||
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// List gets list of all non deleted apiaccess instances as a ListAPIAccess struct
|
// List gets list of all non deleted apiaccess instances.
|
||||||
func (a APIAccess) List(ctx context.Context, req ListRequest) (*ListAPIAccess, error) {
|
func (a APIAccess) List(ctx context.Context, req ListRequest) (*ListAPIAccess, error) {
|
||||||
res, err := a.ListRaw(ctx, req)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
info := ListAPIAccess{}
|
|
||||||
|
|
||||||
err = json.Unmarshal(res, &info)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return &info, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// ListRaw gets list of all non deleted apiaccess instances as an array of bytes
|
|
||||||
func (a APIAccess) ListRaw(ctx context.Context, req ListRequest) ([]byte, 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) {
|
||||||
@@ -71,6 +54,17 @@ func (a APIAccess) ListRaw(ctx context.Context, req ListRequest) ([]byte, error)
|
|||||||
|
|
||||||
url := "/cloudbroker/apiaccess/list"
|
url := "/cloudbroker/apiaccess/list"
|
||||||
|
|
||||||
|
info := ListAPIAccess{}
|
||||||
|
|
||||||
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
return res, err
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
err = json.Unmarshal(res, &info)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return &info, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import (
|
|||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
)
|
)
|
||||||
|
|
||||||
// GetRequest to get information about compute
|
// Request for get information about compute
|
||||||
type GetRequest struct {
|
type GetRequest struct {
|
||||||
// ID of compute instance
|
// ID of compute instance
|
||||||
// Required: true
|
// Required: true
|
||||||
@@ -19,9 +19,18 @@ type GetRequest struct {
|
|||||||
Reason string `url:"reason,omitempty" json:"reason,omitempty"`
|
Reason string `url:"reason,omitempty" json:"reason,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get gets information about compute as a RecordCompute struct
|
// Get gets information about compute
|
||||||
func (c Compute) Get(ctx context.Context, req GetRequest) (*RecordCompute, error) {
|
func (c Compute) Get(ctx context.Context, req GetRequest) (*RecordCompute, error) {
|
||||||
res, err := c.GetRaw(ctx, req)
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
for _, validationError := range validators.GetErrors(err) {
|
||||||
|
return nil, validators.ValidationError(validationError)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudbroker/compute/get"
|
||||||
|
|
||||||
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -35,18 +44,3 @@ func (c Compute) Get(ctx context.Context, req GetRequest) (*RecordCompute, error
|
|||||||
|
|
||||||
return &info, nil
|
return &info, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetRaw gets information about compute as an array of bytes
|
|
||||||
func (c Compute) GetRaw(ctx context.Context, req GetRequest) ([]byte, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
for _, validationError := range validators.GetErrors(err) {
|
|
||||||
return nil, validators.ValidationError(validationError)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudbroker/compute/get"
|
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
|
||||||
return res, err
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ListRequest struct to get list of available computes
|
// Request struct for get list available computes
|
||||||
type ListRequest struct {
|
type ListRequest struct {
|
||||||
// Find by ID
|
// Find by ID
|
||||||
// Required: false
|
// Required: false
|
||||||
@@ -61,10 +61,12 @@ type ListRequest struct {
|
|||||||
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// List gets list of the available computes as a ListComputes struct.
|
// List gets list of the available computes.
|
||||||
// Filtering based on status is possible
|
// Filtering based on status is possible
|
||||||
func (c Compute) List(ctx context.Context, req ListRequest) (*ListComputes, error) {
|
func (c Compute) List(ctx context.Context, req ListRequest) (*ListComputes, error) {
|
||||||
res, err := c.ListRaw(ctx, req)
|
url := "/cloudbroker/compute/list"
|
||||||
|
|
||||||
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -78,11 +80,3 @@ func (c Compute) List(ctx context.Context, req ListRequest) (*ListComputes, erro
|
|||||||
|
|
||||||
return &list, nil
|
return &list, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// ListRaw gets list of the available computes as an array of bytes
|
|
||||||
func (c Compute) ListRaw(ctx context.Context, req ListRequest) ([]byte, error) {
|
|
||||||
url := "/cloudbroker/compute/list"
|
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
|
||||||
return res, err
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -672,7 +672,7 @@ type InfoCompute struct {
|
|||||||
StackName string `json:"stackName"`
|
StackName string `json:"stackName"`
|
||||||
|
|
||||||
// Stateless SEP ID
|
// Stateless SEP ID
|
||||||
StatelessSEPID int64 `json:"statelessSepId"`
|
StatelessSEPID uint64 `json:"statelessSepId"`
|
||||||
|
|
||||||
// Stateless SEP Type
|
// Stateless SEP Type
|
||||||
StatelessSEPType string `json:"statelessSepType"`
|
StatelessSEPType string `json:"statelessSepType"`
|
||||||
|
|||||||
@@ -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
|
|
||||||
}
|
|
||||||
@@ -8,17 +8,26 @@ import (
|
|||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
)
|
)
|
||||||
|
|
||||||
// GetRequest struct to get information about disk
|
// Request struct for get information about disk
|
||||||
type GetRequest struct {
|
type GetRequest struct {
|
||||||
// ID of the disk
|
// ID of the disk
|
||||||
// Required: true
|
// Required: true
|
||||||
DiskID uint64 `url:"diskId" json:"diskId" validate:"required"`
|
DiskID uint64 `url:"diskId" json:"diskId" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get gets disk details as a RecordDisk struct.
|
// Get gets disk details
|
||||||
// Notice: the devicename field is the name as it is passed to the kernel (kname in linux) for unattached disks this field has no relevant value
|
// Notice: the devicename field is the name as it is passed to the kernel (kname in linux) for unattached disks this field has no relevant value
|
||||||
func (d Disks) Get(ctx context.Context, req GetRequest) (*RecordDisk, error) {
|
func (d Disks) Get(ctx context.Context, req GetRequest) (*RecordDisk, error) {
|
||||||
res, err := d.GetRaw(ctx, req)
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
for _, validationError := range validators.GetErrors(err) {
|
||||||
|
return nil, validators.ValidationError(validationError)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudbroker/disks/get"
|
||||||
|
|
||||||
|
res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -32,19 +41,3 @@ func (d Disks) Get(ctx context.Context, req GetRequest) (*RecordDisk, error) {
|
|||||||
|
|
||||||
return &info, nil
|
return &info, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetRaw gets disk details as an array of bytes.
|
|
||||||
// Notice: the devicename field is the name as it is passed to the kernel (kname in linux) for unattached disks this field has no relevant value
|
|
||||||
func (d Disks) GetRaw(ctx context.Context, req GetRequest) ([]byte, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
for _, validationError := range validators.GetErrors(err) {
|
|
||||||
return nil, validators.ValidationError(validationError)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudbroker/disks/get"
|
|
||||||
|
|
||||||
res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
|
||||||
return res, err
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ListRequest struct to get list/list_deleted of disks
|
// Request struct for get list/list_deleted of disks
|
||||||
type ListRequest struct {
|
type ListRequest struct {
|
||||||
// Find by id
|
// Find by id
|
||||||
// Required: false
|
// Required: false
|
||||||
@@ -57,9 +57,11 @@ type ListRequest struct {
|
|||||||
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// List gets list of the created disks belonging to an account as a ListDisks struct
|
// List gets list the created disks belonging to an account
|
||||||
func (d Disks) List(ctx context.Context, req ListRequest) (*ListDisks, error) {
|
func (d Disks) List(ctx context.Context, req ListRequest) (*ListDisks, error) {
|
||||||
res, err := d.ListRaw(ctx, req)
|
url := "/cloudbroker/disks/list"
|
||||||
|
|
||||||
|
res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -73,11 +75,3 @@ func (d Disks) List(ctx context.Context, req ListRequest) (*ListDisks, error) {
|
|||||||
|
|
||||||
return &list, nil
|
return &list, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// ListRaw gets list of the created disks belonging to an account as an array of bytes
|
|
||||||
func (d Disks) ListRaw(ctx context.Context, req ListRequest) ([]byte, error) {
|
|
||||||
url := "/cloudbroker/disks/list"
|
|
||||||
|
|
||||||
res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
|
||||||
return res, err
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -2,24 +2,12 @@ package extnet
|
|||||||
|
|
||||||
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 external network
|
// Request struct for create external network
|
||||||
type CreateRequest struct {
|
type CreateRequest struct {
|
||||||
// External network name
|
// External network name
|
||||||
@@ -82,15 +70,6 @@ type CreateRequest struct {
|
|||||||
// OpenvSwith bridge name for ExtNet connection
|
// OpenvSwith bridge name for ExtNet connection
|
||||||
// Required: false
|
// Required: false
|
||||||
OVSBridge string `url:"ovsBridge,omitempty" json:"ovsBridge,omitempty"`
|
OVSBridge string `url:"ovsBridge,omitempty" json:"ovsBridge,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 wrapperCreateRequest struct {
|
|
||||||
CreateRequest
|
|
||||||
Routes []string `url:"routes,omitempty"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create creates new external network into platform
|
// Create creates new external network into platform
|
||||||
@@ -102,31 +81,9 @@ func (e ExtNet) Create(ctx context.Context, req CreateRequest) (uint64, error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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 := wrapperCreateRequest{
|
|
||||||
CreateRequest: req,
|
|
||||||
Routes: routes,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudbroker/extnet/create"
|
url := "/cloudbroker/extnet/create"
|
||||||
|
|
||||||
res, err := e.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
res, err := e.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,16 +8,25 @@ import (
|
|||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
)
|
)
|
||||||
|
|
||||||
// GetRequest struct to get information about external network
|
// Request struct for get information about external network
|
||||||
type GetRequest struct {
|
type GetRequest struct {
|
||||||
// ID of external network
|
// ID of external network
|
||||||
// Required: true
|
// Required: true
|
||||||
NetID uint64 `url:"net_id" json:"net_id" validate:"required"`
|
NetID uint64 `url:"net_id" json:"net_id" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get gets external network details as a RecordExtNet struct
|
// Get gets external network details
|
||||||
func (e ExtNet) Get(ctx context.Context, req GetRequest) (*RecordExtNet, error) {
|
func (e ExtNet) Get(ctx context.Context, req GetRequest) (*RecordExtNet, error) {
|
||||||
res, err := e.GetRaw(ctx, req)
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
for _, validationError := range validators.GetErrors(err) {
|
||||||
|
return nil, validators.ValidationError(validationError)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudbroker/extnet/get"
|
||||||
|
|
||||||
|
res, err := e.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -31,18 +40,3 @@ func (e ExtNet) Get(ctx context.Context, req GetRequest) (*RecordExtNet, error)
|
|||||||
|
|
||||||
return &info, nil
|
return &info, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetRaw gets external network details as an array of bytes
|
|
||||||
func (e ExtNet) GetRaw(ctx context.Context, req GetRequest) ([]byte, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
for _, validationError := range validators.GetErrors(err) {
|
|
||||||
return nil, validators.ValidationError(validationError)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudbroker/extnet/get"
|
|
||||||
|
|
||||||
res, err := e.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
|
||||||
return res, err
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ListRequest struct to get list of external network
|
// Request struct for get list external network
|
||||||
type ListRequest struct {
|
type ListRequest struct {
|
||||||
// Find by account ID
|
// Find by account ID
|
||||||
// Required: false
|
// Required: false
|
||||||
@@ -45,9 +45,11 @@ type ListRequest struct {
|
|||||||
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// List gets list of all available external networks as a ListExtNet struct
|
// List gets list all available external networks
|
||||||
func (e ExtNet) List(ctx context.Context, req ListRequest) (*ListExtNet, error) {
|
func (e ExtNet) List(ctx context.Context, req ListRequest) (*ListExtNet, error) {
|
||||||
res, err := e.ListRaw(ctx, req)
|
url := "/cloudbroker/extnet/list"
|
||||||
|
|
||||||
|
res, err := e.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -61,11 +63,3 @@ func (e ExtNet) List(ctx context.Context, req ListRequest) (*ListExtNet, error)
|
|||||||
|
|
||||||
return &list, nil
|
return &list, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// ListRaw gets list of all available external networks as an array of bytes
|
|
||||||
func (e ExtNet) ListRaw(ctx context.Context, req ListRequest) ([]byte, error) {
|
|
||||||
url := "/cloudbroker/extnet/list"
|
|
||||||
|
|
||||||
res, err := e.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
|
||||||
return res, err
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -127,114 +127,27 @@ type ListExtNet struct {
|
|||||||
|
|
||||||
// Detailed information about external network
|
// Detailed information about external network
|
||||||
type RecordExtNet struct {
|
type RecordExtNet struct {
|
||||||
// CKey
|
// Main information about external network
|
||||||
CKey string `json:"_ckey"`
|
ItemExtNet
|
||||||
|
|
||||||
// Meta
|
// CheckIps
|
||||||
Meta []interface{} `json:"_meta"`
|
|
||||||
|
|
||||||
// CheckIPs
|
|
||||||
CheckIPs []string `json:"checkIps"`
|
CheckIPs []string `json:"checkIps"`
|
||||||
|
|
||||||
// Default
|
|
||||||
Default bool `json:"default"`
|
|
||||||
|
|
||||||
// Default QOS
|
|
||||||
DefaultQOS QOS `json:"defaultQos"`
|
|
||||||
|
|
||||||
// Description
|
|
||||||
Description string `json:"desc"`
|
|
||||||
|
|
||||||
// List DNS
|
// List DNS
|
||||||
DNS []string `json:"dns"`
|
DNS []string `json:"dns"`
|
||||||
|
|
||||||
// List excludes
|
// List excludes
|
||||||
Excluded ListReservations `json:"excluded"`
|
Excluded ListReservations `json:"excluded"`
|
||||||
|
|
||||||
// Free IPs number
|
|
||||||
FreeIPs uint64 `json:"free_ips"`
|
|
||||||
|
|
||||||
// Gateway
|
// Gateway
|
||||||
Gateway string `json:"gateway"`
|
Gateway string `json:"gateway"`
|
||||||
|
|
||||||
// Grid ID
|
|
||||||
GID uint64 `json:"gid"`
|
|
||||||
|
|
||||||
// GUID
|
|
||||||
GUID uint64 `json:"guid"`
|
|
||||||
|
|
||||||
// ID
|
|
||||||
ID uint64 `json:"id"`
|
|
||||||
|
|
||||||
// IPCIDR
|
|
||||||
IPCIDR string `json:"ipcidr"`
|
|
||||||
|
|
||||||
// Milestones
|
|
||||||
Milestones uint64 `json:"milestones"`
|
|
||||||
|
|
||||||
// Name
|
|
||||||
Name string `json:"name"`
|
|
||||||
|
|
||||||
// Network
|
// Network
|
||||||
Network string `json:"network"`
|
Network string `json:"network"`
|
||||||
|
|
||||||
// Network ID
|
|
||||||
NetworkID uint64 `json:"networkId"`
|
|
||||||
|
|
||||||
// OVSBridge
|
|
||||||
OVSBridge string `json:"ovsBridge"`
|
|
||||||
|
|
||||||
// PreReservationsNum
|
|
||||||
PreReservationsNum uint64 `json:"preReservationsNum"`
|
|
||||||
|
|
||||||
// Prefix
|
// Prefix
|
||||||
Prefix uint64 `json:"prefix"`
|
Prefix uint64 `json:"prefix"`
|
||||||
|
|
||||||
// PriVNFDevID
|
|
||||||
PriVNFDevID uint64 `json:"priVnfDevId"`
|
|
||||||
|
|
||||||
// List reservations
|
// List reservations
|
||||||
Reservations ListReservations `json:"reservations"`
|
Reservations ListReservations `json:"reservations"`
|
||||||
|
|
||||||
// List of shared with
|
|
||||||
SharedWith []interface{} `json:"sharedWith"`
|
|
||||||
|
|
||||||
// Status
|
|
||||||
Status string `json:"status"`
|
|
||||||
|
|
||||||
// VLAN ID
|
|
||||||
VLANID uint64 `json:"vlanId"`
|
|
||||||
|
|
||||||
// VNFs
|
|
||||||
VNFs VNFs `json:"vnfs"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// List of static routes
|
|
||||||
type ListStaticRoutes struct {
|
|
||||||
// Data
|
|
||||||
Data []ItemRoutes `json:"data"`
|
|
||||||
|
|
||||||
// Entry count
|
|
||||||
EntryCount uint64 `json:"entryCount"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// 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"`
|
|
||||||
}
|
|
||||||
@@ -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
|
|
||||||
}
|
|
||||||
@@ -8,16 +8,25 @@ import (
|
|||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
)
|
)
|
||||||
|
|
||||||
// GetRequest struct to get information about FLIPGroup
|
// Request struct for get information about FLIPGroup
|
||||||
type GetRequest struct {
|
type GetRequest struct {
|
||||||
// FLIPGroup ID
|
// FLIPGroup ID
|
||||||
// Required: true
|
// Required: true
|
||||||
FLIPGroupID uint64 `url:"flipgroupId" json:"flipgroupId" validate:"required"`
|
FLIPGroupID uint64 `url:"flipgroupId" json:"flipgroupId" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get gets details of the specified Floating IP group as a RecordFLIPGroup struct
|
// Get gets details of the specified Floating IP group
|
||||||
func (f FLIPGroup) Get(ctx context.Context, req GetRequest) (*RecordFLIPGroup, error) {
|
func (f FLIPGroup) Get(ctx context.Context, req GetRequest) (*RecordFLIPGroup, error) {
|
||||||
res, err := f.GetRaw(ctx, req)
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
for _, validationError := range validators.GetErrors(err) {
|
||||||
|
return nil, validators.ValidationError(validationError)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudbroker/flipgroup/get"
|
||||||
|
|
||||||
|
res, err := f.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -31,18 +40,3 @@ func (f FLIPGroup) Get(ctx context.Context, req GetRequest) (*RecordFLIPGroup, e
|
|||||||
|
|
||||||
return &info, nil
|
return &info, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetRaw gets details of the specified Floating IP group as an array of bytes
|
|
||||||
func (f FLIPGroup) GetRaw(ctx context.Context, req GetRequest) ([]byte, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
for _, validationError := range validators.GetErrors(err) {
|
|
||||||
return nil, validators.ValidationError(validationError)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudbroker/flipgroup/get"
|
|
||||||
|
|
||||||
res, err := f.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
|
||||||
return res, err
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ListRequest struct to get list of FLIPGroup available to the current user
|
// Request struct for get list FLIPGroup available to the current user
|
||||||
type ListRequest struct {
|
type ListRequest struct {
|
||||||
// Find by name
|
// Find by name
|
||||||
// Required: false
|
// Required: false
|
||||||
@@ -25,11 +25,11 @@ type ListRequest struct {
|
|||||||
ExtNetID uint64 `url:"extnetId,omitempty" json:"extnetId,omitempty"`
|
ExtNetID uint64 `url:"extnetId,omitempty" json:"extnetId,omitempty"`
|
||||||
|
|
||||||
// Find by IP
|
// Find by IP
|
||||||
// Required: false
|
// Reuqired: false
|
||||||
ByIP string `url:"byIp,omitempty" json:"byIp,omitempty"`
|
ByIP string `url:"byIp,omitempty" json:"byIp,omitempty"`
|
||||||
|
|
||||||
// Find by resource group ID
|
// Find by resource group ID
|
||||||
// Required: false
|
// Reuqired: false
|
||||||
RGID uint64 `url:"rgId,omitempty" json:"rgId,omitempty"`
|
RGID uint64 `url:"rgId,omitempty" json:"rgId,omitempty"`
|
||||||
|
|
||||||
// Find by id
|
// Find by id
|
||||||
@@ -45,9 +45,11 @@ type ListRequest struct {
|
|||||||
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// List gets list of FLIPGroup managed cluster instances available to the current user as a ListFLIPGroups struct
|
// List gets list FLIPGroup managed cluster instances available to the current user
|
||||||
func (f FLIPGroup) List(ctx context.Context, req ListRequest) (*ListFLIPGroups, error) {
|
func (f FLIPGroup) List(ctx context.Context, req ListRequest) (*ListFLIPGroups, error) {
|
||||||
res, err := f.ListRaw(ctx, req)
|
url := "/cloudbroker/flipgroup/list"
|
||||||
|
|
||||||
|
res, err := f.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -61,11 +63,3 @@ func (f FLIPGroup) List(ctx context.Context, req ListRequest) (*ListFLIPGroups,
|
|||||||
|
|
||||||
return &list, nil
|
return &list, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// ListRaw gets list of FLIPGroup managed cluster instances available to the current user as an array of bytes
|
|
||||||
func (f FLIPGroup) ListRaw(ctx context.Context, req ListRequest) ([]byte, error) {
|
|
||||||
url := "/cloudbroker/flipgroup/list"
|
|
||||||
|
|
||||||
res, err := f.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
|
||||||
return res, err
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -9,15 +9,6 @@ func (lg ListGrids) FilterByID(id uint64) ListGrids {
|
|||||||
return lg.FilterFunc(predicate)
|
return lg.FilterFunc(predicate)
|
||||||
}
|
}
|
||||||
|
|
||||||
// FilterByGID returns ListGrids with specified GID.
|
|
||||||
func (lg ListGrids) FilterByGID(gid uint64) ListGrids {
|
|
||||||
predicate := func(rg ItemGridList) bool {
|
|
||||||
return rg.GID == gid
|
|
||||||
}
|
|
||||||
|
|
||||||
return lg.FilterFunc(predicate)
|
|
||||||
}
|
|
||||||
|
|
||||||
// FilterByName returns ListGrids with specified Name.
|
// FilterByName returns ListGrids with specified Name.
|
||||||
func (lg ListGrids) FilterByName(name string) ListGrids {
|
func (lg ListGrids) FilterByName(name string) ListGrids {
|
||||||
predicate := func(rg ItemGridList) bool {
|
predicate := func(rg ItemGridList) bool {
|
||||||
|
|||||||
@@ -106,14 +106,6 @@ func TestFilterByID(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestFilterByGID(t *testing.T) {
|
|
||||||
actual := grids.FilterByGID(777).FindOne()
|
|
||||||
|
|
||||||
if actual.GID != 777 {
|
|
||||||
t.Fatal("expected ID 777, found: ", actual.GID)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestFilterByName(t *testing.T) {
|
func TestFilterByName(t *testing.T) {
|
||||||
actual := grids.FilterByName("gamma").FindOne()
|
actual := grids.FilterByName("gamma").FindOne()
|
||||||
|
|
||||||
|
|||||||
@@ -8,16 +8,25 @@ import (
|
|||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
)
|
)
|
||||||
|
|
||||||
// GetRequest struct to get grid details
|
// Request struct for get grid details
|
||||||
type GetRequest struct {
|
type GetRequest struct {
|
||||||
// Grid (platform) ID
|
// Grid (platform) ID
|
||||||
// Required: true
|
// Required: true
|
||||||
GID uint64 `url:"gridId" json:"gridId" validate:"required"`
|
GID uint64 `url:"gridId" json:"gridId" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get gets information about grid by ID as a RecordGrid struct
|
// Get gets information about grid by ID
|
||||||
func (g Grid) Get(ctx context.Context, req GetRequest) (*RecordGrid, error) {
|
func (g Grid) Get(ctx context.Context, req GetRequest) (*RecordGrid, error) {
|
||||||
res, err := g.GetRaw(ctx, req)
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
for _, validationError := range validators.GetErrors(err) {
|
||||||
|
return nil, validators.ValidationError(validationError)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudbroker/grid/get"
|
||||||
|
|
||||||
|
res, err := g.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -31,18 +40,3 @@ func (g Grid) Get(ctx context.Context, req GetRequest) (*RecordGrid, error) {
|
|||||||
|
|
||||||
return &info, nil
|
return &info, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetRaw gets information about grid by ID as an array of bytes
|
|
||||||
func (g Grid) GetRaw(ctx context.Context, req GetRequest) ([]byte, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
for _, validationError := range validators.GetErrors(err) {
|
|
||||||
return nil, validators.ValidationError(validationError)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudbroker/grid/get"
|
|
||||||
|
|
||||||
res, err := g.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
|
||||||
return res, err
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ListRequest struct to get list of locations
|
// Request struct for get list locations
|
||||||
type ListRequest struct {
|
type ListRequest struct {
|
||||||
// Find by id grid
|
// Find by id grid
|
||||||
// Required: false
|
// Required: false
|
||||||
@@ -25,9 +25,11 @@ type ListRequest struct {
|
|||||||
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// List gets list of all locations as a ListGrids struct
|
// List gets list all locations
|
||||||
func (g Grid) List(ctx context.Context, req ListRequest) (*ListGrids, error) {
|
func (g Grid) List(ctx context.Context, req ListRequest) (*ListGrids, error) {
|
||||||
res, err := g.ListRaw(ctx, req)
|
url := "/cloudbroker/grid/list"
|
||||||
|
|
||||||
|
res, err := g.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -41,11 +43,3 @@ func (g Grid) List(ctx context.Context, req ListRequest) (*ListGrids, error) {
|
|||||||
|
|
||||||
return &list, nil
|
return &list, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// ListRaw gets list of all locations as an array of bytes
|
|
||||||
func (g Grid) ListRaw(ctx context.Context, req ListRequest) ([]byte, error) {
|
|
||||||
url := "/cloudbroker/grid/list"
|
|
||||||
|
|
||||||
res, err := g.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
|
||||||
return res, err
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -8,16 +8,25 @@ import (
|
|||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
)
|
)
|
||||||
|
|
||||||
// GetRequest struct to get details of the specified group.
|
// Reuqest struct for getting details of the specified group.
|
||||||
type GetRequest struct {
|
type GetRequest struct {
|
||||||
// Group ID
|
// Group ID
|
||||||
// Required: true
|
// Required: true
|
||||||
GroupID string `url:"groupId" json:"groupId" validate:"required"`
|
GroupID string `url:"groupId" json:"groupId" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get gets details of the specified group as an ItemGroup struct
|
// Get gets details of the specified group.
|
||||||
func (g Group) Get(ctx context.Context, req GetRequest) (*ItemGroup, error) {
|
func (g Group) Get(ctx context.Context, req GetRequest) (*ItemGroup, error) {
|
||||||
res, err := g.GetRaw(ctx, req)
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
for _, validationError := range validators.GetErrors(err) {
|
||||||
|
return nil, validators.ValidationError(validationError)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudbroker/group/get"
|
||||||
|
|
||||||
|
res, err := g.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -31,18 +40,3 @@ func (g Group) Get(ctx context.Context, req GetRequest) (*ItemGroup, error) {
|
|||||||
|
|
||||||
return &info, nil
|
return &info, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetRaw gets details of the specified group as an array of bytes
|
|
||||||
func (g Group) GetRaw(ctx context.Context, req GetRequest) ([]byte, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
for _, validationError := range validators.GetErrors(err) {
|
|
||||||
return nil, validators.ValidationError(validationError)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudbroker/group/get"
|
|
||||||
|
|
||||||
res, err := g.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
|
||||||
return res, err
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import (
|
|||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ListRequest struct to get list of group instances.
|
// Request struct for getting list of group instances.
|
||||||
type ListRequest struct {
|
type ListRequest struct {
|
||||||
// Find by id.
|
// Find by id.
|
||||||
// Requires: false
|
// Requires: false
|
||||||
@@ -31,9 +31,17 @@ type ListRequest struct {
|
|||||||
Active bool `url:"active" json:"active" validate:"required"`
|
Active bool `url:"active" json:"active" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// List gets list of group instances as a ListGroups struct
|
|
||||||
func (g Group) List(ctx context.Context, req ListRequest) (*ListGroups, error) {
|
func (g Group) List(ctx context.Context, req ListRequest) (*ListGroups, error) {
|
||||||
res, err := g.ListRaw(ctx, req)
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
for _, validationError := range validators.GetErrors(err) {
|
||||||
|
return nil, validators.ValidationError(validationError)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudbroker/group/list"
|
||||||
|
|
||||||
|
res, err := g.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -47,18 +55,3 @@ func (g Group) List(ctx context.Context, req ListRequest) (*ListGroups, error) {
|
|||||||
|
|
||||||
return &info, nil
|
return &info, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// ListRaw gets list of group instances as an array of bytes
|
|
||||||
func (g Group) ListRaw(ctx context.Context, req ListRequest) ([]byte, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
for _, validationError := range validators.GetErrors(err) {
|
|
||||||
return nil, validators.ValidationError(validationError)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudbroker/group/list"
|
|
||||||
|
|
||||||
res, err := g.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
|
||||||
return res, err
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -8,32 +8,15 @@ import (
|
|||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
)
|
)
|
||||||
|
|
||||||
// GetRequest struct to get image details
|
// Request struct for get image details
|
||||||
type GetRequest struct {
|
type GetRequest struct {
|
||||||
// ID of image
|
// ID of image
|
||||||
// Required: true
|
// Required: true
|
||||||
ImageID uint64 `url:"imageId" json:"imageId" validate:"required"`
|
ImageID uint64 `url:"imageId" json:"imageId" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get gets image details by ID as a RecordImage struct
|
// Get get image details by ID
|
||||||
func (i Image) Get(ctx context.Context, req GetRequest) (*RecordImage, error) {
|
func (i Image) Get(ctx context.Context, req GetRequest) (*RecordImage, error) {
|
||||||
res, err := i.GetRaw(ctx, req)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
info := RecordImage{}
|
|
||||||
|
|
||||||
err = json.Unmarshal(res, &info)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return &info, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetRaw gets image details by ID as an array of bytes
|
|
||||||
func (i Image) GetRaw(ctx context.Context, req GetRequest) ([]byte, 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) {
|
||||||
@@ -43,6 +26,17 @@ func (i Image) GetRaw(ctx context.Context, req GetRequest) ([]byte, error) {
|
|||||||
|
|
||||||
url := "/cloudbroker/image/get"
|
url := "/cloudbroker/image/get"
|
||||||
|
|
||||||
|
info := RecordImage{}
|
||||||
|
|
||||||
res, err := i.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
res, err := i.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
return res, err
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
err = json.Unmarshal(res, &info)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return &info, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ListRequest struct to get list of available images
|
// Request struct for get list available images
|
||||||
type ListRequest struct {
|
type ListRequest struct {
|
||||||
// Filter images by storage endpoint provider ID
|
// Filter images by storage endpoint provider ID
|
||||||
// Required: false
|
// Required: false
|
||||||
@@ -65,9 +65,11 @@ type ListRequest struct {
|
|||||||
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// List gets list of information about images as a ListImages struct
|
// List gets list of information about images
|
||||||
func (i Image) List(ctx context.Context, req ListRequest) (*ListImages, error) {
|
func (i Image) List(ctx context.Context, req ListRequest) (*ListImages, error) {
|
||||||
res, err := i.ListRaw(ctx, req)
|
url := "/cloudbroker/image/list"
|
||||||
|
|
||||||
|
res, err := i.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -81,11 +83,3 @@ func (i Image) List(ctx context.Context, req ListRequest) (*ListImages, error) {
|
|||||||
|
|
||||||
return &list, nil
|
return &list, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// ListRaw gets list of information about images as an array of bytes
|
|
||||||
func (i Image) ListRaw(ctx context.Context, req ListRequest) ([]byte, error) {
|
|
||||||
url := "/cloudbroker/image/list"
|
|
||||||
|
|
||||||
res, err := i.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
|
||||||
return res, err
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -176,10 +176,10 @@ type GUID string
|
|||||||
func (r *GUID) UnmarshalJSON(b []byte) error {
|
func (r *GUID) UnmarshalJSON(b []byte) error {
|
||||||
|
|
||||||
if b[0] == '"' {
|
if b[0] == '"' {
|
||||||
*r = GUID(string(b[1 : len(b)-1]))
|
*r = GUID(string(b[1:len(b)-1]))
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
*r = GUID(string(b))
|
*r = GUID(string(b))
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
@@ -190,167 +190,74 @@ type ListHistory []History
|
|||||||
|
|
||||||
// List stacks
|
// List stacks
|
||||||
type ListStacks struct {
|
type ListStacks struct {
|
||||||
// Data
|
Data []struct {
|
||||||
Data []ItemListStacks `json:"data"`
|
// CKey
|
||||||
|
CKey string `json:"_ckey"`
|
||||||
|
|
||||||
|
// Meta
|
||||||
|
Meta []interface{} `json:"_meta"`
|
||||||
|
|
||||||
|
// API URL
|
||||||
|
APIURL string `json:"apiUrl"`
|
||||||
|
|
||||||
|
// API key
|
||||||
|
APIKey string `json:"apikey"`
|
||||||
|
|
||||||
|
// App ID
|
||||||
|
AppID string `json:"appId"`
|
||||||
|
|
||||||
|
// CPU allocation ratio
|
||||||
|
CPUAllocationRatio float64 `json:"cpu_allocation_ratio"`
|
||||||
|
|
||||||
|
// Description
|
||||||
|
Description string `json:"desc"`
|
||||||
|
|
||||||
|
// Descr
|
||||||
|
Descr string `json:"descr"`
|
||||||
|
|
||||||
|
// Drivers
|
||||||
|
Drivers []string `json:"drivers"`
|
||||||
|
|
||||||
|
// Eco
|
||||||
|
Eco interface{} `json:"eco"`
|
||||||
|
|
||||||
|
// Error
|
||||||
|
Error uint64 `json:"error"`
|
||||||
|
|
||||||
|
// Grid ID
|
||||||
|
GID uint64 `json:"gid"`
|
||||||
|
|
||||||
|
// GID
|
||||||
|
GUID uint64 `json:"guid"`
|
||||||
|
|
||||||
|
// ID
|
||||||
|
ID uint64 `json:"id"`
|
||||||
|
|
||||||
|
// List image IDs
|
||||||
|
Images []uint64 `json:"images"`
|
||||||
|
|
||||||
|
// Login
|
||||||
|
Login string `json:"login"`
|
||||||
|
|
||||||
|
// Mem allocation ratio
|
||||||
|
// Required: false
|
||||||
|
MemAllocationRatio float64 `json:"mem_allocation_ratio"`
|
||||||
|
|
||||||
|
// Name
|
||||||
|
Name string `json:"name"`
|
||||||
|
|
||||||
|
// Password
|
||||||
|
Password string `json:"passwd"`
|
||||||
|
|
||||||
|
// Reference ID
|
||||||
|
ReferenceID string `json:"referenceId"`
|
||||||
|
|
||||||
|
// Status
|
||||||
|
Status string `json:"status"`
|
||||||
|
|
||||||
|
// Type
|
||||||
|
Type string `json:"type"`
|
||||||
|
} `json:"data"`
|
||||||
|
|
||||||
// Entry count
|
|
||||||
EntryCount uint64 `json:"entryCount"`
|
EntryCount uint64 `json:"entryCount"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Detailed information about image
|
|
||||||
type ItemListStacks struct {
|
|
||||||
// CKey
|
|
||||||
CKey string `json:"_ckey"`
|
|
||||||
|
|
||||||
// Meta
|
|
||||||
Meta []interface{} `json:"_meta"`
|
|
||||||
|
|
||||||
// API URL
|
|
||||||
APIURL string `json:"apiUrl"`
|
|
||||||
|
|
||||||
// API key
|
|
||||||
APIKey string `json:"apikey"`
|
|
||||||
|
|
||||||
// App ID
|
|
||||||
AppID string `json:"appId"`
|
|
||||||
|
|
||||||
// CPU allocation ratio
|
|
||||||
CPUAllocationRatio float64 `json:"cpu_allocation_ratio"`
|
|
||||||
|
|
||||||
// Description
|
|
||||||
Description string `json:"desc"`
|
|
||||||
|
|
||||||
// Descr
|
|
||||||
Descr string `json:"descr"`
|
|
||||||
|
|
||||||
// Drivers
|
|
||||||
Drivers []string `json:"drivers"`
|
|
||||||
|
|
||||||
// Eco
|
|
||||||
Eco interface{} `json:"eco"`
|
|
||||||
|
|
||||||
// Error
|
|
||||||
Error uint64 `json:"error"`
|
|
||||||
|
|
||||||
// Grid ID
|
|
||||||
GID uint64 `json:"gid"`
|
|
||||||
|
|
||||||
// GID
|
|
||||||
GUID uint64 `json:"guid"`
|
|
||||||
|
|
||||||
// ID
|
|
||||||
ID uint64 `json:"id"`
|
|
||||||
|
|
||||||
// List image IDs
|
|
||||||
Images []uint64 `json:"images"`
|
|
||||||
|
|
||||||
// Login
|
|
||||||
Login string `json:"login"`
|
|
||||||
|
|
||||||
// Mem allocation ratio
|
|
||||||
MemAllocationRatio float64 `json:"mem_allocation_ratio"`
|
|
||||||
|
|
||||||
// Name
|
|
||||||
Name string `json:"name"`
|
|
||||||
|
|
||||||
// Packegas
|
|
||||||
Packages Packages `json:"packages"`
|
|
||||||
|
|
||||||
// Password
|
|
||||||
Password string `json:"passwd"`
|
|
||||||
|
|
||||||
// Reference ID
|
|
||||||
ReferenceID string `json:"referenceId"`
|
|
||||||
|
|
||||||
// Status
|
|
||||||
Status string `json:"status"`
|
|
||||||
|
|
||||||
// Type
|
|
||||||
Type string `json:"type"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// Package
|
|
||||||
type Packages struct {
|
|
||||||
// LibvirtBin
|
|
||||||
LibvirtBin LibvirtBin `json:"libvirt-bin"`
|
|
||||||
|
|
||||||
// LibvirtDaemon
|
|
||||||
LibvirtDaemon LibvirtDaemon `json:"libvirt-daemon"`
|
|
||||||
|
|
||||||
// Lvm2Lockd
|
|
||||||
Lvm2Lockd Lvm2Lockd `json:"lvm2-lockd"`
|
|
||||||
|
|
||||||
// OpenvswitchCommon
|
|
||||||
OpenvswitchCommon OpenvswitchCommon `json:"openvswitch-common"`
|
|
||||||
|
|
||||||
// OpenvswitchSwitch
|
|
||||||
OpenvswitchSwitch OpenvswitchSwitch `json:"openvswitch-switch"`
|
|
||||||
|
|
||||||
// QemuSystemX86
|
|
||||||
QemuSystemX86 QemuSystemX86 `json:"qemu-system-x86"`
|
|
||||||
|
|
||||||
// Sanlock
|
|
||||||
Sanlock Sanlock `json:"sanlock"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// LibvirtBin
|
|
||||||
type LibvirtBin struct {
|
|
||||||
// InstalledSize
|
|
||||||
InstalledSize string `json:"installed_size"`
|
|
||||||
|
|
||||||
// Version
|
|
||||||
Ver string `json:"ver"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type LibvirtDaemon struct {
|
|
||||||
// InstalledSize
|
|
||||||
InstalledSize string `json:"installed_size"`
|
|
||||||
|
|
||||||
// Version
|
|
||||||
Ver string `json:"ver"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// Lvm2Lockd
|
|
||||||
type Lvm2Lockd struct {
|
|
||||||
// InstalledSize
|
|
||||||
InstalledSize string `json:"installed_size"`
|
|
||||||
|
|
||||||
// Version
|
|
||||||
Ver string `json:"ver"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// OpenvswitchCommon
|
|
||||||
type OpenvswitchCommon struct {
|
|
||||||
// InstalledSize
|
|
||||||
InstalledSize string `json:"installed_size"`
|
|
||||||
|
|
||||||
// Version
|
|
||||||
Ver string `json:"ver"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// OpenvswitchSwitch
|
|
||||||
type OpenvswitchSwitch struct {
|
|
||||||
// InstalledSize
|
|
||||||
InstalledSize string `json:"installed_size"`
|
|
||||||
|
|
||||||
// Version
|
|
||||||
Ver string `json:"ver"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// QemuSystemX86
|
|
||||||
type QemuSystemX86 struct {
|
|
||||||
// InstalledSize
|
|
||||||
InstalledSize string `json:"installed_size"`
|
|
||||||
|
|
||||||
// Version
|
|
||||||
Ver string `json:"ver"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// Sanlock
|
|
||||||
type Sanlock struct {
|
|
||||||
// InstalledSize
|
|
||||||
InstalledSize string `json:"installed_size"`
|
|
||||||
|
|
||||||
// Version
|
|
||||||
Ver string `json:"ver"`
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -8,16 +8,25 @@ import (
|
|||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
)
|
)
|
||||||
|
|
||||||
// GetRequest struct to get information about K8CI
|
// Request struct for get information about K8CI
|
||||||
type GetRequest struct {
|
type GetRequest struct {
|
||||||
// ID of the K8 catalog item to get
|
// ID of the K8 catalog item to get
|
||||||
// Required: true
|
// Required: true
|
||||||
K8CIID uint64 `url:"k8ciId" json:"k8ciId" validate:"required"`
|
K8CIID uint64 `url:"k8ciId" json:"k8ciId" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get gets details of the specified K8 catalog item as a RecordK8CI struct
|
// Get gets details of the specified K8 catalog item
|
||||||
func (k K8CI) Get(ctx context.Context, req GetRequest) (*RecordK8CI, error) {
|
func (k K8CI) Get(ctx context.Context, req GetRequest) (*RecordK8CI, error) {
|
||||||
res, err := k.GetRaw(ctx, req)
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
for _, validationError := range validators.GetErrors(err) {
|
||||||
|
return nil, validators.ValidationError(validationError)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudbroker/k8ci/get"
|
||||||
|
|
||||||
|
res, err := k.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -31,18 +40,3 @@ func (k K8CI) Get(ctx context.Context, req GetRequest) (*RecordK8CI, error) {
|
|||||||
|
|
||||||
return &item, nil
|
return &item, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetRaw gets details of the specified K8 catalog item as an array of bytes
|
|
||||||
func (k K8CI) GetRaw(ctx context.Context, req GetRequest) ([]byte, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
for _, validationError := range validators.GetErrors(err) {
|
|
||||||
return nil, validators.ValidationError(validationError)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudbroker/k8ci/get"
|
|
||||||
|
|
||||||
res, err := k.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
|
||||||
return res, err
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ListRequest struct to get list information about images
|
// Request struct for get list information about images
|
||||||
type ListRequest struct {
|
type ListRequest struct {
|
||||||
// Find by ID
|
// Find by ID
|
||||||
// Required: false
|
// Required: false
|
||||||
@@ -45,9 +45,11 @@ type ListRequest struct {
|
|||||||
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// List gets list of all k8ci catalog items available to the current user as a ListK8CI struct
|
// List gets list all k8ci catalog items available to the current user
|
||||||
func (k K8CI) List(ctx context.Context, req ListRequest) (*ListK8CI, error) {
|
func (k K8CI) List(ctx context.Context, req ListRequest) (*ListK8CI, error) {
|
||||||
res, err := k.ListRaw(ctx, req)
|
url := "/cloudbroker/k8ci/list"
|
||||||
|
|
||||||
|
res, err := k.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -61,11 +63,3 @@ func (k K8CI) List(ctx context.Context, req ListRequest) (*ListK8CI, error) {
|
|||||||
|
|
||||||
return &list, nil
|
return &list, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// ListRaw gets list of all k8ci catalog items available to the current user as an array of bytes
|
|
||||||
func (k K8CI) ListRaw(ctx context.Context, req ListRequest) ([]byte, error) {
|
|
||||||
url := "/cloudbroker/k8ci/list"
|
|
||||||
|
|
||||||
res, err := k.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
|
||||||
return res, err
|
|
||||||
}
|
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user