Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b6185a95ea | ||
|
|
faa9487e03 | ||
|
|
f61319c21b | ||
|
|
fe413c7182 | ||
|
|
3e2edf53a5 | ||
|
|
8f8a81eea4 | ||
|
|
d82ae52951 | ||
|
|
5e5d90e24f | ||
|
|
cd67633a52 | ||
|
|
0812c5a8af |
No files matched your search
+7
-39
@@ -1,4 +1,4 @@
|
|||||||
## Version 14.5.0
|
## Version 14.15.0
|
||||||
|
|
||||||
Методы `Audits` в cloudapi/compute, cloudbroker/compute, cloudapi/account, cloudbroker/account, cloudapi/vins, cloudbroker/vins, cloudapi/rg и cloudbroker/rg стали deprecated и в следующих версиях будут удалены, вместо них необходимо использовать метод `List` в cloudapi/audit и cloudbroker/audit с соответствующими фильтрами
|
Методы `Audits` в cloudapi/compute, cloudbroker/compute, cloudapi/account, cloudbroker/account, cloudapi/vins, cloudbroker/vins, cloudapi/rg и cloudbroker/rg стали deprecated и в следующих версиях будут удалены, вместо них необходимо использовать метод `List` в cloudapi/audit и cloudbroker/audit с соответствующими фильтрами
|
||||||
Методы `AccessGrant`, `AccessGrantToPool`, `AccessRevoke`, `AccessRevokeToPool` в cloudbroker/sep стали deprecated и в следующих версиях будут удалены
|
Методы `AccessGrant`, `AccessGrantToPool`, `AccessRevoke`, `AccessRevokeToPool` в cloudbroker/sep стали deprecated и в следующих версиях будут удалены
|
||||||
@@ -7,43 +7,11 @@
|
|||||||
|
|
||||||
Все методы группы `.SDN()` находятся в альфа-версии.
|
Все методы группы `.SDN()` находятся в альфа-версии.
|
||||||
|
|
||||||
### Добавлено
|
|
||||||
|
|
||||||
#### compute
|
|
||||||
| Идентификатор<br>задачи | Описание |
|
### Исправлено
|
||||||
|
|
||||||
|
#### client sdk
|
||||||
|
| Идентификатор задачи | Описание |
|
||||||
| --- | --- |
|
| --- | --- |
|
||||||
| BGOS-360 | Валидация поля `Label` в структуре запроса `SnapshotCreateRequest` в cloudapi/compute и cloudbroker/compute |
|
| BGOS-1135 | Исправлена ошибка в сообщении об ошибке при отсутствии времени истечения токена в клиенте |
|
||||||
|
|
||||||
#### image
|
|
||||||
| Идентификатор<br>задачи | Описание |
|
|
||||||
| --- | --- |
|
|
||||||
| BGOS-820 | Обязательное поле `SEPID` в структуру запроса `MultiImageExportRequest` в cloudbroker/image |
|
|
||||||
|
|
||||||
#### locations
|
|
||||||
| Идентификатор<br>задачи | Описание |
|
|
||||||
| --- | --- |
|
|
||||||
| BGOS-823 | Вычисляемое поле `ZeroAccessEnabled` в структуру ответа `ItemLocation` в cloudapi/locations |
|
|
||||||
|
|
||||||
#### resource_optimizer
|
|
||||||
| Идентификатор<br>задачи | Описание |
|
|
||||||
| --- | --- |
|
|
||||||
| BGOS-818 | Группа методов `cloudbroker/resource_optimizer` для управления инструментом оптимизации ресурсов (DRS) |
|
|
||||||
|
|
||||||
### zone
|
|
||||||
| Идентификатор<br>задачи | Описание |
|
|
||||||
| --- | --- |
|
|
||||||
| BGOS-819 | Вычисляемые поля `DRS`, `DRSUID`, `AppID`, `DecortURL`, `DRSName` и `SSOURL` в структуру ответа `RecordZone` в cloudapi/zone и в cloudbroker/zone |
|
|
||||||
| BGOS-819 | Структура ответа `ItemZone` в cloudapi/zone и в cloudbroker/zone |
|
|
||||||
| BGOS-819 | Опциональное поле `DRS` в структуру запроса `CreateRequest` в cloudbroker/zone |
|
|
||||||
|
|
||||||
### Изменено
|
|
||||||
|
|
||||||
#### image
|
|
||||||
| Идентификатор<br>задачи | Описание |
|
|
||||||
| --- | --- |
|
|
||||||
| BGOS-822 | Тип полей `HotResize` и `Bootable` в структуре запроса `EditRequest` с bool на interface в cloudbroker/image |
|
|
||||||
|
|
||||||
#### node
|
|
||||||
| Идентификатор<br>задачи | Описание |
|
|
||||||
| --- | --- |
|
|
||||||
| BGOS-821 | Тип вычисляемого поля `VCPU` с `uint64` на `float64` в структуре ответа `FreeResourcesInfo` в cloudbroker/node |
|
|
||||||
@@ -123,6 +123,8 @@ go get -u repository.basistech.ru/BASIS/dynamix-golang-sdk/v14
|
|||||||
- `Trunk` - получение информации о транковых портах;
|
- `Trunk` - получение информации о транковых портах;
|
||||||
- `VFPool` - управление пулом виртуальных сетевых функций;
|
- `VFPool` - управление пулом виртуальных сетевых функций;
|
||||||
- `VINS` - управление виртуальными изолированными сетями;
|
- `VINS` - управление виртуальными изолированными сетями;
|
||||||
|
- `VGPU` - управление виртуальными графическими процессорами;
|
||||||
|
- `VMFolder` – управление директориями ВМ;
|
||||||
- `Zone` - управление зонами.
|
- `Zone` - управление зонами.
|
||||||
|
|
||||||
### Cloudbroker
|
### Cloudbroker
|
||||||
@@ -151,7 +153,6 @@ go get -u repository.basistech.ru/BASIS/dynamix-golang-sdk/v14
|
|||||||
- `PCIDevice` - управление устройствами;
|
- `PCIDevice` - управление устройствами;
|
||||||
- `Prometheus` - получение статистики prometheus;
|
- `Prometheus` - получение статистики prometheus;
|
||||||
- `Resmon` - получение статистики resource monitoring;
|
- `Resmon` - получение статистики resource monitoring;
|
||||||
- `ResourceOptimizer` - управление инструментом оптимизации ресурсов (DRS);
|
|
||||||
- `RG` - управление ресурсными группами аккаунта;
|
- `RG` - управление ресурсными группами аккаунта;
|
||||||
- `Security group` – управление группами безопасности;
|
- `Security group` – управление группами безопасности;
|
||||||
- `SEP` - управление storage endpoint (sep);
|
- `SEP` - управление storage endpoint (sep);
|
||||||
@@ -161,7 +162,8 @@ go get -u repository.basistech.ru/BASIS/dynamix-golang-sdk/v14
|
|||||||
- `User` - управление пользователями (индивидуально);
|
- `User` - управление пользователями (индивидуально);
|
||||||
- `VGPU` - управление виртуальными графическими процессорами;
|
- `VGPU` - управление виртуальными графическими процессорами;
|
||||||
- `VFPool` - управление пулом виртуальных сетевых функций;
|
- `VFPool` - управление пулом виртуальных сетевых функций;
|
||||||
- `VINS` - управление виртуальными изолированными сетями.
|
- `VINS` - управление виртуальными изолированными сетями;
|
||||||
|
- `VMFolder` – управление директориями ВМ;
|
||||||
- `Zone` - управление зонами.
|
- `Zone` - управление зонами.
|
||||||
|
|
||||||
### SDN
|
### SDN
|
||||||
@@ -173,12 +175,14 @@ go get -u repository.basistech.ru/BASIS/dynamix-golang-sdk/v14
|
|||||||
- `Address pool` - управление пулами адресов;
|
- `Address pool` - управление пулами адресов;
|
||||||
- `DefaultSecurityPolicies` - управление политиками хранения по умолчанию;
|
- `DefaultSecurityPolicies` - управление политиками хранения по умолчанию;
|
||||||
- `ExtNet` - управление виртуальными сетями, отвечающими за внешний доступ;
|
- `ExtNet` - управление виртуальными сетями, отвечающими за внешний доступ;
|
||||||
|
- `Hypervisors` - управление гипервизорами;
|
||||||
- `FloatingIPs` - управление плавающими IP-адресами;
|
- `FloatingIPs` - управление плавающими IP-адресами;
|
||||||
- `Logical ports` - управление логическими портами;
|
- `Logical ports` - управление логическими портами;
|
||||||
- `NetworkObjectGroups` - управление группами объектов сети;
|
- `NetworkObjectGroups` - управление группами объектов сети;
|
||||||
- `Routers` - управление роутерами;
|
- `Routers` - управление роутерами;
|
||||||
- `SecurityPolicies` - управление политиками хранения;
|
- `SecurityPolicies` - управление политиками хранения;
|
||||||
- `Segments` - управление сегментами;
|
- `Segments` - управление сегментами;
|
||||||
|
- `Version` - получение информации о версии SDN;
|
||||||
|
|
||||||
## Работа с библиотекой
|
## Работа с библиотекой
|
||||||
|
|
||||||
@@ -334,6 +338,8 @@ func main() {
|
|||||||
- `pkg/cloudapi/trunk` - для `Trunk`
|
- `pkg/cloudapi/trunk` - для `Trunk`
|
||||||
- `pkg/cloudapi/vfpool` - для `VFPool`
|
- `pkg/cloudapi/vfpool` - для `VFPool`
|
||||||
- `pkg/cloudapi/vins` - для `VINS`
|
- `pkg/cloudapi/vins` - для `VINS`
|
||||||
|
- `pkg/cloudapi/vgpu` - для `VGPU`
|
||||||
|
- `pkg/cloudapi/vmfolder` - для `VMFolder`
|
||||||
- `pkg/cloudapi/zone` - для `Zone`
|
- `pkg/cloudapi/zone` - для `Zone`
|
||||||
- **cloudbroker**:
|
- **cloudbroker**:
|
||||||
- `pkg/cloudbroker/account` - для `Account`
|
- `pkg/cloudbroker/account` - для `Account`
|
||||||
@@ -357,7 +363,6 @@ func main() {
|
|||||||
- `pkg/cloudbroker/pcidevice` - для `PCIDevice`
|
- `pkg/cloudbroker/pcidevice` - для `PCIDevice`
|
||||||
- `pkg/cloudbroker/prometheus` - для `Prometheus`
|
- `pkg/cloudbroker/prometheus` - для `Prometheus`
|
||||||
- `pkg/cloudbroker/resmon` - для `Resmon`
|
- `pkg/cloudbroker/resmon` - для `Resmon`
|
||||||
- `pkg/cloudbroker/resource_optimizer` - для `ResourceOptimizer`
|
|
||||||
- `pkg/cloudbroker/rg` - для `RG`
|
- `pkg/cloudbroker/rg` - для `RG`
|
||||||
- `pkg/cloudbroker/secgroup` - для `Security group`
|
- `pkg/cloudbroker/secgroup` - для `Security group`
|
||||||
- `pkg/cloudbroker/sep` - для `SEP`
|
- `pkg/cloudbroker/sep` - для `SEP`
|
||||||
@@ -368,18 +373,21 @@ func main() {
|
|||||||
- `pkg/cloudbroker/vgpu` - для `VGPU`
|
- `pkg/cloudbroker/vgpu` - для `VGPU`
|
||||||
- `pkg/cloudbroker/vfpool` - для `VFPool`
|
- `pkg/cloudbroker/vfpool` - для `VFPool`
|
||||||
- `pkg/cloudbroker/vins` - для `VINS`
|
- `pkg/cloudbroker/vins` - для `VINS`
|
||||||
|
- `pkg/cloudbroker/vmfolder` - для `VMFolder`
|
||||||
- `pkg/cloudbroker/zone` - для `Zone`
|
- `pkg/cloudbroker/zone` - для `Zone`
|
||||||
- **sdn**:
|
- **sdn**:
|
||||||
- `pkg/sdn/acsgroups` - для `Access groups`
|
- `pkg/sdn/acsgroups` - для `Access groups`
|
||||||
- `pkg/sdn/adrspools` - для `Address pool`
|
- `pkg/sdn/adrspools` - для `Address pool`
|
||||||
- `pkg/sdn/defsecpolicies` - для `DefaultSecurityPolicies`
|
- `pkg/sdn/defsecpolicies` - для `DefaultSecurityPolicies`
|
||||||
- `pkg/sdn/external_networks` - для `ExtNet`
|
- `pkg/sdn/external_networks` - для `ExtNet`
|
||||||
|
- `pkg/sdn/hypervisors` - для `Hypervisors`
|
||||||
- `pkg/sdn/flips` - для `FloatingIPs`
|
- `pkg/sdn/flips` - для `FloatingIPs`
|
||||||
- `pkg/sdn/logicalports` - для `Logical ports`
|
- `pkg/sdn/logicalports` - для `Logical ports`
|
||||||
- `pkg/sdn/netobjgroups` - для `NetworkObjectGroups`
|
- `pkg/sdn/netobjgroups` - для `NetworkObjectGroups`
|
||||||
- `pkg/sdn/routers` - для `Routers`
|
- `pkg/sdn/routers` - для `Routers`
|
||||||
- `pkg/sdn/secpolicies` - для `SecurityPolicies`
|
- `pkg/sdn/secpolicies` - для `SecurityPolicies`
|
||||||
- `pkg/sdn/segments` - для `Segments`
|
- `pkg/sdn/segments` - для `Segments`
|
||||||
|
- `pkg/sdn/version` - для `Version`
|
||||||
|
|
||||||
Все поля структуры имеют описание, в которых содержится:
|
Все поля структуры имеют описание, в которых содержится:
|
||||||
|
|
||||||
@@ -459,7 +467,7 @@ type CreateRequest struct {
|
|||||||
|
|
||||||
// Node ID
|
// Node ID
|
||||||
// Required: false
|
// Required: false
|
||||||
NodeID uint64 `url:"nodeId,omitempty" json:"nodeId,omitempty"`
|
NodeID uint64 `url:"nodeId,omitempty" json:"nodeId,omitempty"`
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -531,6 +539,8 @@ func main() {
|
|||||||
- `.Trunk()` - для работы с `Trunk`
|
- `.Trunk()` - для работы с `Trunk`
|
||||||
- `.VFPool()` - для работы с `VFPool`
|
- `.VFPool()` - для работы с `VFPool`
|
||||||
- `.VINS()` - для работы с `VINS`
|
- `.VINS()` - для работы с `VINS`
|
||||||
|
- `.VGPU()` - для работы с `VGPU`
|
||||||
|
- `.VMFolder()` - для работы с `VMFolder`
|
||||||
- `.Zone()` - для работы с `Zone`
|
- `.Zone()` - для работы с `Zone`
|
||||||
|
|
||||||
Доступные методы для `.CloudBroker()`:
|
Доступные методы для `.CloudBroker()`:
|
||||||
@@ -556,7 +566,6 @@ func main() {
|
|||||||
- `.PCIDevice()` - для работы с `PCIDevice`
|
- `.PCIDevice()` - для работы с `PCIDevice`
|
||||||
- `.Prometheus()` - для работы с `Prometheus`
|
- `.Prometheus()` - для работы с `Prometheus`
|
||||||
- `.Resmon()` - для работы с `Resmon`
|
- `.Resmon()` - для работы с `Resmon`
|
||||||
- `.ResourceOptimizer()` - для работы с `ResourceOptimizer`
|
|
||||||
- `.RG()` - для работы с `RG`
|
- `.RG()` - для работы с `RG`
|
||||||
- `.SecurityGroup()` - для работы с `Security Group`
|
- `.SecurityGroup()` - для работы с `Security Group`
|
||||||
- `.SEP()` - для работы с `SEP`
|
- `.SEP()` - для работы с `SEP`
|
||||||
@@ -567,20 +576,23 @@ func main() {
|
|||||||
- `.VGPU()` - для работы с `VGPU`
|
- `.VGPU()` - для работы с `VGPU`
|
||||||
- `.VFPool()` - для работы с `VFPool`
|
- `.VFPool()` - для работы с `VFPool`
|
||||||
- `.VINS()` - для работы с `VINS`
|
- `.VINS()` - для работы с `VINS`
|
||||||
|
- `.VMFolder()` - для работы с `VMFolder`
|
||||||
- `.Zone()` - для работы с `Zone`
|
- `.Zone()` - для работы с `Zone`
|
||||||
|
|
||||||
Доступные методы для `.SDN()`:
|
Доступные методы для `.SDN()`:
|
||||||
|
|
||||||
- `.AccessGroup()` - для работы с `Access group`
|
- `.AccessGroup()` - для работы с `Access group`
|
||||||
- `.AddressPool()` - для работы с `Addres pool`
|
- `.AddressPool()` - для работы с `Addres pool`
|
||||||
- `.DefaultSecurityPolicies()` - для работы с `DefaultSecurityPolicies`
|
- `.DefaultSecurityPolicies()` - для работы с `DefaultSecurityPolicies`
|
||||||
- `.ExtNet()` - для работы с `ExtNet`
|
- `.ExtNet()` - для работы с `ExtNet`
|
||||||
|
- `.Hypervisors()` - для работы с `Hypervisors`
|
||||||
- `.FloatingIPs()` - для работы с `FloatingIPs`
|
- `.FloatingIPs()` - для работы с `FloatingIPs`
|
||||||
- `.LogicalPorts()` - для работы с `Logical ports`
|
- `.LogicalPorts()` - для работы с `Logical ports`
|
||||||
- `.NetworkObjectGroups()` - для работы с `NetworkObjectGroups`
|
- `.NetworkObjectGroups()` - для работы с `NetworkObjectGroups`
|
||||||
- `.Routers()` - для работы с `Routers`
|
- `.Routers()` - для работы с `Routers`
|
||||||
- `.SecurityPolicies()` - для работы с `SecurityPolicies`
|
- `.SecurityPolicies()` - для работы с `SecurityPolicies`
|
||||||
- `.Segments()` - для работы с `Segments`
|
- `.Segments()` - для работы с `Segments`
|
||||||
|
- `.Version()` - для работы с `Version`
|
||||||
|
|
||||||
3. Вызвать метод, отвечающий за выполнение запроса и передать в него:
|
3. Вызвать метод, отвечающий за выполнение запроса и передать в него:
|
||||||
|
|
||||||
@@ -940,7 +952,7 @@ func main() {
|
|||||||
- ToString(): строковое представление результата выполнения задачи
|
- ToString(): строковое представление результата выполнения задачи
|
||||||
- ID() и Name(): получение ID и имени созданного в результате выполнения задачи ресурса
|
- ID() и Name(): получение ID и имени созданного в результате выполнения задачи ресурса
|
||||||
- ToMaps(): получение списка карт, содержащих информацию о дисках, восстановленных в результате выполнения задачи.
|
- ToMaps(): получение списка карт, содержащих информацию о дисках, восстановленных в результате выполнения задачи.
|
||||||
Все методы оборудованы возвратом ошибок. Непустая ошибка означает, что из поля Result нельзя получить информацию, которую предоставляет метод.
|
Все методы оборудованы возвратом ошибок. Непустая ошибка означает, что из поля Result нельзя получить информацию, которую предоставляет метод.
|
||||||
|
|
||||||
```go
|
```go
|
||||||
package main
|
package main
|
||||||
@@ -1547,7 +1559,7 @@ func main() {
|
|||||||
| BVSConfig | *BVSConfig | Нет | Конфигурация BVS |
|
| BVSConfig | *BVSConfig | Нет | Конфигурация BVS |
|
||||||
| LegacyConfig | string | Нет | Конфигурация Legacy |
|
| LegacyConfig | string | Нет | Конфигурация Legacy |
|
||||||
|
|
||||||
В универсальном клиенте можно использовать только один тип конфигурации одновременно.
|
В универсальном клиенте можно использовать только один тип конфигурации одновременно.
|
||||||
|
|
||||||
#### Пример конфигурации универсального клиента
|
#### Пример конфигурации универсального клиента
|
||||||
|
|
||||||
@@ -1618,46 +1630,46 @@ package main
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v14/config"
|
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v14/config"
|
||||||
decort "repository.basistech.ru/BASIS/dynamix-golang-sdk/v14"
|
decort "repository.basistech.ru/BASIS/dynamix-golang-sdk/v14"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
// Настройка конфигурации
|
// Настройка конфигурации
|
||||||
legacyCfg := config.LegacyConfig{
|
legacyCfg := config.LegacyConfig{
|
||||||
Username: "<USERNAME>",
|
Username: "<USERNAME>",
|
||||||
Password: "<PASSWORD>",
|
Password: "<PASSWORD>",
|
||||||
Domain: "dynamix",
|
Domain: "dynamix",
|
||||||
DecortURL: "https://mr4.digitalenergy.online",
|
DecortURL: "https://mr4.digitalenergy.online",
|
||||||
Retries: 5,
|
Retries: 5,
|
||||||
|
}
|
||||||
|
|
||||||
|
legacyCfg.SetTimeout(5 * time.Minute)
|
||||||
|
|
||||||
|
cfg := config.UniversalConfig{
|
||||||
|
LegacyConfig: &legacyCfg,
|
||||||
}
|
}
|
||||||
|
|
||||||
legacyCfg.SetTimeout(5 * time.Minute)
|
// Создание клиента
|
||||||
|
universalClient := decort.NewUniversal(cfg)
|
||||||
|
|
||||||
|
// Создание структуры запроса
|
||||||
|
// CreateRequest - реквест на создание виртуальной машины
|
||||||
|
req := kvmx86.CreateRequest{
|
||||||
|
RGID: 123,
|
||||||
|
Name: "compute",
|
||||||
|
CPU: 4,
|
||||||
|
RAM: 4096,
|
||||||
|
ImageID: 321,
|
||||||
|
}
|
||||||
|
|
||||||
cfg := config.UniversalConfig{
|
// Выполнение запроса
|
||||||
LegacyConfig: &legacyCfg,
|
res, err := universalClient.CloudAPI().KVMX86().Create(context.Background(), req)
|
||||||
}
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
// Создание клиента
|
fmt.Println(res)
|
||||||
universalClient := decort.NewUniversal(cfg)
|
|
||||||
|
|
||||||
// Создание структуры запроса
|
|
||||||
// CreateRequest - реквест на создание виртуальной машины
|
|
||||||
req := kvmx86.CreateRequest{
|
|
||||||
RGID: 123,
|
|
||||||
Name: "compute",
|
|
||||||
CPU: 4,
|
|
||||||
RAM: 4096,
|
|
||||||
ImageID: 321,
|
|
||||||
}
|
|
||||||
|
|
||||||
// Выполнение запроса
|
|
||||||
res, err := universalClient.CloudAPI().KVMX86().Create(context.Background(), req)
|
|
||||||
if err != nil {
|
|
||||||
log.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
fmt.Println(res)
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -440,7 +440,7 @@ func getTokenExp(token string) (time.Time, error) {
|
|||||||
|
|
||||||
exp, ok := claims["exp"]
|
exp, ok := claims["exp"]
|
||||||
if !ok {
|
if !ok {
|
||||||
return time.Time{}, fmt.Errorf("exp time bot found")
|
return time.Time{}, fmt.Errorf("exp time not found")
|
||||||
}
|
}
|
||||||
|
|
||||||
expTime := time.Unix(int64(exp.(float64)), 0)
|
expTime := time.Unix(int64(exp.(float64)), 0)
|
||||||
|
|||||||
@@ -350,6 +350,10 @@ func isBoolTypeValidator(fe validator.FieldLevel) bool {
|
|||||||
return fe.Field().CanConvert(reflect.TypeOf(true))
|
return fe.Field().CanConvert(reflect.TypeOf(true))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func isStringTypeValidator(fe validator.FieldLevel) bool {
|
||||||
|
return fe.Field().Kind() == reflect.String
|
||||||
|
}
|
||||||
|
|
||||||
func urlValidartor(fl validator.FieldLevel) bool {
|
func urlValidartor(fl validator.FieldLevel) bool {
|
||||||
fieldValues := fl.Field().String()
|
fieldValues := fl.Field().String()
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package validators
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
|
|
||||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v14/internal/multierror"
|
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v14/internal/multierror"
|
||||||
|
|
||||||
"github.com/go-playground/validator/v10"
|
"github.com/go-playground/validator/v10"
|
||||||
|
|||||||
@@ -27,6 +27,8 @@ func errorMessage(fe validator.FieldError) string {
|
|||||||
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":
|
case "isBool":
|
||||||
return fmt.Sprintf("%s %s: must be bool type", prefix, fe.Field())
|
return fmt.Sprintf("%s %s: must be bool type", prefix, fe.Field())
|
||||||
|
case "isString":
|
||||||
|
return fmt.Sprintf("%s %s: must be string type", prefix, fe.Field())
|
||||||
|
|
||||||
case "accessType":
|
case "accessType":
|
||||||
return fmt.Sprintf("%s %s must be one of the following: %s",
|
return fmt.Sprintf("%s %s must be one of the following: %s",
|
||||||
|
|||||||
@@ -231,6 +231,11 @@ func registerAllValidators(validate *validator.Validate) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
err = validate.RegisterValidation("isString", isStringTypeValidator)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
err = validate.RegisterValidation("url", urlValidartor)
|
err = validate.RegisterValidation("url", urlValidartor)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|||||||
@@ -8,8 +8,8 @@ type Audit struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Builder for audit endpoint
|
// Builder for audit endpoint
|
||||||
func New(client interfaces.Caller) *Audit{
|
func New(client interfaces.Caller) *Audit {
|
||||||
return &Audit{
|
return &Audit{
|
||||||
client: client,
|
client: client,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -4,6 +4,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v14/internal/validators"
|
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v14/internal/validators"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v14/internal/validators"
|
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v14/internal/validators"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -3,8 +3,9 @@ package compute
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"net/http"
|
"net/http"
|
||||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v14/internal/validators"
|
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v14/internal/validators"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ChangeLinkStateRequest struct to change link state
|
// ChangeLinkStateRequest struct to change link state
|
||||||
|
|||||||
@@ -63,6 +63,14 @@ type ListRequest struct {
|
|||||||
// Required: false
|
// Required: false
|
||||||
ZoneID uint64 `url:"zone_id,omitempty" json:"zone_id,omitempty"`
|
ZoneID uint64 `url:"zone_id,omitempty" json:"zone_id,omitempty"`
|
||||||
|
|
||||||
|
// Find by VM folder ID
|
||||||
|
// Required: false
|
||||||
|
FolderID uint64 `url:"folder_id,omitempty" json:"folder_id,omitempty"`
|
||||||
|
|
||||||
|
// Include computes from descendant folders.
|
||||||
|
// Required: false
|
||||||
|
IncludeDescendants interface{} `url:"include_descendants,omitempty" json:"include_descendants,omitempty" validate:"omitempty,isBool"`
|
||||||
|
|
||||||
// Page number
|
// Page number
|
||||||
// Required: false
|
// Required: false
|
||||||
Page uint64 `url:"page,omitempty" json:"page,omitempty"`
|
Page uint64 `url:"page,omitempty" json:"page,omitempty"`
|
||||||
|
|||||||
@@ -551,6 +551,9 @@ type RecordCompute struct {
|
|||||||
// Zone ID
|
// Zone ID
|
||||||
// Required: false
|
// Required: false
|
||||||
ZoneID uint64 `json:"zoneId"`
|
ZoneID uint64 `json:"zoneId"`
|
||||||
|
|
||||||
|
// Folder ID
|
||||||
|
FolderID uint64 `json:"folder_id"`
|
||||||
}
|
}
|
||||||
type LoaderMetaIso struct {
|
type LoaderMetaIso struct {
|
||||||
// Name
|
// Name
|
||||||
@@ -1249,6 +1252,9 @@ type ItemCompute struct {
|
|||||||
|
|
||||||
// Zone ID
|
// Zone ID
|
||||||
ZoneID uint64 `json:"zoneId"`
|
ZoneID uint64 `json:"zoneId"`
|
||||||
|
|
||||||
|
// Folder ID
|
||||||
|
FolderID uint64 `json:"folder_id"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// ListInfoDisks
|
// ListInfoDisks
|
||||||
|
|||||||
@@ -74,6 +74,7 @@ type NetAttachRequest struct {
|
|||||||
SecGroups []uint64 `url:"security_groups,omitempty" json:"security_groups,omitempty"`
|
SecGroups []uint64 `url:"security_groups,omitempty" json:"security_groups,omitempty"`
|
||||||
|
|
||||||
// Flag indicating whether security groups are enabled for this interface
|
// Flag indicating whether security groups are enabled for this interface
|
||||||
|
// Not applicable to netType VFNIC, TRUNK, or SDN
|
||||||
// Required: false
|
// Required: false
|
||||||
EnableSecGroups bool `url:"enable_secgroups,omitempty" json:"enable_secgroups,omitempty"`
|
EnableSecGroups bool `url:"enable_secgroups,omitempty" json:"enable_secgroups,omitempty"`
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ type RedeployRequest struct {
|
|||||||
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
|
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
|
||||||
|
|
||||||
// Storage policy id of compute. The rules of the specified storage policy will be used.
|
// Storage policy id of compute. The rules of the specified storage policy will be used.
|
||||||
// Required: true
|
// Required: false
|
||||||
StoragePolicyID uint64 `url:"storage_policy_id,omitempty" json:"storage_policy_id,omitempty"`
|
StoragePolicyID uint64 `url:"storage_policy_id,omitempty" json:"storage_policy_id,omitempty"`
|
||||||
|
|
||||||
// ID of the new OS image, if image change is required
|
// ID of the new OS image, if image change is required
|
||||||
|
|||||||
@@ -69,6 +69,7 @@ type Interface struct {
|
|||||||
SecGroups []uint64 `url:"security_groups,omitempty" json:"security_groups,omitempty"`
|
SecGroups []uint64 `url:"security_groups,omitempty" json:"security_groups,omitempty"`
|
||||||
|
|
||||||
// Flag indicating whether security groups are enabled for this interface
|
// Flag indicating whether security groups are enabled for this interface
|
||||||
|
// Not applicable to netType VFNIC, TRUNK, or SDN
|
||||||
// Required: false
|
// Required: false
|
||||||
EnableSecGroups bool `url:"enable_secgroups,omitempty" json:"enable_secgroups,omitempty"`
|
EnableSecGroups bool `url:"enable_secgroups,omitempty" json:"enable_secgroups,omitempty"`
|
||||||
|
|
||||||
|
|||||||
@@ -16,22 +16,22 @@ type HighlyAvailableRequest struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// HighlyAvailable makes load balancer highly available
|
// HighlyAvailable makes load balancer highly available
|
||||||
func (l LB) HighlyAvailable(ctx context.Context, req HighlyAvailableRequest) (uint64, error) {
|
func (l LB) HighlyAvailable(ctx context.Context, req HighlyAvailableRequest) (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/lb/makeHighlyAvailable"
|
url := "/cloudapi/lb/makeHighlyAvailable"
|
||||||
|
|
||||||
res, err := l.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
res, err := l.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
|
||||||
|
|||||||
@@ -37,6 +37,12 @@ type ItemLocation struct {
|
|||||||
|
|
||||||
// Is Zero Access enabled
|
// Is Zero Access enabled
|
||||||
ZeroAccessEnabled bool `json:"zeroaccess_enabled"`
|
ZeroAccessEnabled bool `json:"zeroaccess_enabled"`
|
||||||
|
|
||||||
|
// Is BRO enabled
|
||||||
|
BROEnabled bool `json:"bro_enabled"`
|
||||||
|
|
||||||
|
// Are VM Folders enabled
|
||||||
|
VMFoldersEnabled bool `json:"vm_folders_enabled"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// List of locations
|
// List of locations
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package pcidevice
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v14/internal/serialization"
|
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v14/internal/serialization"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
package cloudapi
|
||||||
|
|
||||||
|
import "repository.basistech.ru/BASIS/dynamix-golang-sdk/v14/pkg/cloudapi/vgpu"
|
||||||
|
|
||||||
|
// Accessing the VGPU method group
|
||||||
|
func (ca *CloudAPI) VGPU() *vgpu.VGPU {
|
||||||
|
return vgpu.New(ca.client)
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
package vgpu
|
||||||
|
|
||||||
|
// IDs gets array of VGPU IDs from ListVGPU struct
|
||||||
|
func (l ListVGPU) IDs() []uint64 {
|
||||||
|
res := make([]uint64, 0, len(l.Data))
|
||||||
|
for _, v := range l.Data {
|
||||||
|
res = append(res, v.ID)
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
||||||
@@ -0,0 +1,88 @@
|
|||||||
|
package vgpu
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"encoding/json"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v14/internal/validators"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ListRequest struct to get list of VGPU
|
||||||
|
type ListRequest struct {
|
||||||
|
// Find by id
|
||||||
|
// Required: false
|
||||||
|
ByID uint64 `url:"by_id,omitempty" json:"by_id,omitempty"`
|
||||||
|
|
||||||
|
// Find by vgpu status
|
||||||
|
// Required: false
|
||||||
|
Status string `url:"status,omitempty" json:"status,omitempty"`
|
||||||
|
|
||||||
|
// Find by vgpu type
|
||||||
|
// Required: false
|
||||||
|
Type string `url:"type,omitempty" json:"type,omitempty"`
|
||||||
|
|
||||||
|
// Find by vgpu mode
|
||||||
|
// Required: false
|
||||||
|
Mode string `url:"mode,omitempty" json:"mode,omitempty"`
|
||||||
|
|
||||||
|
// Find by id resgroup
|
||||||
|
// Required: false
|
||||||
|
RGID uint64 `url:"rgId,omitempty" json:"rgId,omitempty"`
|
||||||
|
|
||||||
|
// Find by account id
|
||||||
|
// Required: false
|
||||||
|
AccountID uint64 `url:"accountId,omitempty" json:"accountId,omitempty"`
|
||||||
|
|
||||||
|
// Find by compute id
|
||||||
|
// Required: false
|
||||||
|
ComputeID uint64 `url:"computeId,omitempty" json:"computeId,omitempty"`
|
||||||
|
|
||||||
|
// Find by pgpu id
|
||||||
|
// Required: false
|
||||||
|
PGPUID uint64 `url:"pgpuId,omitempty" json:"pgpuId,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 all VGPU as a ListVGPU struct
|
||||||
|
func (v VGPU) List(ctx context.Context, req ListRequest) (*ListVGPU, error) {
|
||||||
|
|
||||||
|
res, err := v.ListRaw(ctx, req)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
list := ListVGPU{}
|
||||||
|
|
||||||
|
err = json.Unmarshal(res, &list)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return &list, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListRaw gets list of all VGPU as an array of bytes
|
||||||
|
func (v VGPU) ListRaw(ctx context.Context, req ListRequest) ([]byte, error) {
|
||||||
|
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudapi/vgpu/list"
|
||||||
|
|
||||||
|
res, err := v.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
@@ -0,0 +1,69 @@
|
|||||||
|
package vgpu
|
||||||
|
|
||||||
|
type ItemVGPU struct {
|
||||||
|
// Account ID
|
||||||
|
AccountID uint64 `json:"accountId"`
|
||||||
|
|
||||||
|
// Created time
|
||||||
|
CreatedTime uint64 `json:"createdTime"`
|
||||||
|
|
||||||
|
// Deleted time
|
||||||
|
DeletedTime uint64 `json:"deletedTime"`
|
||||||
|
|
||||||
|
//Grid ID
|
||||||
|
GID uint64 `json:"gid"`
|
||||||
|
|
||||||
|
// GUID
|
||||||
|
GUID uint64 `json:"guid"`
|
||||||
|
|
||||||
|
// VGPU ID
|
||||||
|
ID uint64 `json:"id"`
|
||||||
|
|
||||||
|
// Last claimed by
|
||||||
|
LastClaimedBy uint64 `json:"lastClaimedBy"`
|
||||||
|
|
||||||
|
// Last update time
|
||||||
|
LastUpdateTime uint64 `json:"lastUpdateTime"`
|
||||||
|
|
||||||
|
// Mode
|
||||||
|
Mode string `json:"mode"`
|
||||||
|
|
||||||
|
// Bus number
|
||||||
|
BusNumber int `json:"bus_number"`
|
||||||
|
|
||||||
|
// PCI Slot
|
||||||
|
PCISlot int `json:"pciSlot"`
|
||||||
|
|
||||||
|
// PGPUID
|
||||||
|
PGPUID uint64 `json:"pgpuid"`
|
||||||
|
|
||||||
|
// Profile ID
|
||||||
|
ProfileID uint64 `json:"profileId"`
|
||||||
|
|
||||||
|
// RAM
|
||||||
|
RAM uint64 `json:"ram"`
|
||||||
|
|
||||||
|
// Reference ID
|
||||||
|
ReferenceID string `json:"referenceId"`
|
||||||
|
|
||||||
|
// RGID
|
||||||
|
RGID uint64 `json:"rgId"`
|
||||||
|
|
||||||
|
// Status
|
||||||
|
Status string `json:"status"`
|
||||||
|
|
||||||
|
// Type
|
||||||
|
Type string `json:"type"`
|
||||||
|
|
||||||
|
// VMID
|
||||||
|
VMID uint64 `json:"vmid"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// List of VGPU
|
||||||
|
type ListVGPU struct {
|
||||||
|
// Data
|
||||||
|
Data []ItemVGPU `json:"data"`
|
||||||
|
|
||||||
|
// Entry count
|
||||||
|
EntryCount uint64 `json:"entryCount"`
|
||||||
|
}
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
package vgpu
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v14/internal/serialization"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Serialize returns JSON-serialized []byte. Used as a wrapper over json.Marshal and json.MarshalIndent functions.
|
||||||
|
//
|
||||||
|
// In order to serialize with indent make sure to follow these guidelines:
|
||||||
|
// - First argument -> prefix
|
||||||
|
// - Second argument -> indent
|
||||||
|
func (l ListVGPU) Serialize(params ...string) (serialization.Serialized, error) {
|
||||||
|
if len(l.Data) == 0 {
|
||||||
|
return []byte{}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(params) > 1 {
|
||||||
|
prefix := params[0]
|
||||||
|
indent := params[1]
|
||||||
|
|
||||||
|
return json.MarshalIndent(l, prefix, indent)
|
||||||
|
}
|
||||||
|
|
||||||
|
return json.Marshal(l)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Serialize returns JSON-serialized []byte. Used as a wrapper over json.Marshal and json.MarshalIndent functions.
|
||||||
|
//
|
||||||
|
// In order to serialize with indent make sure to follow these guidelines:
|
||||||
|
// - First argument -> prefix
|
||||||
|
// - Second argument -> indent
|
||||||
|
func (i ItemVGPU) Serialize(params ...string) (serialization.Serialized, error) {
|
||||||
|
if len(params) > 1 {
|
||||||
|
prefix := params[0]
|
||||||
|
indent := params[1]
|
||||||
|
|
||||||
|
return json.MarshalIndent(i, prefix, indent)
|
||||||
|
}
|
||||||
|
|
||||||
|
return json.Marshal(i)
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
package vgpu
|
||||||
|
|
||||||
|
import "repository.basistech.ru/BASIS/dynamix-golang-sdk/v14/interfaces"
|
||||||
|
|
||||||
|
// Structure for creating request to VGPU
|
||||||
|
type VGPU struct {
|
||||||
|
client interfaces.Caller
|
||||||
|
}
|
||||||
|
|
||||||
|
// Builder for VGPU endpoints
|
||||||
|
func New(client interfaces.Caller) *VGPU {
|
||||||
|
return &VGPU{
|
||||||
|
client: client,
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -57,6 +57,11 @@ type CreateInAccountRequest struct {
|
|||||||
// Zone ID
|
// Zone ID
|
||||||
// Required: false
|
// Required: false
|
||||||
ZoneID uint64 `url:"zoneId,omitempty" json:"zoneId,omitempty"`
|
ZoneID uint64 `url:"zoneId,omitempty" json:"zoneId,omitempty"`
|
||||||
|
|
||||||
|
// Enable security groups for VINS
|
||||||
|
// Required: false
|
||||||
|
// Default: false
|
||||||
|
EnableSecGroups interface{} `url:"enable_secgroups,omitempty" json:"enable_secgroups,omitempty" validate:"omitempty,isBool"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type wrapperCreateRequestInAcc struct {
|
type wrapperCreateRequestInAcc struct {
|
||||||
|
|||||||
@@ -51,6 +51,11 @@ type CreateInRGRequest struct {
|
|||||||
// Zone ID
|
// Zone ID
|
||||||
// Required: false
|
// Required: false
|
||||||
ZoneID uint64 `url:"zoneId,omitempty" json:"zoneId,omitempty"`
|
ZoneID uint64 `url:"zoneId,omitempty" json:"zoneId,omitempty"`
|
||||||
|
|
||||||
|
// Enable security groups for VINS
|
||||||
|
// Required: false
|
||||||
|
// Default: false
|
||||||
|
EnableSecGroups interface{} `url:"enable_secgroups,omitempty" json:"enable_secgroups,omitempty" validate:"omitempty,isBool"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type wrapperCreateRequestInRG struct {
|
type wrapperCreateRequestInRG struct {
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
package cloudapi
|
||||||
|
|
||||||
|
import (
|
||||||
|
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v14/pkg/cloudapi/vmfolder"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Accessing the VMFolder method group
|
||||||
|
func (ca *CloudAPI) VMFolder() *vmfolder.VMFolder {
|
||||||
|
return vmfolder.New(ca.client)
|
||||||
|
}
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
package vmfolder
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"net/http"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v14/internal/constants"
|
||||||
|
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v14/internal/validators"
|
||||||
|
)
|
||||||
|
|
||||||
|
// AddACLAccessRequest adds ACL access to a vm folder
|
||||||
|
type AddACLAccessRequest struct {
|
||||||
|
// ID of a folder
|
||||||
|
// Required: true
|
||||||
|
FolderID uint64 `url:"folder_id" json:"folder_id" validate:"required"`
|
||||||
|
|
||||||
|
// User or group name to grant access
|
||||||
|
// Required: true
|
||||||
|
User string `url:"user" json:"user" validate:"required"`
|
||||||
|
|
||||||
|
// ID of a folder
|
||||||
|
// Required: true
|
||||||
|
Right string `url:"right" json:"right" validate:"required"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddACLAccess adds ACL access to a vm folder
|
||||||
|
func (v VMFolder) AddACLAccess(ctx context.Context, req AddACLAccessRequest) (bool, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudapi/vmfolder/add_acl_access"
|
||||||
|
|
||||||
|
res, err := v.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err := strconv.ParseBool(string(res))
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
package vmfolder
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"net/http"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v14/internal/constants"
|
||||||
|
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v14/internal/validators"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ComputesMoveRequest struct to move computes to a vm folder
|
||||||
|
type ComputesMoveRequest struct {
|
||||||
|
// IDs of computes to move
|
||||||
|
// Required: true
|
||||||
|
ComputeIDs []uint64 `url:"compute_ids" json:"compute_ids" validate:"required"`
|
||||||
|
|
||||||
|
// Target vm folder ID
|
||||||
|
// Required: true
|
||||||
|
FolderID uint64 `url:"folder_id" json:"folder_id" validate:"required"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ComputesMove moves computes to a vm folder
|
||||||
|
func (v VMFolder) ComputesMove(ctx context.Context, req ComputesMoveRequest) (bool, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudapi/vmfolder/computes_move"
|
||||||
|
|
||||||
|
res, err := v.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err := strconv.ParseBool(string(res))
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
package vmfolder
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"net/http"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v14/internal/constants"
|
||||||
|
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v14/internal/validators"
|
||||||
|
)
|
||||||
|
|
||||||
|
// CreateRequest struct to create a vm folder
|
||||||
|
type CreateRequest struct {
|
||||||
|
// Resource Group ID
|
||||||
|
// Required: true
|
||||||
|
RGID uint64 `url:"rg_id" json:"rg_id" validate:"required"`
|
||||||
|
|
||||||
|
// Name
|
||||||
|
// Required: true
|
||||||
|
Name string `url:"name" json:"name" validate:"required"`
|
||||||
|
|
||||||
|
// Parent ID
|
||||||
|
// Required: false
|
||||||
|
ParentID uint64 `url:"parent_id,omitempty" json:"parent_id,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create creates a vm folder
|
||||||
|
func (v VMFolder) Create(ctx context.Context, req CreateRequest) (uint64, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
return 0, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudapi/vmfolder/create"
|
||||||
|
|
||||||
|
res, err := v.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err := strconv.ParseUint(string(res), 10, 64)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
package vmfolder
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"net/http"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v14/internal/constants"
|
||||||
|
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v14/internal/validators"
|
||||||
|
)
|
||||||
|
|
||||||
|
// DeleteACLAccessRequest deletes ACL access from a vm folder
|
||||||
|
type DelACLAccessRequest struct {
|
||||||
|
// ID of a folder
|
||||||
|
// Required: true
|
||||||
|
FolderID uint64 `url:"folder_id" json:"folder_id" validate:"required"`
|
||||||
|
|
||||||
|
// User or group name to revoke access from
|
||||||
|
// Required: true
|
||||||
|
User string `url:"user" json:"user" validate:"required"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeleteACLAccess deletes ACL access from a vm foler
|
||||||
|
func (v VMFolder) DeleteACLAccess(ctx context.Context, req DelACLAccessRequest) (bool, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudapi/vmfolder/del_acl_access"
|
||||||
|
|
||||||
|
res, err := v.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err := strconv.ParseBool(string(res))
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
package vmfolder
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"net/http"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v14/internal/constants"
|
||||||
|
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v14/internal/validators"
|
||||||
|
)
|
||||||
|
|
||||||
|
// DeleteRequest struct to delete a VM folder
|
||||||
|
type DeleteRequest struct {
|
||||||
|
// ID of a folder to delete
|
||||||
|
// Required: true
|
||||||
|
FolderID uint64 `url:"folder_id" json:"folder_id" validate:"required"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delete deletes a vm folder
|
||||||
|
func (v VMFolder) Delete(ctx context.Context, req DeleteRequest) (bool, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudapi/vmfolder/delete"
|
||||||
|
|
||||||
|
res, err := v.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err := strconv.ParseBool(string(res))
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
package vmfolder
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"encoding/json"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v14/internal/constants"
|
||||||
|
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v14/internal/validators"
|
||||||
|
)
|
||||||
|
|
||||||
|
// GetRequest struct to get detailed information about a vm folder
|
||||||
|
type GetRequest struct {
|
||||||
|
// ID of a folder
|
||||||
|
// Required: true
|
||||||
|
FolderID uint64 `url:"folder_id" json:"folder_id" validate:"required"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get gets current configuration of the vm folder as a RecordVMFolder struct
|
||||||
|
func (v VMFolder) Get(ctx context.Context, req GetRequest) (*RecordVMFolder, error) {
|
||||||
|
res, err := v.GetRaw(ctx, req)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
info := RecordVMFolder{}
|
||||||
|
|
||||||
|
err = json.Unmarshal(res, &info)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return &info, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetRaw gets current configuration of the vm folder as an array of bytes
|
||||||
|
func (v VMFolder) GetRaw(ctx context.Context, req GetRequest) ([]byte, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudapi/vmfolder/get"
|
||||||
|
|
||||||
|
res, err := v.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
@@ -0,0 +1,56 @@
|
|||||||
|
package vmfolder
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"encoding/json"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v14/internal/constants"
|
||||||
|
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v14/internal/validators"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ListRequest struct to get list of vm folders
|
||||||
|
type ListRequest struct {
|
||||||
|
// Resource group ID
|
||||||
|
// Required: true
|
||||||
|
RGID uint64 `url:"rg_id" json:"rg_id" validate:"required"`
|
||||||
|
|
||||||
|
// Page number
|
||||||
|
// Required: false
|
||||||
|
Page uint64 `url:"page,omitempty" json:"page,omitempty"`
|
||||||
|
|
||||||
|
// Page size
|
||||||
|
// Required: false
|
||||||
|
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// List gets list of all vm folders in a resource group as a ListVMFolder struct
|
||||||
|
func (v VMFolder) List(ctx context.Context, req ListRequest) (*ListVMFolder, error) {
|
||||||
|
|
||||||
|
res, err := v.ListRaw(ctx, req)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
list := ListVMFolder{}
|
||||||
|
|
||||||
|
err = json.Unmarshal(res, &list)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return &list, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListRaw gets list of all vm folders in a resource group as an array of bytes
|
||||||
|
func (v VMFolder) ListRaw(ctx context.Context, req ListRequest) ([]byte, error) {
|
||||||
|
|
||||||
|
if err := validators.ValidateRequest(req); err != nil {
|
||||||
|
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudapi/vmfolder/list"
|
||||||
|
|
||||||
|
res, err := v.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
@@ -0,0 +1,79 @@
|
|||||||
|
package vmfolder
|
||||||
|
|
||||||
|
// Detailed information about a folder
|
||||||
|
type RecordVMFolder struct {
|
||||||
|
// ID
|
||||||
|
ID uint64 `json:"id"`
|
||||||
|
|
||||||
|
// RG ID
|
||||||
|
RGID uint64 `json:"rg_id"`
|
||||||
|
|
||||||
|
// GID
|
||||||
|
GID uint64 `json:"gid"`
|
||||||
|
|
||||||
|
// Name of a folder
|
||||||
|
Name string `json:"name"`
|
||||||
|
|
||||||
|
// ACL
|
||||||
|
ACL []ACL `json:"acl"`
|
||||||
|
|
||||||
|
// Time of creation
|
||||||
|
CreatedTime uint64 `json:"created_time"`
|
||||||
|
|
||||||
|
// Parent ID
|
||||||
|
ParentID uint64 `json:"parent_id"`
|
||||||
|
|
||||||
|
// Status of a folder
|
||||||
|
Status string `json:"status"`
|
||||||
|
|
||||||
|
// Compute IDs
|
||||||
|
ComputeIDs []uint64 `json:"compute_ids"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ACL
|
||||||
|
type ACL struct {
|
||||||
|
// Explicit
|
||||||
|
Explicit bool `json:"explicit"`
|
||||||
|
|
||||||
|
// Right
|
||||||
|
Right string `json:"right"`
|
||||||
|
|
||||||
|
// Status
|
||||||
|
Status string `json:"status"`
|
||||||
|
|
||||||
|
// Type
|
||||||
|
Type string `json:"type"`
|
||||||
|
|
||||||
|
// User group ID
|
||||||
|
UserGroupID string `json:"userGroupId"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// List of vm folders
|
||||||
|
type ListVMFolder struct {
|
||||||
|
// Entry count
|
||||||
|
EntryCount uint64 `json:"entryCount"`
|
||||||
|
|
||||||
|
// Data
|
||||||
|
Data []ItemVMFolder `json:"data"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Detailed information about a folder item
|
||||||
|
type ItemVMFolder struct {
|
||||||
|
// Folder ID
|
||||||
|
ID uint64 `json:"id"`
|
||||||
|
|
||||||
|
// Parent ID
|
||||||
|
ParentID uint64 `json:"parent_id"`
|
||||||
|
|
||||||
|
// Name
|
||||||
|
Name string `json:"name"`
|
||||||
|
|
||||||
|
// ACL
|
||||||
|
ACL []ACL `json:"acl"`
|
||||||
|
|
||||||
|
// Status
|
||||||
|
Status string `json:"status"`
|
||||||
|
|
||||||
|
// VM count
|
||||||
|
VMCount uint64 `json:"vm_count"`
|
||||||
|
}
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
package vmfolder
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"net/http"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v14/internal/constants"
|
||||||
|
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v14/internal/validators"
|
||||||
|
)
|
||||||
|
|
||||||
|
// MoveRequest to move a vm folder to a compute
|
||||||
|
type MoveRequest struct {
|
||||||
|
// VM Folder ID
|
||||||
|
// Required: true
|
||||||
|
FolderID uint64 `url:"folder_id" json:"folder_id"`
|
||||||
|
|
||||||
|
// New parent folder ID
|
||||||
|
// Required: true
|
||||||
|
NewParentID uint64 `url:"new_parent_id" json:"new_parent_id"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Move moves a vm folder to a compute
|
||||||
|
func (v VMFolder) Move(ctx context.Context, req MoveRequest) (bool, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudapi/vmfolder/move"
|
||||||
|
|
||||||
|
res, err := v.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err := strconv.ParseBool(string(res))
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
package vmfolder
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"net/http"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v14/internal/constants"
|
||||||
|
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v14/internal/validators"
|
||||||
|
)
|
||||||
|
|
||||||
|
// RenameRequest struct to rename a VM folder
|
||||||
|
type RenameRequest struct {
|
||||||
|
// ID of a folder to rename
|
||||||
|
// Required: true
|
||||||
|
FolderID uint64 `url:"folder_id" json:"folder_id" validate:"required"`
|
||||||
|
|
||||||
|
// A new name
|
||||||
|
// Required: true
|
||||||
|
Name string `url:"name" json:"name" validate:"required"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Rename renames a vm folder
|
||||||
|
func (v VMFolder) Rename(ctx context.Context, req RenameRequest) (bool, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudapi/vmfolder/rename"
|
||||||
|
|
||||||
|
res, err := v.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err := strconv.ParseBool(string(res))
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
package vmfolder
|
||||||
|
|
||||||
|
import (
|
||||||
|
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v14/interfaces"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Structure for creating request to VMFolder
|
||||||
|
type VMFolder struct {
|
||||||
|
client interfaces.Caller
|
||||||
|
}
|
||||||
|
|
||||||
|
// Builder for VMFolder endpoints
|
||||||
|
func New(client interfaces.Caller) *VMFolder {
|
||||||
|
return &VMFolder{
|
||||||
|
client,
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -81,6 +81,21 @@ type RecordZone struct {
|
|||||||
|
|
||||||
// SSO URL
|
// SSO URL
|
||||||
SSOURL string `json:"sso_url"`
|
SSOURL string `json:"sso_url"`
|
||||||
|
|
||||||
|
// SSO type
|
||||||
|
SSOType string `json:"sso_type"`
|
||||||
|
|
||||||
|
// Ping address
|
||||||
|
PingAddr string `json:"ping_addr"`
|
||||||
|
|
||||||
|
// Broadcast address
|
||||||
|
BroadcastAddr string `json:"broadcast_addr"`
|
||||||
|
|
||||||
|
// Skip ssl verify
|
||||||
|
SSLSkipVerify bool `json:"ssl_skip_verify"`
|
||||||
|
|
||||||
|
// Domain
|
||||||
|
Domain string `json:"domain"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// A zone item from a list
|
// A zone item from a list
|
||||||
@@ -130,9 +145,24 @@ type ItemZone struct {
|
|||||||
// SSO URL
|
// SSO URL
|
||||||
SSOURL string `json:"sso_url"`
|
SSOURL string `json:"sso_url"`
|
||||||
|
|
||||||
|
// SSO type
|
||||||
|
SSOType string `json:"sso_type"`
|
||||||
|
|
||||||
// Status
|
// Status
|
||||||
Status string `json:"status"`
|
Status string `json:"status"`
|
||||||
|
|
||||||
// Updated timestamp
|
// Updated timestamp
|
||||||
UpdatedTime uint64 `json:"updatedTime"`
|
UpdatedTime uint64 `json:"updatedTime"`
|
||||||
|
|
||||||
|
// Ping address
|
||||||
|
PingAddr string `json:"ping_addr"`
|
||||||
|
|
||||||
|
// Broadcast address
|
||||||
|
BroadcastAddr string `json:"broadcast_addr"`
|
||||||
|
|
||||||
|
// Skip ssl verify
|
||||||
|
SSLSkipVerify bool `json:"ssl_skip_verify"`
|
||||||
|
|
||||||
|
// Domain
|
||||||
|
Domain string `json:"domain"`
|
||||||
}
|
}
|
||||||
@@ -3,8 +3,9 @@ package account
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"net/http"
|
"net/http"
|
||||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v14/internal/validators"
|
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v14/internal/validators"
|
||||||
)
|
)
|
||||||
|
|
||||||
// SetCPUAllocationParameterRequest struct for setting CPU allocation parameter
|
// SetCPUAllocationParameterRequest struct for setting CPU allocation parameter
|
||||||
|
|||||||
@@ -2,8 +2,8 @@ package apiaccess
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"encoding/json"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
|
||||||
|
|
||||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v14/internal/validators"
|
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v14/internal/validators"
|
||||||
)
|
)
|
||||||
@@ -20,23 +20,25 @@ type DescUpdateRequest struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// DescUpdate sets a new text description of the apiaccess group.
|
// DescUpdate sets a new text description of the apiaccess group.
|
||||||
func (a APIAccess) DescUpdate(ctx context.Context, req DescUpdateRequest) (bool, error) {
|
func (a APIAccess) DescUpdate(ctx context.Context, req DescUpdateRequest) (*ItemAPIAccess, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
url := "/cloudbroker/apiaccess/descUpdate"
|
url := "/cloudbroker/apiaccess/descUpdate"
|
||||||
|
|
||||||
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
result, err := strconv.ParseBool(string(res))
|
info := ItemAPIAccess{}
|
||||||
|
|
||||||
|
err = json.Unmarshal(res, &info)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return result, nil
|
return &info, nil
|
||||||
}
|
}
|
||||||
+144
-101
@@ -1,5 +1,7 @@
|
|||||||
package apiaccess
|
package apiaccess
|
||||||
|
|
||||||
|
import "encoding/json"
|
||||||
|
|
||||||
type ItemAPIAccess struct {
|
type ItemAPIAccess struct {
|
||||||
// APIs
|
// APIs
|
||||||
APIs APIsEndpoints `json:"apis"`
|
APIs APIsEndpoints `json:"apis"`
|
||||||
@@ -88,119 +90,160 @@ type APIsEndpoints struct {
|
|||||||
// CloudBroker endpoints
|
// CloudBroker endpoints
|
||||||
CloudBroker CloudBrokerEndpoints `json:"cloudbroker,omitempty"`
|
CloudBroker CloudBrokerEndpoints `json:"cloudbroker,omitempty"`
|
||||||
|
|
||||||
// LibCloud endpoints
|
// SDN endpoints
|
||||||
LibCloud LibCloudEndpoints `json:"libcloud,omitempty"`
|
SDN SDNEndpoints `json:"sdn,omitempty"`
|
||||||
|
|
||||||
// System endpoints
|
// System endpoints
|
||||||
System SystemEndpoints `json:"system,omitempty"`
|
System SystemEndpoints `json:"system,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MarshalJSON omits empty namespaces, so that "{}" is not sent in requests.
|
||||||
|
func (a APIsEndpoints) MarshalJSON() ([]byte, error) {
|
||||||
|
namespaces := []struct {
|
||||||
|
key string
|
||||||
|
value interface{}
|
||||||
|
}{
|
||||||
|
{"cloudapi", a.CloudAPI},
|
||||||
|
{"cloudbroker", a.CloudBroker},
|
||||||
|
{"sdn", a.SDN},
|
||||||
|
{"system", a.System},
|
||||||
|
}
|
||||||
|
|
||||||
|
result := make(map[string]json.RawMessage, len(namespaces))
|
||||||
|
|
||||||
|
for _, ns := range namespaces {
|
||||||
|
data, err := json.Marshal(ns.value)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if string(data) == "{}" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
result[ns.key] = data
|
||||||
|
}
|
||||||
|
|
||||||
|
return json.Marshal(result)
|
||||||
|
}
|
||||||
|
|
||||||
type CloudAPIEndpoints struct {
|
type CloudAPIEndpoints struct {
|
||||||
Account []string `json:"account,omitempty"`
|
Account []string `json:"account,omitempty"`
|
||||||
BService []string `json:"bservice,omitempty"`
|
Audit []string `json:"audit,omitempty"`
|
||||||
CloudSpace []string `json:"cloudspace,omitempty"`
|
BService []string `json:"bservice,omitempty"`
|
||||||
Compute []string `json:"compute,omitempty"`
|
Compute []string `json:"compute,omitempty"`
|
||||||
ComputeCI []string `json:"computeci,omitempty"`
|
Disks []string `json:"disks,omitempty"`
|
||||||
Disks []string `json:"disks,omitempty"`
|
DPDKNet []string `json:"dpdknet,omitempty"`
|
||||||
DPDK []string `json:"dpdk,omitempty"`
|
ExtNet []string `json:"extnet,omitempty"`
|
||||||
ExtNet []string `json:"extnet,omitempty"`
|
FLIPGroup []string `json:"flipgroup,omitempty"`
|
||||||
FLIPGroup []string `json:"flipgroup,omitempty"`
|
GPU []string `json:"gpu,omitempty"`
|
||||||
GPU []string `json:"gpu,omitempty"`
|
Image []string `json:"image,omitempty"`
|
||||||
Image []string `json:"image,omitempty"`
|
K8CI []string `json:"k8ci,omitempty"`
|
||||||
K8CI []string `json:"k8ci,omitempty"`
|
K8S []string `json:"k8s,omitempty"`
|
||||||
K8S []string `json:"k8s,omitempty"`
|
KVMX86 []string `json:"kvmx86,omitempty"`
|
||||||
KVMX86 []string `json:"kvmx86,omitempty"`
|
LB []string `json:"lb,omitempty"`
|
||||||
LB []string `json:"lb,omitempty"`
|
Loactions []string `json:"locations,omitempty"`
|
||||||
Loactions []string `json:"locations,omitempty"`
|
PCIDevice []string `json:"pcidevice,omitempty"`
|
||||||
Machine []string `json:"machine,omitempty"`
|
Prometheus []string `json:"prometheus,omitempty"`
|
||||||
Openshift []string `json:"openshift,omitempty"`
|
RG []string `json:"rg,omitempty"`
|
||||||
OpenshiftCI []string `json:"openshiftci,omitempty"`
|
SecurityGroup []string `json:"security_group,omitempty"`
|
||||||
PCIDevice []string `json:"pcidevice,omitempty"`
|
SEP []string `json:"sep,omitempty"`
|
||||||
PortForwarding []string `json:"portforwarding,omitempty"`
|
StoragePolicy []string `json:"storage_policy,omitempty"`
|
||||||
Prometheus []string `json:"prometheus,omitempty"`
|
Tasks []string `json:"tasks,omitempty"`
|
||||||
RG []string `json:"rg,omitempty"`
|
Trunk []string `json:"trunk,omitempty"`
|
||||||
Sizes []string `json:"sizes,omitempty"`
|
User []string `json:"user,omitempty"`
|
||||||
Tasks []string `json:"tasks,omitempty"`
|
VFPool []string `json:"vfpool,omitempty"`
|
||||||
User []string `json:"user,omitempty"`
|
VGPU []string `json:"vgpu,omitempty"`
|
||||||
VGPU []string `json:"vgpu,omitempty"`
|
VINS []string `json:"vins,omitempty"`
|
||||||
VINS []string `json:"vins,omitempty"`
|
Zone []string `json:"zone,omitempty"`
|
||||||
All bool `json:"ALL,omitempty"`
|
All bool `json:"ALL,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type CloudBrokerEndpoints struct {
|
type CloudBrokerEndpoints struct {
|
||||||
Account []string `json:"account,omitempty"`
|
Account []string `json:"account,omitempty"`
|
||||||
APIAccess []string `json:"apiaccess,omitempty"`
|
APIAccess []string `json:"apiaccess,omitempty"`
|
||||||
Audit interface{} `json:"audit,omitempty"`
|
Audit interface{} `json:"audit,omitempty"`
|
||||||
AuditBeat []string `json:"auditbeat,omitempty"`
|
AuditBeat []string `json:"auditbeat,omitempty"`
|
||||||
AuditCollector []string `json:"auditcollector,omitempty"`
|
AuditCollector []string `json:"auditcollector,omitempty"`
|
||||||
BackupCreator []string `json:"backupcreator,omitempty"`
|
Backup []string `json:"backup,omitempty"`
|
||||||
BService []string `json:"bservice,omitempty"`
|
BackupCreator []string `json:"backupcreator,omitempty"`
|
||||||
CloudSpace []string `json:"cloudspace,omitempty"`
|
BService []string `json:"bservice,omitempty"`
|
||||||
Compute []string `json:"compute,omitempty"`
|
Compute []string `json:"compute,omitempty"`
|
||||||
ComputeCI []string `json:"computeci,omitempty"`
|
Disks []string `json:"disks,omitempty"`
|
||||||
Desnode []string `json:"desnode,omitempty"`
|
DPDKNet []string `json:"dpdknet,omitempty"`
|
||||||
Diagnostics []string `json:"diagnostics,omitempty"`
|
Eco []string `json:"eco,omitempty"`
|
||||||
Disks []string `json:"disks,omitempty"`
|
ExtNet []string `json:"extnet,omitempty"`
|
||||||
DPDK []string `json:"dpdk,omitempty"`
|
FlIPgroup []string `json:"flipgroup,omitempty"`
|
||||||
Eco []string `json:"eco,omitempty"`
|
Grid []string `json:"grid,omitempty"`
|
||||||
ExtNet []string `json:"extnet,omitempty"`
|
Group []string `json:"group,omitempty"`
|
||||||
FlIPgroup []string `json:"flipgroup,omitempty"`
|
Health []string `json:"health,omitempty"`
|
||||||
Grid []string `json:"grid,omitempty"`
|
Image []string `json:"image,omitempty"`
|
||||||
Group []string `json:"group,omitempty"`
|
Job interface{} `json:"job,omitempty"`
|
||||||
Health []string `json:"health,omitempty"`
|
K8CI []string `json:"k8ci,omitempty"`
|
||||||
IaaS []string `json:"iaas,omitempty"`
|
K8S []string `json:"k8s,omitempty"`
|
||||||
Image []string `json:"image,omitempty"`
|
KVMX86 []string `json:"kvmx86,omitempty"`
|
||||||
Job interface{} `json:"job,omitempty"`
|
LB []string `json:"lb,omitempty"`
|
||||||
K8CI []string `json:"k8ci,omitempty"`
|
Metering []string `json:"metering,omitempty"`
|
||||||
K8S []string `json:"k8s,omitempty"`
|
Milestones []string `json:"milestones,omitempty"`
|
||||||
KVMX86 []string `json:"kvmx86,omitempty"`
|
Node []string `json:"node,omitempty"`
|
||||||
LB []string `json:"lb,omitempty"`
|
PCIDevice []string `json:"pcidevice,omitempty"`
|
||||||
Machine []string `json:"machine,omitempty"`
|
PGPU []string `json:"pgpu,omitempty"`
|
||||||
Metering []string `json:"metering,omitempty"`
|
Prometheus []string `json:"prometheus,omitempty"`
|
||||||
Milestones []string `json:"milestones,omitempty"`
|
Resmon interface{} `json:"resmon,omitempty"`
|
||||||
Openshift []string `json:"openshift,omitempty"`
|
ResourceOptimizer []string `json:"resource_optimizer,omitempty"`
|
||||||
OpenshiftCI []string `json:"openshiftci,omitempty"`
|
RG []string `json:"rg,omitempty"`
|
||||||
Ovsnode []string `json:"ovsnode,omitempty"`
|
SecurityGroup []string `json:"security_group,omitempty"`
|
||||||
PCIDevice []string `json:"pcidevice,omitempty"`
|
Sep []string `json:"sep,omitempty"`
|
||||||
PGPU []string `json:"pgpu,omitempty"`
|
StoragePolicy []string `json:"storage_policy,omitempty"`
|
||||||
Prometheus []string `json:"prometheus,omitempty"`
|
Tasks []string `json:"tasks,omitempty"`
|
||||||
QOS []string `json:"qos,omitempty"`
|
TLock []string `json:"tlock,omitempty"`
|
||||||
Resmon interface{} `json:"resmon,omitempty"`
|
Trunk []string `json:"trunk,omitempty"`
|
||||||
RG []string `json:"rg,omitempty"`
|
User []string `json:"user,omitempty"`
|
||||||
Sep []string `json:"sep,omitempty"`
|
VFPool []string `json:"vfpool,omitempty"`
|
||||||
Node []string `json:"node,omitempty"`
|
VGPU []string `json:"vgpu,omitempty"`
|
||||||
Tasks []string `json:"tasks,omitempty"`
|
VINS []string `json:"vins,omitempty"`
|
||||||
TLock []string `json:"tlock,omitempty"`
|
VNFDev []string `json:"vnfdev,omitempty"`
|
||||||
User []string `json:"user,omitempty"`
|
ZeroAccess []string `json:"zeroaccess,omitempty"`
|
||||||
VGPU []string `json:"vgpu,omitempty"`
|
Zone []string `json:"zone,omitempty"`
|
||||||
VINS []string `json:"vins,omitempty"`
|
All bool `json:"ALL,omitempty"`
|
||||||
VNFDev []string `json:"vnfdev,omitempty"`
|
|
||||||
ZeroAccess []string `json:"zeroaccess,omitempty"`
|
|
||||||
All bool `json:"ALL,omitempty"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type LibCloudEndpoints struct {
|
type SDNEndpoints struct {
|
||||||
Libvirt []string `json:"libvirt,omitempty"`
|
AccessGroup []string `json:"access_group,omitempty"`
|
||||||
All bool `json:"ALL,omitempty"`
|
AddressPool []string `json:"address_pool,omitempty"`
|
||||||
|
DefaultSecurityPolicy []string `json:"default_security_policy,omitempty"`
|
||||||
|
ExternalNetwork []string `json:"external_network,omitempty"`
|
||||||
|
FloatingIP []string `json:"floating_ip,omitempty"`
|
||||||
|
Hypervisor []string `json:"hypervisor,omitempty"`
|
||||||
|
L2ExternalNetwork []string `json:"l2_external_network,omitempty"`
|
||||||
|
LogicalPort []string `json:"logical_port,omitempty"`
|
||||||
|
NetworkObjectGroup []string `json:"network_object_group,omitempty"`
|
||||||
|
Router []string `json:"router,omitempty"`
|
||||||
|
RouterGatewayPort []string `json:"router/gateway_port,omitempty"`
|
||||||
|
RouterPolicies []string `json:"router/policies,omitempty"`
|
||||||
|
RouterRouterPort []string `json:"router/router_port,omitempty"`
|
||||||
|
RouterStaticRoute []string `json:"router/static_route,omitempty"`
|
||||||
|
SecurityPolicy []string `json:"security_policy,omitempty"`
|
||||||
|
SecurityPolicyRule []string `json:"security_policy/rule,omitempty"`
|
||||||
|
SecurityRule []string `json:"security_rule,omitempty"`
|
||||||
|
Segment []string `json:"segment,omitempty"`
|
||||||
|
Version []string `json:"version,omitempty"`
|
||||||
|
All bool `json:"ALL,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type SystemEndpoints struct {
|
type SystemEndpoints struct {
|
||||||
AgentController []string `json:"agentcontroller,omitempty"`
|
Audits []string `json:"audits,omitempty"`
|
||||||
Alerts []string `json:"alerts,omitempty"`
|
Cache []string `json:"cache,omitempty"`
|
||||||
Audits []string `json:"audits,omitempty"`
|
ContentManager []string `json:"contentmanager,omitempty"`
|
||||||
ContentManager []string `json:"contentmanager,omitempty"`
|
DocGenerator []string `json:"docgenerator,omitempty"`
|
||||||
DocGenerator []string `json:"docgenerator,omitempty"`
|
EmailSender []string `json:"emailsender,omitempty"`
|
||||||
EmailSender []string `json:"emailsender,omitempty"`
|
GridManager []string `json:"gridmanager,omitempty"`
|
||||||
ErrorConditionHandler []string `json:"errorconditionhandler,omitempty"`
|
Health []string `json:"health,omitempty"`
|
||||||
GridManager []string `json:"gridmanager,omitempty"`
|
Info []string `json:"info,omitempty"`
|
||||||
Health []string `json:"health,omitempty"`
|
InfoWellknown []string `json:"info/wellknown,omitempty"`
|
||||||
Info []string `json:"info,omitempty"`
|
InfoMGR []string `json:"infomgr,omitempty"`
|
||||||
InfoMGR []string `json:"infomgr,omitempty"`
|
Oauth []string `json:"oauth,omitempty"`
|
||||||
Job []string `json:"job,omitempty"`
|
Task []string `json:"task,omitempty"`
|
||||||
Log []string `json:"log,omitempty"`
|
UserManager []string `json:"usermanager,omitempty"`
|
||||||
Logo []string `json:"logo,omitempty"`
|
All bool `json:"ALL,omitempty"`
|
||||||
Oauth []string `json:"oauth,omitempty"`
|
|
||||||
Task []string `json:"task,omitempty"`
|
|
||||||
UserManager []string `json:"usermanager,omitempty"`
|
|
||||||
All bool `json:"ALL,omitempty"`
|
|
||||||
}
|
}
|
||||||
@@ -4,7 +4,6 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
|
||||||
|
|
||||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v14/internal/validators"
|
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v14/internal/validators"
|
||||||
)
|
)
|
||||||
@@ -27,10 +26,10 @@ type wrapperUpdateRequest struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Update updates apis of apiaccess group.
|
// Update updates apis of apiaccess group.
|
||||||
func (a APIAccess) Update(ctx context.Context, req UpdateRequest) (bool, error) {
|
func (a APIAccess) Update(ctx context.Context, req UpdateRequest) (*ItemAPIAccess, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
url := "/cloudbroker/apiaccess/update"
|
url := "/cloudbroker/apiaccess/update"
|
||||||
@@ -41,20 +40,22 @@ func (a APIAccess) Update(ctx context.Context, req UpdateRequest) (bool, error)
|
|||||||
|
|
||||||
apiJSON, err := json.Marshal(&req.APIs)
|
apiJSON, err := json.Marshal(&req.APIs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
reqWrapped.APIString = string(apiJSON)
|
reqWrapped.APIString = string(apiJSON)
|
||||||
|
|
||||||
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
result, err := strconv.ParseBool(string(res))
|
info := ItemAPIAccess{}
|
||||||
|
|
||||||
|
err = json.Unmarshal(res, &info)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return result, nil
|
return &info, nil
|
||||||
}
|
}
|
||||||
@@ -8,8 +8,8 @@ type Audit struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Builder for audit endpoint
|
// Builder for audit endpoint
|
||||||
func New(client interfaces.Caller) *Audit{
|
func New(client interfaces.Caller) *Audit {
|
||||||
return &Audit{
|
return &Audit{
|
||||||
client: client,
|
client: client,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3,8 +3,9 @@ package compute
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"net/http"
|
"net/http"
|
||||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v14/internal/validators"
|
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v14/internal/validators"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ChangeLinkStateRequest struct for changing link state
|
// ChangeLinkStateRequest struct for changing link state
|
||||||
|
|||||||
@@ -75,6 +75,14 @@ type ListRequest struct {
|
|||||||
// Required: false
|
// Required: false
|
||||||
ZoneID uint64 `url:"zone_id,omitempty" json:"zone_id,omitempty"`
|
ZoneID uint64 `url:"zone_id,omitempty" json:"zone_id,omitempty"`
|
||||||
|
|
||||||
|
// Find by VM folder ID
|
||||||
|
// Required: false
|
||||||
|
FolderID uint64 `url:"folder_id,omitempty" json:"folder_id,omitempty"`
|
||||||
|
|
||||||
|
// Include computes from descendant folders.
|
||||||
|
// Required: false
|
||||||
|
IncludeDescendants interface{} `url:"include_descendants,omitempty" json:"include_descendants,omitempty" validate:"omitempty,isBool"`
|
||||||
|
|
||||||
// Page number
|
// Page number
|
||||||
// Required: false
|
// Required: false
|
||||||
Page uint64 `url:"page,omitempty" json:"page,omitempty"`
|
Page uint64 `url:"page,omitempty" json:"page,omitempty"`
|
||||||
|
|||||||
@@ -902,6 +902,9 @@ type InfoCompute struct {
|
|||||||
|
|
||||||
// Zone ID
|
// Zone ID
|
||||||
ZoneID uint64 `json:"zoneId"`
|
ZoneID uint64 `json:"zoneId"`
|
||||||
|
|
||||||
|
// Folder ID
|
||||||
|
FolderID uint64 `json:"folder_id"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type QemuQuest struct {
|
type QemuQuest struct {
|
||||||
@@ -1195,6 +1198,9 @@ type RecordCompute struct {
|
|||||||
|
|
||||||
//todo
|
//todo
|
||||||
_ uint64 `json:"nodeId"`
|
_ uint64 `json:"nodeId"`
|
||||||
|
|
||||||
|
// Folder ID
|
||||||
|
FolderID uint64 `json:"folder_id"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type LoaderMetaIso struct {
|
type LoaderMetaIso struct {
|
||||||
|
|||||||
@@ -74,6 +74,7 @@ type NetAttachRequest struct {
|
|||||||
SecGroups []uint64 `url:"security_groups,omitempty" json:"security_groups,omitempty"`
|
SecGroups []uint64 `url:"security_groups,omitempty" json:"security_groups,omitempty"`
|
||||||
|
|
||||||
// Flag indicating whether security groups are enabled for this interface
|
// Flag indicating whether security groups are enabled for this interface
|
||||||
|
// Not applicable to netType VFNIC, TRUNK, or SDN
|
||||||
// Required: false
|
// Required: false
|
||||||
EnableSecGroups bool `url:"enable_secgroups,omitempty" json:"enable_secgroups,omitempty"`
|
EnableSecGroups bool `url:"enable_secgroups,omitempty" json:"enable_secgroups,omitempty"`
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ type RedeployRequest struct {
|
|||||||
OSVersion string `url:"os_version,omitempty" json:"os_version,omitempty"`
|
OSVersion string `url:"os_version,omitempty" json:"os_version,omitempty"`
|
||||||
|
|
||||||
// Storage policy id of compute. The rules of the specified storage policy will be used.
|
// Storage policy id of compute. The rules of the specified storage policy will be used.
|
||||||
// Required: true
|
// Required: false
|
||||||
StoragePolicyID uint64 `url:"storage_policy_id,omitempty" json:"storage_policy_id,omitempty"`
|
StoragePolicyID uint64 `url:"storage_policy_id,omitempty" json:"storage_policy_id,omitempty"`
|
||||||
|
|
||||||
// New size for the boot disk in GB, if boot disk size change is required
|
// New size for the boot disk in GB, if boot disk size change is required
|
||||||
|
|||||||
@@ -3,8 +3,9 @@ package disks
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"net/http"
|
"net/http"
|
||||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v14/internal/validators"
|
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v14/internal/validators"
|
||||||
)
|
)
|
||||||
|
|
||||||
// DepresentRequest struct to depresent disk from node
|
// DepresentRequest struct to depresent disk from node
|
||||||
|
|||||||
@@ -3,8 +3,9 @@ package disks
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"net/http"
|
"net/http"
|
||||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v14/internal/validators"
|
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v14/internal/validators"
|
||||||
)
|
)
|
||||||
|
|
||||||
// PresentRequest struct to present disk to node
|
// PresentRequest struct to present disk to node
|
||||||
|
|||||||
@@ -37,6 +37,11 @@ type CreateRequest struct {
|
|||||||
// List of resource groups IDs to which DPDK network will be available. Empty field means all resource groups in the system.
|
// List of resource groups IDs to which DPDK network will be available. Empty field means all resource groups in the system.
|
||||||
// Required: false
|
// Required: false
|
||||||
RGAccess []uint64 `url:"rgAccess,omitempty" json:"rgAccess,omitempty"`
|
RGAccess []uint64 `url:"rgAccess,omitempty" json:"rgAccess,omitempty"`
|
||||||
|
|
||||||
|
// Enable security groups for DPDK network
|
||||||
|
// Required: false
|
||||||
|
// Default: false
|
||||||
|
EnableSecGroups interface{} `url:"enable_secgroups,omitempty" json:"enable_secgroups,omitempty" validate:"omitempty,isBool"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create creates a DPDK networks
|
// Create creates a DPDK networks
|
||||||
|
|||||||
@@ -104,6 +104,11 @@ type CreateRequest struct {
|
|||||||
// Required: false
|
// Required: false
|
||||||
// Default: false
|
// Default: false
|
||||||
HAMode bool `url:"highlyAvailable,omitempty" json:"highlyAvailable,omitempty"`
|
HAMode bool `url:"highlyAvailable,omitempty" json:"highlyAvailable,omitempty"`
|
||||||
|
|
||||||
|
// Enable security groups for external network
|
||||||
|
// Required: false
|
||||||
|
// Default: false
|
||||||
|
EnableSecGroups interface{} `url:"enable_secgroups,omitempty" json:"enable_secgroups,omitempty" validate:"omitempty,isBool"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type wrapperCreateRequest struct {
|
type wrapperCreateRequest struct {
|
||||||
|
|||||||
@@ -1,46 +0,0 @@
|
|||||||
package grid
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"net/http"
|
|
||||||
"strconv"
|
|
||||||
|
|
||||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v14/internal/validators"
|
|
||||||
)
|
|
||||||
|
|
||||||
// AddRequest struct for location code
|
|
||||||
type AddRequest struct {
|
|
||||||
// Grid (platform) ID
|
|
||||||
// Required: true
|
|
||||||
GID uint64 `url:"gid" json:"gid" validate:"required"`
|
|
||||||
|
|
||||||
// Name of the location
|
|
||||||
// Required: true
|
|
||||||
Name string `url:"name" json:"name" validate:"required"`
|
|
||||||
|
|
||||||
// Location code typicly used in dns names
|
|
||||||
// Required: true
|
|
||||||
LocationCode string `url:"locationcode" json:"locationcode" validate:"required"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add location code (e.g. DNS name of this grid)
|
|
||||||
func (g Grid) Add(ctx context.Context, req AddRequest) (bool, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudbroker/grid/add"
|
|
||||||
|
|
||||||
res, err := g.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
|
|
||||||
}
|
|
||||||
@@ -96,6 +96,12 @@ type RecordGrid struct {
|
|||||||
|
|
||||||
// SDN support
|
// SDN support
|
||||||
SDNSupport bool `json:"sdn_support"`
|
SDNSupport bool `json:"sdn_support"`
|
||||||
|
|
||||||
|
// Is BRO enabled
|
||||||
|
BROEnabled bool `json:"bro_enabled"`
|
||||||
|
|
||||||
|
// Whether VM folders are enabled
|
||||||
|
VMFoldersEnabled bool `json:"vm_folders_enabled"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Information about grid
|
// Information about grid
|
||||||
@@ -129,6 +135,15 @@ type ItemGridList struct {
|
|||||||
|
|
||||||
// SDN support
|
// SDN support
|
||||||
SDNSupport bool `json:"sdn_support"`
|
SDNSupport bool `json:"sdn_support"`
|
||||||
|
|
||||||
|
// Is Zero Access enabled
|
||||||
|
ZeroAccessEnabled bool `json:"zeroaccess_enabled"`
|
||||||
|
|
||||||
|
// Is BRO enabled
|
||||||
|
BROEnabled bool `json:"bro_enabled"`
|
||||||
|
|
||||||
|
// Whether VM folders are enabled
|
||||||
|
VMFoldersEnabled bool `json:"vm_folders_enabled"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// List Grids
|
// List Grids
|
||||||
|
|||||||
@@ -3,8 +3,9 @@ package grid
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"net/http"
|
"net/http"
|
||||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v14/internal/validators"
|
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v14/internal/validators"
|
||||||
)
|
)
|
||||||
|
|
||||||
// SetCPUAllocationParameterRequest for setting CPU allocation parameter
|
// SetCPUAllocationParameterRequest for setting CPU allocation parameter
|
||||||
|
|||||||
@@ -3,8 +3,9 @@ package grid
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"net/http"
|
"net/http"
|
||||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v14/internal/validators"
|
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v14/internal/validators"
|
||||||
)
|
)
|
||||||
|
|
||||||
// SetCPUAllocationRatioForVMRequest for setting CPU allocation ratio for computes
|
// SetCPUAllocationRatioForVMRequest for setting CPU allocation ratio for computes
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ type AccessAddRequest struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Add accountId to sharedWith access list for k8ci.
|
// Add accountId to sharedWith access list for k8ci.
|
||||||
func (k K8CI) AccessAdd (ctx context.Context, req AccessAddRequest) (string, error) {
|
func (k K8CI) AccessAdd(ctx context.Context, req AccessAddRequest) (string, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ type AccessRemoveRequest struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Remove accountId from sharedWith access list for k8ci.
|
// Remove accountId from sharedWith access list for k8ci.
|
||||||
func (k K8CI) AccessRemove (ctx context.Context, req AccessRemoveRequest) (string, error) {
|
func (k K8CI) AccessRemove(ctx context.Context, req AccessRemoveRequest) (string, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ type Interface struct {
|
|||||||
SecGroups []uint64 `url:"security_groups,omitempty" json:"security_groups,omitempty"`
|
SecGroups []uint64 `url:"security_groups,omitempty" json:"security_groups,omitempty"`
|
||||||
|
|
||||||
// Flag indicating whether security groups are enabled for this interface
|
// Flag indicating whether security groups are enabled for this interface
|
||||||
|
// Not applicable to netType VFNIC, TRUNK, or SDN
|
||||||
// Required: false
|
// Required: false
|
||||||
EnableSecGroups bool `url:"enable_secgroups,omitempty" json:"enable_secgroups,omitempty"`
|
EnableSecGroups bool `url:"enable_secgroups,omitempty" json:"enable_secgroups,omitempty"`
|
||||||
|
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ type InterfaceMassCreate struct {
|
|||||||
SecGroups []uint64 `url:"security_groups,omitempty" json:"security_groups,omitempty"`
|
SecGroups []uint64 `url:"security_groups,omitempty" json:"security_groups,omitempty"`
|
||||||
|
|
||||||
// Flag indicating whether security groups are enabled for this interface
|
// Flag indicating whether security groups are enabled for this interface
|
||||||
|
// Not applicable to netType VFNIC, TRUNK, or SDN
|
||||||
// Required: false
|
// Required: false
|
||||||
EnableSecGroups bool `url:"enable_secgroups,omitempty" json:"enable_secgroups,omitempty"`
|
EnableSecGroups bool `url:"enable_secgroups,omitempty" json:"enable_secgroups,omitempty"`
|
||||||
|
|
||||||
|
|||||||
@@ -3,8 +3,9 @@ package pcidevice
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"net/http"
|
"net/http"
|
||||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v14/internal/validators"
|
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v14/internal/validators"
|
||||||
)
|
)
|
||||||
|
|
||||||
// DeleteRequest struct to deleting PCI device
|
// DeleteRequest struct to deleting PCI device
|
||||||
|
|||||||
@@ -3,8 +3,9 @@ package pcidevice
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"net/http"
|
"net/http"
|
||||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v14/internal/validators"
|
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v14/internal/validators"
|
||||||
)
|
)
|
||||||
|
|
||||||
// DisableRequest struct for disabling PCI device
|
// DisableRequest struct for disabling PCI device
|
||||||
|
|||||||
@@ -3,8 +3,9 @@ package pcidevice
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"net/http"
|
"net/http"
|
||||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v14/internal/validators"
|
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v14/internal/validators"
|
||||||
)
|
)
|
||||||
|
|
||||||
// EnableRequest struct for enabling PCI device
|
// EnableRequest struct for enabling PCI device
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package pcidevice
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v14/internal/serialization"
|
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v14/internal/serialization"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +0,0 @@
|
|||||||
package cloudbroker
|
|
||||||
|
|
||||||
import (
|
|
||||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v14/pkg/cloudbroker/resource_optimizer"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Accessing the ResourceOptimizer method group
|
|
||||||
func (cb *CloudBroker) ResourceOptimizer() *resource_optimizer.ResourceOptimizer {
|
|
||||||
return resource_optimizer.New(cb.client)
|
|
||||||
}
|
|
||||||
@@ -1,42 +0,0 @@
|
|||||||
package resource_optimizer
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"net/http"
|
|
||||||
"strconv"
|
|
||||||
|
|
||||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v14/internal/validators"
|
|
||||||
)
|
|
||||||
|
|
||||||
// DRSAddNodesRequest struct to add nodes to DRS
|
|
||||||
type DRSAddNodesRequest struct {
|
|
||||||
// ID of the zone
|
|
||||||
// Required: true
|
|
||||||
ZoneID uint64 `url:"zone_id" json:"zone_id" validate:"required"`
|
|
||||||
|
|
||||||
// IDs of the nodes to add
|
|
||||||
// Required: true
|
|
||||||
NodeIDs []uint64 `url:"node_ids" json:"node_ids" validate:"required"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// DRSAddNodes adds nodes to DRS in the specified zone
|
|
||||||
func (ro ResourceOptimizer) DRSAddNodes(ctx context.Context, req DRSAddNodesRequest) (bool, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudbroker/resource_optimizer/drs_add_nodes"
|
|
||||||
|
|
||||||
res, err := ro.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
|
||||||
if err != nil {
|
|
||||||
return false, err
|
|
||||||
}
|
|
||||||
|
|
||||||
result, err := strconv.ParseBool(string(res))
|
|
||||||
if err != nil {
|
|
||||||
return false, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return result, nil
|
|
||||||
}
|
|
||||||
@@ -1,58 +0,0 @@
|
|||||||
package resource_optimizer
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"net/http"
|
|
||||||
"strconv"
|
|
||||||
|
|
||||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v14/internal/validators"
|
|
||||||
)
|
|
||||||
|
|
||||||
// DRSCreateRequest struct to create DRS
|
|
||||||
type DRSCreateRequest struct {
|
|
||||||
// ID of the zone
|
|
||||||
// Required: true
|
|
||||||
ZoneID uint64 `url:"zone_id" json:"zone_id" validate:"required"`
|
|
||||||
|
|
||||||
// Application ID
|
|
||||||
// Required: true
|
|
||||||
AppID string `url:"app_id" json:"app_id" validate:"required"`
|
|
||||||
|
|
||||||
// Application secret
|
|
||||||
// Required: true
|
|
||||||
AppSecret string `url:"app_secret" json:"app_secret" validate:"required"`
|
|
||||||
|
|
||||||
// Decort URL
|
|
||||||
// Required: true
|
|
||||||
DecortURL string `url:"decort_url" json:"decort_url" validate:"required"`
|
|
||||||
|
|
||||||
// SSO URL
|
|
||||||
// Required: true
|
|
||||||
SSOURL string `url:"sso_url" json:"sso_url" validate:"required"`
|
|
||||||
|
|
||||||
// DRS name
|
|
||||||
// Required: true
|
|
||||||
DRSName string `url:"drs_name" json:"drs_name" validate:"required"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// DRSCreate creates a new DRS in the specified zone
|
|
||||||
func (ro ResourceOptimizer) DRSCreate(ctx context.Context, req DRSCreateRequest) (bool, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudbroker/resource_optimizer/drs_create"
|
|
||||||
|
|
||||||
res, err := ro.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
|
||||||
if err != nil {
|
|
||||||
return false, err
|
|
||||||
}
|
|
||||||
|
|
||||||
result, err := strconv.ParseBool(string(res))
|
|
||||||
if err != nil {
|
|
||||||
return false, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return result, nil
|
|
||||||
}
|
|
||||||
@@ -1,42 +0,0 @@
|
|||||||
package resource_optimizer
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"net/http"
|
|
||||||
"strconv"
|
|
||||||
|
|
||||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v14/internal/validators"
|
|
||||||
)
|
|
||||||
|
|
||||||
// DRSDelNodesRequest struct to delete nodes from DRS
|
|
||||||
type DRSDelNodesRequest struct {
|
|
||||||
// ID of the zone
|
|
||||||
// Required: true
|
|
||||||
ZoneID uint64 `url:"zone_id" json:"zone_id" validate:"required"`
|
|
||||||
|
|
||||||
// IDs of the nodes to delete
|
|
||||||
// Required: true
|
|
||||||
NodeIDs []uint64 `url:"node_ids" json:"node_ids" validate:"required"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// DRSDelNodes removes nodes from DRS in the specified zone
|
|
||||||
func (ro ResourceOptimizer) DRSDelNodes(ctx context.Context, req DRSDelNodesRequest) (bool, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudbroker/resource_optimizer/drs_del_nodes"
|
|
||||||
|
|
||||||
res, err := ro.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
|
||||||
if err != nil {
|
|
||||||
return false, err
|
|
||||||
}
|
|
||||||
|
|
||||||
result, err := strconv.ParseBool(string(res))
|
|
||||||
if err != nil {
|
|
||||||
return false, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return result, nil
|
|
||||||
}
|
|
||||||
@@ -1,38 +0,0 @@
|
|||||||
package resource_optimizer
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"net/http"
|
|
||||||
"strconv"
|
|
||||||
|
|
||||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v14/internal/validators"
|
|
||||||
)
|
|
||||||
|
|
||||||
// DRSRemoveRequest struct to remove DRS
|
|
||||||
type DRSRemoveRequest struct {
|
|
||||||
// ID of the zone
|
|
||||||
// Required: true
|
|
||||||
ZoneID uint64 `url:"zone_id" json:"zone_id" validate:"required"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// DRSRemove removes DRS from the specified zone
|
|
||||||
func (ro ResourceOptimizer) DRSRemove(ctx context.Context, req DRSRemoveRequest) (bool, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudbroker/resource_optimizer/drs_remove"
|
|
||||||
|
|
||||||
res, err := ro.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
|
||||||
if err != nil {
|
|
||||||
return false, err
|
|
||||||
}
|
|
||||||
|
|
||||||
result, err := strconv.ParseBool(string(res))
|
|
||||||
if err != nil {
|
|
||||||
return false, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return result, nil
|
|
||||||
}
|
|
||||||
@@ -1,38 +0,0 @@
|
|||||||
package resource_optimizer
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"net/http"
|
|
||||||
"strconv"
|
|
||||||
|
|
||||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v14/internal/validators"
|
|
||||||
)
|
|
||||||
|
|
||||||
// DRSStartRequest struct to start DRS
|
|
||||||
type DRSStartRequest struct {
|
|
||||||
// ID of the zone
|
|
||||||
// Required: true
|
|
||||||
ZoneID uint64 `url:"zone_id" json:"zone_id" validate:"required"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// DRSStart starts DRS in the specified zone
|
|
||||||
func (ro ResourceOptimizer) DRSStart(ctx context.Context, req DRSStartRequest) (bool, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudbroker/resource_optimizer/drs_start"
|
|
||||||
|
|
||||||
res, err := ro.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
|
||||||
if err != nil {
|
|
||||||
return false, err
|
|
||||||
}
|
|
||||||
|
|
||||||
result, err := strconv.ParseBool(string(res))
|
|
||||||
if err != nil {
|
|
||||||
return false, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return result, nil
|
|
||||||
}
|
|
||||||
@@ -1,38 +0,0 @@
|
|||||||
package resource_optimizer
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"net/http"
|
|
||||||
"strconv"
|
|
||||||
|
|
||||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v14/internal/validators"
|
|
||||||
)
|
|
||||||
|
|
||||||
// DRSStopRequest struct to stop DRS
|
|
||||||
type DRSStopRequest struct {
|
|
||||||
// ID of the zone
|
|
||||||
// Required: true
|
|
||||||
ZoneID uint64 `url:"zone_id" json:"zone_id" validate:"required"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// DRSStop stops DRS in the specified zone
|
|
||||||
func (ro ResourceOptimizer) DRSStop(ctx context.Context, req DRSStopRequest) (bool, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudbroker/resource_optimizer/drs_stop"
|
|
||||||
|
|
||||||
res, err := ro.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
|
||||||
if err != nil {
|
|
||||||
return false, err
|
|
||||||
}
|
|
||||||
|
|
||||||
result, err := strconv.ParseBool(string(res))
|
|
||||||
if err != nil {
|
|
||||||
return false, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return result, nil
|
|
||||||
}
|
|
||||||
@@ -1,58 +0,0 @@
|
|||||||
package resource_optimizer
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"net/http"
|
|
||||||
"strconv"
|
|
||||||
|
|
||||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v14/internal/validators"
|
|
||||||
)
|
|
||||||
|
|
||||||
// DRSUpdateRequest struct to update DRS
|
|
||||||
type DRSUpdateRequest struct {
|
|
||||||
// ID of the zone
|
|
||||||
// Required: true
|
|
||||||
ZoneID uint64 `url:"zone_id" json:"zone_id" validate:"required"`
|
|
||||||
|
|
||||||
// Application ID
|
|
||||||
// Required: false
|
|
||||||
AppID string `url:"app_id,omitempty" json:"app_id,omitempty"`
|
|
||||||
|
|
||||||
// Application secret
|
|
||||||
// Required: false
|
|
||||||
AppSecret string `url:"app_secret,omitempty" json:"app_secret,omitempty"`
|
|
||||||
|
|
||||||
// Decort URL
|
|
||||||
// Required: false
|
|
||||||
DecortURL string `url:"decort_url,omitempty" json:"decort_url,omitempty"`
|
|
||||||
|
|
||||||
// SSO URL
|
|
||||||
// Required: false
|
|
||||||
SSOURL string `url:"sso_url,omitempty" json:"sso_url,omitempty"`
|
|
||||||
|
|
||||||
// DRS name
|
|
||||||
// Required: false
|
|
||||||
DRSName string `url:"drs_name,omitempty" json:"drs_name,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// DRSUpdate updates DRS configuration in the specified zone
|
|
||||||
func (ro ResourceOptimizer) DRSUpdate(ctx context.Context, req DRSUpdateRequest) (bool, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudbroker/resource_optimizer/drs_update"
|
|
||||||
|
|
||||||
res, err := ro.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
|
||||||
if err != nil {
|
|
||||||
return false, err
|
|
||||||
}
|
|
||||||
|
|
||||||
result, err := strconv.ParseBool(string(res))
|
|
||||||
if err != nil {
|
|
||||||
return false, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return result, nil
|
|
||||||
}
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
// API Actor API for managing resource optimizer
|
|
||||||
package resource_optimizer
|
|
||||||
|
|
||||||
import "repository.basistech.ru/BASIS/dynamix-golang-sdk/v14/interfaces"
|
|
||||||
|
|
||||||
// Structure for creating request to resource_optimizer
|
|
||||||
type ResourceOptimizer struct {
|
|
||||||
client interfaces.Caller
|
|
||||||
}
|
|
||||||
|
|
||||||
// Builder for resource_optimizer endpoints
|
|
||||||
func New(client interfaces.Caller) *ResourceOptimizer {
|
|
||||||
return &ResourceOptimizer{
|
|
||||||
client: client,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -3,8 +3,9 @@ package rg
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"net/http"
|
"net/http"
|
||||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v14/internal/validators"
|
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v14/internal/validators"
|
||||||
)
|
)
|
||||||
|
|
||||||
// SetCPUAllocationParameterRequest struct for setting CPU allocation parameter
|
// SetCPUAllocationParameterRequest struct for setting CPU allocation parameter
|
||||||
|
|||||||
@@ -3,8 +3,9 @@ package rg
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"net/http"
|
"net/http"
|
||||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v14/internal/validators"
|
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v14/internal/validators"
|
||||||
)
|
)
|
||||||
|
|
||||||
// SetCPUAllocationRatioRequest struct for setting CPU allocation ratio
|
// SetCPUAllocationRatioRequest struct for setting CPU allocation ratio
|
||||||
|
|||||||
@@ -2,8 +2,8 @@ package sep
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"encoding/json"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
|
||||||
|
|
||||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v14/internal/validators"
|
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v14/internal/validators"
|
||||||
)
|
)
|
||||||
@@ -20,23 +20,24 @@ type AddConsumerNodesRequest struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// AddConsumerNodes adds consumer nodes to SEP parameters
|
// AddConsumerNodes adds consumer nodes to SEP parameters
|
||||||
func (s SEP) AddConsumerNodes(ctx context.Context, req AddConsumerNodesRequest) (uint64, error) {
|
func (s SEP) AddConsumerNodes(ctx context.Context, req AddConsumerNodesRequest) ([]uint64, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
|
list := []uint64{}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, validators.ValidationErrors(validators.GetErrors(err))
|
return list, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
url := "/cloudbroker/sep/addConsumerNodes"
|
url := "/cloudbroker/sep/addConsumerNodes"
|
||||||
|
|
||||||
res, err := s.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
res, err := s.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return list, err
|
||||||
}
|
}
|
||||||
|
|
||||||
result, err := strconv.ParseUint(string(res), 10, 64)
|
err = json.Unmarshal(res, &list)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return result, nil
|
return list, nil
|
||||||
}
|
}
|
||||||
@@ -3,6 +3,8 @@ package sep
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v14/internal/validators"
|
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v14/internal/validators"
|
||||||
)
|
)
|
||||||
@@ -13,32 +15,66 @@ type AddPoolRequest struct {
|
|||||||
// Required: true
|
// Required: true
|
||||||
SEPID uint64 `url:"sep_id" json:"sep_id" validate:"required"`
|
SEPID uint64 `url:"sep_id" json:"sep_id" validate:"required"`
|
||||||
|
|
||||||
// Method Async/Sync
|
|
||||||
// Default: true
|
|
||||||
// Required: false
|
|
||||||
Sync bool `url:"sync" json:"sync"`
|
|
||||||
|
|
||||||
// Pool structure which contains fields such as "name", "usage_limit", "types", "system", "accessAccountIds", "accessResGroupIds". Added fields for other pool types: Des, Ovs - "uris" list of "ip, port".
|
// Pool structure which contains fields such as "name", "usage_limit", "types", "system", "accessAccountIds", "accessResGroupIds". Added fields for other pool types: Des, Ovs - "uris" list of "ip, port".
|
||||||
// Dorado, Tatlin no additional fields required. Hitachi - "id", "snapshotable", "snapshot_pool_id", "minLdevId", "maxLdevId", "clone_technology". Shared - "description", "wwns", "allocate_type", "stripes", "metadata_size", "metadatatalun". Local - "description", "node_consumer", "block_disk".
|
// Dorado, Tatlin no additional fields required. Hitachi - "id", "snapshotable", "snapshot_pool_id", "minLdevId", "maxLdevId", "clone_technology". Shared - "description", "wwns", "allocate_type", "stripes", "metadata_size", "metadatatalun". Local - "description", "node_consumer", "block_disk".
|
||||||
// Required: true
|
// Required: true
|
||||||
Pool string `url:"pool" json:"pool" validate:"required"`
|
Pool string `url:"pool" json:"pool" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// AddPool adds pool to SEP
|
type wrapperAddPoolRequest struct {
|
||||||
func (s SEP) AddPool(ctx context.Context, req AddPoolRequest) (string, error) {
|
AddPoolRequest
|
||||||
|
AsyncMode bool `url:"asyncMode"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddPool adds pool to SEP in sync mode.
|
||||||
|
// It returns result of operation and error.
|
||||||
|
func (s SEP) AddPool(ctx context.Context, req AddPoolRequest) (bool, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
|
}
|
||||||
|
|
||||||
|
reqWrapped := wrapperAddPoolRequest{
|
||||||
|
AddPoolRequest: req,
|
||||||
|
AsyncMode: false,
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudbroker/sep/addPool"
|
||||||
|
|
||||||
|
res, err := s.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err := strconv.ParseBool(string(res))
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddPoolAsync adds pool to SEP in async mode.
|
||||||
|
// It returns guid of task and error.
|
||||||
|
func (s SEP) AddPoolAsync(ctx context.Context, req AddPoolRequest) (string, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
reqWrapped := wrapperAddPoolRequest{
|
||||||
|
AddPoolRequest: req,
|
||||||
|
AsyncMode: true,
|
||||||
|
}
|
||||||
|
|
||||||
url := "/cloudbroker/sep/addPool"
|
url := "/cloudbroker/sep/addPool"
|
||||||
|
|
||||||
res, err := s.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
res, err := s.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
result := string(res)
|
result := strings.ReplaceAll(string(res), "\"", "")
|
||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
@@ -2,8 +2,8 @@ package sep
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"encoding/json"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
|
||||||
|
|
||||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v14/internal/validators"
|
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v14/internal/validators"
|
||||||
)
|
)
|
||||||
@@ -34,23 +34,25 @@ type ConfigFieldEditRequest struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ConfigFieldEdit edits SEP config field value
|
// ConfigFieldEdit edits SEP config field value
|
||||||
func (s SEP) ConfigFieldEdit(ctx context.Context, req ConfigFieldEditRequest) (bool, error) {
|
func (s SEP) ConfigFieldEdit(ctx context.Context, req ConfigFieldEditRequest) (*RecordConfigFieldEdit, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
url := "/cloudbroker/sep/configFieldEdit"
|
url := "/cloudbroker/sep/configFieldEdit"
|
||||||
|
|
||||||
res, err := s.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
res, err := s.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
result, err := strconv.ParseBool(string(res))
|
info := RecordConfigFieldEdit{}
|
||||||
|
|
||||||
|
err = json.Unmarshal(res, &info)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return result, nil
|
return &info, nil
|
||||||
}
|
}
|
||||||
@@ -2,8 +2,8 @@ package sep
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"encoding/json"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
|
||||||
|
|
||||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v14/internal/validators"
|
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v14/internal/validators"
|
||||||
)
|
)
|
||||||
@@ -25,22 +25,24 @@ type DelConsumerNodesRequest struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// DelConsumerNodes excludes consumer nodes from SEP parameters
|
// DelConsumerNodes excludes consumer nodes from SEP parameters
|
||||||
func (s SEP) DelConsumerNodes(ctx context.Context, req DelConsumerNodesRequest) (bool, error) {
|
func (s SEP) DelConsumerNodes(ctx context.Context, req DelConsumerNodesRequest) (interface{}, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
url := "/cloudbroker/sep/delConsumerNodes"
|
url := "/cloudbroker/sep/delConsumerNodes"
|
||||||
|
|
||||||
res, err := s.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
res, err := s.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
result, err := strconv.ParseBool(string(res))
|
var result interface{}
|
||||||
|
|
||||||
|
err = json.Unmarshal(res, &result)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
package sep
|
package sep
|
||||||
|
|
||||||
|
import "encoding/json"
|
||||||
|
|
||||||
// Total resource information
|
// Total resource information
|
||||||
type Total struct {
|
type Total struct {
|
||||||
// Capacity limit
|
// Capacity limit
|
||||||
@@ -185,3 +187,93 @@ type ListAvailableSEP struct {
|
|||||||
// Data
|
// Data
|
||||||
Data []SEPData `json:"data"`
|
Data []SEPData `json:"data"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Disk clean settings
|
||||||
|
type DiskCleanSettings struct {
|
||||||
|
// Block size
|
||||||
|
BlockSize string `json:"blocksize"`
|
||||||
|
|
||||||
|
// Write bytes per second
|
||||||
|
WBPS uint64 `json:"wbps"`
|
||||||
|
|
||||||
|
// Write I/O operations per second
|
||||||
|
WIOPS uint64 `json:"wiops"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Pool configuration
|
||||||
|
type PoolConfig struct {
|
||||||
|
// Disk clean
|
||||||
|
DiskClean *string `json:"disk_clean"`
|
||||||
|
|
||||||
|
// Disk clean settings
|
||||||
|
DiskCleanSettings DiskCleanSettings `json:"disk_clean_settings"`
|
||||||
|
|
||||||
|
// Pool name
|
||||||
|
Name string `json:"name"`
|
||||||
|
|
||||||
|
// Usage limit
|
||||||
|
UsageLimit uint64 `json:"usage_limit"`
|
||||||
|
|
||||||
|
// Additional properties
|
||||||
|
AdditionalProperties map[string]interface{} `json:"-"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *PoolConfig) UnmarshalJSON(data []byte) error {
|
||||||
|
type tmpAlias PoolConfig
|
||||||
|
if err := json.Unmarshal(data, (*tmpAlias)(p)); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
all := make(map[string]interface{})
|
||||||
|
if err := json.Unmarshal(data, &all); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
delete(all, "disk_clean")
|
||||||
|
delete(all, "disk_clean_settings")
|
||||||
|
delete(all, "name")
|
||||||
|
delete(all, "usage_limit")
|
||||||
|
|
||||||
|
if len(all) > 0 {
|
||||||
|
p.AdditionalProperties = all
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sep configuration information
|
||||||
|
type RecordConfigFieldEdit struct {
|
||||||
|
// Format
|
||||||
|
Format string `json:"format"`
|
||||||
|
|
||||||
|
// Pools
|
||||||
|
Pools []PoolConfig `json:"pools"`
|
||||||
|
|
||||||
|
// Protocol
|
||||||
|
Protocol string `json:"protocol"`
|
||||||
|
|
||||||
|
// Additional properties
|
||||||
|
AdditionalProperties map[string]interface{} `json:"-"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *RecordConfigFieldEdit) UnmarshalJSON(data []byte) error {
|
||||||
|
type tmpAlias RecordConfigFieldEdit
|
||||||
|
if err := json.Unmarshal(data, (*tmpAlias)(r)); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
all := make(map[string]interface{})
|
||||||
|
if err := json.Unmarshal(data, &all); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
delete(all, "format")
|
||||||
|
delete(all, "pools")
|
||||||
|
delete(all, "protocol")
|
||||||
|
|
||||||
|
if len(all) > 0 {
|
||||||
|
r.AdditionalProperties = all
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
@@ -38,7 +38,7 @@ type UpdateRequest struct {
|
|||||||
|
|
||||||
type wrapperUpdateRequest struct {
|
type wrapperUpdateRequest struct {
|
||||||
UpdateRequest
|
UpdateRequest
|
||||||
Config []string `url:"config,omitempty"`
|
Config string `url:"config,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update updates vfpool device
|
// Update updates vfpool device
|
||||||
@@ -48,21 +48,15 @@ func (v VFPool) Update(ctx context.Context, req UpdateRequest) (bool, error) {
|
|||||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
var config []string
|
var config string
|
||||||
|
|
||||||
if len(req.Config) != 0 {
|
if len(req.Config) != 0 {
|
||||||
config = make([]string, 0, len(req.Config))
|
b, err := json.Marshal(req.Config)
|
||||||
|
if err != nil {
|
||||||
for c := range req.Config {
|
return false, err
|
||||||
b, err := json.Marshal(req.Config[c])
|
|
||||||
if err != nil {
|
|
||||||
return false, err
|
|
||||||
}
|
|
||||||
|
|
||||||
config = append(config, string(b))
|
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
config = []string{}
|
config = string(b)
|
||||||
}
|
}
|
||||||
|
|
||||||
reqWrapped := wrapperUpdateRequest{
|
reqWrapped := wrapperUpdateRequest{
|
||||||
|
|||||||
@@ -3,8 +3,9 @@ package vgpu
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"net/http"
|
"net/http"
|
||||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v14/internal/validators"
|
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v14/internal/validators"
|
||||||
)
|
)
|
||||||
|
|
||||||
// AllocateRequest struct for allocating VGPU
|
// AllocateRequest struct for allocating VGPU
|
||||||
|
|||||||
@@ -3,8 +3,9 @@ package vgpu
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"net/http"
|
"net/http"
|
||||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v14/internal/validators"
|
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v14/internal/validators"
|
||||||
)
|
)
|
||||||
|
|
||||||
// CreateRequest struct for creating VGPU
|
// CreateRequest struct for creating VGPU
|
||||||
|
|||||||
@@ -3,8 +3,9 @@ package vgpu
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"net/http"
|
"net/http"
|
||||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v14/internal/validators"
|
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v14/internal/validators"
|
||||||
)
|
)
|
||||||
|
|
||||||
// DeallocateRequest struct for deallocating VGPU
|
// DeallocateRequest struct for deallocating VGPU
|
||||||
|
|||||||
@@ -3,8 +3,9 @@ package vgpu
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"net/http"
|
"net/http"
|
||||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v14/internal/validators"
|
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v14/internal/validators"
|
||||||
)
|
)
|
||||||
|
|
||||||
// DestroyRequest struct for destroying VGPU
|
// DestroyRequest struct for destroying VGPU
|
||||||
|
|||||||
@@ -57,6 +57,11 @@ type CreateInAccountRequest struct {
|
|||||||
// Zone ID
|
// Zone ID
|
||||||
// Required: false
|
// Required: false
|
||||||
ZoneID uint64 `url:"zoneId,omitempty" json:"zoneId,omitempty"`
|
ZoneID uint64 `url:"zoneId,omitempty" json:"zoneId,omitempty"`
|
||||||
|
|
||||||
|
// Enable security groups for VINS
|
||||||
|
// Required: false
|
||||||
|
// Default: false
|
||||||
|
EnableSecGroups interface{} `url:"enable_secgroups,omitempty" json:"enable_secgroups,omitempty" validate:"omitempty,isBool"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type wrapperCreateRequestInAcc struct {
|
type wrapperCreateRequestInAcc struct {
|
||||||
|
|||||||
@@ -51,6 +51,11 @@ type CreateInRGRequest struct {
|
|||||||
// Zone ID
|
// Zone ID
|
||||||
// Required: false
|
// Required: false
|
||||||
ZoneID uint64 `url:"zoneId,omitempty" json:"zoneId,omitempty"`
|
ZoneID uint64 `url:"zoneId,omitempty" json:"zoneId,omitempty"`
|
||||||
|
|
||||||
|
// Enable security groups for VINS
|
||||||
|
// Required: false
|
||||||
|
// Default: false
|
||||||
|
EnableSecGroups interface{} `url:"enable_secgroups,omitempty" json:"enable_secgroups,omitempty" validate:"omitempty,isBool"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type wrapperCreateRequestInRG struct {
|
type wrapperCreateRequestInRG struct {
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
package cloudbroker
|
||||||
|
|
||||||
|
import (
|
||||||
|
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v14/pkg/cloudbroker/vmfolder"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Accessing the VMFolder method group
|
||||||
|
func (cb *CloudBroker) VMFolder() *vmfolder.VMFolder {
|
||||||
|
return vmfolder.New(cb.client)
|
||||||
|
}
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
package vmfolder
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"net/http"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v14/internal/constants"
|
||||||
|
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v14/internal/validators"
|
||||||
|
)
|
||||||
|
|
||||||
|
// AddACLAccessRequest adds ACL access to a vm folder
|
||||||
|
type AddACLAccessRequest struct {
|
||||||
|
// ID of a folder
|
||||||
|
// Required: true
|
||||||
|
FolderID uint64 `url:"folder_id" json:"folder_id" validate:"required"`
|
||||||
|
|
||||||
|
// User or group name to grant access
|
||||||
|
// Required: true
|
||||||
|
User string `url:"user" json:"user" validate:"required"`
|
||||||
|
|
||||||
|
// ID of a folder
|
||||||
|
// Required: true
|
||||||
|
Right string `url:"right" json:"right" validate:"required"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddACLAccess adds ACL access to a vm folder
|
||||||
|
func (v VMFolder) AddACLAccess(ctx context.Context, req AddACLAccessRequest) (bool, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudbroker/vmfolder/add_acl_access"
|
||||||
|
|
||||||
|
res, err := v.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err := strconv.ParseBool(string(res))
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
package vmfolder
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"net/http"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v14/internal/constants"
|
||||||
|
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v14/internal/validators"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ComputesMoveRequest struct to move computes to a vm folder
|
||||||
|
type ComputesMoveRequest struct {
|
||||||
|
// IDs of computes to move
|
||||||
|
// Required: true
|
||||||
|
ComputeIDs []uint64 `url:"compute_ids" json:"compute_ids" validate:"required"`
|
||||||
|
|
||||||
|
// Target vm folder ID
|
||||||
|
// Required: true
|
||||||
|
FolderID uint64 `url:"folder_id" json:"folder_id" validate:"required"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ComputesMove moves computes to a vm folder
|
||||||
|
func (v VMFolder) ComputesMove(ctx context.Context, req ComputesMoveRequest) (bool, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudbroker/vmfolder/computes_move"
|
||||||
|
|
||||||
|
res, err := v.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err := strconv.ParseBool(string(res))
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
package vmfolder
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"net/http"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v14/internal/constants"
|
||||||
|
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v14/internal/validators"
|
||||||
|
)
|
||||||
|
|
||||||
|
// CreateRequest struct to create a vm folder
|
||||||
|
type CreateRequest struct {
|
||||||
|
// Resource Group ID
|
||||||
|
// Required: true
|
||||||
|
RGID uint64 `url:"rg_id" json:"rg_id" validate:"required"`
|
||||||
|
|
||||||
|
// Name
|
||||||
|
// Required: true
|
||||||
|
Name string `url:"name" json:"name" validate:"required"`
|
||||||
|
|
||||||
|
// Parent ID
|
||||||
|
// Required: false
|
||||||
|
ParentID uint64 `url:"parent_id,omitempty" json:"parent_id,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create creates a vm folder
|
||||||
|
func (v VMFolder) Create(ctx context.Context, req CreateRequest) (uint64, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
return 0, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudbroker/vmfolder/create"
|
||||||
|
|
||||||
|
res, err := v.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err := strconv.ParseUint(string(res), 10, 64)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
package vmfolder
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"net/http"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v14/internal/constants"
|
||||||
|
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v14/internal/validators"
|
||||||
|
)
|
||||||
|
|
||||||
|
// DeleteACLAccessRequest deletes ACL access from a vm folder
|
||||||
|
type DelACLAccessRequest struct {
|
||||||
|
// ID of a folder
|
||||||
|
// Required: true
|
||||||
|
FolderID uint64 `url:"folder_id" json:"folder_id"`
|
||||||
|
|
||||||
|
// User or group name to revoke access from
|
||||||
|
// Required: true
|
||||||
|
User string `url:"user" json:"user"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeleteACLAccess deletes ACL access from a vm foler
|
||||||
|
func (v VMFolder) DeleteACLAccess(ctx context.Context, req DelACLAccessRequest) (bool, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudbroker/vmfolder/del_acl_access"
|
||||||
|
|
||||||
|
res, err := v.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err := strconv.ParseBool(string(res))
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
package vmfolder
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"net/http"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v14/internal/constants"
|
||||||
|
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v14/internal/validators"
|
||||||
|
)
|
||||||
|
|
||||||
|
// DeleteRequest struct to delete a VM folder
|
||||||
|
type DeleteRequest struct {
|
||||||
|
// ID of a folder to delete
|
||||||
|
// Required: true
|
||||||
|
FolderID uint64 `url:"folder_id" json:"folder_id" validate:"required"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delete deletes a vm folder
|
||||||
|
func (v VMFolder) Delete(ctx context.Context, req DeleteRequest) (bool, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudbroker/vmfolder/delete"
|
||||||
|
|
||||||
|
res, err := v.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err := strconv.ParseBool(string(res))
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
package vmfolder
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"encoding/json"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v14/internal/constants"
|
||||||
|
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v14/internal/validators"
|
||||||
|
)
|
||||||
|
|
||||||
|
// GetRequest struct to get detailed information about a vm folder
|
||||||
|
type GetRequest struct {
|
||||||
|
// ID of a folder
|
||||||
|
// Required: true
|
||||||
|
FolderID uint64 `url:"folder_id" json:"folder_id" validate:"required"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get gets current configuration of the vm folder as a RecordVMFolder struct
|
||||||
|
func (v VMFolder) Get(ctx context.Context, req GetRequest) (*RecordVMFolder, error) {
|
||||||
|
res, err := v.GetRaw(ctx, req)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
info := RecordVMFolder{}
|
||||||
|
|
||||||
|
err = json.Unmarshal(res, &info)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return &info, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetRaw gets current configuration of the vm folder as an array of bytes
|
||||||
|
func (v VMFolder) GetRaw(ctx context.Context, req GetRequest) ([]byte, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudbroker/vmfolder/get"
|
||||||
|
|
||||||
|
res, err := v.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
@@ -0,0 +1,56 @@
|
|||||||
|
package vmfolder
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"encoding/json"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v14/internal/constants"
|
||||||
|
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v14/internal/validators"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ListRequest struct to get list of vm folders
|
||||||
|
type ListRequest struct {
|
||||||
|
// Resource group ID
|
||||||
|
// Required: true
|
||||||
|
RGID uint64 `url:"rg_id" json:"rg_id" validate:"required"`
|
||||||
|
|
||||||
|
// Page number
|
||||||
|
// Required: false
|
||||||
|
Page uint64 `url:"page,omitempty" json:"page,omitempty"`
|
||||||
|
|
||||||
|
// Page size
|
||||||
|
// Required: false
|
||||||
|
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// List gets list of all vm folders in a resource group as a ListVMFolder struct
|
||||||
|
func (v VMFolder) List(ctx context.Context, req ListRequest) (*ListVMFolder, error) {
|
||||||
|
|
||||||
|
res, err := v.ListRaw(ctx, req)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
list := ListVMFolder{}
|
||||||
|
|
||||||
|
err = json.Unmarshal(res, &list)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return &list, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListRaw gets list of all vm folders in a resource group as an array of bytes
|
||||||
|
func (v VMFolder) ListRaw(ctx context.Context, req ListRequest) ([]byte, error) {
|
||||||
|
|
||||||
|
if err := validators.ValidateRequest(req); err != nil {
|
||||||
|
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudbroker/vmfolder/list"
|
||||||
|
|
||||||
|
res, err := v.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
@@ -0,0 +1,82 @@
|
|||||||
|
package vmfolder
|
||||||
|
|
||||||
|
// Detailed information about a folder
|
||||||
|
type RecordVMFolder struct {
|
||||||
|
// ID
|
||||||
|
ID uint64 `json:"id"`
|
||||||
|
|
||||||
|
// RG ID
|
||||||
|
RGID uint64 `json:"rg_id"`
|
||||||
|
|
||||||
|
// GID
|
||||||
|
GID uint64 `json:"gid"`
|
||||||
|
|
||||||
|
// Name of a folder
|
||||||
|
Name string `json:"name"`
|
||||||
|
|
||||||
|
// ACL
|
||||||
|
ACL []ACL `json:"acl"`
|
||||||
|
|
||||||
|
// Time of creation
|
||||||
|
CreatedTime uint64 `json:"created_time"`
|
||||||
|
|
||||||
|
// Parent ID
|
||||||
|
ParentID uint64 `json:"parent_id"`
|
||||||
|
|
||||||
|
// Status of a folder
|
||||||
|
Status string `json:"status"`
|
||||||
|
|
||||||
|
// Compute IDs
|
||||||
|
ComputeIDs []uint64 `json:"compute_ids"`
|
||||||
|
|
||||||
|
// Time of update
|
||||||
|
UpdatedTime uint64 `json:"updated_time"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ACL
|
||||||
|
type ACL struct {
|
||||||
|
// Explicit
|
||||||
|
Explicit bool `json:"explicit"`
|
||||||
|
|
||||||
|
// Right
|
||||||
|
Right string `json:"right"`
|
||||||
|
|
||||||
|
// Status
|
||||||
|
Status string `json:"status"`
|
||||||
|
|
||||||
|
// Type
|
||||||
|
Type string `json:"type"`
|
||||||
|
|
||||||
|
// User group ID
|
||||||
|
UserGroupID string `json:"userGroupId"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// List of vm folders
|
||||||
|
type ListVMFolder struct {
|
||||||
|
// Entry count
|
||||||
|
EntryCount uint64 `json:"entryCount"`
|
||||||
|
|
||||||
|
// Data
|
||||||
|
Data []ItemVMFolder `json:"data"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Detailed information about a folder item
|
||||||
|
type ItemVMFolder struct {
|
||||||
|
// Folder ID
|
||||||
|
ID uint64 `json:"id"`
|
||||||
|
|
||||||
|
// Parent ID
|
||||||
|
ParentID uint64 `json:"parent_id"`
|
||||||
|
|
||||||
|
// Name
|
||||||
|
Name string `json:"name"`
|
||||||
|
|
||||||
|
// ACL
|
||||||
|
ACL []ACL `json:"acl"`
|
||||||
|
|
||||||
|
// Status
|
||||||
|
Status string `json:"status"`
|
||||||
|
|
||||||
|
// VM count
|
||||||
|
VMCount uint64 `json:"vm_count"`
|
||||||
|
}
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
package vmfolder
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"net/http"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v14/internal/constants"
|
||||||
|
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v14/internal/validators"
|
||||||
|
)
|
||||||
|
|
||||||
|
// MoveRequest to move a vm folder to a compute
|
||||||
|
type MoveRequest struct {
|
||||||
|
// VM Folder ID
|
||||||
|
// Required: true
|
||||||
|
FolderID uint64 `url:"folder_id" json:"folder_id"`
|
||||||
|
|
||||||
|
// New parent folder ID
|
||||||
|
// Required: true
|
||||||
|
NewParentID uint64 `url:"new_parent_id" json:"new_parent_id"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Move moves a vm folder to a compute
|
||||||
|
func (v VMFolder) Move(ctx context.Context, req MoveRequest) (bool, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudbroker/vmfolder/move"
|
||||||
|
|
||||||
|
res, err := v.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err := strconv.ParseBool(string(res))
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
package vmfolder
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"net/http"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v14/internal/constants"
|
||||||
|
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v14/internal/validators"
|
||||||
|
)
|
||||||
|
|
||||||
|
// RenameRequest struct to rename a VM folder
|
||||||
|
type RenameRequest struct {
|
||||||
|
// ID of a folder to rename
|
||||||
|
// Required: true
|
||||||
|
FolderID uint64 `url:"folder_id" json:"folder_id" validate:"required"`
|
||||||
|
|
||||||
|
// A new name
|
||||||
|
// Required: true
|
||||||
|
Name string `url:"name" json:"name" validate:"required"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Rename renames a vm folder
|
||||||
|
func (v VMFolder) Rename(ctx context.Context, req RenameRequest) (bool, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudbroker/vmfolder/rename"
|
||||||
|
|
||||||
|
res, err := v.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err := strconv.ParseBool(string(res))
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
Loaded 100 of 134 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user