Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 37135a57ad | |||
|
|
ae66de8ec2 |
215
CHANGELOG.md
215
CHANGELOG.md
@@ -1,209 +1,16 @@
|
|||||||
## Version 1.16.0
|
## Version 1.13.10
|
||||||
|
|
||||||
Метод `ConfigFieldEdit` в cloudbroker/sep стал deprecated и в следующих версиях будет удалён
|
Методы `Audits` в cloudapi/compute, cloudbroker/compute, cloudapi/account, cloudbroker/account, cloudapi/vins, cloudbroker/vins, cloudapi/rg и cloudbroker/rg стали deprecated и в следующих версиях будут удалены, вместо них необходимо использовать метод `List` в cloudapi/audit и cloudbroker/audit с соответствующими фильтрами
|
||||||
|
Метод `ListNodes` в cloudbroker/image стал deprecated и в следующих версиях будет удалён
|
||||||
|
Методы `AccessGrant`, `AccessGrantToPool`, `AccessRevoke`, `AccessRevokeToPool` в cloudbroker/sep стали deprecated и в следующих версиях будут удалены
|
||||||
|
Методы `ComputeCISet`, `ComputeCIUnset`, `GetAudits` в cloudbroker/compute и `GetAudits` в cloudapi/compute стали deprecated и будут удалены в следующих версиях
|
||||||
|
Методы `ComputeCISet`, `ComputeCIUnset` в cloudbroker/image стали deprecated и будут удалены в следующих версиях
|
||||||
|
|
||||||
|
Все методы группы `.SDN()` находятся в альфа-версии.
|
||||||
|
|
||||||
### Добавлено
|
### Исправлено
|
||||||
|
|
||||||
#### Общее
|
#### vfpool
|
||||||
| Идентификатор задачи | Описание |
|
| Идентификатор<br>задачи | Описание |
|
||||||
| --- | --- |
|
| --- | --- |
|
||||||
| BGOS-991 | Допустимые значения `vgpu` и `pcidevice` в валидатор возможностей гипервизора ComputeFeatures |
|
| BGOS-900 | Тип поля `Config` в структуре запроса `wrapperUpdateRequest` с `[]string` на `string` в cloudbroker/vfpool |
|
||||||
|
|
||||||
#### account
|
|
||||||
| Идентификатор задачи | Описание |
|
|
||||||
| --- | --- |
|
|
||||||
| BGOS-986 | Вычисляемое поле `EnableDefaultGateway` в структуру ответа `ItemVINS` в cloudbroker/account и cloudapi/account |
|
|
||||||
| BGOS-989 | Вычисляемые поля `Starting`, `Stopping`, `Paused`, `Pausing`, `Merge`, `Migrating`, `MigratingIn`, `MigratingOut`, `Down`, `Scheduled`, `BackupStopped`, `BackupRunning`, `Snapcreate`, `Cloning` и `Rollback` в структуры ответа `Computes` и `RGComputes` в cloudapi/account |
|
|
||||||
| BGOS-989 | Вычисляемые поля `Starting`, `Stopping`, `Paused`, `Pausing`, `Merge`, `Migrating`, `MigratingIn`, `MigratingOut`, `Down`, `Scheduled`, `BackupStopped`, `BackupRunning`, `Snapcreate`, `Cloning` и `Rollback` в структуру ответа `Computes` в cloudbroker/account |
|
|
||||||
|
|
||||||
#### compute
|
|
||||||
| Идентификатор задачи | Описание |
|
|
||||||
| --- | --- |
|
|
||||||
| BGOS-977 | Вычисляемое поле `ImageID` в структуру ответа `InfoDisk` в cloudbroker/compute и cloudapi/compute |
|
|
||||||
| BGOS-978 | Вычисляемое поле `WatchdogAction` в структуры ответа `RecordCompute` и `ItemCompute` в cloudapi/compute |
|
|
||||||
| BGOS-978 | Вычисляемое поле `WatchdogAction` в структуры ответа `RecordCompute` и `InfoCompute` в cloudbroker/compute |
|
|
||||||
| BGOS-979 | Опциональное поле `WatchdogAction` в структуру запроса `UpdateRequest` в cloudapi/compute и cloudbroker/compute |
|
|
||||||
| BGOS-994 | Вычисляемое поле `QoSPolicies` в структуру ответа `ItemVNFInterface` в cloudapi/compute |
|
|
||||||
| BGOS-994 | Вычисляемое поле `QoSPolicies` в структуру ответа `ItemInterface` в cloudbroker/compute |
|
|
||||||
| BGOS-994 | Опциональное поле `QoSPolicies` в структуру запроса `NetAttachRequest` в cloudapi/compute и cloudbroker/compute |
|
|
||||||
| BGOS-994 | Методы `ChangeQoSPolicies` и `ChangeQoSPoliciesAsync` в cloudbroker/compute и cloudapi/compute |
|
|
||||||
| BGOS-995 | Вычисляемые поля `ComputeID`, `BusNumber`, `DeviceReference`, `MdevUUID`, `ParentPCIAddress`, `ProfileReference` и `SplitMode` в структуру ответа `ItemVGPU` в cloudbroker/compute и cloudapi/compute |
|
|
||||||
| BGOS-999 | Вычисляемое поле `AccountIDs` в структуру ответа `ItemPCIDevice` в cloudbroker/compute и cloudapi/compute |
|
|
||||||
|
|
||||||
#### disks
|
|
||||||
| Идентификатор задачи | Описание |
|
|
||||||
| --- | --- |
|
|
||||||
| BGOS-976 | Метод `CreateAsync` в cloudapi/disks |
|
|
||||||
| BGOS-976 | Методы `CreateAsync` и `MigrateAsync` в cloudbroker/disks |
|
|
||||||
|
|
||||||
#### grid
|
|
||||||
| Идентификатор задачи | Описание |
|
|
||||||
| --- | --- |
|
|
||||||
| BGOS-1000 | Вычисляемые поля `ReservedCPU` и `ReservedRAM` в структуру ответа `RecordSettingsGrid` в cloudbroker/grid |
|
|
||||||
|
|
||||||
#### kvmx86
|
|
||||||
| Идентификатор задачи | Описание |
|
|
||||||
| --- | --- |
|
|
||||||
| BGOS-979 | Опциональное поле `WatchdogAction` в структуры запроса `CreateRequest` и `CreateBlankRequest` в cloudapi/kvmx86 |
|
|
||||||
| BGOS-979 | Опциональное поле `WatchdogAction` в структуры запроса `CreateRequest`, `CreateBlankRequest` и `MassCreateRequest` в cloudbroker/kvmx86 |
|
|
||||||
| BGOS-983 | Метод `CreateAsync` в cloudbroker/kvmx86 и cloudapi/kvmx86 |
|
|
||||||
| BGOS-984 | Опциональное поле `ReadOnly` в структуру запроса `DataDisk` в cloudbroker/kvmx86 и cloudapi/kvmx86 |
|
|
||||||
| BGOS-994 | Опциональное поле `QoSPolicies` в структуру запроса `Interface` в cloudbroker/kvmx86 и cloudapi/kvmx86 |
|
|
||||||
| BGOS-994 | Опциональное поле `QoSPolicies` в структуру запроса `InterfaceMassCreate` в cloudbroker/kvmx86 |
|
|
||||||
|
|
||||||
#### locations
|
|
||||||
| Идентификатор задачи | Описание |
|
|
||||||
| --- | --- |
|
|
||||||
| BGOS-992 | Вычисляемое поле `Budget` в структуру ответа `ItemLocation` в cloudapi/locations |
|
|
||||||
|
|
||||||
#### network qos policy
|
|
||||||
| Идентификатор задачи | Описание |
|
|
||||||
| --- | --- |
|
|
||||||
| BGOS-993 | Группа ручек `QoSPolicy` в cloudbroker/qospolicy и cloudapi/qospolicy |
|
|
||||||
|
|
||||||
#### resmon
|
|
||||||
| Идентификатор задачи | Описание |
|
|
||||||
| --- | --- |
|
|
||||||
| BGOS-981 | Вычисляемое поле `TotalVCPUs` в структуру ответа `GetByNodePoint` в cloudbroker/resmon |
|
|
||||||
|
|
||||||
#### rg
|
|
||||||
| Идентификатор задачи | Описание |
|
|
||||||
| --- | --- |
|
|
||||||
| BGOS-998 | Опциональное поле `IPCIDR` в структуру запроса `CreateRequest` в cloudbroker/rg |
|
|
||||||
|
|
||||||
#### tasks
|
|
||||||
| Идентификатор задачи | Описание |
|
|
||||||
| --- | --- |
|
|
||||||
| BGOS-996 | Опицональные поля `CreatedTimeAt` и `CreatedTimeTo` в структуру запроса `ListRequest` в cloudapi/tasks и cloudbroker/tasks |
|
|
||||||
| BGOS-996 | Вычисляемое поле `CreatedTime` в структуру ответа `RecordAsyncTask` в cloudapi/tasks |
|
|
||||||
| BGOS-996 | Вычисляемое поле `CreatedTime` в структуру ответа `ItemTask` в cloudbroker/tasks |
|
|
||||||
|
|
||||||
#### user
|
|
||||||
| Идентификатор задачи | Описание |
|
|
||||||
| --- | --- |
|
|
||||||
| BGOS-988 | Вычисляемые поля `Destroying`, `Confirmed` и `Deleted` в структуру ответа `Accounts` в cloudapi/user |
|
|
||||||
| BGOS-988 | Вычисляемые поля `Starting`, `Stopping`, `Paused`, `Pausing`, `Merge`, `Migrating`, `MigratingIn`, `MigratingOut`, `Down`, `Scheduled`, `BackupStopped`, `BackupRunning`, `Snapcreate`, `Cloning` и `Rollback` в структуру ответа `Computes` в cloudapi/user |
|
|
||||||
| BGOS-988 | Вычисляемые поля `Modeled`, `Created`, `Deleted`, `Deleting`, `Destroying`, `Disabling`, `Enabling` и `Restoring` в структуру ответа `RGs` в cloudapi/user |
|
|
||||||
|
|
||||||
#### vins
|
|
||||||
| Идентификатор задачи | Описание |
|
|
||||||
| --- | --- |
|
|
||||||
| BGOS-986 | Вычисляемое поле `EnableDefaultGateway` в структуру ответа `ItemVINS` в cloudapi/vins |
|
|
||||||
|
|
||||||
#### vgpu
|
|
||||||
| Идентификатор задачи | Описание |
|
|
||||||
| --- | --- |
|
|
||||||
| BGOS-980 | Опциональные поля `AccountIDs`, `MDEVType` и `PCIAddress` в структуру запроса `CreateRequest` в cloudbroker/vgpu |
|
|
||||||
| BGOS-980 | Опциональное поле `SplitMode` в структуру запроса `ListRequest` в cloudbroker/vgpu и cloudapi/vgpu |
|
|
||||||
| BGOS-980 | Вычисляемые поля `ComputeID`, `DeviceReference`, `MdevUUID`, `ParentPCIAddress`, `ProfileReference` и `SplitMode` в структуру ответа `ItemVGPU` в cloudbroker/vgpu и cloudapi/vgpu |
|
|
||||||
| BGOS-980 | Вычисляемое поле `BusNumber` в структуру ответа `ItemVGPU` в cloudbroker/vgpu |
|
|
||||||
|
|
||||||
#### zone
|
|
||||||
| Идентификатор задачи | Описание |
|
|
||||||
| --- | --- |
|
|
||||||
| BGOS-997 | Вычисляемые поля `SDRS`, `SDRSMode` и `LoggingLevel` в структуры ответа `RecordZone` и `ItemZone` в cloudapi/zone и cloudbroker/zone |
|
|
||||||
|
|
||||||
|
|
||||||
### Изменено
|
|
||||||
|
|
||||||
#### bservice
|
|
||||||
| Идентификатор задачи | Описание |
|
|
||||||
| --- | --- |
|
|
||||||
| BGOS-1003 | Тип опционального поля `UserData` в структуре запроса `GroupAddRequest` сo `string` на `interface{}` в cloudbroker/bservice и cloudapi/bservice |
|
|
||||||
|
|
||||||
#### compute
|
|
||||||
| Идентификатор задачи | Описание |
|
|
||||||
| --- | --- |
|
|
||||||
| BGOS-995 | Название вычисляемого поля `AccountID` на `AccountIDs` и тип с `uint64` на `[]uint64` в структуре ответа `ItemVGPU` в cloudbroker/compute и cloudapi/compute |
|
|
||||||
| BGOS-995 | Тип вычисляемого поля `VGPUs` с `[]VGPUItem` на `[]ItemVGPU` в структурах ответов `RecordCompute` и `SnapRecordCompute` в cloudbroker/compute и cloudapi/compute |
|
|
||||||
|
|
||||||
#### disks
|
|
||||||
| Идентификатор задачи | Описание |
|
|
||||||
| --- | --- |
|
|
||||||
| BGOS-987 | Тип опционального поля `Status` в структуре запроса `ListRequest` с `string` на `[]string` в cloudbroker/disks и cloudapi/disks |
|
|
||||||
|
|
||||||
#### k8s
|
|
||||||
| Идентификатор задачи | Описание |
|
|
||||||
| --- | --- |
|
|
||||||
| BGOS-1002 | Тип опционального поля `UserData` в структурах запросов `CreateRequest` и `UpdateWorkerNodesMetaDataRequest` со `string` на `interface{}` в cloudbroker/k8s и cloudapi/k8s |
|
|
||||||
|
|
||||||
#### node
|
|
||||||
| Идентификатор задачи | Описание |
|
|
||||||
| --- | --- |
|
|
||||||
| BGOS-982 | Тип вычисляемого поля `Total` с `ResourcesInfo` на `FreeResourcesInfo` в структуре ответа `ConsumptionInfo` в cloudbroker/node |
|
|
||||||
|
|
||||||
#### vgpu
|
|
||||||
| Идентификатор задачи | Описание |
|
|
||||||
| --- | --- |
|
|
||||||
| BGOS-980 | Тип опционального поля `ProfileID` в структуре запроса `CreateRequest` с `uint64` на `string` в cloudbroker/vgpu |
|
|
||||||
| BGOS-980 | Название вычисляемого поля `AccountID` на `AccountIDs` и тип с `uint64` на `[]uint64` в структуре ответа `ItemVGPU` в cloudbroker/vgpu и cloudapi/vgpu |
|
|
||||||
| BGOS-980 | Название опционального поля `NID` на `NodeID` в структуре запроса `ListRequest` в cloudbroker/vgpu и cloudapi/vgpu |
|
|
||||||
|
|
||||||
|
|
||||||
### Удалено
|
|
||||||
|
|
||||||
#### account
|
|
||||||
| Идентификатор задачи | Описание |
|
|
||||||
| --- | --- |
|
|
||||||
| BGOS-975 | Метод `Audits` из cloudapi/account и cloudbroker/account |
|
|
||||||
| BGOS-975 | Методы `Delete`, `Disable`, `Enable`, `GetConsumedCloudUnitsByType` и `GetReservedAccountUnits` из cloudapi/account |
|
|
||||||
| BGOS-975 | Методы `Disable` и `Enable` из cloudbroker/account |
|
|
||||||
|
|
||||||
#### compute
|
|
||||||
| Идентификатор задачи | Описание |
|
|
||||||
| --- | --- |
|
|
||||||
| BGOS-975 | Метод `Audits` из cloudapi/compute и cloudbroker/compute |
|
|
||||||
| BGOS-975 | Методы `ComputeCISet`, `ComputeCIUnset`, `GetLog` и `GetAudits` из cloudbroker/compute |
|
|
||||||
| BGOS-975 | Метод `GetAudits` из cloudapi/compute |
|
|
||||||
| BGOS-995 | Вычисляемые поля `LastClaimedBy`, `Mode`, `ProfileID`, `RAM`, `ReferenceID`, `RGID`, `Type` и `VMID` из структуры `ItemVGPU` в cloudbroker/compute и cloudapi/compute |
|
|
||||||
| BGOS-995 | Cтруктура `VGPUItem` в cloudbroker/compute и cloudapi/compute |
|
|
||||||
| BGOS-999 | Вычисляемое поле `RGID` из структуры ответа `ItemPCIDevice` в cloudbroker/compute и cloudapi/compute |
|
|
||||||
| BGOS-999 | Опциональное поле `RGID` из структуры запроса `ListPCIDeviceRequest` в cloudbroker/compute и cloudapi/compute |
|
|
||||||
|
|
||||||
#### grid
|
|
||||||
| Идентификатор задачи | Описание |
|
|
||||||
| --- | --- |
|
|
||||||
| BGOS-975 | Методы `ExecuteMaintenanceScript`, `ListEmails` и `ServicesRestart` из cloudbroker/grid |
|
|
||||||
|
|
||||||
#### group
|
|
||||||
| Идентификатор задачи | Описание |
|
|
||||||
| --- | --- |
|
|
||||||
| BGOS-975 | Метод `Get` из cloudbroker/group |
|
|
||||||
|
|
||||||
#### image
|
|
||||||
| Идентификатор задачи | Описание |
|
|
||||||
| --- | --- |
|
|
||||||
| BGOS-975 | Методы `ComputeCISet` и `ComputeCIUnset` из cloudbroker/image |
|
|
||||||
|
|
||||||
#### rg
|
|
||||||
| Идентификатор задачи | Описание |
|
|
||||||
| --- | --- |
|
|
||||||
| BGOS-975 | Метод `Audits` из cloudapi/rg и cloudbroker/rg |
|
|
||||||
|
|
||||||
#### sep
|
|
||||||
| Идентификатор задачи | Описание |
|
|
||||||
| --- | --- |
|
|
||||||
| BGOS-975 | Методы `AccessGrant`, `AccessGrantToPool`, `AccessRevoke` и `AccessRevokeToPool` из cloudbroker/sep |
|
|
||||||
|
|
||||||
#### user
|
|
||||||
| Идентификатор задачи | Описание |
|
|
||||||
| --- | --- |
|
|
||||||
| BGOS-975 | Метод `IsValidInviteUserToken` из cloudapi/user |
|
|
||||||
| BGOS-975 | Метод `GetAudit` из cloudapi/user и cloudbroker/user |
|
|
||||||
| BGOS-988 | Структуры `CSs` и `VMs` из структуры ответа `BriefResources` из cloudapi/user |
|
|
||||||
| BGOS-988 | Вычисляемое поле `Enabled` из структур ответов `Accounts` и `RGs` из cloudapi/user |
|
|
||||||
|
|
||||||
#### vins
|
|
||||||
| Идентификатор задачи | Описание |
|
|
||||||
| --- | --- |
|
|
||||||
| BGOS-975 | Метод `Audits` из cloudapi/vins и cloudbroker/vins |
|
|
||||||
|
|
||||||
#### vgpu
|
|
||||||
| Идентификатор задачи | Описание |
|
|
||||||
| --- | --- |
|
|
||||||
| BGOS-980 | Опциональные поля `RGID` и `Allocate` из структуры запроса `CreateRequest` в cloudbroker/vgpu |
|
|
||||||
| BGOS-980 | Опциональные поле `Force` из структуры запроса `DestroyRequest` в cloudbroker/vgpu |
|
|
||||||
| BGOS-980 | Опциональные поля `Type`, `Mode` и `RGID` из структуры запроса `ListRequest` в cloudbroker/vgpu и cloudapi/vgpu |
|
|
||||||
| BGOS-980 | Вычисляемые поля `LastClaimedBy`, `Mode`, `ProfileID`, `RAM`, `ReferenceID`, `RGID`, `Type` и `VMID` из структуры ответа `ItemVGPU` в cloudbroker/vgpu и cloudapi/vgpu |
|
|
||||||
| BGOS-980 | Методы `Allocate` и `Deallocate` из cloudbroker/vgpu |
|
|
||||||
|
|||||||
28
README.md
28
README.md
@@ -18,9 +18,6 @@ Decort SDK - это библиотека, написанная на языке G
|
|||||||
- Версия 1.11.х Decort-SDK соответствует 4.3.0 версии платформы
|
- Версия 1.11.х Decort-SDK соответствует 4.3.0 версии платформы
|
||||||
- Версия 1.12.х Decort-SDK соответствует 4.4.0 версии платформы
|
- Версия 1.12.х Decort-SDK соответствует 4.4.0 версии платформы
|
||||||
- Версия 1.13.х Decort-SDK соответствует 4.5.0 версии платформы
|
- Версия 1.13.х Decort-SDK соответствует 4.5.0 версии платформы
|
||||||
- Версия 1.14.х Decort-SDK соответствует 4.6.0 версии платформы
|
|
||||||
- Версия 1.15.х Decort-SDK соответствует 4.7.0 версии платформы
|
|
||||||
- Версия 1.16.х Decort-SDK соответствует 4.8.0 версии платформы
|
|
||||||
|
|
||||||
## Оглавление
|
## Оглавление
|
||||||
|
|
||||||
@@ -126,7 +123,6 @@ go get -u repository.basistech.ru/BASIS/decort-golang-sdk
|
|||||||
- `LB` - управление балансировщиками нагрузки;
|
- `LB` - управление балансировщиками нагрузки;
|
||||||
- `Locations` - получение информации о grid площадки;
|
- `Locations` - получение информации о grid площадки;
|
||||||
- `Prometheus` - получение статистики prometheus;
|
- `Prometheus` - получение статистики prometheus;
|
||||||
- `QoS Policy` - управление политиками качества обслуживания сети;
|
|
||||||
- `RG` - управление ресурсными группами аккаунта;
|
- `RG` - управление ресурсными группами аккаунта;
|
||||||
- `Security group` – управление группами безопасности;
|
- `Security group` – управление группами безопасности;
|
||||||
- `SEP` - управление storage endpoint (sep);
|
- `SEP` - управление storage endpoint (sep);
|
||||||
@@ -135,7 +131,6 @@ go get -u repository.basistech.ru/BASIS/decort-golang-sdk
|
|||||||
- `Trunk` - получение информации о транковых портах;
|
- `Trunk` - получение информации о транковых портах;
|
||||||
- `VFPool` - управление пулом виртуальных сетевых функций;
|
- `VFPool` - управление пулом виртуальных сетевых функций;
|
||||||
- `VINS` - управление виртуальными изолированными сетями;
|
- `VINS` - управление виртуальными изолированными сетями;
|
||||||
- `VGPU` - управление виртуальными графическими процессорами;
|
|
||||||
- `Zone` - управление зонами.
|
- `Zone` - управление зонами.
|
||||||
|
|
||||||
### Cloudbroker
|
### Cloudbroker
|
||||||
@@ -163,7 +158,6 @@ go get -u repository.basistech.ru/BASIS/decort-golang-sdk
|
|||||||
- `Node` - управление нодами платформы;
|
- `Node` - управление нодами платформы;
|
||||||
- `PCIDevice` - управление устройствами;
|
- `PCIDevice` - управление устройствами;
|
||||||
- `Prometheus` - получение статистики prometheus;
|
- `Prometheus` - получение статистики prometheus;
|
||||||
- `QoS Policy` - управление политиками качества обслуживания сети;
|
|
||||||
- `Resmon` - получение статистики resource monitoring;
|
- `Resmon` - получение статистики resource monitoring;
|
||||||
- `RG` - управление ресурсными группами аккаунта;
|
- `RG` - управление ресурсными группами аккаунта;
|
||||||
- `Security group` – управление группами безопасности;
|
- `Security group` – управление группами безопасности;
|
||||||
@@ -186,14 +180,12 @@ go get -u repository.basistech.ru/BASIS/decort-golang-sdk
|
|||||||
- `Address pool` - управление пулами адресов;
|
- `Address pool` - управление пулами адресов;
|
||||||
- `DefaultSecurityPolicies` - управление политиками хранения по умолчанию;
|
- `DefaultSecurityPolicies` - управление политиками хранения по умолчанию;
|
||||||
- `ExtNet` - управление виртуальными сетями, отвечающими за внешний доступ;
|
- `ExtNet` - управление виртуальными сетями, отвечающими за внешний доступ;
|
||||||
- `Hypervisors` - управление гипервизорами;
|
|
||||||
- `FloatingIPs` - управление плавающими IP-адресами;
|
- `FloatingIPs` - управление плавающими IP-адресами;
|
||||||
- `Logical ports` - управление логическими портами;
|
- `Logical ports` - управление логическими портами;
|
||||||
- `NetworkObjectGroups` - управление группами объектов сети;
|
- `NetworkObjectGroups` - управление группами объектов сети;
|
||||||
- `Routers` - управление роутерами;
|
- `Routers` - управление роутерами;
|
||||||
- `SecurityPolicies` - управление политиками хранения;
|
- `SecurityPolicies` - управление политиками хранения;
|
||||||
- `Segments` - управление сегментами;
|
- `Segments` - управление сегментами;
|
||||||
- `Version` - получение информации о версии SDN;
|
|
||||||
|
|
||||||
## Работа с библиотекой
|
## Работа с библиотекой
|
||||||
|
|
||||||
@@ -341,7 +333,6 @@ func main() {
|
|||||||
- `pkg/cloudapi/lb` - для `LB`
|
- `pkg/cloudapi/lb` - для `LB`
|
||||||
- `pkg/cloudapi/locations` - для `Locations`
|
- `pkg/cloudapi/locations` - для `Locations`
|
||||||
- `pkg/cloudapi/prometheus` - для `Prometheus`
|
- `pkg/cloudapi/prometheus` - для `Prometheus`
|
||||||
- `pkg/cloudapi/qospolicy` - для `QoS Policy`
|
|
||||||
- `pkg/cloudapi/rg` - для `RG`
|
- `pkg/cloudapi/rg` - для `RG`
|
||||||
- `pkg/cloudapi/secgroup` - для `Security group`
|
- `pkg/cloudapi/secgroup` - для `Security group`
|
||||||
- `pkg/cloudapi/sep` - для `SEP`
|
- `pkg/cloudapi/sep` - для `SEP`
|
||||||
@@ -350,7 +341,6 @@ func main() {
|
|||||||
- `pkg/cloudapi/trunk` - для `Trunk`
|
- `pkg/cloudapi/trunk` - для `Trunk`
|
||||||
- `pkg/cloudapi/vfpool` - для `VFPool`
|
- `pkg/cloudapi/vfpool` - для `VFPool`
|
||||||
- `pkg/cloudapi/vins` - для `VINS`
|
- `pkg/cloudapi/vins` - для `VINS`
|
||||||
- `pkg/cloudapi/vgpu` - для `VGPU`
|
|
||||||
- `pkg/cloudapi/zone` - для `Zone`
|
- `pkg/cloudapi/zone` - для `Zone`
|
||||||
- **cloudbroker**:
|
- **cloudbroker**:
|
||||||
- `pkg/cloudbroker/account` - для `Account`
|
- `pkg/cloudbroker/account` - для `Account`
|
||||||
@@ -373,7 +363,6 @@ func main() {
|
|||||||
- `pkg/cloudbroker/node` - для `Node`
|
- `pkg/cloudbroker/node` - для `Node`
|
||||||
- `pkg/cloudbroker/pcidevice` - для `PCIDevice`
|
- `pkg/cloudbroker/pcidevice` - для `PCIDevice`
|
||||||
- `pkg/cloudbroker/prometheus` - для `Prometheus`
|
- `pkg/cloudbroker/prometheus` - для `Prometheus`
|
||||||
- `pkg/cloudbroker/qospolicy` - для `QoS Policy`
|
|
||||||
- `pkg/cloudbroker/resmon` - для `Resmon`
|
- `pkg/cloudbroker/resmon` - для `Resmon`
|
||||||
- `pkg/cloudbroker/rg` - для `RG`
|
- `pkg/cloudbroker/rg` - для `RG`
|
||||||
- `pkg/cloudbroker/secgroup` - для `Security group`
|
- `pkg/cloudbroker/secgroup` - для `Security group`
|
||||||
@@ -391,14 +380,12 @@ func main() {
|
|||||||
- `pkg/sdn/adrspools` - для `Address pool`
|
- `pkg/sdn/adrspools` - для `Address pool`
|
||||||
- `pkg/sdn/defsecpolicies` - для `DefaultSecurityPolicies`
|
- `pkg/sdn/defsecpolicies` - для `DefaultSecurityPolicies`
|
||||||
- `pkg/sdn/external_networks` - для `ExtNet`
|
- `pkg/sdn/external_networks` - для `ExtNet`
|
||||||
- `pkg/sdn/hypervisors` - для `Hypervisors`
|
|
||||||
- `pkg/sdn/flips` - для `FloatingIPs`
|
- `pkg/sdn/flips` - для `FloatingIPs`
|
||||||
- `pkg/sdn/logicalports` - для `Logical ports`
|
- `pkg/sdn/logicalports` - для `Logical ports`
|
||||||
- `pkg/sdn/netobjgroups` - для `NetworkObjectGroups`
|
- `pkg/sdn/netobjgroups` - для `NetworkObjectGroups`
|
||||||
- `pkg/sdn/routers` - для `Routers`
|
- `pkg/sdn/routers` - для `Routers`
|
||||||
- `pkg/sdn/secpolicies` - для `SecurityPolicies`
|
- `pkg/sdn/secpolicies` - для `SecurityPolicies`
|
||||||
- `pkg/sdn/segments` - для `Segments`
|
- `pkg/sdn/segments` - для `Segments`
|
||||||
- `pkg/sdn/version` - для `Version`
|
|
||||||
|
|
||||||
Все поля структуры имеют описание, в которых содержится:
|
Все поля структуры имеют описание, в которых содержится:
|
||||||
|
|
||||||
@@ -479,6 +466,16 @@ type CreateRequest struct {
|
|||||||
// Node ID
|
// Node ID
|
||||||
// Required: false
|
// Required: false
|
||||||
NodeID uint64 `url:"nodeId,omitempty" json:"nodeId,omitempty"`
|
NodeID uint64 `url:"nodeId,omitempty" json:"nodeId,omitempty"`
|
||||||
|
|
||||||
|
// System name
|
||||||
|
// Required: false
|
||||||
|
IS string `url:"IS,omitempty" json:"IS,omitempty"`
|
||||||
|
|
||||||
|
// Compute purpose
|
||||||
|
// Required: false
|
||||||
|
IPAType string `url:"ipaType,omitempty" json:"ipaType,omitempty"`
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -542,7 +539,6 @@ func main() {
|
|||||||
- `.LB()` - для работы с `LB`
|
- `.LB()` - для работы с `LB`
|
||||||
- `.Locations()` - для работы с `Locations`
|
- `.Locations()` - для работы с `Locations`
|
||||||
- `.Prometheus()` - для работы с `Prometheus`
|
- `.Prometheus()` - для работы с `Prometheus`
|
||||||
- `.QoSPolicy()` - для работы с `QoS Policy`
|
|
||||||
- `.RG()` - для работы с `RG`
|
- `.RG()` - для работы с `RG`
|
||||||
- `.SecurityGroup()` - для работы с `Security Group`
|
- `.SecurityGroup()` - для работы с `Security Group`
|
||||||
- `.SEP()` - для работы с `SEP`
|
- `.SEP()` - для работы с `SEP`
|
||||||
@@ -551,7 +547,6 @@ func main() {
|
|||||||
- `.Trunk()` - для работы с `Trunk`
|
- `.Trunk()` - для работы с `Trunk`
|
||||||
- `.VFPool()` - для работы с `VFPool`
|
- `.VFPool()` - для работы с `VFPool`
|
||||||
- `.VINS()` - для работы с `VINS`
|
- `.VINS()` - для работы с `VINS`
|
||||||
- `.VGPU()` - для работы с `VGPU`
|
|
||||||
- `.Zone()` - для работы с `Zone`
|
- `.Zone()` - для работы с `Zone`
|
||||||
|
|
||||||
Доступные методы для `.CloudBroker()`:
|
Доступные методы для `.CloudBroker()`:
|
||||||
@@ -576,7 +571,6 @@ func main() {
|
|||||||
- `.Node()` - для работы с `Node`
|
- `.Node()` - для работы с `Node`
|
||||||
- `.PCIDevice()` - для работы с `PCIDevice`
|
- `.PCIDevice()` - для работы с `PCIDevice`
|
||||||
- `.Prometheus()` - для работы с `Prometheus`
|
- `.Prometheus()` - для работы с `Prometheus`
|
||||||
- `.QoSPolicy()` - для работы с `QoS Policy`
|
|
||||||
- `.Resmon()` - для работы с `Resmon`
|
- `.Resmon()` - для работы с `Resmon`
|
||||||
- `.RG()` - для работы с `RG`
|
- `.RG()` - для работы с `RG`
|
||||||
- `.SecurityGroup()` - для работы с `Security Group`
|
- `.SecurityGroup()` - для работы с `Security Group`
|
||||||
@@ -596,14 +590,12 @@ func main() {
|
|||||||
- `.AddressPool()` - для работы с `Addres pool`
|
- `.AddressPool()` - для работы с `Addres pool`
|
||||||
- `.DefaultSecurityPolicies()` - для работы с `DefaultSecurityPolicies`
|
- `.DefaultSecurityPolicies()` - для работы с `DefaultSecurityPolicies`
|
||||||
- `.ExtNet()` - для работы с `ExtNet`
|
- `.ExtNet()` - для работы с `ExtNet`
|
||||||
- `.Hypervisors()` - для работы с `Hypervisors`
|
|
||||||
- `.FloatingIPs()` - для работы с `FloatingIPs`
|
- `.FloatingIPs()` - для работы с `FloatingIPs`
|
||||||
- `.LogicalPorts()` - для работы с `Logical ports`
|
- `.LogicalPorts()` - для работы с `Logical ports`
|
||||||
- `.NetworkObjectGroups()` - для работы с `NetworkObjectGroups`
|
- `.NetworkObjectGroups()` - для работы с `NetworkObjectGroups`
|
||||||
- `.Routers()` - для работы с `Routers`
|
- `.Routers()` - для работы с `Routers`
|
||||||
- `.SecurityPolicies()` - для работы с `SecurityPolicies`
|
- `.SecurityPolicies()` - для работы с `SecurityPolicies`
|
||||||
- `.Segments()` - для работы с `Segments`
|
- `.Segments()` - для работы с `Segments`
|
||||||
- `.Version()` - для работы с `Version`
|
|
||||||
|
|
||||||
3. Вызвать метод, отвечающий за выполнение запроса и передать в него:
|
3. Вызвать метод, отвечающий за выполнение запроса и передать в него:
|
||||||
|
|
||||||
|
|||||||
@@ -34,12 +34,8 @@ type DecortClient struct {
|
|||||||
mutex *sync.Mutex
|
mutex *sync.Mutex
|
||||||
}
|
}
|
||||||
|
|
||||||
// Client builder
|
// Сlient builder
|
||||||
func New(cfg config.Config) *DecortClient {
|
func New(cfg config.Config) *DecortClient {
|
||||||
if err := validators.ValidateConfig(cfg); err != nil {
|
|
||||||
panic(validators.ValidationErrors(validators.GetErrors(err)))
|
|
||||||
}
|
|
||||||
|
|
||||||
if cfg.Retries == 0 {
|
if cfg.Retries == 0 {
|
||||||
cfg.Retries = 5
|
cfg.Retries = 5
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ import (
|
|||||||
"github.com/google/go-querystring/query"
|
"github.com/google/go-querystring/query"
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/config"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/config"
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants"
|
"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/cloudapi"
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker"
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/sdn"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/sdn"
|
||||||
@@ -39,10 +38,6 @@ type tokenJSON struct {
|
|||||||
|
|
||||||
// Сlient builder
|
// Сlient builder
|
||||||
func NewBVS(cfg config.BVSConfig) *BVSDecortClient {
|
func NewBVS(cfg config.BVSConfig) *BVSDecortClient {
|
||||||
if err := validators.ValidateConfig(cfg); err != nil {
|
|
||||||
panic(validators.ValidationErrors(validators.GetErrors(err)))
|
|
||||||
}
|
|
||||||
|
|
||||||
if cfg.Retries == 0 {
|
if cfg.Retries == 0 {
|
||||||
cfg.Retries = 5
|
cfg.Retries = 5
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,9 +28,6 @@ var FileName = map[string]string{
|
|||||||
var K8sValues = []string{"labels", "taints", "annotations, additionalSANs"}
|
var K8sValues = []string{"labels", "taints", "annotations, additionalSANs"}
|
||||||
|
|
||||||
var VersionMap = map[string]string{
|
var VersionMap = map[string]string{
|
||||||
"4.8.0": "-",
|
|
||||||
"4.7.0": "-",
|
|
||||||
"4.6.0": "-",
|
|
||||||
"4.5.0": "-",
|
"4.5.0": "-",
|
||||||
"4.4.0": "-",
|
"4.4.0": "-",
|
||||||
"4.3.0": "-",
|
"4.3.0": "-",
|
||||||
|
|||||||
@@ -86,6 +86,13 @@ func computeModeValidator(fe validator.FieldLevel) bool {
|
|||||||
return IsInSlice(fieldValue, computeModeValues)
|
return IsInSlice(fieldValue, computeModeValues)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// computeDiskTypeValidator is used to validate DiskType field.
|
||||||
|
func computeDiskTypeValidator(fe validator.FieldLevel) bool {
|
||||||
|
fieldValue := fe.Field().String()
|
||||||
|
|
||||||
|
return IsInSlice(fieldValue, computeDiskTypeValues)
|
||||||
|
}
|
||||||
|
|
||||||
// computeNetTypeValidator is used to validate NetType field.
|
// computeNetTypeValidator is used to validate NetType field.
|
||||||
func computeNetTypeValidator(fe validator.FieldLevel) bool {
|
func computeNetTypeValidator(fe validator.FieldLevel) bool {
|
||||||
fieldValue := fe.Field().String()
|
fieldValue := fe.Field().String()
|
||||||
@@ -144,6 +151,13 @@ func computeDataDisksValidator(fe validator.FieldLevel) bool {
|
|||||||
return IsInSlice(fieldValue, computeDataDisksValues)
|
return IsInSlice(fieldValue, computeDataDisksValues)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// diskTypeValidator is used to validate Type field.
|
||||||
|
func diskTypeValidator(fe validator.FieldLevel) bool {
|
||||||
|
fieldValue := fe.Field().String()
|
||||||
|
|
||||||
|
return IsInSlice(fieldValue, diskTypeValues)
|
||||||
|
}
|
||||||
|
|
||||||
// flipgroupClientTypeValidator is used to validate ClientType field.
|
// flipgroupClientTypeValidator is used to validate ClientType field.
|
||||||
func flipgroupClientTypeValidator(fe validator.FieldLevel) bool {
|
func flipgroupClientTypeValidator(fe validator.FieldLevel) bool {
|
||||||
fieldValue := fe.Field().String()
|
fieldValue := fe.Field().String()
|
||||||
@@ -350,10 +364,6 @@ func isBoolTypeValidator(fe validator.FieldLevel) bool {
|
|||||||
return fe.Field().CanConvert(reflect.TypeOf(true))
|
return fe.Field().CanConvert(reflect.TypeOf(true))
|
||||||
}
|
}
|
||||||
|
|
||||||
func isStringTypeValidator(fe validator.FieldLevel) bool {
|
|
||||||
return fe.Field().Kind() == reflect.String
|
|
||||||
}
|
|
||||||
|
|
||||||
func urlValidartor(fl validator.FieldLevel) bool {
|
func urlValidartor(fl validator.FieldLevel) bool {
|
||||||
fieldValues := fl.Field().String()
|
fieldValues := fl.Field().String()
|
||||||
|
|
||||||
@@ -468,29 +478,3 @@ func sepTechStatusValidator(fe validator.FieldLevel) bool {
|
|||||||
|
|
||||||
return IsInSlice(fieldValue, sepTechStatusValues)
|
return IsInSlice(fieldValue, sepTechStatusValues)
|
||||||
}
|
}
|
||||||
|
|
||||||
// pciDeviceHWPathValidator is used to validate PCI device hardware path fields (e.g. 0000:81:00.0)
|
|
||||||
func pciDeviceHWPathValidator(fe validator.FieldLevel) bool {
|
|
||||||
fieldValue := fe.Field().String()
|
|
||||||
|
|
||||||
ok, _ := regexp.MatchString(`^[0-9a-fA-F]{4}:[0-9a-fA-F]{2}:[0-9a-fA-F]{2}\.[0-7]$`, fieldValue)
|
|
||||||
return ok
|
|
||||||
}
|
|
||||||
|
|
||||||
// sepNameValidator is used to validate SEP name fields
|
|
||||||
func sepNameValidator(fe validator.FieldLevel) bool {
|
|
||||||
ok, _ := regexp.MatchString(`^[a-zA-Zа-яА-ЯёЁ0-9][a-zA-Zа-яА-ЯёЁ0-9_.\[\]()\-]*$`, fe.Field().String())
|
|
||||||
return ok
|
|
||||||
}
|
|
||||||
|
|
||||||
// sepDescriptionValidator is used to validate SEP description fields
|
|
||||||
func sepDescriptionValidator(fe validator.FieldLevel) bool {
|
|
||||||
ok, _ := regexp.MatchString(`^[a-zA-Zа-яА-ЯёЁ0-9_.\[\]()\-]*$`, fe.Field().String())
|
|
||||||
return ok
|
|
||||||
}
|
|
||||||
|
|
||||||
func watchdogActionValidator(fe validator.FieldLevel) bool {
|
|
||||||
fieldValue := fe.Field().String()
|
|
||||||
|
|
||||||
return IsInSlice(fieldValue, watchdogActionVaues)
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -15,10 +15,6 @@ func errorMessage(fe validator.FieldError) string {
|
|||||||
// Common Validators
|
// Common Validators
|
||||||
case "required":
|
case "required":
|
||||||
return fmt.Sprintf("%s %s is required", prefix, fe.Field())
|
return fmt.Sprintf("%s %s is required", prefix, fe.Field())
|
||||||
case "required_without_all":
|
|
||||||
return fmt.Sprintf("%s at least one of the following must be specified: %s",
|
|
||||||
prefix,
|
|
||||||
joinValues(append([]string{fe.Field()}, strings.Fields(fe.Param())...)))
|
|
||||||
case "gt":
|
case "gt":
|
||||||
return fmt.Sprintf("%s %s can't be less or equal to zero", prefix, fe.Field())
|
return fmt.Sprintf("%s %s can't be less or equal to zero", prefix, fe.Field())
|
||||||
case "min":
|
case "min":
|
||||||
@@ -29,12 +25,8 @@ func errorMessage(fe validator.FieldError) string {
|
|||||||
return fmt.Sprintf("%s %s: unexpected URL format", prefix, fe.Field())
|
return fmt.Sprintf("%s %s: unexpected URL format", prefix, fe.Field())
|
||||||
case "email":
|
case "email":
|
||||||
return fmt.Sprintf("%s %s: unexpected E-Mail format", prefix, fe.Field())
|
return fmt.Sprintf("%s %s: unexpected E-Mail format", prefix, fe.Field())
|
||||||
case "mac":
|
|
||||||
return fmt.Sprintf("%s %s: unexpected MAC address format", prefix, fe.Field())
|
|
||||||
case "isBool":
|
case "isBool":
|
||||||
return fmt.Sprintf("%s %s: must be bool type", prefix, fe.Field())
|
return fmt.Sprintf("%s %s: must be bool type", prefix, fe.Field())
|
||||||
case "isString":
|
|
||||||
return fmt.Sprintf("%s %s: must be string type", prefix, fe.Field())
|
|
||||||
|
|
||||||
case "accessType":
|
case "accessType":
|
||||||
return fmt.Sprintf("%s %s must be one of the following: %s",
|
return fmt.Sprintf("%s %s must be one of the following: %s",
|
||||||
@@ -94,6 +86,12 @@ func errorMessage(fe validator.FieldError) string {
|
|||||||
fe.Field(),
|
fe.Field(),
|
||||||
joinValues(computeModeValues))
|
joinValues(computeModeValues))
|
||||||
|
|
||||||
|
case "computeDiskType":
|
||||||
|
return fmt.Sprintf("%s %s must be one of the following: %s",
|
||||||
|
prefix,
|
||||||
|
fe.Field(),
|
||||||
|
joinValues(computeDiskTypeValues))
|
||||||
|
|
||||||
case "mtu":
|
case "mtu":
|
||||||
return fmt.Sprint(prefix, fe.Field(), "must be ", mtuMin, "-", mtuMax)
|
return fmt.Sprint(prefix, fe.Field(), "must be ", mtuMin, "-", mtuMax)
|
||||||
|
|
||||||
@@ -124,6 +122,13 @@ func errorMessage(fe validator.FieldError) string {
|
|||||||
fe.Field(),
|
fe.Field(),
|
||||||
joinValues(computeDataDisksValues))
|
joinValues(computeDataDisksValues))
|
||||||
|
|
||||||
|
// Disk Validators
|
||||||
|
case "diskType":
|
||||||
|
return fmt.Sprintf("%s %s must be one of the following: %s",
|
||||||
|
prefix,
|
||||||
|
fe.Field(),
|
||||||
|
joinValues(diskTypeValues))
|
||||||
|
|
||||||
// Flipgroup Validators
|
// Flipgroup Validators
|
||||||
case "flipgroupClientType":
|
case "flipgroupClientType":
|
||||||
return fmt.Sprintf("%s %s must be one of the following: %s",
|
return fmt.Sprintf("%s %s must be one of the following: %s",
|
||||||
|
|||||||
@@ -86,6 +86,11 @@ func registerAllValidators(validate *validator.Validate) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
err = validate.RegisterValidation("computeDiskType", computeDiskTypeValidator)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
err = validate.RegisterValidation("computeNetType", computeNetTypeValidator)
|
err = validate.RegisterValidation("computeNetType", computeNetTypeValidator)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -106,6 +111,11 @@ func registerAllValidators(validate *validator.Validate) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
err = validate.RegisterValidation("diskType", diskTypeValidator)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
err = validate.RegisterValidation("flipgroupClientType", flipgroupClientTypeValidator)
|
err = validate.RegisterValidation("flipgroupClientType", flipgroupClientTypeValidator)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -231,11 +241,6 @@ func registerAllValidators(validate *validator.Validate) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
err = validate.RegisterValidation("isString", isStringTypeValidator)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
err = validate.RegisterValidation("url", urlValidartor)
|
err = validate.RegisterValidation("url", urlValidartor)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -311,25 +316,5 @@ func registerAllValidators(validate *validator.Validate) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
err = validate.RegisterValidation("pciDeviceHWPath", pciDeviceHWPathValidator)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
err = validate.RegisterValidation("sepName", sepNameValidator)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
err = validate.RegisterValidation("sepDescription", sepDescriptionValidator)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
err = validate.RegisterValidation("watchdogAction", watchdogActionValidator)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,11 +14,14 @@ var (
|
|||||||
computeTopologyValues = []string{"compute", "node"}
|
computeTopologyValues = []string{"compute", "node"}
|
||||||
computePolicyValues = []string{"RECOMMENDED", "REQUIRED"}
|
computePolicyValues = []string{"RECOMMENDED", "REQUIRED"}
|
||||||
computeModeValues = []string{"EQ", "EN", "ANY"}
|
computeModeValues = []string{"EQ", "EN", "ANY"}
|
||||||
|
computeDiskTypeValues = []string{"D", "B"}
|
||||||
computeNetTypeValues = []string{"EXTNET", "VINS"}
|
computeNetTypeValues = []string{"EXTNET", "VINS"}
|
||||||
computex86NetTypeValues = []string{"EXTNET", "VINS", "VFNIC", "DPDK", "SDN", "EMPTY", "TRUNK"}
|
computex86NetTypeValues = []string{"EXTNET", "VINS", "VFNIC", "DPDK", "SDN", "EMPTY", "TRUNK"}
|
||||||
computeOrderValues = []string{"cdrom", "network", "hd"}
|
computeOrderValues = []string{"cdrom", "network", "hd"}
|
||||||
computeDataDisksValues = []string{"KEEP", "DETACH", "DESTROY"}
|
computeDataDisksValues = []string{"KEEP", "DETACH", "DESTROY"}
|
||||||
|
|
||||||
|
diskTypeValues = []string{"B", "T", "D"}
|
||||||
|
|
||||||
flipgroupClientTypeValues = []string{"compute", "vins"}
|
flipgroupClientTypeValues = []string{"compute", "vins"}
|
||||||
|
|
||||||
massCreateNetTypeValues = []string{"EXTNET", "VINS", "TRUNK"}
|
massCreateNetTypeValues = []string{"EXTNET", "VINS", "TRUNK"}
|
||||||
@@ -47,7 +50,7 @@ var (
|
|||||||
|
|
||||||
vmActionValues = []string{"stop", "move"}
|
vmActionValues = []string{"stop", "move"}
|
||||||
|
|
||||||
computeFeaturesValues = []string{"hugepages", "numa", "cpupin", "vfnic", "dpdk", "changemac", "trunk", "vgpu", "pcidevice"}
|
computeFeaturesValues = []string{"hugepages", "numa", "cpupin", "vfnic", "dpdk", "changemac", "trunk"}
|
||||||
|
|
||||||
networkInterfaceNamingValues = []string{"eth", "ens"}
|
networkInterfaceNamingValues = []string{"eth", "ens"}
|
||||||
|
|
||||||
@@ -80,12 +83,10 @@ var (
|
|||||||
ipTypeValues = []string{"v4, v6"}
|
ipTypeValues = []string{"v4, v6"}
|
||||||
|
|
||||||
sepTechStatusValues = []string{"ENABLED", "DISABLED"}
|
sepTechStatusValues = []string{"ENABLED", "DISABLED"}
|
||||||
|
|
||||||
watchdogActionVaues = []string{"reset", "shutdown", "poweroff", "pause", "none"}
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
mtuMin = 1500
|
mtuMin = 1
|
||||||
mtuMax = 9216
|
mtuMax = 9216
|
||||||
|
|
||||||
trunkTagsMin = 1
|
trunkTagsMin = 1
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ import (
|
|||||||
"github.com/google/go-querystring/query"
|
"github.com/google/go-querystring/query"
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/config"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/config"
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants"
|
"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/cloudapi"
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker"
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/sdn"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/sdn"
|
||||||
@@ -33,10 +32,6 @@ type LegacyDecortClient struct {
|
|||||||
|
|
||||||
// Legacy client builder
|
// Legacy client builder
|
||||||
func NewLegacy(cfg config.LegacyConfig) *LegacyDecortClient {
|
func NewLegacy(cfg config.LegacyConfig) *LegacyDecortClient {
|
||||||
if err := validators.ValidateConfig(cfg); err != nil {
|
|
||||||
panic(validators.ValidationErrors(validators.GetErrors(err)))
|
|
||||||
}
|
|
||||||
|
|
||||||
if cfg.Retries == 0 {
|
if cfg.Retries == 0 {
|
||||||
cfg.Retries = 5
|
cfg.Retries = 5
|
||||||
}
|
}
|
||||||
|
|||||||
40
pkg/cloudapi/account/audits.go
Normal file
40
pkg/cloudapi/account/audits.go
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
package account
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"encoding/json"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
|
)
|
||||||
|
|
||||||
|
// AuditsRequest struct to give list of account audits
|
||||||
|
type AuditsRequest struct {
|
||||||
|
// ID of the account
|
||||||
|
// Required: true
|
||||||
|
AccountID uint64 `url:"accountId" json:"accountId" validate:"required"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Audits gets audit records for the specified account object
|
||||||
|
func (a Account) Audits(ctx context.Context, req AuditsRequest) (ListAudits, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudapi/account/audits"
|
||||||
|
|
||||||
|
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
list := ListAudits{}
|
||||||
|
|
||||||
|
err = json.Unmarshal(res, &list)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return list, nil
|
||||||
|
}
|
||||||
36
pkg/cloudapi/account/delete.go
Normal file
36
pkg/cloudapi/account/delete.go
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
package account
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
|
)
|
||||||
|
|
||||||
|
// DeleteRequest struct to delete account
|
||||||
|
type DeleteRequest struct {
|
||||||
|
// ID of account to delete
|
||||||
|
// Required: true
|
||||||
|
AccountID uint64 `url:"accountId" json:"accountId" validate:"required"`
|
||||||
|
|
||||||
|
// Whether to completely delete the account
|
||||||
|
// Required: false
|
||||||
|
Permanently bool `url:"permanently,omitempty" json:"permanently,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delete completes delete an account from the system Returns true if account is deleted or was already deleted or never existed
|
||||||
|
func (a Account) Delete(ctx context.Context, req DeleteRequest) (string, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudapi/account/delete"
|
||||||
|
|
||||||
|
result, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
|
||||||
|
return string(result), nil
|
||||||
|
}
|
||||||
60
pkg/cloudapi/account/disable_enable.go
Normal file
60
pkg/cloudapi/account/disable_enable.go
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
package account
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"net/http"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
|
)
|
||||||
|
|
||||||
|
// DisableEnableRequest struct to change status of account
|
||||||
|
type DisableEnableRequest struct {
|
||||||
|
// ID of account
|
||||||
|
// Required: true
|
||||||
|
AccountID uint64 `url:"accountId" json:"accountId" validate:"required"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Disable disables an account
|
||||||
|
func (a Account) Disable(ctx context.Context, req DisableEnableRequest) (bool, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudapi/account/disable"
|
||||||
|
|
||||||
|
res, err := a.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
|
||||||
|
}
|
||||||
|
|
||||||
|
// Enable enables an account
|
||||||
|
func (a Account) Enable(ctx context.Context, req DisableEnableRequest) (bool, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudapi/account/enable"
|
||||||
|
|
||||||
|
res, err := a.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
|
||||||
|
}
|
||||||
51
pkg/cloudapi/account/get_consumed_cloud_units_by_type.go
Normal file
51
pkg/cloudapi/account/get_consumed_cloud_units_by_type.go
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
package account
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"net/http"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
|
)
|
||||||
|
|
||||||
|
// GetConsumedCloudUnitsByTypeRequest struct to calculate the currently consumed cloud units of the specified type for all cloudspaces and resource groups in the account
|
||||||
|
type GetConsumedCloudUnitsByTypeRequest struct {
|
||||||
|
// ID an account
|
||||||
|
// Required: true
|
||||||
|
AccountID uint64 `url:"accountId" json:"accountId" validate:"required"`
|
||||||
|
|
||||||
|
// Cloud unit resource type
|
||||||
|
// Required: true
|
||||||
|
CUType string `url:"cutype" json:"cutype" validate:"required,accountCUType"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetConsumedCloudUnitsByType calculates the currently consumed cloud units of the specified type for all cloudspaces
|
||||||
|
// and resource groups in the account.
|
||||||
|
// Possible types of cloud units are include:
|
||||||
|
//
|
||||||
|
// - CU_M: returns consumed memory in MB
|
||||||
|
// - CU_C: returns number of virtual cpu cores
|
||||||
|
// - CU_D: returns consumed virtual disk storage in GB
|
||||||
|
// - CU_DM: returns consumed max virtual disk storage in GB
|
||||||
|
// - CU_I: returns number of public IPs
|
||||||
|
// - gpu_units: return number of GPU units
|
||||||
|
func (a Account) GetConsumedCloudUnitsByType(ctx context.Context, req GetConsumedCloudUnitsByTypeRequest) (float64, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
return 0, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudapi/account/getConsumedCloudUnitsByType"
|
||||||
|
|
||||||
|
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err := strconv.ParseFloat(string(res), 64)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
47
pkg/cloudapi/account/get_reserved_account_units.go
Normal file
47
pkg/cloudapi/account/get_reserved_account_units.go
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
package account
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"encoding/json"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
|
)
|
||||||
|
|
||||||
|
// GetReservedAccountUnitsRequest struct to calculate the reserved units for all cloudspaces and resource groups in the account
|
||||||
|
type GetReservedAccountUnitsRequest struct {
|
||||||
|
// ID an account
|
||||||
|
// Required: true
|
||||||
|
AccountID uint64 `url:"accountId" json:"accountId" validate:"required"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetReservedAccountUnits calculates the reserved units for all cloudspaces and resource groups in the account.
|
||||||
|
// Calculated cloud units are returned in a dict which includes:
|
||||||
|
//
|
||||||
|
// - CU_M: reserved memory in MB
|
||||||
|
// - CU_C: number of cpu cores
|
||||||
|
// - CU_D: reserved vdisk storage in GB
|
||||||
|
// - CU_DM: reserved max vdisk storage in GB
|
||||||
|
// - CU_I: number of public IPs
|
||||||
|
func (a Account) GetReservedAccountUnits(ctx context.Context, req GetReservedAccountUnitsRequest) (*ResourceLimits, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudapi/account/getReservedAccountUnits"
|
||||||
|
|
||||||
|
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
info := ResourceLimits{}
|
||||||
|
|
||||||
|
err = json.Unmarshal(res, &info)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return &info, nil
|
||||||
|
}
|
||||||
@@ -95,9 +95,6 @@ type ItemAccount struct {
|
|||||||
// Deleted time
|
// Deleted time
|
||||||
DeletedTime uint64 `json:"deletedTime"`
|
DeletedTime uint64 `json:"deletedTime"`
|
||||||
|
|
||||||
// Deleted by
|
|
||||||
DeletedBy string `json:"deletedBy"`
|
|
||||||
|
|
||||||
// Description
|
// Description
|
||||||
Description string `json:"desc"`
|
Description string `json:"desc"`
|
||||||
|
|
||||||
@@ -110,9 +107,6 @@ type ItemAccount struct {
|
|||||||
// Status
|
// Status
|
||||||
Status string `json:"status"`
|
Status string `json:"status"`
|
||||||
|
|
||||||
// Updated by
|
|
||||||
UpdatedBy string `json:"updatedBy"`
|
|
||||||
|
|
||||||
// Updated time
|
// Updated time
|
||||||
UpdatedTime uint64 `json:"updatedTime"`
|
UpdatedTime uint64 `json:"updatedTime"`
|
||||||
|
|
||||||
@@ -203,56 +197,11 @@ type ListResourceConsumption struct {
|
|||||||
|
|
||||||
// Information about computes
|
// Information about computes
|
||||||
type Computes struct {
|
type Computes struct {
|
||||||
// Number of starting computes
|
|
||||||
Starting uint64 `json:"STARTING"`
|
|
||||||
|
|
||||||
// Number of started computes
|
// Number of started computes
|
||||||
Started uint64 `json:"STARTED"`
|
Started uint64 `json:"started"`
|
||||||
|
|
||||||
// Number of stopping computes
|
|
||||||
Stopping uint64 `json:"STOPPING"`
|
|
||||||
|
|
||||||
// Number of stopped computes
|
// Number of stopped computes
|
||||||
Stopped uint64 `json:"STOPPED"`
|
Stopped uint64 `json:"stopped"`
|
||||||
|
|
||||||
// Number of paused computes
|
|
||||||
Paused uint64 `json:"PAUSED"`
|
|
||||||
|
|
||||||
// Number of pausing computes
|
|
||||||
Pausing uint64 `json:"PAUSING"`
|
|
||||||
|
|
||||||
// Number of merging computes
|
|
||||||
Merge uint64 `json:"MERGE"`
|
|
||||||
|
|
||||||
// Number of migrating computes
|
|
||||||
Migrating uint64 `json:"MIGRATING"`
|
|
||||||
|
|
||||||
// Number of computes migrating in
|
|
||||||
MigratingIn uint64 `json:"MIGRATING_IN"`
|
|
||||||
|
|
||||||
// Number of computes migrating out
|
|
||||||
MigratingOut uint64 `json:"MIGRATING_OUT"`
|
|
||||||
|
|
||||||
// Number of computes in down status
|
|
||||||
Down uint64 `json:"DOWN"`
|
|
||||||
|
|
||||||
// Number of scheduled computes
|
|
||||||
Scheduled uint64 `json:"SCHEDULED"`
|
|
||||||
|
|
||||||
// Number of computes with stopped backup
|
|
||||||
BackupStopped uint64 `json:"BACKUP_STOPPED"`
|
|
||||||
|
|
||||||
// Number of computes with running backup
|
|
||||||
BackupRunning uint64 `json:"BACKUP_RUNNING"`
|
|
||||||
|
|
||||||
// Number of computes creating a snapshot
|
|
||||||
Snapcreate uint64 `json:"SNAPCREATE"`
|
|
||||||
|
|
||||||
// Number of cloning computes
|
|
||||||
Cloning uint64 `json:"CLONING"`
|
|
||||||
|
|
||||||
// Number of computes being rolled back
|
|
||||||
Rollback uint64 `json:"ROLLBACK"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Information about machines
|
// Information about machines
|
||||||
@@ -297,7 +246,7 @@ type RecordAccount struct {
|
|||||||
CPUAllocationParameter string `json:"cpu_allocation_parameter"`
|
CPUAllocationParameter string `json:"cpu_allocation_parameter"`
|
||||||
|
|
||||||
// CPU allocation ratio
|
// CPU allocation ratio
|
||||||
CPUAllocationRatio uint64 `json:"cpu_allocation_ratio"`
|
CPUAllocationRatio float64 `json:"cpu_allocation_ratio"`
|
||||||
|
|
||||||
// Created by
|
// Created by
|
||||||
CreatedBy string `json:"createdBy"`
|
CreatedBy string `json:"createdBy"`
|
||||||
@@ -350,9 +299,6 @@ type RecordAccount struct {
|
|||||||
// UniqPools
|
// UniqPools
|
||||||
UniqPools []interface{} `json:"uniqPools"`
|
UniqPools []interface{} `json:"uniqPools"`
|
||||||
|
|
||||||
// Updated By
|
|
||||||
UpdatedBy string `json:"updatedBy"`
|
|
||||||
|
|
||||||
// Updated time
|
// Updated time
|
||||||
UpdatedTime uint64 `json:"updatedTime"`
|
UpdatedTime uint64 `json:"updatedTime"`
|
||||||
|
|
||||||
@@ -500,9 +446,6 @@ type ItemVINS struct {
|
|||||||
// Deleted time
|
// Deleted time
|
||||||
DeletedTime uint64 `json:"deletedTime"`
|
DeletedTime uint64 `json:"deletedTime"`
|
||||||
|
|
||||||
// Enable Default Gateway
|
|
||||||
EnableDefaultGateway bool `json:"enable_default_gateway"`
|
|
||||||
|
|
||||||
// External IP
|
// External IP
|
||||||
ExternalIP string `json:"externalIP"`
|
ExternalIP string `json:"externalIP"`
|
||||||
|
|
||||||
@@ -572,56 +515,11 @@ type ListAudits []ItemAudit
|
|||||||
|
|
||||||
// Information compute in resource group
|
// Information compute in resource group
|
||||||
type RGComputes struct {
|
type RGComputes struct {
|
||||||
// Number of starting computes
|
|
||||||
Starting uint64 `json:"STARTING"`
|
|
||||||
|
|
||||||
// Number of started computes
|
// Number of started computes
|
||||||
Started uint64 `json:"STARTED"`
|
Started uint64 `json:"Started"`
|
||||||
|
|
||||||
// Number of stopping computes
|
|
||||||
Stopping uint64 `json:"STOPPING"`
|
|
||||||
|
|
||||||
// Number of stopped computes
|
// Number of stopped computes
|
||||||
Stopped uint64 `json:"STOPPED"`
|
Stopped uint64 `json:"Stopped"`
|
||||||
|
|
||||||
// Number of paused computes
|
|
||||||
Paused uint64 `json:"PAUSED"`
|
|
||||||
|
|
||||||
// Number of pausing computes
|
|
||||||
Pausing uint64 `json:"PAUSING"`
|
|
||||||
|
|
||||||
// Number of merging computes
|
|
||||||
Merge uint64 `json:"MERGE"`
|
|
||||||
|
|
||||||
// Number of migrating computes
|
|
||||||
Migrating uint64 `json:"MIGRATING"`
|
|
||||||
|
|
||||||
// Number of computes migrating in
|
|
||||||
MigratingIn uint64 `json:"MIGRATING_IN"`
|
|
||||||
|
|
||||||
// Number of computes migrating out
|
|
||||||
MigratingOut uint64 `json:"MIGRATING_OUT"`
|
|
||||||
|
|
||||||
// Number of computes in down status
|
|
||||||
Down uint64 `json:"DOWN"`
|
|
||||||
|
|
||||||
// Number of scheduled computes
|
|
||||||
Scheduled uint64 `json:"SCHEDULED"`
|
|
||||||
|
|
||||||
// Number of computes with stopped backup
|
|
||||||
BackupStopped uint64 `json:"BACKUP_STOPPED"`
|
|
||||||
|
|
||||||
// Number of computes with running backup
|
|
||||||
BackupRunning uint64 `json:"BACKUP_RUNNING"`
|
|
||||||
|
|
||||||
// Number of computes creating a snapshot
|
|
||||||
Snapcreate uint64 `json:"SNAPCREATE"`
|
|
||||||
|
|
||||||
// Number of cloning computes
|
|
||||||
Cloning uint64 `json:"CLONING"`
|
|
||||||
|
|
||||||
// Number of computes being rolled back
|
|
||||||
Rollback uint64 `json:"ROLLBACK"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Resources of Resource group
|
// Resources of Resource group
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"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/internal/validators"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -63,9 +62,9 @@ type GroupAddRequest struct {
|
|||||||
// Required: false
|
// Required: false
|
||||||
TimeoutStart uint64 `url:"timeoutStart,omitempty" json:"timeoutStart,omitempty"`
|
TimeoutStart uint64 `url:"timeoutStart,omitempty" json:"timeoutStart,omitempty"`
|
||||||
|
|
||||||
// Meta data for working group computes, format yaml string or json object
|
// Meta data for working group computes, format YAML "user_data": 1111
|
||||||
// Required: false
|
// Required: false
|
||||||
UserData interface{} `url:"userData,omitempty" json:"userData,omitempty"`
|
UserData string `url:"userData,omitempty" json:"userData,omitempty"`
|
||||||
|
|
||||||
// Chipset "i440fx" or "Q35
|
// Chipset "i440fx" or "Q35
|
||||||
// Default value : Q35
|
// Default value : Q35
|
||||||
@@ -98,7 +97,7 @@ func (b BService) GroupAdd(ctx context.Context, req GroupAddRequest) (uint64, er
|
|||||||
|
|
||||||
url := "/cloudapi/bservice/groupAdd"
|
url := "/cloudapi/bservice/groupAdd"
|
||||||
|
|
||||||
res, err := b.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
|
res, err := b.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package compute
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
)
|
)
|
||||||
@@ -18,51 +19,24 @@ type AbortSharedSnapshotMergeRequest struct {
|
|||||||
Label string `url:"label" json:"label" validate:"required"`
|
Label string `url:"label" json:"label" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type wrapperAbortSharedSnapshotMergeRequest struct {
|
|
||||||
AbortSharedSnapshotMergeRequest
|
|
||||||
AsyncMode bool `url:"asyncMode"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// AbortSharedSnapshotMerge shared snapshots merge abort
|
// AbortSharedSnapshotMerge shared snapshots merge abort
|
||||||
func (c Compute) AbortSharedSnapshotMerge(ctx context.Context, req AbortSharedSnapshotMergeRequest) (string, error) {
|
func (c Compute) AbortSharedSnapshotMerge(ctx context.Context, req AbortSharedSnapshotMergeRequest) (bool, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
}
|
|
||||||
|
|
||||||
reqWrapped := wrapperAbortSharedSnapshotMergeRequest{
|
|
||||||
AbortSharedSnapshotMergeRequest: req,
|
|
||||||
AsyncMode: false,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
url := "/cloudapi/compute/abort_shared_snapshot_merge"
|
url := "/cloudapi/compute/abort_shared_snapshot_merge"
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return string(res), nil
|
result, err := strconv.ParseBool(string(res))
|
||||||
}
|
if err != nil {
|
||||||
|
return false, err
|
||||||
// AbortSharedSnapshotMergeAsync shared snapshots merge abort in async mode
|
}
|
||||||
func (c Compute) AbortSharedSnapshotMergeAsync(ctx context.Context, req AbortSharedSnapshotMergeRequest) (string, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
return result, nil
|
||||||
if err != nil {
|
|
||||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
reqWrapped := wrapperAbortSharedSnapshotMergeRequest{
|
|
||||||
AbortSharedSnapshotMergeRequest: req,
|
|
||||||
AsyncMode: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/abort_shared_snapshot_merge"
|
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
return string(res), nil
|
|
||||||
}
|
}
|
||||||
|
|||||||
76
pkg/cloudapi/compute/audits.go
Normal file
76
pkg/cloudapi/compute/audits.go
Normal file
@@ -0,0 +1,76 @@
|
|||||||
|
package compute
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"encoding/json"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
|
)
|
||||||
|
|
||||||
|
// AuditsRequest struct to get audit records
|
||||||
|
type AuditsRequest struct {
|
||||||
|
// ID of the compute
|
||||||
|
// Required: true
|
||||||
|
ComputeID uint64 `url:"compute_id" json:"compute_id" validate:"required"`
|
||||||
|
|
||||||
|
// Find all audits after point in time
|
||||||
|
// Required: false
|
||||||
|
TimestampAT uint64 `url:"timestamp_at,omitempty" json:"timestamp_at,omitempty"`
|
||||||
|
|
||||||
|
// Find all audits before point in time
|
||||||
|
// Required: false
|
||||||
|
TimestampTO uint64 `url:"timestamp_to,omitempty" json:"timestamp_to,omitempty"`
|
||||||
|
|
||||||
|
// Find by user
|
||||||
|
// Required: false
|
||||||
|
User string `url:"user,omitempty" json:"user,omitempty"`
|
||||||
|
|
||||||
|
// Find by api endpoints
|
||||||
|
// Required: false
|
||||||
|
Call string `url:"call,omitempty" json:"call,omitempty"`
|
||||||
|
|
||||||
|
// Sort by one of supported fields, format ±<field>
|
||||||
|
// Required: false
|
||||||
|
SortBy string `url:"sort_by,omitempty" json:"sort_by,omitempty"`
|
||||||
|
|
||||||
|
// Page number
|
||||||
|
// Required: false
|
||||||
|
Page uint64 `url:"page,omitempty" json:"page,omitempty"`
|
||||||
|
|
||||||
|
// Page size
|
||||||
|
// Required: false
|
||||||
|
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
||||||
|
|
||||||
|
// Find by HTTP min status code
|
||||||
|
// Required: false
|
||||||
|
MinStatusCode uint64 `url:"min_status_code,omitempty" json:"min_status_code,omitempty"`
|
||||||
|
|
||||||
|
// Find by HTTP max status code
|
||||||
|
// Required: false
|
||||||
|
MaxStatusCode uint64 `url:"max_status_code,omitempty" json:"max_status_code,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Audits gets audit records for the specified compute object
|
||||||
|
func (c Compute) Audits(ctx context.Context, req AuditsRequest) (*ListAudits, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudapi/compute/audits"
|
||||||
|
|
||||||
|
res, err := c.client.DecortApiCall(ctx, http.MethodGet, url, req)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
list := ListAudits{}
|
||||||
|
|
||||||
|
err = json.Unmarshal(res, &list)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return &list, nil
|
||||||
|
}
|
||||||
@@ -15,12 +15,6 @@ type CDEjectRequest struct {
|
|||||||
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
|
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type wrapperCDEjectRequest struct {
|
|
||||||
CDEjectRequest
|
|
||||||
|
|
||||||
AsyncMode bool `url:"asyncMode"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// CDEject eject CD image to compute's CD-ROM
|
// CDEject eject CD image to compute's CD-ROM
|
||||||
func (c Compute) CDEject(ctx context.Context, req CDEjectRequest) (bool, error) {
|
func (c Compute) CDEject(ctx context.Context, req CDEjectRequest) (bool, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
@@ -28,14 +22,9 @@ func (c Compute) CDEject(ctx context.Context, req CDEjectRequest) (bool, error)
|
|||||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
reqWrapped := wrapperCDEjectRequest{
|
|
||||||
CDEjectRequest: req,
|
|
||||||
AsyncMode: false,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/cdEject"
|
url := "/cloudapi/compute/cdEject"
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
@@ -44,28 +33,5 @@ func (c Compute) CDEject(ctx context.Context, req CDEjectRequest) (bool, error)
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// CDEjectAsync ejects CD image to compute's CD-ROM with AsyncMode
|
|
||||||
func (c Compute) CDEjectAsync(ctx context.Context, req CDEjectRequest) (string, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
reqWrapped := wrapperCDEjectRequest{
|
|
||||||
CDEjectRequest: req,
|
|
||||||
AsyncMode: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/cdEject"
|
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
return string(res), nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -19,12 +19,6 @@ type CDInsertRequest struct {
|
|||||||
CDROMID uint64 `url:"cdromId" json:"cdromId" validate:"required"`
|
CDROMID uint64 `url:"cdromId" json:"cdromId" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type wrapperCDInsertRequest struct {
|
|
||||||
CDInsertRequest
|
|
||||||
|
|
||||||
AsyncMode bool `url:"asyncMode"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// CDInsert insert new CD image to compute's CD-ROM
|
// CDInsert insert new CD image to compute's CD-ROM
|
||||||
func (c Compute) CDInsert(ctx context.Context, req CDInsertRequest) (bool, error) {
|
func (c Compute) CDInsert(ctx context.Context, req CDInsertRequest) (bool, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
@@ -32,14 +26,9 @@ func (c Compute) CDInsert(ctx context.Context, req CDInsertRequest) (bool, error
|
|||||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
reqWrapped := wrapperCDInsertRequest{
|
|
||||||
CDInsertRequest: req,
|
|
||||||
AsyncMode: false,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/cdInsert"
|
url := "/cloudapi/compute/cdInsert"
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
@@ -48,28 +37,5 @@ func (c Compute) CDInsert(ctx context.Context, req CDInsertRequest) (bool, error
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// CDInsertAsync inserts new CD image to compute's CD-ROM with AsyncMode
|
|
||||||
func (c Compute) CDInsertAsync(ctx context.Context, req CDInsertRequest) (string, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
reqWrapped := wrapperCDInsertRequest{
|
|
||||||
CDInsertRequest: req,
|
|
||||||
AsyncMode: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/cdInsert"
|
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
return string(res), nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -31,12 +31,6 @@ type ChangeIPRequest struct {
|
|||||||
IPAddr string `url:"ip_addr" json:"ip_addr" validate:"required"`
|
IPAddr string `url:"ip_addr" json:"ip_addr" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type wrapperChangeIPRequest struct {
|
|
||||||
ChangeIPRequest
|
|
||||||
|
|
||||||
AsyncMode bool `url:"asyncMode"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// ChangeIP change reserved IP for compute instance
|
// ChangeIP change reserved IP for compute instance
|
||||||
func (c Compute) ChangeIP(ctx context.Context, req ChangeIPRequest) (bool, error) {
|
func (c Compute) ChangeIP(ctx context.Context, req ChangeIPRequest) (bool, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
@@ -44,14 +38,9 @@ func (c Compute) ChangeIP(ctx context.Context, req ChangeIPRequest) (bool, error
|
|||||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
reqWrapped := wrapperChangeIPRequest{
|
|
||||||
ChangeIPRequest: req,
|
|
||||||
AsyncMode: false,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/changeIp"
|
url := "/cloudapi/compute/changeIp"
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
@@ -63,25 +52,3 @@ func (c Compute) ChangeIP(ctx context.Context, req ChangeIPRequest) (bool, error
|
|||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// ChangeIPAsync change reserved IP for compute instance with AsyncMode
|
|
||||||
func (c Compute) ChangeIPAsync(ctx context.Context, req ChangeIPRequest) (string, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
reqWrapped := wrapperChangeIPRequest{
|
|
||||||
ChangeIPRequest: req,
|
|
||||||
AsyncMode: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/changeIp"
|
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
return string(res), nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -3,9 +3,8 @@ package compute
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
|
||||||
|
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
|
"strconv"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ChangeLinkStateRequest struct to change link state
|
// ChangeLinkStateRequest struct to change link state
|
||||||
@@ -24,12 +23,6 @@ type ChangeLinkStateRequest struct {
|
|||||||
State string `url:"state" json:"state" validate:"required,interfaceState"`
|
State string `url:"state" json:"state" validate:"required,interfaceState"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type wrapperChangeLinkStateRequest struct {
|
|
||||||
ChangeLinkStateRequest
|
|
||||||
|
|
||||||
AsyncMode bool `url:"asyncMode"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// ChangeLinkState changes the status link virtual of compute
|
// ChangeLinkState changes the status link virtual of compute
|
||||||
func (c Compute) ChangeLinkState(ctx context.Context, req ChangeLinkStateRequest) (bool, error) {
|
func (c Compute) ChangeLinkState(ctx context.Context, req ChangeLinkStateRequest) (bool, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
@@ -37,14 +30,9 @@ func (c Compute) ChangeLinkState(ctx context.Context, req ChangeLinkStateRequest
|
|||||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
reqWrapped := wrapperChangeLinkStateRequest{
|
|
||||||
ChangeLinkStateRequest: req,
|
|
||||||
AsyncMode: false,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/changeLinkState"
|
url := "/cloudapi/compute/changeLinkState"
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
@@ -53,28 +41,5 @@ func (c Compute) ChangeLinkState(ctx context.Context, req ChangeLinkStateRequest
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// ChangeLinkStateAsync changes the status link virtual of compute with AsyncMode
|
|
||||||
func (c Compute) ChangeLinkStateAsync(ctx context.Context, req ChangeLinkStateRequest) (string, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
reqWrapped := wrapperChangeLinkStateRequest{
|
|
||||||
ChangeLinkStateRequest: req,
|
|
||||||
AsyncMode: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/changeLinkState"
|
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
return string(res), nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -23,12 +23,6 @@ type ChangeMTURequest struct {
|
|||||||
MTU uint64 `url:"mtu" json:"mtu" validate:"required" validate:"omitempty,mtu"`
|
MTU uint64 `url:"mtu" json:"mtu" validate:"required" validate:"omitempty,mtu"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type wrapperChangeMTURequest struct {
|
|
||||||
ChangeMTURequest
|
|
||||||
|
|
||||||
AsyncMode bool `url:"asyncMode"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// ChangeMTU change MTU for compute instance
|
// ChangeMTU change MTU for compute instance
|
||||||
func (c Compute) ChangeMTU(ctx context.Context, req ChangeMTURequest) (bool, error) {
|
func (c Compute) ChangeMTU(ctx context.Context, req ChangeMTURequest) (bool, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
@@ -36,14 +30,9 @@ func (c Compute) ChangeMTU(ctx context.Context, req ChangeMTURequest) (bool, err
|
|||||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
reqWrapped := wrapperChangeMTURequest{
|
|
||||||
ChangeMTURequest: req,
|
|
||||||
AsyncMode: false,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/change_mtu"
|
url := "/cloudapi/compute/change_mtu"
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
@@ -55,25 +44,3 @@ func (c Compute) ChangeMTU(ctx context.Context, req ChangeMTURequest) (bool, err
|
|||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// ChangeMTUAsync change MTU for compute instance with AsyncMode
|
|
||||||
func (c Compute) ChangeMTUAsync(ctx context.Context, req ChangeMTURequest) (string, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
reqWrapped := wrapperChangeMTURequest{
|
|
||||||
ChangeMTURequest: req,
|
|
||||||
AsyncMode: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/change_mtu"
|
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
return string(res), nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,84 +0,0 @@
|
|||||||
package compute
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"net/http"
|
|
||||||
"strconv"
|
|
||||||
|
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants"
|
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
|
||||||
)
|
|
||||||
|
|
||||||
type ChangeQoSPoliciesRequest struct {
|
|
||||||
// Compute ID
|
|
||||||
// Required: true
|
|
||||||
ComputeID uint64 `url:"compute_id" json:"compute_id" validate:"required"`
|
|
||||||
|
|
||||||
// Interface IP or MAC address
|
|
||||||
// Required: true
|
|
||||||
Interface string `url:"interface" json:"interface" validate:"required"`
|
|
||||||
|
|
||||||
// List of QoS Policy IDs to assign to this interface
|
|
||||||
// Required: false
|
|
||||||
QoSPolicyIDs []uint64 `url:"qos_policy_ids,omitempty" json:"qos_policy_ids,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type wrapperChangeQoSPoliciesRequest struct {
|
|
||||||
ChangeQoSPoliciesRequest
|
|
||||||
|
|
||||||
AsyncMode bool `url:"asyncMode"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// ChangeQoSPolicies change qos policies for compute
|
|
||||||
func (c Compute) ChangeQoSPolicies(ctx context.Context, req ChangeQoSPoliciesRequest) (bool, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
reqWrapped := wrapperChangeQoSPoliciesRequest{
|
|
||||||
ChangeQoSPoliciesRequest: req,
|
|
||||||
AsyncMode: false,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/change_qos_policies"
|
|
||||||
|
|
||||||
res, err := c.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, reqWrapped)
|
|
||||||
if err != nil {
|
|
||||||
return false, err
|
|
||||||
}
|
|
||||||
|
|
||||||
result, err := strconv.ParseBool(string(res))
|
|
||||||
if err != nil {
|
|
||||||
return false, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return result, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// ChangeQoSPolicies change qos policies for compute with AsyncMode
|
|
||||||
func (c Compute) ChangeQoSPoliciesAsync(ctx context.Context, req ChangeQoSPoliciesRequest) (bool, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
reqWrapped := wrapperChangeQoSPoliciesRequest{
|
|
||||||
ChangeQoSPoliciesRequest: req,
|
|
||||||
AsyncMode: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/change_qos_policies"
|
|
||||||
|
|
||||||
res, err := c.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, reqWrapped)
|
|
||||||
if err != nil {
|
|
||||||
return false, err
|
|
||||||
}
|
|
||||||
|
|
||||||
result, err := strconv.ParseBool(string(res))
|
|
||||||
if err != nil {
|
|
||||||
return false, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return result, nil
|
|
||||||
}
|
|
||||||
@@ -27,12 +27,6 @@ type ChangeSecGroupsRequest struct {
|
|||||||
EnableSecGroups interface{} `url:"enable_secgroups,omitempty" json:"enable_secgroups,omitempty" validate:"omitempty,isBool"`
|
EnableSecGroups interface{} `url:"enable_secgroups,omitempty" json:"enable_secgroups,omitempty" validate:"omitempty,isBool"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type wrapperChangeSecGroupsRequest struct {
|
|
||||||
ChangeSecGroupsRequest
|
|
||||||
|
|
||||||
AsyncMode bool `url:"asyncMode"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// ChangeSecGroups changes security groups for compute
|
// ChangeSecGroups changes security groups for compute
|
||||||
func (c Compute) ChangeSecGroups(ctx context.Context, req ChangeSecGroupsRequest) (bool, error) {
|
func (c Compute) ChangeSecGroups(ctx context.Context, req ChangeSecGroupsRequest) (bool, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
@@ -40,14 +34,9 @@ func (c Compute) ChangeSecGroups(ctx context.Context, req ChangeSecGroupsRequest
|
|||||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
reqWrapped := wrapperChangeSecGroupsRequest{
|
|
||||||
ChangeSecGroupsRequest: req,
|
|
||||||
AsyncMode: false,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/change_security_groups"
|
url := "/cloudapi/compute/change_security_groups"
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
@@ -59,25 +48,3 @@ func (c Compute) ChangeSecGroups(ctx context.Context, req ChangeSecGroupsRequest
|
|||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// ChangeSecGroupsAsync changes security groups for compute with AsyncMode
|
|
||||||
func (c Compute) ChangeSecGroupsAsync(ctx context.Context, req ChangeSecGroupsRequest) (string, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
reqWrapped := wrapperChangeSecGroupsRequest{
|
|
||||||
ChangeSecGroupsRequest: req,
|
|
||||||
AsyncMode: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/change_security_groups"
|
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
return string(res), nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -44,12 +44,6 @@ type CloneRequest struct {
|
|||||||
SEPID uint64 `url:"sep_id" json:"sep_id"`
|
SEPID uint64 `url:"sep_id" json:"sep_id"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type wrapperCloneRequest struct {
|
|
||||||
CloneRequest
|
|
||||||
|
|
||||||
AsyncMode bool `url:"asyncMode" json:"asyncMode"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// Clone clones compute instance
|
// Clone clones compute instance
|
||||||
func (c Compute) Clone(ctx context.Context, req CloneRequest) (string, error) {
|
func (c Compute) Clone(ctx context.Context, req CloneRequest) (string, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
@@ -57,36 +51,9 @@ func (c Compute) Clone(ctx context.Context, req CloneRequest) (string, error) {
|
|||||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
reqWrapped := wrapperCloneRequest{
|
|
||||||
CloneRequest: req,
|
|
||||||
AsyncMode: false,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/clone"
|
url := "/cloudapi/compute/clone"
|
||||||
|
|
||||||
res, err := c.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, reqWrapped)
|
res, err := c.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
return string(res), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// CloneAsync clones compute instance with AsyncMode
|
|
||||||
func (c Compute) CloneAsync(ctx context.Context, req CloneRequest) (string, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
reqWrapped := wrapperCloneRequest{
|
|
||||||
CloneRequest: req,
|
|
||||||
AsyncMode: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/clone"
|
|
||||||
|
|
||||||
res, err := c.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, reqWrapped)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,8 +2,8 @@ package compute
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants"
|
"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/internal/validators"
|
||||||
@@ -17,24 +17,22 @@ type CloneAbortRequest struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// CloneAbort aborts a compute clone
|
// CloneAbort aborts a compute clone
|
||||||
func (c Compute) CloneAbort(ctx context.Context, req CloneAbortRequest) (ListCloneAbort, error) {
|
func (c Compute) CloneAbort(ctx context.Context, req CloneAbortRequest) (bool, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
url := "/cloudapi/compute/clone_abort"
|
url := "/cloudapi/compute/clone_abort"
|
||||||
|
|
||||||
res, err := c.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
|
res, err := c.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
var result ListCloneAbort
|
result, err := strconv.ParseBool(string(res))
|
||||||
|
|
||||||
err = json.Unmarshal(res, &result)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
|
|||||||
@@ -23,12 +23,6 @@ type DeleteRequest struct {
|
|||||||
DetachDisks bool `url:"detachDisks,omitempty" json:"detachDisks,omitempty"`
|
DetachDisks bool `url:"detachDisks,omitempty" json:"detachDisks,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type wrapperDeleteRequest struct {
|
|
||||||
DeleteRequest
|
|
||||||
|
|
||||||
AsyncMode bool `url:"asyncMode"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// Delete deletes compute
|
// Delete deletes compute
|
||||||
func (c Compute) Delete(ctx context.Context, req DeleteRequest) (bool, error) {
|
func (c Compute) Delete(ctx context.Context, req DeleteRequest) (bool, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
@@ -36,14 +30,9 @@ func (c Compute) Delete(ctx context.Context, req DeleteRequest) (bool, error) {
|
|||||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
reqWrapped := wrapperDeleteRequest{
|
|
||||||
DeleteRequest: req,
|
|
||||||
AsyncMode: false,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/delete"
|
url := "/cloudapi/compute/delete"
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
@@ -55,25 +44,3 @@ func (c Compute) Delete(ctx context.Context, req DeleteRequest) (bool, error) {
|
|||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// DeleteAsync deletes compute with AsyncMode
|
|
||||||
func (c Compute) DeleteAsync(ctx context.Context, req DeleteRequest) (string, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
reqWrapped := wrapperDeleteRequest{
|
|
||||||
DeleteRequest: req,
|
|
||||||
AsyncMode: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/delete"
|
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
return string(res), nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,39 +0,0 @@
|
|||||||
package compute
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"net/http"
|
|
||||||
"strconv"
|
|
||||||
|
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants"
|
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
|
||||||
)
|
|
||||||
|
|
||||||
// DeleteCPUAlignmentProfileRequest struct to delete CPU alignment profile for computes
|
|
||||||
type DeleteCPUAlignmentProfileRequest struct {
|
|
||||||
// IDs of the compute instances
|
|
||||||
// Required: true
|
|
||||||
ComputeIDs []uint64 `url:"compute_ids" json:"compute_ids" validate:"min=1"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// DeleteCPUAlignmentProfile deletes CPU alignment profile for computes
|
|
||||||
func (c Compute) DeleteCPUAlignmentProfile(ctx context.Context, req DeleteCPUAlignmentProfileRequest) (bool, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/delete_cpu_alignment_profile"
|
|
||||||
|
|
||||||
res, err := c.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
|
|
||||||
if err != nil {
|
|
||||||
return false, err
|
|
||||||
}
|
|
||||||
|
|
||||||
result, err := strconv.ParseBool(string(res))
|
|
||||||
if err != nil {
|
|
||||||
return false, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return result, nil
|
|
||||||
}
|
|
||||||
@@ -15,12 +15,6 @@ type DisableRequest struct {
|
|||||||
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
|
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type wrapperDisableRequest struct {
|
|
||||||
DisableRequest
|
|
||||||
|
|
||||||
AsyncMode bool `url:"asyncMode"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// Disable disables compute
|
// Disable disables compute
|
||||||
func (c Compute) Disable(ctx context.Context, req DisableRequest) (bool, error) {
|
func (c Compute) Disable(ctx context.Context, req DisableRequest) (bool, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
@@ -28,14 +22,9 @@ func (c Compute) Disable(ctx context.Context, req DisableRequest) (bool, error)
|
|||||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
reqWrapped := wrapperDisableRequest{
|
|
||||||
DisableRequest: req,
|
|
||||||
AsyncMode: false,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/disable"
|
url := "/cloudapi/compute/disable"
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
@@ -47,25 +36,3 @@ func (c Compute) Disable(ctx context.Context, req DisableRequest) (bool, error)
|
|||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// DisableAsync disables compute with AsyncMode
|
|
||||||
func (c Compute) DisableAsync(ctx context.Context, req DisableRequest) (string, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
reqWrapped := wrapperDisableRequest{
|
|
||||||
DisableRequest: req,
|
|
||||||
AsyncMode: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/disable"
|
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
return string(res), nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -26,6 +26,13 @@ type DiskAddRequest struct {
|
|||||||
// Required: true
|
// Required: true
|
||||||
StoragePolicyID uint64 `url:"storage_policy_id" json:"storage_policy_id" validate:"required"`
|
StoragePolicyID uint64 `url:"storage_policy_id" json:"storage_policy_id" validate:"required"`
|
||||||
|
|
||||||
|
// Type of the disk
|
||||||
|
// Should be one of:
|
||||||
|
// - D
|
||||||
|
// - B
|
||||||
|
// Required: false
|
||||||
|
DiskType string `url:"diskType,omitempty" json:"diskType,omitempty" validate:"omitempty,computeDiskType"`
|
||||||
|
|
||||||
// Storage endpoint provider ID
|
// Storage endpoint provider ID
|
||||||
// By default the same with boot disk
|
// By default the same with boot disk
|
||||||
// Required: false
|
// Required: false
|
||||||
@@ -51,16 +58,6 @@ type DiskAddRequest struct {
|
|||||||
// Desired bus number (hex string, e.g. "0x03")
|
// Desired bus number (hex string, e.g. "0x03")
|
||||||
// Required: false
|
// Required: false
|
||||||
BusNumber string `url:"bus_number,omitempty" json:"bus_number,omitempty"`
|
BusNumber string `url:"bus_number,omitempty" json:"bus_number,omitempty"`
|
||||||
|
|
||||||
// Mount disk in read-only mode
|
|
||||||
// Required: false
|
|
||||||
ReadOnly bool `url:"read_only,omitempty" json:"read_only,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type wrapperDiskAddRequest struct {
|
|
||||||
DiskAddRequest
|
|
||||||
|
|
||||||
AsyncMode bool `url:"asyncMode"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// DiskAdd creates new disk and attach to compute
|
// DiskAdd creates new disk and attach to compute
|
||||||
@@ -70,14 +67,9 @@ func (c Compute) DiskAdd(ctx context.Context, req DiskAddRequest) (uint64, error
|
|||||||
return 0, validators.ValidationErrors(validators.GetErrors(err))
|
return 0, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
reqWrapped := wrapperDiskAddRequest{
|
|
||||||
DiskAddRequest: req,
|
|
||||||
AsyncMode: false,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/diskAdd"
|
url := "/cloudapi/compute/diskAdd"
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
@@ -89,25 +81,3 @@ func (c Compute) DiskAdd(ctx context.Context, req DiskAddRequest) (uint64, error
|
|||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// DiskAddAsync creates new disk and attach to compute with AsyncMode
|
|
||||||
func (c Compute) DiskAddAsync(ctx context.Context, req DiskAddRequest) (string, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
reqWrapped := wrapperDiskAddRequest{
|
|
||||||
DiskAddRequest: req,
|
|
||||||
AsyncMode: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/diskAdd"
|
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
return string(res), nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -18,6 +18,10 @@ type DiskAttachRequest struct {
|
|||||||
// Required: true
|
// Required: true
|
||||||
DiskID uint64 `url:"diskId" json:"diskId" validate:"required"`
|
DiskID uint64 `url:"diskId" json:"diskId" validate:"required"`
|
||||||
|
|
||||||
|
// Type of the disk B;D
|
||||||
|
// Required: false
|
||||||
|
DiskType string `url:"diskType,omitempty" json:"diskType,omitempty" validate:"omitempty,computeDiskType"`
|
||||||
|
|
||||||
// Desired PCI slot (hex string, e.g. "0x1A")
|
// Desired PCI slot (hex string, e.g. "0x1A")
|
||||||
// Required: false
|
// Required: false
|
||||||
PCISlot string `url:"pci_slot,omitempty" json:"pci_slot,omitempty"`
|
PCISlot string `url:"pci_slot,omitempty" json:"pci_slot,omitempty"`
|
||||||
@@ -25,16 +29,6 @@ type DiskAttachRequest struct {
|
|||||||
// Desired bus number (hex string, e.g. "0x03")
|
// Desired bus number (hex string, e.g. "0x03")
|
||||||
// Required: false
|
// Required: false
|
||||||
BusNumber string `url:"bus_number,omitempty" json:"bus_number,omitempty"`
|
BusNumber string `url:"bus_number,omitempty" json:"bus_number,omitempty"`
|
||||||
|
|
||||||
// Mount disk in read-only mode
|
|
||||||
// Required: false
|
|
||||||
ReadOnly bool `url:"read_only,omitempty" json:"read_only,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type wrapperDiskAttachRequest struct {
|
|
||||||
DiskAttachRequest
|
|
||||||
|
|
||||||
AsyncMode bool `url:"asyncMode"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// DiskAttach attach disk to compute
|
// DiskAttach attach disk to compute
|
||||||
@@ -44,14 +38,9 @@ func (c Compute) DiskAttach(ctx context.Context, req DiskAttachRequest) (bool, e
|
|||||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
reqWrapped := wrapperDiskAttachRequest{
|
|
||||||
DiskAttachRequest: req,
|
|
||||||
AsyncMode: false,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/diskAttach"
|
url := "/cloudapi/compute/diskAttach"
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
@@ -63,25 +52,3 @@ func (c Compute) DiskAttach(ctx context.Context, req DiskAttachRequest) (bool, e
|
|||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// DiskAttachAsync attaches disk to compute with AsyncMode
|
|
||||||
func (c Compute) DiskAttachAsync(ctx context.Context, req DiskAttachRequest) (string, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
reqWrapped := wrapperDiskAttachRequest{
|
|
||||||
DiskAttachRequest: req,
|
|
||||||
AsyncMode: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/diskAttach"
|
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
return string(res), nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -23,12 +23,6 @@ type DiskDelRequest struct {
|
|||||||
Permanently bool `url:"permanently" json:"permanently"`
|
Permanently bool `url:"permanently" json:"permanently"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type wrapperDiskDelRequest struct {
|
|
||||||
DiskDelRequest
|
|
||||||
|
|
||||||
AsyncMode bool `url:"asyncMode"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// DiskDel delete disk and detach from compute
|
// DiskDel delete disk and detach from compute
|
||||||
func (c Compute) DiskDel(ctx context.Context, req DiskDelRequest) (bool, error) {
|
func (c Compute) DiskDel(ctx context.Context, req DiskDelRequest) (bool, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
@@ -36,14 +30,9 @@ func (c Compute) DiskDel(ctx context.Context, req DiskDelRequest) (bool, error)
|
|||||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
reqWrapped := wrapperDiskDelRequest{
|
|
||||||
DiskDelRequest: req,
|
|
||||||
AsyncMode: false,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/diskDel"
|
url := "/cloudapi/compute/diskDel"
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
@@ -55,25 +44,3 @@ func (c Compute) DiskDel(ctx context.Context, req DiskDelRequest) (bool, error)
|
|||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// DiskDelAsync deletes disk and detaches from compute with AsyncMode
|
|
||||||
func (c Compute) DiskDelAsync(ctx context.Context, req DiskDelRequest) (string, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
reqWrapped := wrapperDiskDelRequest{
|
|
||||||
DiskDelRequest: req,
|
|
||||||
AsyncMode: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/diskDel"
|
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
return string(res), nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -19,12 +19,6 @@ type DiskDetachRequest struct {
|
|||||||
DiskID uint64 `url:"diskId" json:"diskId" validate:"required"`
|
DiskID uint64 `url:"diskId" json:"diskId" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type wrapperDiskDetachRequest struct {
|
|
||||||
DiskDetachRequest
|
|
||||||
|
|
||||||
AsyncMode bool `url:"asyncMode"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// DiskDetach detach disk from compute
|
// DiskDetach detach disk from compute
|
||||||
func (c Compute) DiskDetach(ctx context.Context, req DiskDetachRequest) (bool, error) {
|
func (c Compute) DiskDetach(ctx context.Context, req DiskDetachRequest) (bool, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
@@ -32,14 +26,9 @@ func (c Compute) DiskDetach(ctx context.Context, req DiskDetachRequest) (bool, e
|
|||||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
reqWrapped := wrapperDiskDetachRequest{
|
|
||||||
DiskDetachRequest: req,
|
|
||||||
AsyncMode: false,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/diskDetach"
|
url := "/cloudapi/compute/diskDetach"
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
@@ -51,25 +40,3 @@ func (c Compute) DiskDetach(ctx context.Context, req DiskDetachRequest) (bool, e
|
|||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// DiskDetachAsync detaches disk from compute with AsyncMode
|
|
||||||
func (c Compute) DiskDetachAsync(ctx context.Context, req DiskDetachRequest) (string, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
reqWrapped := wrapperDiskDetachRequest{
|
|
||||||
DiskDetachRequest: req,
|
|
||||||
AsyncMode: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/diskDetach"
|
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
return string(res), nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -23,12 +23,6 @@ type DiskQOSRequest struct {
|
|||||||
Limits string `url:"limits" json:"limits" validate:"required"`
|
Limits string `url:"limits" json:"limits" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type wrapperDiskQOSRequest struct {
|
|
||||||
DiskQOSRequest
|
|
||||||
|
|
||||||
AsyncMode bool `url:"asyncMode"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// DiskQOS change QoS of the disk
|
// DiskQOS change QoS of the disk
|
||||||
func (c Compute) DiskQOS(ctx context.Context, req DiskQOSRequest) (bool, error) {
|
func (c Compute) DiskQOS(ctx context.Context, req DiskQOSRequest) (bool, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
@@ -36,14 +30,9 @@ func (c Compute) DiskQOS(ctx context.Context, req DiskQOSRequest) (bool, error)
|
|||||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
reqWrapped := wrapperDiskQOSRequest{
|
|
||||||
DiskQOSRequest: req,
|
|
||||||
AsyncMode: false,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/diskQos"
|
url := "/cloudapi/compute/diskQos"
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
@@ -55,25 +44,3 @@ func (c Compute) DiskQOS(ctx context.Context, req DiskQOSRequest) (bool, error)
|
|||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// DiskQOSAsync changes QoS of the disk with AsyncMode
|
|
||||||
func (c Compute) DiskQOSAsync(ctx context.Context, req DiskQOSRequest) (string, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
reqWrapped := wrapperDiskQOSRequest{
|
|
||||||
DiskQOSRequest: req,
|
|
||||||
AsyncMode: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/diskQos"
|
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
return string(res), nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -23,12 +23,6 @@ type DiskResizeRequest struct {
|
|||||||
Size uint64 `url:"size" json:"size" validate:"required"`
|
Size uint64 `url:"size" json:"size" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type wrapperDiskResizeRequest struct {
|
|
||||||
DiskResizeRequest
|
|
||||||
|
|
||||||
AsyncMode bool `url:"asyncMode"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// DiskResize change disk size
|
// DiskResize change disk size
|
||||||
func (c Compute) DiskResize(ctx context.Context, req DiskResizeRequest) (bool, error) {
|
func (c Compute) DiskResize(ctx context.Context, req DiskResizeRequest) (bool, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
@@ -36,14 +30,9 @@ func (c Compute) DiskResize(ctx context.Context, req DiskResizeRequest) (bool, e
|
|||||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
reqWrapped := wrapperDiskResizeRequest{
|
|
||||||
DiskResizeRequest: req,
|
|
||||||
AsyncMode: false,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/diskResize"
|
url := "/cloudapi/compute/diskResize"
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
@@ -55,25 +44,3 @@ func (c Compute) DiskResize(ctx context.Context, req DiskResizeRequest) (bool, e
|
|||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// DiskResizeAsync changes disk size with AsyncMode
|
|
||||||
func (c Compute) DiskResizeAsync(ctx context.Context, req DiskResizeRequest) (string, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
reqWrapped := wrapperDiskResizeRequest{
|
|
||||||
DiskResizeRequest: req,
|
|
||||||
AsyncMode: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/diskResize"
|
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
return string(res), nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -23,12 +23,6 @@ type DiskSwitchToReplicationRequest struct {
|
|||||||
StopReplication bool `url:"stopReplication" json:"stopReplication"`
|
StopReplication bool `url:"stopReplication" json:"stopReplication"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type wrapperDiskSwitchToReplicationRequest struct {
|
|
||||||
DiskSwitchToReplicationRequest
|
|
||||||
|
|
||||||
AsyncMode bool `url:"asyncMode"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// DiskSwitchToReplication switches disk to it's replication
|
// DiskSwitchToReplication switches disk to it's replication
|
||||||
func (c Compute) DiskSwitchToReplication(ctx context.Context, req DiskSwitchToReplicationRequest) (bool, error) {
|
func (c Compute) DiskSwitchToReplication(ctx context.Context, req DiskSwitchToReplicationRequest) (bool, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
@@ -36,14 +30,9 @@ func (c Compute) DiskSwitchToReplication(ctx context.Context, req DiskSwitchToRe
|
|||||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
reqWrapped := wrapperDiskSwitchToReplicationRequest{
|
|
||||||
DiskSwitchToReplicationRequest: req,
|
|
||||||
AsyncMode: false,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/diskSwitchToReplication"
|
url := "/cloudapi/compute/diskSwitchToReplication"
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
@@ -55,25 +44,3 @@ func (c Compute) DiskSwitchToReplication(ctx context.Context, req DiskSwitchToRe
|
|||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// DiskSwitchToReplicationAsync switches disk to it's replication with AsyncMode
|
|
||||||
func (c Compute) DiskSwitchToReplicationAsync(ctx context.Context, req DiskSwitchToReplicationRequest) (string, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
reqWrapped := wrapperDiskSwitchToReplicationRequest{
|
|
||||||
DiskSwitchToReplicationRequest: req,
|
|
||||||
AsyncMode: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/diskSwitchToReplication"
|
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
return string(res), nil
|
|
||||||
}
|
|
||||||
|
|||||||
40
pkg/cloudapi/compute/get_audits.go
Normal file
40
pkg/cloudapi/compute/get_audits.go
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
package compute
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"encoding/json"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
|
)
|
||||||
|
|
||||||
|
// GetAuditsRequest struct to get compute audits
|
||||||
|
type GetAuditsRequest struct {
|
||||||
|
// ID of compute instance
|
||||||
|
// Required: true
|
||||||
|
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetAudits gets compute audits
|
||||||
|
func (c Compute) GetAudits(ctx context.Context, req GetAuditsRequest) (ListShortAudits, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudapi/compute/getAudits"
|
||||||
|
|
||||||
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
list := ListShortAudits{}
|
||||||
|
|
||||||
|
err = json.Unmarshal(res, &list)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return list, nil
|
||||||
|
}
|
||||||
@@ -1,46 +0,0 @@
|
|||||||
package compute
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"encoding/json"
|
|
||||||
"net/http"
|
|
||||||
|
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
|
||||||
)
|
|
||||||
|
|
||||||
// GetCPUAlignmentProfileRequest struct to get CPU alignment profile for compute
|
|
||||||
type GetCPUAlignmentProfileRequest struct {
|
|
||||||
// ID of the compute instance
|
|
||||||
// Required: true
|
|
||||||
ComputeID uint64 `url:"compute_id" json:"compute_id" validate:"required"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetCPUAlignmentProfile gets CPU alignment profile for compute
|
|
||||||
func (c Compute) GetCPUAlignmentProfile(ctx context.Context, req GetCPUAlignmentProfileRequest) (*CPUAlignmentProfile, error) {
|
|
||||||
res, err := c.GetCPUAlignmentProfileRaw(ctx, req)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
info := CPUAlignmentProfile{}
|
|
||||||
|
|
||||||
err = json.Unmarshal(res, &info)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return &info, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetCPUAlignmentProfileRaw gets CPU alignment profile for compute as an array of bytes
|
|
||||||
func (c Compute) GetCPUAlignmentProfileRaw(ctx context.Context, req GetCPUAlignmentProfileRequest) ([]byte, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/get_cpu_alignment_profile"
|
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodGet, url, req)
|
|
||||||
return res, err
|
|
||||||
}
|
|
||||||
@@ -15,12 +15,6 @@ type GuestAgentDisableRequest struct {
|
|||||||
ComputeID uint64 `url:"compute_id" json:"compute_id" validate:"required"`
|
ComputeID uint64 `url:"compute_id" json:"compute_id" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type wrapperGuestAgentDisableRequest struct {
|
|
||||||
GuestAgentDisableRequest
|
|
||||||
|
|
||||||
AsyncMode bool `url:"asyncMode"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// Disable guest agent at a specific compute
|
// Disable guest agent at a specific compute
|
||||||
func (c Compute) GuestAgentDisable(ctx context.Context, req GuestAgentDisableRequest) (bool, error) {
|
func (c Compute) GuestAgentDisable(ctx context.Context, req GuestAgentDisableRequest) (bool, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
@@ -28,14 +22,9 @@ func (c Compute) GuestAgentDisable(ctx context.Context, req GuestAgentDisableReq
|
|||||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
reqWrapped := wrapperGuestAgentDisableRequest{
|
|
||||||
GuestAgentDisableRequest: req,
|
|
||||||
AsyncMode: false,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/guest_agent_disable"
|
url := "/cloudapi/compute/guest_agent_disable"
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
@@ -47,25 +36,3 @@ func (c Compute) GuestAgentDisable(ctx context.Context, req GuestAgentDisableReq
|
|||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// GuestAgentDisableAsync disables guest agent at a specific compute with AsyncMode
|
|
||||||
func (c Compute) GuestAgentDisableAsync(ctx context.Context, req GuestAgentDisableRequest) (string, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
reqWrapped := wrapperGuestAgentDisableRequest{
|
|
||||||
GuestAgentDisableRequest: req,
|
|
||||||
AsyncMode: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/guest_agent_disable"
|
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
return string(res), nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -15,12 +15,6 @@ type GuestAgentEnableRequest struct {
|
|||||||
ComputeID uint64 `url:"compute_id" json:"compute_id" validate:"required"`
|
ComputeID uint64 `url:"compute_id" json:"compute_id" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type wrapperGuestAgentEnableRequest struct {
|
|
||||||
GuestAgentEnableRequest
|
|
||||||
|
|
||||||
AsyncMode bool `url:"asyncMode"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// Enable guest agent at a specific compute
|
// Enable guest agent at a specific compute
|
||||||
func (c Compute) GuestAgentEnable(ctx context.Context, req GuestAgentEnableRequest) (bool, error) {
|
func (c Compute) GuestAgentEnable(ctx context.Context, req GuestAgentEnableRequest) (bool, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
@@ -28,14 +22,9 @@ func (c Compute) GuestAgentEnable(ctx context.Context, req GuestAgentEnableReque
|
|||||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
reqWrapped := wrapperGuestAgentEnableRequest{
|
|
||||||
GuestAgentEnableRequest: req,
|
|
||||||
AsyncMode: false,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/guest_agent_enable"
|
url := "/cloudapi/compute/guest_agent_enable"
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
@@ -47,25 +36,3 @@ func (c Compute) GuestAgentEnable(ctx context.Context, req GuestAgentEnableReque
|
|||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// GuestAgentEnableAsync enables guest agent at a specific compute with AsyncMode
|
|
||||||
func (c Compute) GuestAgentEnableAsync(ctx context.Context, req GuestAgentEnableRequest) (string, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
reqWrapped := wrapperGuestAgentEnableRequest{
|
|
||||||
GuestAgentEnableRequest: req,
|
|
||||||
AsyncMode: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/guest_agent_enable"
|
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
return string(res), nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -23,12 +23,6 @@ type GuestAgentExecuteRequest struct {
|
|||||||
Arguments string `url:"arguments" json:"arguments" validate:"required"`
|
Arguments string `url:"arguments" json:"arguments" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type wrapperGuestAgentExecuteRequest struct {
|
|
||||||
GuestAgentExecuteRequest
|
|
||||||
|
|
||||||
AsyncMode bool `url:"asyncMode"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// Execute guest agent command
|
// Execute guest agent command
|
||||||
func (c Compute) GuestAgentExecuteRequest(ctx context.Context, req GuestAgentExecuteRequest) (map[string]interface{}, error) {
|
func (c Compute) GuestAgentExecuteRequest(ctx context.Context, req GuestAgentExecuteRequest) (map[string]interface{}, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
@@ -36,14 +30,9 @@ func (c Compute) GuestAgentExecuteRequest(ctx context.Context, req GuestAgentExe
|
|||||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
reqWrapped := wrapperGuestAgentExecuteRequest{
|
|
||||||
GuestAgentExecuteRequest: req,
|
|
||||||
AsyncMode: false,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/guest_agent_execute"
|
url := "/cloudapi/compute/guest_agent_execute"
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -57,25 +46,3 @@ func (c Compute) GuestAgentExecuteRequest(ctx context.Context, req GuestAgentExe
|
|||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// GuestAgentExecuteRequestAsync executes guest agent command with AsyncMode
|
|
||||||
func (c Compute) GuestAgentExecuteRequestAsync(ctx context.Context, req GuestAgentExecuteRequest) (string, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
reqWrapped := wrapperGuestAgentExecuteRequest{
|
|
||||||
GuestAgentExecuteRequest: req,
|
|
||||||
AsyncMode: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/guest_agent_execute"
|
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
return string(res), nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -15,12 +15,6 @@ type GuestAgentFeatureUpdateRequest struct {
|
|||||||
ComputeID uint64 `url:"compute_id" json:"compute_id" validate:"required"`
|
ComputeID uint64 `url:"compute_id" json:"compute_id" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type wrapperGuestAgentFeatureUpdateRequest struct {
|
|
||||||
GuestAgentFeatureUpdateRequest
|
|
||||||
|
|
||||||
AsyncMode bool `url:"asyncMode"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// Feature update guest agent
|
// Feature update guest agent
|
||||||
func (c Compute) GuestAgentFeatureUpdate(ctx context.Context, req GuestAgentFeatureUpdateRequest) (bool, error) {
|
func (c Compute) GuestAgentFeatureUpdate(ctx context.Context, req GuestAgentFeatureUpdateRequest) (bool, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
@@ -28,14 +22,9 @@ func (c Compute) GuestAgentFeatureUpdate(ctx context.Context, req GuestAgentFeat
|
|||||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
reqWrapped := wrapperGuestAgentFeatureUpdateRequest{
|
|
||||||
GuestAgentFeatureUpdateRequest: req,
|
|
||||||
AsyncMode: false,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/guest_agent_feature_update"
|
url := "/cloudapi/compute/guest_agent_feature_update"
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
@@ -47,25 +36,3 @@ func (c Compute) GuestAgentFeatureUpdate(ctx context.Context, req GuestAgentFeat
|
|||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// GuestAgentFeatureUpdateAsync feature updates guest agent with AsyncMode
|
|
||||||
func (c Compute) GuestAgentFeatureUpdateAsync(ctx context.Context, req GuestAgentFeatureUpdateRequest) (string, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
reqWrapped := wrapperGuestAgentFeatureUpdateRequest{
|
|
||||||
GuestAgentFeatureUpdateRequest: req,
|
|
||||||
AsyncMode: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/guest_agent_feature_update"
|
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
return string(res), nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -14,6 +14,10 @@ type ListPCIDeviceRequest struct {
|
|||||||
// Required: true
|
// Required: true
|
||||||
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
|
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
|
||||||
|
|
||||||
|
// Find by resource group ID
|
||||||
|
// Required: false
|
||||||
|
RGID uint64 `url:"rgId,omitempty" json:"rgId,omitempty"`
|
||||||
|
|
||||||
// Find by device id
|
// Find by device id
|
||||||
// Required: false
|
// Required: false
|
||||||
DevID uint64 `url:"devId,omitempty" json:"devId,omitempty"`
|
DevID uint64 `url:"devId,omitempty" json:"devId,omitempty"`
|
||||||
|
|||||||
@@ -19,12 +19,6 @@ type MigrateToZoneRequest struct {
|
|||||||
ZoneID uint64 `url:"zoneId" json:"zoneId " validate:"required"`
|
ZoneID uint64 `url:"zoneId" json:"zoneId " validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type wrapperMigrateToZoneRequest struct {
|
|
||||||
MigrateToZoneRequest
|
|
||||||
|
|
||||||
AsyncMode bool `url:"asyncMode"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// MoveToRG moves compute instance to new resource group
|
// MoveToRG moves compute instance to new resource group
|
||||||
func (c Compute) MigrateToZone(ctx context.Context, req MigrateToZoneRequest) (bool, error) {
|
func (c Compute) MigrateToZone(ctx context.Context, req MigrateToZoneRequest) (bool, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
@@ -32,14 +26,9 @@ func (c Compute) MigrateToZone(ctx context.Context, req MigrateToZoneRequest) (b
|
|||||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
reqWrapped := wrapperMigrateToZoneRequest{
|
|
||||||
MigrateToZoneRequest: req,
|
|
||||||
AsyncMode: false,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/migrateToZone"
|
url := "/cloudapi/compute/migrateToZone"
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
@@ -51,25 +40,3 @@ func (c Compute) MigrateToZone(ctx context.Context, req MigrateToZoneRequest) (b
|
|||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// MigrateToZoneAsync moves compute to another zone with AsyncMode
|
|
||||||
func (c Compute) MigrateToZoneAsync(ctx context.Context, req MigrateToZoneRequest) (string, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
reqWrapped := wrapperMigrateToZoneRequest{
|
|
||||||
MigrateToZoneRequest: req,
|
|
||||||
AsyncMode: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/migrateToZone"
|
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
return string(res), nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -83,10 +83,7 @@ type ListUsageSnapshots []ItemUsageSnapshot
|
|||||||
|
|
||||||
// Main information about snapshot
|
// Main information about snapshot
|
||||||
type ItemSnapshot struct {
|
type ItemSnapshot struct {
|
||||||
// Compute info
|
// List disk ID
|
||||||
Compute RecordCompute `json:"compute"`
|
|
||||||
|
|
||||||
// List of disk IDs
|
|
||||||
Disks []uint64 `json:"disks"`
|
Disks []uint64 `json:"disks"`
|
||||||
|
|
||||||
// GUID
|
// GUID
|
||||||
@@ -95,9 +92,6 @@ type ItemSnapshot struct {
|
|||||||
// Label
|
// Label
|
||||||
Label string `json:"label"`
|
Label string `json:"label"`
|
||||||
|
|
||||||
// Memory dump image ID
|
|
||||||
MemoryDumpImage uint64 `json:"memory_dump_image"`
|
|
||||||
|
|
||||||
// Timestamp
|
// Timestamp
|
||||||
Timestamp uint64 `json:"timestamp"`
|
Timestamp uint64 `json:"timestamp"`
|
||||||
}
|
}
|
||||||
@@ -182,9 +176,6 @@ type RecordNetAttach struct {
|
|||||||
// Enabled
|
// Enabled
|
||||||
Enabled bool `json:"enabled"`
|
Enabled bool `json:"enabled"`
|
||||||
|
|
||||||
// Enable default gateway
|
|
||||||
EnableDefaultGateway bool `json:"enable_default_gateway"`
|
|
||||||
|
|
||||||
// Enable security groups
|
// Enable security groups
|
||||||
EnableSecGroups bool `json:"enable_secgroups"`
|
EnableSecGroups bool `json:"enable_secgroups"`
|
||||||
|
|
||||||
@@ -365,9 +356,6 @@ type RecordCompute struct {
|
|||||||
// List clone IDs
|
// List clone IDs
|
||||||
Clones []uint64 `json:"clones"`
|
Clones []uint64 `json:"clones"`
|
||||||
|
|
||||||
// Clock
|
|
||||||
Clock string `json:"clock"`
|
|
||||||
|
|
||||||
// Compute CI ID
|
// Compute CI ID
|
||||||
ComputeCIID uint64 `json:"computeciId"`
|
ComputeCIID uint64 `json:"computeciId"`
|
||||||
|
|
||||||
@@ -494,9 +482,6 @@ type RecordCompute struct {
|
|||||||
// PreferredCPU
|
// PreferredCPU
|
||||||
PreferredCPU []int64 `json:"preferredCpu"`
|
PreferredCPU []int64 `json:"preferredCpu"`
|
||||||
|
|
||||||
// CPU alignment profile
|
|
||||||
CPUAlignmentProfile CPUAlignmentProfile `json:"cpu_alignment_profile"`
|
|
||||||
|
|
||||||
// Qemu_quest
|
// Qemu_quest
|
||||||
QemuQuest QemuQuest `json:"qemu_guest"`
|
QemuQuest QemuQuest `json:"qemu_guest"`
|
||||||
|
|
||||||
@@ -512,9 +497,6 @@ type RecordCompute struct {
|
|||||||
// Registered or not
|
// Registered or not
|
||||||
Registered bool `json:"registered"`
|
Registered bool `json:"registered"`
|
||||||
|
|
||||||
// Whether a compute has been resized online
|
|
||||||
ResizedOnline bool `json:"resizedOnline"`
|
|
||||||
|
|
||||||
// Resource name
|
// Resource name
|
||||||
ResName string `json:"resName"`
|
ResName string `json:"resName"`
|
||||||
|
|
||||||
@@ -558,277 +540,15 @@ type RecordCompute struct {
|
|||||||
Userdata interface{} `json:"userdata"`
|
Userdata interface{} `json:"userdata"`
|
||||||
|
|
||||||
// vGPUs list
|
// vGPUs list
|
||||||
VGPUs []ItemVGPU `json:"vgpus"`
|
VGPUs []VGPUItem `json:"vgpus"`
|
||||||
|
|
||||||
// VNC password
|
// VNC password
|
||||||
VNCPassword string `json:"vncPasswd"`
|
VNCPassword string `json:"vncPasswd"`
|
||||||
|
|
||||||
// Watchdog action
|
|
||||||
WatchdogAction string `json:"watchdog_action"`
|
|
||||||
|
|
||||||
// Weight
|
|
||||||
Weight uint64 `json:"weight"`
|
|
||||||
|
|
||||||
// Zone ID
|
// Zone ID
|
||||||
// Required: false
|
// Required: false
|
||||||
ZoneID uint64 `json:"zoneId"`
|
ZoneID uint64 `json:"zoneId"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type SnapRecordCompute struct {
|
|
||||||
// Access Control List
|
|
||||||
ACL ListACL `json:"acl"`
|
|
||||||
|
|
||||||
// Account ID
|
|
||||||
AccountID uint64 `json:"accountId"`
|
|
||||||
|
|
||||||
// Account name
|
|
||||||
AccountName string `json:"accountName"`
|
|
||||||
|
|
||||||
// Affinity label
|
|
||||||
AffinityLabel string `json:"affinityLabel"`
|
|
||||||
|
|
||||||
// List affinity rules
|
|
||||||
AffinityRules ListRules `json:"affinityRules"`
|
|
||||||
|
|
||||||
// Affinity weight
|
|
||||||
AffinityWeight uint64 `json:"affinityWeight"`
|
|
||||||
|
|
||||||
// List anti affinity rules
|
|
||||||
AntiAffinityRules ListRules `json:"antiAffinityRules"`
|
|
||||||
|
|
||||||
// Auto start when node restarted
|
|
||||||
AutoStart bool `json:"autoStart"`
|
|
||||||
|
|
||||||
// Architecture
|
|
||||||
Architecture string `json:"arch"`
|
|
||||||
|
|
||||||
// Boot image ID
|
|
||||||
BootImageID uint64 `json:"boot_image_id"`
|
|
||||||
|
|
||||||
// Boot order
|
|
||||||
BootOrder []string `json:"bootOrder"`
|
|
||||||
|
|
||||||
// Boot type
|
|
||||||
BootType string `json:"bootType"`
|
|
||||||
|
|
||||||
// Boot disk size
|
|
||||||
BootDiskSize uint64 `json:"bootdiskSize"`
|
|
||||||
|
|
||||||
// CD Image Id
|
|
||||||
CdImageId uint64 `json:"cdImageId"`
|
|
||||||
|
|
||||||
// Chipset
|
|
||||||
Chipset string `json:"chipset"`
|
|
||||||
|
|
||||||
// Clone reference
|
|
||||||
CloneReference uint64 `json:"cloneReference"`
|
|
||||||
|
|
||||||
// List clone IDs
|
|
||||||
Clones []uint64 `json:"clones"`
|
|
||||||
|
|
||||||
// Clock
|
|
||||||
Clock string `json:"clock"`
|
|
||||||
|
|
||||||
// Compute CI ID
|
|
||||||
ComputeCIID uint64 `json:"computeciId"`
|
|
||||||
|
|
||||||
// CPU Pin
|
|
||||||
CPUPin bool `json:"cpupin"`
|
|
||||||
|
|
||||||
// Number of cores
|
|
||||||
CPU uint64 `json:"cpus"`
|
|
||||||
|
|
||||||
// Created by
|
|
||||||
CreatedBy string `json:"createdBy"`
|
|
||||||
|
|
||||||
// Created time
|
|
||||||
CreatedTime uint64 `json:"createdTime"`
|
|
||||||
|
|
||||||
// Custom fields items
|
|
||||||
CustomFields map[string]interface{} `json:"customFields"`
|
|
||||||
|
|
||||||
// Deleted by
|
|
||||||
DeletedBy string `json:"deletedBy"`
|
|
||||||
|
|
||||||
// Deleted time
|
|
||||||
DeletedTime uint64 `json:"deletedTime"`
|
|
||||||
|
|
||||||
// Description
|
|
||||||
Description string `json:"desc"`
|
|
||||||
|
|
||||||
// Devices
|
|
||||||
Devices interface{} `json:"devices"`
|
|
||||||
|
|
||||||
// List disks in compute
|
|
||||||
Disks ListComputeDisks `json:"disks"`
|
|
||||||
|
|
||||||
// Driver
|
|
||||||
Driver string `json:"driver"`
|
|
||||||
|
|
||||||
// Grid ID
|
|
||||||
GID uint64 `json:"gid"`
|
|
||||||
|
|
||||||
// GUID
|
|
||||||
GUID uint64 `json:"guid"`
|
|
||||||
|
|
||||||
// HPBacked
|
|
||||||
HPBacked bool `json:"hpBacked"`
|
|
||||||
|
|
||||||
// Hot resize
|
|
||||||
HotResize bool `json:"hotResize"`
|
|
||||||
|
|
||||||
// ID
|
|
||||||
ID uint64 `json:"id"`
|
|
||||||
|
|
||||||
// Image ID
|
|
||||||
ImageID uint64 `json:"imageId"`
|
|
||||||
|
|
||||||
// Image name
|
|
||||||
ImageName string `json:"imageName"`
|
|
||||||
|
|
||||||
// List interfaces
|
|
||||||
Interfaces ListInterfaces `json:"interfaces"`
|
|
||||||
|
|
||||||
// Loader meta iso information
|
|
||||||
LoaderMetaIso LoaderMetaIso `json:"loaderMetaIso"`
|
|
||||||
|
|
||||||
// Live migration job ID
|
|
||||||
LiveMigrationJobID uint64 `json:"live_migration_job_id"`
|
|
||||||
|
|
||||||
// Loader type
|
|
||||||
LoaderType string `json:"loaderType"`
|
|
||||||
|
|
||||||
// Lock status
|
|
||||||
LockStatus string `json:"lockStatus"`
|
|
||||||
|
|
||||||
// Manager ID
|
|
||||||
ManagerID uint64 `json:"managerId"`
|
|
||||||
|
|
||||||
// Manager type
|
|
||||||
ManagerType string `json:"managerType"`
|
|
||||||
|
|
||||||
// Migration job
|
|
||||||
MigrationJob uint64 `json:"migrationjob"`
|
|
||||||
|
|
||||||
// Milestones
|
|
||||||
Milestones uint64 `json:"milestones"`
|
|
||||||
|
|
||||||
// Name
|
|
||||||
Name string `json:"name"`
|
|
||||||
|
|
||||||
// NeedReboot
|
|
||||||
NeedReboot bool `json:"needReboot"`
|
|
||||||
|
|
||||||
// Network interface naming
|
|
||||||
NetworkInterfaceNaming string `json:"networkInterfaceNaming"`
|
|
||||||
|
|
||||||
// Node ID
|
|
||||||
NodeID uint64 `json:"node_id"`
|
|
||||||
|
|
||||||
// Numa Affinity
|
|
||||||
NumaAffinity string `json:"numaAffinity"`
|
|
||||||
|
|
||||||
//NumaNodeId
|
|
||||||
NumaNodeId int64 `json:"numaNodeId"`
|
|
||||||
|
|
||||||
// Natable VINS ID
|
|
||||||
NatableVINSID uint64 `json:"natableVinsId"`
|
|
||||||
|
|
||||||
// Natable VINS IP
|
|
||||||
NatableVINSIP string `json:"natableVinsIp"`
|
|
||||||
|
|
||||||
// Natable VINS Name
|
|
||||||
NatableVINSName string `json:"natableVinsName"`
|
|
||||||
|
|
||||||
// Natable VINS network
|
|
||||||
NatableVINSNetwork string `json:"natableVinsNetwork"`
|
|
||||||
|
|
||||||
// Natable VINS network name
|
|
||||||
NatableVINSNetworkName string `json:"natableVinsNetworkName"`
|
|
||||||
|
|
||||||
// Name of OS
|
|
||||||
OSVersion string `json:"os_version"`
|
|
||||||
|
|
||||||
// List OS Users
|
|
||||||
OSUsers ListOSUser `json:"osUsers"`
|
|
||||||
|
|
||||||
// Pinned to node
|
|
||||||
PinnedToNode int64 `json:"pinnedToNode"`
|
|
||||||
|
|
||||||
// PreferredCPU
|
|
||||||
PreferredCPU []int64 `json:"preferredCpu"`
|
|
||||||
|
|
||||||
// CPU alignment profile
|
|
||||||
CPUAlignmentProfile CPUAlignmentProfile `json:"cpu_alignment_profile"`
|
|
||||||
|
|
||||||
// Qemu_quest
|
|
||||||
QemuQuest QemuQuest `json:"qemu_guest"`
|
|
||||||
|
|
||||||
// ReadOnly indicates read-only mode state
|
|
||||||
ReadOnly bool `json:"read_only"`
|
|
||||||
|
|
||||||
// Number of RAM
|
|
||||||
RAM uint64 `json:"ram"`
|
|
||||||
|
|
||||||
// Reference ID
|
|
||||||
ReferenceID string `json:"referenceId"`
|
|
||||||
|
|
||||||
// Registered or not
|
|
||||||
Registered bool `json:"registered"`
|
|
||||||
|
|
||||||
// Resource name
|
|
||||||
ResName string `json:"resName"`
|
|
||||||
|
|
||||||
// Reserved Node Cpus
|
|
||||||
ReservedNodeCpus []uint64 `json:"reservedNodeCpus"`
|
|
||||||
|
|
||||||
// Resource group ID
|
|
||||||
RGID uint64 `json:"rgId"`
|
|
||||||
|
|
||||||
// Resource group name
|
|
||||||
RGName string `json:"rgName"`
|
|
||||||
|
|
||||||
// Stateless SepID
|
|
||||||
StatelessSepID int64 `json:"statelessSepId"`
|
|
||||||
|
|
||||||
// Stateless SepType
|
|
||||||
StatelessSepType string `json:"statelessSepType"`
|
|
||||||
|
|
||||||
// Status
|
|
||||||
Status string `json:"status"`
|
|
||||||
|
|
||||||
// Tags
|
|
||||||
Tags map[string]string `json:"tags"`
|
|
||||||
|
|
||||||
// Tech status
|
|
||||||
TechStatus string `json:"techStatus"`
|
|
||||||
|
|
||||||
// Updated by
|
|
||||||
UpdatedBy string `json:"updatedBy"`
|
|
||||||
|
|
||||||
// Updated time
|
|
||||||
UpdatedTime uint64 `json:"updatedTime"`
|
|
||||||
|
|
||||||
// User Managed or not
|
|
||||||
UserManaged bool `json:"userManaged"`
|
|
||||||
|
|
||||||
// Userdata
|
|
||||||
Userdata interface{} `json:"userdata"`
|
|
||||||
|
|
||||||
// vGPUs list
|
|
||||||
VGPUs []ItemVGPU `json:"vgpus"`
|
|
||||||
|
|
||||||
// VNC password
|
|
||||||
VNCPassword string `json:"vncPasswd"`
|
|
||||||
|
|
||||||
// Weight
|
|
||||||
Weight uint64 `json:"weight"`
|
|
||||||
|
|
||||||
// Zone ID
|
|
||||||
// Required: false
|
|
||||||
ZoneID uint64 `json:"zoneId"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type LoaderMetaIso struct {
|
type LoaderMetaIso struct {
|
||||||
// Name
|
// Name
|
||||||
DeviceName string `json:"devicename"`
|
DeviceName string `json:"devicename"`
|
||||||
@@ -845,10 +565,63 @@ type QemuQuest struct {
|
|||||||
User string `json:"user"`
|
User string `json:"user"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type CPUAlignmentProfile struct {
|
type VGPUItem struct {
|
||||||
Model string `json:"model"`
|
// ID
|
||||||
Name string `json:"name"`
|
ID uint64 `json:"id"`
|
||||||
Vendor string `json:"vendor"`
|
|
||||||
|
// GID
|
||||||
|
GID uint64 `json:"gid"`
|
||||||
|
|
||||||
|
// Type
|
||||||
|
Type string `json:"type"`
|
||||||
|
|
||||||
|
// Mode
|
||||||
|
Mode string `json:"mode"`
|
||||||
|
|
||||||
|
// Status
|
||||||
|
Status string `json:"status"`
|
||||||
|
|
||||||
|
// ProfileID
|
||||||
|
ProfileID uint64 `json:"profileId"`
|
||||||
|
|
||||||
|
// RAM
|
||||||
|
RAM uint64 `json:"ram"`
|
||||||
|
|
||||||
|
// LastUpdateTime
|
||||||
|
LastUpdateTime uint64 `json:"lastUpdateTime"`
|
||||||
|
|
||||||
|
// CreatedTime
|
||||||
|
CreatedTime uint64 `json:"createdTime"`
|
||||||
|
|
||||||
|
// DeletedTime
|
||||||
|
DeletedTime uint64 `json:"deletedTime"`
|
||||||
|
|
||||||
|
// VMID
|
||||||
|
VMID uint64 `json:"vmid"`
|
||||||
|
|
||||||
|
// PGPuid
|
||||||
|
PGPuid uint64 `json:"pgpuid"`
|
||||||
|
|
||||||
|
// ReferenceID
|
||||||
|
ReferenceID string `json:"referenceId"`
|
||||||
|
|
||||||
|
// AccountID
|
||||||
|
AccountID uint64 `json:"accountId"`
|
||||||
|
|
||||||
|
// RgID
|
||||||
|
RgID uint64 `json:"rgId"`
|
||||||
|
|
||||||
|
// LastClaimedBy
|
||||||
|
LastClaimedBy uint64 `json:"lastClaimedBy"`
|
||||||
|
|
||||||
|
// PCISlot
|
||||||
|
PCISlot uint64 `json:"pciSlot"`
|
||||||
|
|
||||||
|
// BusNumber
|
||||||
|
BusNumber uint64 `json:"bus_number"`
|
||||||
|
|
||||||
|
// GUID
|
||||||
|
GUID uint64 `json:"guid"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Information about libvirt settings
|
// Information about libvirt settings
|
||||||
@@ -895,10 +668,7 @@ type ListOSUser []ItemOSUser
|
|||||||
|
|
||||||
// Main information about snapsets
|
// Main information about snapsets
|
||||||
type ItemSnapSet struct {
|
type ItemSnapSet struct {
|
||||||
// Compute info
|
// List disk IDs
|
||||||
Compute SnapRecordCompute `json:"compute"`
|
|
||||||
|
|
||||||
// List disk ID
|
|
||||||
Disks []uint64 `json:"disks"`
|
Disks []uint64 `json:"disks"`
|
||||||
|
|
||||||
// GUID
|
// GUID
|
||||||
@@ -907,9 +677,6 @@ type ItemSnapSet struct {
|
|||||||
// Label
|
// Label
|
||||||
Label string `json:"label"`
|
Label string `json:"label"`
|
||||||
|
|
||||||
// Memory dump image ID
|
|
||||||
MemoryDumpImage uint64 `json:"memory_dump_image"`
|
|
||||||
|
|
||||||
// Timestamp
|
// Timestamp
|
||||||
Timestamp uint64 `json:"timestamp"`
|
Timestamp uint64 `json:"timestamp"`
|
||||||
}
|
}
|
||||||
@@ -934,9 +701,6 @@ type ItemVNFInterface struct {
|
|||||||
// Enabled
|
// Enabled
|
||||||
Enabled bool `json:"enabled"`
|
Enabled bool `json:"enabled"`
|
||||||
|
|
||||||
// Enable default gateway
|
|
||||||
EnableDefaultGateway bool `json:"enable_default_gateway"`
|
|
||||||
|
|
||||||
// Enable security groups
|
// Enable security groups
|
||||||
EnableSecGroups bool `json:"enable_secgroups"`
|
EnableSecGroups bool `json:"enable_secgroups"`
|
||||||
|
|
||||||
@@ -982,9 +746,6 @@ type ItemVNFInterface struct {
|
|||||||
// QOS
|
// QOS
|
||||||
QOS QOS `json:"qos"`
|
QOS QOS `json:"qos"`
|
||||||
|
|
||||||
// List of QoS Policy IDs
|
|
||||||
QoSPolicies []uint64 `json:"qos_policies"`
|
|
||||||
|
|
||||||
// List of security groups
|
// List of security groups
|
||||||
SecGroups []uint64 `json:"security_groups"`
|
SecGroups []uint64 `json:"security_groups"`
|
||||||
|
|
||||||
@@ -1028,11 +789,8 @@ type ItemComputeDisk struct {
|
|||||||
// Account ID
|
// Account ID
|
||||||
AccountID uint64 `json:"accountId"`
|
AccountID uint64 `json:"accountId"`
|
||||||
|
|
||||||
// Discard
|
// BLK Discard
|
||||||
Discard string `json:"discard"`
|
BLKDiscard bool `json:"blkdiscard"`
|
||||||
|
|
||||||
// Block Size
|
|
||||||
BlockSize string `json:"block_size"`
|
|
||||||
|
|
||||||
// Boot partition
|
// Boot partition
|
||||||
BootPartition uint64 `json:"bootPartition"`
|
BootPartition uint64 `json:"bootPartition"`
|
||||||
@@ -1079,9 +837,6 @@ type ItemComputeDisk struct {
|
|||||||
// Image ID
|
// Image ID
|
||||||
ImageID uint64 `json:"imageId"`
|
ImageID uint64 `json:"imageId"`
|
||||||
|
|
||||||
// Independent
|
|
||||||
Independent bool `json:"independent"`
|
|
||||||
|
|
||||||
// List image IDs
|
// List image IDs
|
||||||
Images []uint64 `json:"images"`
|
Images []uint64 `json:"images"`
|
||||||
|
|
||||||
@@ -1118,9 +873,6 @@ type ItemComputeDisk struct {
|
|||||||
// Present to
|
// Present to
|
||||||
PresentTo map[string]uint64 `json:"presentTo"`
|
PresentTo map[string]uint64 `json:"presentTo"`
|
||||||
|
|
||||||
// Provision
|
|
||||||
Provision string `json:"provision"`
|
|
||||||
|
|
||||||
// Purge time
|
// Purge time
|
||||||
PurgeTime uint64 `json:"purgeTime"`
|
PurgeTime uint64 `json:"purgeTime"`
|
||||||
|
|
||||||
@@ -1174,9 +926,6 @@ type ItemComputeDisk struct {
|
|||||||
|
|
||||||
// UpdatedTime
|
// UpdatedTime
|
||||||
UpdatedTime uint64 `json:"updatedTime"`
|
UpdatedTime uint64 `json:"updatedTime"`
|
||||||
|
|
||||||
// Read-only
|
|
||||||
ReadOnly bool `json:"read_only"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type ItemReplication struct {
|
type ItemReplication struct {
|
||||||
@@ -1207,9 +956,6 @@ type SnapshotExtend struct {
|
|||||||
// Label
|
// Label
|
||||||
Label string `json:"label"`
|
Label string `json:"label"`
|
||||||
|
|
||||||
// Pool name
|
|
||||||
PoolName string `json:"poolName"`
|
|
||||||
|
|
||||||
// Reference ID
|
// Reference ID
|
||||||
ReferenceID string `json:"referenceId"`
|
ReferenceID string `json:"referenceId"`
|
||||||
|
|
||||||
@@ -1321,9 +1067,6 @@ type ItemCompute struct {
|
|||||||
// Clone reference
|
// Clone reference
|
||||||
CloneReference uint64 `json:"cloneReference"`
|
CloneReference uint64 `json:"cloneReference"`
|
||||||
|
|
||||||
// Clock
|
|
||||||
Clock string `json:"clock"`
|
|
||||||
|
|
||||||
// List clone IDs
|
// List clone IDs
|
||||||
Clones []uint64 `json:"clones"`
|
Clones []uint64 `json:"clones"`
|
||||||
|
|
||||||
@@ -1405,9 +1148,6 @@ type ItemCompute struct {
|
|||||||
// Name
|
// Name
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
|
|
||||||
// Node ID
|
|
||||||
NodeID uint64 `json:"node_id"`
|
|
||||||
|
|
||||||
// NeedReboot
|
// NeedReboot
|
||||||
NeedReboot bool `json:"needReboot"`
|
NeedReboot bool `json:"needReboot"`
|
||||||
|
|
||||||
@@ -1432,9 +1172,6 @@ type ItemCompute struct {
|
|||||||
// Name of OS
|
// Name of OS
|
||||||
OSVersion string `json:"os_version"`
|
OSVersion string `json:"os_version"`
|
||||||
|
|
||||||
// CPU alignment profile
|
|
||||||
CPUAlignmentProfile CPUAlignmentProfile `json:"cpu_alignment_profile"`
|
|
||||||
|
|
||||||
// Qemu_quest
|
// Qemu_quest
|
||||||
QemuQuest QemuQuest `json:"qemu_guest"`
|
QemuQuest QemuQuest `json:"qemu_guest"`
|
||||||
|
|
||||||
@@ -1447,9 +1184,6 @@ type ItemCompute struct {
|
|||||||
// Registered
|
// Registered
|
||||||
Registered bool `json:"registered"`
|
Registered bool `json:"registered"`
|
||||||
|
|
||||||
// Whether a compute has been resized online
|
|
||||||
ResizedOnline bool `json:"resizedOnline"`
|
|
||||||
|
|
||||||
// Resource name
|
// Resource name
|
||||||
ResName string `json:"resName"`
|
ResName string `json:"resName"`
|
||||||
|
|
||||||
@@ -1498,12 +1232,6 @@ type ItemCompute struct {
|
|||||||
// VINS connected
|
// VINS connected
|
||||||
VINSConnected uint64 `json:"vinsConnected"`
|
VINSConnected uint64 `json:"vinsConnected"`
|
||||||
|
|
||||||
// Watchdog action
|
|
||||||
WatchdogAction string `json:"watchdog_action"`
|
|
||||||
|
|
||||||
// Weight
|
|
||||||
Weight uint64 `json:"weight"`
|
|
||||||
|
|
||||||
// Zone ID
|
// Zone ID
|
||||||
ZoneID uint64 `json:"zoneId"`
|
ZoneID uint64 `json:"zoneId"`
|
||||||
}
|
}
|
||||||
@@ -1518,12 +1246,6 @@ type InfoDisk struct {
|
|||||||
|
|
||||||
// SEP ID
|
// SEP ID
|
||||||
SepID int64 `json:"sepId"`
|
SepID int64 `json:"sepId"`
|
||||||
|
|
||||||
// Image ID
|
|
||||||
ImageID uint64 `json:"imageId"`
|
|
||||||
|
|
||||||
// Read-only
|
|
||||||
ReadOnly bool `json:"read_only"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// List information about computes
|
// List information about computes
|
||||||
@@ -1546,56 +1268,59 @@ type ListVGPUs struct {
|
|||||||
|
|
||||||
// Main information about vgpu device
|
// Main information about vgpu device
|
||||||
type ItemVGPU struct {
|
type ItemVGPU struct {
|
||||||
// Account IDs
|
// Account ID
|
||||||
AccountIDs []uint64 `json:"account_ids"`
|
AccountID uint64 `json:"accountId"`
|
||||||
|
|
||||||
// Bus number
|
// Created Time
|
||||||
BusNumber int `json:"bus_number"`
|
CreatedTime uint64 `json:"createdTime"`
|
||||||
|
|
||||||
// ComputeID
|
// Deleted Time
|
||||||
ComputeID uint64 `json:"compute_id"`
|
DeletedTime uint64 `json:"deletedTime"`
|
||||||
|
|
||||||
// Created time
|
// GID
|
||||||
CreatedTime uint64 `json:"created_time"`
|
|
||||||
|
|
||||||
// Deleted time
|
|
||||||
DeletedTime uint64 `json:"deleted_time"`
|
|
||||||
|
|
||||||
// Device Reference
|
|
||||||
DeviceReference string `json:"device_reference"`
|
|
||||||
|
|
||||||
//Grid ID
|
|
||||||
GID uint64 `json:"gid"`
|
GID uint64 `json:"gid"`
|
||||||
|
|
||||||
// GUID
|
// GUID
|
||||||
GUID uint64 `json:"guid"`
|
GUID uint64 `json:"guid"`
|
||||||
|
|
||||||
// VGPU ID
|
// ID
|
||||||
ID uint64 `json:"id"`
|
ID uint64 `json:"id"`
|
||||||
|
|
||||||
// Last Update time
|
// Last Claimed By
|
||||||
LastUpdateTime uint64 `json:"last_update_time"`
|
LastClaimedBy uint64 `json:"lastClaimedBy"`
|
||||||
|
|
||||||
// Mdev UUID
|
// Last Update Time
|
||||||
MdevUUID string `json:"mdev_uuid"`
|
LastUpdateTime uint64 `json:"lastUpdateTime"`
|
||||||
|
|
||||||
// Parent PCI Address
|
// Mode
|
||||||
ParentPCIAddress string `json:"parent_pci_address"`
|
Mode string `json:"mode"`
|
||||||
|
|
||||||
// PCI Slot
|
// PCI Slot
|
||||||
PCISlot uint64 `json:"pci_slot"`
|
PCISlot uint64 `json:"pciSlot"`
|
||||||
|
|
||||||
// PGPU ID
|
// PGPUID
|
||||||
PGPUID uint64 `json:"pgpu_id"`
|
PGPUID uint64 `json:"pgpuid"`
|
||||||
|
|
||||||
// Profile Reference
|
// Profile ID
|
||||||
ProfileReference string `json:"profile_reference"`
|
ProfileID uint64 `json:"profileId"`
|
||||||
|
|
||||||
// Split Mode
|
// RAM
|
||||||
SplitMode string `json:"split_mode"`
|
RAM uint64 `json:"ram"`
|
||||||
|
|
||||||
|
// Reference ID
|
||||||
|
ReferenceID string `json:"referenceId"`
|
||||||
|
|
||||||
|
// RG ID
|
||||||
|
RGID uint64 `json:"rgId"`
|
||||||
|
|
||||||
// Status
|
// Status
|
||||||
Status string `json:"status"`
|
Status string `json:"status"`
|
||||||
|
|
||||||
|
// Type
|
||||||
|
Type string `json:"type"`
|
||||||
|
|
||||||
|
// VM ID
|
||||||
|
VMID uint64 `json:"vmid"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Main information about PCI device
|
// Main information about PCI device
|
||||||
@@ -1618,8 +1343,8 @@ type ItemPCIDevice struct {
|
|||||||
// Name
|
// Name
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
|
|
||||||
// Account IDs
|
// Resource group ID
|
||||||
AccountIDs []uint64 `json:"account_ids"`
|
RGID uint64 `json:"rgId"`
|
||||||
|
|
||||||
// Node ID
|
// Node ID
|
||||||
NodeID uint64 `json:"nodeId"`
|
NodeID uint64 `json:"nodeId"`
|
||||||
@@ -1648,21 +1373,6 @@ type RecordCloneStatus struct {
|
|||||||
Status CloneStatus `json:"status"`
|
Status CloneStatus `json:"status"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Information about aborted clone disk
|
|
||||||
type RecordCloneAbort struct {
|
|
||||||
// Disk ID
|
|
||||||
DiskID uint64 `json:"disk_id"`
|
|
||||||
|
|
||||||
// Aborted
|
|
||||||
Aborted bool `json:"aborted"`
|
|
||||||
|
|
||||||
// Blockcopy abort job ID
|
|
||||||
BlockcopyAbortJobID string `json:"blockcopy_abort_job_id"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// List of aborted clone disks
|
|
||||||
type ListCloneAbort []RecordCloneAbort
|
|
||||||
|
|
||||||
type CloneStatus struct {
|
type CloneStatus struct {
|
||||||
// Type
|
// Type
|
||||||
Type int `json:"type"`
|
Type int `json:"type"`
|
||||||
|
|||||||
@@ -34,12 +34,6 @@ type MoveToRGRequest struct {
|
|||||||
ForceStop bool `url:"forceStop,omitempty" json:"forceStop,omitempty"`
|
ForceStop bool `url:"forceStop,omitempty" json:"forceStop,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type wrapperMoveToRGRequest struct {
|
|
||||||
MoveToRGRequest
|
|
||||||
|
|
||||||
AsyncMode bool `url:"asyncMode"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// MoveToRG moves compute instance to new resource group
|
// MoveToRG moves compute instance to new resource group
|
||||||
func (c Compute) MoveToRG(ctx context.Context, req MoveToRGRequest) (bool, error) {
|
func (c Compute) MoveToRG(ctx context.Context, req MoveToRGRequest) (bool, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
@@ -47,14 +41,9 @@ func (c Compute) MoveToRG(ctx context.Context, req MoveToRGRequest) (bool, error
|
|||||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
reqWrapped := wrapperMoveToRGRequest{
|
|
||||||
MoveToRGRequest: req,
|
|
||||||
AsyncMode: false,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/moveToRg"
|
url := "/cloudapi/compute/moveToRg"
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
@@ -66,25 +55,3 @@ func (c Compute) MoveToRG(ctx context.Context, req MoveToRGRequest) (bool, error
|
|||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// MoveToRGAsync moves compute instance to new resource group with AsyncMode
|
|
||||||
func (c Compute) MoveToRGAsync(ctx context.Context, req MoveToRGRequest) (string, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
reqWrapped := wrapperMoveToRGRequest{
|
|
||||||
MoveToRGRequest: req,
|
|
||||||
AsyncMode: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/moveToRg"
|
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
return string(res), nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -39,8 +39,9 @@ type NetAttachRequest struct {
|
|||||||
// Required: false
|
// Required: false
|
||||||
MACAddr string `url:"mac_addr,omitempty" json:"mac_addr,omitempty"`
|
MACAddr string `url:"mac_addr,omitempty" json:"mac_addr,omitempty"`
|
||||||
|
|
||||||
// Used for EXTNET, TRUNK and DPDK
|
// Used only for EXTNET and DPDK
|
||||||
// Must be 1500-9216
|
// For DPDK must be 1-9216
|
||||||
|
// For EXTNET must be 1500-9216
|
||||||
// Required: false
|
// Required: false
|
||||||
MTU uint64 `url:"mtu,omitempty" json:"mtu,omitempty" validate:"omitempty,mtu"`
|
MTU uint64 `url:"mtu,omitempty" json:"mtu,omitempty" validate:"omitempty,mtu"`
|
||||||
|
|
||||||
@@ -53,9 +54,9 @@ type NetAttachRequest struct {
|
|||||||
// Required: false
|
// Required: false
|
||||||
SDNSegmentID string `url:"sdn_segment_id,omitempty" json:"sdn_segment_id,omitempty"`
|
SDNSegmentID string `url:"sdn_segment_id,omitempty" json:"sdn_segment_id,omitempty"`
|
||||||
|
|
||||||
// SDN Object Group IDs
|
// SDN Object Group ID
|
||||||
// Required: false
|
// Required: false
|
||||||
SDNObjectGroupIDs []string `url:"sdn_object_group_ids,omitempty" json:"sdn_object_group_ids,omitempty"`
|
SDNObjectGroupID string `url:"sdn_object_group_id,omitempty" json:"sdn_object_group_id,omitempty"`
|
||||||
|
|
||||||
// SDN Logical Port Display Name
|
// SDN Logical Port Display Name
|
||||||
// Required: false
|
// Required: false
|
||||||
@@ -74,28 +75,12 @@ type NetAttachRequest struct {
|
|||||||
SecGroups []uint64 `url:"security_groups,omitempty" json:"security_groups,omitempty"`
|
SecGroups []uint64 `url:"security_groups,omitempty" json:"security_groups,omitempty"`
|
||||||
|
|
||||||
// Flag indicating whether security groups are enabled for this interface
|
// Flag indicating whether security groups are enabled for this interface
|
||||||
// Not applicable to netType VFNIC, TRUNK, or SDN
|
|
||||||
// Required: false
|
// Required: false
|
||||||
EnableSecGroups bool `url:"enable_secgroups,omitempty" json:"enable_secgroups,omitempty"`
|
EnableSecGroups bool `url:"enable_secgroups,omitempty" json:"enable_secgroups,omitempty"`
|
||||||
|
|
||||||
// Flag indicating whether this interface is enabled (only for VINS, EXTNET, DPDK, SDN, TRUNK)
|
// Flag indicating whether this interface is enabled (only for VINS, EXTNET, DPDK, SDN, TRUNK)
|
||||||
// Required: false
|
// Required: false
|
||||||
Enabled interface{} `url:"enabled,omitempty" json:"enabled,omitempty" validate:"omitempty,isBool"`
|
Enabled interface{} `url:"enabled,omitempty" json:"enabled,omitempty" validate:"omitempty,isBool"`
|
||||||
|
|
||||||
// Flag indicating whether default gateway is enabled for this interface
|
|
||||||
// Required: false
|
|
||||||
// Default: true
|
|
||||||
EnableDefaultGateway interface{} `url:"enable_default_gateway,omitempty" json:"enable_default_gateway,omitempty" validate:"omitempty,isBool"`
|
|
||||||
|
|
||||||
// List of QoS Policy IDs to apply to this interface (default: []), Allow used only with netType VINS, EXTNET and DPDK
|
|
||||||
// Required: false
|
|
||||||
QoSPolicies []uint64 `url:"qos_policies,omitempty" json:"qos_policies,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type wrapperNetAttachRequest struct {
|
|
||||||
NetAttachRequest
|
|
||||||
|
|
||||||
AsyncMode bool `url:"asyncMode"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// NetAttach attaches network to compute and gets info about network
|
// NetAttach attaches network to compute and gets info about network
|
||||||
@@ -105,14 +90,9 @@ func (c Compute) NetAttach(ctx context.Context, req NetAttachRequest) (*RecordNe
|
|||||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
reqWrapped := wrapperNetAttachRequest{
|
|
||||||
NetAttachRequest: req,
|
|
||||||
AsyncMode: false,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/netAttach"
|
url := "/cloudapi/compute/netAttach"
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -126,25 +106,3 @@ func (c Compute) NetAttach(ctx context.Context, req NetAttachRequest) (*RecordNe
|
|||||||
|
|
||||||
return &info, nil
|
return &info, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// NetAttachAsync attaches network to compute with AsyncMode
|
|
||||||
func (c Compute) NetAttachAsync(ctx context.Context, req NetAttachRequest) (string, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
reqWrapped := wrapperNetAttachRequest{
|
|
||||||
NetAttachRequest: req,
|
|
||||||
AsyncMode: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/netAttach"
|
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
return string(res), nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -23,12 +23,6 @@ type NetDetachRequest struct {
|
|||||||
MAC string `url:"mac,omitempty" json:"mac,omitempty"`
|
MAC string `url:"mac,omitempty" json:"mac,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type wrapperNetDetachRequest struct {
|
|
||||||
NetDetachRequest
|
|
||||||
|
|
||||||
AsyncMode bool `url:"asyncMode"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// NetDetach detaches network from compute
|
// NetDetach detaches network from compute
|
||||||
func (c Compute) NetDetach(ctx context.Context, req NetDetachRequest) (bool, error) {
|
func (c Compute) NetDetach(ctx context.Context, req NetDetachRequest) (bool, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
@@ -36,14 +30,9 @@ func (c Compute) NetDetach(ctx context.Context, req NetDetachRequest) (bool, err
|
|||||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
reqWrapped := wrapperNetDetachRequest{
|
|
||||||
NetDetachRequest: req,
|
|
||||||
AsyncMode: false,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/netDetach"
|
url := "/cloudapi/compute/netDetach"
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
@@ -55,25 +44,3 @@ func (c Compute) NetDetach(ctx context.Context, req NetDetachRequest) (bool, err
|
|||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// NetDetachAsync detaches network from compute with AsyncMode
|
|
||||||
func (c Compute) NetDetachAsync(ctx context.Context, req NetDetachRequest) (string, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
reqWrapped := wrapperNetDetachRequest{
|
|
||||||
NetDetachRequest: req,
|
|
||||||
AsyncMode: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/netDetach"
|
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
return string(res), nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -15,12 +15,6 @@ type PauseRequest struct {
|
|||||||
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
|
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type wrapperPauseRequest struct {
|
|
||||||
PauseRequest
|
|
||||||
|
|
||||||
AsyncMode bool `url:"asyncMode"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// Pause pause compute
|
// Pause pause compute
|
||||||
func (c Compute) Pause(ctx context.Context, req PauseRequest) (bool, error) {
|
func (c Compute) Pause(ctx context.Context, req PauseRequest) (bool, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
@@ -28,14 +22,9 @@ func (c Compute) Pause(ctx context.Context, req PauseRequest) (bool, error) {
|
|||||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
reqWrapped := wrapperPauseRequest{
|
|
||||||
PauseRequest: req,
|
|
||||||
AsyncMode: false,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/pause"
|
url := "/cloudapi/compute/pause"
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
@@ -47,25 +36,3 @@ func (c Compute) Pause(ctx context.Context, req PauseRequest) (bool, error) {
|
|||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// PauseAsync pauses compute with AsyncMode
|
|
||||||
func (c Compute) PauseAsync(ctx context.Context, req PauseRequest) (string, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
reqWrapped := wrapperPauseRequest{
|
|
||||||
PauseRequest: req,
|
|
||||||
AsyncMode: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/pause"
|
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
return string(res), nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -33,12 +33,6 @@ type PFWAddRequest struct {
|
|||||||
Proto string `url:"proto" json:"proto" validate:"proto"`
|
Proto string `url:"proto" json:"proto" validate:"proto"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type wrapperPFWAddRequest struct {
|
|
||||||
PFWAddRequest
|
|
||||||
|
|
||||||
AsyncMode bool `url:"asyncMode"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// PFWAdd add port forward rule
|
// PFWAdd add port forward rule
|
||||||
func (c Compute) PFWAdd(ctx context.Context, req PFWAddRequest) (uint64, error) {
|
func (c Compute) PFWAdd(ctx context.Context, req PFWAddRequest) (uint64, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
@@ -46,14 +40,9 @@ func (c Compute) PFWAdd(ctx context.Context, req PFWAddRequest) (uint64, error)
|
|||||||
return 0, validators.ValidationErrors(validators.GetErrors(err))
|
return 0, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
reqWrapped := wrapperPFWAddRequest{
|
|
||||||
PFWAddRequest: req,
|
|
||||||
AsyncMode: false,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/pfwAdd"
|
url := "/cloudapi/compute/pfwAdd"
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
@@ -65,25 +54,3 @@ func (c Compute) PFWAdd(ctx context.Context, req PFWAddRequest) (uint64, error)
|
|||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// PFWAddAsync adds port forward rule with AsyncMode
|
|
||||||
func (c Compute) PFWAddAsync(ctx context.Context, req PFWAddRequest) (string, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
reqWrapped := wrapperPFWAddRequest{
|
|
||||||
PFWAddRequest: req,
|
|
||||||
AsyncMode: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/pfwAdd"
|
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
return string(res), nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -36,12 +36,6 @@ type PFWDelRequest struct {
|
|||||||
Proto string `url:"proto,omitempty" json:"proto,omitempty"`
|
Proto string `url:"proto,omitempty" json:"proto,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type wrapperPFWDelRequest struct {
|
|
||||||
PFWDelRequest
|
|
||||||
|
|
||||||
AsyncMode bool `url:"asyncMode"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// PFWDel deletes port forward rule
|
// PFWDel deletes port forward rule
|
||||||
func (c Compute) PFWDel(ctx context.Context, req PFWDelRequest) (bool, error) {
|
func (c Compute) PFWDel(ctx context.Context, req PFWDelRequest) (bool, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
@@ -49,14 +43,9 @@ func (c Compute) PFWDel(ctx context.Context, req PFWDelRequest) (bool, error) {
|
|||||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
reqWrapped := wrapperPFWDelRequest{
|
|
||||||
PFWDelRequest: req,
|
|
||||||
AsyncMode: false,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/pfwDel"
|
url := "/cloudapi/compute/pfwDel"
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
@@ -68,25 +57,3 @@ func (c Compute) PFWDel(ctx context.Context, req PFWDelRequest) (bool, error) {
|
|||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// PFWDelAsync deletes port forward rule with AsyncMode
|
|
||||||
func (c Compute) PFWDelAsync(ctx context.Context, req PFWDelRequest) (string, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
reqWrapped := wrapperPFWDelRequest{
|
|
||||||
PFWDelRequest: req,
|
|
||||||
AsyncMode: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/pfwDel"
|
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
return string(res), nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -20,12 +20,6 @@ type PinToNodeRequest struct {
|
|||||||
AutoStart bool `url:"autoStart" json:"autoStart"`
|
AutoStart bool `url:"autoStart" json:"autoStart"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type wrapperPinToNodeRequest struct {
|
|
||||||
PinToNodeRequest
|
|
||||||
|
|
||||||
AsyncMode bool `url:"asyncMode"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// PinToNode pin compute to current node
|
// PinToNode pin compute to current node
|
||||||
func (c Compute) PinToNode(ctx context.Context, req PinToNodeRequest) (bool, error) {
|
func (c Compute) PinToNode(ctx context.Context, req PinToNodeRequest) (bool, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
@@ -33,14 +27,9 @@ func (c Compute) PinToNode(ctx context.Context, req PinToNodeRequest) (bool, err
|
|||||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
reqWrapped := wrapperPinToNodeRequest{
|
|
||||||
PinToNodeRequest: req,
|
|
||||||
AsyncMode: false,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/pin_to_node"
|
url := "/cloudapi/compute/pin_to_node"
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
@@ -52,25 +41,3 @@ func (c Compute) PinToNode(ctx context.Context, req PinToNodeRequest) (bool, err
|
|||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// PinToNodeAsync pins compute to current node with AsyncMode
|
|
||||||
func (c Compute) PinToNodeAsync(ctx context.Context, req PinToNodeRequest) (string, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
reqWrapped := wrapperPinToNodeRequest{
|
|
||||||
PinToNodeRequest: req,
|
|
||||||
AsyncMode: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/pin_to_node"
|
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
return string(res), nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -15,12 +15,6 @@ type PowerCycleRequest struct {
|
|||||||
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
|
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type wrapperPowerCycleRequest struct {
|
|
||||||
PowerCycleRequest
|
|
||||||
|
|
||||||
AsyncMode bool `url:"asyncMode"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// PowerCycle makes force stop and start compute
|
// PowerCycle makes force stop and start compute
|
||||||
func (c Compute) PowerCycle(ctx context.Context, req PowerCycleRequest) (bool, error) {
|
func (c Compute) PowerCycle(ctx context.Context, req PowerCycleRequest) (bool, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
@@ -28,14 +22,9 @@ func (c Compute) PowerCycle(ctx context.Context, req PowerCycleRequest) (bool, e
|
|||||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
reqWrapped := wrapperPowerCycleRequest{
|
|
||||||
PowerCycleRequest: req,
|
|
||||||
AsyncMode: false,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/powerCycle"
|
url := "/cloudapi/compute/powerCycle"
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
@@ -47,25 +36,3 @@ func (c Compute) PowerCycle(ctx context.Context, req PowerCycleRequest) (bool, e
|
|||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// PowerCycleAsync makes force stop and start compute with AsyncMode
|
|
||||||
func (c Compute) PowerCycleAsync(ctx context.Context, req PowerCycleRequest) (string, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
reqWrapped := wrapperPowerCycleRequest{
|
|
||||||
PowerCycleRequest: req,
|
|
||||||
AsyncMode: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/powerCycle"
|
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
return string(res), nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -15,12 +15,6 @@ type RebootRequest struct {
|
|||||||
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
|
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type wrapperRebootRequest struct {
|
|
||||||
RebootRequest
|
|
||||||
|
|
||||||
AsyncMode bool `url:"asyncMode"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// Reboot reboots compute
|
// Reboot reboots compute
|
||||||
func (c Compute) Reboot(ctx context.Context, req RebootRequest) (bool, error) {
|
func (c Compute) Reboot(ctx context.Context, req RebootRequest) (bool, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
@@ -28,14 +22,9 @@ func (c Compute) Reboot(ctx context.Context, req RebootRequest) (bool, error) {
|
|||||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
reqWrapped := wrapperRebootRequest{
|
|
||||||
RebootRequest: req,
|
|
||||||
AsyncMode: false,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/reboot"
|
url := "/cloudapi/compute/reboot"
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
@@ -47,25 +36,3 @@ func (c Compute) Reboot(ctx context.Context, req RebootRequest) (bool, error) {
|
|||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// RebootAsync reboots compute with AsyncMode
|
|
||||||
func (c Compute) RebootAsync(ctx context.Context, req RebootRequest) (string, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
reqWrapped := wrapperRebootRequest{
|
|
||||||
RebootRequest: req,
|
|
||||||
AsyncMode: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/reboot"
|
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
return string(res), nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ type RedeployRequest struct {
|
|||||||
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
|
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
|
||||||
|
|
||||||
// Storage policy id of compute. The rules of the specified storage policy will be used.
|
// Storage policy id of compute. The rules of the specified storage policy will be used.
|
||||||
// Required: false
|
// Required: true
|
||||||
StoragePolicyID uint64 `url:"storage_policy_id,omitempty" json:"storage_policy_id,omitempty"`
|
StoragePolicyID uint64 `url:"storage_policy_id,omitempty" json:"storage_policy_id,omitempty"`
|
||||||
|
|
||||||
// ID of the new OS image, if image change is required
|
// ID of the new OS image, if image change is required
|
||||||
@@ -44,12 +44,6 @@ type RedeployRequest struct {
|
|||||||
ForceStop bool `url:"forceStop,omitempty" json:"forceStop,omitempty"`
|
ForceStop bool `url:"forceStop,omitempty" json:"forceStop,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type wrapperRedeployRequest struct {
|
|
||||||
RedeployRequest
|
|
||||||
|
|
||||||
AsyncMode bool `url:"asyncMode"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// Redeploy redeploys compute
|
// Redeploy redeploys compute
|
||||||
func (c Compute) Redeploy(ctx context.Context, req RedeployRequest) (bool, error) {
|
func (c Compute) Redeploy(ctx context.Context, req RedeployRequest) (bool, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
@@ -57,14 +51,9 @@ func (c Compute) Redeploy(ctx context.Context, req RedeployRequest) (bool, error
|
|||||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
reqWrapped := wrapperRedeployRequest{
|
|
||||||
RedeployRequest: req,
|
|
||||||
AsyncMode: false,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/redeploy"
|
url := "/cloudapi/compute/redeploy"
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
@@ -76,25 +65,3 @@ func (c Compute) Redeploy(ctx context.Context, req RedeployRequest) (bool, error
|
|||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// RedeployAsync redeploys compute with AsyncMode
|
|
||||||
func (c Compute) RedeployAsync(ctx context.Context, req RedeployRequest) (string, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
reqWrapped := wrapperRedeployRequest{
|
|
||||||
RedeployRequest: req,
|
|
||||||
AsyncMode: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/redeploy"
|
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
return string(res), nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -15,12 +15,6 @@ type ResetRequest struct {
|
|||||||
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
|
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type wrapperResetRequest struct {
|
|
||||||
ResetRequest
|
|
||||||
|
|
||||||
AsyncMode bool `url:"asyncMode"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// Reset resets compute
|
// Reset resets compute
|
||||||
func (c Compute) Reset(ctx context.Context, req ResetRequest) (bool, error) {
|
func (c Compute) Reset(ctx context.Context, req ResetRequest) (bool, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
@@ -28,14 +22,9 @@ func (c Compute) Reset(ctx context.Context, req ResetRequest) (bool, error) {
|
|||||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
reqWrapped := wrapperResetRequest{
|
|
||||||
ResetRequest: req,
|
|
||||||
AsyncMode: false,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/reset"
|
url := "/cloudapi/compute/reset"
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
@@ -47,25 +36,3 @@ func (c Compute) Reset(ctx context.Context, req ResetRequest) (bool, error) {
|
|||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// ResetAsync resets compute with AsyncMode
|
|
||||||
func (c Compute) ResetAsync(ctx context.Context, req ResetRequest) (string, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
reqWrapped := wrapperResetRequest{
|
|
||||||
ResetRequest: req,
|
|
||||||
AsyncMode: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/reset"
|
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
return string(res), nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -43,12 +43,6 @@ func (r ResizeRequest) GetRAM() map[string]uint64 {
|
|||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
type wrapperResizeRequest struct {
|
|
||||||
ResizeRequest
|
|
||||||
|
|
||||||
AsyncMode bool `url:"asyncMode"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// Resize resizes compute instance
|
// Resize resizes compute instance
|
||||||
func (c Compute) Resize(ctx context.Context, req ResizeRequest) (bool, error) {
|
func (c Compute) Resize(ctx context.Context, req ResizeRequest) (bool, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
@@ -56,14 +50,9 @@ func (c Compute) Resize(ctx context.Context, req ResizeRequest) (bool, error) {
|
|||||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
reqWrapped := wrapperResizeRequest{
|
|
||||||
ResizeRequest: req,
|
|
||||||
AsyncMode: false,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/resize"
|
url := "/cloudapi/compute/resize"
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
@@ -75,25 +64,3 @@ func (c Compute) Resize(ctx context.Context, req ResizeRequest) (bool, error) {
|
|||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// ResizeAsync resizes compute instance with AsyncMode
|
|
||||||
func (c Compute) ResizeAsync(ctx context.Context, req ResizeRequest) (string, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
reqWrapped := wrapperResizeRequest{
|
|
||||||
ResizeRequest: req,
|
|
||||||
AsyncMode: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/resize"
|
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
return string(res), nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ package compute
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
|
||||||
|
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
)
|
)
|
||||||
@@ -15,54 +14,16 @@ type RestoreRequest struct {
|
|||||||
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
|
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type wrapperRestoreRequest struct {
|
|
||||||
RestoreRequest
|
|
||||||
|
|
||||||
AsyncMode bool `url:"asyncMode"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// Restore restores compute from recycle bin
|
// Restore restores compute from recycle bin
|
||||||
func (c Compute) Restore(ctx context.Context, req RestoreRequest) (bool, error) {
|
func (c Compute) Restore(ctx context.Context, req RestoreRequest) (string, error) {
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
reqWrapped := wrapperRestoreRequest{
|
|
||||||
RestoreRequest: req,
|
|
||||||
AsyncMode: false,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/restore"
|
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
|
||||||
if err != nil {
|
|
||||||
return false, err
|
|
||||||
}
|
|
||||||
|
|
||||||
result, err := strconv.ParseBool(string(res))
|
|
||||||
if err != nil {
|
|
||||||
return false, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return result, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// RestoreAsync restores compute from recycle bin with AsyncMode
|
|
||||||
func (c Compute) RestoreAsync(ctx context.Context, req RestoreRequest) (string, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
reqWrapped := wrapperRestoreRequest{
|
|
||||||
RestoreRequest: req,
|
|
||||||
AsyncMode: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/restore"
|
url := "/cloudapi/compute/restore"
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,12 +15,6 @@ type ResumeRequest struct {
|
|||||||
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
|
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type wrapperResumeRequest struct {
|
|
||||||
ResumeRequest
|
|
||||||
|
|
||||||
AsyncMode bool `url:"asyncMode"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// Resume resume Compute from paused state
|
// Resume resume Compute from paused state
|
||||||
func (c Compute) Resume(ctx context.Context, req ResumeRequest) (bool, error) {
|
func (c Compute) Resume(ctx context.Context, req ResumeRequest) (bool, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
@@ -28,14 +22,9 @@ func (c Compute) Resume(ctx context.Context, req ResumeRequest) (bool, error) {
|
|||||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
reqWrapped := wrapperResumeRequest{
|
|
||||||
ResumeRequest: req,
|
|
||||||
AsyncMode: false,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/resume"
|
url := "/cloudapi/compute/resume"
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
@@ -47,25 +36,3 @@ func (c Compute) Resume(ctx context.Context, req ResumeRequest) (bool, error) {
|
|||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// ResumeAsync resumes Compute from paused state with AsyncMode
|
|
||||||
func (c Compute) ResumeAsync(ctx context.Context, req ResumeRequest) (string, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
reqWrapped := wrapperResumeRequest{
|
|
||||||
ResumeRequest: req,
|
|
||||||
AsyncMode: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/resume"
|
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
return string(res), nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,43 +0,0 @@
|
|||||||
package compute
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"net/http"
|
|
||||||
"strconv"
|
|
||||||
|
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants"
|
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
|
||||||
)
|
|
||||||
|
|
||||||
// SetCPUAlignmentProfileRequest struct to set CPU alignment profile for computes
|
|
||||||
type SetCPUAlignmentProfileRequest struct {
|
|
||||||
// IDs of the compute instances
|
|
||||||
// Required: true
|
|
||||||
ComputeIDs []int64 `url:"compute_ids" json:"compute_ids" validate:"min=1"`
|
|
||||||
|
|
||||||
// CPU alignment profile name
|
|
||||||
// Required: true
|
|
||||||
CPUAlignmentProfile string `url:"cpu_alignment_profile" json:"cpu_alignment_profile" validate:"required"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetCPUAlignmentProfile sets CPU alignment profile for computes
|
|
||||||
func (c Compute) SetCPUAlignmentProfile(ctx context.Context, req SetCPUAlignmentProfileRequest) (bool, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/set_cpu_alignment_profile"
|
|
||||||
|
|
||||||
res, err := c.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
|
|
||||||
if err != nil {
|
|
||||||
return false, err
|
|
||||||
}
|
|
||||||
|
|
||||||
result, err := strconv.ParseBool(string(res))
|
|
||||||
if err != nil {
|
|
||||||
return false, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return result, nil
|
|
||||||
}
|
|
||||||
@@ -16,37 +16,20 @@ type SnapshotCreateRequest struct {
|
|||||||
|
|
||||||
// Text label for snapshot.
|
// Text label for snapshot.
|
||||||
// Must be unique among this compute snapshots
|
// Must be unique among this compute snapshots
|
||||||
// Allowed characters: a-z, 0-9, spaces, punctuation except '<' and '>'
|
|
||||||
// Maximum length: 36 characters
|
|
||||||
// Required: true
|
// Required: true
|
||||||
Label string `url:"label" json:"label" validate:"required,max=36,excludesall=<>"`
|
Label string `url:"label" json:"label" validate:"required"`
|
||||||
|
|
||||||
// Create snapshot with memory dump
|
|
||||||
// Required: false
|
|
||||||
// Default: false
|
|
||||||
WithMemory bool `url:"with_memory" json:"with_memory"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type wrapperSnapshotCreateRequest struct {
|
// SnapshotCreate create compute snapshot
|
||||||
SnapshotCreateRequest
|
|
||||||
AsyncMode bool `url:"asyncMode"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// SnapshotCreate creates compute snapshot
|
|
||||||
func (c Compute) SnapshotCreate(ctx context.Context, req SnapshotCreateRequest) (string, error) {
|
func (c Compute) SnapshotCreate(ctx context.Context, req SnapshotCreateRequest) (string, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
reqWrapped := wrapperSnapshotCreateRequest{
|
|
||||||
SnapshotCreateRequest: req,
|
|
||||||
AsyncMode: false,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/snapshotCreate"
|
url := "/cloudapi/compute/snapshotCreate"
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
@@ -55,25 +38,3 @@ func (c Compute) SnapshotCreate(ctx context.Context, req SnapshotCreateRequest)
|
|||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// SnapshotCreateAsync creates compute snapshot in async mode
|
|
||||||
func (c Compute) SnapshotCreateAsync(ctx context.Context, req SnapshotCreateRequest) (string, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
reqWrapped := wrapperSnapshotCreateRequest{
|
|
||||||
SnapshotCreateRequest: req,
|
|
||||||
AsyncMode: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/snapshotCreate"
|
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
return string(res), nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -17,16 +17,6 @@ type SnapshotRollbackRequest struct {
|
|||||||
// Text label of snapshot to rollback
|
// Text label of snapshot to rollback
|
||||||
// Required: true
|
// Required: true
|
||||||
Label string `url:"label" json:"label" validate:"required"`
|
Label string `url:"label" json:"label" validate:"required"`
|
||||||
|
|
||||||
// Rollback with memory dump restore
|
|
||||||
// Required: false
|
|
||||||
// Default: true
|
|
||||||
WithMemory interface{} `url:"with_memory,omitempty" json:"with_memory,omitempty" validate:"omitempty,isBool"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type wrapperSnapshotRollbackRequest struct {
|
|
||||||
SnapshotRollbackRequest
|
|
||||||
AsyncMode bool `url:"asyncMode"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// SnapshotRollback rollbacks specified compute snapshot
|
// SnapshotRollback rollbacks specified compute snapshot
|
||||||
@@ -36,14 +26,9 @@ func (c Compute) SnapshotRollback(ctx context.Context, req SnapshotRollbackReque
|
|||||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
reqWrapped := wrapperSnapshotRollbackRequest{
|
|
||||||
SnapshotRollbackRequest: req,
|
|
||||||
AsyncMode: false,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/snapshotRollback"
|
url := "/cloudapi/compute/snapshotRollback"
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
@@ -55,25 +40,3 @@ func (c Compute) SnapshotRollback(ctx context.Context, req SnapshotRollbackReque
|
|||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// SnapshotRollbackAsync rollbacks specified compute snapshot in async mode
|
|
||||||
func (c Compute) SnapshotRollbackAsync(ctx context.Context, req SnapshotRollbackRequest) (string, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
reqWrapped := wrapperSnapshotRollbackRequest{
|
|
||||||
SnapshotRollbackRequest: req,
|
|
||||||
AsyncMode: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/snapshotRollback"
|
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
return string(res), nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -19,12 +19,6 @@ type StartRequest struct {
|
|||||||
AltBootID uint64 `url:"altBootId,omitempty" json:"altBootId,omitempty"`
|
AltBootID uint64 `url:"altBootId,omitempty" json:"altBootId,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type wrapperStartRequest struct {
|
|
||||||
StartRequest
|
|
||||||
|
|
||||||
AsyncMode bool `url:"asyncMode"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// Start starts compute
|
// Start starts compute
|
||||||
func (c Compute) Start(ctx context.Context, req StartRequest) (bool, error) {
|
func (c Compute) Start(ctx context.Context, req StartRequest) (bool, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
@@ -32,14 +26,9 @@ func (c Compute) Start(ctx context.Context, req StartRequest) (bool, error) {
|
|||||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
reqWrapped := wrapperStartRequest{
|
|
||||||
StartRequest: req,
|
|
||||||
AsyncMode: false,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/start"
|
url := "/cloudapi/compute/start"
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
@@ -51,25 +40,3 @@ func (c Compute) Start(ctx context.Context, req StartRequest) (bool, error) {
|
|||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// StartAsync starts compute with AsyncMode
|
|
||||||
func (c Compute) StartAsync(ctx context.Context, req StartRequest) (string, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
reqWrapped := wrapperStartRequest{
|
|
||||||
StartRequest: req,
|
|
||||||
AsyncMode: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/start"
|
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
return string(res), nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -19,12 +19,6 @@ type StopRequest struct {
|
|||||||
Force bool `url:"force,omitempty" json:"force,omitempty"`
|
Force bool `url:"force,omitempty" json:"force,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type wrapperStopRequest struct {
|
|
||||||
StopRequest
|
|
||||||
|
|
||||||
AsyncMode bool `url:"asyncMode"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// Stop stops compute
|
// Stop stops compute
|
||||||
func (c Compute) Stop(ctx context.Context, req StopRequest) (bool, error) {
|
func (c Compute) Stop(ctx context.Context, req StopRequest) (bool, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
@@ -32,14 +26,9 @@ func (c Compute) Stop(ctx context.Context, req StopRequest) (bool, error) {
|
|||||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
reqWrapped := wrapperStopRequest{
|
|
||||||
StopRequest: req,
|
|
||||||
AsyncMode: false,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/stop"
|
url := "/cloudapi/compute/stop"
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
@@ -51,25 +40,3 @@ func (c Compute) Stop(ctx context.Context, req StopRequest) (bool, error) {
|
|||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// StopAsync stops compute with AsyncMode
|
|
||||||
func (c Compute) StopAsync(ctx context.Context, req StopRequest) (string, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
reqWrapped := wrapperStopRequest{
|
|
||||||
StopRequest: req,
|
|
||||||
AsyncMode: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/stop"
|
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
return string(res), nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -69,16 +69,6 @@ type UpdateRequest struct {
|
|||||||
// The OS version that will be installed on the virtual machine
|
// The OS version that will be installed on the virtual machine
|
||||||
// Required: false
|
// Required: false
|
||||||
OSVersion string `url:"os_version,omitempty" json:"os_version,omitempty"`
|
OSVersion string `url:"os_version,omitempty" json:"os_version,omitempty"`
|
||||||
|
|
||||||
// Clock type for the VM
|
|
||||||
// Required: false
|
|
||||||
// Default: null
|
|
||||||
Clock string `url:"clock,omitempty" json:"clock,omitempty"`
|
|
||||||
|
|
||||||
// Watchdog action
|
|
||||||
// Required: false
|
|
||||||
// Default: reset
|
|
||||||
WatchdogAction string `url:"watchdog_action,omitempty" json:"watchdog_action,omitempty" validate:"omitempty,watchdogAction"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update updates some properties of the compute
|
// Update updates some properties of the compute
|
||||||
|
|||||||
@@ -39,13 +39,7 @@ type CreateRequest struct {
|
|||||||
Pool string `url:"pool,omitempty" json:"pool,omitempty"`
|
Pool string `url:"pool,omitempty" json:"pool,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type wrapperCreateRequest struct {
|
// Create creates a disk
|
||||||
CreateRequest
|
|
||||||
|
|
||||||
AsyncMode bool `url:"async_mode" json:"async_mode"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create creates a disk in sync mode
|
|
||||||
func (d Disks) Create(ctx context.Context, req CreateRequest) (uint64, error) {
|
func (d Disks) Create(ctx context.Context, req CreateRequest) (uint64, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -54,12 +48,7 @@ func (d Disks) Create(ctx context.Context, req CreateRequest) (uint64, error) {
|
|||||||
|
|
||||||
url := "/cloudapi/disks/create"
|
url := "/cloudapi/disks/create"
|
||||||
|
|
||||||
wrappedReq := wrapperCreateRequest{
|
res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
CreateRequest: req,
|
|
||||||
AsyncMode: false,
|
|
||||||
}
|
|
||||||
|
|
||||||
res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, wrappedReq)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
@@ -71,25 +60,3 @@ func (d Disks) Create(ctx context.Context, req CreateRequest) (uint64, error) {
|
|||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create creates a disk in async mode
|
|
||||||
func (d Disks) CreateAsync(ctx context.Context, req CreateRequest) (string, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/disks/create"
|
|
||||||
|
|
||||||
wrappedReq := wrapperCreateRequest{
|
|
||||||
CreateRequest: req,
|
|
||||||
AsyncMode: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, wrappedReq)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
return string(res), nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ var disks = ListDisks{
|
|||||||
Snapshots: []ItemSnapshot{},
|
Snapshots: []ItemSnapshot{},
|
||||||
Status: "ASSIGNED",
|
Status: "ASSIGNED",
|
||||||
TechStatus: techStatusAllocated,
|
TechStatus: techStatusAllocated,
|
||||||
|
Type: "B",
|
||||||
VMID: 48500,
|
VMID: 48500,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -91,6 +92,7 @@ var disks = ListDisks{
|
|||||||
Snapshots: []ItemSnapshot{},
|
Snapshots: []ItemSnapshot{},
|
||||||
Status: "ASSIGNED",
|
Status: "ASSIGNED",
|
||||||
TechStatus: techStatusAllocated,
|
TechStatus: techStatusAllocated,
|
||||||
|
Type: "B",
|
||||||
VMID: 48502,
|
VMID: 48502,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -222,6 +224,7 @@ var searchDisks = ListSearchDisks{
|
|||||||
Snapshots: []ItemSnapshot{},
|
Snapshots: []ItemSnapshot{},
|
||||||
Status: "ASSIGNED",
|
Status: "ASSIGNED",
|
||||||
TechStatus: techStatusAllocated,
|
TechStatus: techStatusAllocated,
|
||||||
|
Type: "B",
|
||||||
VMID: 48500,
|
VMID: 48500,
|
||||||
},
|
},
|
||||||
ItemDisk{
|
ItemDisk{
|
||||||
@@ -265,6 +268,7 @@ var searchDisks = ListSearchDisks{
|
|||||||
Snapshots: []ItemSnapshot{},
|
Snapshots: []ItemSnapshot{},
|
||||||
Status: "ASSIGNED",
|
Status: "ASSIGNED",
|
||||||
TechStatus: techStatusAllocated,
|
TechStatus: techStatusAllocated,
|
||||||
|
Type: "B",
|
||||||
VMID: 48502,
|
VMID: 48502,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@@ -356,6 +360,7 @@ func TestListSearchDisks_SortByCreatedTime(t *testing.T) {
|
|||||||
var unattachedDisks = ListDisksUnattached{
|
var unattachedDisks = ListDisksUnattached{
|
||||||
Data: []ItemDiskUnattached{
|
Data: []ItemDiskUnattached{
|
||||||
{
|
{
|
||||||
|
CKey: "",
|
||||||
Meta: []interface{}{
|
Meta: []interface{}{
|
||||||
"cloudbroker",
|
"cloudbroker",
|
||||||
"disk",
|
"disk",
|
||||||
@@ -403,9 +408,11 @@ var unattachedDisks = ListDisksUnattached{
|
|||||||
Snapshots: nil,
|
Snapshots: nil,
|
||||||
Status: "CREATED",
|
Status: "CREATED",
|
||||||
TechStatus: techStatusAllocated,
|
TechStatus: techStatusAllocated,
|
||||||
|
Type: "D",
|
||||||
VMID: 0,
|
VMID: 0,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
CKey: "",
|
||||||
Meta: []interface{}{
|
Meta: []interface{}{
|
||||||
"cloudbroker",
|
"cloudbroker",
|
||||||
"disk",
|
"disk",
|
||||||
@@ -456,6 +463,7 @@ var unattachedDisks = ListDisksUnattached{
|
|||||||
Snapshots: nil,
|
Snapshots: nil,
|
||||||
Status: "CREATED",
|
Status: "CREATED",
|
||||||
TechStatus: techStatusAllocated,
|
TechStatus: techStatusAllocated,
|
||||||
|
Type: "B",
|
||||||
VMID: 0,
|
VMID: 0,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ type ListRequest struct {
|
|||||||
|
|
||||||
// Find by status
|
// Find by status
|
||||||
// Required: false
|
// Required: false
|
||||||
Status []string `url:"status,omitempty" json:"status,omitempty"`
|
Status string `url:"status,omitempty" json:"status,omitempty"`
|
||||||
|
|
||||||
// Find by shared, true or false
|
// Find by shared, true or false
|
||||||
// Required: false
|
// Required: false
|
||||||
@@ -38,6 +38,10 @@ type ListRequest struct {
|
|||||||
// Required: false
|
// Required: false
|
||||||
AccountID uint64 `url:"accountId,omitempty" json:"accountId,omitempty"`
|
AccountID uint64 `url:"accountId,omitempty" json:"accountId,omitempty"`
|
||||||
|
|
||||||
|
// Type of the disks
|
||||||
|
// Required: false
|
||||||
|
Type string `url:"type,omitempty" json:"type,omitempty"`
|
||||||
|
|
||||||
// Find by sep ID
|
// Find by sep ID
|
||||||
// Required: false
|
// Required: false
|
||||||
SEPID uint64 `url:"sepId,omitempty" json:"sepId,omitempty"`
|
SEPID uint64 `url:"sepId,omitempty" json:"sepId,omitempty"`
|
||||||
@@ -61,14 +65,6 @@ type ListRequest struct {
|
|||||||
// Page size
|
// Page size
|
||||||
// Required: false
|
// Required: false
|
||||||
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
||||||
|
|
||||||
// ID of the resource group
|
|
||||||
// Required: false
|
|
||||||
RGID uint64 `url:"rg_id,omitempty" json:"rg_id,omitempty"`
|
|
||||||
|
|
||||||
// ID of the compute
|
|
||||||
// Required: false
|
|
||||||
ComputeID uint64 `url:"compute_id,omitempty" json:"compute_id,omitempty"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// List gets list of the created disks belonging to an account as a ListDisks struct
|
// List gets list of the created disks belonging to an account as a ListDisks struct
|
||||||
|
|||||||
@@ -34,6 +34,10 @@ type ListDeletedRequest struct {
|
|||||||
// Required: false
|
// Required: false
|
||||||
AccountID uint64 `url:"accountId,omitempty" json:"accountId,omitempty"`
|
AccountID uint64 `url:"accountId,omitempty" json:"accountId,omitempty"`
|
||||||
|
|
||||||
|
// Type of the disks
|
||||||
|
// Required: false
|
||||||
|
Type string `url:"type,omitempty" json:"type,omitempty"`
|
||||||
|
|
||||||
// Sort by one of supported fields, format +|-(field)
|
// Sort by one of supported fields, format +|-(field)
|
||||||
// Required: false
|
// Required: false
|
||||||
SortBy string `url:"sortBy,omitempty" json:"sortBy,omitempty" validate:"omitempty,sortBy"`
|
SortBy string `url:"sortBy,omitempty" json:"sortBy,omitempty" validate:"omitempty,sortBy"`
|
||||||
|
|||||||
52
pkg/cloudapi/disks/list_types.go
Normal file
52
pkg/cloudapi/disks/list_types.go
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
package disks
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"encoding/json"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ListTypesRequest struct to get list types of disks
|
||||||
|
type ListTypesRequest struct {
|
||||||
|
// Show detailed disk types by seps
|
||||||
|
// Required: true
|
||||||
|
Detailed bool `url:"detailed" json:"detailed"`
|
||||||
|
|
||||||
|
// 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"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListTypes gets list defined disk types
|
||||||
|
func (d Disks) ListTypes(ctx context.Context, req ListTypesRequest) (*ListTypes, error) {
|
||||||
|
|
||||||
|
if err := validators.ValidateRequest(req); err != nil {
|
||||||
|
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudapi/disks/listTypes"
|
||||||
|
|
||||||
|
res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
list := ListTypes{}
|
||||||
|
|
||||||
|
err = json.Unmarshal(res, &list)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return &list, nil
|
||||||
|
}
|
||||||
@@ -26,6 +26,10 @@ type ListUnattachedRequest struct {
|
|||||||
// Required: false
|
// Required: false
|
||||||
Status string `url:"status,omitempty" json:"status,omitempty"`
|
Status string `url:"status,omitempty" json:"status,omitempty"`
|
||||||
|
|
||||||
|
// Type of the disks
|
||||||
|
// Required: false
|
||||||
|
Type string `url:"type,omitempty" json:"type,omitempty"`
|
||||||
|
|
||||||
// ID of the account
|
// ID of the account
|
||||||
// Required: false
|
// Required: false
|
||||||
AccountID uint64 `url:"accountId,omitempty" json:"accountId,omitempty"`
|
AccountID uint64 `url:"accountId,omitempty" json:"accountId,omitempty"`
|
||||||
|
|||||||
@@ -11,18 +11,12 @@ type ItemDisk struct {
|
|||||||
// Account name
|
// Account name
|
||||||
AccountName string `json:"accountName"`
|
AccountName string `json:"accountName"`
|
||||||
|
|
||||||
// Discard
|
// BLK Discard
|
||||||
Discard string `json:"discard"`
|
BLKDiscard bool `json:"blkdiscard"`
|
||||||
|
|
||||||
// Block size of disk
|
|
||||||
BlockSize string `json:"block_size"`
|
|
||||||
|
|
||||||
// Computes
|
// Computes
|
||||||
Computes map[string]string `json:"computes"`
|
Computes map[string]string `json:"computes"`
|
||||||
|
|
||||||
// Computes read only
|
|
||||||
ComputesReadOnly map[string]bool `json:"computes_read_only"`
|
|
||||||
|
|
||||||
//Created by
|
//Created by
|
||||||
CreatedBy string `json:"createdBy"`
|
CreatedBy string `json:"createdBy"`
|
||||||
|
|
||||||
@@ -53,9 +47,6 @@ type ItemDisk struct {
|
|||||||
// Image ID
|
// Image ID
|
||||||
ImageID uint64 `json:"imageId"`
|
ImageID uint64 `json:"imageId"`
|
||||||
|
|
||||||
// Independent
|
|
||||||
Independent bool `json:"independent"`
|
|
||||||
|
|
||||||
// List of image IDs
|
// List of image IDs
|
||||||
Images []uint64 `json:"images"`
|
Images []uint64 `json:"images"`
|
||||||
|
|
||||||
@@ -92,9 +83,6 @@ type ItemDisk struct {
|
|||||||
// Present to
|
// Present to
|
||||||
PresentTo map[string]uint64 `json:"presentTo"`
|
PresentTo map[string]uint64 `json:"presentTo"`
|
||||||
|
|
||||||
// Provision
|
|
||||||
Provision string `json:"provision"`
|
|
||||||
|
|
||||||
// Purge time
|
// Purge time
|
||||||
PurgeTime uint64 `json:"purgeTime"`
|
PurgeTime uint64 `json:"purgeTime"`
|
||||||
|
|
||||||
@@ -143,6 +131,9 @@ type ItemDisk struct {
|
|||||||
// Need to clean before destroy
|
// Need to clean before destroy
|
||||||
ToClean bool `json:"to_clean"`
|
ToClean bool `json:"to_clean"`
|
||||||
|
|
||||||
|
// Type
|
||||||
|
Type string `json:"type"`
|
||||||
|
|
||||||
// Virtual machine ID
|
// Virtual machine ID
|
||||||
VMID uint64 `json:"vmid"`
|
VMID uint64 `json:"vmid"`
|
||||||
|
|
||||||
@@ -169,11 +160,8 @@ type ItemDiskUnattached struct {
|
|||||||
// Access Control List
|
// Access Control List
|
||||||
ACL map[string]interface{} `json:"acl"`
|
ACL map[string]interface{} `json:"acl"`
|
||||||
|
|
||||||
// Discard
|
// BLK Discard
|
||||||
Discard string `json:"discard"`
|
BLKDiscard bool `json:"blkdiscard"`
|
||||||
|
|
||||||
// Block size of disk
|
|
||||||
BlockSize string `json:"block_size"`
|
|
||||||
|
|
||||||
// Boot Partition
|
// Boot Partition
|
||||||
BootPartition uint64 `json:"bootPartition"`
|
BootPartition uint64 `json:"bootPartition"`
|
||||||
@@ -247,9 +235,6 @@ type ItemDiskUnattached struct {
|
|||||||
// Present to
|
// Present to
|
||||||
PresentTo map[string]uint64 `json:"presentTo"`
|
PresentTo map[string]uint64 `json:"presentTo"`
|
||||||
|
|
||||||
// Provision
|
|
||||||
Provision string `json:"provision"`
|
|
||||||
|
|
||||||
// Purge attempts
|
// Purge attempts
|
||||||
PurgeAttempts uint64 `json:"purgeAttempts"`
|
PurgeAttempts uint64 `json:"purgeAttempts"`
|
||||||
|
|
||||||
@@ -292,11 +277,8 @@ type ItemDiskUnattached struct {
|
|||||||
// Tech status
|
// Tech status
|
||||||
TechStatus string `json:"techStatus"`
|
TechStatus string `json:"techStatus"`
|
||||||
|
|
||||||
// Need to clean before destroy
|
// Type
|
||||||
ToClean bool `json:"to_clean"`
|
Type string `json:"type"`
|
||||||
|
|
||||||
// ID of the Storage Policy
|
|
||||||
StoragePolicyID uint64 `json:"storage_policy_id"`
|
|
||||||
|
|
||||||
// Virtual machine ID
|
// Virtual machine ID
|
||||||
VMID uint64 `json:"vmid"`
|
VMID uint64 `json:"vmid"`
|
||||||
@@ -331,10 +313,6 @@ type ItemSnapshot struct {
|
|||||||
// Label
|
// Label
|
||||||
Label string `json:"label"`
|
Label string `json:"label"`
|
||||||
|
|
||||||
// Pool name
|
|
||||||
PoolName string `json:"poolName"`
|
|
||||||
|
|
||||||
// Reference ID
|
|
||||||
ReferenceID string `json:"referenceId"`
|
ReferenceID string `json:"referenceId"`
|
||||||
|
|
||||||
// Resource ID
|
// Resource ID
|
||||||
@@ -406,18 +384,12 @@ type RecordDisk struct {
|
|||||||
// Account name
|
// Account name
|
||||||
AccountName string `json:"accountName"`
|
AccountName string `json:"accountName"`
|
||||||
|
|
||||||
// Discard
|
// BLK Discard
|
||||||
Discard string `json:"discard"`
|
BLKDiscard bool `json:"blkdiscard"`
|
||||||
|
|
||||||
// Block size of disk
|
|
||||||
BlockSize string `json:"block_size"`
|
|
||||||
|
|
||||||
// Computes
|
// Computes
|
||||||
Computes map[string]string `json:"computes"`
|
Computes map[string]string `json:"computes"`
|
||||||
|
|
||||||
// Computes read only
|
|
||||||
ComputesReadOnly map[string]bool `json:"computes_read_only"`
|
|
||||||
|
|
||||||
// Created by
|
// Created by
|
||||||
CreatedBy string `json:"createdBy"`
|
CreatedBy string `json:"createdBy"`
|
||||||
|
|
||||||
@@ -448,9 +420,6 @@ type RecordDisk struct {
|
|||||||
// Image ID
|
// Image ID
|
||||||
ImageID uint64 `json:"imageId"`
|
ImageID uint64 `json:"imageId"`
|
||||||
|
|
||||||
// Independent
|
|
||||||
Independent bool `json:"independent"`
|
|
||||||
|
|
||||||
// List of image IDs
|
// List of image IDs
|
||||||
Images []uint64 `json:"images"`
|
Images []uint64 `json:"images"`
|
||||||
|
|
||||||
@@ -487,9 +456,6 @@ type RecordDisk struct {
|
|||||||
// Present to
|
// Present to
|
||||||
PresentTo map[string]uint64 `json:"presentTo"`
|
PresentTo map[string]uint64 `json:"presentTo"`
|
||||||
|
|
||||||
// Provision
|
|
||||||
Provision string `json:"provision"`
|
|
||||||
|
|
||||||
// Purge time
|
// Purge time
|
||||||
PurgeTime uint64 `json:"purgeTime"`
|
PurgeTime uint64 `json:"purgeTime"`
|
||||||
|
|
||||||
@@ -538,6 +504,9 @@ type RecordDisk struct {
|
|||||||
// Need to clean before destroy
|
// Need to clean before destroy
|
||||||
ToClean bool `json:"to_clean"`
|
ToClean bool `json:"to_clean"`
|
||||||
|
|
||||||
|
// Type
|
||||||
|
Type string `json:"type"`
|
||||||
|
|
||||||
// Virtual machine ID
|
// Virtual machine ID
|
||||||
VMID uint64 `json:"vmid"`
|
VMID uint64 `json:"vmid"`
|
||||||
|
|
||||||
@@ -570,3 +539,11 @@ type ItemReplication struct {
|
|||||||
// VolumeID
|
// VolumeID
|
||||||
VolumeID string `json:"volumeId"`
|
VolumeID string `json:"volumeId"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type ListTypes struct {
|
||||||
|
// Data
|
||||||
|
Data []interface{} `json:"data"`
|
||||||
|
|
||||||
|
// Entry count
|
||||||
|
EntryCount uint64 `json:"entryCount"`
|
||||||
|
}
|
||||||
|
|||||||
@@ -13,9 +13,6 @@ type ItemExtNet struct {
|
|||||||
|
|
||||||
// Status
|
// Status
|
||||||
Status string `json:"status"`
|
Status string `json:"status"`
|
||||||
|
|
||||||
// Free IPs
|
|
||||||
FreeIPs uint64 `json:"freeIps"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Extend information about external network
|
// Extend information about external network
|
||||||
|
|||||||
@@ -19,8 +19,9 @@ type CreateVirtualRequest struct {
|
|||||||
TargetID uint64 `url:"targetId" json:"targetId" validate:"required"`
|
TargetID uint64 `url:"targetId" json:"targetId" validate:"required"`
|
||||||
|
|
||||||
// AccountID to make the virtual image exclusive
|
// AccountID to make the virtual image exclusive
|
||||||
// Required: true
|
// Required: false
|
||||||
AccountID uint64 `url:"accountId" json:"accountId" validate:"required"`
|
// Default: 0
|
||||||
|
AccountID uint64 `url:"accountId,omitempty" json:"accountId,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreateVirtual creates virtual image
|
// CreateVirtual creates virtual image
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"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/internal/validators"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -29,7 +28,7 @@ type ListRequest struct {
|
|||||||
|
|
||||||
// Find by type
|
// Find by type
|
||||||
// Required: false
|
// Required: false
|
||||||
TypeImage []string `url:"typeImage,omitempty" json:"typeImage,omitempty"`
|
TypeImage string `url:"typeImage,omitempty" json:"typeImage,omitempty"`
|
||||||
|
|
||||||
// Find by image size
|
// Find by image size
|
||||||
// Required: false
|
// Required: false
|
||||||
@@ -103,6 +102,6 @@ func (i Image) ListRaw(ctx context.Context, req ListRequest) ([]byte, error) {
|
|||||||
|
|
||||||
url := "/cloudapi/image/list"
|
url := "/cloudapi/image/list"
|
||||||
|
|
||||||
res, err := i.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
|
res, err := i.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -140,18 +140,12 @@ type RecordImage struct {
|
|||||||
// ID
|
// ID
|
||||||
ID uint64 `json:"id"`
|
ID uint64 `json:"id"`
|
||||||
|
|
||||||
// Independent
|
|
||||||
Independent bool `json:"independent"`
|
|
||||||
|
|
||||||
// Last modified
|
// Last modified
|
||||||
LastModified uint64 `json:"lastModified"`
|
LastModified uint64 `json:"lastModified"`
|
||||||
|
|
||||||
// Link to
|
// Link to
|
||||||
LinkTo uint64 `json:"linkTo"`
|
LinkTo uint64 `json:"linkTo"`
|
||||||
|
|
||||||
// Links to
|
|
||||||
LinksTo []uint64 `json:"linksTo"`
|
|
||||||
|
|
||||||
// Milestones
|
// Milestones
|
||||||
Milestones uint64 `json:"milestones"`
|
Milestones uint64 `json:"milestones"`
|
||||||
|
|
||||||
|
|||||||
@@ -157,7 +157,7 @@ type CreateRequest struct {
|
|||||||
|
|
||||||
// Meta data for working group computes, format YAML "user_data": 1111
|
// Meta data for working group computes, format YAML "user_data": 1111
|
||||||
// Required: false
|
// Required: false
|
||||||
UserData interface{} `url:"userData,omitempty" json:"userData,omitempty"`
|
UserData string `url:"userData,omitempty" json:"userData,omitempty"`
|
||||||
|
|
||||||
// Use only selected ExtNet for infrastructure connections
|
// Use only selected ExtNet for infrastructure connections
|
||||||
// Required: false
|
// Required: false
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ type UpdateWorkerNodesMetaDataRequest struct {
|
|||||||
|
|
||||||
// Meta data for working group computes, format YAML "user_data": 1111
|
// Meta data for working group computes, format YAML "user_data": 1111
|
||||||
// Required: true
|
// Required: true
|
||||||
UserData interface{} `url:"userData" json:"userData" validate:"required"`
|
UserData string `url:"userData" json:"userData" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// UpdateWorkerNodesMetaData adds worker nodes to a kubernetes cluster
|
// UpdateWorkerNodesMetaData adds worker nodes to a kubernetes cluster
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"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/internal/validators"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -31,8 +30,8 @@ type Interface struct {
|
|||||||
// Required: false
|
// Required: false
|
||||||
IPAddr string `url:"ipAddr,omitempty" json:"ipAddr,omitempty"`
|
IPAddr string `url:"ipAddr,omitempty" json:"ipAddr,omitempty"`
|
||||||
|
|
||||||
// Used for EXTNET, TRUNK and DPDK
|
// Maximum transmission unit, must be 1-9216
|
||||||
// Must be 1500-9216
|
// Used only to DPDK net type
|
||||||
// Required: false
|
// Required: false
|
||||||
MTU uint64 `url:"mtu,omitempty" json:"mtu,omitempty" validate:"omitempty,mtu"`
|
MTU uint64 `url:"mtu,omitempty" json:"mtu,omitempty" validate:"omitempty,mtu"`
|
||||||
|
|
||||||
@@ -49,9 +48,9 @@ type Interface struct {
|
|||||||
// Required: false
|
// Required: false
|
||||||
SDNSegmentID string `url:"sdn_segment_id,omitempty" json:"sdn_segment_id,omitempty"`
|
SDNSegmentID string `url:"sdn_segment_id,omitempty" json:"sdn_segment_id,omitempty"`
|
||||||
|
|
||||||
// SDN Object Group IDs
|
// SDN Object Group ID
|
||||||
// Required: false
|
// Required: false
|
||||||
SDNObjectGroupIDs []string `url:"sdn_object_group_ids,omitempty" json:"sdn_object_group_ids,omitempty"`
|
SDNObjectGroupID string `url:"sdn_object_group_id,omitempty" json:"sdn_object_group_id,omitempty"`
|
||||||
|
|
||||||
// SDN Logical Port Display Name
|
// SDN Logical Port Display Name
|
||||||
// Required: false
|
// Required: false
|
||||||
@@ -70,22 +69,12 @@ type Interface struct {
|
|||||||
SecGroups []uint64 `url:"security_groups,omitempty" json:"security_groups,omitempty"`
|
SecGroups []uint64 `url:"security_groups,omitempty" json:"security_groups,omitempty"`
|
||||||
|
|
||||||
// Flag indicating whether security groups are enabled for this interface
|
// Flag indicating whether security groups are enabled for this interface
|
||||||
// Not applicable to netType VFNIC, TRUNK, or SDN
|
|
||||||
// Required: false
|
// Required: false
|
||||||
EnableSecGroups bool `url:"enable_secgroups,omitempty" json:"enable_secgroups,omitempty"`
|
EnableSecGroups bool `url:"enable_secgroups,omitempty" json:"enable_secgroups,omitempty"`
|
||||||
|
|
||||||
// Flag indicating whether this interface is enabled (only for VINS, EXTNET, DPDK, SDN, TRUNK)
|
// Flag indicating whether this interface is enabled (only for VINS, EXTNET, DPDK, SDN, TRUNK)
|
||||||
// Required: false
|
// Required: false
|
||||||
Enabled interface{} `url:"enabled,omitempty" json:"enabled,omitempty" validate:"omitempty,isBool"`
|
Enabled interface{} `url:"enabled,omitempty" json:"enabled,omitempty" validate:"omitempty,isBool"`
|
||||||
|
|
||||||
// Flag indicating whether default gateway are enabled for this interface, not applicable to netType EXTNET, VFNIC, TRUNK, or SDN
|
|
||||||
// Default: true
|
|
||||||
// Required: false
|
|
||||||
EnableDefaultGateway interface{} `url:"enable_default_gateway,omitempty" json:"enable_default_gateway,omitempty" validate:"omitempty,isBool"`
|
|
||||||
|
|
||||||
// List of QoS Policy IDs to apply to this interface (default: []), Allow used only with netType VINS, EXTNET and DPDK
|
|
||||||
// Required: false
|
|
||||||
QoSPolicies []uint64 `url:"qos_policies,omitempty" json:"qos_policies,omitempty"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// DataDisk detailed struct for DataDisks field in CreateRequest and CreateBlankRequest
|
// DataDisk detailed struct for DataDisks field in CreateRequest and CreateBlankRequest
|
||||||
@@ -119,11 +108,6 @@ type DataDisk struct {
|
|||||||
// Specify image id for create disk from template
|
// Specify image id for create disk from template
|
||||||
// Required: false
|
// Required: false
|
||||||
ImageID uint64 `url:"imageId,omitempty" json:"imageId,omitempty"`
|
ImageID uint64 `url:"imageId,omitempty" json:"imageId,omitempty"`
|
||||||
|
|
||||||
// Attach disk in read-only mode
|
|
||||||
// Required: false
|
|
||||||
// Default: false
|
|
||||||
ReadOnly bool `url:"read_only,omitempty" json:"read_only,omitempty"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreateRequest struct to create KVM x86 VM
|
// CreateRequest struct to create KVM x86 VM
|
||||||
@@ -199,6 +183,14 @@ type CreateRequest struct {
|
|||||||
// Required: false
|
// Required: false
|
||||||
Start bool `url:"start" json:"start"`
|
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"`
|
||||||
|
|
||||||
// Custom fields for compute. Must be a dict
|
// Custom fields for compute. Must be a dict
|
||||||
// Required: false
|
// Required: false
|
||||||
CustomFields string `url:"customFields,omitempty" json:"customFields,omitempty"`
|
CustomFields string `url:"customFields,omitempty" json:"customFields,omitempty"`
|
||||||
@@ -209,12 +201,12 @@ type CreateRequest struct {
|
|||||||
// loose (use NUMA affinity if possible)
|
// loose (use NUMA affinity if possible)
|
||||||
// Required: false
|
// Required: false
|
||||||
// Default: none
|
// Default: none
|
||||||
NumaAffinity string `url:"numa_affinity,omitempty" json:"numa_affinity,omitempty" validate:"omitempty,numaAffinity"`
|
NumaAffinity string `url:"numaAffinity,omitempty" json:"numaAffinity,omitempty" validate:"omitempty,numaAffinity"`
|
||||||
|
|
||||||
// Run VM on dedicated CPUs. To use this feature, the system must be pre-configured by allocating CPUs on the physical node
|
// Run VM on dedicated CPUs. To use this feature, the system must be pre-configured by allocating CPUs on the physical node
|
||||||
// Required: false
|
// Required: false
|
||||||
// Default: false
|
// Default: false
|
||||||
CPUPin bool `url:"cpu_pin" json:"cpu_pin"`
|
CPUPin bool `url:"cpupin" json:"cpupin"`
|
||||||
|
|
||||||
// Type of the emulated system, Q35 or i440fx
|
// Type of the emulated system, Q35 or i440fx
|
||||||
// Required: false
|
// Required: false
|
||||||
@@ -224,7 +216,7 @@ type CreateRequest struct {
|
|||||||
// Use Huge Pages to allocate RAM of the virtual machine. The system must be pre-configured by allocating Huge Pages on the physical node
|
// Use Huge Pages to allocate RAM of the virtual machine. The system must be pre-configured by allocating Huge Pages on the physical node
|
||||||
// Required: false
|
// Required: false
|
||||||
// Default: false
|
// Default: false
|
||||||
HPBacked bool `url:"hp_backed" json:"hp_backed"`
|
HPBacked bool `url:"hpBacked" json:"hpBacked"`
|
||||||
|
|
||||||
// Recommended isolated CPUs. Field is ignored if compute.cpupin=False or compute.pinned=False
|
// Recommended isolated CPUs. Field is ignored if compute.cpupin=False or compute.pinned=False
|
||||||
// Required: false
|
// Required: false
|
||||||
@@ -233,24 +225,11 @@ type CreateRequest struct {
|
|||||||
// Zone ID
|
// Zone ID
|
||||||
// Required: false
|
// Required: false
|
||||||
ZoneID uint64 `url:"zoneId,omitempty" json:"zoneId,omitempty"`
|
ZoneID uint64 `url:"zoneId,omitempty" json:"zoneId,omitempty"`
|
||||||
|
|
||||||
// CPU alignment profile name
|
|
||||||
// Required: false
|
|
||||||
CPUAlignmentProfile string `url:"cpu_alignment_profile,omitempty" json:"cpu_alignment_profile,omitempty"`
|
|
||||||
|
|
||||||
// Clock type for the VM
|
|
||||||
// Required: false
|
|
||||||
// Default: default
|
|
||||||
Clock string `url:"clock,omitempty" json:"clock,omitempty"`
|
|
||||||
|
|
||||||
// Watchdog action
|
|
||||||
// Required: false
|
|
||||||
// Default: reset
|
|
||||||
WatchdogAction string `url:"watchdog_action,omitempty" json:"watchdog_action,omitempty" validate:"omitempty,watchdogAction"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetRAM returns RAM field values
|
// GetRAM returns RAM field values
|
||||||
func (r CreateRequest) GetRAM() map[string]uint64 {
|
func (r CreateRequest) GetRAM() map[string]uint64 {
|
||||||
|
|
||||||
res := make(map[string]uint64, 1)
|
res := make(map[string]uint64, 1)
|
||||||
|
|
||||||
res["RAM"] = r.RAM
|
res["RAM"] = r.RAM
|
||||||
@@ -260,7 +239,8 @@ func (r CreateRequest) GetRAM() map[string]uint64 {
|
|||||||
|
|
||||||
type wrapperCreateRequest struct {
|
type wrapperCreateRequest struct {
|
||||||
CreateRequest
|
CreateRequest
|
||||||
AsyncMode bool `json:"asyncMode"`
|
Interfaces []string `url:"interfaces,omitempty"`
|
||||||
|
DataDisks []string `url:"dataDisks,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create creates KVM x86 VM based on specified OS image
|
// Create creates KVM x86 VM based on specified OS image
|
||||||
@@ -270,42 +250,55 @@ func (k KVMX86) Create(ctx context.Context, req CreateRequest) (uint64, error) {
|
|||||||
return 0, validators.ValidationErrors(validators.GetErrors(err))
|
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/kvmx86/create"
|
url := "/cloudapi/kvmx86/create"
|
||||||
|
|
||||||
res, err := k.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, wrapperCreateRequest{
|
res, err := k.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
||||||
CreateRequest: req,
|
|
||||||
AsyncMode: false,
|
|
||||||
})
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return strconv.ParseUint(string(res), 10, 64)
|
result, err := strconv.ParseUint(string(res), 10, 64)
|
||||||
}
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
// CreateAsync creates KVM x86 VM based on specified OS image in async mode
|
}
|
||||||
func (k KVMX86) CreateAsync(ctx context.Context, req CreateRequest) (string, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
return result, nil
|
||||||
if err != nil {
|
|
||||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/kvmx86/create"
|
|
||||||
|
|
||||||
res, err := k.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, wrapperCreateRequest{
|
|
||||||
CreateRequest: req,
|
|
||||||
AsyncMode: true,
|
|
||||||
})
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
var taskID string
|
|
||||||
|
|
||||||
err = json.Unmarshal(res, &taskID)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
return taskID, nil
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,10 +2,10 @@ package kvmx86
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"encoding/json"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"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/internal/validators"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -115,20 +115,6 @@ type CreateBlankRequest struct {
|
|||||||
// The OS version that will be installed on the virtual machine
|
// The OS version that will be installed on the virtual machine
|
||||||
// Required: false
|
// Required: false
|
||||||
OSVersion string `url:"os_version,omitempty" json:"os_version,omitempty"`
|
OSVersion string `url:"os_version,omitempty" json:"os_version,omitempty"`
|
||||||
|
|
||||||
// CPU alignment profile name
|
|
||||||
// Required: false
|
|
||||||
CPUAlignmentProfile string `url:"cpu_alignment_profile,omitempty" json:"cpu_alignment_profile,omitempty"`
|
|
||||||
|
|
||||||
// Clock type for the VM
|
|
||||||
// Required: false
|
|
||||||
// Default: default
|
|
||||||
Clock string `url:"clock,omitempty" json:"clock,omitempty"`
|
|
||||||
|
|
||||||
// Watchdog action
|
|
||||||
// Required: false
|
|
||||||
// Default: reset
|
|
||||||
WatchdogAction string `url:"watchdog_action,omitempty" json:"watchdog_action,omitempty" validate:"omitempty,watchdogAction"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetRAM returns RAM field values
|
// GetRAM returns RAM field values
|
||||||
@@ -141,6 +127,12 @@ func (r CreateBlankRequest) GetRAM() map[string]uint64 {
|
|||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type wrapperCreateBlankRequest struct {
|
||||||
|
CreateBlankRequest
|
||||||
|
Interfaces []string `url:"interfaces,omitempty"`
|
||||||
|
DataDisks []string `url:"dataDisks,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
// CreateBlank creates KVM x86 VM from scratch
|
// CreateBlank creates KVM x86 VM from scratch
|
||||||
func (k KVMX86) CreateBlank(ctx context.Context, req CreateBlankRequest) (uint64, error) {
|
func (k KVMX86) CreateBlank(ctx context.Context, req CreateBlankRequest) (uint64, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
@@ -148,12 +140,55 @@ func (k KVMX86) CreateBlank(ctx context.Context, req CreateBlankRequest) (uint64
|
|||||||
return 0, validators.ValidationErrors(validators.GetErrors(err))
|
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/kvmx86/createBlank"
|
url := "/cloudapi/kvmx86/createBlank"
|
||||||
|
|
||||||
res, err := k.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
|
res, err := k.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return strconv.ParseUint(string(res), 10, 64)
|
result, err := strconv.ParseUint(string(res), 10, 64)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,22 +16,22 @@ type HighlyAvailableRequest struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// HighlyAvailable makes load balancer highly available
|
// HighlyAvailable makes load balancer highly available
|
||||||
func (l LB) HighlyAvailable(ctx context.Context, req HighlyAvailableRequest) (bool, error) {
|
func (l LB) HighlyAvailable(ctx context.Context, req HighlyAvailableRequest) (uint64, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
return 0, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
url := "/cloudapi/lb/makeHighlyAvailable"
|
url := "/cloudapi/lb/makeHighlyAvailable"
|
||||||
|
|
||||||
res, err := l.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
res, err := l.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
|
||||||
result, err := strconv.ParseBool(string(res))
|
result, err := strconv.ParseUint(string(res), 10, 64)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
|
|||||||
@@ -5,9 +5,6 @@ type ItemLocation struct {
|
|||||||
// AuthBroker
|
// AuthBroker
|
||||||
AuthBroker []string `json:"authBroker"`
|
AuthBroker []string `json:"authBroker"`
|
||||||
|
|
||||||
// Budget
|
|
||||||
Budget bool `json:"budget"`
|
|
||||||
|
|
||||||
// Grid ID
|
// Grid ID
|
||||||
GID uint64 `json:"gid"`
|
GID uint64 `json:"gid"`
|
||||||
|
|
||||||
@@ -37,12 +34,6 @@ type ItemLocation struct {
|
|||||||
|
|
||||||
// Support of SDN
|
// Support of SDN
|
||||||
SDNSupport bool `json:"sdn_support"`
|
SDNSupport bool `json:"sdn_support"`
|
||||||
|
|
||||||
// Is Zero Access enabled
|
|
||||||
ZeroAccessEnabled bool `json:"zeroaccess_enabled"`
|
|
||||||
|
|
||||||
// Is BRO enabled
|
|
||||||
BROEnabled bool `json:"bro_enabled"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// List of locations
|
// List of locations
|
||||||
|
|||||||
@@ -1,10 +0,0 @@
|
|||||||
package cloudapi
|
|
||||||
|
|
||||||
import (
|
|
||||||
qospolicy "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/qospolicy"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Accessing the QoS Policy method group
|
|
||||||
func (ca *CloudAPI) QoSPolicy() *qospolicy.QoSPolicy {
|
|
||||||
return qospolicy.New(ca.client)
|
|
||||||
}
|
|
||||||
@@ -1,46 +0,0 @@
|
|||||||
package qospolicy
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"net/http"
|
|
||||||
"strconv"
|
|
||||||
|
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants"
|
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
|
||||||
)
|
|
||||||
|
|
||||||
type CreateRequest struct {
|
|
||||||
// Account ID that owns QoS policy
|
|
||||||
// Required: true
|
|
||||||
AccountID uint64 `url:"account_id" json:"account_id" validate:"required"`
|
|
||||||
|
|
||||||
// QoS policy name
|
|
||||||
// Required: true
|
|
||||||
Name string `url:"name" json:"name" validate:"required"`
|
|
||||||
|
|
||||||
// QoS policy description
|
|
||||||
// Required: false
|
|
||||||
Description string `url:"description,omitempty" json:"description,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create creates a new QoS policy
|
|
||||||
func (qp QoSPolicy) Create(ctx context.Context, req CreateRequest) (uint64, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return 0, validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/network_qos_policy/create"
|
|
||||||
|
|
||||||
res, err := qp.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
|
|
||||||
if err != nil {
|
|
||||||
return 0, err
|
|
||||||
}
|
|
||||||
|
|
||||||
result, err := strconv.ParseUint(string(res), 10, 64)
|
|
||||||
if err != nil {
|
|
||||||
return 0, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return result, nil
|
|
||||||
}
|
|
||||||
@@ -1,93 +0,0 @@
|
|||||||
package qospolicy
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"net/http"
|
|
||||||
"strconv"
|
|
||||||
|
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants"
|
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
|
||||||
)
|
|
||||||
|
|
||||||
type CreateRuleRequest struct {
|
|
||||||
// ID of the parent QoS policy this rule belongs to
|
|
||||||
// Required: true
|
|
||||||
QoSPolicyID uint64 `url:"qos_policy_id" json:"qos_policy_id" validate:"required"`
|
|
||||||
|
|
||||||
// QoS policy rule description
|
|
||||||
// Default: ""
|
|
||||||
// Required: false
|
|
||||||
Description string `url:"description,omitempty" json:"description,omitempty"`
|
|
||||||
|
|
||||||
// Rule priority in OVS (higher number = higher priority)
|
|
||||||
// Possible values: [0, 65535]
|
|
||||||
// Required: true
|
|
||||||
Priority *uint64 `url:"priority" json:"priority" validate:"required,min=0,max=65535"`
|
|
||||||
|
|
||||||
// Traffic direction
|
|
||||||
// Required: true
|
|
||||||
Direction string `url:"direction" json:"direction" validate:"required,oneof=outbound"`
|
|
||||||
|
|
||||||
// IP protocol to match
|
|
||||||
// Possible values: tcp, udp, icmp
|
|
||||||
// Required: true
|
|
||||||
Protocol string `url:"protocol" json:"protocol" validate:"required,oneof=tcp udp icmp"`
|
|
||||||
|
|
||||||
// Priority Code Point. L2 marking
|
|
||||||
// Possible values: [0, 7]
|
|
||||||
// Required: false
|
|
||||||
PCPTag *uint64 `url:"pcp_tag,omitempty" json:"pcp_tag,omitempty" validate:"required_without_all=DSCPValue,omitempty,min=0,max=7"`
|
|
||||||
|
|
||||||
// DSCP value (0-63). L3 marking
|
|
||||||
// Possible values: [0, 63]
|
|
||||||
// Required: false
|
|
||||||
DSCPValue *uint64 `url:"dscp_value,omitempty" json:"dscp_value,omitempty" validate:"required_without_all=PCPTag,omitempty,min=0,max=63"`
|
|
||||||
|
|
||||||
// Source IP address for traffic filtering
|
|
||||||
// Required: false
|
|
||||||
SrcIP string `url:"src_ip,omitempty" json:"src_ip,omitempty"`
|
|
||||||
|
|
||||||
// Destination IP address for traffic filtering
|
|
||||||
// Required: false
|
|
||||||
DstIP string `url:"dst_ip,omitempty" json:"dst_ip,omitempty"`
|
|
||||||
|
|
||||||
// Source MAC address for traffic filtering
|
|
||||||
// Required: false
|
|
||||||
SrcMAC string `url:"src_mac,omitempty" json:"src_mac,omitempty" validate:"omitempty,mac"`
|
|
||||||
|
|
||||||
// Destination MAC address for traffic filtering
|
|
||||||
// Required: false
|
|
||||||
DstMAC string `url:"dst_mac,omitempty" json:"dst_mac,omitempty" validate:"omitempty,mac"`
|
|
||||||
|
|
||||||
// Source port for traffic filtering (TCP/UDP only)
|
|
||||||
// Possible values: [1, 65535]
|
|
||||||
// Required: false
|
|
||||||
SrcPort uint64 `url:"src_port,omitempty" json:"src_port,omitempty" validate:"omitempty,min=1,max=65535"`
|
|
||||||
|
|
||||||
// Destination port for traffic filtering (TCP/UDP only)
|
|
||||||
// Possible values: [1, 65535]
|
|
||||||
// Required: false
|
|
||||||
DstPort uint64 `url:"dst_port,omitempty" json:"dst_port,omitempty" validate:"omitempty,min=1,max=65535"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// CreateRule creates a new rule for a QoS policy
|
|
||||||
func (qp QoSPolicy) CreateRule(ctx context.Context, req CreateRuleRequest) (uint64, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return 0, validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/network_qos_policy/create_rule"
|
|
||||||
|
|
||||||
res, err := qp.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
|
|
||||||
if err != nil {
|
|
||||||
return 0, err
|
|
||||||
}
|
|
||||||
|
|
||||||
result, err := strconv.ParseUint(string(res), 10, 64)
|
|
||||||
if err != nil {
|
|
||||||
return 0, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return result, nil
|
|
||||||
}
|
|
||||||
@@ -1,37 +0,0 @@
|
|||||||
package qospolicy
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"net/http"
|
|
||||||
"strconv"
|
|
||||||
|
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants"
|
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
|
||||||
)
|
|
||||||
|
|
||||||
type DeleteRequest struct {
|
|
||||||
// QoS policy ID
|
|
||||||
// Required: true
|
|
||||||
QoSPolicyID uint64 `url:"qos_policy_id" json:"qos_policy_id" validate:"required"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func (qp QoSPolicy) Delete(ctx context.Context, req DeleteRequest) (bool, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/network_qos_policy/delete"
|
|
||||||
|
|
||||||
res, err := qp.client.DecortApiCallCtype(ctx, http.MethodDelete, url, constants.MIMEJSON, req)
|
|
||||||
if err != nil {
|
|
||||||
return false, err
|
|
||||||
}
|
|
||||||
|
|
||||||
result, err := strconv.ParseBool(string(res))
|
|
||||||
if err != nil {
|
|
||||||
return false, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return result, nil
|
|
||||||
}
|
|
||||||
@@ -1,41 +0,0 @@
|
|||||||
package qospolicy
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"net/http"
|
|
||||||
"strconv"
|
|
||||||
|
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants"
|
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
|
||||||
)
|
|
||||||
|
|
||||||
type DeleteRuleRequest struct {
|
|
||||||
// ID of the QoS policy
|
|
||||||
// Required: true
|
|
||||||
QoSPolicyID uint64 `url:"qos_policy_id" json:"qos_policy_id" validate:"required"`
|
|
||||||
|
|
||||||
// ID of the rule to delete
|
|
||||||
// Required: true
|
|
||||||
RuleID uint64 `url:"rule_id" json:"rule_id" validate:"required"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func (qp QoSPolicy) DeleteRule(ctx context.Context, req DeleteRuleRequest) (bool, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/network_qos_policy/delete_rule"
|
|
||||||
|
|
||||||
res, err := qp.client.DecortApiCallCtype(ctx, http.MethodDelete, url, constants.MIMEJSON, req)
|
|
||||||
if err != nil {
|
|
||||||
return false, err
|
|
||||||
}
|
|
||||||
|
|
||||||
result, err := strconv.ParseBool(string(res))
|
|
||||||
if err != nil {
|
|
||||||
return false, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return result, nil
|
|
||||||
}
|
|
||||||
@@ -1,89 +0,0 @@
|
|||||||
package qospolicy
|
|
||||||
|
|
||||||
// FilterByID returns ListQoSPolicies with specified ID
|
|
||||||
func (lqp ListQoSPolicies) FilterByID(id uint64) ListQoSPolicies {
|
|
||||||
predicate := func(iqp ItemQoSPolicy) bool {
|
|
||||||
return iqp.ID == id
|
|
||||||
}
|
|
||||||
|
|
||||||
return lqp.FilterFunc(predicate)
|
|
||||||
}
|
|
||||||
|
|
||||||
// FilterByName returns ListQoSPolicies with specified Name
|
|
||||||
func (lqp ListQoSPolicies) FilterByName(name string) ListQoSPolicies {
|
|
||||||
predicate := func(iqp ItemQoSPolicy) bool {
|
|
||||||
return iqp.Name == name
|
|
||||||
}
|
|
||||||
|
|
||||||
return lqp.FilterFunc(predicate)
|
|
||||||
}
|
|
||||||
|
|
||||||
// FilterByAccountID returns ListQoSPolicies with specified AccountID
|
|
||||||
func (lqp ListQoSPolicies) FilterByAccountID(accountID uint64) ListQoSPolicies {
|
|
||||||
predicate := func(iqp ItemQoSPolicy) bool {
|
|
||||||
return iqp.AccountID == accountID
|
|
||||||
}
|
|
||||||
|
|
||||||
return lqp.FilterFunc(predicate)
|
|
||||||
}
|
|
||||||
|
|
||||||
// FilterByStatus returns ListQoSPolicies with specified Status
|
|
||||||
func (lqp ListQoSPolicies) FilterByStatus(status string) ListQoSPolicies {
|
|
||||||
predicate := func(iqp ItemQoSPolicy) bool {
|
|
||||||
return iqp.Status == status
|
|
||||||
}
|
|
||||||
|
|
||||||
return lqp.FilterFunc(predicate)
|
|
||||||
}
|
|
||||||
|
|
||||||
// FilterByDescription returns ListQoSPolicies with specified Description
|
|
||||||
func (lqp ListQoSPolicies) FilterByDescription(description string) ListQoSPolicies {
|
|
||||||
predicate := func(iqp ItemQoSPolicy) bool {
|
|
||||||
return iqp.Description == description
|
|
||||||
}
|
|
||||||
|
|
||||||
return lqp.FilterFunc(predicate)
|
|
||||||
}
|
|
||||||
|
|
||||||
// FilterByCreatedBy returns ListQoSPolicies with specified CreatedBy
|
|
||||||
func (lqp ListQoSPolicies) FilterByCreatedBy(createdBy string) ListQoSPolicies {
|
|
||||||
predicate := func(iqp ItemQoSPolicy) bool {
|
|
||||||
return iqp.CreatedBy == createdBy
|
|
||||||
}
|
|
||||||
|
|
||||||
return lqp.FilterFunc(predicate)
|
|
||||||
}
|
|
||||||
|
|
||||||
// FilterByUpdatedBy returns ListQoSPolicies with specified UpdatedBy
|
|
||||||
func (lqp ListQoSPolicies) FilterByUpdatedBy(updatedBy string) ListQoSPolicies {
|
|
||||||
predicate := func(iqp ItemQoSPolicy) bool {
|
|
||||||
return iqp.UpdatedBy == updatedBy
|
|
||||||
}
|
|
||||||
|
|
||||||
return lqp.FilterFunc(predicate)
|
|
||||||
}
|
|
||||||
|
|
||||||
// FilterFunc allows filtering ListQoSPolicies based on a user-specified predicate
|
|
||||||
func (lqp ListQoSPolicies) FilterFunc(predicate func(ItemQoSPolicy) bool) ListQoSPolicies {
|
|
||||||
var result ListQoSPolicies
|
|
||||||
|
|
||||||
for _, item := range lqp.Data {
|
|
||||||
if predicate(item) {
|
|
||||||
result.Data = append(result.Data, item)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
result.EntryCount = uint64(len(result.Data))
|
|
||||||
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
|
|
||||||
// FindOne returns first found ListQoSPolicies
|
|
||||||
// If none was found, returns an empty struct
|
|
||||||
func (lqp ListQoSPolicies) FindOne() ItemQoSPolicy {
|
|
||||||
if len(lqp.Data) == 0 {
|
|
||||||
return ItemQoSPolicy{}
|
|
||||||
}
|
|
||||||
|
|
||||||
return lqp.Data[0]
|
|
||||||
}
|
|
||||||
@@ -1,97 +0,0 @@
|
|||||||
package qospolicy
|
|
||||||
|
|
||||||
import "testing"
|
|
||||||
|
|
||||||
var qosPolicies = ListQoSPolicies{
|
|
||||||
Data: []ItemQoSPolicy{
|
|
||||||
{
|
|
||||||
ID: 1,
|
|
||||||
AccountID: 1,
|
|
||||||
Name: "qos1",
|
|
||||||
Description: "some desc",
|
|
||||||
Status: "ENABLED",
|
|
||||||
CreatedBy: "user",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
ID: 3,
|
|
||||||
AccountID: 3,
|
|
||||||
Name: "qos3",
|
|
||||||
Description: "some desc",
|
|
||||||
Status: "ENABLED",
|
|
||||||
CreatedBy: "anotheruser",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
ID: 5,
|
|
||||||
AccountID: 3,
|
|
||||||
Name: "qos5",
|
|
||||||
Description: "some other desc",
|
|
||||||
Status: "DISABLED",
|
|
||||||
CreatedBy: "anotheruser",
|
|
||||||
UpdatedBy: "user",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
EntryCount: 3,
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestFilterByID(t *testing.T) {
|
|
||||||
actual := qosPolicies.FilterByID(1).FindOne()
|
|
||||||
if actual.ID != 1 {
|
|
||||||
t.Fatal("expected ID 1, found: ", actual.ID)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestFilterByName(t *testing.T) {
|
|
||||||
actual := qosPolicies.FilterByName("qos3").FindOne()
|
|
||||||
if actual.Name != "qos3" {
|
|
||||||
t.Fatal("expected Name qos3, found: ", actual.Name)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestFilterByDescription(t *testing.T) {
|
|
||||||
actual := qosPolicies.FilterByDescription("some desc")
|
|
||||||
|
|
||||||
if len(actual.Data) != 2 {
|
|
||||||
t.Fatal("expected 2 found, actual: ", len(actual.Data))
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, item := range actual.Data {
|
|
||||||
if item.Description != "some desc" {
|
|
||||||
t.Fatal("expected Description 'some desc', found: ", item.Description)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestFilterByAccountID(t *testing.T) {
|
|
||||||
actual := qosPolicies.FilterByAccountID(1).FindOne()
|
|
||||||
if actual.AccountID != 1 {
|
|
||||||
t.Fatal("expected AccountID 1, found: ", actual.AccountID)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestFilterByStatus(t *testing.T) {
|
|
||||||
actual := qosPolicies.FilterByStatus("DISABLED").FindOne()
|
|
||||||
if actual.Status != "DISABLED" {
|
|
||||||
t.Fatal("expected Status DISABLED, found: ", actual.Status)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestFilterByCreatedBy(t *testing.T) {
|
|
||||||
actual := qosPolicies.FilterByCreatedBy("anotheruser")
|
|
||||||
|
|
||||||
if len(actual.Data) != 2 {
|
|
||||||
t.Fatal("expected 2 found, actual: ", len(actual.Data))
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, item := range actual.Data {
|
|
||||||
if item.CreatedBy != "anotheruser" {
|
|
||||||
t.Fatal("expected CreatedBy 'anotheruser', found: ", item.CreatedBy)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestFilterByUpdatedBy(t *testing.T) {
|
|
||||||
actual := qosPolicies.FilterByUpdatedBy("user").FindOne()
|
|
||||||
if actual.UpdatedBy != "user" {
|
|
||||||
t.Fatal("expected UpdatedBy 'user', found: ", actual.UpdatedBy)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,43 +0,0 @@
|
|||||||
package qospolicy
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"encoding/json"
|
|
||||||
"net/http"
|
|
||||||
|
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
|
||||||
)
|
|
||||||
|
|
||||||
type GetRequest struct {
|
|
||||||
// QoS policy ID
|
|
||||||
// Required: true
|
|
||||||
QoSPolicyID uint64 `url:"qos_policy_id" json:"qos_policy_id" validate:"required"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func (qp QoSPolicy) Get(ctx context.Context, req GetRequest) (*RecordQoSPolicy, error) {
|
|
||||||
res, err := qp.GetRaw(ctx, req)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
info := RecordQoSPolicy{}
|
|
||||||
|
|
||||||
err = json.Unmarshal(res, &info)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return &info, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (qp QoSPolicy) GetRaw(ctx context.Context, req GetRequest) ([]byte, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/network_qos_policy/get"
|
|
||||||
|
|
||||||
res, err := qp.client.DecortApiCall(ctx, http.MethodGet, url, req)
|
|
||||||
return res, err
|
|
||||||
}
|
|
||||||
@@ -1,89 +0,0 @@
|
|||||||
package qospolicy
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"encoding/json"
|
|
||||||
"net/http"
|
|
||||||
|
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
|
||||||
)
|
|
||||||
|
|
||||||
type ListRequest struct {
|
|
||||||
// Page number
|
|
||||||
// Required: false
|
|
||||||
Page uint64 `url:"page,omitempty" json:"page,omitempty"`
|
|
||||||
|
|
||||||
// Page size
|
|
||||||
// Required: false
|
|
||||||
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
|
||||||
|
|
||||||
// Find QoS policy by id
|
|
||||||
// Required: false
|
|
||||||
ByID uint64 `url:"by_id,omitempty" json:"by_id,omitempty"`
|
|
||||||
|
|
||||||
// Find by account id
|
|
||||||
// Required: false
|
|
||||||
AccountID uint64 `url:"account_id,omitempty" json:"account_id,omitempty"`
|
|
||||||
|
|
||||||
// Find by QoS policy name
|
|
||||||
// Required: false
|
|
||||||
Name string `url:"name,omitempty" json:"name,omitempty"`
|
|
||||||
|
|
||||||
// Find by QoS policy description
|
|
||||||
// Required: false
|
|
||||||
Description string `url:"description,omitempty" json:"description,omitempty"`
|
|
||||||
|
|
||||||
// Find by QoS policy status
|
|
||||||
// Possible values: ENABLED, DISABLED, DESTROYED
|
|
||||||
// Required: false
|
|
||||||
Status string `url:"status,omitempty" json:"status,omitempty"`
|
|
||||||
|
|
||||||
// Find by created after time (unix timestamp)
|
|
||||||
// Required: false
|
|
||||||
CreatedMin uint64 `url:"created_min,omitempty" json:"created_min,omitempty"`
|
|
||||||
|
|
||||||
// Find by created before time (unix timestamp)
|
|
||||||
// Required: false
|
|
||||||
CreatedMax uint64 `url:"created_max,omitempty" json:"created_max,omitempty"`
|
|
||||||
|
|
||||||
// Find by updated after time (unix timestamp)
|
|
||||||
// Required: false
|
|
||||||
UpdatedMin uint64 `url:"updated_min,omitempty" json:"updated_min,omitempty"`
|
|
||||||
|
|
||||||
// Find by updated before time (unix timestamp)
|
|
||||||
// Required: false
|
|
||||||
UpdatedMax uint64 `url:"updated_max,omitempty" json:"updated_max,omitempty"`
|
|
||||||
|
|
||||||
// Sort by one of supported fields, format ±<field>
|
|
||||||
// Required: false
|
|
||||||
SortBy string `url:"sort_by,omitempty" json:"sort_by,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// List gets list of QoS policies as a ListQosPolicies struct
|
|
||||||
func (qp QoSPolicy) List(ctx context.Context, req ListRequest) (*ListQoSPolicies, error) {
|
|
||||||
res, err := qp.ListRaw(ctx, req)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
list := ListQoSPolicies{}
|
|
||||||
|
|
||||||
err = json.Unmarshal(res, &list)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return &list, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// ListRaw gets list of QoS policies as an array of bytes
|
|
||||||
func (qp QoSPolicy) ListRaw(ctx context.Context, req ListRequest) ([]byte, error) {
|
|
||||||
if err := validators.ValidateRequest(req); err != nil {
|
|
||||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/network_qos_policy/list"
|
|
||||||
|
|
||||||
res, err := qp.client.DecortApiCall(ctx, http.MethodGet, url, req)
|
|
||||||
return res, err
|
|
||||||
}
|
|
||||||
@@ -1,122 +0,0 @@
|
|||||||
package qospolicy
|
|
||||||
|
|
||||||
type ListQoSPolicies struct {
|
|
||||||
// List
|
|
||||||
Data []ItemQoSPolicy `json:"data"`
|
|
||||||
|
|
||||||
// Entry count
|
|
||||||
EntryCount uint64 `json:"entryCount"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type ItemQoSPolicy struct {
|
|
||||||
// ID of the QoS policy
|
|
||||||
ID uint64 `json:"id"`
|
|
||||||
|
|
||||||
// GUID
|
|
||||||
GUID uint64 `json:"guid"`
|
|
||||||
|
|
||||||
// Account ID that owns the QoS policy
|
|
||||||
AccountID uint64 `json:"account_id"`
|
|
||||||
|
|
||||||
// Name of the QoS policy
|
|
||||||
Name string `json:"name"`
|
|
||||||
|
|
||||||
// Description of the QoS policy
|
|
||||||
Description string `json:"description"`
|
|
||||||
|
|
||||||
// Status of the QoS policy
|
|
||||||
Status string `json:"status"`
|
|
||||||
|
|
||||||
// Created at (unix timestamp)
|
|
||||||
CreatedAt uint64 `json:"created_at"`
|
|
||||||
|
|
||||||
// Updated at (unix timestamp)
|
|
||||||
UpdatedAt uint64 `json:"updated_at"`
|
|
||||||
|
|
||||||
// Created by
|
|
||||||
CreatedBy string `json:"created_by"`
|
|
||||||
|
|
||||||
// Updated by
|
|
||||||
UpdatedBy string `json:"updated_by"`
|
|
||||||
|
|
||||||
// List of rules
|
|
||||||
Rules Rules `json:"rules"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type RecordQoSPolicy struct {
|
|
||||||
// ID of the QoS policy
|
|
||||||
ID uint64 `json:"id"`
|
|
||||||
|
|
||||||
// GUID
|
|
||||||
GUID uint64 `json:"guid"`
|
|
||||||
|
|
||||||
// Account ID that owns the QoS policy
|
|
||||||
AccountID uint64 `json:"account_id"`
|
|
||||||
|
|
||||||
// Name of the QoS policy
|
|
||||||
Name string `json:"name"`
|
|
||||||
|
|
||||||
// Description of the QoS policy
|
|
||||||
Description string `json:"description"`
|
|
||||||
|
|
||||||
// Status of the QoS policy
|
|
||||||
Status string `json:"status"`
|
|
||||||
|
|
||||||
// Created at (unix timestamp)
|
|
||||||
CreatedAt uint64 `json:"created_at"`
|
|
||||||
|
|
||||||
// Updated at (unix timestamp)
|
|
||||||
UpdatedAt uint64 `json:"updated_at"`
|
|
||||||
|
|
||||||
// Created by
|
|
||||||
CreatedBy string `json:"created_by"`
|
|
||||||
|
|
||||||
// Updated by
|
|
||||||
UpdatedBy string `json:"updated_by"`
|
|
||||||
|
|
||||||
// List of rules
|
|
||||||
Rules Rules `json:"rules"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type Rules []Rule
|
|
||||||
|
|
||||||
type Rule struct {
|
|
||||||
// ID of the rule
|
|
||||||
ID uint64 `json:"id"`
|
|
||||||
|
|
||||||
// Description of the rule
|
|
||||||
Description string `json:"description"`
|
|
||||||
|
|
||||||
// Rule priority in OVS (higher number = higher priority)
|
|
||||||
Priority uint64 `json:"priority"`
|
|
||||||
|
|
||||||
// Traffic direction
|
|
||||||
Direction string `json:"direction"`
|
|
||||||
|
|
||||||
// IP protocol
|
|
||||||
Protocol string `json:"protocol"`
|
|
||||||
|
|
||||||
// Priority Code Point (0-7). L2 marking
|
|
||||||
PCPTag uint64 `json:"pcp_tag"`
|
|
||||||
|
|
||||||
// DSCP value (0-63). L3 marking
|
|
||||||
DSCPValue uint64 `json:"dscp_value"`
|
|
||||||
|
|
||||||
// Source IP address
|
|
||||||
SrcIP string `json:"src_ip"`
|
|
||||||
|
|
||||||
// Destination IP address
|
|
||||||
DstIP string `json:"dst_ip"`
|
|
||||||
|
|
||||||
// Source MAC address
|
|
||||||
SrcMAC string `json:"src_mac"`
|
|
||||||
|
|
||||||
// Destination MAC address
|
|
||||||
DstMAC string `json:"dst_mac"`
|
|
||||||
|
|
||||||
// Source port
|
|
||||||
SrcPort uint64 `json:"src_port"`
|
|
||||||
|
|
||||||
// Destination port
|
|
||||||
DstPort uint64 `json:"dst_port"`
|
|
||||||
}
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
package qospolicy
|
|
||||||
|
|
||||||
import "repository.basistech.ru/BASIS/decort-golang-sdk/interfaces"
|
|
||||||
|
|
||||||
// Structure for creating request to QoS policy
|
|
||||||
type QoSPolicy struct {
|
|
||||||
client interfaces.Caller
|
|
||||||
}
|
|
||||||
|
|
||||||
// Builder for QoS policy endpoint
|
|
||||||
func New(client interfaces.Caller) *QoSPolicy {
|
|
||||||
return &QoSPolicy{
|
|
||||||
client: client,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,39 +0,0 @@
|
|||||||
package qospolicy
|
|
||||||
|
|
||||||
import "sort"
|
|
||||||
|
|
||||||
// SortByCreatedAt sorts ListQosPolicies by the CreatedAt field in ascending order
|
|
||||||
// If inverse param is set to true, the order is reversed
|
|
||||||
func (lqp ListQoSPolicies) SortByCreatedAt(inverse bool) ListQoSPolicies {
|
|
||||||
if len(lqp.Data) < 2 {
|
|
||||||
return lqp
|
|
||||||
}
|
|
||||||
|
|
||||||
sort.Slice(lqp.Data, func(i, j int) bool {
|
|
||||||
if inverse {
|
|
||||||
return lqp.Data[i].CreatedAt > lqp.Data[j].CreatedAt
|
|
||||||
}
|
|
||||||
|
|
||||||
return lqp.Data[i].CreatedAt < lqp.Data[j].CreatedAt
|
|
||||||
})
|
|
||||||
|
|
||||||
return lqp
|
|
||||||
}
|
|
||||||
|
|
||||||
// SortByUpdatedAt sorts ListQosPolicies by the UpdatedAt field in ascending order
|
|
||||||
// If inverse param is set to true, the order is reversed
|
|
||||||
func (lqp ListQoSPolicies) SortByUpdatedAt(inverse bool) ListQoSPolicies {
|
|
||||||
if len(lqp.Data) < 2 {
|
|
||||||
return lqp
|
|
||||||
}
|
|
||||||
|
|
||||||
sort.Slice(lqp.Data, func(i, j int) bool {
|
|
||||||
if inverse {
|
|
||||||
return lqp.Data[i].UpdatedAt > lqp.Data[j].UpdatedAt
|
|
||||||
}
|
|
||||||
|
|
||||||
return lqp.Data[i].UpdatedAt < lqp.Data[j].UpdatedAt
|
|
||||||
})
|
|
||||||
|
|
||||||
return lqp
|
|
||||||
}
|
|
||||||
@@ -1,52 +0,0 @@
|
|||||||
package qospolicy
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"encoding/json"
|
|
||||||
"net/http"
|
|
||||||
|
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants"
|
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
|
||||||
)
|
|
||||||
|
|
||||||
type UpdateRequest struct {
|
|
||||||
// QoS policy ID
|
|
||||||
// Required: true
|
|
||||||
QoSPolicyID uint64 `url:"qos_policy_id" json:"qos_policy_id" validate:"required"`
|
|
||||||
|
|
||||||
// New QoS policy name
|
|
||||||
// Required: false
|
|
||||||
Name string `url:"name,omitempty" json:"name,omitempty"`
|
|
||||||
|
|
||||||
// New QoS policy description
|
|
||||||
// Required: false
|
|
||||||
Description string `url:"description,omitempty" json:"description,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func (qp QoSPolicy) Update(ctx context.Context, req UpdateRequest) (*RecordQoSPolicy, error) {
|
|
||||||
res, err := qp.UpdateRaw(ctx, req)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
info := RecordQoSPolicy{}
|
|
||||||
|
|
||||||
err = json.Unmarshal(res, &info)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return &info, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (qp QoSPolicy) UpdateRaw(ctx context.Context, req UpdateRequest) ([]byte, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/network_qos_policy/update"
|
|
||||||
|
|
||||||
res, err := qp.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
|
|
||||||
return res, err
|
|
||||||
}
|
|
||||||
40
pkg/cloudapi/rg/audits.go
Normal file
40
pkg/cloudapi/rg/audits.go
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
package rg
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"encoding/json"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
|
)
|
||||||
|
|
||||||
|
// AuditsRequest struct to get audit
|
||||||
|
type AuditsRequest struct {
|
||||||
|
// Resource group ID
|
||||||
|
// Required: true
|
||||||
|
RGID uint64 `url:"rgId" json:"rgId" validate:"required"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Audits gets audit records for the specified resource group object
|
||||||
|
func (r RG) Audits(ctx context.Context, req AuditsRequest) (ListAudits, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudapi/rg/audits"
|
||||||
|
|
||||||
|
res, err := r.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
list := ListAudits{}
|
||||||
|
|
||||||
|
err = json.Unmarshal(res, &list)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return list, nil
|
||||||
|
}
|
||||||
@@ -76,10 +76,6 @@ type CreateRequest struct {
|
|||||||
// SDN access group id
|
// SDN access group id
|
||||||
// Required: false
|
// Required: false
|
||||||
SDNAccessGroupID string `url:"sdn_access_group_id,omitempty" json:"sdn_access_group_id,omitempty"`
|
SDNAccessGroupID string `url:"sdn_access_group_id,omitempty" json:"sdn_access_group_id,omitempty"`
|
||||||
|
|
||||||
// Enabling default gateway
|
|
||||||
// Required: false
|
|
||||||
EnableDefaultGateway interface{} `url:"enable_default_gateway,omitempty" json:"enable_default_gateway,omitempty" validate:"omitempty,isBool"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type StoragePolicy struct {
|
type StoragePolicy struct {
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ type RecordResourceGroup struct {
|
|||||||
CPUAllocationParameter string `json:"cpu_allocation_parameter"`
|
CPUAllocationParameter string `json:"cpu_allocation_parameter"`
|
||||||
|
|
||||||
// CPU allocation ratio
|
// CPU allocation ratio
|
||||||
CPUAllocationRatio uint64 `json:"cpu_allocation_ratio"`
|
CPUAllocationRatio float64 `json:"cpu_allocation_ratio"`
|
||||||
|
|
||||||
// Created by
|
// Created by
|
||||||
CreatedBy string `json:"createdBy"`
|
CreatedBy string `json:"createdBy"`
|
||||||
@@ -180,7 +180,7 @@ type ItemResourceGroup struct {
|
|||||||
CPUAllocationParameter string `json:"cpu_allocation_parameter"`
|
CPUAllocationParameter string `json:"cpu_allocation_parameter"`
|
||||||
|
|
||||||
// CPU allocation ratio
|
// CPU allocation ratio
|
||||||
CPUAllocationRatio uint64 `json:"cpu_allocation_ratio"`
|
CPUAllocationRatio float64 `json:"cpu_allocation_ratio"`
|
||||||
|
|
||||||
// Created by
|
// Created by
|
||||||
CreatedBy string `json:"createdBy"`
|
CreatedBy string `json:"createdBy"`
|
||||||
@@ -267,9 +267,6 @@ type ListResourceGroups struct {
|
|||||||
|
|
||||||
// Main information about Access Control List
|
// Main information about Access Control List
|
||||||
type ItemACL struct {
|
type ItemACL struct {
|
||||||
// Email
|
|
||||||
Email string `json:"email"`
|
|
||||||
|
|
||||||
// Explicit
|
// Explicit
|
||||||
Explicit bool `json:"explicit"`
|
Explicit bool `json:"explicit"`
|
||||||
|
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user