Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| e04dc42d2b | |||
|
|
88eb9e8898 | ||
| 9ec34c6bfc | |||
| 80491ed643 | |||
| f1e0f7abb6 | |||
| 8eeef825c0 | |||
| 9a7a7b6f36 | |||
| 3393934456 |
5
.gitignore
vendored
5
.gitignore
vendored
@@ -3,3 +3,8 @@ cmd/
|
||||
.vscode/
|
||||
.fleet/
|
||||
.DS_Store
|
||||
tests/platform_upgrade/.env
|
||||
tests/platform_upgrade/input.json
|
||||
tests/platform_upgrade/*.txt
|
||||
tests/platform_upgrade/*.log
|
||||
*.env
|
||||
|
||||
235
CHANGELOG.md
235
CHANGELOG.md
@@ -1,197 +1,64 @@
|
||||
## Version 1.8.0
|
||||
## Version 1.10.0
|
||||
|
||||
### Feature
|
||||
### Добавлено
|
||||
|
||||
#### account:
|
||||
- Add endpoints GrantAccessTemplates, ListAvailableTemplates, RevokeAccessTemplates in cloudbroker/account
|
||||
- Add SortBy field for list groups and validation functionality
|
||||
- Add ComputeFeatures field to RecordAccount and ItemAccount models in cloudapi/account
|
||||
- Add ComputeFeatures field to InfoAccount and CreateRequest model in cloudbroker/account
|
||||
- Add UpdateComputeFeatures endpoint in cloudbroker/account
|
||||
- Add ExtnetId, FreeIPs fields to model ItemVINS in cloudapi/account and cloudbroker/account
|
||||
#### compute
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-204 | Вычисляемое поле `VNCPassword` в моделях `RecordCompute` в cloudapi/compute и cloudbroker/compute |
|
||||
| BGOS-204 | Опциональное поле `CDImageID` в структуре `ListRequest` в cloudbroker/compute |
|
||||
| BGOS-211 | Вычисляемое поле `AutoStart` в моделях `RecordCompute, ItemCompute, InfoCompute` в cloudapi/compute и cloudbroker/compute |
|
||||
| BGOS-211 | Опциональное поле `AutoStart` в структурах `PinToStackRequest, UpdateRequest` в cloudapi/compute и cloudbroker/compute |
|
||||
|
||||
#### audit:
|
||||
- Add field GUID in model ItemLinkedJobs cloudbroker/audit
|
||||
- Delete field StatusCode in model ListRequest cloudbroker/audit
|
||||
- Add fields MinStatusCode and MaxStatusCode in model ListRequest cloudbroker/audit
|
||||
#### extnet
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-204 | Вычисляемое поле `AccountID` в модели `ItemReservation` в cloudapi/extnet и cloudbroker/extnet |
|
||||
| BGOS-205 | Методы API `cloudbroker/extnet/addReservedIp, cloudbroker/extnet/getReservedIp, cloudapi/extnet/getReservedIp, cloudbroker/extnet/delReservedIp` в cloudapi/extnet и cloudbroker/extnet |
|
||||
|
||||
#### bservice:
|
||||
- Add validation of RAM to be divisible by 128 in cloudapi/bservice
|
||||
#### image
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-214 | Вычисляемое поле `SnapshotID` в модели `RecordImage, ItemImage` в cloudbroker/image |
|
||||
|
||||
#### compute:
|
||||
- Add field CdImageId in models ItemCompute and RecordCompute in cloudapi/compute and cloudbroker/compute
|
||||
- Add fields NatableVINSID, NatableVINSIP, NatableVINSName, NatableVINSNetwork, NatableVINSNetworkName in models RecordCompute in cloudbroker/compute
|
||||
- Set field LocalBasePort in model PFWAddRequest as optional in cloudapi/compute and cloudbroker/compute
|
||||
- Add SortBy field for list groups and validation functionality
|
||||
- Add HPBacked, CPUPin, NumaAffinity fields to RecordCompute and InfoCompute models in cloudbroker/compute
|
||||
- Add HPBacked, CPUPin, NumaAffinity fields to RecordCompute and ItemCompute models in cloudapi/compute
|
||||
- Add validation of RAM to be divisible by 128 in cloudapi/compute and cloudbroker/compute
|
||||
- Add field NumaNodeId in models RecordCompute and ItemCompute in cloudapi/compute and cloudbroker/compute
|
||||
- Add BootDiskSet endpoints in cloudapi/compute and cloudbroker/compute
|
||||
- Add endpoints DiskSwitchToReplication, DiskMigrate in cloudapi/compute and cloudbroker/compute
|
||||
- Add field Replication in model RecordCompute.Disks.ItemComputeDisk in cloudapi/compute and cloudbroker/compute
|
||||
- Add endpoint getCustomFields in cloudbroker/compute
|
||||
- Delete field AffinityLabel in model AffinityRelationsRequest in cloudbroker/compute
|
||||
- Add fields ImageName and VirtualImageName, delete VINSConnected fields in RecordCompute model in cloudbroker/compute
|
||||
- Add fields Enabled and NodeID in ItemInterface model in cloudbroker/compute. Add NodeID field in ItemVNFInterface model in cloudapi/compute
|
||||
#### node
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-204 | Обязательное поле `Spoofchk` в структуре `SetVFsNumberRequest` в cloudbroker/node |
|
||||
| BGOS-213 | Вычисляемое поле `NetAddr` в модели `RecordNode` в cloudbroker/node |
|
||||
|
||||
#### disks:
|
||||
- Add endpoints Replicate, ReplicationResume, ReplicationReverse, ReplicationStart, ReplicationStop, ReplicationStatus, ReplicationSuspend in cloudapi/disks and cloudbroker/disks
|
||||
- Add field Replication in models RecordDisk and ItemDisk in cloudapi/disks and cloudbroker/disks
|
||||
- Add CreateTemplateFromBlank and CreateTemplateFromBlankAsync endpoints in cloudapi/compute and cloudbroker/compute
|
||||
- Add fields Page and Size in model SearchRequest in cloudapi/disks
|
||||
- Add FromPlatformDisk and FromPlatformDiskAsync endpoints in cloudapi/disks and cloudbroker/disks
|
||||
#### vgpu
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-204 | Опциональное поле `NID` в структуре `ListRequest` в cloudbroker/vgpu |
|
||||
|
||||
#### flipgroup:
|
||||
- Add fields ConnId, Status, AccountId to model ListRequest in cloudapi/flipgroup and cloudbroker/flipgroup
|
||||
- Add SortBy field for list groups and validation functionality
|
||||
#### vins
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-204 | Вычисляемое поле `VNCPassword` в модели `RecordVNFDev` в cloudapi/vins и cloudbroker/vins |
|
||||
| BGOS-204 | Вычисляемое поле `AccoundID` в модели `ItemReservation` в cloudapi/vins |
|
||||
|
||||
#### grid:
|
||||
- Add endpoints addCustomBackupPath, removeCustomBackupPath, setPasswordPolicy in cloudbroker/grid
|
||||
### Удалено
|
||||
|
||||
#### image:
|
||||
- Add field CdPresentedTo in model RecordImage in cloudapi/image cloudbroker/image
|
||||
- Set field AccountId in CreateRequest in cloudapi/image as required
|
||||
- Add endpoints GrantAccess, RevokeAccess in cloudbroker/image
|
||||
- Add SortBy field for list groups and validation functionality
|
||||
- Add field NetworkInterfaceNaming in model CreateRequest in cloudapi/image cloudbroker/image, in model EditRequest in cloudbroker/image, in models ItemImage and RecordImage in cloudapi/image and cloudbroker/image
|
||||
- Add validation field NetworkInterfaceNaming in cloudapi/image cloudbroker/image
|
||||
- Delete field GID in model CreateRequest in cloudapi/image
|
||||
- Delete field Meta and Ckey in model and RecordImage in cloudbroker/image
|
||||
- Add model ItemImage in cloudbroker/image
|
||||
#### disks
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-206 | Метод `Resize` в cloudapi/disks и cloudbroker/disks |
|
||||
|
||||
#### k8s:
|
||||
- Add field LbSysctlParams in model CreateRequest in cloudapi/k8s/create and cloudbroker/k8s/create
|
||||
- Add validation of RAM to be divisible by 128 in cloudapi/k8s and cloudbroker/k8s
|
||||
- Set uint64 as MasterRAM and WorkerRAM types in CreateRequest struct in cloudapi/k8s and cloudbroker/k8s
|
||||
#### sep
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-206 | Метод `UpdateCapacityLimit` cloudbroker/sep |
|
||||
|
||||
#### kvmppc
|
||||
- Add validation of RAM to be divisible by 128 in cloudapi/kvmppc and cloudbroker/kvmppc
|
||||
- Add DataDisks field to CreateRequest and CreateBlankRequest in cloudapi/kvmppc and cloudbroker/kvmppc
|
||||
- Add DataDisks field to MassCreateRequest in cloudbroker/kvmppc
|
||||
#### vins
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-204 | Вычисляемые поля `ClientType,Description,DomainName,Hostname` в модели `ItemReservation` в cloudapi/vins и cloudbroker/vins |
|
||||
| BGOS-204 | Вычисляемое поле `СomputeIds` в структуре `StaticRouteAddRequest` в cloudapi/vins и cloudbroker/vins |
|
||||
|
||||
#### kvmx86
|
||||
- Add validation of RAM to be divisible by 128 in cloudapi/kvmx86 and cloudbroker/kvmx86
|
||||
- Add DataDisks field to CreateRequest and CreateBlankRequest in cloudapi/kvmx86 and cloudbroker/kvmx86
|
||||
- Add DataDisks field to MassCreateRequest in cloudbroker/kvmx86
|
||||
### Исправлено
|
||||
|
||||
#### lb:
|
||||
- Add fields UserManaged, ManagerId, ManagerType, PartK8S in models RecordLB, ItemLBList in cloudapi/lb and cloudbroker/lb
|
||||
- Add SortBy field for list groups and validation functionality
|
||||
- Add field SysctlParams in model CreateRequest in cloudapi/lb/create and cloudbroker/lb/create
|
||||
- Add endpoint update_sysctl_params in cloudapi/lb and cloudbroker/lb
|
||||
|
||||
#### node:
|
||||
- Add ApplyIpmiAction, Consumption, Decommission, Enable, EnableNodes, Get, GetRaw, List, ListRaw, Maintenance, Restrict, SetCoreIsolation, SetHugePages, SetSRIOVStatus, SetVFSNumber and Update endpoints in cloudbroker/node
|
||||
- Add IDs method and Filters methods for ListNodes structure in cloudbroker/node
|
||||
- Add Serialize method for ListNodes, ItemNode and RecordNode structures in cloudbroker/node
|
||||
|
||||
#### pcidevice:
|
||||
- Add List, ListRaw endpoints in cloudapi/pcidevice
|
||||
- Add IDs and Serialize methods for ListPCIDevices structure in cloudapi/pcidevice
|
||||
|
||||
#### rg:
|
||||
- Add ComputeFeatures field to ItemResourceGroup and RecordResourceGroup models in cloudapi/rg
|
||||
- Add ComputeFeatures field to ItemRG and CreateRequest models in cloudbroker/rg
|
||||
- Add UpdateComputeFeatures endpoint in cloudbroker/rg
|
||||
- Add ExtnetId, FreeIPs fields to model ItemVINS in cloudapi/rg and cloudbroker/rg
|
||||
|
||||
#### sep:
|
||||
- Add endpoints addPool, delPool in cloudbroker/sep
|
||||
- Set field Config in CreateRequest as required in cloudbroker/sep
|
||||
- Add SortBy field for list groups and validation functionality
|
||||
|
||||
#### stack:
|
||||
- Add endpoints getLogicalCoresCount, setCpuAllocationRatio, setMemAllocationRatio in cloudbroker/stack
|
||||
|
||||
#### tasks:
|
||||
- Add field TaskId, Status, Completed in model ListRequest in cloudapi/task and cloudbroker/task
|
||||
- Add fields GUID, UpdatedBy in model ItemTask in cloudapi/task and cloudbroker/task
|
||||
- Fix panic in List endpoints in cloudapi/task and cloudbroker/task
|
||||
- Change type field Result from int to interface{} in models RecordAsyncTask, ItemAsyncTask in cloudapi/task and models ItemTask, RecordTask in cloudbroker/task
|
||||
- Add methods ID(), Name(), ToString(), ToMaps() for processing the value of the Result field in model ItemTask in cloudapi/task and cloudbroker/task
|
||||
- Add use case examples for the above methods in README.md
|
||||
- Add SortBy field for list groups and validation functionality
|
||||
- Add fields UpdateTimeAt and UpdateTimeTo in model ListRequest in cloudapi/tasks and cloudbroker/tasks
|
||||
|
||||
#### user:
|
||||
- Add fields Call, StatusCode, TimestampAt, TimestampTo in models GetAuditRequest in cloudbroker/user
|
||||
- Fix return value in GetAudit endpoint in cloudbroker/user
|
||||
- Add model ListAudits and change type field APIAccess in model ItemUser in cloudbroker/user
|
||||
- Add SortBy field for list groups and validation functionality in cloudbroker/user
|
||||
- Add APIList, Authenticate, Brief, GetAudit, GetResourceConsumption, Get, GetRaw, IsValidInviteUserToken, Search, SetData endpoints in cloudapi/user
|
||||
|
||||
#### vfpool:
|
||||
- Add Get, GetRaw, List, ListRaw endpoints in cloudapi/vfpool
|
||||
- Add Create, Delete, Disable, Enable, Get, GetRaw, List, ListRaw, Update endpoints in cloudbroker/vfpool
|
||||
- Add IDs method for ListVFPool, VFSInfoListand in cloudapi/vfpool and cloudbroker/vfpool
|
||||
- Add Filters methods for ListVFPool structure in cloudapi/vfpool and cloudbroker/vfpool
|
||||
- Add Serialize method for ListVFPool, ItemVFPool and RecordVFPool structures in cloudapi/vfpool and cloudbroker/vfpool
|
||||
|
||||
#### vins:
|
||||
- Set field IntPort in model NATRuleAddRequest as optional in cloudapi/vins and cloudbroker/vins
|
||||
- Add SortBy field for list groups and validation functionality
|
||||
- Add ExtnetId, FreeIPs fields to model ItemVINS in cloudapi/vins and cloudbroker/vins
|
||||
- Add DNSList field to models CreateInAccountRequest and CreateInRGRequest in cloudapi/vins and cloudbroker/vins
|
||||
- Add DNSApply endpoints in cloudapi/vins and cloudbroker/vins
|
||||
- Add field NodeID in model RecordVINS.RecordVNFDev.Interfaces in cloudapi/vins and cloudbroker/vins
|
||||
|
||||
### Bugfix
|
||||
|
||||
#### account:
|
||||
- Fix wrong json, url field AccountID in model SetCPUAllocationParameterRequest in cloudbroker/account
|
||||
- Fix wrong json, url field AccountID in model SetCPUAllocationRatioRequest in cloudbroker/account
|
||||
- Change Start and End fields type from uint64 to float64 in model GetConsumptionRequest in cloudapi/account
|
||||
|
||||
#### apiaccess:
|
||||
- Changed Job and Resmon field types in model CloudBrokerEndpoints in cloudbroker/apiaccess
|
||||
- Add fields Page and Size in model UserListRequest in cloudbroker/apiaccess
|
||||
|
||||
#### bservice:
|
||||
- Fix url for Disable endpoint in cloudapi/bservice
|
||||
|
||||
#### compute:
|
||||
- Fix Entrycount tag in model ListComputes in cloudbroker/compute
|
||||
- Add field Name in model ListPCIDeviceRequest in cloudbroker/compute
|
||||
- Fix type of field Data in model ListPCIDevices in cloudapi/compute
|
||||
- Add model ItemPCIDevice in cloudapi/compute
|
||||
- Fix type of field Data in model ListVGPUs in cloudapi/compute and cloudbroker/compute
|
||||
- Add model ItemVGPU in cloudapi/compute and cloudbroker/compute
|
||||
|
||||
#### disks:
|
||||
- Delete tag required from field Detailed in ListTypesRequest model in cloudapi/disks
|
||||
|
||||
#### grid:
|
||||
- Fix json, url tags in field Name in model RenameRequest in cloudbroker/grid
|
||||
|
||||
#### image:
|
||||
- Fix url for ComputeCIUnset endpoint in cloudbroker/image
|
||||
|
||||
#### k8ci:
|
||||
- Delete omitempty from json, url tags in field Permanently in model DeleteRequest in cloudbroker/k8ci
|
||||
- Fix wrong json, url tags field ByID in model ListDeletedRequest in cloudbroker/k8ci
|
||||
- Fix allowed network plugin value from "weawenet" to "weavenet" in validators for cloudbroker/k8ci
|
||||
|
||||
#### k8s:
|
||||
- Fix allowed network plugin value from "weawenet" to "weavenet" in validators for cloudapi/k8s, cloudbroker/k8s
|
||||
|
||||
#### lb:
|
||||
- Fix wrong json, url tags field AccountID in model ListDeletedRequest in cloudapi/lb
|
||||
- Add field Safe in model RestartRequest in cloudbroker/lb
|
||||
- Fix wrong json, url tags field AccountID in models ListRequest, ListDeletedRequest in cloudbroker/lb
|
||||
- Fix url for Stop endpoint in cloudapi/lb
|
||||
|
||||
#### rg:
|
||||
- Fix wrong json, url field AccountID in model ListLBRequest in cloudapi/rg and cloudbroker/rg
|
||||
- Fix wrong json, url field UniqPools in model CreateRequest in cloudbroker/rg
|
||||
|
||||
#### sep:
|
||||
- Fix wrong json, url tag in field GID in model ListRequest in cloudbroker/sep
|
||||
|
||||
#### user:
|
||||
- Fix wrong json, url field Password in model ItemUser in cloudbroker/user
|
||||
- Change ByID field type from uint64 to string in model ListRequest in cloudbroker/user
|
||||
|
||||
#### vins:
|
||||
- Fix wrong json, url tags in models DefaultQOSUpdateRequest and NetQOSRequest in field IngressBirst in cloudbroker/vins
|
||||
- Fix wrong name field ListNatRule to ListNATRule in cloudbroker/vins
|
||||
#### compute
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| BATF-215 | Изменены возвращаемые параметры метода `PinToStack` на `bool,error` в cloudapi/compute |
|
||||
2
LICENSE
2
LICENSE
@@ -186,7 +186,7 @@ APPENDIX: How to apply the Apache License to your work.
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
Copyright 2022 Basis LTD
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
|
||||
164
README.md
164
README.md
@@ -1,6 +1,6 @@
|
||||
# Decort SDK
|
||||
|
||||
Decort SDK - это библиотека, написанная на языке GO, позволяющая взаимодействовать с API облачной платформы **DECORT**. Библиотека содеражит в себе структуры и методы, необходимые для отправки запросов. Decort SDK имеет встроенный http-клиент и поддерживает разные способы авторизации на платформе. Библиотека так же содержит в себе модели ответов от платформы.
|
||||
Decort SDK - это библиотека, написанная на языке GO, позволяющая взаимодействовать с API облачной платформы **DECORT**. Библиотека содержит в себе структуры и методы, необходимые для отправки запросов. Decort SDK имеет встроенный http-клиент и поддерживает разные способы авторизации на платформе. Библиотека так же содержит в себе модели ответов от платформы.
|
||||
|
||||
## Версии
|
||||
|
||||
@@ -13,6 +13,8 @@ Decort SDK - это библиотека, написанная на языке G
|
||||
- Версия 1.6.x Decort-SDK соответствует 3.8.8 версии платформы
|
||||
- Версия 1.7.х Decort-SDK соответствует 3.8.9 версии платформы
|
||||
- Версия 1.8.х Decort-SDK соответствует 4.0.0 версии платформы
|
||||
- Версия 1.9.х Decort-SDK соответствует 4.1.0 версии платформы
|
||||
- Версия 1.10.х Decort-SDK соответствует 4.2.0 версии платформы
|
||||
|
||||
## Оглавление
|
||||
|
||||
@@ -69,6 +71,13 @@ Decort SDK - это библиотека, написанная на языке G
|
||||
- [Пример выполнения запроса](#пример-выполнения-запроса-2)
|
||||
- [Пример валидации запросов, имеющих в своей структуре поле RAM (или MasterRam/WorkerRAM)](#пример-валидации-запросов-имеющих-в-своей-структуре-поле-ram-или-masterramworkerram)
|
||||
- [Пример выполнения запроса](#пример-выполнения-запроса-3)
|
||||
- [Работа с универсальным клиентом](#работа-с-универсальным-клиентом)
|
||||
- [Настройка конфигурации универсального клиента](#настройка-конфигурации-универсального-клиента)
|
||||
- [Пример конфигурации универсального клиента](#пример-конфигурации-универсального-клиента)
|
||||
- [Парсинг универсальной конфигурации из файла](#парсинг-универсальной-конфигурации-из-файла)
|
||||
- [Создание универсального клиента](#создание-универсального-клиента)
|
||||
- [Пример создания универсального клиента](#пример-создания-универсального-клиента)
|
||||
- [Пример выполнения запроса](#пример-выполнения-запроса-4)
|
||||
|
||||
## Установка
|
||||
|
||||
@@ -91,20 +100,20 @@ go get -u repository.basistech.ru/BASIS/decort-golang-sdk
|
||||
Данная группа ручек позволяет выполнять следующие операции в платформе:
|
||||
|
||||
- `Account` - управление аккаунтами - внутренними учетными записями платформы, которые являются владельцами вычислительных ресурсов;
|
||||
- `Audit` - получение информации о событиях системы;
|
||||
- `BService` - управление группами виртуальных машин (computes);
|
||||
- `Compute` - управление виртуальными машинами (индивидуально);
|
||||
- `Disks` - управление виртуальными дисками;
|
||||
- `DPDK` - управление виртуальными сетями DPDK;
|
||||
- `ExtNet` - управление виртуальными сетями, отвечающими за внешний доступ;
|
||||
- `FLIPgroup` - управление группами "плавающими" ip - адресами;
|
||||
- `Image` - управление образами операционных систем;
|
||||
- `K8CI` - получение информации о конвейере для создания кластера;
|
||||
- `K8S` - управление кластерами kubernetes;
|
||||
- `KVMPPC` - создание виртуальной машины Power PC (IBM);
|
||||
- `KVMx86` - создание виртуальной машины x86;
|
||||
- `LB` - управление балансировщиками нагрузки;
|
||||
- `Locations` - получение информации о grid площадки;
|
||||
- `RG` - управление ресурсными группами аккаунта;
|
||||
- `Sizes` - получение информации о потребляемых ресурсах виртуальными машинами и дисками;
|
||||
- `Stack` - получение информации о вычислительных узлах;
|
||||
- `Tasks` - получение информации о ходе выполнения асинхронных задач (например, создание кластера);
|
||||
- `VFPool` - управление пулом виртуальных сетевых функций;
|
||||
@@ -116,10 +125,12 @@ go get -u repository.basistech.ru/BASIS/decort-golang-sdk
|
||||
Данная группа ручек позволяет выполнять следующие операции в платформе:
|
||||
|
||||
- `Account` - управление аккаунтами - внутренними учетными записями платформы, которые являются владельцами вычислительных ресурсов;
|
||||
- `Audit` - получение информации о событиях системы;
|
||||
- `APIAccess` - управление доступом к API и его объектам;
|
||||
- `Backup` - управление резервным копированием;
|
||||
- `Compute` - управление виртуальными машинами (индивидуально);
|
||||
- `Disks` - управление виртуальными дисками;
|
||||
- `DPDK` - управление виртуальными сетями DPDK;
|
||||
- `ExtNet` - управление виртуальными сетями, отвечающими за внешний доступ;
|
||||
- `FLIPGroup` - управление группами с «плавающими» ip адресами;
|
||||
- `Grid` - управление площадками;
|
||||
@@ -127,7 +138,6 @@ go get -u repository.basistech.ru/BASIS/decort-golang-sdk
|
||||
- `Image` - управление образами операционных систем;
|
||||
- `K8CI` - управление конвейром для создания кластера;
|
||||
- `K8S` - управление кластерами kubernetes;
|
||||
- `KVMPPC` - создание виртуальной машины Power PC (IBM);
|
||||
- `KVMx86` - создание виртуальной машины x86;
|
||||
- `LB` - управление балансировщиками нагрузки;
|
||||
- `Node` - управление нодами платформы;
|
||||
@@ -166,7 +176,7 @@ go get -u repository.basistech.ru/BASIS/decort-golang-sdk
|
||||
| SSLSkipVerify | bool | Нет | Пропуск проверки подлинности сертификата |
|
||||
| Token | string | Нет | JWT токен |
|
||||
|
||||
#### Пример конфигурации клиента
|
||||
##### Пример конфигурации клиента
|
||||
|
||||
```go
|
||||
import (
|
||||
@@ -272,30 +282,32 @@ func main() {
|
||||
|
||||
- **cloudapi**:
|
||||
- `pkg/cloudapi/account` - для `Account`
|
||||
- `pkg/cloudapi/audit` - для `Audit`
|
||||
- `pkg/cloudapi/bservice` - для `Basic Service`
|
||||
- `pkg/cloudapi/compute` - для `Compute`
|
||||
- `pkg/cloudapi/disks` - для `Disks`
|
||||
- `pkg/cloudapi/dpdknet` - для `DPDK`
|
||||
- `pkg/cloudapi/extnet` - для `ExtNet`
|
||||
- `pkg/cloudapi/flipgroup` - для `FLIPGroup`
|
||||
- `pkg/cloudapi/image` - для `Image`
|
||||
- `pkg/cloudapi/k8ci` - для `K8CI`
|
||||
- `pkg/cloudapi/k8s` - для `K8S`
|
||||
- `pkg/cloudapi/kvmppc` - для `KVMPPC`
|
||||
- `pkg/cloudapi/kvmx86` - для `KVMX86`
|
||||
- `pkg/cloudapi/lb` - для `LB`
|
||||
- `pkg/cloudapi/locations` - для `Locations`
|
||||
- `pkg/cloudapi/rg` - для `RG`
|
||||
- `pkg/cloudapi/sizes` - для `Sizes`
|
||||
- `pkg/cloudapi/stack` - для `Stack`
|
||||
- `pkg/cloudapi/tasks` - для `Tasks`
|
||||
- `pkg/cloudapi/vfpool` - для `VFPool`
|
||||
- `pkg/cloudapi/vins` - для `VINS`
|
||||
- **cloudbroker**:
|
||||
- `pkg/cloudbroker/account` - для `Account`
|
||||
- `pkg/cloudbroker/audit` - для `Audit`
|
||||
- `pkg/cloudbroker/apiaccess` - для `APIAccess`
|
||||
- `pkg/cloudbroker/backup` - для `Backup`
|
||||
- `pkg/cloudbroker/compute` - для `Compute`
|
||||
- `pkg/cloudbroker/disks` - для `Disks`
|
||||
- `pkg/cloudbroker/dpdknet` - для `DPDK`
|
||||
- `pkg/cloudbroker/extnet` - для `ExtNet`
|
||||
- `pkg/cloudbroker/flipgroup` - для `FLIPGroup`
|
||||
- `pkg/cloudbroker/grid` - для `Grid`
|
||||
@@ -303,7 +315,6 @@ func main() {
|
||||
- `pkg/cloudbroker/image` - для `Image`
|
||||
- `pkg/cloudbroker/k8ci` - для `K8CI`
|
||||
- `pkg/cloudbroker/k8s` - для `K8S`
|
||||
- `pkg/cloudbroker/kvmppc` - для `KVMPPC`
|
||||
- `pkg/cloudbroker/kvmx86` - для `KVMX86`
|
||||
- `pkg/cloudbroker/lb` - для `LB`
|
||||
- `pkg/cloudbroker/node` - для `Node`
|
||||
@@ -405,9 +416,7 @@ type CreateRequest struct {
|
||||
// Required: false
|
||||
IPAType string `url:"ipaType,omitempty" json:"ipaType,omitempty"`
|
||||
|
||||
// Reason for action
|
||||
// Required: false
|
||||
Reason string `url:"reason,omitempty" json:"reason,omitempty"`
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
@@ -457,20 +466,20 @@ func main() {
|
||||
Доступные методы для `.CloudAPI()`:
|
||||
|
||||
- `.Account()` - для работы с `Account`
|
||||
- `.Audit()` - для работы с `Audit`
|
||||
- `.BService()` - для работы с `BService`
|
||||
- `.Compute()` - для работы с `Compute`
|
||||
- `.Disks()` - для работы с `Disks`
|
||||
- `.DPDKNet()` - для работы с `DPDK`
|
||||
- `.ExtNet()` - для работы с `ExtNet`
|
||||
- `.FLIPgroup()` - для работы с `FLIPGroup`
|
||||
- `.Image()` - для работы с `Image`
|
||||
- `.K8CI()` - для работы с `K8CI`
|
||||
- `.K8S()` - для работы с `K8S`
|
||||
- `.KVMPPC()` - для работы с `KVMPPC`
|
||||
- `.KVMx86()` - для работы с `KVMX86`
|
||||
- `.LB()` - для работы с `LB`
|
||||
- `.Locations()` - для работы с `Locations`
|
||||
- `.RG()` - для работы с `RG`
|
||||
- `.Sizes()` - для работы с `Sizes`
|
||||
- `.Stack()` - для работы с `Stack`
|
||||
- `.Tasks()` - для работы с `Tasks`
|
||||
- `.VFPool()` - для работы с `VFPool`
|
||||
@@ -479,10 +488,12 @@ func main() {
|
||||
Доступные методы для `.CloudBroker()`:
|
||||
|
||||
- `.Account()` - для работы с `Account`
|
||||
- `.Audit()` - для работы с `Audit`
|
||||
- `.APIAccess()` - для работы с `APIAccess`
|
||||
- `.Backup()` - для работы с `Backup`
|
||||
- `.Compute()` - для работы с `Compute`
|
||||
- `.Disks()` - для работы с `Disks`
|
||||
- `.DPDKNet()` - для работы с `DPDK`
|
||||
- `.ExtNet()` - для работы с `ExtNet`
|
||||
- `.FLIPGroup()` - для работы с `FLIPGroup`
|
||||
- `.Grid()` - для работы с `Grid`
|
||||
@@ -490,7 +501,6 @@ func main() {
|
||||
- `.Image()` - для работы с `Image`
|
||||
- `.K8CI()` - для работы с `K8CI`
|
||||
- `.K8S()` - для работы с `K8S`
|
||||
- `.KVMPPC()` - для работы с `KVMPPC`
|
||||
- `.KVMx86()` - для работы с `KVMX86`
|
||||
- `.LB()` - для работы с `LB`
|
||||
- `.Node()` - для работы с `Node`
|
||||
@@ -1455,4 +1465,130 @@ func main() {
|
||||
log.Println(res)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
## Работа с универсальным клиентом
|
||||
|
||||
Работа с универсальным клиентом позволяет использовать любой тип авторизации
|
||||
|
||||
### Настройка конфигурации универсального клиента
|
||||
|
||||
| Параметр | Тип | Обязательный | Описание |
|
||||
| --- | --- | --- | --- |
|
||||
| Decs3oConfig | *Config | Нет | Конфигурация Decs3o |
|
||||
| BVSConfig | *BVSConfig | Нет | Конфигурация BVS |
|
||||
| LegacyConfig | string | Нет | Конфигурация Legacy |
|
||||
|
||||
В универсальном клиенте можно использовать только один тип конфигурации одновременно.
|
||||
|
||||
#### Пример конфигурации универсального клиента
|
||||
|
||||
```go
|
||||
import (
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/config"
|
||||
)
|
||||
|
||||
func main(){
|
||||
// Настройка конфигурации
|
||||
BVSConfig := config.BVSConfig{
|
||||
AppID: "<APP_ID>",
|
||||
AppSecret: "<APP_SECRET>",
|
||||
SSOURL: "https://sso.digitalenergy.online",
|
||||
DecortURL: "https://mr4.digitalenergy.online",
|
||||
Username: "<Username>",
|
||||
Password: "<Password>",
|
||||
Retries: 5,
|
||||
}
|
||||
|
||||
BVSConfig.SetTimeout(5 * time.Minute)
|
||||
|
||||
cfg := config.UniversalConfig{
|
||||
BVSConfig: &BVScfg,
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
#### Создание универсального клиента
|
||||
|
||||
Создание клиента происходит с помощью функции-строителя `NewUniversal` из основного пакета `decort-sdk`, для избежания проблем с именами, пакету можно присвоить алиас `decort`. Функция принимает конфигурацию, возвращает структуру `ClientInterface`, с помощью которой можно взаимодействовать с платформой.
|
||||
|
||||
#### Пример создания универсального клиента
|
||||
|
||||
```go
|
||||
package main
|
||||
|
||||
import (
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/config"
|
||||
decort "repository.basistech.ru/BASIS/decort-golang-sdk"
|
||||
)
|
||||
|
||||
func main() {
|
||||
// Настройка конфигурации
|
||||
legacyCfg := config.LegacyConfig{
|
||||
Username: "<USERNAME>",
|
||||
Password: "<PASSWORD>",
|
||||
DecortURL: "https://mr4.digitalenergy.online",
|
||||
Retries: 5,
|
||||
}
|
||||
|
||||
legacyCfg.SetTimeout(5 * time.Minute)
|
||||
|
||||
cfg := config.UniversalConfig{
|
||||
LegacyConfig: &legacyCfg,
|
||||
}
|
||||
|
||||
// Создание клиента
|
||||
universalClient := decort.NewUniversal(cfg)
|
||||
}
|
||||
```
|
||||
|
||||
#### Пример выполнения запроса
|
||||
|
||||
```go
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/config"
|
||||
decort "repository.basistech.ru/BASIS/decort-golang-sdk"
|
||||
)
|
||||
|
||||
func main() {
|
||||
// Настройка конфигурации
|
||||
legacyCfg := config.LegacyConfig{
|
||||
Username: "<USERNAME>",
|
||||
Password: "<PASSWORD>",
|
||||
Domain: "dynamix",
|
||||
DecortURL: "https://mr4.digitalenergy.online",
|
||||
Retries: 5,
|
||||
}
|
||||
|
||||
legacyCfg.SetTimeout(5 * time.Minute)
|
||||
|
||||
cfg := config.UniversalConfig{
|
||||
LegacyConfig: &legacyCfg,
|
||||
}
|
||||
|
||||
// Создание клиента
|
||||
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)
|
||||
}
|
||||
```
|
||||
62
README_EN.md
62
README_EN.md
@@ -1,62 +0,0 @@
|
||||
# Decort SDK
|
||||
|
||||
Decort SDK is a library, written in GO (Golang) for interact with the **DECORT** API.
|
||||
The library contents structures and methods for requesting to an user (cloudapi) and admin (cloudbroker) groups of API.
|
||||
Also the library have structures for responses.
|
||||
|
||||
## Contents
|
||||
|
||||
- [Install](#install)
|
||||
- [API List](#api-list)
|
||||
- [Examples](#examples)
|
||||
- [Examples2](#examples2)
|
||||
|
||||
## Install
|
||||
|
||||
```bash
|
||||
go get -u repository.basistech.ru/BASIS/decort-golang-sdk
|
||||
```
|
||||
|
||||
## API List
|
||||
|
||||
## Examples
|
||||
|
||||
```go
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"log"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/config"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/kvmx86"
|
||||
)
|
||||
|
||||
func main() {
|
||||
cfg := config.Config{
|
||||
AppID: "<APPID>",
|
||||
AppSecret: "<APPSECRET>",
|
||||
SSOURL: "https://sso.digitalenergy.online",
|
||||
DecortURL: "https://mr4.digitalenergy.online",
|
||||
Retries: 5,
|
||||
}
|
||||
client := decort.New(cfg)
|
||||
req := kvmx86.CreateRequest{
|
||||
RGID: 123,
|
||||
Name: "compute",
|
||||
CPU: 4,
|
||||
RAM: 4096,
|
||||
ImageID: 321,
|
||||
}
|
||||
|
||||
res, err := client.KVMX86().Create(context.Background(), req)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
fmt.Println(res)
|
||||
}
|
||||
```
|
||||
|
||||
## Examples2
|
||||
47
client.go
47
client.go
@@ -18,6 +18,7 @@ import (
|
||||
"github.com/google/go-querystring/query"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/config"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker"
|
||||
)
|
||||
@@ -53,7 +54,7 @@ func New(cfg config.Config) *DecortClient {
|
||||
},
|
||||
},
|
||||
},
|
||||
cfg: cfg,
|
||||
cfg: trimConfig(&cfg),
|
||||
expiryTime: expiryTime,
|
||||
mutex: &sync.Mutex{},
|
||||
}
|
||||
@@ -71,12 +72,22 @@ func (dc *DecortClient) CloudBroker() *cloudbroker.CloudBroker {
|
||||
|
||||
// DecortApiCall method for sending requests to the platform
|
||||
func (dc *DecortClient) DecortApiCall(ctx context.Context, method, url string, params interface{}) ([]byte, error) {
|
||||
values, err := query.Values(params)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
body := bytes.NewBufferString(values.Encode())
|
||||
var body *bytes.Buffer
|
||||
var ctype string
|
||||
|
||||
byteSlice, ok := params.([]byte)
|
||||
if ok {
|
||||
body = bytes.NewBuffer(byteSlice)
|
||||
// ctype = "application/x-iso9660-image"
|
||||
ctype = "application/octet-stream"
|
||||
} else {
|
||||
values, err := query.Values(params)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
body = bytes.NewBufferString(values.Encode())
|
||||
}
|
||||
|
||||
req, err := http.NewRequestWithContext(ctx, method, dc.decortURL+constants.RESTMACHINE+url, body)
|
||||
if err != nil {
|
||||
@@ -87,9 +98,8 @@ func (dc *DecortClient) DecortApiCall(ctx context.Context, method, url string, p
|
||||
if err = dc.getToken(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// perform request
|
||||
respBytes, err := dc.do(req, "")
|
||||
respBytes, err := dc.do(req, ctype)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -284,11 +294,22 @@ func multiPartReq(params interface{}) (*bytes.Buffer, string, error) {
|
||||
if values.Field(i).Type().Kind() == reflect.Slice {
|
||||
switch slice := values.Field(i).Interface().(type) {
|
||||
case []string:
|
||||
for _, val := range slice {
|
||||
err := writer.WriteField(trimString(types.Field(i)), val)
|
||||
if validators.IsInSlice(trimString(types.Field(i)), constants.K8sValues) {
|
||||
code, err := json.Marshal(slice)
|
||||
if err != nil {
|
||||
return &bytes.Buffer{}, "", err
|
||||
}
|
||||
err = writer.WriteField(trimString(types.Field(i)), string(code))
|
||||
if err != nil {
|
||||
return &bytes.Buffer{}, "", err
|
||||
}
|
||||
} else {
|
||||
for _, val := range slice {
|
||||
err := writer.WriteField(trimString(types.Field(i)), val)
|
||||
if err != nil {
|
||||
return &bytes.Buffer{}, "", err
|
||||
}
|
||||
}
|
||||
}
|
||||
case []uint:
|
||||
for _, val := range slice {
|
||||
@@ -348,3 +369,9 @@ func valueToString(a any) string {
|
||||
func trimString(el reflect.StructField) string {
|
||||
return strings.TrimSuffix(el.Tag.Get("url"), ",omitempty")
|
||||
}
|
||||
|
||||
func trimConfig(cfg *config.Config) config.Config {
|
||||
cfg.SSOURL = strings.TrimSuffix(cfg.SSOURL, "/")
|
||||
cfg.DecortURL = strings.TrimSuffix(cfg.DecortURL, "/")
|
||||
return *cfg
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ func NewBVS(cfg config.BVSConfig) *BVSDecortClient {
|
||||
},
|
||||
},
|
||||
},
|
||||
cfg: cfg,
|
||||
cfg: trimBVSConfig(&cfg),
|
||||
mutex: &sync.Mutex{},
|
||||
}
|
||||
}
|
||||
@@ -71,12 +71,21 @@ func (bdc *BVSDecortClient) CloudBroker() *cloudbroker.CloudBroker {
|
||||
|
||||
// DecortApiCall method for sending requests to the platform
|
||||
func (bdc *BVSDecortClient) DecortApiCall(ctx context.Context, method, url string, params interface{}) ([]byte, error) {
|
||||
values, err := query.Values(params)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var body *bytes.Buffer
|
||||
var ctype string
|
||||
|
||||
body := bytes.NewBufferString(values.Encode())
|
||||
byteSlice, ok := params.([]byte)
|
||||
if ok {
|
||||
body = bytes.NewBuffer(byteSlice)
|
||||
// ctype = "application/x-iso9660-image"
|
||||
ctype = "application/octet-stream"
|
||||
} else {
|
||||
values, err := query.Values(params)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
body = bytes.NewBufferString(values.Encode())
|
||||
}
|
||||
|
||||
req, err := http.NewRequestWithContext(ctx, method, bdc.decortURL+constants.RESTMACHINE+url, body)
|
||||
if err != nil {
|
||||
@@ -101,7 +110,7 @@ func (bdc *BVSDecortClient) DecortApiCall(ctx context.Context, method, url strin
|
||||
|
||||
// perform request
|
||||
reqCopy := req.Clone(ctx)
|
||||
respBytes, err := bdc.do(req, "")
|
||||
respBytes, err := bdc.do(req, ctype)
|
||||
if err == nil {
|
||||
return respBytes, nil
|
||||
}
|
||||
@@ -378,3 +387,9 @@ func (bdc *BVSDecortClient) do(req *http.Request, ctype string) ([]byte, error)
|
||||
err = fmt.Errorf("%s", respBytes)
|
||||
return nil, fmt.Errorf("could not execute request: %w", err)
|
||||
}
|
||||
|
||||
func trimBVSConfig(cfg *config.BVSConfig) config.BVSConfig {
|
||||
cfg.SSOURL = strings.TrimSuffix(cfg.SSOURL, "/")
|
||||
cfg.DecortURL = strings.TrimSuffix(cfg.DecortURL, "/")
|
||||
return *cfg
|
||||
}
|
||||
|
||||
8
config/universal-config.go
Normal file
8
config/universal-config.go
Normal file
@@ -0,0 +1,8 @@
|
||||
package config
|
||||
|
||||
// UniversalConfig combines configurations for different types of clients
|
||||
type UniversalConfig struct {
|
||||
Decs3oConfig *Config `json:"decs3oConfig,omitempty" yaml:"decs3oConfig,omitempty"`
|
||||
BVSConfig *BVSConfig `json:"bvsConfig,omitempty" yaml:"bvsConfig,omitempty"`
|
||||
LegacyConfig *LegacyConfig `json:"legacyConfig,omitempty" yaml:"legacyConfig,omitempty"`
|
||||
}
|
||||
@@ -10,3 +10,5 @@ const (
|
||||
var FileName = map[string]string{
|
||||
"OidcCertificate": "ca.crt",
|
||||
}
|
||||
|
||||
var K8sValues = []string{"labels", "taints", "annotations, additionalSANs"}
|
||||
|
||||
@@ -3,6 +3,8 @@ package validators
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/url"
|
||||
"reflect"
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
@@ -11,7 +13,7 @@ import (
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/multierror"
|
||||
)
|
||||
|
||||
// computeDriverValidator is used to validate Driver field in kvmx86/kvmppc create.
|
||||
// computeDriverValidator is used to validate Driver field in kvmx86 create.
|
||||
func computeDriverValidator(fe validator.FieldLevel) bool {
|
||||
fieldValue := fe.Field().String()
|
||||
|
||||
@@ -104,6 +106,13 @@ func computeNetTypeValidator(fe validator.FieldLevel) bool {
|
||||
return IsInSlice(fieldValue, computeNetTypeValues)
|
||||
}
|
||||
|
||||
// computex86NetTypeValidator is used to validate NetType field.
|
||||
func computex86NetTypeValidator(fe validator.FieldLevel) bool {
|
||||
fieldValue := fe.Field().String()
|
||||
|
||||
return IsInSlice(fieldValue, computex86NetTypeValues)
|
||||
}
|
||||
|
||||
// computeOrderValidator is used to validate Order field.
|
||||
func computeOrderValidator(fe validator.FieldLevel) bool {
|
||||
fieldSlice, ok := fe.Field().Interface().([]string)
|
||||
@@ -262,6 +271,27 @@ func interfaceStateValidator(fe validator.FieldLevel) bool {
|
||||
return IsInSlice(fieldValue, interfaceStateValues)
|
||||
}
|
||||
|
||||
func interfaceTXModelValidator(fe validator.FieldLevel) bool {
|
||||
fieldValue := fe.Field().String()
|
||||
fieldValue = strings.ToLower(fieldValue)
|
||||
|
||||
return IsInSlice(fieldValue, txModelValues)
|
||||
}
|
||||
|
||||
func interfaceIOEventFDValidator(fe validator.FieldLevel) bool {
|
||||
fieldValue := fe.Field().String()
|
||||
fieldValue = strings.ToLower(fieldValue)
|
||||
|
||||
return IsInSlice(fieldValue, ioEventFDValues)
|
||||
}
|
||||
|
||||
func interfaceEventIDxValidator(fe validator.FieldLevel) bool {
|
||||
fieldValue := fe.Field().String()
|
||||
fieldValue = strings.ToLower(fieldValue)
|
||||
|
||||
return IsInSlice(fieldValue, eventIDxValues)
|
||||
}
|
||||
|
||||
func strictLooseValidator(fe validator.FieldLevel) bool {
|
||||
fieldValue := fe.Field().String()
|
||||
fieldValue = strings.ToLower(fieldValue)
|
||||
@@ -296,6 +326,12 @@ func vmActionValidator(fe validator.FieldLevel) bool {
|
||||
return IsInSlice(fieldValue, vmActionValues)
|
||||
}
|
||||
|
||||
func mtuValidator(fe validator.FieldLevel) bool {
|
||||
fieldValue := fe.Field().Uint()
|
||||
|
||||
return fieldValue >= uint64(mtuMin) && fieldValue <= uint64(mtuMax)
|
||||
}
|
||||
|
||||
func computeFeaturesValidator(fe validator.FieldLevel) bool {
|
||||
field := fe.Field()
|
||||
slice, ok := field.Interface().([]string)
|
||||
@@ -312,6 +348,36 @@ func networkInterfaceNamingValidator(fe validator.FieldLevel) bool {
|
||||
return IsInSlice(fieldValue, networkInterfaceNamingValues)
|
||||
}
|
||||
|
||||
func numaAffinityValidator(fe validator.FieldLevel) bool {
|
||||
fieldValue := fe.Field().String()
|
||||
|
||||
return IsInSlice(fieldValue, numaAffinityValues)
|
||||
}
|
||||
|
||||
// kvmx86NetTypeValidator is used to validate NetType field for x86 compute.
|
||||
func kvmx86NetTypeValidator(fe validator.FieldLevel) bool {
|
||||
fieldValue := fe.Field().String()
|
||||
|
||||
return IsInSlice(fieldValue, kvmx86NetTypeValues)
|
||||
}
|
||||
|
||||
func isBoolTypeValidator(fe validator.FieldLevel) bool {
|
||||
return fe.Field().CanConvert(reflect.TypeOf(true))
|
||||
}
|
||||
|
||||
func urlValidartor(fl validator.FieldLevel) bool {
|
||||
fieldValues := fl.Field().String()
|
||||
|
||||
_, err := url.ParseRequestURI(fieldValues)
|
||||
return err == nil
|
||||
}
|
||||
|
||||
func chipsetValidator(fe validator.FieldLevel) bool {
|
||||
fieldValue := fe.Field().String()
|
||||
|
||||
return IsInSlice(fieldValue, chipsetValues)
|
||||
}
|
||||
|
||||
// ValidateRAM checks if request contains RAM value that is positive integer divisible by divisibility passed.
|
||||
// It is recommended to pass constants.RAM_DIVISIBILITY as divisility arguement
|
||||
func ValidateRAM(r interfaces.RequestWithRAM, divisibility uint64) error {
|
||||
|
||||
@@ -25,6 +25,8 @@ func errorMessage(fe validator.FieldError) string {
|
||||
return fmt.Sprintf("%s %s: unexpected URL format", prefix, fe.Field())
|
||||
case "email":
|
||||
return fmt.Sprintf("%s %s: unexpected E-Mail format", prefix, fe.Field())
|
||||
case "isBool":
|
||||
return fmt.Sprintf("%s %s: must be bool type", prefix, fe.Field())
|
||||
|
||||
case "driver":
|
||||
return fmt.Sprintf("%s %s must be one of the following: %s",
|
||||
@@ -89,6 +91,15 @@ func errorMessage(fe validator.FieldError) string {
|
||||
fe.Field(),
|
||||
joinValues(computeDiskTypeValues))
|
||||
|
||||
case "mtu":
|
||||
return fmt.Sprint(prefix, fe.Field(), "must be ", mtuMin, "-", mtuMax)
|
||||
|
||||
case "computex86NetType":
|
||||
return fmt.Sprintf("%s %s must be one of the following: %s",
|
||||
prefix,
|
||||
fe.Field(),
|
||||
joinValues(computex86NetTypeValues))
|
||||
|
||||
case "computeNetType":
|
||||
return fmt.Sprintf("%s %s must be one of the following: %s",
|
||||
prefix,
|
||||
@@ -133,7 +144,7 @@ func errorMessage(fe validator.FieldError) string {
|
||||
prefix,
|
||||
fe.Field())
|
||||
|
||||
// KVM_X86/KVM_PPC Validators
|
||||
// KVM_X86 Validators
|
||||
case "kvmNetType":
|
||||
return fmt.Sprintf("%s %s must be one of the following: %s",
|
||||
prefix,
|
||||
@@ -230,6 +241,24 @@ func errorMessage(fe validator.FieldError) string {
|
||||
fe.Field(),
|
||||
joinValues(interfaceStateValues))
|
||||
|
||||
case "interfaceTXModel":
|
||||
return fmt.Sprintf("%s %s must be one of the following: %s",
|
||||
prefix,
|
||||
fe.Field(),
|
||||
joinValues(txModelValues))
|
||||
|
||||
case "interfaceIOEventFD":
|
||||
return fmt.Sprintf("%s %s must be one of the following: %s",
|
||||
prefix,
|
||||
fe.Field(),
|
||||
joinValues(ioEventFDValues))
|
||||
|
||||
case "interfaceEventIDx":
|
||||
return fmt.Sprintf("%s %s must be one of the following: %s",
|
||||
prefix,
|
||||
fe.Field(),
|
||||
joinValues(eventIDxValues))
|
||||
|
||||
case "sortBy":
|
||||
return fmt.Sprintf("%s %s must be in format +|-(field)",
|
||||
prefix,
|
||||
@@ -258,6 +287,24 @@ func errorMessage(fe validator.FieldError) string {
|
||||
prefix,
|
||||
fe.Field(),
|
||||
joinValues(networkInterfaceNamingValues))
|
||||
|
||||
case "numaAffinity":
|
||||
return fmt.Sprintf("%s %s must be one of the following: %s",
|
||||
prefix,
|
||||
fe.Field(),
|
||||
joinValues(numaAffinityValues))
|
||||
|
||||
case "kvmx86NetType":
|
||||
return fmt.Sprintf("%s %s must be one of the following: %s",
|
||||
prefix,
|
||||
fe.Field(),
|
||||
joinValues(kvmx86NetTypeValues))
|
||||
|
||||
case "chipset":
|
||||
return fmt.Sprintf("%s %s must be one of the following: %s",
|
||||
prefix,
|
||||
fe.Field(),
|
||||
joinValues(chipsetValues))
|
||||
}
|
||||
|
||||
return fe.Error()
|
||||
|
||||
@@ -106,6 +106,11 @@ func registerAllValidators(validate *validator.Validate) error {
|
||||
return err
|
||||
}
|
||||
|
||||
err = validate.RegisterValidation("computex86NetType", computex86NetTypeValidator)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = validate.RegisterValidation("computeOrder", computeOrderValidator)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -181,6 +186,21 @@ func registerAllValidators(validate *validator.Validate) error {
|
||||
return err
|
||||
}
|
||||
|
||||
err = validate.RegisterValidation("interfaceTXModel", interfaceTXModelValidator)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = validate.RegisterValidation("interfaceIOEventFD", interfaceIOEventFDValidator)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = validate.RegisterValidation("interfaceEventIDx", interfaceEventIDxValidator)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = validate.RegisterValidation("workerGroupName", workerGroupNameValidator)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -201,6 +221,11 @@ func registerAllValidators(validate *validator.Validate) error {
|
||||
return err
|
||||
}
|
||||
|
||||
err = validate.RegisterValidation("mtu", mtuValidator)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = validate.RegisterValidation("computeFeatures", computeFeaturesValidator)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -211,5 +236,30 @@ func registerAllValidators(validate *validator.Validate) error {
|
||||
return err
|
||||
}
|
||||
|
||||
err = validate.RegisterValidation("numaAffinity", numaAffinityValidator)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = validate.RegisterValidation("kvmx86NetType", kvmx86NetTypeValidator)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = validate.RegisterValidation("isBool", isBoolTypeValidator)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = validate.RegisterValidation("url", urlValidartor)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = validate.RegisterValidation("chipset", chipsetValidator)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package validators
|
||||
|
||||
var (
|
||||
driverValues = []string{"KVM_X86", "KVM_PPC"}
|
||||
driverValues = []string{"KVM_X86"}
|
||||
accessTypeValues = []string{"R", "RCX", "ARCXDU"}
|
||||
resTypesValues = []string{"compute", "vins", "k8s", "openshift", "lb", "flipgroup"}
|
||||
protoValues = []string{"tcp", "udp"}
|
||||
@@ -10,32 +10,34 @@ var (
|
||||
|
||||
bserviceModeValues = []string{"ABSOLUTE", "RELATIVE"}
|
||||
|
||||
computeTopologyValues = []string{"compute", "node"}
|
||||
computePolicyValues = []string{"RECOMMENDED", "REQUIRED"}
|
||||
computeModeValues = []string{"EQ", "EN", "ANY"}
|
||||
computeDiskTypeValues = []string{"D", "B"}
|
||||
computeNetTypeValues = []string{"EXTNET", "VINS"}
|
||||
computeOrderValues = []string{"cdrom", "network", "hd"}
|
||||
computeDataDisksValues = []string{"KEEP", "DETACH", "DESTROY"}
|
||||
computeDriverValues = []string{"KVM_X86", "SVA_KVM_X86"}
|
||||
computeTopologyValues = []string{"compute", "node"}
|
||||
computePolicyValues = []string{"RECOMMENDED", "REQUIRED"}
|
||||
computeModeValues = []string{"EQ", "EN", "ANY"}
|
||||
computeDiskTypeValues = []string{"D", "B"}
|
||||
computeNetTypeValues = []string{"EXTNET", "VINS"}
|
||||
computex86NetTypeValues = []string{"EXTNET", "VINS", "VFNIC", "DPDK"}
|
||||
computeOrderValues = []string{"cdrom", "network", "hd"}
|
||||
computeDataDisksValues = []string{"KEEP", "DETACH", "DESTROY"}
|
||||
computeDriverValues = []string{"KVM_X86", "SVA_KVM_X86"}
|
||||
|
||||
diskTypeValues = []string{"B", "T", "D"}
|
||||
|
||||
flipgroupClientTypeValues = []string{"compute", "vins"}
|
||||
|
||||
kvmNetTypeValues = []string{"EXTNET", "VINS", "NONE"}
|
||||
kvmNetTypeValues = []string{"EXTNET", "VINS", "NONE"}
|
||||
kvmx86NetTypeValues = []string{"EXTNET", "VINS", "NONE", "VFNIC", "DPDK"}
|
||||
|
||||
lbAlgorithmValues = []string{"roundrobin", "static-rr", "leastconn"}
|
||||
|
||||
rgDefNetValues = []string{"PRIVATE", "PUBLIC", "NONE"}
|
||||
rgNetTypeValues = []string{"PUBLIC", "PRIVATE"}
|
||||
|
||||
vinsTypeValues = []string{"DHCP", "VIP", "EXCLUDE"}
|
||||
vinsTypeValues = []string{"DHCP", "VIP", "EXCLUDED"}
|
||||
|
||||
imageBootTypeValues = []string{"uefi", "bios"}
|
||||
imageTypeValues = []string{"windows", "linux", "other"}
|
||||
imageDriversValues = []string{"KVM_X86"}
|
||||
imageArchitectureValues = []string{"X86_64", "PPC64_LE"}
|
||||
imageArchitectureValues = []string{"X86_64"}
|
||||
|
||||
sepFieldTypeValues = []string{"int", "str", "bool", "list", "dict"}
|
||||
|
||||
@@ -52,4 +54,20 @@ var (
|
||||
computeFeaturesValues = []string{"hugepages", "numa", "cpupin", "vfnic"}
|
||||
|
||||
networkInterfaceNamingValues = []string{"eth", "ens"}
|
||||
|
||||
numaAffinityValues = []string{"none", "strict", "loose"}
|
||||
|
||||
txModelValues = []string{"iothread", "timer", "selected by hypervisor"}
|
||||
|
||||
ioEventFDValues = []string{"on", "off", "selected by hypervisor"}
|
||||
|
||||
eventIDxValues = []string{"on", "off", "selected by hypervisor"}
|
||||
|
||||
chipsetValues = []string{"i440fx", "Q35"}
|
||||
)
|
||||
|
||||
const (
|
||||
mtuMin = 1
|
||||
|
||||
mtuMax = 9216
|
||||
)
|
||||
|
||||
@@ -50,7 +50,7 @@ func NewLegacy(cfg config.LegacyConfig) *LegacyDecortClient {
|
||||
},
|
||||
},
|
||||
},
|
||||
cfg: cfg,
|
||||
cfg: trimLegacyConfig(&cfg),
|
||||
expiryTime: expiryTime,
|
||||
mutex: &sync.Mutex{},
|
||||
}
|
||||
@@ -73,12 +73,20 @@ func (ldc *LegacyDecortClient) DecortApiCall(ctx context.Context, method, url st
|
||||
return nil, err
|
||||
}
|
||||
|
||||
values, err := query.Values(params)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var body *bytes.Buffer
|
||||
var ctype string
|
||||
|
||||
body := bytes.NewBufferString(values.Encode() + fmt.Sprintf("&authkey=%s", ldc.cfg.Token))
|
||||
byteSlice, ok := params.([]byte)
|
||||
if ok {
|
||||
body = bytes.NewBuffer(byteSlice)
|
||||
ctype = "application/octet-stream"
|
||||
} else {
|
||||
values, err := query.Values(params)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
body = bytes.NewBufferString(values.Encode() + fmt.Sprintf("&authkey=%s", ldc.cfg.Token))
|
||||
}
|
||||
|
||||
req, err := http.NewRequestWithContext(ctx, method, ldc.decortURL+constants.RESTMACHINE+url, body)
|
||||
if err != nil {
|
||||
@@ -86,7 +94,7 @@ func (ldc *LegacyDecortClient) DecortApiCall(ctx context.Context, method, url st
|
||||
}
|
||||
|
||||
// perform request
|
||||
respBytes, err := ldc.do(req, "")
|
||||
respBytes, err := ldc.do(req, ctype)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -233,3 +241,8 @@ func (ldc *LegacyDecortClient) do(req *http.Request, ctype string) ([]byte, erro
|
||||
err = fmt.Errorf("%s", respBytes)
|
||||
return nil, fmt.Errorf("could not execute request: %w", err)
|
||||
}
|
||||
|
||||
func trimLegacyConfig(cfg *config.LegacyConfig) config.LegacyConfig {
|
||||
cfg.DecortURL = strings.TrimSuffix(cfg.DecortURL, "/")
|
||||
return *cfg
|
||||
}
|
||||
|
||||
@@ -17,10 +17,6 @@ type DeleteUserRequest struct {
|
||||
// ID or emailaddress of the user to remove
|
||||
// Required: true
|
||||
UserID string `url:"userId" json:"userId" validate:"required"`
|
||||
|
||||
// Recursively revoke access rights from owned cloudspaces and vmachines
|
||||
// Required: false
|
||||
RecursiveDelete bool `url:"recursivedelete" json:"recursivedelete"`
|
||||
}
|
||||
|
||||
// DeleteUser revokes user access from the account
|
||||
|
||||
@@ -1,58 +0,0 @@
|
||||
package account
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// GetConsumptionRequest struct to download the resources tracking files for an account
|
||||
type GetConsumptionRequest struct {
|
||||
// ID an account
|
||||
// Required: true
|
||||
AccountID uint64 `url:"accountId" json:"accountId" validate:"required"`
|
||||
|
||||
// Epoch represents the start time
|
||||
// Required: true
|
||||
Start float64 `url:"start" json:"start" validate:"required"`
|
||||
|
||||
// Epoch represents the end time
|
||||
// Required: true
|
||||
End float64 `url:"end" json:"end" validate:"required"`
|
||||
}
|
||||
|
||||
// GetConsumption downloads the resources tracking files for an account within a given period
|
||||
func (a Account) GetConsumption(ctx context.Context, req GetConsumptionRequest) (string, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudapi/account/getConsumption"
|
||||
|
||||
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return string(res), nil
|
||||
|
||||
}
|
||||
|
||||
// GetConsumptionGet downloads the resources tracking files for an account within a given period
|
||||
func (a Account) GetConsumptionGet(ctx context.Context, req GetConsumptionRequest) (string, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudapi/account/getConsumption"
|
||||
|
||||
res, err := a.client.DecortApiCall(ctx, http.MethodGet, url, req)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return string(res), nil
|
||||
}
|
||||
@@ -38,6 +38,10 @@ type ListFLIPGroupsRequest struct {
|
||||
// Required: false
|
||||
FLIPGroupID uint64 `url:"flipGroupId,omitempty" json:"flipGroupId,omitempty"`
|
||||
|
||||
// Sort by one of supported fields, format +|-(field)
|
||||
// Required: false
|
||||
SortBy string `url:"sortBy,omitempty" json:"sortBy,omitempty" validate:"omitempty,sortBy"`
|
||||
|
||||
// Page number
|
||||
// Required: false
|
||||
Page uint64 `url:"page,omitempty" json:"page,omitempty"`
|
||||
|
||||
@@ -384,7 +384,7 @@ type ItemVINS struct {
|
||||
ExtnetId uint64 `json:"extnetId"`
|
||||
|
||||
// Free IPs
|
||||
FreeIPs uint64 `json:"freeIPs"`
|
||||
FreeIPs int64 `json:"freeIPs"`
|
||||
|
||||
// ID
|
||||
ID uint64 `json:"id"`
|
||||
|
||||
@@ -45,6 +45,11 @@ type UpdateRequest struct {
|
||||
// Limit (positive) or disable (0) GPU resources
|
||||
// Required: false
|
||||
GPUUnits int64 `url:"gpu_units,omitempty" json:"gpu_units,omitempty"`
|
||||
|
||||
// List of strings with pools
|
||||
// i.e.: ["sep1_poolName1", "sep2_poolName2", etc]
|
||||
// Required: false
|
||||
UniqPools []string `url:"uniqPools,omitempty" json:"uniqPools,omitempty"`
|
||||
}
|
||||
|
||||
// Update updates an account name and resource types and limits
|
||||
|
||||
10
pkg/cloudapi/audit.go
Normal file
10
pkg/cloudapi/audit.go
Normal file
@@ -0,0 +1,10 @@
|
||||
package cloudapi
|
||||
|
||||
import (
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/audit"
|
||||
)
|
||||
|
||||
// Accessing the Stack method group
|
||||
func (ca *CloudAPI) Audit() *audit.Audit {
|
||||
return audit.New(ca.client)
|
||||
}
|
||||
15
pkg/cloudapi/audit/audit.go
Normal file
15
pkg/cloudapi/audit/audit.go
Normal file
@@ -0,0 +1,15 @@
|
||||
package audit
|
||||
|
||||
import "repository.basistech.ru/BASIS/decort-golang-sdk/interfaces"
|
||||
|
||||
// Structure for creating request to audit
|
||||
type Audit struct {
|
||||
client interfaces.Caller
|
||||
}
|
||||
|
||||
// Builder for audit endpoint
|
||||
func New(client interfaces.Caller) *Audit{
|
||||
return &Audit{
|
||||
client: client,
|
||||
}
|
||||
}
|
||||
46
pkg/cloudapi/audit/get.go
Normal file
46
pkg/cloudapi/audit/get.go
Normal file
@@ -0,0 +1,46 @@
|
||||
package audit
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// GetRequest struct to get information about account
|
||||
type GetRequest struct {
|
||||
// Audit GUID
|
||||
// Required: true
|
||||
AuditGuid string `url:"auditGuid" json:"auditGuid" validate:"required"`
|
||||
}
|
||||
|
||||
// Get gets information about audit as a RecordAudit struct
|
||||
func (a Audit) Get(ctx context.Context, req GetRequest) (*RecordAudit, error) {
|
||||
res, err := a.GetRaw(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
info := RecordAudit{}
|
||||
|
||||
err = json.Unmarshal(res, &info)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &info, nil
|
||||
}
|
||||
|
||||
// GetRaw gets information about audit as an array of bytes
|
||||
func (a Audit) GetRaw(ctx context.Context, req GetRequest) ([]byte, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudapi/audit/get"
|
||||
|
||||
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
return res, err
|
||||
}
|
||||
41
pkg/cloudapi/audit/models.go
Normal file
41
pkg/cloudapi/audit/models.go
Normal file
@@ -0,0 +1,41 @@
|
||||
package audit
|
||||
|
||||
// Main info about audit
|
||||
type RecordAudit struct {
|
||||
|
||||
// Arguments
|
||||
Arguments string `json:"args"`
|
||||
|
||||
// Call
|
||||
Call string `json:"call"`
|
||||
|
||||
// GUID
|
||||
GUID string `json:"guid"`
|
||||
|
||||
// Kwargs
|
||||
Kwargs string `json:"kwargs"`
|
||||
|
||||
// RemoteAddr
|
||||
RemoteAddr string `json:"remote_addr"`
|
||||
|
||||
// Response time
|
||||
ResponseTime float64 `json:"responsetime"`
|
||||
|
||||
// Result
|
||||
Result string `json:"result"`
|
||||
|
||||
// Status code
|
||||
StatusCode uint64 `json:"statuscode"`
|
||||
|
||||
// Tags
|
||||
Tags string `json:"tags"`
|
||||
|
||||
// Timestamp
|
||||
Timestamp float64 `json:"timestamp"`
|
||||
|
||||
// TimestampEnd
|
||||
TimestampEnd float64 `json:"timestampEnd"`
|
||||
|
||||
// User
|
||||
User string `json:"user"`
|
||||
}
|
||||
@@ -41,7 +41,6 @@ type GroupAddRequest struct {
|
||||
// Compute driver
|
||||
// should be one of:
|
||||
// - KVM_X86
|
||||
// - KVM_PPC
|
||||
// Required: true
|
||||
Driver string `url:"driver" json:"driver" validate:"driver"`
|
||||
|
||||
|
||||
54
pkg/cloudapi/compute/change_ip.go
Normal file
54
pkg/cloudapi/compute/change_ip.go
Normal file
@@ -0,0 +1,54 @@
|
||||
package compute
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// ChangeIPRequest struct to change IP for network
|
||||
type ChangeIPRequest struct {
|
||||
// ID of compute instance
|
||||
// Required: true
|
||||
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
|
||||
|
||||
// Network type
|
||||
// 'EXTNET' for connect to external network directly
|
||||
// 'VINS' for connect to ViNS
|
||||
// Required: true
|
||||
NetType string `url:"netType" json:"netType" validate:"computeNetType"`
|
||||
|
||||
// Network ID for connect to
|
||||
// For EXTNET - external network ID
|
||||
// For VINS - VINS ID
|
||||
// Required: true
|
||||
NetID uint64 `url:"netId" json:"netId" validate:"required"`
|
||||
|
||||
// IP address to which we will change the existing one, it must be from the same subnet
|
||||
// Required: true
|
||||
IPAddr string `url:"ipAddr" json:"ipAddr" validate:"required"`
|
||||
}
|
||||
|
||||
// ChangeIP change reserved IP for compute instance
|
||||
func (c Compute) ChangeIP(ctx context.Context, req ChangeIPRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudapi/compute/changeIp"
|
||||
|
||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseBool(string(res))
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
@@ -25,6 +25,11 @@ type CloneRequest struct {
|
||||
// Name of the parent's snapshot to create clone from
|
||||
// Required: false
|
||||
SnapshotName string `url:"snapshotName,omitempty" json:"snapshotName,omitempty"`
|
||||
|
||||
// true ignore that the compute is running
|
||||
// Default: false
|
||||
// Required: false
|
||||
Force bool `url:"force" json:"force"`
|
||||
}
|
||||
|
||||
// Clone clones compute instance
|
||||
|
||||
@@ -23,7 +23,7 @@ type CreateTemplateRequest struct {
|
||||
type wrapperCreateTemplateRequest struct {
|
||||
CreateTemplateRequest
|
||||
|
||||
Async bool `url:"async"`
|
||||
AsyncMode bool `url:"asyncMode"`
|
||||
}
|
||||
|
||||
// CreateTemplate create template from compute instance
|
||||
@@ -35,7 +35,7 @@ func (c Compute) CreateTemplate(ctx context.Context, req CreateTemplateRequest)
|
||||
|
||||
reqWrapped := wrapperCreateTemplateRequest{
|
||||
CreateTemplateRequest: req,
|
||||
Async: false,
|
||||
AsyncMode: false,
|
||||
}
|
||||
|
||||
url := "/cloudapi/compute/createTemplate"
|
||||
@@ -62,7 +62,7 @@ func (c Compute) CreateTemplateAsync(ctx context.Context, req CreateTemplateRequ
|
||||
|
||||
reqWrapped := wrapperCreateTemplateRequest{
|
||||
CreateTemplateRequest: req,
|
||||
Async: true,
|
||||
AsyncMode: true,
|
||||
}
|
||||
|
||||
url := "/cloudapi/compute/createTemplate"
|
||||
|
||||
@@ -24,8 +24,8 @@ type DiskMigrateRequest struct {
|
||||
|
||||
// Migration mode. 1 - Data migration and domain update were already completed by third-party software.
|
||||
// Use this if target disk already connected to compute and you only need to save changes for next reboot.
|
||||
// Required: true
|
||||
Mode int64 `url:"mode" json:"mode" validate:"required"`
|
||||
// Required: false
|
||||
Mode int64 `url:"mode,omitempty" json:"mode,omitempty"`
|
||||
}
|
||||
|
||||
// DiskMigrate - migrate compute's disk to target disk. Source disk will be detached, target disk will be attached to the same PCI slot.
|
||||
|
||||
@@ -42,7 +42,7 @@ func (c Compute) GetLogGet(ctx context.Context, req GetLogRequest) (string, erro
|
||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudapi//compute/getLog"
|
||||
url := "/cloudapi/compute/getLog"
|
||||
|
||||
res, err := c.client.DecortApiCall(ctx, http.MethodGet, url, req)
|
||||
if err != nil {
|
||||
|
||||
@@ -214,6 +214,9 @@ type RecordNetAttach struct {
|
||||
|
||||
// List VNF IDs
|
||||
VNFs []uint64 `json:"vnfs"`
|
||||
|
||||
// Maximum transmission unit
|
||||
MTU uint64 `json:"mtu"`
|
||||
}
|
||||
|
||||
// Detailed information about audit
|
||||
@@ -296,6 +299,9 @@ type RecordCompute struct {
|
||||
// List anti affinity rules
|
||||
AntiAffinityRules ListRules `json:"antiAffinityRules"`
|
||||
|
||||
// Auto start when node restarted
|
||||
AutoStart bool `json:"autoStart"`
|
||||
|
||||
// Architecture
|
||||
Architecture string `json:"arch"`
|
||||
|
||||
@@ -305,9 +311,12 @@ type RecordCompute struct {
|
||||
// Boot disk size
|
||||
BootDiskSize uint64 `json:"bootdiskSize"`
|
||||
|
||||
// cd Image Id
|
||||
// CD Image Id
|
||||
CdImageId uint64 `json:"cdImageId"`
|
||||
|
||||
// Chipset
|
||||
Chipset string `json:"chipset"`
|
||||
|
||||
// Clone reference
|
||||
CloneReference uint64 `json:"cloneReference"`
|
||||
|
||||
@@ -431,6 +440,9 @@ type RecordCompute struct {
|
||||
// Resource name
|
||||
ResName string `json:"resName"`
|
||||
|
||||
// Reserved Node Cpus
|
||||
ReservedNodeCpus []uint64 `json:"reservedNodeCpus"`
|
||||
|
||||
// Resource group ID
|
||||
RGID uint64 `json:"rgId"`
|
||||
|
||||
@@ -475,6 +487,33 @@ type RecordCompute struct {
|
||||
|
||||
// Virtual image name
|
||||
VirtualImageName string `json:"virtualImageName"`
|
||||
|
||||
// VNC password
|
||||
VNCPassword string `json:"vncPasswd"`
|
||||
}
|
||||
|
||||
// Information about libvirt settings
|
||||
type LibvirtSettings struct {
|
||||
// TX mode
|
||||
TXMode string `json:"txmode"`
|
||||
|
||||
// IO event
|
||||
IOEventFD string `json:"ioeventfd"`
|
||||
|
||||
// Event ID
|
||||
EventIDx string `json:"event_idx"`
|
||||
|
||||
// Number of queues
|
||||
Queues uint64 `json:"queues"`
|
||||
|
||||
// RX queue size
|
||||
RXQueueSize uint64 `json:"rx_queue_size"`
|
||||
|
||||
// TX queue size
|
||||
TXQueueSize uint64 `json:"tx_queue_size"`
|
||||
|
||||
// GUID
|
||||
GUID string `json:"guid"`
|
||||
}
|
||||
|
||||
// Main information about OS user
|
||||
@@ -515,6 +554,9 @@ type ListSnapSets []ItemSnapSet
|
||||
|
||||
// Main information about VNF
|
||||
type ItemVNFInterface struct {
|
||||
// Bus number
|
||||
BusNumber uint64 `json:"bus_number"`
|
||||
|
||||
// Connection ID
|
||||
ConnID uint64 `json:"connId"`
|
||||
|
||||
@@ -539,9 +581,15 @@ type ItemVNFInterface struct {
|
||||
// Listen SSH or not
|
||||
ListenSSH bool `json:"listenSsh"`
|
||||
|
||||
// Libvirt Settings
|
||||
LibvirtSettings LibvirtSettings `json:"libvirtSettings"`
|
||||
|
||||
// MAC
|
||||
MAC string `json:"mac"`
|
||||
|
||||
// Maximum transmission unit
|
||||
MTU uint64 `json:"mtu"`
|
||||
|
||||
// Name
|
||||
Name string `json:"name"`
|
||||
|
||||
@@ -600,6 +648,9 @@ type ItemComputeDisk struct {
|
||||
// Boot partition
|
||||
BootPartition uint64 `json:"bootPartition"`
|
||||
|
||||
// Bus number
|
||||
BusNumber uint64 `json:"bus_number"`
|
||||
|
||||
// Created time
|
||||
CreatedTime uint64 `json:"createdTime"`
|
||||
|
||||
@@ -673,7 +724,7 @@ type ItemComputeDisk struct {
|
||||
RealityDeviceNumber uint64 `json:"realityDeviceNumber"`
|
||||
|
||||
// Replication
|
||||
Replication interface{} `json:"replication"`
|
||||
Replication ItemReplication `json:"replication"`
|
||||
|
||||
// Resource ID
|
||||
ResID string `json:"resId"`
|
||||
@@ -709,6 +760,26 @@ type ItemComputeDisk struct {
|
||||
VMID uint64 `json:"vmid"`
|
||||
}
|
||||
|
||||
type ItemReplication struct {
|
||||
// DiskID
|
||||
DiskID uint64 `json:"diskId"`
|
||||
|
||||
// PoolID
|
||||
PoolID string `json:"poolId"`
|
||||
|
||||
// Role
|
||||
Role string `json:"role"`
|
||||
|
||||
// SelfVolumeID
|
||||
SelfVolumeID string `json:"selfVolumeId"`
|
||||
|
||||
// StorageID
|
||||
StorageID string `json:"storageId"`
|
||||
|
||||
// VolumeID
|
||||
VolumeID string `json:"volumeId"`
|
||||
}
|
||||
|
||||
// Main information about snapshot extend
|
||||
type SnapshotExtend struct {
|
||||
// GUID
|
||||
@@ -801,6 +872,9 @@ type ItemCompute struct {
|
||||
// List anti affinity rules
|
||||
AntiAffinityRules ListRules `json:"antiAffinityRules"`
|
||||
|
||||
// Auto start when node restarted
|
||||
AutoStart bool `json:"autoStart"`
|
||||
|
||||
// Architecture
|
||||
Architecture string `json:"arch"`
|
||||
|
||||
@@ -810,9 +884,12 @@ type ItemCompute struct {
|
||||
// Boot disk size
|
||||
BootDiskSize uint64 `json:"bootdiskSize"`
|
||||
|
||||
// cd Image Id
|
||||
// CD Image Id
|
||||
CdImageId uint64 `json:"cdImageId"`
|
||||
|
||||
// Chipset
|
||||
Chipset string `json:"chipset"`
|
||||
|
||||
// Clone reference
|
||||
CloneReference uint64 `json:"cloneReference"`
|
||||
|
||||
@@ -915,6 +992,9 @@ type ItemCompute struct {
|
||||
// Resource name
|
||||
ResName string `json:"resName"`
|
||||
|
||||
// Reserved Node Cpus
|
||||
ReservedNodeCpus []uint64 `json:"reservedNodeCpus"`
|
||||
|
||||
// Resource group ID
|
||||
RGID uint64 `json:"rgId"`
|
||||
|
||||
@@ -971,6 +1051,9 @@ type InfoDisk struct {
|
||||
|
||||
// PCISlot
|
||||
PCISlot int64 `json:"pciSlot"`
|
||||
|
||||
// Bus number
|
||||
BusNumber uint64 `json:"bus_number"`
|
||||
}
|
||||
|
||||
// List information about computes
|
||||
@@ -1085,6 +1168,7 @@ type ItemPCIDevice struct {
|
||||
type ListPCIDevices struct {
|
||||
// Data
|
||||
Data []ItemPCIDevice `json:"data"`
|
||||
|
||||
// Entry count
|
||||
EntryCount uint64 `json:"entryCount"`
|
||||
}
|
||||
|
||||
@@ -16,9 +16,11 @@ type NetAttachRequest struct {
|
||||
|
||||
// Network type
|
||||
// 'EXTNET' for connect to external network directly
|
||||
// and 'VINS' for connect to ViNS
|
||||
// 'VINS' for connect to ViNS
|
||||
// 'VFNIC' for connect to vfpool
|
||||
// 'DPDK' for connect to DPDK
|
||||
// Required: true
|
||||
NetType string `url:"netType" json:"netType" validate:"computeNetType"`
|
||||
NetType string `url:"netType" json:"netType" validate:"computex86NetType"`
|
||||
|
||||
// Network ID for connect to
|
||||
// For EXTNET - external network ID
|
||||
@@ -29,6 +31,10 @@ type NetAttachRequest struct {
|
||||
// Directly required IP address for new network interface
|
||||
// Required: false
|
||||
IPAddr string `url:"ipAddr,omitempty" json:"ipAddr,omitempty"`
|
||||
|
||||
// Used only for DPDK type, must be 1-9216
|
||||
// Required: false
|
||||
MTU uint64 `url:"mtu,omitempty" json:"mtu,omitempty" validate:"omitempty,mtu"`
|
||||
}
|
||||
|
||||
// NetAttach attaches network to compute and gets info about network
|
||||
|
||||
@@ -13,25 +13,30 @@ type PinToStackRequest struct {
|
||||
// ID of the compute instance
|
||||
// Required: true
|
||||
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
|
||||
|
||||
// Auto start when node restarted
|
||||
// Required: false
|
||||
// Default: false
|
||||
AutoStart bool `url:"autoStart" json:"autoStart"`
|
||||
}
|
||||
|
||||
// PinToStack pin compute to current stack
|
||||
func (c Compute) PinToStack(ctx context.Context, req PinToStackRequest) (uint64, error) {
|
||||
func (c Compute) PinToStack(ctx context.Context, req PinToStackRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return 0, validators.ValidationErrors(validators.GetErrors(err))
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudapi/compute/pinToStack"
|
||||
|
||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
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 {
|
||||
return 0, err
|
||||
return false, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
|
||||
@@ -3,7 +3,6 @@ package compute
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
@@ -19,24 +18,52 @@ type SnapshotDeleteRequest struct {
|
||||
Label string `url:"label" json:"label" validate:"required"`
|
||||
}
|
||||
|
||||
type wrapperSnapshotDeleteRequeststruct struct {
|
||||
SnapshotDeleteRequest
|
||||
|
||||
AsyncMode bool `url:"asyncMode"`
|
||||
}
|
||||
|
||||
// SnapshotDelete deletes specified compute snapshot
|
||||
func (c Compute) SnapshotDelete(ctx context.Context, req SnapshotDeleteRequest) (bool, error) {
|
||||
func (c Compute) SnapshotDelete(ctx context.Context, req SnapshotDeleteRequest) (string, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
reqWrapped := wrapperSnapshotDeleteRequeststruct{
|
||||
SnapshotDeleteRequest: req,
|
||||
AsyncMode: false,
|
||||
}
|
||||
|
||||
url := "/cloudapi/compute/snapshotDelete"
|
||||
|
||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
||||
if err != nil {
|
||||
return false, err
|
||||
return "", err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseBool(string(res))
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
return string(res), nil
|
||||
}
|
||||
|
||||
// SnapshotDeleteAsync deletes specified compute snapshot
|
||||
func (c Compute) SnapshotDeleteAsync(ctx context.Context, req SnapshotDeleteRequest) (string, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
reqWrapped := wrapperSnapshotDeleteRequeststruct{
|
||||
SnapshotDeleteRequest: req,
|
||||
AsyncMode: true,
|
||||
}
|
||||
|
||||
url := "/cloudapi/compute/snapshotDelete"
|
||||
|
||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return string(res), nil
|
||||
}
|
||||
|
||||
@@ -21,6 +21,33 @@ type UpdateRequest struct {
|
||||
// New description
|
||||
// Required: false
|
||||
Description string `url:"desc,omitempty" json:"desc,omitempty"`
|
||||
|
||||
// Rule for VM placement with NUMA affinity.
|
||||
// Possible values - none (placement without NUMA affinity),
|
||||
// strict (strictly with NUMA affinity, if not possible - do not start VM),
|
||||
// loose (use NUMA affinity if possible)
|
||||
// Required: false
|
||||
// Default: none
|
||||
NumaAffinity string `url:"numaAffinity,omitempty" json:"numaAffinity,omitempty" validate:"omitempty,numaAffinity"`
|
||||
|
||||
// Run VM on dedicated CPUs. To use this feature, the system must be pre-configured by allocating CPUs on the physical node
|
||||
// Required: false
|
||||
// Default: false
|
||||
CPUPin bool `url:"cpupin" json:"cpupin"`
|
||||
|
||||
// Type of the emulated system, Q35 or i440fx
|
||||
// Required: false
|
||||
Chipset string `url:"chipset,omitempty" json:"chipset,omitempty" validate:"omitempty,chipset"`
|
||||
|
||||
// Use Huge Pages to allocate RAM of the virtual machine. The system must be pre-configured by allocating Huge Pages on the physical node
|
||||
// Required: false
|
||||
// Default: false
|
||||
HPBacked bool `url:"hpBacked" json:"hpBacked"`
|
||||
|
||||
// Auto start when node restarted
|
||||
// Required: false
|
||||
// Default: false
|
||||
AutoStart bool `url:"autoStart" json:"autoStart"`
|
||||
}
|
||||
|
||||
// Update updates some properties of the compute
|
||||
|
||||
@@ -21,10 +21,6 @@ type DeleteRequest struct {
|
||||
// Whether to completely delete the disk, works only with non attached disks
|
||||
// Required: false
|
||||
Permanently bool `url:"permanently,omitempty" json:"permanently,omitempty"`
|
||||
|
||||
// Reason to delete
|
||||
// Required: false
|
||||
Reason string `url:"reason,omitempty" json:"reason,omitempty"`
|
||||
}
|
||||
|
||||
// Delete deletes disk by ID
|
||||
|
||||
@@ -14,10 +14,6 @@ type DisksDeleteRequest struct {
|
||||
// Required: true
|
||||
DisksIDs []uint64 `url:"diskIds" json:"diskIds" validate:"required"`
|
||||
|
||||
// Reason for deleting the disks
|
||||
// Required: true
|
||||
Reason string `url:"reason" json:"reason" validate:"required"`
|
||||
|
||||
// Whether to completely delete the disks, works only with non attached disks
|
||||
// Required: false
|
||||
Permanently bool `url:"permanently,omitempty" json:"permanently,omitempty"`
|
||||
|
||||
@@ -30,7 +30,6 @@ type FromPlatformDiskRequest struct {
|
||||
// Binary architecture of this image
|
||||
// Should be:
|
||||
// - X86_64
|
||||
// - PPC64_LE
|
||||
// Required: true
|
||||
Architecture string `url:"architecture" json:"architecture" validate:"imageArchitecture"`
|
||||
|
||||
@@ -56,8 +55,8 @@ type FromPlatformDiskRequest struct {
|
||||
|
||||
// List of types of compute suitable for image
|
||||
// Example: [ "KVM_X86" ]
|
||||
// Required: false
|
||||
Drivers []string `url:"drivers" json:"drivers" validate:"min=1,max=2,imageDrivers"`
|
||||
// Required: true
|
||||
Drivers []string `url:"drivers" json:"drivers" validate:"required"`
|
||||
|
||||
// Does this machine supports hot resize
|
||||
// Required: false
|
||||
|
||||
@@ -32,7 +32,7 @@ type ListRequest struct {
|
||||
|
||||
// Find by shared, true or false
|
||||
// Required: false
|
||||
Shared bool `url:"shared,omitempty" json:"shared,omitempty"`
|
||||
Shared interface{} `url:"shared,omitempty" json:"shared,omitempty" validate:"omitempty,isBool"`
|
||||
|
||||
// ID of the account the disks belong to
|
||||
// Required: false
|
||||
|
||||
@@ -28,7 +28,7 @@ type ListDeletedRequest struct {
|
||||
|
||||
// Find by shared, true or false
|
||||
// Required: false
|
||||
Shared bool `url:"shared,omitempty" json:"shared,omitempty"`
|
||||
Shared interface{} `url:"shared,omitempty" json:"shared,omitempty" validate:"omitempty,isBool"`
|
||||
|
||||
// ID of the account the disks belong to
|
||||
// Required: false
|
||||
|
||||
@@ -75,7 +75,7 @@ type ItemDisk struct {
|
||||
PurgeTime uint64 `json:"purgeTime"`
|
||||
|
||||
// Replication
|
||||
Replication interface{} `json:"replication"`
|
||||
Replication ItemReplication `json:"replication"`
|
||||
|
||||
// Resource ID
|
||||
ResID string `json:"resId"`
|
||||
@@ -265,8 +265,10 @@ type ListDisks struct {
|
||||
|
||||
// List of unattached disks
|
||||
type ListDisksUnattached struct {
|
||||
// Data
|
||||
Data []ItemDiskUnattached `json:"data"`
|
||||
|
||||
// Entry count
|
||||
EntryCount uint64 `json:"entryCount"`
|
||||
}
|
||||
|
||||
@@ -407,7 +409,7 @@ type RecordDisk struct {
|
||||
PurgeTime uint64 `json:"purgeTime"`
|
||||
|
||||
// Replication
|
||||
Replication interface{} `json:"replication"`
|
||||
Replication ItemReplication `json:"replication"`
|
||||
|
||||
// Resource ID
|
||||
ResID string `json:"resId"`
|
||||
@@ -449,6 +451,26 @@ type RecordDisk struct {
|
||||
VMID uint64 `json:"vmid"`
|
||||
}
|
||||
|
||||
type ItemReplication struct {
|
||||
// DiskID
|
||||
DiskID uint64 `json:"diskId"`
|
||||
|
||||
// PoolID
|
||||
PoolID string `json:"poolId"`
|
||||
|
||||
// Role
|
||||
Role string `json:"role"`
|
||||
|
||||
// SelfVolumeID
|
||||
SelfVolumeID string `json:"selfVolumeId"`
|
||||
|
||||
// StorageID
|
||||
StorageID string `json:"storageId"`
|
||||
|
||||
// VolumeID
|
||||
VolumeID string `json:"volumeId"`
|
||||
}
|
||||
|
||||
type ListTypes struct {
|
||||
// Data
|
||||
Data []interface{} `json:"data"`
|
||||
|
||||
@@ -15,23 +15,18 @@ type ReplicationStatusRequest struct {
|
||||
}
|
||||
|
||||
// ReplicationStatus get replication status
|
||||
func (d Disks) ReplicationStatus(ctx context.Context, req ReplicationStatusRequest) (interface{}, error) {
|
||||
func (d Disks) ReplicationStatus(ctx context.Context, req ReplicationStatusRequest) (string, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudapi/disks/replicationStatus"
|
||||
|
||||
res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return "", err
|
||||
}
|
||||
|
||||
// result, err := strconv.ParseBool(string(res))
|
||||
// if err != nil {
|
||||
// return nil, err
|
||||
// }
|
||||
|
||||
return res, nil
|
||||
return string(res), nil
|
||||
}
|
||||
|
||||
@@ -19,31 +19,6 @@ type ResizeRequest struct {
|
||||
Size uint64 `url:"size" json:"size" validate:"required"`
|
||||
}
|
||||
|
||||
// Resize resizes disk
|
||||
// Returns 200 if disk is resized online, else will return 202,
|
||||
// in that case please stop and start your machine after changing the disk size, for your changes to be reflected.
|
||||
// This method will not be used for disks, assigned to computes. Only unassigned disks and disks, assigned with "old" virtual machines.
|
||||
func (d Disks) Resize(ctx context.Context, req ResizeRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudapi/disks/resize"
|
||||
|
||||
res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseBool(string(res))
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// Resize2 resize disk
|
||||
// Returns 200 if disk is resized online, else will return 202,
|
||||
// in that case please stop and start your machine after changing the disk size, for your changes to be reflected.
|
||||
|
||||
@@ -13,10 +13,6 @@ type RestoreRequest struct {
|
||||
// ID of the disk to restore
|
||||
// Required: true
|
||||
DiskID uint64 `url:"diskId" json:"diskId" validate:"required"`
|
||||
|
||||
// Reason for restoring the disk
|
||||
// Required: true
|
||||
Reason string `url:"reason" json:"reason" validate:"required"`
|
||||
}
|
||||
|
||||
// Restore restores a deleted unattached disk from recycle bin
|
||||
|
||||
8
pkg/cloudapi/dpdknet.go
Normal file
8
pkg/cloudapi/dpdknet.go
Normal file
@@ -0,0 +1,8 @@
|
||||
package cloudapi
|
||||
|
||||
import "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/dpdknet"
|
||||
|
||||
// Accessing the DPDKNet method group
|
||||
func (ca *CloudAPI) DPDKNet() *dpdknet.DPDKNet {
|
||||
return dpdknet.New(ca.client)
|
||||
}
|
||||
15
pkg/cloudapi/dpdknet/dpdknet.go
Normal file
15
pkg/cloudapi/dpdknet/dpdknet.go
Normal file
@@ -0,0 +1,15 @@
|
||||
package dpdknet
|
||||
|
||||
import "repository.basistech.ru/BASIS/decort-golang-sdk/interfaces"
|
||||
|
||||
// Structure for creating request to DPDK network
|
||||
type DPDKNet struct {
|
||||
client interfaces.Caller
|
||||
}
|
||||
|
||||
// Builder for dpdk endpoints
|
||||
func New(client interfaces.Caller) *DPDKNet {
|
||||
return &DPDKNet{
|
||||
client,
|
||||
}
|
||||
}
|
||||
46
pkg/cloudapi/dpdknet/get.go
Normal file
46
pkg/cloudapi/dpdknet/get.go
Normal file
@@ -0,0 +1,46 @@
|
||||
package dpdknet
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// GetRequest struct to get information about DPDK network
|
||||
type GetRequest struct {
|
||||
// ID of the DPDK network
|
||||
// Required: true
|
||||
DPDKID uint64 `url:"dpdkId" json:"dpdkId" validate:"required"`
|
||||
}
|
||||
|
||||
// Get DPDK network details as a RecordDPDKNet struct
|
||||
func (d DPDKNet) Get(ctx context.Context, req GetRequest) (*RecordDPDKNet, error) {
|
||||
res, err := d.GetRaw(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
info := RecordDPDKNet{}
|
||||
|
||||
err = json.Unmarshal(res, &info)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &info, nil
|
||||
}
|
||||
|
||||
// GetRaw gets DPDK network details as an array of bytes
|
||||
func (d DPDKNet) GetRaw(ctx context.Context, req GetRequest) ([]byte, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudapi/dpdknet/get"
|
||||
|
||||
res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
return res, err
|
||||
}
|
||||
79
pkg/cloudapi/dpdknet/list.go
Normal file
79
pkg/cloudapi/dpdknet/list.go
Normal file
@@ -0,0 +1,79 @@
|
||||
package dpdknet
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// ListRequest struct to get list of DPDK networks
|
||||
type ListRequest struct {
|
||||
// Find by id
|
||||
// Required: false
|
||||
ByID uint64 `url:"by_id,omitempty" json:"by_id,omitempty"`
|
||||
|
||||
// Find by gid
|
||||
// Required: false
|
||||
GID uint64 `url:"gid,omitempty" json:"gid,omitempty"`
|
||||
|
||||
// Find by name
|
||||
// Required: false
|
||||
Name string `url:"name,omitempty" json:"name,omitempty"`
|
||||
|
||||
// Find by description
|
||||
// Required: false
|
||||
Description string `url:"description,omitempty" json:"description,omitempty"`
|
||||
|
||||
// Find by status
|
||||
// Required: false
|
||||
Status string `url:"status,omitempty" json:"status,omitempty"`
|
||||
|
||||
// Find by computeIDs
|
||||
// Required: false
|
||||
ComputeIDs []uint64 `url:"computeIds,omitempty" json:"computeIds,omitempty"`
|
||||
|
||||
// Sort by one of supported fields, format +|-(field)
|
||||
// Required: false
|
||||
SortBy string `url:"sortBy,omitempty" json:"sortBy,omitempty" validate:"omitempty,sortBy"`
|
||||
|
||||
// Page number
|
||||
// Required: false
|
||||
Page uint64 `url:"page,omitempty" json:"page,omitempty"`
|
||||
|
||||
// Page size
|
||||
// Required: false
|
||||
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
||||
}
|
||||
|
||||
// List gets list of the created DPDK networks belonging to an account as a ListDPDKNet struct
|
||||
func (d DPDKNet) List(ctx context.Context, req ListRequest) (*ListDPDKNet, error) {
|
||||
|
||||
res, err := d.ListRaw(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
list := ListDPDKNet{}
|
||||
|
||||
err = json.Unmarshal(res, &list)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &list, nil
|
||||
}
|
||||
|
||||
// ListRaw gets list of the created DPDK networks belonging to an account as an array of bytes
|
||||
func (d DPDKNet) ListRaw(ctx context.Context, req ListRequest) ([]byte, error) {
|
||||
|
||||
if err := validators.ValidateRequest(req); err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudapi/dpdknet/list"
|
||||
|
||||
res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
return res, err
|
||||
}
|
||||
92
pkg/cloudapi/dpdknet/models.go
Normal file
92
pkg/cloudapi/dpdknet/models.go
Normal file
@@ -0,0 +1,92 @@
|
||||
package dpdknet
|
||||
|
||||
// Detailed information about DPDK network
|
||||
type RecordDPDKNet struct {
|
||||
// List of accounts with access
|
||||
AccountAccess []uint64 `json:"accountAccess"`
|
||||
|
||||
// Created time
|
||||
CreatedTime uint64 `json:"createdTime"`
|
||||
|
||||
// Updated time
|
||||
UpdatedTime uint64 `json:"updatedTime"`
|
||||
|
||||
// Description
|
||||
Description string `json:"description"`
|
||||
|
||||
// Grid ID
|
||||
GID uint64 `json:"gid"`
|
||||
|
||||
// Guid ID
|
||||
GUID uint64 `json:"guid"`
|
||||
|
||||
// ID
|
||||
ID uint64 `json:"id"`
|
||||
|
||||
// Name
|
||||
Name string `json:"name"`
|
||||
|
||||
// List of resource groups with access
|
||||
RGAccess []uint64 `json:"rgAccess"`
|
||||
|
||||
// Status
|
||||
Status string `json:"status"`
|
||||
|
||||
// OVS bridge
|
||||
OVSBridge string `json:"ovsBridge"`
|
||||
|
||||
// Vlan ID
|
||||
VlanID uint64 `json:"vlanId"`
|
||||
|
||||
// Compute IDs
|
||||
ComputeIDs []uint64 `json:"computeIds"`
|
||||
}
|
||||
|
||||
type ListDPDKNet struct {
|
||||
// Data
|
||||
Data []ItemDPDKNet `json:"data"`
|
||||
|
||||
// Entry count
|
||||
EntryCount uint64 `json:"entryCount"`
|
||||
}
|
||||
|
||||
type ItemDPDKNet struct {
|
||||
// List of accounts with access
|
||||
AccountAccess []uint64 `json:"accountAccess"`
|
||||
|
||||
// Created time
|
||||
CreatedTime uint64 `json:"createdTime"`
|
||||
|
||||
// Updated time
|
||||
UpdatedTime uint64 `json:"updatedTime"`
|
||||
|
||||
// Description
|
||||
Description string `json:"description"`
|
||||
|
||||
// Grid ID
|
||||
GID uint64 `json:"gid"`
|
||||
|
||||
// Guid ID
|
||||
GUID uint64 `json:"guid"`
|
||||
|
||||
// ID
|
||||
ID uint64 `json:"id"`
|
||||
|
||||
// Name
|
||||
Name string `json:"name"`
|
||||
|
||||
// List of resource groups with access
|
||||
RGAccess []uint64 `json:"rgAccess"`
|
||||
|
||||
// Status
|
||||
Status string `json:"status"`
|
||||
|
||||
// OVS bridge
|
||||
OVSBridge string `json:"ovsBridge"`
|
||||
|
||||
// Vlan ID
|
||||
VlanID uint64 `json:"vlanId"`
|
||||
|
||||
// Compute IDs
|
||||
ComputeIDs []uint64 `json:"computeIds"`
|
||||
}
|
||||
50
pkg/cloudapi/extnet/get_reserved_ip.go
Normal file
50
pkg/cloudapi/extnet/get_reserved_ip.go
Normal file
@@ -0,0 +1,50 @@
|
||||
package extnet
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// GetRequest struct to get information about reserved address or address poll
|
||||
type GetReservedIP struct {
|
||||
// AccountID of the account whose reservation information we want to receive
|
||||
// Required: true
|
||||
AccountID uint64 `url:"accountId" json:"accountId" validate:"required"`
|
||||
|
||||
// Field for specifying the ID of extnet whose reservation information we want to receive
|
||||
// Required: false
|
||||
ExtNetID uint64 `url:"extnetId,omitempty" json:"extnetId,omitempty"`
|
||||
}
|
||||
|
||||
// GetReservedIP gets information about reserved address or address poll as a slice of RecordReservedIP struct
|
||||
func (e ExtNet) GetReservedIP(ctx context.Context, req GetReservedIP) ([]RecordReservedIP, error) {
|
||||
res, err := e.GetReservedIPRaw(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
reservedIP := make([]RecordReservedIP, 0)
|
||||
|
||||
err = json.Unmarshal(res, &reservedIP)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return reservedIP, nil
|
||||
}
|
||||
|
||||
// GetRaw gets detailed information about external network as an array of bytes
|
||||
func (e ExtNet) GetReservedIPRaw(ctx context.Context, req GetReservedIP) ([]byte, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudapi/extnet/getReservedIp"
|
||||
|
||||
res, err := e.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
return res, err
|
||||
}
|
||||
@@ -87,6 +87,9 @@ type QOS struct {
|
||||
|
||||
// Main information about reservations
|
||||
type ItemReservation struct {
|
||||
// Account ID
|
||||
AccountID uint64 `json:"account_id"`
|
||||
|
||||
// ClientType
|
||||
ClientType string `json:"clientType"`
|
||||
|
||||
@@ -170,7 +173,7 @@ type RecordExtNet struct {
|
||||
Excluded []Excluded `json:"excluded"`
|
||||
|
||||
// Free IPs
|
||||
FreeIPs uint64 `json:"free_ips"`
|
||||
FreeIPs int64 `json:"free_ips"`
|
||||
|
||||
// Gateway
|
||||
Gateway string `json:"gateway"`
|
||||
@@ -226,3 +229,20 @@ type RecordExtNet struct {
|
||||
// VNFs
|
||||
VNFs VNFs `json:"vnfs"`
|
||||
}
|
||||
|
||||
// Detailed information about reserved address or address pool
|
||||
type RecordReservedIP struct {
|
||||
ExtnetID int `json:"extnet_id"`
|
||||
Reservations []Reservations `json:"reservations"`
|
||||
}
|
||||
|
||||
type Reservations struct {
|
||||
AccountID int `json:"account_id"`
|
||||
ClientType string `json:"clientType"`
|
||||
DomainName string `json:"domainname"`
|
||||
Hostname string `json:"hostname"`
|
||||
IP string `json:"ip"`
|
||||
Mac string `json:"mac"`
|
||||
Type string `json:"type"`
|
||||
VMID int `json:"vmId"`
|
||||
}
|
||||
|
||||
@@ -42,6 +42,10 @@ type ListRequest struct {
|
||||
// Required: false
|
||||
ByID uint64 `url:"by_id,omitempty" json:"by_id,omitempty"`
|
||||
|
||||
// Find by list of clientIds
|
||||
// Required: false
|
||||
ClientIDs []uint64 `url:"clientIds,omitempty" json:"clientIds,omitempty"`
|
||||
|
||||
// Page number
|
||||
// Required: false
|
||||
Page uint64 `url:"page,omitempty" json:"page,omitempty"`
|
||||
|
||||
@@ -72,7 +72,6 @@ type CreateRequest struct {
|
||||
// Binary architecture of this image
|
||||
// Should be:
|
||||
// - X86_64
|
||||
// - PPC64_LE
|
||||
// Required: false
|
||||
Architecture string `url:"architecture,omitempty" json:"architecture,omitempty" validate:"omitempty,imageArchitecture"`
|
||||
|
||||
|
||||
@@ -13,10 +13,6 @@ type DeleteRequest struct {
|
||||
// ID of the image to delete
|
||||
// Required: true
|
||||
ImageID uint64 `url:"imageId" json:"imageId" validate:"required"`
|
||||
|
||||
// Whether to completely delete the image
|
||||
// Required: false
|
||||
Permanently bool `url:"permanently,omitempty" json:"permanently,omitempty"`
|
||||
}
|
||||
|
||||
// Delete deletes image by ID
|
||||
|
||||
@@ -48,15 +48,15 @@ type ListRequest struct {
|
||||
|
||||
// Find by public True or False
|
||||
// Required: false
|
||||
Public bool `url:"public,omitempty" json:"public,omitempty"`
|
||||
Public interface{} `url:"public,omitempty" json:"public,omitempty" validate:"omitempty,isBool"`
|
||||
|
||||
// Find by hot resize True or False
|
||||
// Required: false
|
||||
HotResize bool `url:"hotResize,omitempty" json:"hotResize,omitempty"`
|
||||
HotResize interface{} `url:"hotResize,omitempty" json:"hotResize,omitempty" validate:"omitempty,isBool"`
|
||||
|
||||
// Find by bootable True or False
|
||||
// Required: false
|
||||
Bootable bool `url:"bootable,omitempty" json:"bootable,omitempty"`
|
||||
Bootable interface{} `url:"bootable,omitempty" json:"bootable,omitempty" validate:"omitempty,isBool"`
|
||||
|
||||
// Sort by one of supported fields, format +|-(field)
|
||||
// Required: false
|
||||
@@ -69,6 +69,10 @@ type ListRequest struct {
|
||||
// Page size
|
||||
// Required: false
|
||||
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
||||
|
||||
// Find by enabled True or False
|
||||
// Required: false
|
||||
Enabled interface{} `url:"enabled,omitempty" json:"enabled,omitempty" validate:"omitempty,isBool"`
|
||||
}
|
||||
|
||||
// List gets list of available images as a ListImages struct, optionally filtering by account ID
|
||||
|
||||
@@ -162,6 +162,10 @@ type CreateRequest struct {
|
||||
// Insert ssl certificate in x509 pem format
|
||||
// Required: false
|
||||
OidcCertificate string `url:"oidcCertificate,omitempty" json:"oidcCertificate,omitempty"`
|
||||
|
||||
// Type of the emulated system, Q35 or i440fx
|
||||
// Required: false
|
||||
Chipset string `url:"chipset,omitempty" json:"chipset,omitempty" validate:"omitempty,chipset"`
|
||||
}
|
||||
|
||||
// GetRAM returns RAM field values
|
||||
|
||||
@@ -20,7 +20,7 @@ type DeleteMasterFromGroupRequest struct {
|
||||
|
||||
// List of Compute IDs of master nodes to delete
|
||||
// Required: true
|
||||
MasterIDs []string `url:"masterIds" json:"masterIds" validate:"min=1"`
|
||||
MasterIDs []uint64 `url:"masterIds" json:"masterIds" validate:"min=1"`
|
||||
}
|
||||
|
||||
// DeleteMasterFromGroup deletes compute from masters group in selected Kubernetes cluster
|
||||
|
||||
@@ -89,6 +89,15 @@ type RecordK8S struct {
|
||||
// Deleted time
|
||||
DeletedTime uint64 `json:"deletedTime"`
|
||||
|
||||
// Only external network
|
||||
ExtnetOnly bool `json:"extnetOnly"`
|
||||
|
||||
// Highly available LB
|
||||
HighlyAvailableLB bool `json:"highlyAvailableLB"`
|
||||
|
||||
// Address Virtual Internet Protocol
|
||||
AddressVIP K8SAddressVIP `json:"addressVip"`
|
||||
|
||||
// ID
|
||||
ID uint64 `json:"id"`
|
||||
|
||||
@@ -124,6 +133,18 @@ type RecordK8S struct {
|
||||
|
||||
// Updated time
|
||||
UpdatedTime uint64 `json:"updatedTime"`
|
||||
|
||||
// With LB
|
||||
WithLB bool `json:"withLB"`
|
||||
}
|
||||
|
||||
// Detailed information about address of the Virtual Internet Protocol
|
||||
type K8SAddressVIP struct {
|
||||
// Backend IP
|
||||
BackendIP string `json:"backendIp"`
|
||||
|
||||
// Frontend IP
|
||||
FrontendIP string `json:"frontendIp"`
|
||||
}
|
||||
|
||||
// Detailed information about kubernetes cluster groups
|
||||
|
||||
@@ -21,6 +21,10 @@ type WorkerAddRequest struct {
|
||||
// How many worker nodes to add
|
||||
// Required: false
|
||||
Num uint64 `url:"num,omitempty" json:"num,omitempty"`
|
||||
|
||||
// Type of the emulated system, Q35 or i440fx
|
||||
// Required: false
|
||||
Chipset string `url:"chipset,omitempty" json:"chipset,omitempty" validate:"omitempty,chipset"`
|
||||
}
|
||||
|
||||
// WorkerAdd adds worker nodes to a Kubernetes cluster
|
||||
|
||||
@@ -3,7 +3,6 @@ package k8s
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
@@ -60,6 +59,10 @@ type WorkersGroupAddRequest struct {
|
||||
// Meta data for working group computes, format YAML "user_data": 1111
|
||||
// Required: false
|
||||
UserData string `url:"userData,omitempty" json:"userData,omitempty"`
|
||||
|
||||
// Type of the emulated system, Q35 or i440fx
|
||||
// Required: false
|
||||
Chipset string `url:"chipset,omitempty" json:"chipset,omitempty" validate:"omitempty,chipset"`
|
||||
}
|
||||
|
||||
// GetRAM returns RAM field values
|
||||
@@ -73,23 +76,18 @@ func (r WorkersGroupAddRequest) GetRAM() map[string]uint64 {
|
||||
}
|
||||
|
||||
// WorkersGroupAdd adds workers group to Kubernetes cluster
|
||||
func (k8s K8S) WorkersGroupAdd(ctx context.Context, req WorkersGroupAddRequest) (uint64, error) {
|
||||
func (k8s K8S) WorkersGroupAdd(ctx context.Context, req WorkersGroupAddRequest) (string, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return 0, validators.ValidationErrors(validators.GetErrors(err))
|
||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudapi/k8s/workersGroupAdd"
|
||||
|
||||
res, err := k8s.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
return "", err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseUint(string(res), 10, 64)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
return string(res), nil
|
||||
}
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
package cloudapi
|
||||
|
||||
import "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/kvmppc"
|
||||
|
||||
// Accessing the KVMPPC method group
|
||||
func (ca *CloudAPI) KVMPPC() *kvmppc.KVMPPC {
|
||||
return kvmppc.New(ca.client)
|
||||
}
|
||||
@@ -1,202 +0,0 @@
|
||||
package kvmppc
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
type Interface struct {
|
||||
// Network type
|
||||
// Should be one of:
|
||||
// - VINS
|
||||
// - EXTNET
|
||||
NetType string `url:"netType" json:"netType" validate:"required,kvmNetType"`
|
||||
|
||||
// Network ID for connect to,
|
||||
// for EXTNET - external network ID,
|
||||
// for VINS - VINS ID,
|
||||
NetID uint64 `url:"netId" json:"netId" validate:"required"`
|
||||
|
||||
// IP address to assign to this VM when connecting to the specified network
|
||||
// Required: false
|
||||
IPAddr string `url:"ipAddr,omitempty" json:"ipAddr,omitempty"`
|
||||
}
|
||||
|
||||
// DataDisk detailed struct for DataDisks field in CreateRequest and CreateBlankRequest
|
||||
type DataDisk struct {
|
||||
// Name for disk
|
||||
// Required: true
|
||||
DiskName string `url:"diskName" json:"diskName" validate:"required"`
|
||||
|
||||
// Disk size in GB
|
||||
// Required: true
|
||||
Size uint64 `url:"size" json:"size" validate:"required"`
|
||||
|
||||
// Storage endpoint provider ID
|
||||
// By default the same with boot disk
|
||||
// Required: false
|
||||
SepID uint64 `url:"sepId,omitempty" json:"sepId,omitempty"`
|
||||
|
||||
// Pool name
|
||||
// By default will be chosen automatically
|
||||
// Required: false
|
||||
Pool string `url:"pool,omitempty" json:"pool,omitempty"`
|
||||
|
||||
// Optional description
|
||||
// Required: false
|
||||
Description string `url:"desc,omitempty" json:"desc,omitempty"`
|
||||
|
||||
// Specify image id for create disk from template
|
||||
// Required: false
|
||||
ImageID uint64 `url:"imageId,omitempty" json:"imageId,omitempty"`
|
||||
}
|
||||
|
||||
// CreateRequest struct to create KVM PowerPC VM
|
||||
type CreateRequest struct {
|
||||
// ID of the resource group, which will own this VM
|
||||
// Required: true
|
||||
RGID uint64 `url:"rgId" json:"rgId" validate:"required"`
|
||||
|
||||
// Name of this VM.
|
||||
// Must be unique among all VMs (including those in DELETED state) in target resource group
|
||||
// Required: true
|
||||
Name string `url:"name" json:"name" validate:"required"`
|
||||
|
||||
// Number CPUs to allocate to this VM
|
||||
// Required: true
|
||||
CPU uint64 `url:"cpu" json:"cpu" validate:"required"`
|
||||
|
||||
// Volume of RAM in MB to allocate to this VM
|
||||
// Required: true
|
||||
RAM uint64 `url:"ram" json:"ram" validate:"required"`
|
||||
|
||||
// ID of the OS image to base this VM on;
|
||||
// Could be boot disk image or CD-ROM image
|
||||
// Required: true
|
||||
ImageID uint64 `url:"imageId" json:"imageId" validate:"required"`
|
||||
|
||||
// Size of the boot disk in GB
|
||||
// Required: false
|
||||
BootDisk uint64 `url:"bootDisk,omitempty" json:"bootDisk,omitempty"`
|
||||
|
||||
// ID of SEP to create boot disk on.
|
||||
// Uses images SEP ID if not set
|
||||
// Required: false
|
||||
SEPID uint64 `url:"sepId,omitempty" json:"sepId,omitempty"`
|
||||
|
||||
// Pool to use if sepId is set, can be also empty if needed to be chosen by system
|
||||
// Required: false
|
||||
Pool string `url:"pool,omitempty" json:"pool,omitempty"`
|
||||
|
||||
// Slice of structs with data disk description. Each disk has parameters: required - diskName, size; optional - sepId, pool, desc and imageId.
|
||||
// If not specified, compute will be created without disks.
|
||||
// To create compute without disks, pass initialized empty slice .
|
||||
// Required: false
|
||||
DataDisks []DataDisk `url:"-" json:"dataDisks,omitempty" validate:"omitempty,dive"`
|
||||
|
||||
// Slice of structs with net interface description.
|
||||
// If not specified, compute will be created with default interface from RG.
|
||||
// To create compute without interfaces, pass initialized empty slice .
|
||||
// Required: false
|
||||
Interfaces []Interface `url:"-" json:"interfaces,omitempty" validate:"omitempty,dive"`
|
||||
|
||||
// Input data for cloud-init facility
|
||||
// Required: false
|
||||
Userdata string `url:"userdata,omitempty" json:"userdata,omitempty"`
|
||||
|
||||
// Text description of this VM
|
||||
// Required: false
|
||||
Description string `url:"desc,omitempty" json:"desc,omitempty"`
|
||||
|
||||
// Start VM upon success
|
||||
// Required: false
|
||||
Start bool `url:"start" json:"start"`
|
||||
|
||||
// System name
|
||||
// Required: false
|
||||
IS string `url:"IS,omitempty" json:"IS,omitempty"`
|
||||
|
||||
// Compute purpose
|
||||
// Required: false
|
||||
IPAType string `url:"ipaType,omitempty" json:"ipaType,omitempty"`
|
||||
}
|
||||
|
||||
// GetRAM returns RAM field values
|
||||
func (r CreateRequest) GetRAM() map[string]uint64 {
|
||||
|
||||
res := make(map[string]uint64, 1)
|
||||
|
||||
res["RAM"] = r.RAM
|
||||
|
||||
return res
|
||||
}
|
||||
|
||||
type wrapperCreateRequest struct {
|
||||
CreateRequest
|
||||
Interfaces []string `url:"interfaces,omitempty"`
|
||||
DataDisks []string `url:"dataDisks,omitempty"`
|
||||
}
|
||||
|
||||
// Create creates KVM PowerPC VM based on specified OS image
|
||||
func (k KVMPPC) Create(ctx context.Context, req CreateRequest) (uint64, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return 0, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
var interfaces []string
|
||||
|
||||
if req.Interfaces != nil && len(req.Interfaces) != 0 {
|
||||
interfaces = make([]string, 0, len(req.Interfaces))
|
||||
|
||||
for i := range req.Interfaces {
|
||||
b, err := json.Marshal(req.Interfaces[i])
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
interfaces = append(interfaces, string(b))
|
||||
}
|
||||
} else if req.Interfaces != nil && len(req.Interfaces) == 0 {
|
||||
interfaces = []string{"[]"}
|
||||
}
|
||||
|
||||
var dataDisks []string
|
||||
|
||||
if req.DataDisks != nil && len(req.DataDisks) != 0 {
|
||||
dataDisks = make([]string, 0, len(req.DataDisks))
|
||||
|
||||
for i := range req.DataDisks {
|
||||
b, err := json.Marshal(req.DataDisks[i])
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
dataDisks = append(dataDisks, string(b))
|
||||
}
|
||||
}
|
||||
|
||||
reqWrapped := wrapperCreateRequest{
|
||||
CreateRequest: req,
|
||||
Interfaces: interfaces,
|
||||
DataDisks: dataDisks,
|
||||
}
|
||||
|
||||
url := "/cloudapi/kvmppc/create"
|
||||
|
||||
res, err := k.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseUint(string(res), 10, 64)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
@@ -1,135 +0,0 @@
|
||||
package kvmppc
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// CreateBlankRequest struct to create KVM PowerPC VM from scratch
|
||||
type CreateBlankRequest struct {
|
||||
// ID of the resource group, which will own this VM
|
||||
// Required: true
|
||||
RGID uint64 `url:"rgId" json:"rgId" validate:"required"`
|
||||
|
||||
// Name of this VM.
|
||||
// Must be unique among all VMs (including those in DELETED state) in target resource group
|
||||
// Required: true
|
||||
Name string `url:"name" json:"name" validate:"required"`
|
||||
|
||||
// Number CPUs to allocate to this VM
|
||||
// Required: true
|
||||
CPU uint64 `url:"cpu" json:"cpu" validate:"required"`
|
||||
|
||||
// Volume of RAM in MB to allocate to this VM
|
||||
// Required: true
|
||||
RAM uint64 `url:"ram" json:"ram" validate:"required"`
|
||||
|
||||
// Size of the boot disk in GB
|
||||
// Required: true
|
||||
BootDisk uint64 `url:"bootDisk" json:"bootDisk" validate:"required"`
|
||||
|
||||
// ID of SEP to create boot disk on
|
||||
// Uses images SEP ID if not set
|
||||
// Required: true
|
||||
SEPID uint64 `url:"sepId" json:"sepId" validate:"required"`
|
||||
|
||||
// Pool to use if SEP ID is set, can be also empty if needed to be chosen by system
|
||||
// Required: true
|
||||
Pool string `url:"pool" json:"pool" validate:"required"`
|
||||
|
||||
// Slice of structs with data disk description. Each disk has parameters: required - diskName, size; optional - sepId, pool, desc and imageId.
|
||||
// If not specified, compute will be created without disks.
|
||||
// To create compute without disks, pass initialized empty slice .
|
||||
// Required: false
|
||||
DataDisks []DataDisk `url:"-" json:"dataDisks,omitempty" validate:"omitempty,dive"`
|
||||
|
||||
// Slice of structs with net interface description.
|
||||
// If not specified, compute will be created with default interface from RG.
|
||||
// To create compute without interfaces, pass initialized empty slice .
|
||||
// Required: false
|
||||
Interfaces []Interface `url:"-" json:"interfaces,omitempty" validate:"omitempty,dive"`
|
||||
|
||||
// Text description of this VM
|
||||
// Required: false
|
||||
Description string `url:"desc,omitempty" json:"desc,omitempty"`
|
||||
}
|
||||
|
||||
// GetRAM returns RAM field values
|
||||
func (r CreateBlankRequest) GetRAM() map[string]uint64 {
|
||||
|
||||
res := make(map[string]uint64, 1)
|
||||
|
||||
res["RAM"] = r.RAM
|
||||
|
||||
return res
|
||||
}
|
||||
|
||||
type wrapperCreateBlankRequest struct {
|
||||
CreateBlankRequest
|
||||
Interfaces []string `url:"interfaces,omitempty"`
|
||||
DataDisks []string `url:"dataDisks,omitempty"`
|
||||
}
|
||||
|
||||
// CreateBlank creates KVM PowerPC VM from scratch
|
||||
func (k KVMPPC) CreateBlank(ctx context.Context, req CreateBlankRequest) (uint64, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return 0, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
var interfaces []string
|
||||
|
||||
if req.Interfaces != nil && len(req.Interfaces) != 0 {
|
||||
interfaces = make([]string, 0, len(req.Interfaces))
|
||||
|
||||
for i := range req.Interfaces {
|
||||
b, err := json.Marshal(req.Interfaces[i])
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
interfaces = append(interfaces, string(b))
|
||||
}
|
||||
} else if req.Interfaces != nil && len(req.Interfaces) == 0 {
|
||||
interfaces = []string{"[]"}
|
||||
}
|
||||
|
||||
var dataDisks []string
|
||||
|
||||
if req.DataDisks != nil && len(req.DataDisks) != 0 {
|
||||
dataDisks = make([]string, 0, len(req.DataDisks))
|
||||
|
||||
for i := range req.DataDisks {
|
||||
b, err := json.Marshal(req.DataDisks[i])
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
dataDisks = append(dataDisks, string(b))
|
||||
}
|
||||
}
|
||||
|
||||
reqWrapped := wrapperCreateBlankRequest{
|
||||
CreateBlankRequest: req,
|
||||
Interfaces: interfaces,
|
||||
DataDisks: dataDisks,
|
||||
}
|
||||
|
||||
url := "/cloudapi/kvmppc/createBlank"
|
||||
|
||||
res, err := k.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseUint(string(res), 10, 64)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
// API to manage KVM PowerPC compute instances (PPC VMs)
|
||||
package kvmppc
|
||||
|
||||
import (
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/interfaces"
|
||||
)
|
||||
|
||||
// Structure for creating request to KVMPPC
|
||||
type KVMPPC struct {
|
||||
client interfaces.Caller
|
||||
}
|
||||
|
||||
// Builder for KVMPPC endpoints
|
||||
func New(client interfaces.Caller) *KVMPPC {
|
||||
return &KVMPPC{
|
||||
client,
|
||||
}
|
||||
}
|
||||
@@ -14,7 +14,9 @@ type Interface struct {
|
||||
// Should be one of:
|
||||
// - VINS
|
||||
// - EXTNET
|
||||
NetType string `url:"netType" json:"netType" validate:"required,kvmNetType"`
|
||||
// - VFNIC
|
||||
// - DPDK
|
||||
NetType string `url:"netType" json:"netType" validate:"required,kvmx86NetType"`
|
||||
|
||||
// Network ID for connect to,
|
||||
// for EXTNET - external network ID,
|
||||
@@ -24,6 +26,11 @@ type Interface struct {
|
||||
// IP address to assign to this VM when connecting to the specified network
|
||||
// Required: false
|
||||
IPAddr string `url:"ipAddr,omitempty" json:"ipAddr,omitempty"`
|
||||
|
||||
// Maximum transmission unit, must be 1-9216
|
||||
// Used only to DPDK net type
|
||||
// Required: false
|
||||
MTU uint64 `url:"mtu,omitempty" json:"mtu,omitempty" validate:"omitempty,mtu"`
|
||||
}
|
||||
|
||||
// DataDisk detailed struct for DataDisks field in CreateRequest and CreateBlankRequest
|
||||
@@ -74,10 +81,14 @@ type CreateRequest struct {
|
||||
// Required: true
|
||||
RAM uint64 `url:"ram" json:"ram" validate:"required"`
|
||||
|
||||
// If True, the imageId, bootDisk, sepId, pool parameters are ignored and the compute is created without a boot disk in the stopped state
|
||||
// Required: false
|
||||
WithoutBootDisk bool `url:"withoutBootDisk" json:"withoutBootDisk"`
|
||||
|
||||
// ID of the OS image to base this VM on;
|
||||
// Could be boot disk image or CD-ROM image
|
||||
// Required: true
|
||||
ImageID uint64 `url:"imageId" json:"imageId" validate:"required"`
|
||||
// Required: false
|
||||
ImageID uint64 `url:"imageId,omitempty" json:"imageId,omitempty"`
|
||||
|
||||
// Size of the boot disk in GB
|
||||
// Required: false
|
||||
@@ -131,6 +142,28 @@ type CreateRequest struct {
|
||||
// Type of compute Stateful (KVM_X86) or Stateless (SVA_KVM_X86)
|
||||
// Required: false
|
||||
Driver string `url:"driver,omitempty" json:"driver,omitempty" validate:"omitempty,computeDriver"`
|
||||
|
||||
// Rule for VM placement with NUMA affinity.
|
||||
// Possible values - none (placement without NUMA affinity),
|
||||
// strict (strictly with NUMA affinity, if not possible - do not start VM),
|
||||
// loose (use NUMA affinity if possible)
|
||||
// Required: false
|
||||
// Default: none
|
||||
NumaAffinity string `url:"numaAffinity,omitempty" json:"numaAffinity,omitempty" validate:"omitempty,numaAffinity"`
|
||||
|
||||
// Run VM on dedicated CPUs. To use this feature, the system must be pre-configured by allocating CPUs on the physical node
|
||||
// Required: false
|
||||
// Default: false
|
||||
CPUPin bool `url:"cpupin" json:"cpupin"`
|
||||
|
||||
// Type of the emulated system, Q35 or i440fx
|
||||
// Required: false
|
||||
Chipset string `url:"chipset,omitempty" json:"chipset,omitempty" validate:"omitempty,chipset"`
|
||||
|
||||
// Use Huge Pages to allocate RAM of the virtual machine. The system must be pre-configured by allocating Huge Pages on the physical node
|
||||
// Required: false
|
||||
// Default: false
|
||||
HPBacked bool `url:"hpBacked" json:"hpBacked"`
|
||||
}
|
||||
|
||||
// GetRAM returns RAM field values
|
||||
|
||||
@@ -28,18 +28,22 @@ type CreateBlankRequest struct {
|
||||
// Required: true
|
||||
RAM uint64 `url:"ram" json:"ram" validate:"required"`
|
||||
|
||||
// If True, the imageId, bootDisk, sepId, pool parameters are ignored and the compute is created without a boot disk in the stopped state
|
||||
// Required: false
|
||||
WithoutBootDisk bool `url:"withoutBootDisk" json:"withoutBootDisk"`
|
||||
|
||||
// Size of the boot disk in GB
|
||||
// Required: true
|
||||
BootDisk uint64 `url:"bootDisk" json:"bootDisk" validate:"required"`
|
||||
// Required: false
|
||||
BootDisk uint64 `url:"bootDisk,omitempty" json:"bootDisk,omitempty"`
|
||||
|
||||
// ID of SEP to create boot disk on.
|
||||
// Uses images SEP ID if not set
|
||||
// Required: true
|
||||
SEPID uint64 `url:"sepId" json:"sepId" validate:"required"`
|
||||
// Required: false
|
||||
SEPID uint64 `url:"sepId,omitempty" json:"sepId,omitempty"`
|
||||
|
||||
// Pool to use if sepId is set, can be also empty if needed to be chosen by system
|
||||
// Required: true
|
||||
Pool string `url:"pool" json:"pool" validate:"required"`
|
||||
// Required: false
|
||||
Pool string `url:"pool,omitempty" json:"pool,omitempty"`
|
||||
|
||||
// Slice of structs with data disk description. Each disk has parameters: required - diskName, size; optional - sepId, pool, desc and imageId.
|
||||
// If not specified, compute will be created without disks.
|
||||
@@ -57,6 +61,10 @@ type CreateBlankRequest struct {
|
||||
// Required: false
|
||||
Driver string `url:"driver,omitempty" json:"driver,omitempty" validate:"omitempty,computeDriver"`
|
||||
|
||||
// Type of the emulated system, Q35 or i440fx
|
||||
// Required: false
|
||||
Chipset string `url:"chipset,omitempty" json:"chipset,omitempty" validate:"omitempty,chipset"`
|
||||
|
||||
// Text description of this VM
|
||||
// Required: false
|
||||
Description string `url:"desc,omitempty" json:"desc,omitempty"`
|
||||
|
||||
@@ -22,11 +22,11 @@ type CreateRequest struct {
|
||||
Name string `url:"name" json:"name" validate:"required"`
|
||||
|
||||
// External network to connect this load balancer to
|
||||
// Required: false
|
||||
// Required: true, can be 0
|
||||
ExtNetID uint64 `url:"extnetId" json:"extnetId"`
|
||||
|
||||
// Internal network (VINS) to connect this load balancer to
|
||||
// Required: false
|
||||
// Required: true, can be 0
|
||||
VINSID uint64 `url:"vinsId" json:"vinsId"`
|
||||
|
||||
// Custom sysctl values for Load Balancer instance. Applied on boot
|
||||
|
||||
@@ -26,7 +26,7 @@ func (ll ListLB) FilterByName(name string) ListLB {
|
||||
}
|
||||
|
||||
// FilterByExtNetID returns ListLB with specified ExtNetID.
|
||||
func (ll ListLB) FilterByExtNetID(extNetID uint64) ListLB {
|
||||
func (ll ListLB) FilterByExtNetID(extNetID int64) ListLB {
|
||||
predicate := func(ill ItemLoadBalancer) bool {
|
||||
return ill.ExtNetID == extNetID
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ type RecordLB struct {
|
||||
DPAPIUser string `json:"dpApiUser"`
|
||||
|
||||
// External network ID
|
||||
ExtNetID uint64 `json:"extnetId"`
|
||||
ExtNetID int64 `json:"extnetId"`
|
||||
|
||||
// FrontendHAIP
|
||||
FrontendHAIP string `json:"frontendHAIP"`
|
||||
|
||||
@@ -24,10 +24,6 @@ type AccessGrantRequest struct {
|
||||
// - "ARCXDU"
|
||||
// Required: true
|
||||
Right string `url:"right" json:"right" validate:"accessType"`
|
||||
|
||||
// Reason for action
|
||||
// Required: false
|
||||
Reason string `url:"reason,omitempty" json:"reason,omitempty"`
|
||||
}
|
||||
|
||||
// AccessGrant grants user or group access to the resource group as specified
|
||||
|
||||
@@ -17,10 +17,6 @@ type AccessRevokeRequest struct {
|
||||
// User or group name to revoke access
|
||||
// Required: true
|
||||
User string `url:"user" json:"user" validate:"required"`
|
||||
|
||||
// Reason for action
|
||||
// Required: false
|
||||
Reason string `url:"reason,omitempty" json:"reason,omitempty"`
|
||||
}
|
||||
|
||||
// AccessRevoke revokes specified user or group access from the resource group
|
||||
|
||||
@@ -64,10 +64,6 @@ type CreateRequest struct {
|
||||
// Required: false
|
||||
Description string `url:"desc,omitempty" json:"desc,omitempty"`
|
||||
|
||||
// Reason for action
|
||||
// Required: false
|
||||
Reason string `url:"reason,omitempty" json:"reason,omitempty"`
|
||||
|
||||
// External network ID
|
||||
// Required: false
|
||||
ExtNetID uint64 `url:"extNetId,omitempty" json:"extNetId,omitempty"`
|
||||
|
||||
@@ -22,10 +22,6 @@ type DeleteRequest struct {
|
||||
// Otherwise, they will be placed into recycle bin and could be restored later within recycle bin's purge period
|
||||
// Required: false
|
||||
Permanently bool `url:"permanently,omitempty" json:"permanently,omitempty"`
|
||||
|
||||
// Reason for action
|
||||
// Required: false
|
||||
Reason string `url:"reason,omitempty" json:"reason,omitempty"`
|
||||
}
|
||||
|
||||
// Delete deletes resource group
|
||||
|
||||
@@ -13,10 +13,6 @@ type DisableRequest struct {
|
||||
// Resource group ID
|
||||
// Required: true
|
||||
RGID uint64 `url:"rgId" json:"rgId" validate:"required"`
|
||||
|
||||
// Reason for action
|
||||
// Required: false
|
||||
Reason string `url:"reason,omitempty" json:"reason,omitempty"`
|
||||
}
|
||||
|
||||
// Disable disables resource group
|
||||
|
||||
@@ -13,10 +13,6 @@ type EnableRequest struct {
|
||||
// Resource group ID
|
||||
// Required: true
|
||||
RGID uint64 `url:"rgId" json:"rgId" validate:"required"`
|
||||
|
||||
// Reason for action
|
||||
// Required: false
|
||||
Reason string `url:"reason,omitempty" json:"reason,omitempty"`
|
||||
}
|
||||
|
||||
// Enable enables resource group
|
||||
|
||||
@@ -13,10 +13,6 @@ type GetRequest struct {
|
||||
// Resource group ID
|
||||
// Required: true
|
||||
RGID uint64 `url:"rgId" json:"rgId" validate:"required"`
|
||||
|
||||
// Reason for action
|
||||
// Required: false
|
||||
Reason string `url:"reason,omitempty" json:"reason,omitempty"`
|
||||
}
|
||||
|
||||
// Get gets current configuration of the resource group as a RecordResourceGroup struct
|
||||
|
||||
@@ -22,10 +22,6 @@ type ListLBRequest struct {
|
||||
// Required: false
|
||||
Name string `url:"name,omitempty" json:"name,omitempty"`
|
||||
|
||||
// Find by account ID
|
||||
// Required: false
|
||||
AccountID uint64 `url:"accountId,omitempty" json:"accountId,omitempty"`
|
||||
|
||||
// Find by tech status
|
||||
// Required: false
|
||||
TechStatus string `url:"techStatus,omitempty" json:"techStatus,omitempty"`
|
||||
|
||||
@@ -787,7 +787,7 @@ type ItemVINS struct {
|
||||
ExtnetId uint64 `json:"extnetId"`
|
||||
|
||||
// Free IPs
|
||||
FreeIPs uint64 `json:"freeIPs"`
|
||||
FreeIPs int64 `json:"freeIPs"`
|
||||
|
||||
// ID
|
||||
ID uint64 `json:"id"`
|
||||
|
||||
38
pkg/cloudapi/rg/remove_def_net.go
Normal file
38
pkg/cloudapi/rg/remove_def_net.go
Normal file
@@ -0,0 +1,38 @@
|
||||
package rg
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// RemoveDefNetRequest struct to remove default network
|
||||
type RemoveDefNetRequest struct {
|
||||
// Resource group ID
|
||||
// Required: true
|
||||
RGID uint64 `url:"rgId" json:"rgId" validate:"required"`
|
||||
}
|
||||
|
||||
// RemoveDefNet removes default network from resource group
|
||||
func (r RG) RemoveDefNet(ctx context.Context, req RemoveDefNetRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudapi/rg/removeDefNet"
|
||||
|
||||
res, err := r.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseBool(string(res))
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
@@ -13,10 +13,6 @@ type RestoreRequest struct {
|
||||
// Resource group ID
|
||||
// Required: true
|
||||
RGID uint64 `url:"rgId" json:"rgId" validate:"required"`
|
||||
|
||||
// Reason for action
|
||||
// Required: false
|
||||
Reason string `url:"reason,omitempty" json:"reason,omitempty"`
|
||||
}
|
||||
|
||||
// Restore restores resource group from recycle bin
|
||||
|
||||
@@ -24,10 +24,6 @@ type SetDefNetRequest struct {
|
||||
// Network ID
|
||||
// Required: false
|
||||
NetID uint64 `url:"netId,omitempty" json:"netId,omitempty"`
|
||||
|
||||
// Reason for action
|
||||
// Required: false
|
||||
Reason string `url:"reason,omitempty" json:"reason,omitempty"`
|
||||
}
|
||||
|
||||
// SetDefNet sets default network for attach associated virtual machines
|
||||
|
||||
@@ -46,9 +46,14 @@ type UpdateRequest struct {
|
||||
// Required: false
|
||||
RegisterComputes bool `url:"registerComputes,omitempty" json:"registerComputes,omitempty"`
|
||||
|
||||
// Reason for action
|
||||
// List of strings with pools i.e.: ["sep1_poolName1", "sep2_poolName2", etc]
|
||||
// Required: false
|
||||
Reason string `url:"reason,omitempty" json:"reason,omitempty"`
|
||||
UniqPools []string `url:"uniqPools,omitempty" json:"uniqPools,omitempty"`
|
||||
|
||||
// if True the field will be cleared
|
||||
// Default: false
|
||||
// Required: false
|
||||
ClearUniqPools bool `url:"clearUniqPools" json:"clearUniqPools"`
|
||||
}
|
||||
|
||||
// Update updates resource group
|
||||
|
||||
@@ -13,10 +13,6 @@ type UsageRequest struct {
|
||||
// Resource group ID
|
||||
// Required: true
|
||||
RGID uint64 `url:"rgId" json:"rgId" validate:"required"`
|
||||
|
||||
// Reason for action
|
||||
// Required: false
|
||||
Reason string `url:"reason,omitempty" json:"reason,omitempty"`
|
||||
}
|
||||
|
||||
// Usage gets report resource usage on the resource group
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
package cloudapi
|
||||
|
||||
import (
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/sizes"
|
||||
)
|
||||
|
||||
// Accessing the Sizes method group
|
||||
func (ca *CloudAPI) Sizes() *sizes.Sizes {
|
||||
return sizes.New(ca.client)
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
package sizes
|
||||
|
||||
// FilterByID returns ListSizes with specified ID.
|
||||
func (ls ListSizes) FilterByID(id uint64) ListSizes {
|
||||
predicate := func(is ItemSize) bool {
|
||||
return is.ID == id
|
||||
}
|
||||
|
||||
return ls.FilterFunc(predicate)
|
||||
}
|
||||
|
||||
// FilterByName returns ListSizes with specified Name.
|
||||
func (ls ListSizes) FilterByName(name string) ListSizes {
|
||||
predicate := func(is ItemSize) bool {
|
||||
return is.Name == name
|
||||
}
|
||||
|
||||
return ls.FilterFunc(predicate)
|
||||
}
|
||||
|
||||
// FilterFunc allows filtering ListSizes based on a user-specified predicate.
|
||||
func (ls ListSizes) FilterFunc(predicate func(ItemSize) bool) ListSizes {
|
||||
var result ListSizes
|
||||
|
||||
for _, item := range ls.Data {
|
||||
if predicate(item) {
|
||||
result.Data = append(result.Data, item)
|
||||
}
|
||||
}
|
||||
|
||||
result.EntryCount = uint64(len(result.Data))
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
// FindOne returns first found ItemSize
|
||||
// If none was found, returns an empty struct.
|
||||
func (ls ListSizes) FindOne() ItemSize {
|
||||
if len(ls.Data) == 0 {
|
||||
return ItemSize{}
|
||||
}
|
||||
|
||||
return ls.Data[0]
|
||||
}
|
||||
@@ -1,65 +0,0 @@
|
||||
package sizes
|
||||
|
||||
import "testing"
|
||||
|
||||
var sizeItems = ListSizes{
|
||||
Data: []ItemSize{
|
||||
{
|
||||
Description: "",
|
||||
Disks: []uint64{},
|
||||
ID: 1,
|
||||
Memory: 512,
|
||||
Name: "size_1",
|
||||
VCPUs: 2,
|
||||
},
|
||||
{
|
||||
Description: "",
|
||||
Disks: []uint64{},
|
||||
ID: 2,
|
||||
Memory: 1024,
|
||||
Name: "size_2",
|
||||
VCPUs: 4,
|
||||
},
|
||||
{
|
||||
Description: "",
|
||||
Disks: []uint64{},
|
||||
ID: 2,
|
||||
Memory: 2048,
|
||||
Name: "size_3",
|
||||
VCPUs: 6,
|
||||
},
|
||||
},
|
||||
EntryCount: 3,
|
||||
}
|
||||
|
||||
func TestFilterByID(t *testing.T) {
|
||||
actual := sizeItems.FilterByID(1).FindOne()
|
||||
|
||||
if actual.ID != 1 {
|
||||
t.Fatal("expected ID 1, found: ", actual.ID)
|
||||
}
|
||||
}
|
||||
|
||||
func TestFilterByName(t *testing.T) {
|
||||
actual := sizeItems.FilterByName("size_2").FindOne()
|
||||
|
||||
if actual.Name != "size_2" {
|
||||
t.Fatal("expected Name 'size_2', found: ", actual.Name)
|
||||
}
|
||||
}
|
||||
|
||||
func TestFilterFunc(t *testing.T) {
|
||||
actual := sizeItems.FilterFunc(func(is ItemSize) bool {
|
||||
return is.Memory > 512
|
||||
})
|
||||
|
||||
if len(actual.Data) != 2 {
|
||||
t.Fatal("expected 2 found, actual: ", len(actual.Data))
|
||||
}
|
||||
|
||||
for _, item := range actual.Data {
|
||||
if item.Memory <= 512 {
|
||||
t.Fatal("expected Memory greater than 512, found: ", item.Memory)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
package sizes
|
||||
|
||||
// IDs gets array of configured available flavours IDs from ListSizes struct
|
||||
func (ls ListSizes) IDs() []uint64 {
|
||||
res := make([]uint64, 0, len(ls.Data))
|
||||
for _, s := range ls.Data {
|
||||
res = append(res, s.ID)
|
||||
}
|
||||
return res
|
||||
}
|
||||
@@ -1,63 +0,0 @@
|
||||
package sizes
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// ListRequest struct for list of the available flavors
|
||||
type ListRequest struct {
|
||||
// ID of the cloudspace
|
||||
// Required: false
|
||||
CloudspaceID uint64 `url:"cloudspaceId,omitempty" json:"cloudspaceId,omitempty"`
|
||||
|
||||
// Location code for the sizes
|
||||
// Required: false
|
||||
Location string `url:"location,omitempty" json:"location,omitempty"`
|
||||
|
||||
// Sort by one of supported fields, format +|-(field)
|
||||
// Required: false
|
||||
SortBy string `url:"sortBy,omitempty" json:"sortBy,omitempty" validate:"omitempty,sortBy"`
|
||||
|
||||
// Page number
|
||||
// Required: false
|
||||
Page uint64 `url:"page,omitempty" json:"page,omitempty"`
|
||||
|
||||
// Page size
|
||||
// Required: false
|
||||
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
||||
}
|
||||
|
||||
// List gets list of the available flavors as a ListSizes struct, filtering can be based on the user which is doing the request
|
||||
func (s Sizes) List(ctx context.Context, req ListRequest) (*ListSizes, error) {
|
||||
|
||||
res, err := s.ListRaw(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
list := &ListSizes{}
|
||||
|
||||
err = json.Unmarshal(res, &list)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return list, nil
|
||||
}
|
||||
|
||||
// ListRaw gets list of the available flavors as an array of bytes
|
||||
func (s Sizes) ListRaw(ctx context.Context, req ListRequest) ([]byte, error) {
|
||||
|
||||
if err := validators.ValidateRequest(req); err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudapi/sizes/list"
|
||||
|
||||
res, err := s.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
return res, err
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
package sizes
|
||||
|
||||
// Main onformation about configured available flavors
|
||||
type ItemSize struct {
|
||||
// Description
|
||||
Description string `json:"desc"`
|
||||
|
||||
// List of disk IDs
|
||||
Disks []uint64 `json:"disks"`
|
||||
|
||||
// ID
|
||||
ID uint64 `json:"id"`
|
||||
|
||||
// Memory
|
||||
Memory uint64 `json:"memory"`
|
||||
|
||||
// Name
|
||||
Name string `json:"name"`
|
||||
|
||||
// VCPUs
|
||||
VCPUs uint64 `json:"vcpus"`
|
||||
}
|
||||
|
||||
// List of configured available flavors
|
||||
type ListSizes struct {
|
||||
// Data
|
||||
Data []ItemSize `json:"data"`
|
||||
|
||||
// Entry count
|
||||
EntryCount uint64 `json:"entryCount"`
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
package sizes
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/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 (ls ListSizes) Serialize(params ...string) (serialization.Serialized, error) {
|
||||
if len(ls.Data) == 0 {
|
||||
return []byte{}, nil
|
||||
}
|
||||
|
||||
if len(params) > 1 {
|
||||
prefix := params[0]
|
||||
indent := params[1]
|
||||
|
||||
return json.MarshalIndent(ls, prefix, indent)
|
||||
}
|
||||
|
||||
return json.Marshal(ls)
|
||||
}
|
||||
|
||||
// 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 (is ItemSize) Serialize(params ...string) (serialization.Serialized, error) {
|
||||
if len(params) > 1 {
|
||||
prefix := params[0]
|
||||
indent := params[1]
|
||||
|
||||
return json.MarshalIndent(is, prefix, indent)
|
||||
}
|
||||
|
||||
return json.Marshal(is)
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
// Lists all the configured flavors available.
|
||||
// A flavor is a combination of amount of compute capacity(CU) and disk capacity(GB).
|
||||
package sizes
|
||||
|
||||
import (
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/interfaces"
|
||||
)
|
||||
|
||||
// Structure for creatig request to sizes
|
||||
type Sizes struct {
|
||||
client interfaces.Caller
|
||||
}
|
||||
|
||||
// Builder for sizes endpoints
|
||||
func New(client interfaces.Caller) *Sizes {
|
||||
return &Sizes{
|
||||
client,
|
||||
}
|
||||
}
|
||||
@@ -14,14 +14,17 @@ type ListRequest struct {
|
||||
// Required: false
|
||||
TaskID string `url:"taskId,omitempty" json:"taskId,omitempty"`
|
||||
|
||||
// Find by auditId
|
||||
// Required: false
|
||||
AuditID string `url:"auditId,omitempty" json:"auditId,omitempty"`
|
||||
|
||||
// Find by status
|
||||
// Required: false
|
||||
Status string `url:"status,omitempty" json:"status,omitempty"`
|
||||
|
||||
// Find by completed True or False
|
||||
// Default: false
|
||||
// Required: false
|
||||
Completed bool `url:"completed" json:"completed"`
|
||||
Completed interface{} `url:"completed,omitempty" json:"completed,omitempty" validate:"omitempty,isBool"`
|
||||
|
||||
// Sort by one of supported fields, format +|-(field)
|
||||
// Required: false
|
||||
@@ -29,19 +32,21 @@ type ListRequest struct {
|
||||
|
||||
// Find all tasks after point in time (unixtime)
|
||||
// Required: false
|
||||
UpdateTimeAt uint64 `url:"page,updateTimeAt" json:"updateTimeAt,omitempty"`
|
||||
UpdateTimeAt uint64 `url:"updateTimeAt,omitempty" json:"updateTimeAt,omitempty"`
|
||||
|
||||
// Find all tasks before point in time (unixtime)
|
||||
// Required: false
|
||||
UpdateTimeTo uint64 `url:"page,updateTimeTo" json:"updateTimeTo,omitempty"`
|
||||
UpdateTimeTo uint64 `url:"updateTimeTo,omitempty" json:"updateTimeTo,omitempty"`
|
||||
|
||||
// Page number
|
||||
// Default: 0
|
||||
// Default: 0
|
||||
// Required: false
|
||||
Page uint64 `url:"page,omitempty" json:"page,omitempty"`
|
||||
|
||||
// Page size
|
||||
// Default: 0
|
||||
// Default: 0
|
||||
// Required: false
|
||||
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
||||
}
|
||||
@@ -71,6 +76,10 @@ func (t Tasks) ListRaw(ctx context.Context, req ListRequest) ([]byte, error) {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
if err := validators.ValidateRequest(req); err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudapi/tasks/list"
|
||||
|
||||
res, err := t.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
|
||||
@@ -12,10 +12,6 @@ type GetAuditRequest struct {
|
||||
// Required: false
|
||||
Call string `url:"call,omitempty" json:"call,omitempty"`
|
||||
|
||||
// Find by HTTP status code
|
||||
// Required: false
|
||||
StatusCode uint64 `url:"statuscode,omitempty" json:"statuscode,omitempty"`
|
||||
|
||||
// Find all audits after point in time (unixtime)
|
||||
// Required: false
|
||||
TimestampAt uint64 `url:"timestampAt,omitempty" json:"timestampAt,omitempty"`
|
||||
@@ -24,6 +20,14 @@ type GetAuditRequest struct {
|
||||
// Required: false
|
||||
TimestampTo uint64 `url:"timestampTo,omitempty" json:"timestampTo,omitempty"`
|
||||
|
||||
// find by HTTP max status code
|
||||
// Required: false
|
||||
MaxStatusCode uint64 `url:"maxStatusCode,omitempty" json:"maxStatusCode,omitempty"`
|
||||
|
||||
// find by HTTP min status code
|
||||
// Required: false
|
||||
MinStatusCode uint64 `url:"minStatusCode,omitempty" json:"minStatusCode,omitempty"`
|
||||
|
||||
// Page number.
|
||||
// Required: false
|
||||
Page uint64 `url:"page,omitempty" json:"page,omitempty"`
|
||||
|
||||
@@ -23,6 +23,9 @@ type ItemAudit struct {
|
||||
// StatusCode
|
||||
StatusCode StatusCode `json:"Status Code"`
|
||||
|
||||
// Guid
|
||||
GUID string `json:"Guid"`
|
||||
|
||||
// Time
|
||||
Time float64 `json:"Time"`
|
||||
}
|
||||
|
||||
@@ -30,6 +30,10 @@ type ListRequest struct {
|
||||
// Required: false
|
||||
ExtIP string `url:"extIp,omitempty" json:"extIp,omitempty"`
|
||||
|
||||
// Find by VNF Device id
|
||||
// Required: false
|
||||
VNFDevId uint64 `url:"vnfdevId,omitempty" json:"vnfdevId,omitempty"`
|
||||
|
||||
// Include deleted
|
||||
// Required: false
|
||||
IncludeDeleted bool `url:"includeDeleted,omitempty" json:"includeDeleted,omitempty"`
|
||||
|
||||
@@ -30,6 +30,10 @@ type ListDeletedRequest struct {
|
||||
// Required: false
|
||||
ExtIP string `url:"extIp,omitempty" json:"extIp,omitempty"`
|
||||
|
||||
// Find by VNF Device id
|
||||
// Required: false
|
||||
VNFDevID uint64 `url:"vnfdevId,omitempty" json:"vnfdevId,omitempty"`
|
||||
|
||||
// Sort by one of supported fields, format +|-(field)
|
||||
// Required: false
|
||||
SortBy string `url:"sortBy,omitempty" json:"sortBy,omitempty" validate:"omitempty,sortBy"`
|
||||
@@ -50,6 +54,10 @@ func (v VINS) ListDeleted(ctx context.Context, req ListDeletedRequest) (*ListVIN
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
if err := validators.ValidateRequest(req); err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudapi/vins/listDeleted"
|
||||
|
||||
res, err := v.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
|
||||
@@ -27,7 +27,7 @@ type ItemVINS struct {
|
||||
ExtnetId uint64 `json:"extnetId"`
|
||||
|
||||
// Free IPs
|
||||
FreeIPs uint64 `json:"freeIPs"`
|
||||
FreeIPs int64 `json:"freeIPs"`
|
||||
|
||||
// ID
|
||||
ID uint64 `json:"id"`
|
||||
@@ -208,6 +208,9 @@ type RecordVNFDev struct {
|
||||
|
||||
// List of VINS IDs
|
||||
VINS []uint64 `json:"vins"`
|
||||
|
||||
// VNC password
|
||||
VNCPassword string `json:"vncPasswd"`
|
||||
}
|
||||
|
||||
// VNF config
|
||||
@@ -251,6 +254,9 @@ type RecordResources struct {
|
||||
|
||||
// Main information about VNF interface
|
||||
type ItemVNFInterface struct {
|
||||
// Bus number
|
||||
BusNumber uint64 `json:"bus_number"`
|
||||
|
||||
// Connection ID
|
||||
ConnID uint64 `json:"connId"`
|
||||
|
||||
@@ -278,6 +284,12 @@ type ItemVNFInterface struct {
|
||||
// MAC
|
||||
MAC string `json:"mac"`
|
||||
|
||||
// Maximum transmission unit
|
||||
MTU uint64 `json:"mtu"`
|
||||
|
||||
// Libvirt Settings
|
||||
LibvirtSettings LibvirtSettings `json:"libvirtSettings"`
|
||||
|
||||
// Name
|
||||
Name string `json:"name"`
|
||||
|
||||
@@ -722,6 +734,30 @@ type RecordVINS struct {
|
||||
VXLANID uint64 `json:"vxlanId"`
|
||||
}
|
||||
|
||||
// Information about libvirt settings
|
||||
type LibvirtSettings struct {
|
||||
// TX mode
|
||||
TXMode string `json:"txmode"`
|
||||
|
||||
// IO event
|
||||
IOEventFD string `json:"ioeventfd"`
|
||||
|
||||
// Event ID
|
||||
EventIDx string `json:"event_idx"`
|
||||
|
||||
// Number of queues
|
||||
Queues uint64 `json:"queues"`
|
||||
|
||||
// RX queue size
|
||||
RXQueueSize uint64 `json:"rx_queue_size"`
|
||||
|
||||
// TX queue size
|
||||
TXQueueSize uint64 `json:"tx_queue_size"`
|
||||
|
||||
// GUID
|
||||
GUID string `json:"guid"`
|
||||
}
|
||||
|
||||
// Main information about NAT rule
|
||||
type ItemNATRule struct {
|
||||
// ID
|
||||
@@ -760,17 +796,8 @@ type ListNATRules struct {
|
||||
|
||||
// Main information about reservation
|
||||
type ItemReservation struct {
|
||||
// Client type
|
||||
ClientType string `json:"clientType"`
|
||||
|
||||
// Description
|
||||
Description string `json:"desc"`
|
||||
|
||||
// Domain name
|
||||
DomainName string `json:"domainname"`
|
||||
|
||||
// Hostname
|
||||
Hostname string `json:"hostname"`
|
||||
// Account ID
|
||||
AccountID uint64 `json:"account_id"`
|
||||
|
||||
// IP
|
||||
IP string `json:"ip"`
|
||||
|
||||
@@ -25,10 +25,6 @@ type StaticRouteAddRequest struct {
|
||||
// Next hop host, IP address from ViNS ID free IP pool
|
||||
// Required: true
|
||||
Gateway string `url:"gateway" json:"gateway" validate:"required"`
|
||||
|
||||
// List of Compute IDs which have access to this route
|
||||
// Required: false
|
||||
ComputeIds []uint64 `url:"computeIds,omitempty" json:"computeIds,omitempty"`
|
||||
}
|
||||
|
||||
// StaticRouteAdd adds new static route to ViNS
|
||||
|
||||
@@ -13,10 +13,6 @@ type DeleteRequest struct {
|
||||
// Required: true
|
||||
AccountID uint64 `url:"accountId" json:"accountId" validate:"required"`
|
||||
|
||||
// Reason to delete
|
||||
// Required: false
|
||||
Reason string `url:"reason,omitempty" json:"reason,omitempty"`
|
||||
|
||||
// Whether to completely delete the account
|
||||
// Required: false
|
||||
Permanently bool `url:"permanently,omitempty" json:"permanently,omitempty"`
|
||||
|
||||
@@ -13,10 +13,6 @@ type DeleteAccountsRequest struct {
|
||||
// Required: true
|
||||
AccountsIDs []uint64 `url:"accountIds" json:"accountIds" validate:"min=1"`
|
||||
|
||||
// Reason for deletion
|
||||
// Required: false
|
||||
Reason string `url:"reason,omitempty" json:"reason,omitempty"`
|
||||
|
||||
// Whether to completely destroy accounts or not
|
||||
// Required: false
|
||||
Permanently bool `url:"permanently,omitempty" json:"permanently,omitempty"`
|
||||
|
||||
@@ -17,10 +17,6 @@ type DeleteUserRequest struct {
|
||||
// ID or emailaddress of the user to remove
|
||||
// Required: true
|
||||
UserName string `url:"username" json:"username" validate:"required"`
|
||||
|
||||
// Recursively revoke access rights from owned cloudspaces and vmachines
|
||||
// Required: false
|
||||
RecursiveDelete bool `url:"recursivedelete" json:"recursivedelete"`
|
||||
}
|
||||
|
||||
// DeleteUser revokes user access from the account
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user