Compare commits
11 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c7a2c4ed5a | ||
| 0c44daa241 | |||
|
|
650b1c158b | ||
| 8a101c6fcb | |||
|
|
3f21a89e80 | ||
| cbce7f434f | |||
| e04dc42d2b | |||
|
|
88eb9e8898 | ||
| 9ec34c6bfc | |||
| 80491ed643 | |||
| f1e0f7abb6 |
5
.gitignore
vendored
5
.gitignore
vendored
@@ -3,3 +3,8 @@ cmd/
|
|||||||
.vscode/
|
.vscode/
|
||||||
.fleet/
|
.fleet/
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
tests/platform_upgrade/.env
|
||||||
|
tests/platform_upgrade/input.json
|
||||||
|
tests/platform_upgrade/*.txt
|
||||||
|
tests/platform_upgrade/*.log
|
||||||
|
*.env
|
||||||
|
|||||||
60
CHANGELOG.md
60
CHANGELOG.md
@@ -1,5 +1,59 @@
|
|||||||
## Version 1.8.2
|
## Version 1.11.3
|
||||||
|
|
||||||
### Feature
|
### Добавлено
|
||||||
|
|
||||||
- Add universal client for connections
|
### account
|
||||||
|
| Идентификатор<br>задачи | Описание |
|
||||||
|
| --- | --- |
|
||||||
|
| BGOS-467 | Опциональные поля `Name` и `Reason` в структуре запроса `DeleteRequest` в cloudbroker/account |
|
||||||
|
|
||||||
|
### apiaccess
|
||||||
|
| Идентификатор<br>задачи | Описание |
|
||||||
|
| --- | --- |
|
||||||
|
| BGOS-470 | Опциональное поле `Desc` в структуре запроса `ListRequest` в cloudbroker/apiaccess |
|
||||||
|
|
||||||
|
#### bservice
|
||||||
|
| Идентификатор<br>задачи | Описание |
|
||||||
|
| --- | --- |
|
||||||
|
| BGOS-361 | Группа ручек `bservice` в cloudbroker/bservice |
|
||||||
|
|
||||||
|
#### location
|
||||||
|
| Идентификатор<br>задачи | Описание |
|
||||||
|
| --- | --- |
|
||||||
|
| BGOS-471 | Поле `SDNSupport` в возвращаемой модели `ItemLocation` в cloudbroker/location |
|
||||||
|
|
||||||
|
### Исправлено
|
||||||
|
|
||||||
|
#### disks
|
||||||
|
| Идентификатор<br>задачи | Описание |
|
||||||
|
| --- | --- |
|
||||||
|
| BGOS-468 | Исправлен тип поля `UpdatedBy` c uint64 на string в структурах ответа `ItemComputeDisk` в cloudapi/disks и `ItemDisk` в cloudbroker/disks |
|
||||||
|
|
||||||
|
#### kvmvm
|
||||||
|
| Идентификатор<br>задачи | Описание |
|
||||||
|
| --- | --- |
|
||||||
|
| BGOS-433 | Исправлена ошибка валидации поля LoaderType для всех структур в cloudapi/compute и в cloudbroker/compute |
|
||||||
|
| BGOS-458 | Изменен тип параметров `CPUPin`, `HPBacked`, `AutoStart`, `HotResize` с bool на interface в структуре `UpdateRequest` cloudapi/compute и в cloudbroker/compute |
|
||||||
|
|
||||||
|
#### node
|
||||||
|
| Идентификатор<br>задачи | Описание |
|
||||||
|
| --- | --- |
|
||||||
|
| BGOS-472 | Исправлен тип поля `NumaNode` c uint64 на int в структуре ответа `Backplane1` в cloudbroker/node |
|
||||||
|
| BGOS-428 | Поле `Message` заменено на `Reason` в структуре запроса `EnableNodesRequest` в cloudbroker/node |
|
||||||
|
|
||||||
|
### Удалено
|
||||||
|
|
||||||
|
### compute
|
||||||
|
| Идентификатор<br>задачи | Описание |
|
||||||
|
| --- | --- |
|
||||||
|
| BGOS-469 | Опциональное поле `SepID` в структуре запроса `CreateTemplateFromBlankRequest` в cloudapi/compute и cloudbroker/compute |
|
||||||
|
|
||||||
|
### disks
|
||||||
|
| Идентификатор<br>задачи | Описание |
|
||||||
|
| --- | --- |
|
||||||
|
| BGOS-469 | Опциональное поле `SepID` в структуре запроса `FromPlatformDiskRequest` в cloudapi/disks и cloudbroker/disks |
|
||||||
|
|
||||||
|
#### rg
|
||||||
|
| Идентификатор<br>задачи | Описание |
|
||||||
|
| --- | --- |
|
||||||
|
| BGOS-427 | Поле `RegisterComputes` в структурах ответа `RecordResourceGroup`, `ItemResourceGroup` в cloudapi/rg и `ItemRG` в cloudbroker/rg |
|
||||||
|
|||||||
2
LICENSE
2
LICENSE
@@ -186,7 +186,7 @@ APPENDIX: How to apply the Apache License to your work.
|
|||||||
same "printed page" as the copyright notice for easier
|
same "printed page" as the copyright notice for easier
|
||||||
identification within third-party archives.
|
identification within third-party archives.
|
||||||
|
|
||||||
Copyright [yyyy] [name of copyright owner]
|
Copyright 2022 Basis LTD
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
|
|||||||
42
README.md
42
README.md
@@ -1,6 +1,6 @@
|
|||||||
# Decort SDK
|
# Decort SDK
|
||||||
|
|
||||||
Decort SDK - это библиотека, написанная на языке GO, позволяющая взаимодействовать с API облачной платформы **DECORT**. Библиотека содеражит в себе структуры и методы, необходимые для отправки запросов. Decort SDK имеет встроенный http-клиент и поддерживает разные способы авторизации на платформе. Библиотека так же содержит в себе модели ответов от платформы.
|
Decort SDK - это библиотека, написанная на языке GO, позволяющая взаимодействовать с API облачной платформы **DECORT**. Библиотека содержит в себе структуры и методы, необходимые для отправки запросов. Decort SDK имеет встроенный http-клиент и поддерживает разные способы авторизации на платформе. Библиотека так же содержит в себе модели ответов от платформы.
|
||||||
|
|
||||||
## Версии
|
## Версии
|
||||||
|
|
||||||
@@ -13,6 +13,9 @@ Decort SDK - это библиотека, написанная на языке G
|
|||||||
- Версия 1.6.x Decort-SDK соответствует 3.8.8 версии платформы
|
- Версия 1.6.x Decort-SDK соответствует 3.8.8 версии платформы
|
||||||
- Версия 1.7.х Decort-SDK соответствует 3.8.9 версии платформы
|
- Версия 1.7.х Decort-SDK соответствует 3.8.9 версии платформы
|
||||||
- Версия 1.8.х Decort-SDK соответствует 4.0.0 версии платформы
|
- Версия 1.8.х Decort-SDK соответствует 4.0.0 версии платформы
|
||||||
|
- Версия 1.9.х Decort-SDK соответствует 4.1.0 версии платформы
|
||||||
|
- Версия 1.10.х Decort-SDK соответствует 4.2.0 версии платформы
|
||||||
|
- Версия 1.11.х Decort-SDK соответствует 4.3.0 версии платформы
|
||||||
|
|
||||||
## Оглавление
|
## Оглавление
|
||||||
|
|
||||||
@@ -98,20 +101,22 @@ go get -u repository.basistech.ru/BASIS/decort-golang-sdk
|
|||||||
Данная группа ручек позволяет выполнять следующие операции в платформе:
|
Данная группа ручек позволяет выполнять следующие операции в платформе:
|
||||||
|
|
||||||
- `Account` - управление аккаунтами - внутренними учетными записями платформы, которые являются владельцами вычислительных ресурсов;
|
- `Account` - управление аккаунтами - внутренними учетными записями платформы, которые являются владельцами вычислительных ресурсов;
|
||||||
|
- `Audit` - получение информации о событиях системы;
|
||||||
- `BService` - управление группами виртуальных машин (computes);
|
- `BService` - управление группами виртуальных машин (computes);
|
||||||
- `Compute` - управление виртуальными машинами (индивидуально);
|
- `Compute` - управление виртуальными машинами (индивидуально);
|
||||||
- `Disks` - управление виртуальными дисками;
|
- `Disks` - управление виртуальными дисками;
|
||||||
|
- `DPDK` - управление виртуальными сетями DPDK;
|
||||||
- `ExtNet` - управление виртуальными сетями, отвечающими за внешний доступ;
|
- `ExtNet` - управление виртуальными сетями, отвечающими за внешний доступ;
|
||||||
- `FLIPgroup` - управление группами "плавающими" ip - адресами;
|
- `FLIPgroup` - управление группами "плавающими" ip - адресами;
|
||||||
- `Image` - управление образами операционных систем;
|
- `Image` - управление образами операционных систем;
|
||||||
- `K8CI` - получение информации о конвейере для создания кластера;
|
- `K8CI` - получение информации о конвейере для создания кластера;
|
||||||
- `K8S` - управление кластерами kubernetes;
|
- `K8S` - управление кластерами kubernetes;
|
||||||
- `KVMPPC` - создание виртуальной машины Power PC (IBM);
|
|
||||||
- `KVMx86` - создание виртуальной машины x86;
|
- `KVMx86` - создание виртуальной машины x86;
|
||||||
- `LB` - управление балансировщиками нагрузки;
|
- `LB` - управление балансировщиками нагрузки;
|
||||||
- `Locations` - получение информации о grid площадки;
|
- `Locations` - получение информации о grid площадки;
|
||||||
|
- `Prometheus` - получение статистики prometheus;
|
||||||
- `RG` - управление ресурсными группами аккаунта;
|
- `RG` - управление ресурсными группами аккаунта;
|
||||||
- `Sizes` - получение информации о потребляемых ресурсах виртуальными машинами и дисками;
|
- `SEP` - управление storage endpoint (sep);
|
||||||
- `Stack` - получение информации о вычислительных узлах;
|
- `Stack` - получение информации о вычислительных узлах;
|
||||||
- `Tasks` - получение информации о ходе выполнения асинхронных задач (например, создание кластера);
|
- `Tasks` - получение информации о ходе выполнения асинхронных задач (например, создание кластера);
|
||||||
- `VFPool` - управление пулом виртуальных сетевых функций;
|
- `VFPool` - управление пулом виртуальных сетевых функций;
|
||||||
@@ -123,10 +128,12 @@ go get -u repository.basistech.ru/BASIS/decort-golang-sdk
|
|||||||
Данная группа ручек позволяет выполнять следующие операции в платформе:
|
Данная группа ручек позволяет выполнять следующие операции в платформе:
|
||||||
|
|
||||||
- `Account` - управление аккаунтами - внутренними учетными записями платформы, которые являются владельцами вычислительных ресурсов;
|
- `Account` - управление аккаунтами - внутренними учетными записями платформы, которые являются владельцами вычислительных ресурсов;
|
||||||
|
- `Audit` - получение информации о событиях системы;
|
||||||
- `APIAccess` - управление доступом к API и его объектам;
|
- `APIAccess` - управление доступом к API и его объектам;
|
||||||
- `Backup` - управление резервным копированием;
|
- `Backup` - управление резервным копированием;
|
||||||
- `Compute` - управление виртуальными машинами (индивидуально);
|
- `Compute` - управление виртуальными машинами (индивидуально);
|
||||||
- `Disks` - управление виртуальными дисками;
|
- `Disks` - управление виртуальными дисками;
|
||||||
|
- `DPDK` - управление виртуальными сетями DPDK;
|
||||||
- `ExtNet` - управление виртуальными сетями, отвечающими за внешний доступ;
|
- `ExtNet` - управление виртуальными сетями, отвечающими за внешний доступ;
|
||||||
- `FLIPGroup` - управление группами с «плавающими» ip адресами;
|
- `FLIPGroup` - управление группами с «плавающими» ip адресами;
|
||||||
- `Grid` - управление площадками;
|
- `Grid` - управление площадками;
|
||||||
@@ -134,11 +141,12 @@ go get -u repository.basistech.ru/BASIS/decort-golang-sdk
|
|||||||
- `Image` - управление образами операционных систем;
|
- `Image` - управление образами операционных систем;
|
||||||
- `K8CI` - управление конвейром для создания кластера;
|
- `K8CI` - управление конвейром для создания кластера;
|
||||||
- `K8S` - управление кластерами kubernetes;
|
- `K8S` - управление кластерами kubernetes;
|
||||||
- `KVMPPC` - создание виртуальной машины Power PC (IBM);
|
|
||||||
- `KVMx86` - создание виртуальной машины x86;
|
- `KVMx86` - создание виртуальной машины x86;
|
||||||
- `LB` - управление балансировщиками нагрузки;
|
- `LB` - управление балансировщиками нагрузки;
|
||||||
- `Node` - управление нодами платформы;
|
- `Node` - управление нодами платформы;
|
||||||
- `PCIDevice` - управление устройствами;
|
- `PCIDevice` - управление устройствами;
|
||||||
|
- `Prometheus` - получение статистики prometheus;
|
||||||
|
- `Resmon` - получение статистики resource monitoring;
|
||||||
- `RG` - управление ресурсными группами аккаунта;
|
- `RG` - управление ресурсными группами аккаунта;
|
||||||
- `SEP` - управление storage endpoint (sep);
|
- `SEP` - управление storage endpoint (sep);
|
||||||
- `Stack` - получение информации о вычислительных узлах;
|
- `Stack` - получение информации о вычислительных узлах;
|
||||||
@@ -279,30 +287,34 @@ func main() {
|
|||||||
|
|
||||||
- **cloudapi**:
|
- **cloudapi**:
|
||||||
- `pkg/cloudapi/account` - для `Account`
|
- `pkg/cloudapi/account` - для `Account`
|
||||||
|
- `pkg/cloudapi/audit` - для `Audit`
|
||||||
- `pkg/cloudapi/bservice` - для `Basic Service`
|
- `pkg/cloudapi/bservice` - для `Basic Service`
|
||||||
- `pkg/cloudapi/compute` - для `Compute`
|
- `pkg/cloudapi/compute` - для `Compute`
|
||||||
- `pkg/cloudapi/disks` - для `Disks`
|
- `pkg/cloudapi/disks` - для `Disks`
|
||||||
|
- `pkg/cloudapi/dpdknet` - для `DPDK`
|
||||||
- `pkg/cloudapi/extnet` - для `ExtNet`
|
- `pkg/cloudapi/extnet` - для `ExtNet`
|
||||||
- `pkg/cloudapi/flipgroup` - для `FLIPGroup`
|
- `pkg/cloudapi/flipgroup` - для `FLIPGroup`
|
||||||
- `pkg/cloudapi/image` - для `Image`
|
- `pkg/cloudapi/image` - для `Image`
|
||||||
- `pkg/cloudapi/k8ci` - для `K8CI`
|
- `pkg/cloudapi/k8ci` - для `K8CI`
|
||||||
- `pkg/cloudapi/k8s` - для `K8S`
|
- `pkg/cloudapi/k8s` - для `K8S`
|
||||||
- `pkg/cloudapi/kvmppc` - для `KVMPPC`
|
|
||||||
- `pkg/cloudapi/kvmx86` - для `KVMX86`
|
- `pkg/cloudapi/kvmx86` - для `KVMX86`
|
||||||
- `pkg/cloudapi/lb` - для `LB`
|
- `pkg/cloudapi/lb` - для `LB`
|
||||||
- `pkg/cloudapi/locations` - для `Locations`
|
- `pkg/cloudapi/locations` - для `Locations`
|
||||||
|
- `pkg/cloudapi/prometheus` - для `Prometheus`
|
||||||
- `pkg/cloudapi/rg` - для `RG`
|
- `pkg/cloudapi/rg` - для `RG`
|
||||||
- `pkg/cloudapi/sizes` - для `Sizes`
|
- `pkg/cloudapi/sep` - для `SEP`
|
||||||
- `pkg/cloudapi/stack` - для `Stack`
|
- `pkg/cloudapi/stack` - для `Stack`
|
||||||
- `pkg/cloudapi/tasks` - для `Tasks`
|
- `pkg/cloudapi/tasks` - для `Tasks`
|
||||||
- `pkg/cloudapi/vfpool` - для `VFPool`
|
- `pkg/cloudapi/vfpool` - для `VFPool`
|
||||||
- `pkg/cloudapi/vins` - для `VINS`
|
- `pkg/cloudapi/vins` - для `VINS`
|
||||||
- **cloudbroker**:
|
- **cloudbroker**:
|
||||||
- `pkg/cloudbroker/account` - для `Account`
|
- `pkg/cloudbroker/account` - для `Account`
|
||||||
|
- `pkg/cloudbroker/audit` - для `Audit`
|
||||||
- `pkg/cloudbroker/apiaccess` - для `APIAccess`
|
- `pkg/cloudbroker/apiaccess` - для `APIAccess`
|
||||||
- `pkg/cloudbroker/backup` - для `Backup`
|
- `pkg/cloudbroker/backup` - для `Backup`
|
||||||
- `pkg/cloudbroker/compute` - для `Compute`
|
- `pkg/cloudbroker/compute` - для `Compute`
|
||||||
- `pkg/cloudbroker/disks` - для `Disks`
|
- `pkg/cloudbroker/disks` - для `Disks`
|
||||||
|
- `pkg/cloudbroker/dpdknet` - для `DPDK`
|
||||||
- `pkg/cloudbroker/extnet` - для `ExtNet`
|
- `pkg/cloudbroker/extnet` - для `ExtNet`
|
||||||
- `pkg/cloudbroker/flipgroup` - для `FLIPGroup`
|
- `pkg/cloudbroker/flipgroup` - для `FLIPGroup`
|
||||||
- `pkg/cloudbroker/grid` - для `Grid`
|
- `pkg/cloudbroker/grid` - для `Grid`
|
||||||
@@ -310,11 +322,12 @@ func main() {
|
|||||||
- `pkg/cloudbroker/image` - для `Image`
|
- `pkg/cloudbroker/image` - для `Image`
|
||||||
- `pkg/cloudbroker/k8ci` - для `K8CI`
|
- `pkg/cloudbroker/k8ci` - для `K8CI`
|
||||||
- `pkg/cloudbroker/k8s` - для `K8S`
|
- `pkg/cloudbroker/k8s` - для `K8S`
|
||||||
- `pkg/cloudbroker/kvmppc` - для `KVMPPC`
|
|
||||||
- `pkg/cloudbroker/kvmx86` - для `KVMX86`
|
- `pkg/cloudbroker/kvmx86` - для `KVMX86`
|
||||||
- `pkg/cloudbroker/lb` - для `LB`
|
- `pkg/cloudbroker/lb` - для `LB`
|
||||||
- `pkg/cloudbroker/node` - для `Node`
|
- `pkg/cloudbroker/node` - для `Node`
|
||||||
- `pkg/cloudbroker/pcidevice` - для `PCIDevice`
|
- `pkg/cloudbroker/pcidevice` - для `PCIDevice`
|
||||||
|
- `pkg/cloudbroker/prometheus` - для `Prometheus`
|
||||||
|
- `pkg/cloudbroker/resmon` - для `Resmon`
|
||||||
- `pkg/cloudbroker/rg` - для `RG`
|
- `pkg/cloudbroker/rg` - для `RG`
|
||||||
- `pkg/cloudbroker/sep` - для `SEP`
|
- `pkg/cloudbroker/sep` - для `SEP`
|
||||||
- `pkg/cloudbroker/stack` - для `Stack`
|
- `pkg/cloudbroker/stack` - для `Stack`
|
||||||
@@ -412,9 +425,7 @@ type CreateRequest struct {
|
|||||||
// Required: false
|
// Required: false
|
||||||
IPAType string `url:"ipaType,omitempty" json:"ipaType,omitempty"`
|
IPAType string `url:"ipaType,omitempty" json:"ipaType,omitempty"`
|
||||||
|
|
||||||
// Reason for action
|
|
||||||
// Required: false
|
|
||||||
Reason string `url:"reason,omitempty" json:"reason,omitempty"`
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -464,20 +475,22 @@ func main() {
|
|||||||
Доступные методы для `.CloudAPI()`:
|
Доступные методы для `.CloudAPI()`:
|
||||||
|
|
||||||
- `.Account()` - для работы с `Account`
|
- `.Account()` - для работы с `Account`
|
||||||
|
- `.Audit()` - для работы с `Audit`
|
||||||
- `.BService()` - для работы с `BService`
|
- `.BService()` - для работы с `BService`
|
||||||
- `.Compute()` - для работы с `Compute`
|
- `.Compute()` - для работы с `Compute`
|
||||||
- `.Disks()` - для работы с `Disks`
|
- `.Disks()` - для работы с `Disks`
|
||||||
|
- `.DPDKNet()` - для работы с `DPDK`
|
||||||
- `.ExtNet()` - для работы с `ExtNet`
|
- `.ExtNet()` - для работы с `ExtNet`
|
||||||
- `.FLIPgroup()` - для работы с `FLIPGroup`
|
- `.FLIPgroup()` - для работы с `FLIPGroup`
|
||||||
- `.Image()` - для работы с `Image`
|
- `.Image()` - для работы с `Image`
|
||||||
- `.K8CI()` - для работы с `K8CI`
|
- `.K8CI()` - для работы с `K8CI`
|
||||||
- `.K8S()` - для работы с `K8S`
|
- `.K8S()` - для работы с `K8S`
|
||||||
- `.KVMPPC()` - для работы с `KVMPPC`
|
|
||||||
- `.KVMx86()` - для работы с `KVMX86`
|
- `.KVMx86()` - для работы с `KVMX86`
|
||||||
- `.LB()` - для работы с `LB`
|
- `.LB()` - для работы с `LB`
|
||||||
- `.Locations()` - для работы с `Locations`
|
- `.Locations()` - для работы с `Locations`
|
||||||
|
- `.Prometheus()` - для работы с `Prometheus`
|
||||||
- `.RG()` - для работы с `RG`
|
- `.RG()` - для работы с `RG`
|
||||||
- `.Sizes()` - для работы с `Sizes`
|
- `.SEP()` - для работы с `SEP`
|
||||||
- `.Stack()` - для работы с `Stack`
|
- `.Stack()` - для работы с `Stack`
|
||||||
- `.Tasks()` - для работы с `Tasks`
|
- `.Tasks()` - для работы с `Tasks`
|
||||||
- `.VFPool()` - для работы с `VFPool`
|
- `.VFPool()` - для работы с `VFPool`
|
||||||
@@ -486,10 +499,12 @@ func main() {
|
|||||||
Доступные методы для `.CloudBroker()`:
|
Доступные методы для `.CloudBroker()`:
|
||||||
|
|
||||||
- `.Account()` - для работы с `Account`
|
- `.Account()` - для работы с `Account`
|
||||||
|
- `.Audit()` - для работы с `Audit`
|
||||||
- `.APIAccess()` - для работы с `APIAccess`
|
- `.APIAccess()` - для работы с `APIAccess`
|
||||||
- `.Backup()` - для работы с `Backup`
|
- `.Backup()` - для работы с `Backup`
|
||||||
- `.Compute()` - для работы с `Compute`
|
- `.Compute()` - для работы с `Compute`
|
||||||
- `.Disks()` - для работы с `Disks`
|
- `.Disks()` - для работы с `Disks`
|
||||||
|
- `.DPDKNet()` - для работы с `DPDK`
|
||||||
- `.ExtNet()` - для работы с `ExtNet`
|
- `.ExtNet()` - для работы с `ExtNet`
|
||||||
- `.FLIPGroup()` - для работы с `FLIPGroup`
|
- `.FLIPGroup()` - для работы с `FLIPGroup`
|
||||||
- `.Grid()` - для работы с `Grid`
|
- `.Grid()` - для работы с `Grid`
|
||||||
@@ -497,11 +512,12 @@ func main() {
|
|||||||
- `.Image()` - для работы с `Image`
|
- `.Image()` - для работы с `Image`
|
||||||
- `.K8CI()` - для работы с `K8CI`
|
- `.K8CI()` - для работы с `K8CI`
|
||||||
- `.K8S()` - для работы с `K8S`
|
- `.K8S()` - для работы с `K8S`
|
||||||
- `.KVMPPC()` - для работы с `KVMPPC`
|
|
||||||
- `.KVMx86()` - для работы с `KVMX86`
|
- `.KVMx86()` - для работы с `KVMX86`
|
||||||
- `.LB()` - для работы с `LB`
|
- `.LB()` - для работы с `LB`
|
||||||
- `.Node()` - для работы с `Node`
|
- `.Node()` - для работы с `Node`
|
||||||
- `.PCIDevice()` - для работы с `PCIDevice`
|
- `.PCIDevice()` - для работы с `PCIDevice`
|
||||||
|
- `.Prometheus()` - для работы с `Prometheus`
|
||||||
|
- `.Resmon()` - для работы с `Resmon`
|
||||||
- `.RG()` - для работы с `RG`
|
- `.RG()` - для работы с `RG`
|
||||||
- `.SEP()` - для работы с `SEP`
|
- `.SEP()` - для работы с `SEP`
|
||||||
- `.Stack()` - для работы с `Stack`
|
- `.Stack()` - для работы с `Stack`
|
||||||
|
|||||||
62
README_EN.md
62
README_EN.md
@@ -1,62 +0,0 @@
|
|||||||
# Decort SDK
|
|
||||||
|
|
||||||
Decort SDK is a library, written in GO (Golang) for interact with the **DECORT** API.
|
|
||||||
The library contents structures and methods for requesting to an user (cloudapi) and admin (cloudbroker) groups of API.
|
|
||||||
Also the library have structures for responses.
|
|
||||||
|
|
||||||
## Contents
|
|
||||||
|
|
||||||
- [Install](#install)
|
|
||||||
- [API List](#api-list)
|
|
||||||
- [Examples](#examples)
|
|
||||||
- [Examples2](#examples2)
|
|
||||||
|
|
||||||
## Install
|
|
||||||
|
|
||||||
```bash
|
|
||||||
go get -u repository.basistech.ru/BASIS/decort-golang-sdk
|
|
||||||
```
|
|
||||||
|
|
||||||
## API List
|
|
||||||
|
|
||||||
## Examples
|
|
||||||
|
|
||||||
```go
|
|
||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"fmt"
|
|
||||||
"log"
|
|
||||||
|
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/config"
|
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/kvmx86"
|
|
||||||
)
|
|
||||||
|
|
||||||
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)
|
|
||||||
req := kvmx86.CreateRequest{
|
|
||||||
RGID: 123,
|
|
||||||
Name: "compute",
|
|
||||||
CPU: 4,
|
|
||||||
RAM: 4096,
|
|
||||||
ImageID: 321,
|
|
||||||
}
|
|
||||||
|
|
||||||
res, err := client.KVMX86().Create(context.Background(), req)
|
|
||||||
if err != nil {
|
|
||||||
log.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
fmt.Println(res)
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
## Examples2
|
|
||||||
@@ -3,6 +3,7 @@ package validators
|
|||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"net/url"
|
||||||
"reflect"
|
"reflect"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
@@ -12,7 +13,7 @@ import (
|
|||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/multierror"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/multierror"
|
||||||
)
|
)
|
||||||
|
|
||||||
// computeDriverValidator is used to validate Driver field in kvmx86/kvmppc create.
|
// computeDriverValidator is used to validate Driver field in kvmx86 create.
|
||||||
func computeDriverValidator(fe validator.FieldLevel) bool {
|
func computeDriverValidator(fe validator.FieldLevel) bool {
|
||||||
fieldValue := fe.Field().String()
|
fieldValue := fe.Field().String()
|
||||||
|
|
||||||
@@ -26,6 +27,13 @@ func protoValidator(fe validator.FieldLevel) bool {
|
|||||||
return IsInSlice(fieldValue, protoValues)
|
return IsInSlice(fieldValue, protoValues)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// apiGroupValidator is used to validate APIGroup fields
|
||||||
|
func apiGroupValidator(fe validator.FieldLevel) bool {
|
||||||
|
fieldValue := fe.Field().String()
|
||||||
|
|
||||||
|
return IsInSlice(fieldValue, apiGroupValues)
|
||||||
|
}
|
||||||
|
|
||||||
// accessTypeValidator is used to validate AccessType fields.
|
// accessTypeValidator is used to validate AccessType fields.
|
||||||
func accessTypeValidator(fe validator.FieldLevel) bool {
|
func accessTypeValidator(fe validator.FieldLevel) bool {
|
||||||
fieldValue := fe.Field().String()
|
fieldValue := fe.Field().String()
|
||||||
@@ -270,6 +278,27 @@ func interfaceStateValidator(fe validator.FieldLevel) bool {
|
|||||||
return IsInSlice(fieldValue, interfaceStateValues)
|
return IsInSlice(fieldValue, interfaceStateValues)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func interfaceTXModelValidator(fe validator.FieldLevel) bool {
|
||||||
|
fieldValue := fe.Field().String()
|
||||||
|
fieldValue = strings.ToLower(fieldValue)
|
||||||
|
|
||||||
|
return IsInSlice(fieldValue, txModelValues)
|
||||||
|
}
|
||||||
|
|
||||||
|
func interfaceIOEventFDValidator(fe validator.FieldLevel) bool {
|
||||||
|
fieldValue := fe.Field().String()
|
||||||
|
fieldValue = strings.ToLower(fieldValue)
|
||||||
|
|
||||||
|
return IsInSlice(fieldValue, ioEventFDValues)
|
||||||
|
}
|
||||||
|
|
||||||
|
func interfaceEventIDxValidator(fe validator.FieldLevel) bool {
|
||||||
|
fieldValue := fe.Field().String()
|
||||||
|
fieldValue = strings.ToLower(fieldValue)
|
||||||
|
|
||||||
|
return IsInSlice(fieldValue, eventIDxValues)
|
||||||
|
}
|
||||||
|
|
||||||
func strictLooseValidator(fe validator.FieldLevel) bool {
|
func strictLooseValidator(fe validator.FieldLevel) bool {
|
||||||
fieldValue := fe.Field().String()
|
fieldValue := fe.Field().String()
|
||||||
fieldValue = strings.ToLower(fieldValue)
|
fieldValue = strings.ToLower(fieldValue)
|
||||||
@@ -304,6 +333,12 @@ func vmActionValidator(fe validator.FieldLevel) bool {
|
|||||||
return IsInSlice(fieldValue, vmActionValues)
|
return IsInSlice(fieldValue, vmActionValues)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func mtuValidator(fe validator.FieldLevel) bool {
|
||||||
|
fieldValue := fe.Field().Uint()
|
||||||
|
|
||||||
|
return fieldValue >= uint64(mtuMin) && fieldValue <= uint64(mtuMax)
|
||||||
|
}
|
||||||
|
|
||||||
func computeFeaturesValidator(fe validator.FieldLevel) bool {
|
func computeFeaturesValidator(fe validator.FieldLevel) bool {
|
||||||
field := fe.Field()
|
field := fe.Field()
|
||||||
slice, ok := field.Interface().([]string)
|
slice, ok := field.Interface().([]string)
|
||||||
@@ -337,6 +372,55 @@ func isBoolTypeValidator(fe validator.FieldLevel) bool {
|
|||||||
return fe.Field().CanConvert(reflect.TypeOf(true))
|
return fe.Field().CanConvert(reflect.TypeOf(true))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func urlValidartor(fl validator.FieldLevel) bool {
|
||||||
|
fieldValues := fl.Field().String()
|
||||||
|
|
||||||
|
_, err := url.ParseRequestURI(fieldValues)
|
||||||
|
return err == nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func chipsetValidator(fe validator.FieldLevel) bool {
|
||||||
|
fieldValue := fe.Field().String()
|
||||||
|
|
||||||
|
return IsInSlice(fieldValue, chipsetValues)
|
||||||
|
}
|
||||||
|
|
||||||
|
func preferredCPUValidator(fe validator.FieldLevel) bool {
|
||||||
|
fieldSlice, ok := fe.Field().Interface().([]int64)
|
||||||
|
if !ok {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, value := range fieldSlice {
|
||||||
|
if value < -1 {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
// loaderTypeValidator is used to validate loaderType fields
|
||||||
|
func loaderTypeValidator(fe validator.FieldLevel) bool {
|
||||||
|
fieldValue := fe.Field().String()
|
||||||
|
|
||||||
|
return IsInSlice(fieldValue, loaderTypeValues)
|
||||||
|
}
|
||||||
|
|
||||||
|
// languageValidator is used to validate language fields
|
||||||
|
func languageValidator(fe validator.FieldLevel) bool {
|
||||||
|
fieldValue := fe.Field().String()
|
||||||
|
|
||||||
|
return IsInSlice(fieldValue, languageValues)
|
||||||
|
}
|
||||||
|
|
||||||
|
// sepTypeValidator is used to validate sepType fields
|
||||||
|
func sepTypeValidator(fe validator.FieldLevel) bool {
|
||||||
|
fieldValue := fe.Field().String()
|
||||||
|
|
||||||
|
return IsInSlice(fieldValue, sepTypeValues)
|
||||||
|
}
|
||||||
|
|
||||||
// ValidateRAM checks if request contains RAM value that is positive integer divisible by divisibility passed.
|
// ValidateRAM checks if request contains RAM value that is positive integer divisible by divisibility passed.
|
||||||
// It is recommended to pass constants.RAM_DIVISIBILITY as divisility arguement
|
// It is recommended to pass constants.RAM_DIVISIBILITY as divisility arguement
|
||||||
func ValidateRAM(r interfaces.RequestWithRAM, divisibility uint64) error {
|
func ValidateRAM(r interfaces.RequestWithRAM, divisibility uint64) error {
|
||||||
|
|||||||
@@ -25,6 +25,8 @@ func errorMessage(fe validator.FieldError) string {
|
|||||||
return fmt.Sprintf("%s %s: unexpected URL format", prefix, fe.Field())
|
return fmt.Sprintf("%s %s: unexpected URL format", prefix, fe.Field())
|
||||||
case "email":
|
case "email":
|
||||||
return fmt.Sprintf("%s %s: unexpected E-Mail format", prefix, fe.Field())
|
return fmt.Sprintf("%s %s: unexpected E-Mail format", prefix, fe.Field())
|
||||||
|
case "isBool":
|
||||||
|
return fmt.Sprintf("%s %s: must be bool type", prefix, fe.Field())
|
||||||
|
|
||||||
case "driver":
|
case "driver":
|
||||||
return fmt.Sprintf("%s %s must be one of the following: %s",
|
return fmt.Sprintf("%s %s must be one of the following: %s",
|
||||||
@@ -50,6 +52,13 @@ func errorMessage(fe validator.FieldError) string {
|
|||||||
fe.Field(),
|
fe.Field(),
|
||||||
joinValues(protoValues))
|
joinValues(protoValues))
|
||||||
|
|
||||||
|
// apiGroup Validators
|
||||||
|
case "apiGroup":
|
||||||
|
return fmt.Sprintf("%s %s must be one of the following: %s",
|
||||||
|
prefix,
|
||||||
|
fe.Field(),
|
||||||
|
joinValues(apiGroupValues))
|
||||||
|
|
||||||
// Account Validators
|
// Account Validators
|
||||||
case "accountCUType":
|
case "accountCUType":
|
||||||
return fmt.Sprintf("%s %s must be one of the following: %s",
|
return fmt.Sprintf("%s %s must be one of the following: %s",
|
||||||
@@ -89,11 +98,11 @@ func errorMessage(fe validator.FieldError) string {
|
|||||||
fe.Field(),
|
fe.Field(),
|
||||||
joinValues(computeDiskTypeValues))
|
joinValues(computeDiskTypeValues))
|
||||||
|
|
||||||
case "computeNetType":
|
case "mtu":
|
||||||
return fmt.Sprintf("%s %s must be one of the following: %s",
|
return fmt.Sprint(prefix, fe.Field(), "must be ", mtuMin, "-", mtuMax)
|
||||||
prefix,
|
|
||||||
fe.Field(),
|
case "preferredCPU":
|
||||||
joinValues(computeNetTypeValues))
|
return fmt.Sprint(prefix, fe.Field(), "must be equal to or greater than", -1)
|
||||||
|
|
||||||
case "computex86NetType":
|
case "computex86NetType":
|
||||||
return fmt.Sprintf("%s %s must be one of the following: %s",
|
return fmt.Sprintf("%s %s must be one of the following: %s",
|
||||||
@@ -101,6 +110,12 @@ func errorMessage(fe validator.FieldError) string {
|
|||||||
fe.Field(),
|
fe.Field(),
|
||||||
joinValues(computex86NetTypeValues))
|
joinValues(computex86NetTypeValues))
|
||||||
|
|
||||||
|
case "computeNetType":
|
||||||
|
return fmt.Sprintf("%s %s must be one of the following: %s",
|
||||||
|
prefix,
|
||||||
|
fe.Field(),
|
||||||
|
joinValues(computeNetTypeValues))
|
||||||
|
|
||||||
case "computeOrder":
|
case "computeOrder":
|
||||||
return fmt.Sprintf("%s %s can contain only the following values: %s",
|
return fmt.Sprintf("%s %s can contain only the following values: %s",
|
||||||
prefix,
|
prefix,
|
||||||
@@ -139,7 +154,7 @@ func errorMessage(fe validator.FieldError) string {
|
|||||||
prefix,
|
prefix,
|
||||||
fe.Field())
|
fe.Field())
|
||||||
|
|
||||||
// KVM_X86/KVM_PPC Validators
|
// KVM_X86 Validators
|
||||||
case "kvmNetType":
|
case "kvmNetType":
|
||||||
return fmt.Sprintf("%s %s must be one of the following: %s",
|
return fmt.Sprintf("%s %s must be one of the following: %s",
|
||||||
prefix,
|
prefix,
|
||||||
@@ -236,6 +251,24 @@ func errorMessage(fe validator.FieldError) string {
|
|||||||
fe.Field(),
|
fe.Field(),
|
||||||
joinValues(interfaceStateValues))
|
joinValues(interfaceStateValues))
|
||||||
|
|
||||||
|
case "interfaceTXModel":
|
||||||
|
return fmt.Sprintf("%s %s must be one of the following: %s",
|
||||||
|
prefix,
|
||||||
|
fe.Field(),
|
||||||
|
joinValues(txModelValues))
|
||||||
|
|
||||||
|
case "interfaceIOEventFD":
|
||||||
|
return fmt.Sprintf("%s %s must be one of the following: %s",
|
||||||
|
prefix,
|
||||||
|
fe.Field(),
|
||||||
|
joinValues(ioEventFDValues))
|
||||||
|
|
||||||
|
case "interfaceEventIDx":
|
||||||
|
return fmt.Sprintf("%s %s must be one of the following: %s",
|
||||||
|
prefix,
|
||||||
|
fe.Field(),
|
||||||
|
joinValues(eventIDxValues))
|
||||||
|
|
||||||
case "sortBy":
|
case "sortBy":
|
||||||
return fmt.Sprintf("%s %s must be in format +|-(field)",
|
return fmt.Sprintf("%s %s must be in format +|-(field)",
|
||||||
prefix,
|
prefix,
|
||||||
@@ -276,6 +309,30 @@ func errorMessage(fe validator.FieldError) string {
|
|||||||
prefix,
|
prefix,
|
||||||
fe.Field(),
|
fe.Field(),
|
||||||
joinValues(kvmx86NetTypeValues))
|
joinValues(kvmx86NetTypeValues))
|
||||||
|
|
||||||
|
case "chipset":
|
||||||
|
return fmt.Sprintf("%s %s must be one of the following: %s",
|
||||||
|
prefix,
|
||||||
|
fe.Field(),
|
||||||
|
joinValues(chipsetValues))
|
||||||
|
|
||||||
|
case "loaderType":
|
||||||
|
return fmt.Sprintf("%s %s must be one of the following: %s",
|
||||||
|
prefix,
|
||||||
|
fe.Field(),
|
||||||
|
joinValues(loaderTypeValues))
|
||||||
|
|
||||||
|
case "language":
|
||||||
|
return fmt.Sprintf("%s %s must be one of the following: %s",
|
||||||
|
prefix,
|
||||||
|
fe.Field(),
|
||||||
|
joinValues(languageValues))
|
||||||
|
|
||||||
|
case "sepType":
|
||||||
|
return fmt.Sprintf("%s %s must be one of the following: %s",
|
||||||
|
prefix,
|
||||||
|
fe.Field(),
|
||||||
|
joinValues(sepTypeValues))
|
||||||
}
|
}
|
||||||
|
|
||||||
return fe.Error()
|
return fe.Error()
|
||||||
|
|||||||
@@ -36,6 +36,11 @@ func registerAllValidators(validate *validator.Validate) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
err = validate.RegisterValidation("apiGroup", apiGroupValidator)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
err = validate.RegisterValidation("accessType", accessTypeValidator)
|
err = validate.RegisterValidation("accessType", accessTypeValidator)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -186,6 +191,21 @@ func registerAllValidators(validate *validator.Validate) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
err = validate.RegisterValidation("interfaceTXModel", interfaceTXModelValidator)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
err = validate.RegisterValidation("interfaceIOEventFD", interfaceIOEventFDValidator)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
err = validate.RegisterValidation("interfaceEventIDx", interfaceEventIDxValidator)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
err = validate.RegisterValidation("workerGroupName", workerGroupNameValidator)
|
err = validate.RegisterValidation("workerGroupName", workerGroupNameValidator)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -206,6 +226,11 @@ func registerAllValidators(validate *validator.Validate) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
err = validate.RegisterValidation("mtu", mtuValidator)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
err = validate.RegisterValidation("computeFeatures", computeFeaturesValidator)
|
err = validate.RegisterValidation("computeFeatures", computeFeaturesValidator)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -231,5 +256,35 @@ func registerAllValidators(validate *validator.Validate) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
err = validate.RegisterValidation("url", urlValidartor)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
err = validate.RegisterValidation("chipset", chipsetValidator)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
err = validate.RegisterValidation("preferredCPU", preferredCPUValidator)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
err = validate.RegisterValidation("loaderType", loaderTypeValidator)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
err = validate.RegisterValidation("language", languageValidator)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
err = validate.RegisterValidation("sepType", sepTypeValidator)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
package validators
|
package validators
|
||||||
|
|
||||||
var (
|
var (
|
||||||
driverValues = []string{"KVM_X86", "KVM_PPC"}
|
apiGroupValues = []string{"cloudapi", "cloudbroker", "system"}
|
||||||
|
|
||||||
|
driverValues = []string{"KVM_X86"}
|
||||||
accessTypeValues = []string{"R", "RCX", "ARCXDU"}
|
accessTypeValues = []string{"R", "RCX", "ARCXDU"}
|
||||||
resTypesValues = []string{"compute", "vins", "k8s", "openshift", "lb", "flipgroup"}
|
resTypesValues = []string{"compute", "vins", "k8s", "openshift", "lb", "flipgroup"}
|
||||||
protoValues = []string{"tcp", "udp"}
|
protoValues = []string{"tcp", "udp"}
|
||||||
@@ -15,7 +17,7 @@ var (
|
|||||||
computeModeValues = []string{"EQ", "EN", "ANY"}
|
computeModeValues = []string{"EQ", "EN", "ANY"}
|
||||||
computeDiskTypeValues = []string{"D", "B"}
|
computeDiskTypeValues = []string{"D", "B"}
|
||||||
computeNetTypeValues = []string{"EXTNET", "VINS"}
|
computeNetTypeValues = []string{"EXTNET", "VINS"}
|
||||||
computex86NetTypeValues = []string{"EXTNET", "VINS", "VFNIC"}
|
computex86NetTypeValues = []string{"EXTNET", "VINS", "VFNIC", "DPDK"}
|
||||||
computeOrderValues = []string{"cdrom", "network", "hd"}
|
computeOrderValues = []string{"cdrom", "network", "hd"}
|
||||||
computeDataDisksValues = []string{"KEEP", "DETACH", "DESTROY"}
|
computeDataDisksValues = []string{"KEEP", "DETACH", "DESTROY"}
|
||||||
computeDriverValues = []string{"KVM_X86", "SVA_KVM_X86"}
|
computeDriverValues = []string{"KVM_X86", "SVA_KVM_X86"}
|
||||||
@@ -25,19 +27,19 @@ var (
|
|||||||
flipgroupClientTypeValues = []string{"compute", "vins"}
|
flipgroupClientTypeValues = []string{"compute", "vins"}
|
||||||
|
|
||||||
kvmNetTypeValues = []string{"EXTNET", "VINS", "NONE"}
|
kvmNetTypeValues = []string{"EXTNET", "VINS", "NONE"}
|
||||||
kvmx86NetTypeValues = []string{"EXTNET", "VINS", "NONE", "VFNIC"}
|
kvmx86NetTypeValues = []string{"EXTNET", "VINS", "NONE", "VFNIC", "DPDK"}
|
||||||
|
|
||||||
lbAlgorithmValues = []string{"roundrobin", "static-rr", "leastconn"}
|
lbAlgorithmValues = []string{"roundrobin", "static-rr", "leastconn"}
|
||||||
|
|
||||||
rgDefNetValues = []string{"PRIVATE", "PUBLIC", "NONE"}
|
rgDefNetValues = []string{"PRIVATE", "PUBLIC", "NONE"}
|
||||||
rgNetTypeValues = []string{"PUBLIC", "PRIVATE"}
|
rgNetTypeValues = []string{"PUBLIC", "PRIVATE"}
|
||||||
|
|
||||||
vinsTypeValues = []string{"DHCP", "VIP", "EXCLUDE"}
|
vinsTypeValues = []string{"DHCP", "VIP", "EXCLUDED"}
|
||||||
|
|
||||||
imageBootTypeValues = []string{"uefi", "bios"}
|
imageBootTypeValues = []string{"uefi", "bios"}
|
||||||
imageTypeValues = []string{"windows", "linux", "other"}
|
imageTypeValues = []string{"windows", "linux", "unknown"}
|
||||||
imageDriversValues = []string{"KVM_X86"}
|
imageDriversValues = []string{"KVM_X86"}
|
||||||
imageArchitectureValues = []string{"X86_64", "PPC64_LE"}
|
imageArchitectureValues = []string{"X86_64"}
|
||||||
|
|
||||||
sepFieldTypeValues = []string{"int", "str", "bool", "list", "dict"}
|
sepFieldTypeValues = []string{"int", "str", "bool", "list", "dict"}
|
||||||
|
|
||||||
@@ -51,9 +53,29 @@ var (
|
|||||||
|
|
||||||
vmActionValues = []string{"stop", "move"}
|
vmActionValues = []string{"stop", "move"}
|
||||||
|
|
||||||
computeFeaturesValues = []string{"hugepages", "numa", "cpupin", "vfnic"}
|
computeFeaturesValues = []string{"hugepages", "numa", "cpupin", "vfnic", "dpdk", "changemac"}
|
||||||
|
|
||||||
networkInterfaceNamingValues = []string{"eth", "ens"}
|
networkInterfaceNamingValues = []string{"eth", "ens"}
|
||||||
|
|
||||||
numaAffinityValues = []string{"none", "strict", "loose"}
|
numaAffinityValues = []string{"none", "strict", "loose"}
|
||||||
|
|
||||||
|
txModelValues = []string{"iothread", "timer", "selected by hypervisor"}
|
||||||
|
|
||||||
|
ioEventFDValues = []string{"on", "off", "selected by hypervisor"}
|
||||||
|
|
||||||
|
eventIDxValues = []string{"on", "off", "selected by hypervisor"}
|
||||||
|
|
||||||
|
chipsetValues = []string{"i440fx", "Q35"}
|
||||||
|
|
||||||
|
loaderTypeValues = []string{"linux", "windows", "unknown"}
|
||||||
|
|
||||||
|
sepTypeValues = []string{"hitachi", "dorado", "tatlin", "shared", "local", "des"}
|
||||||
|
|
||||||
|
languageValues = []string{"ru", "en"}
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
mtuMin = 1
|
||||||
|
|
||||||
|
mtuMax = 9216
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -17,10 +17,6 @@ type DeleteUserRequest struct {
|
|||||||
// ID or emailaddress of the user to remove
|
// ID or emailaddress of the user to remove
|
||||||
// Required: true
|
// Required: true
|
||||||
UserID string `url:"userId" json:"userId" validate:"required"`
|
UserID string `url:"userId" json:"userId" validate:"required"`
|
||||||
|
|
||||||
// Recursively revoke access rights from owned cloudspaces and vmachines
|
|
||||||
// Required: false
|
|
||||||
RecursiveDelete bool `url:"recursivedelete" json:"recursivedelete"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// DeleteUser revokes user access from the account
|
// DeleteUser revokes user access from the account
|
||||||
|
|||||||
@@ -13,6 +13,10 @@ type DisableEnableRequest struct {
|
|||||||
// ID of account
|
// ID of account
|
||||||
// Required: true
|
// Required: true
|
||||||
AccountID uint64 `url:"accountId" json:"accountId" validate:"required"`
|
AccountID uint64 `url:"accountId" json:"accountId" validate:"required"`
|
||||||
|
|
||||||
|
// Reason of disabling
|
||||||
|
// Required: false
|
||||||
|
Reason string `url:"reason,omitempty" json:"reason,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Disable disables an account
|
// Disable disables an account
|
||||||
|
|||||||
@@ -1,58 +0,0 @@
|
|||||||
package account
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"net/http"
|
|
||||||
|
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
|
||||||
)
|
|
||||||
|
|
||||||
// GetConsumptionRequest struct to download the resources tracking files for an account
|
|
||||||
type GetConsumptionRequest struct {
|
|
||||||
// ID an account
|
|
||||||
// Required: true
|
|
||||||
AccountID uint64 `url:"accountId" json:"accountId" validate:"required"`
|
|
||||||
|
|
||||||
// Epoch represents the start time
|
|
||||||
// Required: true
|
|
||||||
Start float64 `url:"start" json:"start" validate:"required"`
|
|
||||||
|
|
||||||
// Epoch represents the end time
|
|
||||||
// Required: true
|
|
||||||
End float64 `url:"end" json:"end" validate:"required"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetConsumption downloads the resources tracking files for an account within a given period
|
|
||||||
func (a Account) GetConsumption(ctx context.Context, req GetConsumptionRequest) (string, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/account/getConsumption"
|
|
||||||
|
|
||||||
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
return string(res), nil
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetConsumptionGet downloads the resources tracking files for an account within a given period
|
|
||||||
func (a Account) GetConsumptionGet(ctx context.Context, req GetConsumptionRequest) (string, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/account/getConsumption"
|
|
||||||
|
|
||||||
res, err := a.client.DecortApiCall(ctx, http.MethodGet, url, req)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
return string(res), nil
|
|
||||||
}
|
|
||||||
@@ -38,6 +38,10 @@ type ListFLIPGroupsRequest struct {
|
|||||||
// Required: false
|
// Required: false
|
||||||
FLIPGroupID uint64 `url:"flipGroupId,omitempty" json:"flipGroupId,omitempty"`
|
FLIPGroupID uint64 `url:"flipGroupId,omitempty" json:"flipGroupId,omitempty"`
|
||||||
|
|
||||||
|
// Sort by one of supported fields, format +|-(field)
|
||||||
|
// Required: false
|
||||||
|
SortBy string `url:"sortBy,omitempty" json:"sortBy,omitempty" validate:"omitempty,sortBy"`
|
||||||
|
|
||||||
// Page number
|
// Page number
|
||||||
// Required: false
|
// Required: false
|
||||||
Page uint64 `url:"page,omitempty" json:"page,omitempty"`
|
Page uint64 `url:"page,omitempty" json:"page,omitempty"`
|
||||||
|
|||||||
@@ -62,6 +62,9 @@ type ItemAccount struct {
|
|||||||
// Deleted time
|
// Deleted time
|
||||||
DeletedTime uint64 `json:"deletedTime"`
|
DeletedTime uint64 `json:"deletedTime"`
|
||||||
|
|
||||||
|
// Description
|
||||||
|
Description string `json:"desc"`
|
||||||
|
|
||||||
// ID
|
// ID
|
||||||
ID uint64 `json:"id"`
|
ID uint64 `json:"id"`
|
||||||
|
|
||||||
@@ -197,6 +200,9 @@ type RecordAccount struct {
|
|||||||
// Created time
|
// Created time
|
||||||
CreatedTime uint64 `json:"createdTime"`
|
CreatedTime uint64 `json:"createdTime"`
|
||||||
|
|
||||||
|
// Description
|
||||||
|
Description string `json:"desc"`
|
||||||
|
|
||||||
// Deactivation time
|
// Deactivation time
|
||||||
DeactivationTime float64 `json:"deactivationTime"`
|
DeactivationTime float64 `json:"deactivationTime"`
|
||||||
|
|
||||||
@@ -384,7 +390,7 @@ type ItemVINS struct {
|
|||||||
ExtnetId uint64 `json:"extnetId"`
|
ExtnetId uint64 `json:"extnetId"`
|
||||||
|
|
||||||
// Free IPs
|
// Free IPs
|
||||||
FreeIPs uint64 `json:"freeIPs"`
|
FreeIPs int64 `json:"freeIPs"`
|
||||||
|
|
||||||
// ID
|
// ID
|
||||||
ID uint64 `json:"id"`
|
ID uint64 `json:"id"`
|
||||||
@@ -512,6 +518,9 @@ type ItemRG struct {
|
|||||||
// Deleted time
|
// Deleted time
|
||||||
DeletedTime uint64 `json:"deletedTime"`
|
DeletedTime uint64 `json:"deletedTime"`
|
||||||
|
|
||||||
|
// Description
|
||||||
|
Description string `json:"desc"`
|
||||||
|
|
||||||
// Resource group ID
|
// Resource group ID
|
||||||
RGID uint64 `json:"id"`
|
RGID uint64 `json:"id"`
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,10 @@ type UpdateRequest struct {
|
|||||||
// Required: true
|
// Required: true
|
||||||
AccountID uint64 `url:"accountId" json:"accountId" validate:"required"`
|
AccountID uint64 `url:"accountId" json:"accountId" validate:"required"`
|
||||||
|
|
||||||
|
// Description
|
||||||
|
// Required: false
|
||||||
|
Description string `url:"desc,omitempty" json:"desc,omitempty"`
|
||||||
|
|
||||||
// Name of the account
|
// Name of the account
|
||||||
// Required: false
|
// Required: false
|
||||||
Name string `url:"name,omitempty" json:"name,omitempty"`
|
Name string `url:"name,omitempty" json:"name,omitempty"`
|
||||||
@@ -45,6 +49,11 @@ type UpdateRequest struct {
|
|||||||
// Limit (positive) or disable (0) GPU resources
|
// Limit (positive) or disable (0) GPU resources
|
||||||
// Required: false
|
// Required: false
|
||||||
GPUUnits int64 `url:"gpu_units,omitempty" json:"gpu_units,omitempty"`
|
GPUUnits int64 `url:"gpu_units,omitempty" json:"gpu_units,omitempty"`
|
||||||
|
|
||||||
|
// List of strings with pools
|
||||||
|
// i.e.: ["sep1_poolName1", "sep2_poolName2", etc]
|
||||||
|
// Required: false
|
||||||
|
UniqPools []string `url:"uniqPools,omitempty" json:"uniqPools,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update updates an account name and resource types and limits
|
// Update updates an account name and resource types and limits
|
||||||
|
|||||||
10
pkg/cloudapi/audit.go
Normal file
10
pkg/cloudapi/audit.go
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
package cloudapi
|
||||||
|
|
||||||
|
import (
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/audit"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Accessing the Stack method group
|
||||||
|
func (ca *CloudAPI) Audit() *audit.Audit {
|
||||||
|
return audit.New(ca.client)
|
||||||
|
}
|
||||||
15
pkg/cloudapi/audit/audit.go
Normal file
15
pkg/cloudapi/audit/audit.go
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
package audit
|
||||||
|
|
||||||
|
import "repository.basistech.ru/BASIS/decort-golang-sdk/interfaces"
|
||||||
|
|
||||||
|
// Structure for creating request to audit
|
||||||
|
type Audit struct {
|
||||||
|
client interfaces.Caller
|
||||||
|
}
|
||||||
|
|
||||||
|
// Builder for audit endpoint
|
||||||
|
func New(client interfaces.Caller) *Audit{
|
||||||
|
return &Audit{
|
||||||
|
client: client,
|
||||||
|
}
|
||||||
|
}
|
||||||
46
pkg/cloudapi/audit/get.go
Normal file
46
pkg/cloudapi/audit/get.go
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
package audit
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"encoding/json"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
|
)
|
||||||
|
|
||||||
|
// GetRequest struct to get information about account
|
||||||
|
type GetRequest struct {
|
||||||
|
// Audit GUID
|
||||||
|
// Required: true
|
||||||
|
AuditGuid string `url:"audit_guid" json:"audit_guid" validate:"required"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get gets information about audit as a RecordAudit struct
|
||||||
|
func (a Audit) Get(ctx context.Context, req GetRequest) (*RecordAudit, error) {
|
||||||
|
res, err := a.GetRaw(ctx, req)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
info := RecordAudit{}
|
||||||
|
|
||||||
|
err = json.Unmarshal(res, &info)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return &info, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetRaw gets information about audit as an array of bytes
|
||||||
|
func (a Audit) GetRaw(ctx context.Context, req GetRequest) ([]byte, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudapi/audit/get"
|
||||||
|
|
||||||
|
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
41
pkg/cloudapi/audit/models.go
Normal file
41
pkg/cloudapi/audit/models.go
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
package audit
|
||||||
|
|
||||||
|
// Main info about audit
|
||||||
|
type RecordAudit struct {
|
||||||
|
|
||||||
|
// Arguments
|
||||||
|
Arguments string `json:"args"`
|
||||||
|
|
||||||
|
// Call
|
||||||
|
Call string `json:"call"`
|
||||||
|
|
||||||
|
// GUID
|
||||||
|
GUID string `json:"guid"`
|
||||||
|
|
||||||
|
// Kwargs
|
||||||
|
Kwargs string `json:"kwargs"`
|
||||||
|
|
||||||
|
// RemoteAddr
|
||||||
|
RemoteAddr string `json:"remote_addr"`
|
||||||
|
|
||||||
|
// Response time
|
||||||
|
ResponseTime float64 `json:"responsetime"`
|
||||||
|
|
||||||
|
// Result
|
||||||
|
Result string `json:"result"`
|
||||||
|
|
||||||
|
// Status code
|
||||||
|
StatusCode uint64 `json:"statuscode"`
|
||||||
|
|
||||||
|
// Tags
|
||||||
|
Tags string `json:"tags"`
|
||||||
|
|
||||||
|
// Timestamp
|
||||||
|
Timestamp float64 `json:"timestamp"`
|
||||||
|
|
||||||
|
// TimestampEnd
|
||||||
|
TimestampEnd float64 `json:"timestampEnd"`
|
||||||
|
|
||||||
|
// User
|
||||||
|
User string `json:"user"`
|
||||||
|
}
|
||||||
@@ -41,7 +41,6 @@ type GroupAddRequest struct {
|
|||||||
// Compute driver
|
// Compute driver
|
||||||
// should be one of:
|
// should be one of:
|
||||||
// - KVM_X86
|
// - KVM_X86
|
||||||
// - KVM_PPC
|
|
||||||
// Required: true
|
// Required: true
|
||||||
Driver string `url:"driver" json:"driver" validate:"driver"`
|
Driver string `url:"driver" json:"driver" validate:"driver"`
|
||||||
|
|
||||||
@@ -72,6 +71,10 @@ type GroupAddRequest struct {
|
|||||||
// Meta data for working group computes, format YAML "user_data": 1111
|
// Meta data for working group computes, format YAML "user_data": 1111
|
||||||
// Required: false
|
// Required: false
|
||||||
UserData string `url:"userData,omitempty" json:"userData,omitempty"`
|
UserData string `url:"userData,omitempty" json:"userData,omitempty"`
|
||||||
|
|
||||||
|
//Chipset "i440fx" or "Q35
|
||||||
|
//Required: false
|
||||||
|
Chipset string `url:"chipset,omitempty" json:"chipset,omitempty" validate:"chipset,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetRAM returns RAM field values
|
// GetRAM returns RAM field values
|
||||||
|
|||||||
@@ -22,6 +22,12 @@ type GroupResizeRequest struct {
|
|||||||
// Required: true
|
// Required: true
|
||||||
Count int64 `url:"count" json:"count" validate:"required"`
|
Count int64 `url:"count" json:"count" validate:"required"`
|
||||||
|
|
||||||
|
//Chipset for new computes, either i440fx or Q35 (i440fx by default)
|
||||||
|
//Available values : i440fx, Q35
|
||||||
|
//Default value : i440fx
|
||||||
|
//Required: true
|
||||||
|
Chipset string `url:"chipset" json:"chipset" validate:"required,chipset"`
|
||||||
|
|
||||||
// Either delta or absolute value of computes
|
// Either delta or absolute value of computes
|
||||||
// Should be one of:
|
// Should be one of:
|
||||||
// - ABSOLUTE
|
// - ABSOLUTE
|
||||||
|
|||||||
@@ -295,6 +295,9 @@ type ItemGroupCompute struct {
|
|||||||
|
|
||||||
// List of information about OS Users
|
// List of information about OS Users
|
||||||
OSUsers ListOSUsers `json:"osUsers"`
|
OSUsers ListOSUsers `json:"osUsers"`
|
||||||
|
|
||||||
|
//Chipset
|
||||||
|
Chipset string `json:"chipset"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// List of Group Computes
|
// List of Group Computes
|
||||||
|
|||||||
54
pkg/cloudapi/compute/change_ip.go
Normal file
54
pkg/cloudapi/compute/change_ip.go
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
package compute
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"net/http"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ChangeIPRequest struct to change IP for network
|
||||||
|
type ChangeIPRequest struct {
|
||||||
|
// ID of compute instance
|
||||||
|
// Required: true
|
||||||
|
ComputeID uint64 `url:"compute_id" json:"compute_id" validate:"required"`
|
||||||
|
|
||||||
|
// Network type
|
||||||
|
// 'EXTNET' for connect to external network directly
|
||||||
|
// 'VINS' for connect to ViNS
|
||||||
|
// Required: true
|
||||||
|
NetType string `url:"net_type" json:"net_type" validate:"computeNetType"`
|
||||||
|
|
||||||
|
// Network ID for connect to
|
||||||
|
// For EXTNET - external network ID
|
||||||
|
// For VINS - VINS ID
|
||||||
|
// Required: true
|
||||||
|
NetID uint64 `url:"net_id" json:"net_id" validate:"required"`
|
||||||
|
|
||||||
|
// IP address to which we will change the existing one, it must be from the same subnet
|
||||||
|
// Required: true
|
||||||
|
IPAddr string `url:"ip_addr" json:"ip_addr" validate:"required"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ChangeIP change reserved IP for compute instance
|
||||||
|
func (c Compute) ChangeIP(ctx context.Context, req ChangeIPRequest) (bool, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudapi/compute/changeIp"
|
||||||
|
|
||||||
|
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
|
||||||
|
}
|
||||||
46
pkg/cloudapi/compute/change_mac.go
Normal file
46
pkg/cloudapi/compute/change_mac.go
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
package compute
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"net/http"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ChangeMACRequest struct to change MAC for network
|
||||||
|
type ChangeMACRequest struct {
|
||||||
|
// ID of compute instance
|
||||||
|
// Required: true
|
||||||
|
ComputeID uint64 `url:"compute_id" json:"compute_id" validate:"required"`
|
||||||
|
|
||||||
|
// Current mac address
|
||||||
|
// Required: true
|
||||||
|
СurrentMAC string `url:"current_mac_address" json:"current_mac_address" validate:"required"`
|
||||||
|
|
||||||
|
// the MAC address to which we will change the existing one
|
||||||
|
// Required: true
|
||||||
|
NewMAC string `url:"new_mac_address" json:"new_mac_address" validate:"required"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ChangeMAC change MAC for compute instance
|
||||||
|
func (c Compute) ChangeMAC(ctx context.Context, req ChangeMACRequest) (bool, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudapi/compute/changeMac"
|
||||||
|
|
||||||
|
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
|
||||||
|
}
|
||||||
@@ -25,6 +25,11 @@ type CloneRequest struct {
|
|||||||
// Name of the parent's snapshot to create clone from
|
// Name of the parent's snapshot to create clone from
|
||||||
// Required: false
|
// Required: false
|
||||||
SnapshotName string `url:"snapshotName,omitempty" json:"snapshotName,omitempty"`
|
SnapshotName string `url:"snapshotName,omitempty" json:"snapshotName,omitempty"`
|
||||||
|
|
||||||
|
// true ignore that the compute is running
|
||||||
|
// Default: false
|
||||||
|
// Required: false
|
||||||
|
Force bool `url:"force" json:"force"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clone clones compute instance
|
// Clone clones compute instance
|
||||||
|
|||||||
@@ -39,10 +39,6 @@ type CreateTemplateFromBlankRequest struct {
|
|||||||
// Required: false
|
// Required: false
|
||||||
AccountID uint64 `url:"accountId,omitempty" json:"accountId,omitempty"`
|
AccountID uint64 `url:"accountId,omitempty" json:"accountId,omitempty"`
|
||||||
|
|
||||||
// SEP ID
|
|
||||||
// Required: false
|
|
||||||
SepID uint64 `url:"sepId,omitempty" json:"sepId,omitempty"`
|
|
||||||
|
|
||||||
// Pool for image create
|
// Pool for image create
|
||||||
// Required: false
|
// Required: false
|
||||||
PoolName string `url:"poolName,omitempty" json:"poolName,omitempty"`
|
PoolName string `url:"poolName,omitempty" json:"poolName,omitempty"`
|
||||||
|
|||||||
@@ -24,8 +24,8 @@ type DiskMigrateRequest struct {
|
|||||||
|
|
||||||
// Migration mode. 1 - Data migration and domain update were already completed by third-party software.
|
// Migration mode. 1 - Data migration and domain update were already completed by third-party software.
|
||||||
// Use this if target disk already connected to compute and you only need to save changes for next reboot.
|
// Use this if target disk already connected to compute and you only need to save changes for next reboot.
|
||||||
// Required: true
|
// Required: false
|
||||||
Mode int64 `url:"mode" json:"mode" validate:"required"`
|
Mode int64 `url:"mode,omitempty" json:"mode,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// DiskMigrate - migrate compute's disk to target disk. Source disk will be detached, target disk will be attached to the same PCI slot.
|
// DiskMigrate - migrate compute's disk to target disk. Source disk will be detached, target disk will be attached to the same PCI slot.
|
||||||
|
|||||||
@@ -48,8 +48,7 @@ var computes = ListComputes{
|
|||||||
Devices: nil,
|
Devices: nil,
|
||||||
Disks: []InfoDisk{
|
Disks: []InfoDisk{
|
||||||
{
|
{
|
||||||
ID: 65191,
|
ID: 65191,
|
||||||
PCISlot: 6,
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Driver: "KVM_X86",
|
Driver: "KVM_X86",
|
||||||
@@ -64,7 +63,7 @@ var computes = ListComputes{
|
|||||||
MigrationJob: 0,
|
MigrationJob: 0,
|
||||||
Milestones: 363500,
|
Milestones: 363500,
|
||||||
Name: "test",
|
Name: "test",
|
||||||
Pinned: false,
|
PinnedToStack: true,
|
||||||
RAM: 4096,
|
RAM: 4096,
|
||||||
ReferenceID: "c7cb19ac-af4a-4067-852f-c5572949207e",
|
ReferenceID: "c7cb19ac-af4a-4067-852f-c5572949207e",
|
||||||
Registered: true,
|
Registered: true,
|
||||||
@@ -111,8 +110,7 @@ var computes = ListComputes{
|
|||||||
Devices: nil,
|
Devices: nil,
|
||||||
Disks: []InfoDisk{
|
Disks: []InfoDisk{
|
||||||
{
|
{
|
||||||
ID: 65248,
|
ID: 65248,
|
||||||
PCISlot: 6,
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Driver: "KVM_X86",
|
Driver: "KVM_X86",
|
||||||
@@ -127,10 +125,10 @@ var computes = ListComputes{
|
|||||||
MigrationJob: 0,
|
MigrationJob: 0,
|
||||||
Milestones: 363853,
|
Milestones: 363853,
|
||||||
Name: "compute_2",
|
Name: "compute_2",
|
||||||
Pinned: false,
|
|
||||||
RAM: 4096,
|
RAM: 4096,
|
||||||
ReferenceID: "a542c449-5b1c-4f90-88c5-7bb5f8ae68ff",
|
ReferenceID: "a542c449-5b1c-4f90-88c5-7bb5f8ae68ff",
|
||||||
Registered: true,
|
Registered: true,
|
||||||
|
PinnedToStack: true,
|
||||||
ResName: "compute-48556",
|
ResName: "compute-48556",
|
||||||
RGID: 79727,
|
RGID: 79727,
|
||||||
RGName: "sdk_negative_fields_test",
|
RGName: "sdk_negative_fields_test",
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ func (c Compute) GetLogGet(ctx context.Context, req GetLogRequest) (string, erro
|
|||||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
url := "/cloudapi//compute/getLog"
|
url := "/cloudapi/compute/getLog"
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodGet, url, req)
|
res, err := c.client.DecortApiCall(ctx, http.MethodGet, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -214,6 +214,9 @@ type RecordNetAttach struct {
|
|||||||
|
|
||||||
// List VNF IDs
|
// List VNF IDs
|
||||||
VNFs []uint64 `json:"vnfs"`
|
VNFs []uint64 `json:"vnfs"`
|
||||||
|
|
||||||
|
// Maximum transmission unit
|
||||||
|
MTU uint64 `json:"mtu"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Detailed information about audit
|
// Detailed information about audit
|
||||||
@@ -296,18 +299,27 @@ type RecordCompute struct {
|
|||||||
// List anti affinity rules
|
// List anti affinity rules
|
||||||
AntiAffinityRules ListRules `json:"antiAffinityRules"`
|
AntiAffinityRules ListRules `json:"antiAffinityRules"`
|
||||||
|
|
||||||
|
// Auto start when node restarted
|
||||||
|
AutoStart bool `json:"autoStart"`
|
||||||
|
|
||||||
// Architecture
|
// Architecture
|
||||||
Architecture string `json:"arch"`
|
Architecture string `json:"arch"`
|
||||||
|
|
||||||
// Boot order
|
// Boot order
|
||||||
BootOrder []string `json:"bootOrder"`
|
BootOrder []string `json:"bootOrder"`
|
||||||
|
|
||||||
|
// Boot type
|
||||||
|
BootType string `json:"bootType"`
|
||||||
|
|
||||||
// Boot disk size
|
// Boot disk size
|
||||||
BootDiskSize uint64 `json:"bootdiskSize"`
|
BootDiskSize uint64 `json:"bootdiskSize"`
|
||||||
|
|
||||||
// cd Image Id
|
// CD Image Id
|
||||||
CdImageId uint64 `json:"cdImageId"`
|
CdImageId uint64 `json:"cdImageId"`
|
||||||
|
|
||||||
|
// Chipset
|
||||||
|
Chipset string `json:"chipset"`
|
||||||
|
|
||||||
// Clone reference
|
// Clone reference
|
||||||
CloneReference uint64 `json:"cloneReference"`
|
CloneReference uint64 `json:"cloneReference"`
|
||||||
|
|
||||||
@@ -359,6 +371,9 @@ type RecordCompute struct {
|
|||||||
// HPBacked
|
// HPBacked
|
||||||
HPBacked bool `json:"hpBacked"`
|
HPBacked bool `json:"hpBacked"`
|
||||||
|
|
||||||
|
// Hot resize
|
||||||
|
HotResize bool `json:"hotResize"`
|
||||||
|
|
||||||
// ID
|
// ID
|
||||||
ID uint64 `json:"id"`
|
ID uint64 `json:"id"`
|
||||||
|
|
||||||
@@ -371,6 +386,9 @@ type RecordCompute struct {
|
|||||||
// List interfaces
|
// List interfaces
|
||||||
Interfaces ListInterfaces `json:"interfaces"`
|
Interfaces ListInterfaces `json:"interfaces"`
|
||||||
|
|
||||||
|
// Loader type
|
||||||
|
LoaderType string `json:"loaderType"`
|
||||||
|
|
||||||
// Lock status
|
// Lock status
|
||||||
LockStatus string `json:"lockStatus"`
|
LockStatus string `json:"lockStatus"`
|
||||||
|
|
||||||
@@ -392,6 +410,9 @@ type RecordCompute struct {
|
|||||||
// NeedReboot
|
// NeedReboot
|
||||||
NeedReboot bool `json:"needReboot"`
|
NeedReboot bool `json:"needReboot"`
|
||||||
|
|
||||||
|
// Network interface naming
|
||||||
|
NetworkInterfaceNaming string `json:"networkInterfaceNaming"`
|
||||||
|
|
||||||
// Numa Affinity
|
// Numa Affinity
|
||||||
NumaAffinity string `json:"numaAffinity"`
|
NumaAffinity string `json:"numaAffinity"`
|
||||||
|
|
||||||
@@ -416,8 +437,11 @@ type RecordCompute struct {
|
|||||||
// List OS Users
|
// List OS Users
|
||||||
OSUsers ListOSUser `json:"osUsers"`
|
OSUsers ListOSUser `json:"osUsers"`
|
||||||
|
|
||||||
// Pinned or not
|
// Pinned to stack
|
||||||
Pinned bool `json:"pinned"`
|
PinnedToStack bool `json:"pinnedToStack"`
|
||||||
|
|
||||||
|
// PreferredCPU
|
||||||
|
PreferredCPU []int64 `json:"preferredCpu"`
|
||||||
|
|
||||||
// Number of RAM
|
// Number of RAM
|
||||||
RAM uint64 `json:"ram"`
|
RAM uint64 `json:"ram"`
|
||||||
@@ -478,6 +502,33 @@ type RecordCompute struct {
|
|||||||
|
|
||||||
// Virtual image name
|
// Virtual image name
|
||||||
VirtualImageName string `json:"virtualImageName"`
|
VirtualImageName string `json:"virtualImageName"`
|
||||||
|
|
||||||
|
// VNC password
|
||||||
|
VNCPassword string `json:"vncPasswd"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Information about libvirt settings
|
||||||
|
type LibvirtSettings struct {
|
||||||
|
// TX mode
|
||||||
|
TXMode string `json:"txmode"`
|
||||||
|
|
||||||
|
// IO event
|
||||||
|
IOEventFD string `json:"ioeventfd"`
|
||||||
|
|
||||||
|
// Event ID
|
||||||
|
EventIDx string `json:"event_idx"`
|
||||||
|
|
||||||
|
// Number of queues
|
||||||
|
Queues uint64 `json:"queues"`
|
||||||
|
|
||||||
|
// RX queue size
|
||||||
|
RXQueueSize uint64 `json:"rx_queue_size"`
|
||||||
|
|
||||||
|
// TX queue size
|
||||||
|
TXQueueSize uint64 `json:"tx_queue_size"`
|
||||||
|
|
||||||
|
// GUID
|
||||||
|
GUID string `json:"guid"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Main information about OS user
|
// Main information about OS user
|
||||||
@@ -518,6 +569,9 @@ type ListSnapSets []ItemSnapSet
|
|||||||
|
|
||||||
// Main information about VNF
|
// Main information about VNF
|
||||||
type ItemVNFInterface struct {
|
type ItemVNFInterface struct {
|
||||||
|
// Bus number
|
||||||
|
BusNumber uint64 `json:"bus_number"`
|
||||||
|
|
||||||
// Connection ID
|
// Connection ID
|
||||||
ConnID uint64 `json:"connId"`
|
ConnID uint64 `json:"connId"`
|
||||||
|
|
||||||
@@ -542,9 +596,15 @@ type ItemVNFInterface struct {
|
|||||||
// Listen SSH or not
|
// Listen SSH or not
|
||||||
ListenSSH bool `json:"listenSsh"`
|
ListenSSH bool `json:"listenSsh"`
|
||||||
|
|
||||||
|
// Libvirt Settings
|
||||||
|
LibvirtSettings LibvirtSettings `json:"libvirtSettings"`
|
||||||
|
|
||||||
// MAC
|
// MAC
|
||||||
MAC string `json:"mac"`
|
MAC string `json:"mac"`
|
||||||
|
|
||||||
|
// Maximum transmission unit
|
||||||
|
MTU uint64 `json:"mtu"`
|
||||||
|
|
||||||
// Name
|
// Name
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
|
|
||||||
@@ -603,6 +663,9 @@ type ItemComputeDisk struct {
|
|||||||
// Boot partition
|
// Boot partition
|
||||||
BootPartition uint64 `json:"bootPartition"`
|
BootPartition uint64 `json:"bootPartition"`
|
||||||
|
|
||||||
|
// Bus number
|
||||||
|
BusNumber uint64 `json:"bus_number"`
|
||||||
|
|
||||||
// Created time
|
// Created time
|
||||||
CreatedTime uint64 `json:"createdTime"`
|
CreatedTime uint64 `json:"createdTime"`
|
||||||
|
|
||||||
@@ -661,13 +724,13 @@ type ItemComputeDisk struct {
|
|||||||
Passwd string `json:"passwd"`
|
Passwd string `json:"passwd"`
|
||||||
|
|
||||||
// PCI slot
|
// PCI slot
|
||||||
PCISlot int64 `json:"pciSlot"`
|
PCISlot int64 `json:"pci_slot"`
|
||||||
|
|
||||||
// Pool
|
// Pool
|
||||||
Pool string `json:"pool"`
|
Pool string `json:"pool"`
|
||||||
|
|
||||||
// Present to
|
// Present to
|
||||||
PresentTo []uint64 `json:"presentTo"`
|
PresentTo map[string]uint64 `json:"presentTo"`
|
||||||
|
|
||||||
// Purge time
|
// Purge time
|
||||||
PurgeTime uint64 `json:"purgeTime"`
|
PurgeTime uint64 `json:"purgeTime"`
|
||||||
@@ -690,6 +753,9 @@ type ItemComputeDisk struct {
|
|||||||
// Shareable
|
// Shareable
|
||||||
Shareable bool `json:"shareable"`
|
Shareable bool `json:"shareable"`
|
||||||
|
|
||||||
|
// Size available
|
||||||
|
SizeAvailable float64 `json:"sizeAvailable"`
|
||||||
|
|
||||||
// Size max
|
// Size max
|
||||||
SizeMax uint64 `json:"sizeMax"`
|
SizeMax uint64 `json:"sizeMax"`
|
||||||
|
|
||||||
@@ -708,6 +774,9 @@ type ItemComputeDisk struct {
|
|||||||
// Type
|
// Type
|
||||||
Type string `json:"type"`
|
Type string `json:"type"`
|
||||||
|
|
||||||
|
// Updated by
|
||||||
|
UpdatedBy string `json:"updatedBy"`
|
||||||
|
|
||||||
// Virtual machine ID
|
// Virtual machine ID
|
||||||
VMID uint64 `json:"vmid"`
|
VMID uint64 `json:"vmid"`
|
||||||
}
|
}
|
||||||
@@ -824,18 +893,27 @@ type ItemCompute struct {
|
|||||||
// List anti affinity rules
|
// List anti affinity rules
|
||||||
AntiAffinityRules ListRules `json:"antiAffinityRules"`
|
AntiAffinityRules ListRules `json:"antiAffinityRules"`
|
||||||
|
|
||||||
|
// Auto start when node restarted
|
||||||
|
AutoStart bool `json:"autoStart"`
|
||||||
|
|
||||||
// Architecture
|
// Architecture
|
||||||
Architecture string `json:"arch"`
|
Architecture string `json:"arch"`
|
||||||
|
|
||||||
// Boot order
|
// Boot order
|
||||||
BootOrder []string `json:"bootOrder"`
|
BootOrder []string `json:"bootOrder"`
|
||||||
|
|
||||||
|
// Boot type
|
||||||
|
BootType string `json:"bootType"`
|
||||||
|
|
||||||
// Boot disk size
|
// Boot disk size
|
||||||
BootDiskSize uint64 `json:"bootdiskSize"`
|
BootDiskSize uint64 `json:"bootdiskSize"`
|
||||||
|
|
||||||
// cd Image Id
|
// CD Image Id
|
||||||
CdImageId uint64 `json:"cdImageId"`
|
CdImageId uint64 `json:"cdImageId"`
|
||||||
|
|
||||||
|
// Chipset
|
||||||
|
Chipset string `json:"chipset"`
|
||||||
|
|
||||||
// Clone reference
|
// Clone reference
|
||||||
CloneReference uint64 `json:"cloneReference"`
|
CloneReference uint64 `json:"cloneReference"`
|
||||||
|
|
||||||
@@ -884,6 +962,9 @@ type ItemCompute struct {
|
|||||||
// GUID
|
// GUID
|
||||||
GUID uint64 `json:"guid"`
|
GUID uint64 `json:"guid"`
|
||||||
|
|
||||||
|
// Hot resize
|
||||||
|
HotResize bool `json:"hotResize"`
|
||||||
|
|
||||||
// HPBacked
|
// HPBacked
|
||||||
HPBacked bool `json:"hpBacked"`
|
HPBacked bool `json:"hpBacked"`
|
||||||
|
|
||||||
@@ -896,6 +977,9 @@ type ItemCompute struct {
|
|||||||
// List interfaces
|
// List interfaces
|
||||||
Interfaces ListInterfaces `json:"interfaces"`
|
Interfaces ListInterfaces `json:"interfaces"`
|
||||||
|
|
||||||
|
// Loader type
|
||||||
|
LoaderType string `json:"loaderType"`
|
||||||
|
|
||||||
// Lock status
|
// Lock status
|
||||||
LockStatus string `json:"lockStatus"`
|
LockStatus string `json:"lockStatus"`
|
||||||
|
|
||||||
@@ -917,14 +1001,20 @@ type ItemCompute struct {
|
|||||||
// NeedReboot
|
// NeedReboot
|
||||||
NeedReboot bool `json:"needReboot"`
|
NeedReboot bool `json:"needReboot"`
|
||||||
|
|
||||||
|
// network interface naming
|
||||||
|
NetworkInterfaceNaming string `json:"networkInterfaceNaming"`
|
||||||
|
|
||||||
// Numa Affinity
|
// Numa Affinity
|
||||||
NumaAffinity string `json:"numaAffinity"`
|
NumaAffinity string `json:"numaAffinity"`
|
||||||
|
|
||||||
//NumaNodeId
|
//NumaNodeId
|
||||||
NumaNodeId int64 `json:"numaNodeId"`
|
NumaNodeId int64 `json:"numaNodeId"`
|
||||||
|
|
||||||
// Pinned or not
|
// Pinned to stack
|
||||||
Pinned bool `json:"pinned"`
|
PinnedToStack bool `json:"pinnedToStack"`
|
||||||
|
|
||||||
|
// PreferredCPU
|
||||||
|
PreferredCPU []int64 `json:"preferredCpu"`
|
||||||
|
|
||||||
// Number of RAM
|
// Number of RAM
|
||||||
RAM uint64 `json:"ram"`
|
RAM uint64 `json:"ram"`
|
||||||
@@ -994,9 +1084,6 @@ type ListInfoDisks []InfoDisk
|
|||||||
type InfoDisk struct {
|
type InfoDisk struct {
|
||||||
// ID
|
// ID
|
||||||
ID uint64 `json:"id"`
|
ID uint64 `json:"id"`
|
||||||
|
|
||||||
// PCISlot
|
|
||||||
PCISlot int64 `json:"pciSlot"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// List information about computes
|
// List information about computes
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ type NetAttachRequest struct {
|
|||||||
// 'EXTNET' for connect to external network directly
|
// 'EXTNET' for connect to external network directly
|
||||||
// 'VINS' for connect to ViNS
|
// 'VINS' for connect to ViNS
|
||||||
// 'VFNIC' for connect to vfpool
|
// 'VFNIC' for connect to vfpool
|
||||||
|
// 'DPDK' for connect to DPDK
|
||||||
// Required: true
|
// Required: true
|
||||||
NetType string `url:"netType" json:"netType" validate:"computex86NetType"`
|
NetType string `url:"netType" json:"netType" validate:"computex86NetType"`
|
||||||
|
|
||||||
@@ -30,6 +31,14 @@ type NetAttachRequest struct {
|
|||||||
// Directly required IP address for new network interface
|
// Directly required IP address for new network interface
|
||||||
// Required: false
|
// Required: false
|
||||||
IPAddr string `url:"ipAddr,omitempty" json:"ipAddr,omitempty"`
|
IPAddr string `url:"ipAddr,omitempty" json:"ipAddr,omitempty"`
|
||||||
|
|
||||||
|
// MAC address
|
||||||
|
// Required: false
|
||||||
|
MACAddr string `url:"mac_addr,omitempty" json:"mac_addr,omitempty"`
|
||||||
|
|
||||||
|
// Used only for DPDK type, must be 1-9216
|
||||||
|
// Required: false
|
||||||
|
MTU uint64 `url:"mtu,omitempty" json:"mtu,omitempty" validate:"omitempty,mtu"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// NetAttach attaches network to compute and gets info about network
|
// NetAttach attaches network to compute and gets info about network
|
||||||
|
|||||||
@@ -13,25 +13,30 @@ type PinToStackRequest struct {
|
|||||||
// ID of the compute instance
|
// ID of the compute instance
|
||||||
// Required: true
|
// Required: true
|
||||||
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
|
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
|
||||||
|
|
||||||
|
// Auto start when node restarted
|
||||||
|
// Required: false
|
||||||
|
// Default: false
|
||||||
|
AutoStart bool `url:"autoStart" json:"autoStart"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// PinToStack pin compute to current stack
|
// PinToStack pin compute to current stack
|
||||||
func (c Compute) PinToStack(ctx context.Context, req PinToStackRequest) (uint64, error) {
|
func (c Compute) PinToStack(ctx context.Context, req PinToStackRequest) (bool, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, validators.ValidationErrors(validators.GetErrors(err))
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
url := "/cloudapi/compute/pinToStack"
|
url := "/cloudapi/compute/pinToStack"
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
result, err := strconv.ParseUint(string(res), 10, 64)
|
result, err := strconv.ParseBool(string(res))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
|
|||||||
@@ -27,6 +27,10 @@ type ResizeRequest struct {
|
|||||||
// Force compute resize
|
// Force compute resize
|
||||||
// Required: false
|
// Required: false
|
||||||
Force bool `url:"force,omitempty" json:"force,omitempty"`
|
Force bool `url:"force,omitempty" json:"force,omitempty"`
|
||||||
|
|
||||||
|
// Recommended isolated CPUs. Field is ignored if compute.cpupin=False or compute.pinned=False
|
||||||
|
// Required: false
|
||||||
|
PreferredCPU []int64 `url:"preferredCpu,omitempty" json:"preferredCpu,omitempty" validate:"omitempty,preferredCPU"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetRAM returns RAM field values
|
// GetRAM returns RAM field values
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ package compute
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
|
||||||
|
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
)
|
)
|
||||||
@@ -19,24 +18,52 @@ type SnapshotDeleteRequest struct {
|
|||||||
Label string `url:"label" json:"label" validate:"required"`
|
Label string `url:"label" json:"label" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type wrapperSnapshotDeleteRequeststruct struct {
|
||||||
|
SnapshotDeleteRequest
|
||||||
|
|
||||||
|
AsyncMode bool `url:"asyncMode"`
|
||||||
|
}
|
||||||
|
|
||||||
// SnapshotDelete deletes specified compute snapshot
|
// SnapshotDelete deletes specified compute snapshot
|
||||||
func (c Compute) SnapshotDelete(ctx context.Context, req SnapshotDeleteRequest) (bool, error) {
|
func (c Compute) SnapshotDelete(ctx context.Context, req SnapshotDeleteRequest) (string, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||||
|
}
|
||||||
|
|
||||||
|
reqWrapped := wrapperSnapshotDeleteRequeststruct{
|
||||||
|
SnapshotDeleteRequest: req,
|
||||||
|
AsyncMode: false,
|
||||||
}
|
}
|
||||||
|
|
||||||
url := "/cloudapi/compute/snapshotDelete"
|
url := "/cloudapi/compute/snapshotDelete"
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
result, err := strconv.ParseBool(string(res))
|
return string(res), nil
|
||||||
if err != nil {
|
}
|
||||||
return false, err
|
|
||||||
}
|
// SnapshotDeleteAsync deletes specified compute snapshot
|
||||||
|
func (c Compute) SnapshotDeleteAsync(ctx context.Context, req SnapshotDeleteRequest) (string, error) {
|
||||||
return result, nil
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||||
|
}
|
||||||
|
|
||||||
|
reqWrapped := wrapperSnapshotDeleteRequeststruct{
|
||||||
|
SnapshotDeleteRequest: req,
|
||||||
|
AsyncMode: true,
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudapi/compute/snapshotDelete"
|
||||||
|
|
||||||
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
|
||||||
|
return string(res), nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,15 +30,41 @@ type UpdateRequest struct {
|
|||||||
// Default: none
|
// Default: none
|
||||||
NumaAffinity string `url:"numaAffinity,omitempty" json:"numaAffinity,omitempty" validate:"omitempty,numaAffinity"`
|
NumaAffinity string `url:"numaAffinity,omitempty" json:"numaAffinity,omitempty" validate:"omitempty,numaAffinity"`
|
||||||
|
|
||||||
// Run VM on dedicated CPUs. To use this feature, the system must be pre-configured by allocating CPUs on the physical node
|
// Run VM on dedicated CPUs. To use this feature, the system must be pre-configured by allocating CPUs on the physical node, true or false
|
||||||
// Required: false
|
// Required: false
|
||||||
// Default: false
|
CPUPin interface{} `url:"cpupin,omitempty" json:"cpupin,omitempty" validate:"omitempty,isBool"`
|
||||||
CPUPin bool `url:"cpupin" json:"cpupin"`
|
|
||||||
|
|
||||||
// Use Huge Pages to allocate RAM of the virtual machine. The system must be pre-configured by allocating Huge Pages on the physical node
|
// Type of the emulated system, Q35 or i440fx
|
||||||
// Required: false
|
// Required: false
|
||||||
// Default: false
|
Chipset string `url:"chipset,omitempty" json:"chipset,omitempty" validate:"omitempty,chipset"`
|
||||||
HPBacked bool `url:"hpBacked" json:"hpBacked"`
|
|
||||||
|
// Use Huge Pages to allocate RAM of the virtual machine. The system must be pre-configured by allocating Huge Pages on the physical node, true or false
|
||||||
|
// Required: false
|
||||||
|
HPBacked interface{} `url:"hpBacked,omitempty" json:"hpBacked,omitempty" validate:"omitempty,isBool"`
|
||||||
|
|
||||||
|
// Auto start when node restarted, true or false
|
||||||
|
// Required: false
|
||||||
|
AutoStart interface{} `url:"autoStart,omitempty" json:"autoStart,omitempty" validate:"omitempty,isBool"`
|
||||||
|
|
||||||
|
// Recommended isolated CPUs. Field is ignored if compute.cpupin=False or compute.pinned=False
|
||||||
|
// Required: false
|
||||||
|
PreferredCPU []int64 `url:"preferredCpu,omitempty" json:"preferredCpu,omitempty" validate:"omitempty,preferredCPU"`
|
||||||
|
|
||||||
|
// VM type linux, windows or unknown
|
||||||
|
// Required: false
|
||||||
|
LoaderType string `url:"loaderType,omitempty" json:"loaderType,omitempty" validate:"omitempty,loaderType"`
|
||||||
|
|
||||||
|
// Boot type of image bios or uefi
|
||||||
|
// Required: false
|
||||||
|
BootType string `url:"bootType,omitempty" json:"bootType,omitempty" validate:"omitempty,imageBootType"`
|
||||||
|
|
||||||
|
// Select a network interface naming pattern for your Linux machine. eth - onboard, ens - pci slot naming.
|
||||||
|
// Required: false
|
||||||
|
NetworkInterfaceNaming string `url:"networkInterfaceNaming,omitempty" json:"networkInterfaceNaming,omitempty" validate:"omitempty,networkInterfaceNaming"`
|
||||||
|
|
||||||
|
// Does this machine supports hot resize, true or false
|
||||||
|
// Required: false
|
||||||
|
HotResize interface{} `url:"hotResize,omitempty" json:"hotResize,omitempty" validate:"omitempty,isBool"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update updates some properties of the compute
|
// Update updates some properties of the compute
|
||||||
|
|||||||
@@ -3,8 +3,9 @@ package disks
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"net/http"
|
"net/http"
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
)
|
)
|
||||||
|
|
||||||
// CreateRequest struct to create disk
|
// CreateRequest struct to create disk
|
||||||
@@ -13,10 +14,6 @@ type CreateRequest struct {
|
|||||||
// Required: true
|
// Required: true
|
||||||
AccountID uint64 `url:"accountId" json:"accountId" validate:"required"`
|
AccountID uint64 `url:"accountId" json:"accountId" validate:"required"`
|
||||||
|
|
||||||
// ID of the grid (platform)
|
|
||||||
// Required: true
|
|
||||||
GID uint64 `url:"gid" json:"gid" validate:"required"`
|
|
||||||
|
|
||||||
// Name of disk
|
// Name of disk
|
||||||
// Required: true
|
// Required: true
|
||||||
Name string `url:"name" json:"name" validate:"required"`
|
Name string `url:"name" json:"name" validate:"required"`
|
||||||
@@ -29,17 +26,6 @@ type CreateRequest struct {
|
|||||||
// Required: false
|
// Required: false
|
||||||
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
||||||
|
|
||||||
// Type of disk
|
|
||||||
// - B=Boot
|
|
||||||
// - D=Data
|
|
||||||
// - T=Temp
|
|
||||||
// Required: true
|
|
||||||
Type string `url:"type" json:"type" validate:"diskType"`
|
|
||||||
|
|
||||||
// Size in GB default is 0
|
|
||||||
// Required: false
|
|
||||||
SSDSize uint64 `url:"ssdSize,omitempty" json:"ssdSize,omitempty"`
|
|
||||||
|
|
||||||
// Max IOPS disk can perform defaults to 2000
|
// Max IOPS disk can perform defaults to 2000
|
||||||
// Required: false
|
// Required: false
|
||||||
IOPS uint64 `url:"iops,omitempty" json:"iops,omitempty"`
|
IOPS uint64 `url:"iops,omitempty" json:"iops,omitempty"`
|
||||||
|
|||||||
@@ -21,10 +21,6 @@ type DeleteRequest struct {
|
|||||||
// Whether to completely delete the disk, works only with non attached disks
|
// Whether to completely delete the disk, works only with non attached disks
|
||||||
// Required: false
|
// Required: false
|
||||||
Permanently bool `url:"permanently,omitempty" json:"permanently,omitempty"`
|
Permanently bool `url:"permanently,omitempty" json:"permanently,omitempty"`
|
||||||
|
|
||||||
// Reason to delete
|
|
||||||
// Required: false
|
|
||||||
Reason string `url:"reason,omitempty" json:"reason,omitempty"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete deletes disk by ID
|
// Delete deletes disk by ID
|
||||||
|
|||||||
@@ -14,10 +14,6 @@ type DisksDeleteRequest struct {
|
|||||||
// Required: true
|
// Required: true
|
||||||
DisksIDs []uint64 `url:"diskIds" json:"diskIds" validate:"required"`
|
DisksIDs []uint64 `url:"diskIds" json:"diskIds" validate:"required"`
|
||||||
|
|
||||||
// Reason for deleting the disks
|
|
||||||
// Required: true
|
|
||||||
Reason string `url:"reason" json:"reason" validate:"required"`
|
|
||||||
|
|
||||||
// Whether to completely delete the disks, works only with non attached disks
|
// Whether to completely delete the disks, works only with non attached disks
|
||||||
// Required: false
|
// Required: false
|
||||||
Permanently bool `url:"permanently,omitempty" json:"permanently,omitempty"`
|
Permanently bool `url:"permanently,omitempty" json:"permanently,omitempty"`
|
||||||
|
|||||||
@@ -35,9 +35,9 @@ var disks = ListDisks{
|
|||||||
ParentID: 0,
|
ParentID: 0,
|
||||||
PCISlot: 6,
|
PCISlot: 6,
|
||||||
Pool: "vmstor",
|
Pool: "vmstor",
|
||||||
PresentTo: []uint64{
|
//PresentTo: []uint64{
|
||||||
27,
|
// 27,
|
||||||
},
|
//},
|
||||||
PurgeTime: 0,
|
PurgeTime: 0,
|
||||||
ResID: "sample",
|
ResID: "sample",
|
||||||
ResName: "sample",
|
ResName: "sample",
|
||||||
@@ -78,10 +78,10 @@ var disks = ListDisks{
|
|||||||
ParentID: 0,
|
ParentID: 0,
|
||||||
PCISlot: 6,
|
PCISlot: 6,
|
||||||
Pool: "vmstor",
|
Pool: "vmstor",
|
||||||
PresentTo: []uint64{
|
//PresentTo: []uint64{
|
||||||
27,
|
// 27,
|
||||||
27,
|
// 27,
|
||||||
},
|
//},
|
||||||
PurgeTime: 0,
|
PurgeTime: 0,
|
||||||
ResID: "sample",
|
ResID: "sample",
|
||||||
ResName: "sample",
|
ResName: "sample",
|
||||||
@@ -211,9 +211,9 @@ var searchDisks = ListSearchDisks{
|
|||||||
ParentID: 0,
|
ParentID: 0,
|
||||||
PCISlot: 6,
|
PCISlot: 6,
|
||||||
Pool: "vmstor",
|
Pool: "vmstor",
|
||||||
PresentTo: []uint64{
|
//PresentTo: []uint64{
|
||||||
27,
|
// 27,
|
||||||
},
|
//},
|
||||||
PurgeTime: 0,
|
PurgeTime: 0,
|
||||||
ResID: "sample",
|
ResID: "sample",
|
||||||
ResName: "sample",
|
ResName: "sample",
|
||||||
@@ -254,10 +254,10 @@ var searchDisks = ListSearchDisks{
|
|||||||
ParentID: 0,
|
ParentID: 0,
|
||||||
PCISlot: 6,
|
PCISlot: 6,
|
||||||
Pool: "vmstor",
|
Pool: "vmstor",
|
||||||
PresentTo: []uint64{
|
//PresentTo: []uint64{
|
||||||
27,
|
// 27,
|
||||||
27,
|
// 27,
|
||||||
},
|
//},
|
||||||
PurgeTime: 0,
|
PurgeTime: 0,
|
||||||
ResID: "sample",
|
ResID: "sample",
|
||||||
ResName: "sample",
|
ResName: "sample",
|
||||||
@@ -393,7 +393,7 @@ var unattachedDisks = ListDisksUnattached{
|
|||||||
Password: "",
|
Password: "",
|
||||||
PCISlot: -1,
|
PCISlot: -1,
|
||||||
Pool: "data05",
|
Pool: "data05",
|
||||||
PresentTo: []uint64{},
|
PresentTo: map[string]uint64{},
|
||||||
PurgeAttempts: 0,
|
PurgeAttempts: 0,
|
||||||
PurgeTime: 0,
|
PurgeTime: 0,
|
||||||
RealityDeviceNumber: 0,
|
RealityDeviceNumber: 0,
|
||||||
@@ -445,10 +445,10 @@ var unattachedDisks = ListDisksUnattached{
|
|||||||
Password: "",
|
Password: "",
|
||||||
PCISlot: -1,
|
PCISlot: -1,
|
||||||
Pool: "data05",
|
Pool: "data05",
|
||||||
PresentTo: []uint64{
|
//PresentTo: []uint64{
|
||||||
27,
|
// 27,
|
||||||
27,
|
// 27,
|
||||||
},
|
//},
|
||||||
PurgeAttempts: 0,
|
PurgeAttempts: 0,
|
||||||
PurgeTime: 0,
|
PurgeTime: 0,
|
||||||
RealityDeviceNumber: 0,
|
RealityDeviceNumber: 0,
|
||||||
|
|||||||
@@ -30,7 +30,6 @@ type FromPlatformDiskRequest struct {
|
|||||||
// Binary architecture of this image
|
// Binary architecture of this image
|
||||||
// Should be:
|
// Should be:
|
||||||
// - X86_64
|
// - X86_64
|
||||||
// - PPC64_LE
|
|
||||||
// Required: true
|
// Required: true
|
||||||
Architecture string `url:"architecture" json:"architecture" validate:"imageArchitecture"`
|
Architecture string `url:"architecture" json:"architecture" validate:"imageArchitecture"`
|
||||||
|
|
||||||
@@ -46,18 +45,14 @@ type FromPlatformDiskRequest struct {
|
|||||||
// Required: false
|
// Required: false
|
||||||
AccountID uint64 `url:"accountId,omitempty" json:"accountId,omitempty"`
|
AccountID uint64 `url:"accountId,omitempty" json:"accountId,omitempty"`
|
||||||
|
|
||||||
// SEP ID
|
|
||||||
// Required: false
|
|
||||||
SepID uint64 `url:"sepId,omitempty" json:"sepId,omitempty"`
|
|
||||||
|
|
||||||
// Pool for image create
|
// Pool for image create
|
||||||
// Required: false
|
// Required: false
|
||||||
PoolName string `url:"poolName,omitempty" json:"poolName,omitempty"`
|
PoolName string `url:"poolName,omitempty" json:"poolName,omitempty"`
|
||||||
|
|
||||||
// List of types of compute suitable for image
|
// List of types of compute suitable for image
|
||||||
// Example: [ "KVM_X86" ]
|
// Example: [ "KVM_X86" ]
|
||||||
// Required: false
|
// Required: true
|
||||||
Drivers []string `url:"drivers,omitempty" json:"drivers,omitempty"`
|
Drivers []string `url:"drivers" json:"drivers" validate:"required"`
|
||||||
|
|
||||||
// Does this machine supports hot resize
|
// Does this machine supports hot resize
|
||||||
// Required: false
|
// Required: false
|
||||||
|
|||||||
@@ -14,9 +14,15 @@ type ItemDisk struct {
|
|||||||
// Computes
|
// Computes
|
||||||
Computes map[string]string `json:"computes"`
|
Computes map[string]string `json:"computes"`
|
||||||
|
|
||||||
|
//Created by
|
||||||
|
CreatedBy string `json:"createdBy"`
|
||||||
|
|
||||||
// Created time
|
// Created time
|
||||||
CreatedTime uint64 `json:"createdTime"`
|
CreatedTime uint64 `json:"createdTime"`
|
||||||
|
|
||||||
|
// Deleted by
|
||||||
|
DeletedBy string `json:"deletedBy"`
|
||||||
|
|
||||||
// Deleted time
|
// Deleted time
|
||||||
DeletedTime uint64 `json:"deletedTime"`
|
DeletedTime uint64 `json:"deletedTime"`
|
||||||
|
|
||||||
@@ -50,6 +56,9 @@ type ItemDisk struct {
|
|||||||
// Machine name
|
// Machine name
|
||||||
MachineName string `json:"machineName"`
|
MachineName string `json:"machineName"`
|
||||||
|
|
||||||
|
// Milestones
|
||||||
|
Milestones uint64 `json:"milestones"`
|
||||||
|
|
||||||
// Name
|
// Name
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
|
|
||||||
@@ -69,7 +78,7 @@ type ItemDisk struct {
|
|||||||
Pool string `json:"pool"`
|
Pool string `json:"pool"`
|
||||||
|
|
||||||
// Present to
|
// Present to
|
||||||
PresentTo []uint64 `json:"presentTo"`
|
PresentTo map[string]uint64 `json:"presentTo"`
|
||||||
|
|
||||||
// Purge time
|
// Purge time
|
||||||
PurgeTime uint64 `json:"purgeTime"`
|
PurgeTime uint64 `json:"purgeTime"`
|
||||||
@@ -95,6 +104,9 @@ type ItemDisk struct {
|
|||||||
// SepID
|
// SepID
|
||||||
SepID uint64 `json:"sepId"`
|
SepID uint64 `json:"sepId"`
|
||||||
|
|
||||||
|
// Size available
|
||||||
|
SizeAvailable float64 `json:"sizeAvailable"`
|
||||||
|
|
||||||
// Size max
|
// Size max
|
||||||
SizeMax uint64 `json:"sizeMax"`
|
SizeMax uint64 `json:"sizeMax"`
|
||||||
|
|
||||||
@@ -115,6 +127,12 @@ type ItemDisk struct {
|
|||||||
|
|
||||||
// Virtual machine ID
|
// Virtual machine ID
|
||||||
VMID uint64 `json:"vmid"`
|
VMID uint64 `json:"vmid"`
|
||||||
|
|
||||||
|
// Update time
|
||||||
|
UpdatedTime uint64 `json:"updatedTime"`
|
||||||
|
|
||||||
|
// Updated by
|
||||||
|
UpdatedBy string `json:"updatedBy"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ItemDiskUnattached struct {
|
type ItemDiskUnattached struct {
|
||||||
@@ -200,7 +218,7 @@ type ItemDiskUnattached struct {
|
|||||||
Pool string `json:"pool"`
|
Pool string `json:"pool"`
|
||||||
|
|
||||||
// Present to
|
// Present to
|
||||||
PresentTo []uint64 `json:"presentTo"`
|
PresentTo map[string]uint64 `json:"presentTo"`
|
||||||
|
|
||||||
// Purge attempts
|
// Purge attempts
|
||||||
PurgeAttempts uint64 `json:"purgeAttempts"`
|
PurgeAttempts uint64 `json:"purgeAttempts"`
|
||||||
@@ -354,9 +372,15 @@ type RecordDisk struct {
|
|||||||
// Computes
|
// Computes
|
||||||
Computes map[string]string `json:"computes"`
|
Computes map[string]string `json:"computes"`
|
||||||
|
|
||||||
|
// Created by
|
||||||
|
CreatedBy string `json:"createdBy"`
|
||||||
|
|
||||||
// Created time
|
// Created time
|
||||||
CreatedTime uint64 `json:"createdTime"`
|
CreatedTime uint64 `json:"createdTime"`
|
||||||
|
|
||||||
|
// Deleted by
|
||||||
|
DeletedBy string `json:"deletedBy"`
|
||||||
|
|
||||||
// Deleted time
|
// Deleted time
|
||||||
DeletedTime uint64 `json:"deletedTime"`
|
DeletedTime uint64 `json:"deletedTime"`
|
||||||
|
|
||||||
@@ -384,6 +408,15 @@ type RecordDisk struct {
|
|||||||
// IOTune
|
// IOTune
|
||||||
IOTune IOTune `json:"iotune"`
|
IOTune IOTune `json:"iotune"`
|
||||||
|
|
||||||
|
// Machine ID
|
||||||
|
MachineID uint64 `json:"machineId"`
|
||||||
|
|
||||||
|
// Machine name
|
||||||
|
MachineName string `json:"machineName"`
|
||||||
|
|
||||||
|
// Milestones
|
||||||
|
Milestones uint64 `json:"milestones"`
|
||||||
|
|
||||||
// Name
|
// Name
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
|
|
||||||
@@ -403,7 +436,7 @@ type RecordDisk struct {
|
|||||||
Pool string `json:"pool"`
|
Pool string `json:"pool"`
|
||||||
|
|
||||||
// Present to
|
// Present to
|
||||||
PresentTo []uint64 `json:"presentTo"`
|
PresentTo map[string]uint64 `json:"presentTo"`
|
||||||
|
|
||||||
// Purge time
|
// Purge time
|
||||||
PurgeTime uint64 `json:"purgeTime"`
|
PurgeTime uint64 `json:"purgeTime"`
|
||||||
@@ -429,6 +462,9 @@ type RecordDisk struct {
|
|||||||
// Shareable
|
// Shareable
|
||||||
Shareable bool `json:"shareable"`
|
Shareable bool `json:"shareable"`
|
||||||
|
|
||||||
|
// Size available
|
||||||
|
SizeAvailable float64 `json:"sizeAvailable"`
|
||||||
|
|
||||||
// Size max
|
// Size max
|
||||||
SizeMax uint64 `json:"sizeMax"`
|
SizeMax uint64 `json:"sizeMax"`
|
||||||
|
|
||||||
@@ -449,6 +485,12 @@ type RecordDisk struct {
|
|||||||
|
|
||||||
// Virtual machine ID
|
// Virtual machine ID
|
||||||
VMID uint64 `json:"vmid"`
|
VMID uint64 `json:"vmid"`
|
||||||
|
|
||||||
|
// Update time
|
||||||
|
UpdatedTime uint64 `json:"updatedTime"`
|
||||||
|
|
||||||
|
// Updated by
|
||||||
|
UpdatedBy string `json:"updatedBy"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ItemReplication struct {
|
type ItemReplication struct {
|
||||||
|
|||||||
@@ -19,31 +19,6 @@ type ResizeRequest struct {
|
|||||||
Size uint64 `url:"size" json:"size" validate:"required"`
|
Size uint64 `url:"size" json:"size" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Resize resizes disk
|
|
||||||
// Returns 200 if disk is resized online, else will return 202,
|
|
||||||
// in that case please stop and start your machine after changing the disk size, for your changes to be reflected.
|
|
||||||
// This method will not be used for disks, assigned to computes. Only unassigned disks and disks, assigned with "old" virtual machines.
|
|
||||||
func (d Disks) Resize(ctx context.Context, req ResizeRequest) (bool, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/disks/resize"
|
|
||||||
|
|
||||||
res, err := d.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
|
|
||||||
}
|
|
||||||
|
|
||||||
// Resize2 resize disk
|
// Resize2 resize disk
|
||||||
// Returns 200 if disk is resized online, else will return 202,
|
// Returns 200 if disk is resized online, else will return 202,
|
||||||
// in that case please stop and start your machine after changing the disk size, for your changes to be reflected.
|
// in that case please stop and start your machine after changing the disk size, for your changes to be reflected.
|
||||||
|
|||||||
@@ -13,10 +13,6 @@ type RestoreRequest struct {
|
|||||||
// ID of the disk to restore
|
// ID of the disk to restore
|
||||||
// Required: true
|
// Required: true
|
||||||
DiskID uint64 `url:"diskId" json:"diskId" validate:"required"`
|
DiskID uint64 `url:"diskId" json:"diskId" validate:"required"`
|
||||||
|
|
||||||
// Reason for restoring the disk
|
|
||||||
// Required: true
|
|
||||||
Reason string `url:"reason" json:"reason" validate:"required"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Restore restores a deleted unattached disk from recycle bin
|
// Restore restores a deleted unattached disk from recycle bin
|
||||||
|
|||||||
8
pkg/cloudapi/dpdknet.go
Normal file
8
pkg/cloudapi/dpdknet.go
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
package cloudapi
|
||||||
|
|
||||||
|
import "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/dpdknet"
|
||||||
|
|
||||||
|
// Accessing the DPDKNet method group
|
||||||
|
func (ca *CloudAPI) DPDKNet() *dpdknet.DPDKNet {
|
||||||
|
return dpdknet.New(ca.client)
|
||||||
|
}
|
||||||
15
pkg/cloudapi/dpdknet/dpdknet.go
Normal file
15
pkg/cloudapi/dpdknet/dpdknet.go
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
package dpdknet
|
||||||
|
|
||||||
|
import "repository.basistech.ru/BASIS/decort-golang-sdk/interfaces"
|
||||||
|
|
||||||
|
// Structure for creating request to DPDK network
|
||||||
|
type DPDKNet struct {
|
||||||
|
client interfaces.Caller
|
||||||
|
}
|
||||||
|
|
||||||
|
// Builder for dpdk endpoints
|
||||||
|
func New(client interfaces.Caller) *DPDKNet {
|
||||||
|
return &DPDKNet{
|
||||||
|
client,
|
||||||
|
}
|
||||||
|
}
|
||||||
46
pkg/cloudapi/dpdknet/get.go
Normal file
46
pkg/cloudapi/dpdknet/get.go
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
package dpdknet
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"encoding/json"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
|
)
|
||||||
|
|
||||||
|
// GetRequest struct to get information about DPDK network
|
||||||
|
type GetRequest struct {
|
||||||
|
// ID of the DPDK network
|
||||||
|
// Required: true
|
||||||
|
DPDKID uint64 `url:"dpdkId" json:"dpdkId" validate:"required"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get DPDK network details as a RecordDPDKNet struct
|
||||||
|
func (d DPDKNet) Get(ctx context.Context, req GetRequest) (*RecordDPDKNet, error) {
|
||||||
|
res, err := d.GetRaw(ctx, req)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
info := RecordDPDKNet{}
|
||||||
|
|
||||||
|
err = json.Unmarshal(res, &info)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return &info, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetRaw gets DPDK network details as an array of bytes
|
||||||
|
func (d DPDKNet) GetRaw(ctx context.Context, req GetRequest) ([]byte, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudapi/dpdknet/get"
|
||||||
|
|
||||||
|
res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
79
pkg/cloudapi/dpdknet/list.go
Normal file
79
pkg/cloudapi/dpdknet/list.go
Normal file
@@ -0,0 +1,79 @@
|
|||||||
|
package dpdknet
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"encoding/json"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ListRequest struct to get list of DPDK networks
|
||||||
|
type ListRequest struct {
|
||||||
|
// Find by id
|
||||||
|
// Required: false
|
||||||
|
ByID uint64 `url:"by_id,omitempty" json:"by_id,omitempty"`
|
||||||
|
|
||||||
|
// Find by gid
|
||||||
|
// Required: false
|
||||||
|
GID uint64 `url:"gid,omitempty" json:"gid,omitempty"`
|
||||||
|
|
||||||
|
// Find by name
|
||||||
|
// Required: false
|
||||||
|
Name string `url:"name,omitempty" json:"name,omitempty"`
|
||||||
|
|
||||||
|
// Find by description
|
||||||
|
// Required: false
|
||||||
|
Description string `url:"description,omitempty" json:"description,omitempty"`
|
||||||
|
|
||||||
|
// Find by status
|
||||||
|
// Required: false
|
||||||
|
Status string `url:"status,omitempty" json:"status,omitempty"`
|
||||||
|
|
||||||
|
// Find by computeIDs
|
||||||
|
// Required: false
|
||||||
|
ComputeIDs []uint64 `url:"computeIds,omitempty" json:"computeIds,omitempty"`
|
||||||
|
|
||||||
|
// Sort by one of supported fields, format +|-(field)
|
||||||
|
// Required: false
|
||||||
|
SortBy string `url:"sortBy,omitempty" json:"sortBy,omitempty" validate:"omitempty,sortBy"`
|
||||||
|
|
||||||
|
// 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 the created DPDK networks belonging to an account as a ListDPDKNet struct
|
||||||
|
func (d DPDKNet) List(ctx context.Context, req ListRequest) (*ListDPDKNet, error) {
|
||||||
|
|
||||||
|
res, err := d.ListRaw(ctx, req)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
list := ListDPDKNet{}
|
||||||
|
|
||||||
|
err = json.Unmarshal(res, &list)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return &list, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListRaw gets list of the created DPDK networks belonging to an account as an array of bytes
|
||||||
|
func (d DPDKNet) ListRaw(ctx context.Context, req ListRequest) ([]byte, error) {
|
||||||
|
|
||||||
|
if err := validators.ValidateRequest(req); err != nil {
|
||||||
|
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudapi/dpdknet/list"
|
||||||
|
|
||||||
|
res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
92
pkg/cloudapi/dpdknet/models.go
Normal file
92
pkg/cloudapi/dpdknet/models.go
Normal file
@@ -0,0 +1,92 @@
|
|||||||
|
package dpdknet
|
||||||
|
|
||||||
|
// Detailed information about DPDK network
|
||||||
|
type RecordDPDKNet struct {
|
||||||
|
// List of accounts with access
|
||||||
|
AccountAccess []uint64 `json:"accountAccess"`
|
||||||
|
|
||||||
|
// Created time
|
||||||
|
CreatedTime uint64 `json:"createdTime"`
|
||||||
|
|
||||||
|
// Updated time
|
||||||
|
UpdatedTime uint64 `json:"updatedTime"`
|
||||||
|
|
||||||
|
// Description
|
||||||
|
Description string `json:"description"`
|
||||||
|
|
||||||
|
// Grid ID
|
||||||
|
GID uint64 `json:"gid"`
|
||||||
|
|
||||||
|
// Guid ID
|
||||||
|
GUID uint64 `json:"guid"`
|
||||||
|
|
||||||
|
// ID
|
||||||
|
ID uint64 `json:"id"`
|
||||||
|
|
||||||
|
// Name
|
||||||
|
Name string `json:"name"`
|
||||||
|
|
||||||
|
// List of resource groups with access
|
||||||
|
RGAccess []uint64 `json:"rgAccess"`
|
||||||
|
|
||||||
|
// Status
|
||||||
|
Status string `json:"status"`
|
||||||
|
|
||||||
|
// OVS bridge
|
||||||
|
OVSBridge string `json:"ovsBridge"`
|
||||||
|
|
||||||
|
// Vlan ID
|
||||||
|
VlanID uint64 `json:"vlanId"`
|
||||||
|
|
||||||
|
// Compute IDs
|
||||||
|
ComputeIDs []uint64 `json:"computeIds"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ListDPDKNet struct {
|
||||||
|
// Data
|
||||||
|
Data []ItemDPDKNet `json:"data"`
|
||||||
|
|
||||||
|
// Entry count
|
||||||
|
EntryCount uint64 `json:"entryCount"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ItemDPDKNet struct {
|
||||||
|
// List of accounts with access
|
||||||
|
AccountAccess []uint64 `json:"accountAccess"`
|
||||||
|
|
||||||
|
// Created time
|
||||||
|
CreatedTime uint64 `json:"createdTime"`
|
||||||
|
|
||||||
|
// Updated time
|
||||||
|
UpdatedTime uint64 `json:"updatedTime"`
|
||||||
|
|
||||||
|
// Description
|
||||||
|
Description string `json:"description"`
|
||||||
|
|
||||||
|
// Grid ID
|
||||||
|
GID uint64 `json:"gid"`
|
||||||
|
|
||||||
|
// Guid ID
|
||||||
|
GUID uint64 `json:"guid"`
|
||||||
|
|
||||||
|
// ID
|
||||||
|
ID uint64 `json:"id"`
|
||||||
|
|
||||||
|
// Name
|
||||||
|
Name string `json:"name"`
|
||||||
|
|
||||||
|
// List of resource groups with access
|
||||||
|
RGAccess []uint64 `json:"rgAccess"`
|
||||||
|
|
||||||
|
// Status
|
||||||
|
Status string `json:"status"`
|
||||||
|
|
||||||
|
// OVS bridge
|
||||||
|
OVSBridge string `json:"ovsBridge"`
|
||||||
|
|
||||||
|
// Vlan ID
|
||||||
|
VlanID uint64 `json:"vlanId"`
|
||||||
|
|
||||||
|
// Compute IDs
|
||||||
|
ComputeIDs []uint64 `json:"computeIds"`
|
||||||
|
}
|
||||||
50
pkg/cloudapi/extnet/get_reserved_ip.go
Normal file
50
pkg/cloudapi/extnet/get_reserved_ip.go
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
package extnet
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"encoding/json"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
|
)
|
||||||
|
|
||||||
|
// GetRequest struct to get information about reserved address or address poll
|
||||||
|
type GetReservedIP struct {
|
||||||
|
// AccountID of the account whose reservation information we want to receive
|
||||||
|
// Required: true
|
||||||
|
AccountID uint64 `url:"accountId" json:"accountId" validate:"required"`
|
||||||
|
|
||||||
|
// Field for specifying the ID of extnet whose reservation information we want to receive
|
||||||
|
// Required: false
|
||||||
|
ExtNetID uint64 `url:"extnetId,omitempty" json:"extnetId,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetReservedIP gets information about reserved address or address poll as a slice of RecordReservedIP struct
|
||||||
|
func (e ExtNet) GetReservedIP(ctx context.Context, req GetReservedIP) ([]RecordReservedIP, error) {
|
||||||
|
res, err := e.GetReservedIPRaw(ctx, req)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
reservedIP := make([]RecordReservedIP, 0)
|
||||||
|
|
||||||
|
err = json.Unmarshal(res, &reservedIP)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return reservedIP, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetRaw gets detailed information about external network as an array of bytes
|
||||||
|
func (e ExtNet) GetReservedIPRaw(ctx context.Context, req GetReservedIP) ([]byte, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudapi/extnet/getReservedIp"
|
||||||
|
|
||||||
|
res, err := e.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
@@ -49,6 +49,10 @@ type ListRequest struct {
|
|||||||
// Page size
|
// Page size
|
||||||
// Required: false
|
// Required: false
|
||||||
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
||||||
|
|
||||||
|
//openVswitch bridge name
|
||||||
|
//Required: false
|
||||||
|
OVSBridge string `url:"ovsBridge,omitempty" json:"ovsBridge,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// List gets list of all available external networks as a ListExtNets struct
|
// List gets list of all available external networks as a ListExtNets struct
|
||||||
|
|||||||
@@ -87,6 +87,9 @@ type QOS struct {
|
|||||||
|
|
||||||
// Main information about reservations
|
// Main information about reservations
|
||||||
type ItemReservation struct {
|
type ItemReservation struct {
|
||||||
|
// Account ID
|
||||||
|
AccountID uint64 `json:"account_id"`
|
||||||
|
|
||||||
// ClientType
|
// ClientType
|
||||||
ClientType string `json:"clientType"`
|
ClientType string `json:"clientType"`
|
||||||
|
|
||||||
@@ -170,7 +173,7 @@ type RecordExtNet struct {
|
|||||||
Excluded []Excluded `json:"excluded"`
|
Excluded []Excluded `json:"excluded"`
|
||||||
|
|
||||||
// Free IPs
|
// Free IPs
|
||||||
FreeIPs uint64 `json:"free_ips"`
|
FreeIPs int64 `json:"free_ips"`
|
||||||
|
|
||||||
// Gateway
|
// Gateway
|
||||||
Gateway string `json:"gateway"`
|
Gateway string `json:"gateway"`
|
||||||
@@ -199,6 +202,9 @@ type RecordExtNet struct {
|
|||||||
// Network ID
|
// Network ID
|
||||||
NetworkID uint64 `json:"networkId"`
|
NetworkID uint64 `json:"networkId"`
|
||||||
|
|
||||||
|
// NTP
|
||||||
|
NTP []string `json:"ntp"`
|
||||||
|
|
||||||
// OVS Bridge
|
// OVS Bridge
|
||||||
OVSBridge string `json:"ovsBridge"`
|
OVSBridge string `json:"ovsBridge"`
|
||||||
|
|
||||||
@@ -226,3 +232,20 @@ type RecordExtNet struct {
|
|||||||
// VNFs
|
// VNFs
|
||||||
VNFs VNFs `json:"vnfs"`
|
VNFs VNFs `json:"vnfs"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Detailed information about reserved address or address pool
|
||||||
|
type RecordReservedIP struct {
|
||||||
|
ExtnetID int `json:"extnet_id"`
|
||||||
|
Reservations []Reservations `json:"reservations"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type Reservations struct {
|
||||||
|
AccountID int `json:"account_id"`
|
||||||
|
ClientType string `json:"clientType"`
|
||||||
|
DomainName string `json:"domainname"`
|
||||||
|
Hostname string `json:"hostname"`
|
||||||
|
IP string `json:"ip"`
|
||||||
|
Mac string `json:"mac"`
|
||||||
|
Type string `json:"type"`
|
||||||
|
VMID int `json:"vmId"`
|
||||||
|
}
|
||||||
|
|||||||
@@ -72,7 +72,6 @@ type CreateRequest struct {
|
|||||||
// Binary architecture of this image
|
// Binary architecture of this image
|
||||||
// Should be:
|
// Should be:
|
||||||
// - X86_64
|
// - X86_64
|
||||||
// - PPC64_LE
|
|
||||||
// Required: false
|
// Required: false
|
||||||
Architecture string `url:"architecture,omitempty" json:"architecture,omitempty" validate:"omitempty,imageArchitecture"`
|
Architecture string `url:"architecture,omitempty" json:"architecture,omitempty" validate:"omitempty,imageArchitecture"`
|
||||||
|
|
||||||
|
|||||||
@@ -13,10 +13,6 @@ type DeleteRequest struct {
|
|||||||
// ID of the image to delete
|
// ID of the image to delete
|
||||||
// Required: true
|
// Required: true
|
||||||
ImageID uint64 `url:"imageId" json:"imageId" validate:"required"`
|
ImageID uint64 `url:"imageId" json:"imageId" validate:"required"`
|
||||||
|
|
||||||
// Whether to completely delete the image
|
|
||||||
// Required: false
|
|
||||||
Permanently bool `url:"permanently,omitempty" json:"permanently,omitempty"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete deletes image by ID
|
// Delete deletes image by ID
|
||||||
|
|||||||
@@ -48,15 +48,15 @@ type ListRequest struct {
|
|||||||
|
|
||||||
// Find by public True or False
|
// Find by public True or False
|
||||||
// Required: false
|
// Required: false
|
||||||
Public interface{} `url:"public,omitempty" json:"public,omitempty" validate:"omitempty,sortBy"`
|
Public interface{} `url:"public,omitempty" json:"public,omitempty" validate:"omitempty,isBool"`
|
||||||
|
|
||||||
// Find by hot resize True or False
|
// Find by hot resize True or False
|
||||||
// Required: false
|
// Required: false
|
||||||
HotResize interface{} `url:"hotResize,omitempty" json:"hotResize,omitempty" validate:"omitempty,sortBy"`
|
HotResize interface{} `url:"hotResize,omitempty" json:"hotResize,omitempty" validate:"omitempty,isBool"`
|
||||||
|
|
||||||
// Find by bootable True or False
|
// Find by bootable True or False
|
||||||
// Required: false
|
// Required: false
|
||||||
Bootable interface{} `url:"bootable,omitempty" json:"bootable,omitempty" validate:"omitempty,sortBy"`
|
Bootable interface{} `url:"bootable,omitempty" json:"bootable,omitempty" validate:"omitempty,isBool"`
|
||||||
|
|
||||||
// Sort by one of supported fields, format +|-(field)
|
// Sort by one of supported fields, format +|-(field)
|
||||||
// Required: false
|
// Required: false
|
||||||
@@ -69,6 +69,10 @@ type ListRequest struct {
|
|||||||
// Page size
|
// Page size
|
||||||
// Required: false
|
// Required: false
|
||||||
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
||||||
|
|
||||||
|
// Find by enabled True or False
|
||||||
|
// Required: false
|
||||||
|
Enabled interface{} `url:"enabled,omitempty" json:"enabled,omitempty" validate:"omitempty,isBool"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// List gets list of available images as a ListImages struct, optionally filtering by account ID
|
// List gets list of available images as a ListImages struct, optionally filtering by account ID
|
||||||
|
|||||||
@@ -162,7 +162,7 @@ type RecordImage struct {
|
|||||||
Pool string `json:"pool"`
|
Pool string `json:"pool"`
|
||||||
|
|
||||||
// Present to
|
// Present to
|
||||||
PresentTo []uint64 `json:"presentTo"`
|
PresentTo map[string]uint64 `json:"presentTo"`
|
||||||
|
|
||||||
// ProviderName
|
// ProviderName
|
||||||
ProviderName string `json:"provider_name"`
|
ProviderName string `json:"provider_name"`
|
||||||
@@ -185,6 +185,9 @@ type RecordImage struct {
|
|||||||
// Size
|
// Size
|
||||||
Size uint64 `json:"size"`
|
Size uint64 `json:"size"`
|
||||||
|
|
||||||
|
// snapshot ID
|
||||||
|
SnapshotID string `json:"snapshotId"`
|
||||||
|
|
||||||
// Status
|
// Status
|
||||||
Status string `json:"status"`
|
Status string `json:"status"`
|
||||||
|
|
||||||
|
|||||||
@@ -162,6 +162,10 @@ type CreateRequest struct {
|
|||||||
// Insert ssl certificate in x509 pem format
|
// Insert ssl certificate in x509 pem format
|
||||||
// Required: false
|
// Required: false
|
||||||
OidcCertificate string `url:"oidcCertificate,omitempty" json:"oidcCertificate,omitempty"`
|
OidcCertificate string `url:"oidcCertificate,omitempty" json:"oidcCertificate,omitempty"`
|
||||||
|
|
||||||
|
// Type of the emulated system, Q35 or i440fx
|
||||||
|
// Required: false
|
||||||
|
Chipset string `url:"chipset,omitempty" json:"chipset,omitempty" validate:"omitempty,chipset"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetRAM returns RAM field values
|
// GetRAM returns RAM field values
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ type DeleteMasterFromGroupRequest struct {
|
|||||||
|
|
||||||
// List of Compute IDs of master nodes to delete
|
// List of Compute IDs of master nodes to delete
|
||||||
// Required: true
|
// Required: true
|
||||||
MasterIDs []string `url:"masterIds" json:"masterIds" validate:"min=1"`
|
MasterIDs []uint64 `url:"masterIds" json:"masterIds" validate:"min=1"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// DeleteMasterFromGroup deletes compute from masters group in selected Kubernetes cluster
|
// DeleteMasterFromGroup deletes compute from masters group in selected Kubernetes cluster
|
||||||
|
|||||||
@@ -89,6 +89,18 @@ type RecordK8S struct {
|
|||||||
// Deleted time
|
// Deleted time
|
||||||
DeletedTime uint64 `json:"deletedTime"`
|
DeletedTime uint64 `json:"deletedTime"`
|
||||||
|
|
||||||
|
// Description
|
||||||
|
Description string `json:"desc"`
|
||||||
|
|
||||||
|
// Only external network
|
||||||
|
ExtnetOnly bool `json:"extnetOnly"`
|
||||||
|
|
||||||
|
// Highly available LB
|
||||||
|
HighlyAvailableLB bool `json:"highlyAvailableLB"`
|
||||||
|
|
||||||
|
// Address Virtual Internet Protocol
|
||||||
|
AddressVIP K8SAddressVIP `json:"addressVip"`
|
||||||
|
|
||||||
// ID
|
// ID
|
||||||
ID uint64 `json:"id"`
|
ID uint64 `json:"id"`
|
||||||
|
|
||||||
@@ -124,6 +136,18 @@ type RecordK8S struct {
|
|||||||
|
|
||||||
// Updated time
|
// Updated time
|
||||||
UpdatedTime uint64 `json:"updatedTime"`
|
UpdatedTime uint64 `json:"updatedTime"`
|
||||||
|
|
||||||
|
// With LB
|
||||||
|
WithLB bool `json:"withLB"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Detailed information about address of the Virtual Internet Protocol
|
||||||
|
type K8SAddressVIP struct {
|
||||||
|
// Backend IP
|
||||||
|
BackendIP string `json:"backendIp"`
|
||||||
|
|
||||||
|
// Frontend IP
|
||||||
|
FrontendIP string `json:"frontendIp"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Detailed information about kubernetes cluster groups
|
// Detailed information about kubernetes cluster groups
|
||||||
|
|||||||
@@ -21,6 +21,10 @@ type WorkerAddRequest struct {
|
|||||||
// How many worker nodes to add
|
// How many worker nodes to add
|
||||||
// Required: false
|
// Required: false
|
||||||
Num uint64 `url:"num,omitempty" json:"num,omitempty"`
|
Num uint64 `url:"num,omitempty" json:"num,omitempty"`
|
||||||
|
|
||||||
|
// Type of the emulated system, Q35 or i440fx
|
||||||
|
// Required: false
|
||||||
|
Chipset string `url:"chipset,omitempty" json:"chipset,omitempty" validate:"omitempty,chipset"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// WorkerAdd adds worker nodes to a Kubernetes cluster
|
// WorkerAdd adds worker nodes to a Kubernetes cluster
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ package k8s
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
|
||||||
|
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
)
|
)
|
||||||
@@ -60,6 +59,10 @@ type WorkersGroupAddRequest struct {
|
|||||||
// Meta data for working group computes, format YAML "user_data": 1111
|
// Meta data for working group computes, format YAML "user_data": 1111
|
||||||
// Required: false
|
// Required: false
|
||||||
UserData string `url:"userData,omitempty" json:"userData,omitempty"`
|
UserData string `url:"userData,omitempty" json:"userData,omitempty"`
|
||||||
|
|
||||||
|
// Type of the emulated system, Q35 or i440fx
|
||||||
|
// Required: false
|
||||||
|
Chipset string `url:"chipset,omitempty" json:"chipset,omitempty" validate:"omitempty,chipset"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetRAM returns RAM field values
|
// GetRAM returns RAM field values
|
||||||
@@ -73,23 +76,18 @@ func (r WorkersGroupAddRequest) GetRAM() map[string]uint64 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// WorkersGroupAdd adds workers group to Kubernetes cluster
|
// WorkersGroupAdd adds workers group to Kubernetes cluster
|
||||||
func (k8s K8S) WorkersGroupAdd(ctx context.Context, req WorkersGroupAddRequest) (uint64, error) {
|
func (k8s K8S) WorkersGroupAdd(ctx context.Context, req WorkersGroupAddRequest) (string, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, validators.ValidationErrors(validators.GetErrors(err))
|
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
url := "/cloudapi/k8s/workersGroupAdd"
|
url := "/cloudapi/k8s/workersGroupAdd"
|
||||||
|
|
||||||
res, err := k8s.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
res, err := k8s.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)
|
return string(res), nil
|
||||||
if err != nil {
|
|
||||||
return 0, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return result, nil
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +0,0 @@
|
|||||||
package cloudapi
|
|
||||||
|
|
||||||
import "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/kvmppc"
|
|
||||||
|
|
||||||
// Accessing the KVMPPC method group
|
|
||||||
func (ca *CloudAPI) KVMPPC() *kvmppc.KVMPPC {
|
|
||||||
return kvmppc.New(ca.client)
|
|
||||||
}
|
|
||||||
@@ -1,202 +0,0 @@
|
|||||||
package kvmppc
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"encoding/json"
|
|
||||||
"net/http"
|
|
||||||
"strconv"
|
|
||||||
|
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
|
||||||
)
|
|
||||||
|
|
||||||
type Interface struct {
|
|
||||||
// Network type
|
|
||||||
// Should be one of:
|
|
||||||
// - VINS
|
|
||||||
// - EXTNET
|
|
||||||
NetType string `url:"netType" json:"netType" validate:"required,kvmNetType"`
|
|
||||||
|
|
||||||
// Network ID for connect to,
|
|
||||||
// for EXTNET - external network ID,
|
|
||||||
// for VINS - VINS ID,
|
|
||||||
NetID uint64 `url:"netId" json:"netId" validate:"required"`
|
|
||||||
|
|
||||||
// IP address to assign to this VM when connecting to the specified network
|
|
||||||
// Required: false
|
|
||||||
IPAddr string `url:"ipAddr,omitempty" json:"ipAddr,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// DataDisk detailed struct for DataDisks field in CreateRequest and CreateBlankRequest
|
|
||||||
type DataDisk struct {
|
|
||||||
// Name for disk
|
|
||||||
// Required: true
|
|
||||||
DiskName string `url:"diskName" json:"diskName" validate:"required"`
|
|
||||||
|
|
||||||
// Disk size in GB
|
|
||||||
// Required: true
|
|
||||||
Size uint64 `url:"size" json:"size" validate:"required"`
|
|
||||||
|
|
||||||
// Storage endpoint provider ID
|
|
||||||
// By default the same with boot disk
|
|
||||||
// Required: false
|
|
||||||
SepID uint64 `url:"sepId,omitempty" json:"sepId,omitempty"`
|
|
||||||
|
|
||||||
// Pool name
|
|
||||||
// By default will be chosen automatically
|
|
||||||
// Required: false
|
|
||||||
Pool string `url:"pool,omitempty" json:"pool,omitempty"`
|
|
||||||
|
|
||||||
// Optional description
|
|
||||||
// Required: false
|
|
||||||
Description string `url:"desc,omitempty" json:"desc,omitempty"`
|
|
||||||
|
|
||||||
// Specify image id for create disk from template
|
|
||||||
// Required: false
|
|
||||||
ImageID uint64 `url:"imageId,omitempty" json:"imageId,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// CreateRequest struct to create KVM PowerPC VM
|
|
||||||
type CreateRequest struct {
|
|
||||||
// ID of the resource group, which will own this VM
|
|
||||||
// Required: true
|
|
||||||
RGID uint64 `url:"rgId" json:"rgId" validate:"required"`
|
|
||||||
|
|
||||||
// Name of this VM.
|
|
||||||
// Must be unique among all VMs (including those in DELETED state) in target resource group
|
|
||||||
// Required: true
|
|
||||||
Name string `url:"name" json:"name" validate:"required"`
|
|
||||||
|
|
||||||
// Number CPUs to allocate to this VM
|
|
||||||
// Required: true
|
|
||||||
CPU uint64 `url:"cpu" json:"cpu" validate:"required"`
|
|
||||||
|
|
||||||
// Volume of RAM in MB to allocate to this VM
|
|
||||||
// Required: true
|
|
||||||
RAM uint64 `url:"ram" json:"ram" validate:"required"`
|
|
||||||
|
|
||||||
// ID of the OS image to base this VM on;
|
|
||||||
// Could be boot disk image or CD-ROM image
|
|
||||||
// Required: true
|
|
||||||
ImageID uint64 `url:"imageId" json:"imageId" validate:"required"`
|
|
||||||
|
|
||||||
// Size of the boot disk in GB
|
|
||||||
// Required: false
|
|
||||||
BootDisk uint64 `url:"bootDisk,omitempty" json:"bootDisk,omitempty"`
|
|
||||||
|
|
||||||
// ID of SEP to create boot disk on.
|
|
||||||
// Uses images SEP ID if not set
|
|
||||||
// Required: false
|
|
||||||
SEPID uint64 `url:"sepId,omitempty" json:"sepId,omitempty"`
|
|
||||||
|
|
||||||
// Pool to use if sepId is set, can be also empty if needed to be chosen by system
|
|
||||||
// Required: false
|
|
||||||
Pool string `url:"pool,omitempty" json:"pool,omitempty"`
|
|
||||||
|
|
||||||
// Slice of structs with data disk description. Each disk has parameters: required - diskName, size; optional - sepId, pool, desc and imageId.
|
|
||||||
// If not specified, compute will be created without disks.
|
|
||||||
// To create compute without disks, pass initialized empty slice .
|
|
||||||
// Required: false
|
|
||||||
DataDisks []DataDisk `url:"-" json:"dataDisks,omitempty" validate:"omitempty,dive"`
|
|
||||||
|
|
||||||
// Slice of structs with net interface description.
|
|
||||||
// If not specified, compute will be created with default interface from RG.
|
|
||||||
// To create compute without interfaces, pass initialized empty slice .
|
|
||||||
// Required: false
|
|
||||||
Interfaces []Interface `url:"-" json:"interfaces,omitempty" validate:"omitempty,dive"`
|
|
||||||
|
|
||||||
// Input data for cloud-init facility
|
|
||||||
// Required: false
|
|
||||||
Userdata string `url:"userdata,omitempty" json:"userdata,omitempty"`
|
|
||||||
|
|
||||||
// Text description of this VM
|
|
||||||
// Required: false
|
|
||||||
Description string `url:"desc,omitempty" json:"desc,omitempty"`
|
|
||||||
|
|
||||||
// Start VM upon success
|
|
||||||
// Required: false
|
|
||||||
Start bool `url:"start" json:"start"`
|
|
||||||
|
|
||||||
// System name
|
|
||||||
// Required: false
|
|
||||||
IS string `url:"IS,omitempty" json:"IS,omitempty"`
|
|
||||||
|
|
||||||
// Compute purpose
|
|
||||||
// Required: false
|
|
||||||
IPAType string `url:"ipaType,omitempty" json:"ipaType,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetRAM returns RAM field values
|
|
||||||
func (r CreateRequest) GetRAM() map[string]uint64 {
|
|
||||||
|
|
||||||
res := make(map[string]uint64, 1)
|
|
||||||
|
|
||||||
res["RAM"] = r.RAM
|
|
||||||
|
|
||||||
return res
|
|
||||||
}
|
|
||||||
|
|
||||||
type wrapperCreateRequest struct {
|
|
||||||
CreateRequest
|
|
||||||
Interfaces []string `url:"interfaces,omitempty"`
|
|
||||||
DataDisks []string `url:"dataDisks,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create creates KVM PowerPC VM based on specified OS image
|
|
||||||
func (k KVMPPC) Create(ctx context.Context, req CreateRequest) (uint64, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return 0, validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
var interfaces []string
|
|
||||||
|
|
||||||
if req.Interfaces != nil && len(req.Interfaces) != 0 {
|
|
||||||
interfaces = make([]string, 0, len(req.Interfaces))
|
|
||||||
|
|
||||||
for i := range req.Interfaces {
|
|
||||||
b, err := json.Marshal(req.Interfaces[i])
|
|
||||||
if err != nil {
|
|
||||||
return 0, err
|
|
||||||
}
|
|
||||||
|
|
||||||
interfaces = append(interfaces, string(b))
|
|
||||||
}
|
|
||||||
} else if req.Interfaces != nil && len(req.Interfaces) == 0 {
|
|
||||||
interfaces = []string{"[]"}
|
|
||||||
}
|
|
||||||
|
|
||||||
var dataDisks []string
|
|
||||||
|
|
||||||
if req.DataDisks != nil && len(req.DataDisks) != 0 {
|
|
||||||
dataDisks = make([]string, 0, len(req.DataDisks))
|
|
||||||
|
|
||||||
for i := range req.DataDisks {
|
|
||||||
b, err := json.Marshal(req.DataDisks[i])
|
|
||||||
if err != nil {
|
|
||||||
return 0, err
|
|
||||||
}
|
|
||||||
|
|
||||||
dataDisks = append(dataDisks, string(b))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
reqWrapped := wrapperCreateRequest{
|
|
||||||
CreateRequest: req,
|
|
||||||
Interfaces: interfaces,
|
|
||||||
DataDisks: dataDisks,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/kvmppc/create"
|
|
||||||
|
|
||||||
res, err := k.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
|
||||||
if err != nil {
|
|
||||||
return 0, err
|
|
||||||
}
|
|
||||||
|
|
||||||
result, err := strconv.ParseUint(string(res), 10, 64)
|
|
||||||
if err != nil {
|
|
||||||
return 0, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return result, nil
|
|
||||||
}
|
|
||||||
@@ -1,135 +0,0 @@
|
|||||||
package kvmppc
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"encoding/json"
|
|
||||||
"net/http"
|
|
||||||
"strconv"
|
|
||||||
|
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
|
||||||
)
|
|
||||||
|
|
||||||
// CreateBlankRequest struct to create KVM PowerPC VM from scratch
|
|
||||||
type CreateBlankRequest struct {
|
|
||||||
// ID of the resource group, which will own this VM
|
|
||||||
// Required: true
|
|
||||||
RGID uint64 `url:"rgId" json:"rgId" validate:"required"`
|
|
||||||
|
|
||||||
// Name of this VM.
|
|
||||||
// Must be unique among all VMs (including those in DELETED state) in target resource group
|
|
||||||
// Required: true
|
|
||||||
Name string `url:"name" json:"name" validate:"required"`
|
|
||||||
|
|
||||||
// Number CPUs to allocate to this VM
|
|
||||||
// Required: true
|
|
||||||
CPU uint64 `url:"cpu" json:"cpu" validate:"required"`
|
|
||||||
|
|
||||||
// Volume of RAM in MB to allocate to this VM
|
|
||||||
// Required: true
|
|
||||||
RAM uint64 `url:"ram" json:"ram" validate:"required"`
|
|
||||||
|
|
||||||
// Size of the boot disk in GB
|
|
||||||
// Required: true
|
|
||||||
BootDisk uint64 `url:"bootDisk" json:"bootDisk" validate:"required"`
|
|
||||||
|
|
||||||
// ID of SEP to create boot disk on
|
|
||||||
// Uses images SEP ID if not set
|
|
||||||
// Required: true
|
|
||||||
SEPID uint64 `url:"sepId" json:"sepId" validate:"required"`
|
|
||||||
|
|
||||||
// Pool to use if SEP ID is set, can be also empty if needed to be chosen by system
|
|
||||||
// Required: true
|
|
||||||
Pool string `url:"pool" json:"pool" validate:"required"`
|
|
||||||
|
|
||||||
// Slice of structs with data disk description. Each disk has parameters: required - diskName, size; optional - sepId, pool, desc and imageId.
|
|
||||||
// If not specified, compute will be created without disks.
|
|
||||||
// To create compute without disks, pass initialized empty slice .
|
|
||||||
// Required: false
|
|
||||||
DataDisks []DataDisk `url:"-" json:"dataDisks,omitempty" validate:"omitempty,dive"`
|
|
||||||
|
|
||||||
// Slice of structs with net interface description.
|
|
||||||
// If not specified, compute will be created with default interface from RG.
|
|
||||||
// To create compute without interfaces, pass initialized empty slice .
|
|
||||||
// Required: false
|
|
||||||
Interfaces []Interface `url:"-" json:"interfaces,omitempty" validate:"omitempty,dive"`
|
|
||||||
|
|
||||||
// Text description of this VM
|
|
||||||
// Required: false
|
|
||||||
Description string `url:"desc,omitempty" json:"desc,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetRAM returns RAM field values
|
|
||||||
func (r CreateBlankRequest) GetRAM() map[string]uint64 {
|
|
||||||
|
|
||||||
res := make(map[string]uint64, 1)
|
|
||||||
|
|
||||||
res["RAM"] = r.RAM
|
|
||||||
|
|
||||||
return res
|
|
||||||
}
|
|
||||||
|
|
||||||
type wrapperCreateBlankRequest struct {
|
|
||||||
CreateBlankRequest
|
|
||||||
Interfaces []string `url:"interfaces,omitempty"`
|
|
||||||
DataDisks []string `url:"dataDisks,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// CreateBlank creates KVM PowerPC VM from scratch
|
|
||||||
func (k KVMPPC) CreateBlank(ctx context.Context, req CreateBlankRequest) (uint64, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return 0, validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
var interfaces []string
|
|
||||||
|
|
||||||
if req.Interfaces != nil && len(req.Interfaces) != 0 {
|
|
||||||
interfaces = make([]string, 0, len(req.Interfaces))
|
|
||||||
|
|
||||||
for i := range req.Interfaces {
|
|
||||||
b, err := json.Marshal(req.Interfaces[i])
|
|
||||||
if err != nil {
|
|
||||||
return 0, err
|
|
||||||
}
|
|
||||||
|
|
||||||
interfaces = append(interfaces, string(b))
|
|
||||||
}
|
|
||||||
} else if req.Interfaces != nil && len(req.Interfaces) == 0 {
|
|
||||||
interfaces = []string{"[]"}
|
|
||||||
}
|
|
||||||
|
|
||||||
var dataDisks []string
|
|
||||||
|
|
||||||
if req.DataDisks != nil && len(req.DataDisks) != 0 {
|
|
||||||
dataDisks = make([]string, 0, len(req.DataDisks))
|
|
||||||
|
|
||||||
for i := range req.DataDisks {
|
|
||||||
b, err := json.Marshal(req.DataDisks[i])
|
|
||||||
if err != nil {
|
|
||||||
return 0, err
|
|
||||||
}
|
|
||||||
|
|
||||||
dataDisks = append(dataDisks, string(b))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
reqWrapped := wrapperCreateBlankRequest{
|
|
||||||
CreateBlankRequest: req,
|
|
||||||
Interfaces: interfaces,
|
|
||||||
DataDisks: dataDisks,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/kvmppc/createBlank"
|
|
||||||
|
|
||||||
res, err := k.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
|
||||||
if err != nil {
|
|
||||||
return 0, err
|
|
||||||
}
|
|
||||||
|
|
||||||
result, err := strconv.ParseUint(string(res), 10, 64)
|
|
||||||
if err != nil {
|
|
||||||
return 0, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return result, nil
|
|
||||||
}
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
// API to manage KVM PowerPC compute instances (PPC VMs)
|
|
||||||
package kvmppc
|
|
||||||
|
|
||||||
import (
|
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/interfaces"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Structure for creating request to KVMPPC
|
|
||||||
type KVMPPC struct {
|
|
||||||
client interfaces.Caller
|
|
||||||
}
|
|
||||||
|
|
||||||
// Builder for KVMPPC endpoints
|
|
||||||
func New(client interfaces.Caller) *KVMPPC {
|
|
||||||
return &KVMPPC{
|
|
||||||
client,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -15,6 +15,7 @@ type Interface struct {
|
|||||||
// - VINS
|
// - VINS
|
||||||
// - EXTNET
|
// - EXTNET
|
||||||
// - VFNIC
|
// - VFNIC
|
||||||
|
// - DPDK
|
||||||
NetType string `url:"netType" json:"netType" validate:"required,kvmx86NetType"`
|
NetType string `url:"netType" json:"netType" validate:"required,kvmx86NetType"`
|
||||||
|
|
||||||
// Network ID for connect to,
|
// Network ID for connect to,
|
||||||
@@ -25,6 +26,15 @@ type Interface struct {
|
|||||||
// IP address to assign to this VM when connecting to the specified network
|
// IP address to assign to this VM when connecting to the specified network
|
||||||
// Required: false
|
// Required: false
|
||||||
IPAddr string `url:"ipAddr,omitempty" json:"ipAddr,omitempty"`
|
IPAddr string `url:"ipAddr,omitempty" json:"ipAddr,omitempty"`
|
||||||
|
|
||||||
|
// Maximum transmission unit, must be 1-9216
|
||||||
|
// Used only to DPDK net type
|
||||||
|
// Required: false
|
||||||
|
MTU uint64 `url:"mtu,omitempty" json:"mtu,omitempty" validate:"omitempty,mtu"`
|
||||||
|
|
||||||
|
// MAC address to assign to this VM when connecting to the specified network
|
||||||
|
// Required: false
|
||||||
|
MAC string `url:"mac,omitempty" json:"mac,omitempty" validate:"omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// DataDisk detailed struct for DataDisks field in CreateRequest and CreateBlankRequest
|
// DataDisk detailed struct for DataDisks field in CreateRequest and CreateBlankRequest
|
||||||
@@ -150,10 +160,18 @@ type CreateRequest struct {
|
|||||||
// Default: false
|
// Default: false
|
||||||
CPUPin bool `url:"cpupin" json:"cpupin"`
|
CPUPin bool `url:"cpupin" json:"cpupin"`
|
||||||
|
|
||||||
|
// Type of the emulated system, Q35 or i440fx
|
||||||
|
// Required: false
|
||||||
|
Chipset string `url:"chipset,omitempty" json:"chipset,omitempty" validate:"omitempty,chipset"`
|
||||||
|
|
||||||
// Use Huge Pages to allocate RAM of the virtual machine. The system must be pre-configured by allocating Huge Pages on the physical node
|
// Use Huge Pages to allocate RAM of the virtual machine. The system must be pre-configured by allocating Huge Pages on the physical node
|
||||||
// Required: false
|
// Required: false
|
||||||
// Default: false
|
// Default: false
|
||||||
HPBacked bool `url:"hpBacked" json:"hpBacked"`
|
HPBacked bool `url:"hpBacked" json:"hpBacked"`
|
||||||
|
|
||||||
|
// Recommended isolated CPUs. Field is ignored if compute.cpupin=False or compute.pinned=False
|
||||||
|
// Required: false
|
||||||
|
PreferredCPU []int64 `url:"preferredCpu,omitempty" json:"preferredCpu,omitempty" validate:"omitempty,preferredCPU"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetRAM returns RAM field values
|
// GetRAM returns RAM field values
|
||||||
|
|||||||
@@ -61,9 +61,33 @@ type CreateBlankRequest struct {
|
|||||||
// Required: false
|
// Required: false
|
||||||
Driver string `url:"driver,omitempty" json:"driver,omitempty" validate:"omitempty,computeDriver"`
|
Driver string `url:"driver,omitempty" json:"driver,omitempty" validate:"omitempty,computeDriver"`
|
||||||
|
|
||||||
|
// Type of the emulated system, Q35 or i440fx
|
||||||
|
// Required: false
|
||||||
|
Chipset string `url:"chipset,omitempty" json:"chipset,omitempty" validate:"omitempty,chipset"`
|
||||||
|
|
||||||
// Text description of this VM
|
// Text description of this VM
|
||||||
// Required: false
|
// Required: false
|
||||||
Description string `url:"desc,omitempty" json:"desc,omitempty"`
|
Description string `url:"desc,omitempty" json:"desc,omitempty"`
|
||||||
|
|
||||||
|
// Recommended isolated CPUs. Field is ignored if compute.cpupin=False or compute.pinned=False
|
||||||
|
// Required: false
|
||||||
|
PreferredCPU []int64 `url:"preferredCpu,omitempty" json:"preferredCpu,omitempty" validate:"omitempty,preferredCPU"`
|
||||||
|
|
||||||
|
// VM type linux, windows or unknown
|
||||||
|
// Required: false
|
||||||
|
LoaderType string `url:"loaderType,omitempty" json:"loaderType,omitempty" validate:"omitempty,loaderType"`
|
||||||
|
|
||||||
|
// Boot type of image bios or uefi
|
||||||
|
// Required: false
|
||||||
|
BootType string `url:"bootType,omitempty" json:"bootType,omitempty" validate:"omitempty,imageBootType"`
|
||||||
|
|
||||||
|
// Select a network interface naming pattern for your Linux machine. eth - onboard, ens - pci slot naming.
|
||||||
|
// Required: false
|
||||||
|
NetworkInterfaceNaming string `url:"networkInterfaceNaming,omitempty" json:"networkInterfaceNaming,omitempty" validate:"omitempty,networkInterfaceNaming"`
|
||||||
|
|
||||||
|
// Does this machine supports hot resize
|
||||||
|
// Required: false
|
||||||
|
HotResize bool `url:"hotResize,omitempty" json:"hotResize,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetRAM returns RAM field values
|
// GetRAM returns RAM field values
|
||||||
|
|||||||
@@ -22,11 +22,11 @@ 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, can be 0
|
||||||
ExtNetID uint64 `url:"extnetId" json:"extnetId"`
|
ExtNetID uint64 `url:"extnetId" json:"extnetId"`
|
||||||
|
|
||||||
// Internal network (VINS) to connect this load balancer to
|
// Internal network (VINS) to connect this load balancer to
|
||||||
// Required: false
|
// Required: true, can be 0
|
||||||
VINSID uint64 `url:"vinsId" json:"vinsId"`
|
VINSID uint64 `url:"vinsId" json:"vinsId"`
|
||||||
|
|
||||||
// Custom sysctl values for Load Balancer instance. Applied on boot
|
// Custom sysctl values for Load Balancer instance. Applied on boot
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ func (ll ListLB) FilterByName(name string) ListLB {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// FilterByExtNetID returns ListLB with specified ExtNetID.
|
// FilterByExtNetID returns ListLB with specified ExtNetID.
|
||||||
func (ll ListLB) FilterByExtNetID(extNetID uint64) ListLB {
|
func (ll ListLB) FilterByExtNetID(extNetID int64) ListLB {
|
||||||
predicate := func(ill ItemLoadBalancer) bool {
|
predicate := func(ill ItemLoadBalancer) bool {
|
||||||
return ill.ExtNetID == extNetID
|
return ill.ExtNetID == extNetID
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ type RecordLB struct {
|
|||||||
DPAPIUser string `json:"dpApiUser"`
|
DPAPIUser string `json:"dpApiUser"`
|
||||||
|
|
||||||
// External network ID
|
// External network ID
|
||||||
ExtNetID uint64 `json:"extnetId"`
|
ExtNetID int64 `json:"extnetId"`
|
||||||
|
|
||||||
// FrontendHAIP
|
// FrontendHAIP
|
||||||
FrontendHAIP string `json:"frontendHAIP"`
|
FrontendHAIP string `json:"frontendHAIP"`
|
||||||
|
|||||||
@@ -28,6 +28,9 @@ type ItemLocation struct {
|
|||||||
|
|
||||||
// CKey
|
// CKey
|
||||||
CKey string `json:"_ckey"`
|
CKey string `json:"_ckey"`
|
||||||
|
|
||||||
|
// Support of SDN
|
||||||
|
SDNSupport bool `json:"sdn_support"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// List of locations
|
// List of locations
|
||||||
|
|||||||
8
pkg/cloudapi/prometheus.go
Normal file
8
pkg/cloudapi/prometheus.go
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
package cloudapi
|
||||||
|
|
||||||
|
import "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/prometheus"
|
||||||
|
|
||||||
|
// Accessing the Resmon method group
|
||||||
|
func (ca *CloudAPI) Prometheus() *prometheus.Prometheus {
|
||||||
|
return prometheus.New(ca.client)
|
||||||
|
}
|
||||||
57
pkg/cloudapi/prometheus/compute_cpu_load.go
Normal file
57
pkg/cloudapi/prometheus/compute_cpu_load.go
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
package prometheus
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"encoding/json"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
|
)
|
||||||
|
|
||||||
|
type ComputeCPULoadRequest struct {
|
||||||
|
// Compute ID
|
||||||
|
// Required: true
|
||||||
|
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
|
||||||
|
|
||||||
|
// Time to loads of statistic in seconds
|
||||||
|
// Required: false
|
||||||
|
ForLast uint64 `url:"forLast,omitempty" json:"forLast,omitempty"`
|
||||||
|
|
||||||
|
// The reading interval in seconds
|
||||||
|
// Required: false
|
||||||
|
Step uint64 `url:"step,omitempty" json:"step,omitempty"`
|
||||||
|
|
||||||
|
// Number of zeros after the decimal point
|
||||||
|
// Required: false
|
||||||
|
DecimalPlaces uint64 `url:"decimalPlaces,omitempty" json:"decimalPlaces,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Per-second CPU time consumed by Compute in percent, average over the time step specified
|
||||||
|
func (p Prometheus) ComputeCPULoad(ctx context.Context, req ComputeCPULoadRequest) (*PrometheusData, error) {
|
||||||
|
res, err := p.ComputeCPULoadRaw(ctx, req)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
info := PrometheusData{}
|
||||||
|
|
||||||
|
err = json.Unmarshal(res, &info)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return &info, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetRaw gets information about compute as an array of bytes
|
||||||
|
func (p Prometheus) ComputeCPULoadRaw(ctx context.Context, req ComputeCPULoadRequest) ([]byte, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudapi/prometheus/computeCPUload"
|
||||||
|
|
||||||
|
res, err := p.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
53
pkg/cloudapi/prometheus/compute_memory_available.go
Normal file
53
pkg/cloudapi/prometheus/compute_memory_available.go
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
package prometheus
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"encoding/json"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
|
)
|
||||||
|
|
||||||
|
type ComputeMemoryAvailableRequest struct {
|
||||||
|
// Compute ID
|
||||||
|
// Required: true
|
||||||
|
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
|
||||||
|
|
||||||
|
// Time to loads of statistic in seconds
|
||||||
|
// Required: false
|
||||||
|
ForLast uint64 `url:"forLast,omitempty" json:"forLast,omitempty"`
|
||||||
|
|
||||||
|
// The reading interval in seconds
|
||||||
|
// Required: false
|
||||||
|
Step uint64 `url:"step,omitempty" json:"step,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Available Memory
|
||||||
|
func (p Prometheus) ComputeMemoryAvailable(ctx context.Context, req ComputeMemoryAvailableRequest) (*PrometheusData, error) {
|
||||||
|
res, err := p.ComputeMemoryAvailableRaw(ctx, req)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
info := PrometheusData{}
|
||||||
|
|
||||||
|
err = json.Unmarshal(res, &info)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return &info, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetRaw gets information about compute as an array of bytes
|
||||||
|
func (p Prometheus) ComputeMemoryAvailableRaw(ctx context.Context, req ComputeMemoryAvailableRequest) ([]byte, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudapi/prometheus/computeMemoryAvailable"
|
||||||
|
|
||||||
|
res, err := p.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
53
pkg/cloudapi/prometheus/compute_memory_unused.go
Normal file
53
pkg/cloudapi/prometheus/compute_memory_unused.go
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
package prometheus
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"encoding/json"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
|
)
|
||||||
|
|
||||||
|
type ComputeMemoryUnusedRequest struct {
|
||||||
|
// Compute ID
|
||||||
|
// Required: true
|
||||||
|
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
|
||||||
|
|
||||||
|
// Time to loads of statistic in seconds
|
||||||
|
// Required: false
|
||||||
|
ForLast uint64 `url:"forLast,omitempty" json:"forLast,omitempty"`
|
||||||
|
|
||||||
|
// The reading interval in seconds
|
||||||
|
// Required: false
|
||||||
|
Step uint64 `url:"step,omitempty" json:"step,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Unused Memory
|
||||||
|
func (p Prometheus) ComputeMemoryUnused(ctx context.Context, req ComputeMemoryUnusedRequest) (*PrometheusData, error) {
|
||||||
|
res, err := p.ComputeMemoryUnusedRaw(ctx, req)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
info := PrometheusData{}
|
||||||
|
|
||||||
|
err = json.Unmarshal(res, &info)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return &info, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetRaw gets information about compute as an array of bytes
|
||||||
|
func (p Prometheus) ComputeMemoryUnusedRaw(ctx context.Context, req ComputeMemoryUnusedRequest) ([]byte, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudapi/prometheus/computeMemoryUnused"
|
||||||
|
|
||||||
|
res, err := p.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
53
pkg/cloudapi/prometheus/compute_memory_usable.go
Normal file
53
pkg/cloudapi/prometheus/compute_memory_usable.go
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
package prometheus
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"encoding/json"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
|
)
|
||||||
|
|
||||||
|
type ComputeMemoryUsableRequest struct {
|
||||||
|
// Compute ID
|
||||||
|
// Required: true
|
||||||
|
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
|
||||||
|
|
||||||
|
// Time to loads of statistic in seconds
|
||||||
|
// Required: false
|
||||||
|
ForLast uint64 `url:"forLast,omitempty" json:"forLast,omitempty"`
|
||||||
|
|
||||||
|
// The reading interval in seconds
|
||||||
|
// Required: false
|
||||||
|
Step uint64 `url:"step,omitempty" json:"step,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Usable Memory
|
||||||
|
func (p Prometheus) ComputeMemoryUsable(ctx context.Context, req ComputeMemoryUsableRequest) (*PrometheusData, error) {
|
||||||
|
res, err := p.ComputeMemoryUsableRaw(ctx, req)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
info := PrometheusData{}
|
||||||
|
|
||||||
|
err = json.Unmarshal(res, &info)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return &info, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetRaw gets information about compute as an array of bytes
|
||||||
|
func (p Prometheus) ComputeMemoryUsableRaw(ctx context.Context, req ComputeMemoryUsableRequest) ([]byte, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudapi/prometheus/computeMemoryUsable"
|
||||||
|
|
||||||
|
res, err := p.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
53
pkg/cloudapi/prometheus/compute_memory_usage.go
Normal file
53
pkg/cloudapi/prometheus/compute_memory_usage.go
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
package prometheus
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"encoding/json"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
|
)
|
||||||
|
|
||||||
|
type ComputeMemoryUsageRequest struct {
|
||||||
|
// Compute ID
|
||||||
|
// Required: true
|
||||||
|
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
|
||||||
|
|
||||||
|
// Time to loads of statistic in seconds
|
||||||
|
// Required: false
|
||||||
|
ForLast uint64 `url:"forLast,omitempty" json:"forLast,omitempty"`
|
||||||
|
|
||||||
|
// The reading interval in seconds
|
||||||
|
// Required: false
|
||||||
|
Step uint64 `url:"step,omitempty" json:"step,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Memory Usage
|
||||||
|
func (p Prometheus) ComputeMemoryUsage(ctx context.Context, req ComputeMemoryUsageRequest) (*PrometheusData, error) {
|
||||||
|
res, err := p.ComputeMemoryUsageRaw(ctx, req)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
info := PrometheusData{}
|
||||||
|
|
||||||
|
err = json.Unmarshal(res, &info)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return &info, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetRaw gets information about compute as an array of bytes
|
||||||
|
func (p Prometheus) ComputeMemoryUsageRaw(ctx context.Context, req ComputeMemoryUsageRequest) ([]byte, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudapi/prometheus/computeMemoryUsage"
|
||||||
|
|
||||||
|
res, err := p.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
53
pkg/cloudapi/prometheus/compute_memory_used.go
Normal file
53
pkg/cloudapi/prometheus/compute_memory_used.go
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
package prometheus
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"encoding/json"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
|
)
|
||||||
|
|
||||||
|
type ComputeMemoryUsedRequest struct {
|
||||||
|
// Compute ID
|
||||||
|
// Required: true
|
||||||
|
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
|
||||||
|
|
||||||
|
// Time to loads of statistic in seconds
|
||||||
|
// Required: false
|
||||||
|
ForLast uint64 `url:"forLast,omitempty" json:"forLast,omitempty"`
|
||||||
|
|
||||||
|
// The reading interval in seconds
|
||||||
|
// Required: false
|
||||||
|
Step uint64 `url:"step,omitempty" json:"step,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Used Memory
|
||||||
|
func (p Prometheus) ComputeMemoryUsed(ctx context.Context, req ComputeMemoryUsedRequest) (*PrometheusData, error) {
|
||||||
|
res, err := p.ComputeMemoryUsedRaw(ctx, req)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
info := PrometheusData{}
|
||||||
|
|
||||||
|
err = json.Unmarshal(res, &info)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return &info, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetRaw gets information about compute as an array of bytes
|
||||||
|
func (p Prometheus) ComputeMemoryUsedRaw(ctx context.Context, req ComputeMemoryUsedRequest) ([]byte, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudapi/prometheus/computeMemoryUsed"
|
||||||
|
|
||||||
|
res, err := p.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
57
pkg/cloudapi/prometheus/compute_read_bytes.go
Normal file
57
pkg/cloudapi/prometheus/compute_read_bytes.go
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
package prometheus
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"encoding/json"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
|
)
|
||||||
|
|
||||||
|
type ComputeReadBytesRequest struct {
|
||||||
|
// Compute ID
|
||||||
|
// Required: true
|
||||||
|
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
|
||||||
|
|
||||||
|
// Time to loads of statistic in seconds
|
||||||
|
// Required: false
|
||||||
|
ForLast uint64 `url:"forLast,omitempty" json:"forLast,omitempty"`
|
||||||
|
|
||||||
|
// The reading interval in seconds
|
||||||
|
// Required: false
|
||||||
|
Step uint64 `url:"step,omitempty" json:"step,omitempty"`
|
||||||
|
|
||||||
|
// Number of zeros after the decimal point
|
||||||
|
// Required: false
|
||||||
|
DecimalPlaces uint64 `url:"decimalPlaces,omitempty" json:"decimalPlaces,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Read Bytes
|
||||||
|
func (p Prometheus) ComputeReadBytes(ctx context.Context, req ComputeReadBytesRequest) (*PrometheusData, error) {
|
||||||
|
res, err := p.ComputeReadBytesRaw(ctx, req)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
info := PrometheusData{}
|
||||||
|
|
||||||
|
err = json.Unmarshal(res, &info)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return &info, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetRaw gets information about compute as an array of bytes
|
||||||
|
func (p Prometheus) ComputeReadBytesRaw(ctx context.Context, req ComputeReadBytesRequest) ([]byte, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudapi/prometheus/computeReadBytes"
|
||||||
|
|
||||||
|
res, err := p.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
57
pkg/cloudapi/prometheus/compute_read_requests.go
Normal file
57
pkg/cloudapi/prometheus/compute_read_requests.go
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
package prometheus
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"encoding/json"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
|
)
|
||||||
|
|
||||||
|
type ComputeReadRequestsRequest struct {
|
||||||
|
// Compute ID
|
||||||
|
// Required: true
|
||||||
|
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
|
||||||
|
|
||||||
|
// Time to loads of statistic in seconds
|
||||||
|
// Required: false
|
||||||
|
ForLast uint64 `url:"forLast,omitempty" json:"forLast,omitempty"`
|
||||||
|
|
||||||
|
// The reading interval in seconds
|
||||||
|
// Required: false
|
||||||
|
Step uint64 `url:"step,omitempty" json:"step,omitempty"`
|
||||||
|
|
||||||
|
// Number of zeros after the decimal point
|
||||||
|
// Required: false
|
||||||
|
DecimalPlaces uint64 `url:"decimalPlaces,omitempty" json:"decimalPlaces,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Read Requests
|
||||||
|
func (p Prometheus) ComputeReadRequests(ctx context.Context, req ComputeReadRequestsRequest) (*PrometheusData, error) {
|
||||||
|
res, err := p.ComputeReadRequestsRaw(ctx, req)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
info := PrometheusData{}
|
||||||
|
|
||||||
|
err = json.Unmarshal(res, &info)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return &info, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetRaw gets information about compute as an array of bytes
|
||||||
|
func (p Prometheus) ComputeReadRequestsRaw(ctx context.Context, req ComputeReadRequestsRequest) ([]byte, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudapi/prometheus/computeReadRequests"
|
||||||
|
|
||||||
|
res, err := p.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
57
pkg/cloudapi/prometheus/compute_receive_bytes.go
Normal file
57
pkg/cloudapi/prometheus/compute_receive_bytes.go
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
package prometheus
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"encoding/json"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
|
)
|
||||||
|
|
||||||
|
type ComputeReceiveBytesRequest struct {
|
||||||
|
// Compute ID
|
||||||
|
// Required: true
|
||||||
|
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
|
||||||
|
|
||||||
|
// Time to loads of statistic in seconds
|
||||||
|
// Required: false
|
||||||
|
ForLast uint64 `url:"forLast,omitempty" json:"forLast,omitempty"`
|
||||||
|
|
||||||
|
// The reading interval in seconds
|
||||||
|
// Required: false
|
||||||
|
Step uint64 `url:"step,omitempty" json:"step,omitempty"`
|
||||||
|
|
||||||
|
// Number of zeros after the decimal point
|
||||||
|
// Required: false
|
||||||
|
DecimalPlaces uint64 `url:"decimalPlaces,omitempty" json:"decimalPlaces,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Receive Bytes
|
||||||
|
func (p Prometheus) ComputeReceiveBytes(ctx context.Context, req ComputeReceiveBytesRequest) (*PrometheusData, error) {
|
||||||
|
res, err := p.ComputeReceiveBytesRaw(ctx, req)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
info := PrometheusData{}
|
||||||
|
|
||||||
|
err = json.Unmarshal(res, &info)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return &info, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetRaw gets information about compute as an array of bytes
|
||||||
|
func (p Prometheus) ComputeReceiveBytesRaw(ctx context.Context, req ComputeReceiveBytesRequest) ([]byte, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudapi/prometheus/computeReceiveBytes"
|
||||||
|
|
||||||
|
res, err := p.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
57
pkg/cloudapi/prometheus/compute_receive_packets.go
Normal file
57
pkg/cloudapi/prometheus/compute_receive_packets.go
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
package prometheus
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"encoding/json"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
|
)
|
||||||
|
|
||||||
|
type ComputeReceivePacketsRequest struct {
|
||||||
|
// Compute ID
|
||||||
|
// Required: true
|
||||||
|
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
|
||||||
|
|
||||||
|
// Time to loads of statistic in seconds
|
||||||
|
// Required: false
|
||||||
|
ForLast uint64 `url:"forLast,omitempty" json:"forLast,omitempty"`
|
||||||
|
|
||||||
|
// The reading interval in seconds
|
||||||
|
// Required: false
|
||||||
|
Step uint64 `url:"step,omitempty" json:"step,omitempty"`
|
||||||
|
|
||||||
|
// Number of zeros after the decimal point
|
||||||
|
// Required: false
|
||||||
|
DecimalPlaces uint64 `url:"decimalPlaces,omitempty" json:"decimalPlaces,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Receive Packets
|
||||||
|
func (p Prometheus) ComputeReceivePackets(ctx context.Context, req ComputeReceivePacketsRequest) (*PrometheusData, error) {
|
||||||
|
res, err := p.ComputeReceivePacketsRaw(ctx, req)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
info := PrometheusData{}
|
||||||
|
|
||||||
|
err = json.Unmarshal(res, &info)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return &info, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetRaw gets information about compute as an array of bytes
|
||||||
|
func (p Prometheus) ComputeReceivePacketsRaw(ctx context.Context, req ComputeReceivePacketsRequest) ([]byte, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudapi/prometheus/computeReceivePackets"
|
||||||
|
|
||||||
|
res, err := p.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
57
pkg/cloudapi/prometheus/compute_transmit_bytes.go
Normal file
57
pkg/cloudapi/prometheus/compute_transmit_bytes.go
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
package prometheus
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"encoding/json"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
|
)
|
||||||
|
|
||||||
|
type ComputeTransmitBytesRequest struct {
|
||||||
|
// Compute ID
|
||||||
|
// Required: true
|
||||||
|
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
|
||||||
|
|
||||||
|
// Time to loads of statistic in seconds
|
||||||
|
// Required: false
|
||||||
|
ForLast uint64 `url:"forLast,omitempty" json:"forLast,omitempty"`
|
||||||
|
|
||||||
|
// The reading interval in seconds
|
||||||
|
// Required: false
|
||||||
|
Step uint64 `url:"step,omitempty" json:"step,omitempty"`
|
||||||
|
|
||||||
|
// Number of zeros after the decimal point
|
||||||
|
// Required: false
|
||||||
|
DecimalPlaces uint64 `url:"decimalPlaces,omitempty" json:"decimalPlaces,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Transmit Bytes
|
||||||
|
func (p Prometheus) ComputeTransmitBytes(ctx context.Context, req ComputeTransmitBytesRequest) (*PrometheusData, error) {
|
||||||
|
res, err := p.ComputeTransmitBytesRaw(ctx, req)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
info := PrometheusData{}
|
||||||
|
|
||||||
|
err = json.Unmarshal(res, &info)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return &info, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetRaw gets information about compute as an array of bytes
|
||||||
|
func (p Prometheus) ComputeTransmitBytesRaw(ctx context.Context, req ComputeTransmitBytesRequest) ([]byte, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudapi/prometheus/computeTransmitBytes"
|
||||||
|
|
||||||
|
res, err := p.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
57
pkg/cloudapi/prometheus/compute_transmit_packets.go
Normal file
57
pkg/cloudapi/prometheus/compute_transmit_packets.go
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
package prometheus
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"encoding/json"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
|
)
|
||||||
|
|
||||||
|
type ComputeTransmitPacketsRequest struct {
|
||||||
|
// Compute ID
|
||||||
|
// Required: true
|
||||||
|
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
|
||||||
|
|
||||||
|
// Time to loads of statistic in seconds
|
||||||
|
// Required: false
|
||||||
|
ForLast uint64 `url:"forLast,omitempty" json:"forLast,omitempty"`
|
||||||
|
|
||||||
|
// The reading interval in seconds
|
||||||
|
// Required: false
|
||||||
|
Step uint64 `url:"step,omitempty" json:"step,omitempty"`
|
||||||
|
|
||||||
|
// Number of zeros after the decimal point
|
||||||
|
// Required: false
|
||||||
|
DecimalPlaces uint64 `url:"decimalPlaces,omitempty" json:"decimalPlaces,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Transmit Packets
|
||||||
|
func (p Prometheus) ComputeTransmitPackets(ctx context.Context, req ComputeTransmitPacketsRequest) (*PrometheusData, error) {
|
||||||
|
res, err := p.ComputeTransmitPacketsRaw(ctx, req)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
info := PrometheusData{}
|
||||||
|
|
||||||
|
err = json.Unmarshal(res, &info)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return &info, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetRaw gets information about compute as an array of bytes
|
||||||
|
func (p Prometheus) ComputeTransmitPacketsRaw(ctx context.Context, req ComputeTransmitPacketsRequest) ([]byte, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudapi/prometheus/computeTransmitPackets"
|
||||||
|
|
||||||
|
res, err := p.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
57
pkg/cloudapi/prometheus/compute_write_bytes.go
Normal file
57
pkg/cloudapi/prometheus/compute_write_bytes.go
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
package prometheus
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"encoding/json"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
|
)
|
||||||
|
|
||||||
|
type ComputeWriteBytesRequest struct {
|
||||||
|
// Compute ID
|
||||||
|
// Required: true
|
||||||
|
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
|
||||||
|
|
||||||
|
// Time to loads of statistic in seconds
|
||||||
|
// Required: false
|
||||||
|
ForLast uint64 `url:"forLast,omitempty" json:"forLast,omitempty"`
|
||||||
|
|
||||||
|
// The reading interval in seconds
|
||||||
|
// Required: false
|
||||||
|
Step uint64 `url:"step,omitempty" json:"step,omitempty"`
|
||||||
|
|
||||||
|
// Number of zeros after the decimal point
|
||||||
|
// Required: false
|
||||||
|
DecimalPlaces uint64 `url:"decimalPlaces,omitempty" json:"decimalPlaces,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Write Bytes
|
||||||
|
func (p Prometheus) ComputeWriteBytes(ctx context.Context, req ComputeWriteBytesRequest) (*PrometheusData, error) {
|
||||||
|
res, err := p.ComputeWriteBytesRaw(ctx, req)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
info := PrometheusData{}
|
||||||
|
|
||||||
|
err = json.Unmarshal(res, &info)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return &info, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetRaw gets information about compute as an array of bytes
|
||||||
|
func (p Prometheus) ComputeWriteBytesRaw(ctx context.Context, req ComputeWriteBytesRequest) ([]byte, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudapi/prometheus/computeWriteBytes"
|
||||||
|
|
||||||
|
res, err := p.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
57
pkg/cloudapi/prometheus/compute_write_requests.go
Normal file
57
pkg/cloudapi/prometheus/compute_write_requests.go
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
package prometheus
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"encoding/json"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
|
)
|
||||||
|
|
||||||
|
type ComputeWriteRequestsRequest struct {
|
||||||
|
// Compute ID
|
||||||
|
// Required: true
|
||||||
|
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
|
||||||
|
|
||||||
|
// Time to loads of statistic in seconds
|
||||||
|
// Required: false
|
||||||
|
ForLast uint64 `url:"forLast,omitempty" json:"forLast,omitempty"`
|
||||||
|
|
||||||
|
// The reading interval in seconds
|
||||||
|
// Required: false
|
||||||
|
Step uint64 `url:"step,omitempty" json:"step,omitempty"`
|
||||||
|
|
||||||
|
// Number of zeros after the decimal point
|
||||||
|
// Required: false
|
||||||
|
DecimalPlaces uint64 `url:"decimalPlaces,omitempty" json:"decimalPlaces,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Write Requests
|
||||||
|
func (p Prometheus) ComputeWriteRequests(ctx context.Context, req ComputeWriteRequestsRequest) (*PrometheusData, error) {
|
||||||
|
res, err := p.ComputeWriteRequestsRaw(ctx, req)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
info := PrometheusData{}
|
||||||
|
|
||||||
|
err = json.Unmarshal(res, &info)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return &info, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetRaw gets information about compute as an array of bytes
|
||||||
|
func (p Prometheus) ComputeWriteRequestsRaw(ctx context.Context, req ComputeWriteRequestsRequest) ([]byte, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudapi/prometheus/computeWriteRequests"
|
||||||
|
|
||||||
|
res, err := p.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
77
pkg/cloudapi/prometheus/computes.go
Normal file
77
pkg/cloudapi/prometheus/computes.go
Normal file
@@ -0,0 +1,77 @@
|
|||||||
|
package prometheus
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"encoding/json"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
ComputeCPULoad = "computeCPUload"
|
||||||
|
ComputeMemoryUsage = "computeMemoryUsage"
|
||||||
|
ComputeMemoryUsable = "computeMemoryUsable"
|
||||||
|
ComputeMemoryUnused = "computeMemoryUnused"
|
||||||
|
ComputeMemoryUsed = "computeMemoryUsed"
|
||||||
|
ComputeMemoryAvailable = "computeMemoryAvailable"
|
||||||
|
ComputeReadBytes = "computeReadBytes"
|
||||||
|
ComputeReadRequests = "computeReadRequests"
|
||||||
|
ComputeReceiveBytes = "computeReceiveBytes"
|
||||||
|
ComputeTransmitBytes = "computeTransmitBytes"
|
||||||
|
ComputeTransmitPackets = "computeTransmitPackets"
|
||||||
|
ComputeWriteBytes = "computeWriteBytes"
|
||||||
|
ComputeWriteRequests = "computeWriteRequests"
|
||||||
|
)
|
||||||
|
|
||||||
|
type ComputesRequest struct {
|
||||||
|
// List of compute IDs to fetch metrics for
|
||||||
|
// Required: true
|
||||||
|
ComputeIDs []uint64 `url:"computeIds" json:"computeIds" validate:"required"`
|
||||||
|
|
||||||
|
// List of compute IDs to fetch metrics for
|
||||||
|
// Required: true
|
||||||
|
MetricIDs []string `url:"metricIds" json:"metricIds" validate:"required"`
|
||||||
|
|
||||||
|
// Time to loads of statistic in seconds
|
||||||
|
// Required: false
|
||||||
|
ForLast uint64 `url:"forLast,omitempty" json:"forLast,omitempty"`
|
||||||
|
|
||||||
|
// The reading interval in seconds
|
||||||
|
// Required: false
|
||||||
|
Step uint64 `url:"step,omitempty" json:"step,omitempty"`
|
||||||
|
|
||||||
|
// Number of zeros after the decimal point
|
||||||
|
// Required: false
|
||||||
|
DecimalPlaces uint64 `url:"decimalPlaces,omitempty" json:"decimalPlaces,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get multiple metrics for multiple compute instances
|
||||||
|
func (p Prometheus) Computes(ctx context.Context, req ComputesRequest) (*ComputesData, error) {
|
||||||
|
res, err := p.ComputesRaw(ctx, req)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
info := ComputesData{}
|
||||||
|
|
||||||
|
err = json.Unmarshal(res, &info)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return &info, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetRaw gets information about compute as an array of bytes
|
||||||
|
func (p Prometheus) ComputesRaw(ctx context.Context, req ComputesRequest) ([]byte, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudapi/prometheus/computes"
|
||||||
|
|
||||||
|
res, err := p.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
40
pkg/cloudapi/prometheus/models.go
Normal file
40
pkg/cloudapi/prometheus/models.go
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
package prometheus
|
||||||
|
|
||||||
|
// PrometheusData represents an array of data points
|
||||||
|
type PrometheusData []PrometheusPoint
|
||||||
|
|
||||||
|
// PrometheusPoint represents a single data point
|
||||||
|
type PrometheusPoint struct {
|
||||||
|
// Value of the metric at a specific point in time
|
||||||
|
Value float64 `json:"value"`
|
||||||
|
|
||||||
|
// Timestamp the Unix timestamp.
|
||||||
|
Timestamp uint64 `json:"timestamp"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ComputesData represents an array of data points for computes
|
||||||
|
type ComputesData []ItemCompute
|
||||||
|
|
||||||
|
// ItemCompute represents a single data of compute
|
||||||
|
type ItemCompute struct {
|
||||||
|
// Compute ID
|
||||||
|
ComputeID uint64 `json:"computeId"`
|
||||||
|
|
||||||
|
// Array of metrics
|
||||||
|
Metrics []ItemMetric `json:"metrics"`
|
||||||
|
|
||||||
|
// Error
|
||||||
|
Error string `json:"error"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ItemMetric represents a single data point of metric
|
||||||
|
type ItemMetric struct {
|
||||||
|
// Metric ID
|
||||||
|
MetricID string `json:"metricId"`
|
||||||
|
|
||||||
|
// Data represents an array of data points
|
||||||
|
Data PrometheusData `json:"data"`
|
||||||
|
|
||||||
|
// Error
|
||||||
|
Error string `json:"error"`
|
||||||
|
}
|
||||||
15
pkg/cloudapi/prometheus/prometheus.go
Normal file
15
pkg/cloudapi/prometheus/prometheus.go
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
package prometheus
|
||||||
|
|
||||||
|
import (
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/interfaces"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Prometheus struct {
|
||||||
|
client interfaces.Caller
|
||||||
|
}
|
||||||
|
|
||||||
|
func New(client interfaces.Caller) *Prometheus {
|
||||||
|
return &Prometheus{
|
||||||
|
client: client,
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -24,10 +24,6 @@ type AccessGrantRequest struct {
|
|||||||
// - "ARCXDU"
|
// - "ARCXDU"
|
||||||
// Required: true
|
// Required: true
|
||||||
Right string `url:"right" json:"right" validate:"accessType"`
|
Right string `url:"right" json:"right" validate:"accessType"`
|
||||||
|
|
||||||
// Reason for action
|
|
||||||
// Required: false
|
|
||||||
Reason string `url:"reason,omitempty" json:"reason,omitempty"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// AccessGrant grants user or group access to the resource group as specified
|
// AccessGrant grants user or group access to the resource group as specified
|
||||||
|
|||||||
@@ -17,10 +17,6 @@ type AccessRevokeRequest struct {
|
|||||||
// User or group name to revoke access
|
// User or group name to revoke access
|
||||||
// Required: true
|
// Required: true
|
||||||
User string `url:"user" json:"user" validate:"required"`
|
User string `url:"user" json:"user" validate:"required"`
|
||||||
|
|
||||||
// Reason for action
|
|
||||||
// Required: false
|
|
||||||
Reason string `url:"reason,omitempty" json:"reason,omitempty"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// AccessRevoke revokes specified user or group access from the resource group
|
// AccessRevoke revokes specified user or group access from the resource group
|
||||||
|
|||||||
@@ -64,10 +64,6 @@ type CreateRequest struct {
|
|||||||
// Required: false
|
// Required: false
|
||||||
Description string `url:"desc,omitempty" json:"desc,omitempty"`
|
Description string `url:"desc,omitempty" json:"desc,omitempty"`
|
||||||
|
|
||||||
// Reason for action
|
|
||||||
// Required: false
|
|
||||||
Reason string `url:"reason,omitempty" json:"reason,omitempty"`
|
|
||||||
|
|
||||||
// External network ID
|
// External network ID
|
||||||
// Required: false
|
// Required: false
|
||||||
ExtNetID uint64 `url:"extNetId,omitempty" json:"extNetId,omitempty"`
|
ExtNetID uint64 `url:"extNetId,omitempty" json:"extNetId,omitempty"`
|
||||||
@@ -75,10 +71,6 @@ type CreateRequest struct {
|
|||||||
// External IP address
|
// External IP address
|
||||||
// Required: false
|
// Required: false
|
||||||
ExtIP string `url:"extIp,omitempty" json:"extIp,omitempty"`
|
ExtIP string `url:"extIp,omitempty" json:"extIp,omitempty"`
|
||||||
|
|
||||||
// Register computes in registration system
|
|
||||||
// Required: false
|
|
||||||
RegisterComputes bool `url:"registerComputes,omitempty" json:"registerComputes,omitempty"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create creates resource group
|
// Create creates resource group
|
||||||
|
|||||||
@@ -22,10 +22,6 @@ type DeleteRequest struct {
|
|||||||
// Otherwise, they will be placed into recycle bin and could be restored later within recycle bin's purge period
|
// Otherwise, they will be placed into recycle bin and could be restored later within recycle bin's purge period
|
||||||
// Required: false
|
// Required: false
|
||||||
Permanently bool `url:"permanently,omitempty" json:"permanently,omitempty"`
|
Permanently bool `url:"permanently,omitempty" json:"permanently,omitempty"`
|
||||||
|
|
||||||
// Reason for action
|
|
||||||
// Required: false
|
|
||||||
Reason string `url:"reason,omitempty" json:"reason,omitempty"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete deletes resource group
|
// Delete deletes resource group
|
||||||
|
|||||||
@@ -13,10 +13,6 @@ type DisableRequest 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"`
|
||||||
|
|
||||||
// Reason for action
|
|
||||||
// Required: false
|
|
||||||
Reason string `url:"reason,omitempty" json:"reason,omitempty"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Disable disables resource group
|
// Disable disables resource group
|
||||||
|
|||||||
@@ -13,10 +13,6 @@ type EnableRequest 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"`
|
||||||
|
|
||||||
// Reason for action
|
|
||||||
// Required: false
|
|
||||||
Reason string `url:"reason,omitempty" json:"reason,omitempty"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Enable enables resource group
|
// Enable enables resource group
|
||||||
|
|||||||
@@ -17,20 +17,19 @@ var rgs = ListResourceGroups{
|
|||||||
UserGroupID: "sample_user_1@decs3o",
|
UserGroupID: "sample_user_1@decs3o",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
CreatedBy: "sample_user_1@decs3o",
|
CreatedBy: "sample_user_1@decs3o",
|
||||||
CreatedTime: 1676645305,
|
CreatedTime: 1676645305,
|
||||||
DefNetID: 1,
|
DefNetID: 1,
|
||||||
DefNetType: "NONE",
|
DefNetType: "NONE",
|
||||||
DeletedBy: "",
|
DeletedBy: "",
|
||||||
DeletedTime: 0,
|
DeletedTime: 0,
|
||||||
Description: "",
|
Description: "",
|
||||||
GID: 212,
|
GID: 212,
|
||||||
GUID: 7971,
|
GUID: 7971,
|
||||||
ID: 7971,
|
ID: 7971,
|
||||||
LockStatus: "UNLOCKED",
|
LockStatus: "UNLOCKED",
|
||||||
Milestones: 363459,
|
Milestones: 363459,
|
||||||
Name: "rg_1",
|
Name: "rg_1",
|
||||||
RegisterComputes: false,
|
|
||||||
ResourceLimits: ResourceLimits{
|
ResourceLimits: ResourceLimits{
|
||||||
CUC: -1,
|
CUC: -1,
|
||||||
CUI: -1,
|
CUI: -1,
|
||||||
@@ -60,20 +59,19 @@ var rgs = ListResourceGroups{
|
|||||||
UserGroupID: "sample_user_1@decs3o",
|
UserGroupID: "sample_user_1@decs3o",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
CreatedBy: "sample_user_1@decs3o",
|
CreatedBy: "sample_user_1@decs3o",
|
||||||
CreatedTime: 1676645461,
|
CreatedTime: 1676645461,
|
||||||
DefNetID: 2,
|
DefNetID: 2,
|
||||||
DefNetType: "NONE",
|
DefNetType: "NONE",
|
||||||
DeletedBy: "",
|
DeletedBy: "",
|
||||||
DeletedTime: 0,
|
DeletedTime: 0,
|
||||||
Description: "",
|
Description: "",
|
||||||
GID: 212,
|
GID: 212,
|
||||||
GUID: 7972,
|
GUID: 7972,
|
||||||
ID: 7972,
|
ID: 7972,
|
||||||
LockStatus: "UNLOCKED",
|
LockStatus: "UNLOCKED",
|
||||||
Milestones: 363468,
|
Milestones: 363468,
|
||||||
Name: "rg_2",
|
Name: "rg_2",
|
||||||
RegisterComputes: false,
|
|
||||||
ResourceLimits: ResourceLimits{
|
ResourceLimits: ResourceLimits{
|
||||||
CUC: -1,
|
CUC: -1,
|
||||||
CUI: -1,
|
CUI: -1,
|
||||||
@@ -103,20 +101,19 @@ var rgs = ListResourceGroups{
|
|||||||
UserGroupID: "sample_user_2@decs3o",
|
UserGroupID: "sample_user_2@decs3o",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
CreatedBy: "sample_user_2@decs3o",
|
CreatedBy: "sample_user_2@decs3o",
|
||||||
CreatedTime: 1676645548,
|
CreatedTime: 1676645548,
|
||||||
DefNetID: 3,
|
DefNetID: 3,
|
||||||
DefNetType: "NONE",
|
DefNetType: "NONE",
|
||||||
DeletedBy: "",
|
DeletedBy: "",
|
||||||
DeletedTime: 0,
|
DeletedTime: 0,
|
||||||
Description: "",
|
Description: "",
|
||||||
GID: 212,
|
GID: 212,
|
||||||
GUID: 7973,
|
GUID: 7973,
|
||||||
ID: 7973,
|
ID: 7973,
|
||||||
LockStatus: "kjLOCKED",
|
LockStatus: "kjLOCKED",
|
||||||
Milestones: 363471,
|
Milestones: 363471,
|
||||||
Name: "rg_3",
|
Name: "rg_3",
|
||||||
RegisterComputes: false,
|
|
||||||
ResourceLimits: ResourceLimits{
|
ResourceLimits: ResourceLimits{
|
||||||
CUC: -1,
|
CUC: -1,
|
||||||
CUI: -1,
|
CUI: -1,
|
||||||
|
|||||||
@@ -13,10 +13,6 @@ type GetRequest 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"`
|
||||||
|
|
||||||
// Reason for action
|
|
||||||
// Required: false
|
|
||||||
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 as a RecordResourceGroup struct
|
||||||
|
|||||||
@@ -128,9 +128,6 @@ type RecordResourceGroup struct {
|
|||||||
// Name
|
// Name
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
|
|
||||||
// RegisterComputes
|
|
||||||
RegisterComputes bool `json:"registerComputes"`
|
|
||||||
|
|
||||||
// Resource limits
|
// Resource limits
|
||||||
ResourceLimits ResourceLimits `json:"resourceLimits"`
|
ResourceLimits ResourceLimits `json:"resourceLimits"`
|
||||||
|
|
||||||
@@ -224,9 +221,6 @@ type ItemResourceGroup struct {
|
|||||||
// Name
|
// Name
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
|
|
||||||
// RegisterComputes
|
|
||||||
RegisterComputes bool `json:"registerComputes"`
|
|
||||||
|
|
||||||
// Resource limits
|
// Resource limits
|
||||||
ResourceLimits ResourceLimits `json:"resourceLimits"`
|
ResourceLimits ResourceLimits `json:"resourceLimits"`
|
||||||
|
|
||||||
@@ -787,7 +781,7 @@ type ItemVINS struct {
|
|||||||
ExtnetId uint64 `json:"extnetId"`
|
ExtnetId uint64 `json:"extnetId"`
|
||||||
|
|
||||||
// Free IPs
|
// Free IPs
|
||||||
FreeIPs uint64 `json:"freeIPs"`
|
FreeIPs int64 `json:"freeIPs"`
|
||||||
|
|
||||||
// ID
|
// ID
|
||||||
ID uint64 `json:"id"`
|
ID uint64 `json:"id"`
|
||||||
|
|||||||
38
pkg/cloudapi/rg/remove_def_net.go
Normal file
38
pkg/cloudapi/rg/remove_def_net.go
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
package rg
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"net/http"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
|
)
|
||||||
|
|
||||||
|
// RemoveDefNetRequest struct to remove default network
|
||||||
|
type RemoveDefNetRequest struct {
|
||||||
|
// Resource group ID
|
||||||
|
// Required: true
|
||||||
|
RGID uint64 `url:"rgId" json:"rgId" validate:"required"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// RemoveDefNet removes default network from resource group
|
||||||
|
func (r RG) RemoveDefNet(ctx context.Context, req RemoveDefNetRequest) (bool, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudapi/rg/removeDefNet"
|
||||||
|
|
||||||
|
res, err := r.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
|
||||||
|
}
|
||||||
@@ -13,10 +13,6 @@ type RestoreRequest 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"`
|
||||||
|
|
||||||
// Reason for action
|
|
||||||
// Required: false
|
|
||||||
Reason string `url:"reason,omitempty" json:"reason,omitempty"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Restore restores resource group from recycle bin
|
// Restore restores resource group from recycle bin
|
||||||
|
|||||||
@@ -24,10 +24,6 @@ type SetDefNetRequest struct {
|
|||||||
// Network ID
|
// Network ID
|
||||||
// Required: false
|
// Required: false
|
||||||
NetID uint64 `url:"netId,omitempty" json:"netId,omitempty"`
|
NetID uint64 `url:"netId,omitempty" json:"netId,omitempty"`
|
||||||
|
|
||||||
// Reason for action
|
|
||||||
// Required: false
|
|
||||||
Reason string `url:"reason,omitempty" json:"reason,omitempty"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetDefNet sets default network for attach associated virtual machines
|
// SetDefNet sets default network for attach associated virtual machines
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user