Compare commits
30 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| fea00bbb42 | |||
|
|
e9adcfec1c | ||
| f6bc14c7be | |||
|
|
f93065e8b1 | ||
|
|
2bd93e92c2 | ||
|
|
5cdae8520f | ||
| 30e464e4d2 | |||
| 9258a1574b | |||
|
|
444a33dc7e | ||
| 17017b6d5d | |||
|
|
c701001bb6 | ||
|
|
c2c810504d | ||
|
|
b834e5d074 | ||
| e1f0d354af | |||
|
|
d149ba19fd | ||
| c17b6f2336 | |||
|
|
b1fbd6872d | ||
|
|
365a4991d2 | ||
| bb90a2d511 | |||
|
|
f111bf25fc | ||
|
|
055b256d6b | ||
|
|
f0dee6360a | ||
| a267d35ddf | |||
|
|
0bf073da93 | ||
|
|
562b6019d0 | ||
| bf5c01b40b | |||
|
|
095a18f27a | ||
|
|
84a090f9e8 | ||
| befff7acd9 | |||
|
|
abd35f858c |
274
CHANGELOG.md
274
CHANGELOG.md
@@ -1,183 +1,199 @@
|
||||
## Version 1.12.2
|
||||
## Version 1.15.0
|
||||
|
||||
Методы `Audits` в cloudapi/compute, cloudbroker/compute, cloudapi/account, cloudbroker/account, cloudapi/vins, cloudbroker/vins, cloudapi/rg и cloudbroker/rg стали deprecated и в следующих версиях будут удалены, вместо них необходимо использовать метод `List` в cloudapi/audit и cloudbroker/audit с соответствующими фильтрами
|
||||
Методы `AccessGrant`, `AccessGrantToPool`, `AccessRevoke`, `AccessRevokeToPool` в cloudbroker/sep стали deprecated и в следующих версиях будут удалены
|
||||
Методы `ComputeCISet`, `ComputeCIUnset`, `GetAudits` в cloudbroker/compute и `GetAudits` в cloudapi/compute стали deprecated и будут удалены в следующих версиях
|
||||
Методы `ComputeCISet`, `ComputeCIUnset` в cloudbroker/image стали deprecated и будут удалены в следующих версиях
|
||||
|
||||
Все методы группы `.SDN()` находятся в альфа-версии.
|
||||
|
||||
|
||||
### Добавлено
|
||||
|
||||
#### общие изменения
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-525 | Поддержка работы с различными сontent-type |
|
||||
| BGOS-514 | Пакет SDN со структурой для SDN запросов |
|
||||
| BGOS-587 | Проверка срока действия и обновления JWT токена для `DecortClient`, в связи с добавлением срока действия токена |
|
||||
|
||||
#### account
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-572 | Поля `StoragePolicyIDs` в структуре ответа `RecordAccount` в cloudapi/account и в `InfoAccount` cloudbroker/account |
|
||||
| BGOS-572 | Поля `StoragePolicies` в структуре ответа `ResourceLimits` в cloudapi/account и в cloudbroker/account |
|
||||
| BGOS-572 | Методы `AddStoragePolicy`, `DelStoragePolicyRequest` и структуры запросов `AddStoragePolicyRequest`, `DelStoragePolicyRequest` в cloudbroker/account |
|
||||
| BGOS-572 | Обязательное поле `StoragePolicies` в структуру запроса `CreateRequest` в cloudbroker/account |
|
||||
| BGOS-572 | Опциональное поле `StoragePolicies` в структуру запроса `UpdateRequest` в cloudbroker/account |
|
||||
| BGOS-585 | Опциональное поле `ZoneID` в структуру запроса `ListRequest` в cloudapi/account и в cloudbroker/account |
|
||||
|
||||
#### audit
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-595 | Поле `CorrelationID` в структуры ответа `RecordAudit` в cloudapi/audit и в `RecordAudit` и `ItemAudit` в cloudbroker/audit |
|
||||
|
||||
#### bservice
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-576 | Опциональное поле `StoragePolicyID` в структуру запроса `GroupAddRequest` в cloudapi/bservice и в структуру запроса `GroupAddRequest` в cloudbroker/bservice |
|
||||
| BGOS-585 | Опциональное поле `ZoneID` в структуру запроса `ListRequest` в cloudapi/bservice и в cloudbroker/bservice |
|
||||
|
||||
#### compute
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| Идентификатор задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-569 | Опциональные поля `TimestampAT`, `TimestampTO`, `User`, `Call`, `SortBy`, `Page`, `Size`, `MinStatusCode`, `MaxStatusCode` в структуру запроса `AuditsRequest` в cloudapi/compute и в cloudbroker/compute |
|
||||
| BGOS-575 | Обязательное поле `StoragePolicyID` в структуру запроса `CreateTemplateFromBlankRequest`, `DiskAddRequest`, `RedeployRequest` в cloudapi/compute и в cloudbroker/compute |
|
||||
| BGOS-575 | Поле `StoragePolicyID` в структуру ответа `ItemComputeDisk` в cloudapi/compute и в структуру ответа `ItemDisk` в cloudbroker/compute |
|
||||
| BGOS-580 | Поле `ZoneID` в структуру ответа `ItemCompute` в cloudapi/compute |
|
||||
| BGOS-583 | Опциональные поля `SecGroups`, `EnableSecGroups` в структуру запроса `NetAttachRequest` в cloudapi/compute и в cloudbroker/compute |
|
||||
| BGOS-583 | Поля `SecGroups`, `EnableSecGroups` в структуру ответа `ItemVNFInterface` в cloudapi/compute и в `ItemInterface` cloudbroker/compute |
|
||||
| BGOS-585 | Опциональное поле `ZoneID` в структуру запроса `ListRequest` в cloudapi/compute и в cloudbroker/compute |
|
||||
| BGOS-592 | Опциональное поле `Enabled` в структуру запроса `NetAttachRequest` в cloudapi/compute и в cloudbroker/compute |
|
||||
| BGOS-593 | Поле `ToClean` в структурах ответа `ItemComputeDisk` в cloudapi/compute и `ItemDisk` cloudbroker/compute |
|
||||
| BGOS-864 | Методы `GetCPUAlignmentProfile`, `SetCPUAlignmentProfile` и `DeleteCPUAlignmentProfile` в cloudapi/compute и cloudbroker/compute |
|
||||
| BGOS-864 | Структуры запросов `GetCPUAlignmentProfileRequest`, `SetCPUAlignmentProfileRequest` и `DeleteCPUAlignmentProfileRequest` в cloudapi/compute и cloudbroker/compute |
|
||||
| BGOS-865 | Вычисляемое поле `CPUAlignmentProfile` в структуру ответа `RecordCompute` в cloudapi/compute и cloudbroker/compute |
|
||||
| BGOS-865 | Вычисляемое поле `CPUAlignmentProfile` в структуру ответа `ItemCompute` в cloudapi/compute и cloudbroker/compute |
|
||||
| BGOS-865 | Структура ответа `CPUAlignmentProfile` в cloudapi/compute и cloudbroker/compute |
|
||||
| BGOS-872 | Опциональное поле `WithMemory` в структуру запроса `SnapshotCreateRequest` в cloudapi/compute и cloudbroker/compute |
|
||||
| BGOS-872 | Опциональное поле `WithMemory` в структуру запроса `SnapshotRollbackRequest` в cloudapi/compute и cloudbroker/compute |
|
||||
| BGOS-872 | Вычисляемые поля `MemoryDumpImage` и `Compute` в структуру ответа `ItemSnapshot` в cloudapi/compute и cloudbroker/compute |
|
||||
| BGOS-872 | Методы `SnapshotCreateAsync`, `SnapshotRollbackAsync` и `AbortSharedSnapshotMergeAsync` в cloudapi/compute и cloudbroker/compute |
|
||||
| BGOS-872 | Опциональное поле `NodeID` в структуру запроса `SnapshotRollbackRequest` в cloudbroker/compute |
|
||||
| BGOS-877 | Опциональное поле `Clock` в структуру запроса `UpdateRequest` в cloudapi/compute и cloudbroker/compute |
|
||||
| BGOS-877 | Вычисляемое поле `Clock` в структуры ответа `RecordCompute` и `ItemCompute` в cloudapi/compute|
|
||||
| BGOS-877 | Вычисляемое поле `Clock` в структуры ответа `RecordCompute` и `InfoCompute` в cloudbroker/compute |
|
||||
| BGOS-885 | Методы `CDEjectAsync`, `CDInsertAsync`, `ChangeIPAsync`, `ChangeLinkStateAsync`, `ChangeSecGroupsAsync`, `ChangeMTUAsync`, `CloneAsync`, `CreateTemplateAsync`, `DeleteAsync`, `DisableAsync`, `DiskAddAsync`, `DiskAttachAsync`, `DiskDelAsync`, `DiskDetachAsync`, `DiskQOSAsync`, `DiskResizeAsync`, `DiskSwitchToReplicationAsync`, `GuestAgentDisableAsync`, `GuestAgentEnableAsync`, `GuestAgentExecuteRequestAsync`, `GuestAgentFeatureUpdateAsync`, `MigrateToZoneAsync`, `MoveToRGAsync`, `NetAttachAsync`, `NetDetachAsync`, `PauseAsync`, `PFWAddAsync`, `PFWDelAsync`, `PinToNodeAsync`, `PowerCycleAsync`, `RebootAsync`, `RedeployAsync`, `ResetAsync`, `ResizeAsync`, `RestoreAsync`, `ResumeAsync`, `StartAsync`, `StopAsync`, `MassDeleteAsync`, `MassRebootAsync`, `MassStartAsync`, `MassStopAsync`, `MigrateAbortAsync`, `MigrateStorageAbortAsync`, `MigrateStorageCleanUpAsync`, `NetQOSAsync` и `RaiseDownAsync` в cloudbroker/compute |
|
||||
| BGOS-885 | Методы `CDEjectAsync`, `CDInsertAsync`, `ChangeIPAsync`, `ChangeLinkStateAsync`, `ChangeMTUAsync`, `ChangeSecGroupsAsync`, `CloneAsync`, `DeleteAsync`, `DisableAsync`, `DiskAddAsync`, `DiskDelAsync`, `DiskAttachAsync`, `DiskDetachAsync`, `DiskQOSAsync`, `DiskResizeAsync`, `DiskSwitchToReplicationAsync`, `GuestAgentDisableAsync`, `GuestAgentEnableAsync`, `GuestAgentExecuteRequestAsync`, `GuestAgentFeatureUpdateAsync`, `MigrateToZoneAsync`, `MoveToRGAsync`, `NetAttachAsync`, `NetDetachAsync`, `PauseAsync`, `PFWAddAsync`, `PFWDelAsync`, `PinToNodeAsync`, `PowerCycleAsync`, `RebootAsync`, `RedeployAsync`, `ResetAsync`, `ResizeAsync`, `RestoreAsync`, `ResumeAsync`, `StartAsync` и `StopAsync` в cloudapi/compute |
|
||||
| BGOS-894 | Опциональное поле `ReadOnly` в структуры запросов `DiskAddRequest` и `DiskAttachRequest` в cloudapi/compute и cloudbroker/compute |
|
||||
| BGOS-894 | Опциональное поле `ReadOnly` в структуры ответа `InfoDisk` в cloudapi/compute и cloudbroker/compute |
|
||||
| BGOS-894 | Опциональное поле `ReadOnly` в структуру ответа `ItemComputeDisk` в cloudapi/compute |
|
||||
| BGOS-894 | Опциональное поле `ReadOnly` в структуру ответа `ItemDisk` в cloudbroker/compute |
|
||||
|
||||
#### disks
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| Идентификатор задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-574 | Поля `StoragePolicyID` в структуры ответа `RecordDisk` и `ItemDisk` в cloudapi/disks и в `InfoDisk` cloudbroker/disks |
|
||||
| BGOS-574 | Метод `ChangeDiskStoragePolicy` и структура запроса `ChangeDiskStoragePolicyRequest` в cloudapi/disks и в cloudbroker/disks |
|
||||
| BGOS-574 | Обязательное поле `StoragePolicyID` в структуры запроса `CreateRequest` и `ReplicateRequest` в cloudapi/disks и в cloudbroker/disks |
|
||||
| BGOS-593 | Поле `ToClean` в структурах ответа `ItemDisk`, `RecordDisk` в cloudapi/disks и `InfoDisk` cloudbroker/disks |
|
||||
|
||||
#### dpdknet
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-584 | Опциональное поле `EnableSecGroups` в структуру запроса `UpdateRequest` в cloudbroker/dpdknet |
|
||||
| BGOS-584 | Поле `EnableSecGroups` в структуры ответа `ItemDPDKNet`, `RecordDPDKNet` в cloudapi/dpdknet и в cloudbroker/dpdknet |
|
||||
| BGOS-895 | Вычисляемое поле `ComputesReadOnly` в структуру ответа `InfoDisk` в cloudbroker/disks |
|
||||
| BGOS-895 | Вычисляемое поле `ComputesReadOnly` в структуры ответа `ItemDisk` и `RecordDisk` в cloudapi/disks |
|
||||
|
||||
#### extnet
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-585 | Опциональное поле `ZoneID` в структуру запроса `ListRequest` в cloudapi/extnet и в cloudbroker/extnet |
|
||||
| BGOS-584 | Опциональное поле `EnableSecGroups` в структуру запроса `UpdateRequest` в cloudbroker/extnet |
|
||||
| BGOS-584 | Поле `EnableSecGroups` в структуру ответа `ItemExtNet` в cloudbroker/extnet |
|
||||
| BGOS-584 | Поле `EnableSecGroups` в структуру ответа `RecordExtNet` в cloudapi/extnet и в cloudbroker/extnet |
|
||||
| BGOS-876 | Вычисляемое поле `FreeIPs` в структуру ответа `ItemExtNet` в cloudapi/extnet |
|
||||
|
||||
#### image
|
||||
#### grid
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-578 | Обязательное поле `StoragePolicyID` в структуру запроса `CreateRequest` в cloudapi/image и в структуры запроса `CreateRequest` и `CreateCDROMImageRequest` в cloudbroker/image |
|
||||
| BGOS-578 | Поле `StoragePolicyID` в структуру ответа `RecordImage` в cloudapi/image и в структуры ответа `RecordImage` и `ItemImage` в cloudbroker/image |
|
||||
| BGOS-578 | Метод `ChangeStoragePolicy` и структура запроса `ChangeStoragePolicyRequest` в cloudapi/image и в cloudbroker/image |
|
||||
|
||||
#### k8s
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-577 | Обязательное поле `StoragePolicyID` в структуры запроса `CreateRequest` и `WorkersGroupAddRequest` в cloudapi/k8s и в структуры запроса `CreateRequest` и `WorkersGroupAddRequest` в cloudbroker/k8s |
|
||||
| BGOS-585 | Опциональное поле `ZoneID` в структуру запроса `ListRequest` в cloudapi/k8s и в cloudbroker/k8s |
|
||||
| BGOS-888 | Вычисляемые поля `CPUAllocationRatio`, `CPUAllocationRatioVM`, `CustomBackupPath`, `InterfaceGenerationScheme`, `MACAddressPrefix`, `NodeSelfStopTimerUptimeMonitor` и `NodeSelfStopUptimeMonitor` в структуру ответа `RecordSettingsGrid` в cloudbroker/grid |
|
||||
| BGOS-888 | Вычисляемое поле `ZeroAccessEnabled` в структуру ответа `RecordGrid` в cloudbroker/grid |
|
||||
| BGOS-888 | Вычисляемое поле `Policies` в структуру ответа `RecordResource` и структура ответа `PolicyUsage` в cloudbroker/grid |
|
||||
|
||||
#### kvmx86
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| Идентификатор задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-575 | Обязательное поле `StoragePolicyID` в структуры запросов `CreateRequest`, `DataDisk`, `CreateBlankRequest` в cloudapi/kvmx86 и cloudbroker/kvmx86 и `MassCreateRequest` в cloudbroker/kvmx86 |
|
||||
| BGOS-583 | Опциональные поля `SecGroups`, `EnableSecGroups` в структуру запроса `Interface` в cloudapi/kvmx86 и в cloudbroker/kvmx86 |
|
||||
| BGOS-592 | Опциональное поле `Enabled` в структуру запроса `Interface` в cloudapi/kvmx86 и в cloudbroker/kvmx86 |
|
||||
|
||||
#### lb
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-585 | Опциональное поле `ZoneID` в структуру запроса `ListRequest` в cloudapi/lb и в cloudbroker/lb |
|
||||
| BGOS-865 | Опциональное поле `CPUAlignmentProfile` в структуры запросов `CreateRequest` и `CreateBlankRequest` в cloudapi/kvmx86 и cloudbroker/kvmx86 |
|
||||
| BGOS-865 | Опциональное поле `CPUAlignmentProfile` в структуру запроса `MassCreateRequest` в cloudbroker/kvmx86 |
|
||||
| BGOS-877 | Опциональное поле `Clock` в структуры запросов `CreateRequest` и `CreateBlankRequest` в cloudapi/kvmx86 и cloudbroker/kvmx86 |
|
||||
| BGOS-877 | Опциональное поле `Clock` в структуру запроса `MassCreateRequest` в cloudbroker/kvmx86 |
|
||||
|
||||
#### node
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-597 | Поле `VCPU` в структуру ответа `FreeResourcesInfo` в cloudbroker/node |
|
||||
| BGOS-866 | Вычисляемые поля `OneGAvailable`, `OneGFree`, `OneGReserved`, `OneGUsed`, `OneGDPDKReserved`, `TwoMAvailable`, `TwoMFree`, `TwoMReserved` и `TwoMUsed` в структуру ответа `ItemMemory` в cloudbroker/node |
|
||||
| BGOS-879 | Методы `GetPCIDevices`, `PCIDeviceDriverToVFIO` и `PCIDeviceDriverToKernel` в cloudbroker/node |
|
||||
| BGOS-879 | Структуры запросов `GetPCIDevicesRequest`, `PCIDeviceDriverToVFIORequest` и `PCIDeviceDriverToKernelRequest` в cloudbroker/node |
|
||||
| BGOS-879 | Структуры ответов `RecordPCIDeviceDriver`, `ListPCIDevices` и `ItemPCIDevice` в cloudbroker/node |
|
||||
| BGOS-880 | Вычисляемое поле `PCIDevices` в структуру ответа `ItemNode` в cloudbroker/node |
|
||||
| BGOS-882 | Метод `GetNetworkInfo` и структура запроса `GetNetworkInfoRequest` в cloudbroker/node |
|
||||
| BGOS-882 | Структуры ответа `RecordNodeNetworkInfo`, `SystemNetworkInfo`, `OVSNetworkInfo`, `LibvirtNetworkInfo` и `NetworkTopology` в cloudbroker/node |
|
||||
| BGOS-890 | Структура ответа `ItemNode` для методов `SetCpuAllocationRatio` и `SetMemAllocationRatio` в cloudbroker/node |
|
||||
|
||||
#### rg
|
||||
#### sep
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-573 | Поля `StoragePolicyIDs` в структуре ответа `RecordResourceGroup` в cloudapi/rg и в `ItemRG` cloudbroker/rg |
|
||||
| BGOS-573 | Поля `StoragePolicies` в структуре ответа `ResourceLimits` в cloudapi/rg и в cloudbroker/rg |
|
||||
| BGOS-573 | Методы `AddStoragePolicy`, `DelStoragePolicyRequest` и структуры запросов `AddStoragePolicyRequest`, `DelStoragePolicyRequest` в cloudbroker/rg |
|
||||
| BGOS-573 | Опциональное поле `StoragePolicies` в структуры запроса `CreateRequest`, `UpdateRequest` в cloudapi/rg и в cloudbroker/rg |
|
||||
| BGOS-873 | Метод `Update` и структура запроса `UpdateRequest` в cloudbroker/sep |
|
||||
|
||||
#### security group
|
||||
#### zone
|
||||
| Идентификатор задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-862 | Метод `AddCPUAlignmentProfile` и структура запроса `AddCPUAlignmentProfileRequest` в cloudbroker/zone |
|
||||
| BGOS-862 | Метод `DeleteCPUAlignmentProfile` и структура запроса `DeleteCPUAlignmentProfileRequest` в cloudbroker/zone |
|
||||
| BGOS-862 | Метод `GetCPUAlignmentProfile` и структура запроса `GetCPUAlignmentProfileRequest` в cloudbroker/zone |
|
||||
| BGOS-862 | Метод `ListCPUAlignmentProfile` и структура запроса `ListCPUAlignmentProfileRequest` в cloudbroker/zone |
|
||||
| BGOS-862 | Метод `TestCPUAlignmentProfile` и структура запроса `TestCPUAlignmentProfileRequest` в cloudbroker/zone |
|
||||
| BGOS-862 | Структуры ответов `ListCPUAlignmentProfiles`, `ItemCPUAlignmentProfile`, `TestCPUAlignmentProfileResult` и `CpuAlignmentProfileCandidate` в cloudbroker/zone |
|
||||
| BGOS-863 | Вычисляемое поле `CpuAlignmentProfiles` в структуры ответа `RecordZone` и `ItemZone` и структура `CpuAlignmentProfile` в cloudapi/zone и cloudbroker/zone |
|
||||
|
||||
#### SDN logicalports
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-582 | Группа ручек `security_group` в cloudapi и в cloudbroker |
|
||||
| BGOS-896 | Обязательное поле `ID` в структуру запроса `UpdateAddress` в sdn/logical_port |
|
||||
|
||||
#### storage policy
|
||||
#### SDN netobjgroups
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-571 | Группа ручек `storage_policy` в cloudapi и в cloudbroker |
|
||||
| BGOS-884 | Опциональное поле `Type` в структуру запроса `ListRequest` в sdn/netobjgroups |
|
||||
|
||||
#### trunk
|
||||
### Изменено
|
||||
|
||||
#### account
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-565 | Опциональное поле `Status` в структуру запроса `ListRequest` в cloudapi/trunk и в cloudbroker/trunk |
|
||||
|
||||
#### user
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-562 | Опциональное поле `AccountID` в структуру запроса `CreateVirtualRequest` в cloudapi/image и в cloudbroker/image |
|
||||
|
||||
#### vins
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-584 | Метод `Update` и структура запроса `UpdateRequest` в cloudbroker/vins |
|
||||
| BGOS-584 | Поле `EnableSecGroups` в структуру ответа `ItemVINS` в cloudbroker/vins |
|
||||
| BGOS-584 | Поле `EnableSecGroups` в структуру ответа `RecordVINS` в cloudapi/vins и в cloudbroker/vins |
|
||||
|
||||
#### SDN access groups
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-514 | Группа api access_groups |
|
||||
|
||||
### Исправлено
|
||||
| BGOS-887 | Тип поля `CPUAllocationRatio` с `float64` на `uint64` в структуре ответа `RecordAccount` в cloudapi/account |
|
||||
| BGOS-887 | Тип поля `CPUAllocationRatio` с `float64` на `uint64` в структуре ответа `InfoAccount` в cloudbroker/account |
|
||||
|
||||
#### compute
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-569 | Изменена структура ответа с `ListAudits` на `*ListAudits`, содержащую поля `Data` и `EntryCount` в методе `Audits` в cloudapi/compute |
|
||||
| BGOS-569 | Изменена структура ответа с `ListDetailedAudits` на `*ListDetailedAudits`, содержащую поля `Data` и `EntryCount` в методе `Audits` в cloudbroker/compute |
|
||||
| BGOS-874 | Поле `StoragePolicyID` с обязательного на опциональное в структуре запроса `RedeployRequest` в cloudapi/compute и cloudbroker/compute |
|
||||
| BGOS-870 | Тип поля `BLKDiscard` с `bool` на `string` и переименование в `Discard` в структуре ответа `ItemComputeDisk` в cloudapi/compute |
|
||||
| BGOS-870 | Тип поля `BLKDiscard` с `bool` на `string` и переименование в `Discard` в структуре ответа `ItemDisk` в cloudbroker/compute|
|
||||
| BGOS-870 | Тип поля `BLKDiscard` с `bool` на `string` и переименование в `Discard` в структуре запроса `DiskAddRequest` в cloudbroker/compute|
|
||||
| BGOS-885 | Тип возвращаемого значения с `string` на `bool` в методе `Restore` в cloudapi/compute |
|
||||
| BGOS-885 | Тип возвращаемого значения с `string` на `bool` в методе `MigrateStorageAbort` в cloudbroker/compute |
|
||||
| BGOS-885 | Тип возвращаемого значения с `string` на `bool` в методе `MigrateStorageCleanUp` в cloudbroker/compute |
|
||||
| BGOS-885 | Название метода с `Validate` на `MoveToRG` в cloudbroker/compute |
|
||||
| BGOS-893 | Тип поля `SDNObjectGroupID` с `string` на `[]string` и переименование в `SDNObjectGroupIDs` в структуре запроса `NetAttachRequest` в cloudapi/compute и cloudbroker/compute |
|
||||
|
||||
#### user
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-561 | Изменен тип поля `UserIDs` с stirng на []string в структуре запроса `DeleteUsersRequest` в cloudbroker/user |
|
||||
|
||||
#### vins
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-560 | Изменен тип возвращаемого значения методов `MassDelete`, `MassDisable`, `MassEnable` c bool на string в cloudbroker/vins|
|
||||
|
||||
### Удалено
|
||||
|
||||
#### disks
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-563 | Опциональное поле `Drivers` в структуре запроса `FromPlatformDiskRequest` в cloudapi/disks и cloudbroker/disks |
|
||||
| BGOS-870 | Тип поля `BLKDiscard` с `bool` на `string` и переименование в `Discard` в структурах ответа `RecordDisk`, `ItemDisk` и `ItemDiskUnattached` в cloudapi/disks |
|
||||
| BGOS-870 | Тип поля `BLKDiscard` с `bool` на `string` и переименование в `Discard` в структуре ответа `InfoDisk` в cloudbroker/disks |
|
||||
| BGOS-870 | Тип поля `BLKDiscard` с `bool` на `string` и переименование в `Discard` в структурах запросов `CreateRequest` и `UpdateRequest` в cloudbroker/disks |
|
||||
| BGOS-881 | Поле `StoragePolicyID` c опционального на обязательное в структуре запроса `MigrateRequest` в cloudbroker/disks |
|
||||
|
||||
#### compute
|
||||
#### grid
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-580 | Поле `ZoneID` в структуре ответа `ItemComputeDisk` в cloudapi/compute |
|
||||
| BGOS-888 | Тип поля `Ratio` с `float64` на `uint64` в структурах запросов `SetCPUAllocationRatioRequest`, `SetCPUAllocationRatioForVMRequest` и `SetMemAllocationRatioRequest` в cloudbroker/grid |
|
||||
|
||||
#### image
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-563 | Опциональное поле `Drivers` в структуре запроса `CreateRequest` в cloudapi/image и cloudbroker/image |
|
||||
| BGOS-563 | Опциональное поле `Drivers` в структуре запроса `CreateCDROMImageRequest` в cloudbroker/image |
|
||||
|
||||
#### k8ci
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-563 | Опциональные поля `MasterDriver` и `WorkerDriver` в структурах запроса `ListRequest` и `ListDeletedRequest` в cloudapi/k8ci и cloudbroker/k8ci |
|
||||
| BGOS-563 | Опциональные поля `MasterDriver` и `WorkerDriver` в структуре запроса `CreateRequest` в cloudbroker/k8ci |
|
||||
| BGOS-860 | Тип ответа метода `MultiImageExport` со `string` на `uint64` в cloudbroker/image |
|
||||
| BGOS-869 | Тип вычисляемого поля `AccountID` с опционального на обязательный в структуре `CreateVirtualRequest` в cloudapi/image |
|
||||
| BGOS-878 | Тип поля `TypeImage` в структуре запроса `ListRequest` с `string` на `[]string` в cloudbroker/image и cloudapi/image |
|
||||
|
||||
#### kvmx86
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-563 | Опциональное поле `Driver` в структурах запроса `CreateRequest` и `CreateBlankRequest` в cloudapi/kvmx86 и cloudbroker/kvmx86 |
|
||||
| BGOS-870 | Тип поля `BLKDiscard` с `bool` на `string` и переименование в `Discard` в структуре ответа `DataDisk` в cloudbroker/kvmx86 |
|
||||
| BGOS-870 | Тип поля `BootDiskBLKDiscard` с `bool` на `string` и переименование в `BootDiskDiscard` в структурах запросов `CreateRequest`, `CreateBlankRequest` и `MassCreateRequest` в cloudbroker/kvmx86 |
|
||||
| BGOS-893 | Тип поля `SDNObjectGroupID` с `string` на `[]string` и переименование в `SDNObjectGroupIDs` в структуре `Interface` в cloudapi/kvmx86 и cloudbroker/kvmx86 |
|
||||
| BGOS-893 | Тип поля `SDNObjectGroupID` с `string` на `[]string` и переименование в `SDNObjectGroupIDs` в структуре `InterfaceMassCreate` в cloudbroker/kvmx86 |
|
||||
|
||||
#### node
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-867 | Тип обязательного поля `Ratio` с `float64` на `uint64` в структурах запросов `SetMemAllocationRatioRequest` и `SetCpuAllocationRatioRequest` в cloudbroker/node |
|
||||
| BGOS-889 | Тип поля `VCPU` с `float64` на `uint64` в структуре ответа `FreeResourcesInfo` в cloudbroker/node |
|
||||
| BGOS-889 | Тип полей `CPUAllocationRatio` и `MemAllocationRatio` с `float64` на `uint64` в структурах ответа `RecordNode` и `ItemNode` в cloudbroker/node |
|
||||
|
||||
#### resmon
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-868 | Тип поля `EndTime` с обязательного на опциональное в структурах запроса `GetByNodeRequest`, `GetByNodesRequest` `GetByGRIDRequest`, `GetByComputeRequest` и `GetByComputesRequest` в cloudbroker/resmon |
|
||||
|
||||
#### rg
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-886 | Тип поля `CPUAllocationRatio` с `float64` на `uint64` в структурах ответа `RecordResourceGroup` и `ItemResourceGroup` в cloudapi/rg |
|
||||
| BGOS-886 | Тип поля `CPUAllocationRatio` с `float64` на `uint64` в структуре ответа `ItemRG` в cloudbroker/rg |
|
||||
| BGOS-886 | Тип поля `Ratio` с `float64` на `uint64` в структуре запроса `SetCPUAllocationRatioRequest` в cloudbroker/rg |
|
||||
|
||||
#### user
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-891 | Тип поля `Password` с опционального на обязательный в структуре запроса `CreateRequest` в cloudbroker/user |
|
||||
|
||||
#### SDN logicalports
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-896 | Тип полей `IsDiscovered` и `MAC` с опционального на обязательный в структурах запроса `UpdateAddress` и `AddAddress` в sdn/logical_port |
|
||||
| BGOS-896 | Тип поля `IsDiscovered` с опционального на обязательный в структуре запроса `LogicalPortAddressRequest` в sdn/logical_port
|
||||
| BGOS-896 | Тип полей `IsDiscovered`, `MAC` с `interface` на `bool` в структурах запроса `UpdateAddress`, `AddAddress`, `LogicalPortAddressRequest` в sdn/logical_port/update |
|
||||
|
||||
### Исправлено
|
||||
|
||||
#### vfpool
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-871 | Тип поля `Config` в структуре запроса `wrapperUpdateRequest` с `[]string` на `string` в cloudbroker/vfpool |
|
||||
|
||||
### Удалено
|
||||
|
||||
#### grid
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-888 | Вычисляемые поля `CKey` и `Meta` из структуры ответа `RecordGrid` в cloudbroker/grid |
|
||||
|
||||
#### user
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-861 | Значение по умолчанию опционального поля `Password` в структуре запроса `CreateRequest` в cloudbroker/user |
|
||||
| BGOS-875 | Опциональное поле `Password` из структуры ответа `ItemUser` в cloudbroker/user |
|
||||
|
||||
111
README.md
111
README.md
@@ -17,6 +17,9 @@ Decort SDK - это библиотека, написанная на языке G
|
||||
- Версия 1.10.х Decort-SDK соответствует 4.2.0 версии платформы
|
||||
- Версия 1.11.х Decort-SDK соответствует 4.3.0 версии платформы
|
||||
- Версия 1.12.х Decort-SDK соответствует 4.4.0 версии платформы
|
||||
- Версия 1.13.х Decort-SDK соответствует 4.5.0 версии платформы
|
||||
- Версия 1.14.х Decort-SDK соответствует 4.6.0 версии платформы
|
||||
- Версия 1.15.х Decort-SDK соответствует 4.7.0 версии платформы
|
||||
|
||||
## Оглавление
|
||||
|
||||
@@ -27,6 +30,7 @@ Decort SDK - это библиотека, написанная на языке G
|
||||
- [Список API](#список-api)
|
||||
- [Cloudapi](#cloudapi)
|
||||
- [Cloudbroker](#cloudbroker)
|
||||
- [SDN](#sdn)
|
||||
- [Работа с библиотекой](#работа-с-библиотекой)
|
||||
- [Настройка конфигурации клиента](#настройка-конфигурации-клиента)
|
||||
- [Пример конфигурации клиента](#пример-конфигурации-клиента)
|
||||
@@ -82,6 +86,8 @@ Decort SDK - это библиотека, написанная на языке G
|
||||
- [Пример выполнения запроса](#пример-выполнения-запроса-4)
|
||||
- [Проверка соответствия версии платформы и версии dynamix](#проверка-соответствия-версии-платформы-и-версии-dynamix)
|
||||
- [Пример выполнения запроса](#пример-выполнения-запроса-5)
|
||||
- [Создание mock клиента](#создание-mock-клиента)
|
||||
- [Пример создания mock клиента](#пример-создания-mock-клиента)
|
||||
|
||||
## Установка
|
||||
|
||||
@@ -122,12 +128,12 @@ go get -u repository.basistech.ru/BASIS/decort-golang-sdk
|
||||
- `RG` - управление ресурсными группами аккаунта;
|
||||
- `Security group` – управление группами безопасности;
|
||||
- `SEP` - управление storage endpoint (sep);
|
||||
- `Stack` - получение информации о вычислительных узлах;
|
||||
- `Storage policy` – получение информации о политиках хранения;
|
||||
- `Tasks` - получение информации о ходе выполнения асинхронных задач (например, создание кластера);
|
||||
- `Trunk` - получение информации о транковых портах;
|
||||
- `VFPool` - управление пулом виртуальных сетевых функций;
|
||||
- `VINS` - управление виртуальными изолированными сетями;
|
||||
- `VGPU` - управление виртуальными графическими процессорами;
|
||||
- `Zone` - управление зонами.
|
||||
|
||||
### Cloudbroker
|
||||
@@ -159,7 +165,6 @@ go get -u repository.basistech.ru/BASIS/decort-golang-sdk
|
||||
- `RG` - управление ресурсными группами аккаунта;
|
||||
- `Security group` – управление группами безопасности;
|
||||
- `SEP` - управление storage endpoint (sep);
|
||||
- `Stack` - получение информации о вычислительных узлах;
|
||||
- `Storage policy` – управление политиками хранения;
|
||||
- `Tasks` - получение информации о ходе выполнения асинхронных задач (например, создание кластера);
|
||||
- `Trunk` - управление транковыми портами;
|
||||
@@ -174,7 +179,18 @@ go get -u repository.basistech.ru/BASIS/decort-golang-sdk
|
||||
`SDN` позволяет выполнять запросы к группе пользовательских конечных точек
|
||||
Данная группа ручек позволяет выполнять следующие операции в платформе:
|
||||
|
||||
- `AccessGroup` - управление группами доступа
|
||||
- `Access group` - управление группами доступа;
|
||||
- `Address pool` - управление пулами адресов;
|
||||
- `DefaultSecurityPolicies` - управление политиками хранения по умолчанию;
|
||||
- `ExtNet` - управление виртуальными сетями, отвечающими за внешний доступ;
|
||||
- `Hypervisors` - управление гипервизорами;
|
||||
- `FloatingIPs` - управление плавающими IP-адресами;
|
||||
- `Logical ports` - управление логическими портами;
|
||||
- `NetworkObjectGroups` - управление группами объектов сети;
|
||||
- `Routers` - управление роутерами;
|
||||
- `SecurityPolicies` - управление политиками хранения;
|
||||
- `Segments` - управление сегментами;
|
||||
- `Version` - получение информации о версии SDN;
|
||||
|
||||
## Работа с библиотекой
|
||||
|
||||
@@ -323,14 +339,14 @@ func main() {
|
||||
- `pkg/cloudapi/locations` - для `Locations`
|
||||
- `pkg/cloudapi/prometheus` - для `Prometheus`
|
||||
- `pkg/cloudapi/rg` - для `RG`
|
||||
- `pkg/cloudapi/security_group` - для `Security group`
|
||||
- `pkg/cloudapi/secgroup` - для `Security group`
|
||||
- `pkg/cloudapi/sep` - для `SEP`
|
||||
- `pkg/cloudapi/stack` - для `Stack`
|
||||
- `pkg/cloudapi/storage_policy` - для `Storage policy`
|
||||
- `pkg/cloudapi/stpolicy` - для `Storage policy`
|
||||
- `pkg/cloudapi/tasks` - для `Tasks`
|
||||
- `pkg/cloudapi/trunk` - для `Trunk`
|
||||
- `pkg/cloudapi/vfpool` - для `VFPool`
|
||||
- `pkg/cloudapi/vins` - для `VINS`
|
||||
- `pkg/cloudapi/vgpu` - для `VGPU`
|
||||
- `pkg/cloudapi/zone` - для `Zone`
|
||||
- **cloudbroker**:
|
||||
- `pkg/cloudbroker/account` - для `Account`
|
||||
@@ -355,10 +371,9 @@ func main() {
|
||||
- `pkg/cloudbroker/prometheus` - для `Prometheus`
|
||||
- `pkg/cloudbroker/resmon` - для `Resmon`
|
||||
- `pkg/cloudbroker/rg` - для `RG`
|
||||
- `pkg/cloudbroker/security_group` - для `Security group`
|
||||
- `pkg/cloudbroker/secgroup` - для `Security group`
|
||||
- `pkg/cloudbroker/sep` - для `SEP`
|
||||
- `pkg/cloudbroker/stack` - для `Stack`
|
||||
- `pkg/cloudbroker/storage_policy` - для `Storage policy`
|
||||
- `pkg/cloudbroker/stpolicy` - для `Storage policy`
|
||||
- `pkg/cloudbroker/tasks` - для `Tasks`
|
||||
- `pkg/cloudbroker/trunk` - для `Trunk`
|
||||
- `pkg/cloudbroker/user` - для `User`
|
||||
@@ -367,7 +382,18 @@ func main() {
|
||||
- `pkg/cloudbroker/vins` - для `VINS`
|
||||
- `pkg/cloudbroker/zone` - для `Zone`
|
||||
- **sdn**:
|
||||
- `pkg/sdn/access_groups` - для `AccessGroups`
|
||||
- `pkg/sdn/acsgroups` - для `Access groups`
|
||||
- `pkg/sdn/adrspools` - для `Address pool`
|
||||
- `pkg/sdn/defsecpolicies` - для `DefaultSecurityPolicies`
|
||||
- `pkg/sdn/external_networks` - для `ExtNet`
|
||||
- `pkg/sdn/hypervisors` - для `Hypervisors`
|
||||
- `pkg/sdn/flips` - для `FloatingIPs`
|
||||
- `pkg/sdn/logicalports` - для `Logical ports`
|
||||
- `pkg/sdn/netobjgroups` - для `NetworkObjectGroups`
|
||||
- `pkg/sdn/routers` - для `Routers`
|
||||
- `pkg/sdn/secpolicies` - для `SecurityPolicies`
|
||||
- `pkg/sdn/segments` - для `Segments`
|
||||
- `pkg/sdn/version` - для `Version`
|
||||
|
||||
Все поля структуры имеют описание, в которых содержится:
|
||||
|
||||
@@ -445,19 +471,9 @@ type CreateRequest struct {
|
||||
// Required: false
|
||||
Start bool `url:"start,omitempty" json:"start,omitempty"`
|
||||
|
||||
// Stack ID
|
||||
// Node ID
|
||||
// Required: false
|
||||
StackID uint64 `url:"stackId,omitempty" json:"stackId,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"`
|
||||
|
||||
|
||||
NodeID uint64 `url:"nodeId,omitempty" json:"nodeId,omitempty"`
|
||||
}
|
||||
```
|
||||
|
||||
@@ -524,12 +540,12 @@ func main() {
|
||||
- `.RG()` - для работы с `RG`
|
||||
- `.SecurityGroup()` - для работы с `Security Group`
|
||||
- `.SEP()` - для работы с `SEP`
|
||||
- `.Stack()` - для работы с `Stack`
|
||||
- `.StoragePolicy()` - для работы с `Storage Policy`
|
||||
- `.StPolicy()` - для работы с `Storage Policy`
|
||||
- `.Tasks()` - для работы с `Tasks`
|
||||
- `.Trunk()` - для работы с `Trunk`
|
||||
- `.VFPool()` - для работы с `VFPool`
|
||||
- `.VINS()` - для работы с `VINS`
|
||||
- `.VGPU()` - для работы с `VGPU`
|
||||
- `.Zone()` - для работы с `Zone`
|
||||
|
||||
Доступные методы для `.CloudBroker()`:
|
||||
@@ -558,8 +574,7 @@ func main() {
|
||||
- `.RG()` - для работы с `RG`
|
||||
- `.SecurityGroup()` - для работы с `Security Group`
|
||||
- `.SEP()` - для работы с `SEP`
|
||||
- `.Stack()` - для работы с `Stack`
|
||||
- `.StoragePolicy()` - для работы с `Storage Policy`
|
||||
- `.StPolicy()` - для работы с `Storage Policy`
|
||||
- `.Tasks()` - для работы с `Tasks`
|
||||
- `.Trunk()` - для работы с `Trunk`
|
||||
- `.User()` - для работы с `User`
|
||||
@@ -570,7 +585,18 @@ func main() {
|
||||
|
||||
Доступные методы для `.SDN()`:
|
||||
|
||||
- `.AccessGroup()` - для работы с `AccessGroup`
|
||||
- `.AccessGroup()` - для работы с `Access group`
|
||||
- `.AddressPool()` - для работы с `Addres pool`
|
||||
- `.DefaultSecurityPolicies()` - для работы с `DefaultSecurityPolicies`
|
||||
- `.ExtNet()` - для работы с `ExtNet`
|
||||
- `.Hypervisors()` - для работы с `Hypervisors`
|
||||
- `.FloatingIPs()` - для работы с `FloatingIPs`
|
||||
- `.LogicalPorts()` - для работы с `Logical ports`
|
||||
- `.NetworkObjectGroups()` - для работы с `NetworkObjectGroups`
|
||||
- `.Routers()` - для работы с `Routers`
|
||||
- `.SecurityPolicies()` - для работы с `SecurityPolicies`
|
||||
- `.Segments()` - для работы с `Segments`
|
||||
- `.Version()` - для работы с `Version`
|
||||
|
||||
3. Вызвать метод, отвечающий за выполнение запроса и передать в него:
|
||||
|
||||
@@ -1682,3 +1708,34 @@ func main(){
|
||||
checkInfo, err := client.Check()
|
||||
}
|
||||
```
|
||||
|
||||
# Создание mock клиента
|
||||
|
||||
Создание клиента происходит с помощью функции-строителя `NewMockDecortClient` из основного пакета `decort-sdk`. Функция принимает mock реализацию интерфейса interfaces.Calller, возвращает структуру `MockDecortClient`, с помощью которой можно производить unit тестирование API Decort SDK без подключения к серверу
|
||||
|
||||
#### Пример создания mock клиента
|
||||
```go
|
||||
package unit_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"go.uber.org/mock/gomock"
|
||||
decortsdk "repository.basistech.ru/BASIS/decort-golang-sdk"
|
||||
)
|
||||
|
||||
// Пример юнит тестирования на моках
|
||||
func TestClient(t *testing.T) {
|
||||
ctrl := gomock.NewController(t)
|
||||
// Создаем mock интерфейса Caller
|
||||
mockCaller := decortsdk.NewMockCaller(ctrl)
|
||||
// Создаем mock интерфейса DecortClient
|
||||
mockClient := decortsdk.NewMockDecortClient(mockCaller)
|
||||
// ....
|
||||
}
|
||||
```
|
||||
Пример юнит теста можно посмотреть в файле [samples/client/client_test.go](samples/client/client_test.go)
|
||||
|
||||
При редактировании интерфеса interface.Caller необходимо перегенерировать Mock :
|
||||
``` shell
|
||||
make gen-mock
|
||||
```
|
||||
24
check.go
24
check.go
@@ -28,7 +28,13 @@ func (de DecortClient) Check() (*CheckInfo, error) {
|
||||
|
||||
err = json.Unmarshal([]byte(strings.Replace(strings.Trim(string(res), `"`), "\\", "", -1)), &info)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
var v string
|
||||
json.Unmarshal([]byte(res), &v)
|
||||
if _, exists := constants.VersionMap[v]; exists {
|
||||
info.Version = v
|
||||
} else {
|
||||
return nil, fmt.Errorf("platform version isn't supported")
|
||||
}
|
||||
}
|
||||
|
||||
if v, ok := constants.VersionMap[info.Version]; ok {
|
||||
@@ -51,7 +57,13 @@ func (bvs BVSDecortClient) Check() (*CheckInfo, error) {
|
||||
|
||||
err = json.Unmarshal([]byte(strings.Replace(strings.Trim(string(res), `"`), "\\", "", -1)), &info)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
var v string
|
||||
json.Unmarshal([]byte(res), &v)
|
||||
if _, exists := constants.VersionMap[v]; exists {
|
||||
info.Version = v
|
||||
} else {
|
||||
return nil, fmt.Errorf("platform version isn't supported")
|
||||
}
|
||||
}
|
||||
|
||||
if v, ok := constants.VersionMap[info.Version]; ok {
|
||||
@@ -74,7 +86,13 @@ func (ldc LegacyDecortClient) Check() (*CheckInfo, error) {
|
||||
|
||||
err = json.Unmarshal([]byte(strings.Replace(strings.Trim(string(res), `"`), "\\", "", -1)), &info)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
var v string
|
||||
json.Unmarshal([]byte(res), &v)
|
||||
if _, exists := constants.VersionMap[v]; exists {
|
||||
info.Version = v
|
||||
} else {
|
||||
return nil, fmt.Errorf("platform version isn't supported")
|
||||
}
|
||||
}
|
||||
|
||||
if v, ok := constants.VersionMap[info.Version]; ok {
|
||||
|
||||
@@ -288,7 +288,7 @@ func (dc *DecortClient) do(req *http.Request, ctype string) ([]byte, error) {
|
||||
|
||||
// handle successful request
|
||||
respBytes, _ := io.ReadAll(resp.Body)
|
||||
if resp.StatusCode == 200 {
|
||||
if resp.StatusCode == 200 || resp.StatusCode == 204 {
|
||||
return respBytes, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ import (
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants"
|
||||
"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/sdn"
|
||||
)
|
||||
|
||||
// BVSDecortClient is HTTP-client for platform
|
||||
@@ -69,6 +70,11 @@ func (bdc *BVSDecortClient) CloudBroker() *cloudbroker.CloudBroker {
|
||||
return cloudbroker.New(bdc)
|
||||
}
|
||||
|
||||
// SDN builder
|
||||
func (bdc *BVSDecortClient) SDN() *sdn.SDN {
|
||||
return sdn.New(bdc)
|
||||
}
|
||||
|
||||
// DecortApiCall method for sending requests to the platform
|
||||
func (bdc *BVSDecortClient) DecortApiCall(ctx context.Context, method, url string, params interface{}) ([]byte, error) {
|
||||
var body *bytes.Buffer
|
||||
|
||||
32
client_mock.go
Normal file
32
client_mock.go
Normal file
@@ -0,0 +1,32 @@
|
||||
package decortsdk
|
||||
|
||||
import (
|
||||
"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/sdn"
|
||||
)
|
||||
|
||||
type MockDecortClient struct {
|
||||
apiCaller *MockCaller
|
||||
}
|
||||
|
||||
func NewMockDecortClient(apiCaller *MockCaller) ClientInterface {
|
||||
return &MockDecortClient{
|
||||
apiCaller: apiCaller,
|
||||
}
|
||||
}
|
||||
|
||||
// CloudAPI builder
|
||||
func (mdc *MockDecortClient) CloudAPI() *cloudapi.CloudAPI {
|
||||
return cloudapi.New(mdc.apiCaller)
|
||||
}
|
||||
|
||||
// CloudBroker builder
|
||||
func (mdc *MockDecortClient) CloudBroker() *cloudbroker.CloudBroker {
|
||||
return cloudbroker.New(mdc.apiCaller)
|
||||
}
|
||||
|
||||
// SDN builder
|
||||
func (mdc *MockDecortClient) SDN() *sdn.SDN {
|
||||
return sdn.New(mdc.apiCaller)
|
||||
}
|
||||
86
client_mock_gen.go
Normal file
86
client_mock_gen.go
Normal file
@@ -0,0 +1,86 @@
|
||||
// Code generated by MockGen. DO NOT EDIT.
|
||||
// Source: interfaces/caller.go
|
||||
//
|
||||
// Generated by this command:
|
||||
//
|
||||
// mockgen -package decortsdk -source interfaces/caller.go
|
||||
//
|
||||
|
||||
// Package decortsdk is a generated GoMock package.
|
||||
package decortsdk
|
||||
|
||||
import (
|
||||
context "context"
|
||||
reflect "reflect"
|
||||
|
||||
gomock "go.uber.org/mock/gomock"
|
||||
)
|
||||
|
||||
// MockCaller is a mock of Caller interface.
|
||||
type MockCaller struct {
|
||||
ctrl *gomock.Controller
|
||||
recorder *MockCallerMockRecorder
|
||||
isgomock struct{}
|
||||
}
|
||||
|
||||
// MockCallerMockRecorder is the mock recorder for MockCaller.
|
||||
type MockCallerMockRecorder struct {
|
||||
mock *MockCaller
|
||||
}
|
||||
|
||||
// NewMockCaller creates a new mock instance.
|
||||
func NewMockCaller(ctrl *gomock.Controller) *MockCaller {
|
||||
mock := &MockCaller{ctrl: ctrl}
|
||||
mock.recorder = &MockCallerMockRecorder{mock}
|
||||
return mock
|
||||
}
|
||||
|
||||
// EXPECT returns an object that allows the caller to indicate expected use.
|
||||
func (m *MockCaller) EXPECT() *MockCallerMockRecorder {
|
||||
return m.recorder
|
||||
}
|
||||
|
||||
// DecortApiCall mocks base method.
|
||||
func (m *MockCaller) DecortApiCall(ctx context.Context, method, url string, params any) ([]byte, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "DecortApiCall", ctx, method, url, params)
|
||||
ret0, _ := ret[0].([]byte)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// DecortApiCall indicates an expected call of DecortApiCall.
|
||||
func (mr *MockCallerMockRecorder) DecortApiCall(ctx, method, url, params any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DecortApiCall", reflect.TypeOf((*MockCaller)(nil).DecortApiCall), ctx, method, url, params)
|
||||
}
|
||||
|
||||
// DecortApiCallCtype mocks base method.
|
||||
func (m *MockCaller) DecortApiCallCtype(ctx context.Context, method, url, ctype string, params any) ([]byte, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "DecortApiCallCtype", ctx, method, url, ctype, params)
|
||||
ret0, _ := ret[0].([]byte)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// DecortApiCallCtype indicates an expected call of DecortApiCallCtype.
|
||||
func (mr *MockCallerMockRecorder) DecortApiCallCtype(ctx, method, url, ctype, params any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DecortApiCallCtype", reflect.TypeOf((*MockCaller)(nil).DecortApiCallCtype), ctx, method, url, ctype, params)
|
||||
}
|
||||
|
||||
// DecortApiCallMP mocks base method.
|
||||
func (m *MockCaller) DecortApiCallMP(ctx context.Context, method, url string, params any) ([]byte, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "DecortApiCallMP", ctx, method, url, params)
|
||||
ret0, _ := ret[0].([]byte)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// DecortApiCallMP indicates an expected call of DecortApiCallMP.
|
||||
func (mr *MockCallerMockRecorder) DecortApiCallMP(ctx, method, url, params any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DecortApiCallMP", reflect.TypeOf((*MockCaller)(nil).DecortApiCallMP), ctx, method, url, params)
|
||||
}
|
||||
18
go.mod
18
go.mod
@@ -1,21 +1,25 @@
|
||||
module repository.basistech.ru/BASIS/decort-golang-sdk
|
||||
|
||||
go 1.20
|
||||
go 1.24.0
|
||||
|
||||
require (
|
||||
github.com/go-playground/validator/v10 v10.11.2
|
||||
github.com/go-playground/validator/v10 v10.28.0
|
||||
github.com/google/go-querystring v1.1.0
|
||||
github.com/joho/godotenv v1.5.1
|
||||
github.com/stretchr/testify v1.9.0
|
||||
go.uber.org/mock v0.6.0
|
||||
gopkg.in/yaml.v3 v3.0.1
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||
github.com/gabriel-vasile/mimetype v1.4.10 // indirect
|
||||
github.com/go-playground/locales v0.14.1 // indirect
|
||||
github.com/go-playground/universal-translator v0.18.1 // indirect
|
||||
github.com/google/go-cmp v0.5.9 // indirect
|
||||
github.com/kr/text v0.2.0 // indirect
|
||||
github.com/leodido/go-urn v1.2.1 // indirect
|
||||
golang.org/x/crypto v0.15.0 // indirect
|
||||
golang.org/x/sys v0.14.0 // indirect
|
||||
golang.org/x/text v0.14.0 // indirect
|
||||
github.com/leodido/go-urn v1.4.0 // indirect
|
||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||
golang.org/x/crypto v0.42.0 // indirect
|
||||
golang.org/x/sys v0.36.0 // indirect
|
||||
golang.org/x/text v0.29.0 // indirect
|
||||
)
|
||||
|
||||
40
go.sum
40
go.sum
@@ -1,13 +1,15 @@
|
||||
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/gabriel-vasile/mimetype v1.4.10 h1:zyueNbySn/z8mJZHLt6IPw0KoZsiQNszIpU+bX4+ZK0=
|
||||
github.com/gabriel-vasile/mimetype v1.4.10/go.mod h1:d+9Oxyo1wTzWdyVUPMmXFvp4F9tea18J8ufA774AB3s=
|
||||
github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s=
|
||||
github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
|
||||
github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA=
|
||||
github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=
|
||||
github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY=
|
||||
github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=
|
||||
github.com/go-playground/validator/v10 v10.11.2 h1:q3SHpufmypg+erIExEKUmsgmhDTyhcJ38oeKGACXohU=
|
||||
github.com/go-playground/validator/v10 v10.11.2/go.mod h1:NieE624vt4SCTJtD87arVLvdmjPAeV8BQlHtMnw9D7s=
|
||||
github.com/go-playground/validator/v10 v10.28.0 h1:Q7ibns33JjyW48gHkuFT91qX48KG0ktULL6FgHdG688=
|
||||
github.com/go-playground/validator/v10 v10.28.0/go.mod h1:GoI6I1SjPBh9p7ykNE/yj3fFYbyDOpwMn5KXd+m2hUU=
|
||||
github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
|
||||
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||
@@ -15,26 +17,22 @@ github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD
|
||||
github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU=
|
||||
github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
|
||||
github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
|
||||
github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0=
|
||||
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
||||
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
||||
github.com/leodido/go-urn v1.2.1 h1:BqpAaACuzVSgi/VLzGZIobT2z4v53pjosyNd9Yv6n/w=
|
||||
github.com/leodido/go-urn v1.2.1/go.mod h1:zt4jvISO2HfUBqxjfIshjdMTYS56ZS/qv49ictyFfxY=
|
||||
github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ=
|
||||
github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/rogpeppe/go-internal v1.8.0 h1:FCbCCtXNOY3UtUuHUYaghJg4y7Fd14rXifAYUAtL9R8=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
|
||||
golang.org/x/crypto v0.15.0 h1:frVn1TEaCEaZcn3Tmd7Y2b5KKPaZ+I32Q2OA3kYp5TA=
|
||||
golang.org/x/crypto v0.15.0/go.mod h1:4ChreQoLWfG3xLDer1WdlH5NdlQ3+mwnQq1YTKY+72g=
|
||||
golang.org/x/sys v0.14.0 h1:Vz7Qs629MkJkGyHxUlRHizWJRG2j8fbQKjELVSNhy7Q=
|
||||
golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
|
||||
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
|
||||
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
|
||||
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
||||
go.uber.org/mock v0.6.0 h1:hyF9dfmbgIX5EfOdasqLsWD6xqpNZlXblLB/Dbnwv3Y=
|
||||
go.uber.org/mock v0.6.0/go.mod h1:KiVJ4BqZJaMj4svdfmHM0AUx4NJYO8ZNpPnZn1Z+BBU=
|
||||
golang.org/x/crypto v0.42.0 h1:chiH31gIWm57EkTXpwnqf8qeuMUi0yekh6mT2AvFlqI=
|
||||
golang.org/x/crypto v0.42.0/go.mod h1:4+rDnOTJhQCx2q7/j6rAN5XDw8kPjeaXEUR2eL94ix8=
|
||||
golang.org/x/sys v0.36.0 h1:KVRy2GtZBrk1cBYA7MKu5bEZFxQk4NIDV6RLVcC8o0k=
|
||||
golang.org/x/sys v0.36.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
|
||||
golang.org/x/text v0.29.0 h1:1neNs90w9YzJ9BocxfsQNHKuAT4pkghyXc4nhZ6sJvk=
|
||||
golang.org/x/text v0.29.0/go.mod h1:7MhJOA9CD2qZyOKYazxdYMF85OwPdEr9jTtBpO7ydH4=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
|
||||
@@ -28,5 +28,12 @@ var FileName = map[string]string{
|
||||
var K8sValues = []string{"labels", "taints", "annotations, additionalSANs"}
|
||||
|
||||
var VersionMap = map[string]string{
|
||||
"4.7.0": "-",
|
||||
"4.6.0": "-",
|
||||
"4.5.0": "-",
|
||||
"4.4.0": "-",
|
||||
"4.3.0": "-",
|
||||
"4.2.0": "-",
|
||||
"4.1.1": "-",
|
||||
"4.1.0": "-",
|
||||
}
|
||||
|
||||
@@ -86,13 +86,6 @@ func computeModeValidator(fe validator.FieldLevel) bool {
|
||||
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.
|
||||
func computeNetTypeValidator(fe validator.FieldLevel) bool {
|
||||
fieldValue := fe.Field().String()
|
||||
@@ -151,13 +144,6 @@ func computeDataDisksValidator(fe validator.FieldLevel) bool {
|
||||
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.
|
||||
func flipgroupClientTypeValidator(fe validator.FieldLevel) bool {
|
||||
fieldValue := fe.Field().String()
|
||||
@@ -165,11 +151,11 @@ func flipgroupClientTypeValidator(fe validator.FieldLevel) bool {
|
||||
return IsInSlice(fieldValue, flipgroupClientTypeValues)
|
||||
}
|
||||
|
||||
// kvmNetTypeValidator is used to validate NetType field.
|
||||
func kvmNetTypeValidator(fe validator.FieldLevel) bool {
|
||||
// massCreateTypeValidator is used to validate net type field when mass creating kvm
|
||||
func massCreateTypeValidator(fe validator.FieldLevel) bool {
|
||||
fieldValue := fe.Field().String()
|
||||
|
||||
return IsInSlice(fieldValue, kvmNetTypeValues)
|
||||
return IsInSlice(fieldValue, massCreateNetTypeValues)
|
||||
}
|
||||
|
||||
// lbAlgorithmValidator is used to validate Algorithm field.
|
||||
@@ -426,6 +412,13 @@ func deviceValidator(fe validator.FieldLevel) bool {
|
||||
return IsInSlice(fieldValue, deviceValues)
|
||||
}
|
||||
|
||||
// ipTypesValidator is used to validate ip types version fields
|
||||
func ipTypesValidator(fe validator.FieldLevel) bool {
|
||||
fieldValue := fe.Field().String()
|
||||
|
||||
return IsInSlice(fieldValue, ipTypeValues)
|
||||
}
|
||||
|
||||
// ValidateRAM checks if request contains RAM value that is positive integer divisible by divisibility passed.
|
||||
// It is recommended to pass constants.RAM_DIVISIBILITY as divisility arguement
|
||||
func ValidateRAM(r interfaces.RequestWithRAM, divisibility uint64) error {
|
||||
@@ -457,3 +450,37 @@ func trunkTagsValidator(fe validator.FieldLevel) bool {
|
||||
}
|
||||
return uint64(numFieldValue) >= uint64(trunkTagsMin) && uint64(numFieldValue) <= uint64(trunkTagsMax)
|
||||
}
|
||||
|
||||
// addressPoolNetTypeValidator is used to validate NetAddressType fields
|
||||
func addressPoolNetTypeValidator(fe validator.FieldLevel) bool {
|
||||
fieldValue := fe.Field().String()
|
||||
|
||||
return IsInSlice(fieldValue, addressPoolNetTypeValues)
|
||||
}
|
||||
|
||||
// sepTechStatusValidator is used to validate SepTechStatus fields
|
||||
func sepTechStatusValidator(fe validator.FieldLevel) bool {
|
||||
fieldValue := fe.Field().String()
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
@@ -86,12 +86,6 @@ func errorMessage(fe validator.FieldError) string {
|
||||
fe.Field(),
|
||||
joinValues(computeModeValues))
|
||||
|
||||
case "computeDiskType":
|
||||
return fmt.Sprintf("%s %s must be one of the following: %s",
|
||||
prefix,
|
||||
fe.Field(),
|
||||
joinValues(computeDiskTypeValues))
|
||||
|
||||
case "mtu":
|
||||
return fmt.Sprint(prefix, fe.Field(), "must be ", mtuMin, "-", mtuMax)
|
||||
|
||||
@@ -122,13 +116,6 @@ func errorMessage(fe validator.FieldError) string {
|
||||
fe.Field(),
|
||||
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
|
||||
case "flipgroupClientType":
|
||||
return fmt.Sprintf("%s %s must be one of the following: %s",
|
||||
@@ -142,12 +129,12 @@ func errorMessage(fe validator.FieldError) string {
|
||||
prefix,
|
||||
fe.Field())
|
||||
|
||||
// KVM_X86 Validators
|
||||
case "kvmNetType":
|
||||
// KVM_X86 Mass create validators
|
||||
case "massCreateNetType":
|
||||
return fmt.Sprintf("%s %s must be one of the following: %s",
|
||||
prefix,
|
||||
fe.Field(),
|
||||
joinValues(kvmNetTypeValues))
|
||||
joinValues(massCreateNetTypeValues))
|
||||
|
||||
// LB Validators
|
||||
case "lbAlgorithm":
|
||||
@@ -348,11 +335,30 @@ func errorMessage(fe validator.FieldError) string {
|
||||
prefix,
|
||||
fe.Field())
|
||||
|
||||
// addressPoolNetTypeValidator validator
|
||||
case "addressPoolNetTypeValidator":
|
||||
return fmt.Sprintf("%s %s must be one of the following: %s",
|
||||
prefix,
|
||||
fe.Field(),
|
||||
joinValues(addressPoolNetTypeValues))
|
||||
|
||||
case "device":
|
||||
return fmt.Sprintf("%s %s must be one of the following: %s",
|
||||
prefix,
|
||||
fe.Field(),
|
||||
joinValues(deviceValues))
|
||||
|
||||
case "ipTypes":
|
||||
return fmt.Sprintf("%s %s must be one of the following: %s",
|
||||
prefix,
|
||||
fe.Field(),
|
||||
joinValues(ipTypeValues))
|
||||
|
||||
case "sepTechStatus":
|
||||
return fmt.Sprintf("%s %s must be one of the following: %s",
|
||||
prefix,
|
||||
fe.Field(),
|
||||
joinValues(sepTechStatusValues))
|
||||
}
|
||||
|
||||
return fe.Error()
|
||||
|
||||
@@ -86,11 +86,6 @@ func registerAllValidators(validate *validator.Validate) error {
|
||||
return err
|
||||
}
|
||||
|
||||
err = validate.RegisterValidation("computeDiskType", computeDiskTypeValidator)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = validate.RegisterValidation("computeNetType", computeNetTypeValidator)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -111,17 +106,12 @@ func registerAllValidators(validate *validator.Validate) error {
|
||||
return err
|
||||
}
|
||||
|
||||
err = validate.RegisterValidation("diskType", diskTypeValidator)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = validate.RegisterValidation("flipgroupClientType", flipgroupClientTypeValidator)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = validate.RegisterValidation("kvmNetType", kvmNetTypeValidator)
|
||||
err = validate.RegisterValidation("massCreateNetType", massCreateTypeValidator)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -301,5 +291,35 @@ func registerAllValidators(validate *validator.Validate) error {
|
||||
return err
|
||||
}
|
||||
|
||||
err = validate.RegisterValidation("addressPoolNetTypeValidator", addressPoolNetTypeValidator)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = validate.RegisterValidation("ipTypes", ipTypesValidator)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = validate.RegisterValidation("sepTechStatus", sepTechStatusValidator)
|
||||
if err != nil {
|
||||
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
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -7,24 +7,21 @@ var (
|
||||
resTypesValues = []string{"compute", "vins", "k8s", "openshift", "lb", "flipgroup"}
|
||||
protoValues = []string{"tcp", "udp"}
|
||||
|
||||
accountCUTypeValues = []string{"CU_M", "CU_C", "CU_D", "CU_DM", "CU_S", "CU_A", "CU_NO", "CU_I", "CU_NP"}
|
||||
accountCUTypeValues = []string{"CU_M", "CU_C", "CU_D", "CU_DM", "CU_I", "gpu_units"}
|
||||
|
||||
bserviceModeValues = []string{"ABSOLUTE", "RELATIVE"}
|
||||
|
||||
computeTopologyValues = []string{"compute", "node"}
|
||||
computePolicyValues = []string{"RECOMMENDED", "REQUIRED"}
|
||||
computeModeValues = []string{"EQ", "EN", "ANY"}
|
||||
computeDiskTypeValues = []string{"D", "B"}
|
||||
computeNetTypeValues = []string{"EXTNET", "VINS"}
|
||||
computex86NetTypeValues = []string{"EXTNET", "VINS", "VFNIC", "DPDK", "SDN", "EMPTY", "TRUNK"}
|
||||
computeOrderValues = []string{"cdrom", "network", "hd"}
|
||||
computeDataDisksValues = []string{"KEEP", "DETACH", "DESTROY"}
|
||||
|
||||
diskTypeValues = []string{"B", "T", "D"}
|
||||
|
||||
flipgroupClientTypeValues = []string{"compute", "vins"}
|
||||
|
||||
kvmNetTypeValues = []string{"EXTNET", "VINS", "NONE"}
|
||||
massCreateNetTypeValues = []string{"EXTNET", "VINS", "TRUNK"}
|
||||
kvmx86NetTypeValues = []string{"EXTNET", "VINS", "EMPTY", "VFNIC", "DPDK", "SDN", "TRUNK"}
|
||||
|
||||
lbAlgorithmValues = []string{"roundrobin", "static-rr", "leastconn"}
|
||||
@@ -66,7 +63,7 @@ var (
|
||||
|
||||
loaderTypeValues = []string{"linux", "windows", "unknown"}
|
||||
|
||||
sepTypeValues = []string{"hitachi", "dorado", "tatlin", "shared", "local", "des"}
|
||||
sepTypeValues = []string{"hitachi", "dorado", "tatlin", "shared", "local", "des", "ustor"}
|
||||
|
||||
languageValues = []string{"ru", "en"}
|
||||
|
||||
@@ -77,10 +74,16 @@ var (
|
||||
securityGroupDirectionValues = []string{"inbound", "outbound"}
|
||||
securityGroupEthertypeValues = []string{"IPv4", "IPv6"}
|
||||
securityGroupProtocolValues = []string{"icmp", "tcp", "udp"}
|
||||
|
||||
addressPoolNetTypeValues = []string{"IPv4", "IPv6", "MAC"}
|
||||
|
||||
ipTypeValues = []string{"v4, v6"}
|
||||
|
||||
sepTechStatusValues = []string{"ENABLED", "DISABLED"}
|
||||
)
|
||||
|
||||
const (
|
||||
mtuMin = 1
|
||||
mtuMin = 1500
|
||||
mtuMax = 9216
|
||||
|
||||
trunkTagsMin = 1
|
||||
|
||||
@@ -18,6 +18,7 @@ import (
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants"
|
||||
"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/sdn"
|
||||
)
|
||||
|
||||
// LegacyDecortClient is Legacy HTTP-client for platform
|
||||
@@ -67,6 +68,11 @@ func (ldc *LegacyDecortClient) CloudBroker() *cloudbroker.CloudBroker {
|
||||
return cloudbroker.New(ldc)
|
||||
}
|
||||
|
||||
// SDN builder
|
||||
func (ldc *LegacyDecortClient) SDN() *sdn.SDN {
|
||||
return sdn.New(ldc)
|
||||
}
|
||||
|
||||
// DecortApiCall method for sending requests to the platform
|
||||
func (ldc *LegacyDecortClient) DecortApiCall(ctx context.Context, method, url string, params interface{}) ([]byte, error) {
|
||||
// get token
|
||||
|
||||
@@ -27,11 +27,8 @@ type GetConsumedCloudUnitsByTypeRequest struct {
|
||||
// - 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_S: returns consumed primary storage (NAS) in TB
|
||||
// - CU_A: returns consumed secondary storage (Archive) in TB
|
||||
// - CU_NO: returns sent/received network transfer in operator in GB
|
||||
// - CU_NP: returns sent/received network transfer peering 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 {
|
||||
|
||||
@@ -68,9 +68,6 @@ type ResourceLimits struct {
|
||||
// RAM size, MB
|
||||
CUM float64 `json:"CU_M"`
|
||||
|
||||
// Traffic volume, GB
|
||||
CUNP float64 `json:"CU_NP"`
|
||||
|
||||
// Number of graphics cores
|
||||
GPUUnits float64 `json:"gpu_units"`
|
||||
|
||||
@@ -98,6 +95,9 @@ type ItemAccount struct {
|
||||
// Deleted time
|
||||
DeletedTime uint64 `json:"deletedTime"`
|
||||
|
||||
// Deleted by
|
||||
DeletedBy string `json:"deletedBy"`
|
||||
|
||||
// Description
|
||||
Description string `json:"desc"`
|
||||
|
||||
@@ -110,6 +110,9 @@ type ItemAccount struct {
|
||||
// Status
|
||||
Status string `json:"status"`
|
||||
|
||||
// Updated by
|
||||
UpdatedBy string `json:"updatedBy"`
|
||||
|
||||
// Updated time
|
||||
UpdatedTime uint64 `json:"updatedTime"`
|
||||
|
||||
@@ -124,6 +127,18 @@ type ListAccounts struct {
|
||||
EntryCount uint64 `json:"entryCount"`
|
||||
}
|
||||
|
||||
// Policy
|
||||
type Policy struct {
|
||||
// Size of the disk
|
||||
DiskSize float64 `json:"disksize"`
|
||||
|
||||
// Max size of the disk
|
||||
DiskSizeMax float64 `json:"disksizemax"`
|
||||
|
||||
// SEPs used
|
||||
SEPs map[string]map[string]DiskUsage `json:"seps"`
|
||||
}
|
||||
|
||||
// Resources used
|
||||
type Resource struct {
|
||||
// Number of cores
|
||||
@@ -138,12 +153,12 @@ type Resource struct {
|
||||
// Number of External IPs
|
||||
ExtIPs int64 `json:"extips"`
|
||||
|
||||
// External traffic
|
||||
ExtTraffic int64 `json:"exttraffic"`
|
||||
|
||||
// Number of grafic cores
|
||||
GPU int64 `json:"gpu"`
|
||||
|
||||
// Policies
|
||||
Policies map[string]Policy `json:"policies"`
|
||||
|
||||
// Number of RAM
|
||||
RAM int64 `json:"ram"`
|
||||
|
||||
@@ -218,9 +233,6 @@ type RecordAccount struct {
|
||||
// DCLocation
|
||||
DCLocation string `json:"DCLocation"`
|
||||
|
||||
// CKey
|
||||
CKey string `json:"_ckey"`
|
||||
|
||||
// Access control list
|
||||
ACL []RecordACL `json:"acl"`
|
||||
|
||||
@@ -240,7 +252,7 @@ type RecordAccount struct {
|
||||
CPUAllocationParameter string `json:"cpu_allocation_parameter"`
|
||||
|
||||
// CPU allocation ratio
|
||||
CPUAllocationRatio float64 `json:"cpu_allocation_ratio"`
|
||||
CPUAllocationRatio uint64 `json:"cpu_allocation_ratio"`
|
||||
|
||||
// Created by
|
||||
CreatedBy string `json:"createdBy"`
|
||||
@@ -293,6 +305,9 @@ type RecordAccount struct {
|
||||
// UniqPools
|
||||
UniqPools []interface{} `json:"uniqPools"`
|
||||
|
||||
// Updated By
|
||||
UpdatedBy string `json:"updatedBy"`
|
||||
|
||||
// Updated time
|
||||
UpdatedTime uint64 `json:"updatedTime"`
|
||||
|
||||
@@ -542,9 +557,6 @@ type LimitsRG struct {
|
||||
// Number of External IPs
|
||||
ExtIPs int64 `json:"extips"`
|
||||
|
||||
// External traffic
|
||||
ExtTraffic int64 `json:"exttraffic"`
|
||||
|
||||
// Number of grafic cores
|
||||
GPU int64 `json:"gpu"`
|
||||
|
||||
@@ -553,6 +565,9 @@ type LimitsRG struct {
|
||||
|
||||
// SEPs
|
||||
SEPs uint64 `json:"seps"`
|
||||
|
||||
// Policies
|
||||
Policies map[string]Policy `json:"policies"`
|
||||
}
|
||||
|
||||
// Main information about resource group
|
||||
|
||||
@@ -34,10 +34,6 @@ type UpdateRequest struct {
|
||||
// Required: false
|
||||
MaxCPUCapacity int64 `url:"maxCPUCapacity,omitempty" json:"maxCPUCapacity,omitempty"`
|
||||
|
||||
// Max sent/received network transfer peering
|
||||
// Required: false
|
||||
MaxNetworkPeerTransfer int64 `url:"maxNetworkPeerTransfer,omitempty" json:"maxNetworkPeerTransfer,omitempty"`
|
||||
|
||||
// Max number of assigned public IPs
|
||||
// Required: false
|
||||
MaxNumPublicIP int64 `url:"maxNumPublicIP,omitempty" json:"maxNumPublicIP,omitempty"`
|
||||
|
||||
81
pkg/cloudapi/audit/filter.go
Normal file
81
pkg/cloudapi/audit/filter.go
Normal file
@@ -0,0 +1,81 @@
|
||||
package audit
|
||||
|
||||
// FilterByID returns ListAudits with specified ID.
|
||||
func (la ListAudits) FilterByID(guid string) ListAudits {
|
||||
predicate := func(ia ItemAudit) bool {
|
||||
return ia.GUID == guid
|
||||
}
|
||||
|
||||
return la.FilterFunc(predicate)
|
||||
}
|
||||
|
||||
// FilterByCall returns ListAudits with specified call.
|
||||
func (la ListAudits) FilterByCall(call string) ListAudits {
|
||||
predicate := func(ic ItemAudit) bool {
|
||||
return ic.Call == call
|
||||
}
|
||||
|
||||
return la.FilterFunc(predicate)
|
||||
}
|
||||
|
||||
// FilterByCorrelationID returns ListAudits with specified correlation id.
|
||||
func (la ListAudits) FilterByCorrelationID(correlationID string) ListAudits {
|
||||
predicate := func(ic ItemAudit) bool {
|
||||
return ic.CorrelationID == correlationID
|
||||
}
|
||||
|
||||
return la.FilterFunc(predicate)
|
||||
}
|
||||
|
||||
// FilterByRemoteAddr returns ListAudits with specified remote address.
|
||||
func (la ListAudits) FilterByRemoteAddr(remoteAddr string) ListAudits {
|
||||
predicate := func(ic ItemAudit) bool {
|
||||
return ic.RemoteAddr == remoteAddr
|
||||
}
|
||||
|
||||
return la.FilterFunc(predicate)
|
||||
}
|
||||
|
||||
// FilterByUser returns ListAudits with specified user name.
|
||||
func (la ListAudits) FilterByUser(user string) ListAudits {
|
||||
predicate := func(ic ItemAudit) bool {
|
||||
return ic.User == user
|
||||
}
|
||||
|
||||
return la.FilterFunc(predicate)
|
||||
}
|
||||
|
||||
// FilterByStatusCode return ListAudits with specified status code.
|
||||
func (la ListAudits) FilterByStatusCode(statusCode uint64) ListAudits {
|
||||
predicate := func(ic ItemAudit) bool {
|
||||
return ic.StatusCode == statusCode
|
||||
}
|
||||
|
||||
return la.FilterFunc(predicate)
|
||||
|
||||
}
|
||||
|
||||
// FilterFunc allows filtering ListAudits based on a user-specified predicate.
|
||||
func (la ListAudits) FilterFunc(predicate func(ItemAudit) bool) ListAudits {
|
||||
var result ListAudits
|
||||
|
||||
for _, item := range la.Data {
|
||||
if predicate(item) {
|
||||
result.Data = append(result.Data, item)
|
||||
}
|
||||
}
|
||||
|
||||
result.EntryCount = uint64(len(result.Data))
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
// FindOne returns first found ItemAudit
|
||||
// If none was found, returns an empty struct.
|
||||
func (la ListAudits) FindOne() ItemAudit {
|
||||
if len(la.Data) == 0 {
|
||||
return ItemAudit{}
|
||||
}
|
||||
|
||||
return la.Data[0]
|
||||
}
|
||||
115
pkg/cloudapi/audit/filter_test.go
Normal file
115
pkg/cloudapi/audit/filter_test.go
Normal file
@@ -0,0 +1,115 @@
|
||||
package audit
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
var audits = ListAudits{
|
||||
Data: []ItemAudit{
|
||||
{
|
||||
Args: "[]",
|
||||
Call: "/restmachine/cloudapi/audit/linkedJobs",
|
||||
GUID: "550e8400-e29b-41d4-a716-446655440001",
|
||||
CorrelationID: "550e8400-e29b-41d4-a716-446655440001",
|
||||
Kwargs: `{\"audit_guid\":\"dd8623a1-a887-48c1-a500-c10210d404cf\"}`,
|
||||
RemoteAddr: "192.168.1.100",
|
||||
ResponseTime: 1,
|
||||
Result: `[]`,
|
||||
StatusCode: 200,
|
||||
Timestamp: 1640995200,
|
||||
TimestampEnd: 1640995201,
|
||||
User: "test@example.com",
|
||||
TTL: "2025-07-31T14:22:57.028000",
|
||||
},
|
||||
{
|
||||
Args: "[]",
|
||||
Call: "/restmachine/cloudapi/audit/test",
|
||||
GUID: "550e8400-e29b-41d4-a716-446655440002",
|
||||
CorrelationID: "550e8400-e29b-41d4-a716-446655440002",
|
||||
Kwargs: `{\"audit_guid\":\"dd8623a1-a887-48c1-a500-c10210d404cf\"}`,
|
||||
RemoteAddr: "192.168.1.105",
|
||||
ResponseTime: 5,
|
||||
Result: `[]`,
|
||||
StatusCode: 400,
|
||||
Timestamp: 1640995200,
|
||||
TimestampEnd: 1640995201,
|
||||
User: "test2@example.com",
|
||||
TTL: "2025-07-31T14:22:57.028000",
|
||||
},
|
||||
},
|
||||
EntryCount: 2,
|
||||
}
|
||||
|
||||
func TestFilterByID(t *testing.T) {
|
||||
actual := audits.FilterByID("550e8400-e29b-41d4-a716-446655440002").FindOne()
|
||||
|
||||
if actual.GUID != "550e8400-e29b-41d4-a716-446655440002" {
|
||||
t.Fatal("expected GUID 550e8400-e29b-41d4-a716-446655440002, found: ", actual.GUID)
|
||||
}
|
||||
|
||||
actualEmpty := audits.FilterByID("")
|
||||
|
||||
if len(actualEmpty.Data) != 0 {
|
||||
t.Fatal("expected empty, actual: ", len(actualEmpty.Data))
|
||||
}
|
||||
}
|
||||
|
||||
func TestFilterByCorrelationID(t *testing.T) {
|
||||
actual := audits.FilterByCorrelationID("550e8400-e29b-41d4-a716-446655440002").FindOne()
|
||||
|
||||
if actual.CorrelationID != "550e8400-e29b-41d4-a716-446655440002" {
|
||||
t.Fatal("expected GUID 550e8400-e29b-41d4-a716-446655440002, found: ", actual.CorrelationID)
|
||||
}
|
||||
|
||||
actualEmpty := audits.FilterByCorrelationID("")
|
||||
|
||||
if len(actualEmpty.Data) != 0 {
|
||||
t.Fatal("expected empty, actual: ", len(actualEmpty.Data))
|
||||
}
|
||||
}
|
||||
|
||||
func TestFilterByRemoteAddr(t *testing.T) {
|
||||
actual := audits.FilterByRemoteAddr("192.168.1.100").FindOne()
|
||||
|
||||
if actual.RemoteAddr != "192.168.1.100" {
|
||||
t.Fatal("expected remote address 192.168.1.100, found: ", actual.RemoteAddr)
|
||||
}
|
||||
|
||||
actualEmpty := audits.FilterByRemoteAddr("")
|
||||
|
||||
if len(actualEmpty.Data) != 0 {
|
||||
t.Fatal("expected empty, actual: ", len(actualEmpty.Data))
|
||||
}
|
||||
}
|
||||
|
||||
func TestFilterByUser(t *testing.T) {
|
||||
actual := audits.FilterByUser("test@example.com").FindOne()
|
||||
|
||||
if actual.User != "test@example.com" {
|
||||
t.Fatal("expected user test@example.com, found: ", actual.RemoteAddr)
|
||||
}
|
||||
|
||||
actualEmpty := audits.FilterByUser("")
|
||||
|
||||
if len(actualEmpty.Data) != 0 {
|
||||
t.Fatal("expected empty, actual: ", len(actualEmpty.Data))
|
||||
}
|
||||
}
|
||||
|
||||
func TestFilterByCall(t *testing.T) {
|
||||
actual := audits.FilterByCall("/restmachine/cloudapi/audit/test").FindOne()
|
||||
|
||||
if actual.Call != "/restmachine/cloudapi/audit/test" {
|
||||
t.Fatal("expected call /restmachine/cloudapi/audit/test, found: ", actual.Call)
|
||||
}
|
||||
}
|
||||
|
||||
func TestFilterByStatusCode(t *testing.T) {
|
||||
actual := audits.FilterByStatusCode(200)
|
||||
|
||||
for _, item := range actual.Data {
|
||||
if item.StatusCode != 200 {
|
||||
t.Fatal("expected 200 status code, found: ", item.StatusCode)
|
||||
}
|
||||
}
|
||||
}
|
||||
124
pkg/cloudapi/audit/list.go
Normal file
124
pkg/cloudapi/audit/list.go
Normal file
@@ -0,0 +1,124 @@
|
||||
package audit
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// ListRequest struct to give list of account audits
|
||||
type ListRequest struct {
|
||||
|
||||
// Find all audits after point in time (unixtime)
|
||||
// Required: false
|
||||
TimestampAt uint64 `url:"timestamp_at,omitempty" json:"timestamp_at,omitempty"`
|
||||
|
||||
// Find all audits before point in time (unixtime)
|
||||
// Required: false
|
||||
TimestampTo uint64 `url:"timestamp_to,omitempty" json:"timestamp_to,omitempty"`
|
||||
|
||||
// Find by user (Mongo RegExp supported)
|
||||
// Required: false
|
||||
User string `url:"user,omitempty" json:"user,omitempty"`
|
||||
|
||||
// Find by api endpoint (Mongo RegExp supported)
|
||||
// Required: false
|
||||
Call string `url:"call,omitempty" json:"call,omitempty"`
|
||||
|
||||
// Find by request id
|
||||
// Required: false
|
||||
RequestID string `url:"request_id,omitempty" json:"request_id,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"`
|
||||
|
||||
// Sort by one of supported fields, format +|-(field)
|
||||
// Required: false
|
||||
SortBy string `url:"sort_by,omitempty" json:"sort_by,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"`
|
||||
|
||||
// Find by resource group id
|
||||
// Required: false
|
||||
RGID uint64 `url:"resgroup_id,omitempty" json:"resgroup_id,omitempty"`
|
||||
|
||||
// Find by compute id
|
||||
// Required: false
|
||||
ComputeID uint64 `url:"compute_id,omitempty" json:"compute_id,omitempty"`
|
||||
|
||||
// Find by account id
|
||||
// Required: false
|
||||
AccountID uint64 `url:"account_id,omitempty" json:"account_id,omitempty"`
|
||||
|
||||
// Find by vins id
|
||||
// Required: false
|
||||
VINSID uint64 `url:"vins_id,omitempty" json:"vins_id,omitempty"`
|
||||
|
||||
// Find by service id
|
||||
// Required: false
|
||||
ServiceID uint64 `url:"service_id,omitempty" json:"service_id,omitempty"`
|
||||
|
||||
// Find by k8s id
|
||||
// Required: false
|
||||
K8SID uint64 `url:"k8s_id,omitempty" json:"k8s_id,omitempty"`
|
||||
|
||||
// Find by flipgroup id
|
||||
// Required: false
|
||||
FLIPGroupID uint64 `url:"flipgroup_id,omitempty" json:"flipgroup_id,omitempty"`
|
||||
|
||||
// Find by load balancer id
|
||||
// Required: false
|
||||
LBID uint64 `url:"lb_id,omitempty" json:"lb_id,omitempty"`
|
||||
|
||||
// Find by sep id
|
||||
// Required: false
|
||||
SEPID uint64 `url:"sep_id,omitempty" json:"sep_id,omitempty"`
|
||||
|
||||
// Exclude audit lines from response
|
||||
// Required: false
|
||||
ExcludeAuditLines bool `url:"exclude_audit_lines,omitempty" json:"exclude_audit_lines,omitempty"`
|
||||
}
|
||||
|
||||
// List gets audit records for the specified account object
|
||||
func (a Audit) List(ctx context.Context, req ListRequest) (*ListAudits, error) {
|
||||
|
||||
res, err := a.ListRaw(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
list := ListAudits{}
|
||||
|
||||
err = json.Unmarshal(res, &list)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &list, nil
|
||||
}
|
||||
|
||||
// ListRaw gets list of audit records an array of bytes
|
||||
func (a Audit) ListRaw(ctx context.Context, req ListRequest) ([]byte, error) {
|
||||
|
||||
if err := validators.ValidateRequest(req); err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudapi/audit/list"
|
||||
|
||||
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
return res, err
|
||||
}
|
||||
@@ -42,3 +42,54 @@ type RecordAudit struct {
|
||||
// User
|
||||
User string `json:"user"`
|
||||
}
|
||||
|
||||
// Main info about audit
|
||||
type ItemAudit struct {
|
||||
// Args
|
||||
Args string `json:"args"`
|
||||
|
||||
// Call
|
||||
Call string `json:"call"`
|
||||
|
||||
// GUID
|
||||
GUID string `json:"guid"`
|
||||
|
||||
// Correlation ID
|
||||
CorrelationID string `json:"correlation_id"`
|
||||
|
||||
// Kwargs
|
||||
Kwargs string `json:"kwargs"`
|
||||
|
||||
// RemoteAddr
|
||||
RemoteAddr string `json:"remote_addr"`
|
||||
|
||||
// Response time
|
||||
ResponseTime float64 `json:"responsetime"`
|
||||
|
||||
// Result
|
||||
Result string `json:"result"`
|
||||
|
||||
// Status code
|
||||
StatusCode uint64 `json:"statuscode"`
|
||||
|
||||
// Timestamp
|
||||
Timestamp float64 `json:"timestamp"`
|
||||
|
||||
// Timestamp End
|
||||
TimestampEnd float64 `json:"timestampEnd"`
|
||||
|
||||
// User
|
||||
User string `json:"user"`
|
||||
|
||||
// TTL
|
||||
TTL string `json:"_ttl"`
|
||||
}
|
||||
|
||||
// List of audits
|
||||
type ListAudits struct {
|
||||
// Data
|
||||
Data []ItemAudit `json:"data"`
|
||||
|
||||
// EntryCount
|
||||
EntryCount uint64 `json:"entryCount"`
|
||||
}
|
||||
|
||||
@@ -38,10 +38,6 @@ type GroupAddRequest struct {
|
||||
// Required: true
|
||||
ImageID uint64 `url:"imageId" json:"imageId" validate:"required"`
|
||||
|
||||
// Compute driver like a KVM_X86, etc.
|
||||
// Required: true
|
||||
Driver string `url:"driver" json:"driver" validate:"required"`
|
||||
|
||||
// Storage endpoint provider ID
|
||||
// Required: false
|
||||
SEPID uint64 `url:"sepId,omitempty" json:"sepId,omitempty"`
|
||||
@@ -71,6 +67,7 @@ type GroupAddRequest struct {
|
||||
UserData string `url:"userData,omitempty" json:"userData,omitempty"`
|
||||
|
||||
// Chipset "i440fx" or "Q35
|
||||
// Default value : Q35
|
||||
// Required: false
|
||||
Chipset string `url:"chipset,omitempty" json:"chipset,omitempty" validate:"chipset,omitempty"`
|
||||
|
||||
|
||||
@@ -24,16 +24,16 @@ type GroupResizeRequest struct {
|
||||
|
||||
// Chipset for new computes, either i440fx or Q35 (i440fx by default)
|
||||
// Available values : i440fx, Q35
|
||||
//Default value : i440fx
|
||||
//Required: true
|
||||
Chipset string `url:"chipset" json:"chipset" validate:"required,chipset"`
|
||||
// Default value : Q35
|
||||
// Required: false
|
||||
Chipset string `url:"chipset,omitempty" json:"chipset,omitempty" validate:"omitempty,chipset"`
|
||||
|
||||
// Either delta or absolute value of computes
|
||||
// Should be one of:
|
||||
// - ABSOLUTE
|
||||
// - RELATIVE
|
||||
// Required: true
|
||||
Mode string `url:"mode" json:"mode" validate:"bserviceMode"`
|
||||
// Required: false
|
||||
Mode string `url:"mode,omitempty" json:"mode,omitempty" validate:"omitempty,bserviceMode"`
|
||||
}
|
||||
|
||||
// GroupResize resize the group by changing the number of computes
|
||||
|
||||
@@ -119,8 +119,8 @@ type ItemCompute struct {
|
||||
// Resource group ID
|
||||
RGID uint64 `json:"rgId"`
|
||||
|
||||
// StackID
|
||||
StackID uint64 `json:"stackId"`
|
||||
// NodeID
|
||||
NodeID uint64 `json:"node_id"`
|
||||
|
||||
// Status
|
||||
Status string `json:"status"`
|
||||
|
||||
@@ -3,7 +3,6 @@ package compute
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
@@ -19,24 +18,51 @@ type AbortSharedSnapshotMergeRequest struct {
|
||||
Label string `url:"label" json:"label" validate:"required"`
|
||||
}
|
||||
|
||||
type wrapperAbortSharedSnapshotMergeRequest struct {
|
||||
AbortSharedSnapshotMergeRequest
|
||||
AsyncMode bool `url:"asyncMode"`
|
||||
}
|
||||
|
||||
// AbortSharedSnapshotMerge shared snapshots merge abort
|
||||
func (c Compute) AbortSharedSnapshotMerge(ctx context.Context, req AbortSharedSnapshotMergeRequest) (bool, error) {
|
||||
func (c Compute) AbortSharedSnapshotMerge(ctx context.Context, req AbortSharedSnapshotMergeRequest) (string, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
reqWrapped := wrapperAbortSharedSnapshotMergeRequest{
|
||||
AbortSharedSnapshotMergeRequest: req,
|
||||
AsyncMode: false,
|
||||
}
|
||||
|
||||
url := "/cloudapi/compute/abort_shared_snapshot_merge"
|
||||
|
||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
||||
if err != nil {
|
||||
return false, err
|
||||
return "", err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseBool(string(res))
|
||||
if err != nil {
|
||||
return false, err
|
||||
return string(res), nil
|
||||
}
|
||||
|
||||
return result, nil
|
||||
// AbortSharedSnapshotMergeAsync shared snapshots merge abort in async mode
|
||||
func (c Compute) AbortSharedSnapshotMergeAsync(ctx context.Context, req AbortSharedSnapshotMergeRequest) (string, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
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
|
||||
}
|
||||
|
||||
@@ -38,9 +38,8 @@ type AffinityRuleAddRequest struct {
|
||||
Key string `url:"key" json:"key" validate:"required"`
|
||||
|
||||
// Value that must match the key to be taken into account when analyzing this rule
|
||||
// Required: false
|
||||
// Not required on purpose: despite required tag on platform, empty string is allowed
|
||||
Value string `url:"value" json:"value"`
|
||||
// Required: true
|
||||
Value string `url:"value" json:"value" validate:"required"`
|
||||
}
|
||||
|
||||
// AffinityRuleAdd add affinity rule
|
||||
|
||||
@@ -38,9 +38,8 @@ type AffinityRuleRemoveRequest struct {
|
||||
Key string `url:"key" json:"key" validate:"required"`
|
||||
|
||||
// Value that must match the key to be taken into account when analyzing this rule
|
||||
// Required: false
|
||||
// Not required on purpose: despite required tag on platform, empty string is allowed
|
||||
Value string `url:"value" json:"value"`
|
||||
// Required: true
|
||||
Value string `url:"value" json:"value" validate:"required"`
|
||||
}
|
||||
|
||||
// AffinityRuleRemove remove affinity rule
|
||||
|
||||
@@ -38,9 +38,8 @@ type AntiAffinityRuleAddRequest struct {
|
||||
Key string `url:"key" json:"key" validate:"required"`
|
||||
|
||||
// Value that must match the key to be taken into account when analyzing this rule
|
||||
// Required: false
|
||||
// Not required on purpose: despite required tag on platform, empty string is allowed
|
||||
Value string `url:"value" json:"value"`
|
||||
// Required: true
|
||||
Value string `url:"value" json:"value" validate:"required"`
|
||||
}
|
||||
|
||||
// AntiAffinityRuleAdd add anti affinity rule
|
||||
|
||||
@@ -38,9 +38,8 @@ type AntiAffinityRuleRemoveRequest struct {
|
||||
Key string `url:"key" json:"key" validate:"required"`
|
||||
|
||||
// Value that must match the key to be taken into account when analyzing this rule
|
||||
// Required: false
|
||||
// Not required on purpose: despite required tag on platform, empty string is allowed
|
||||
Value string `url:"value" json:"value"`
|
||||
// Required: true
|
||||
Value string `url:"value" json:"value" validate:"required"`
|
||||
}
|
||||
|
||||
// AntiAffinityRuleRemove remove anti affinity rule
|
||||
|
||||
@@ -15,6 +15,12 @@ type CDEjectRequest struct {
|
||||
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
|
||||
func (c Compute) CDEject(ctx context.Context, req CDEjectRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
@@ -22,9 +28,14 @@ func (c Compute) CDEject(ctx context.Context, req CDEjectRequest) (bool, error)
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
reqWrapped := wrapperCDEjectRequest{
|
||||
CDEjectRequest: req,
|
||||
AsyncMode: false,
|
||||
}
|
||||
|
||||
url := "/cloudapi/compute/cdEject"
|
||||
|
||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
@@ -33,5 +44,28 @@ func (c Compute) CDEject(ctx context.Context, req CDEjectRequest) (bool, error)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
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,6 +19,12 @@ type CDInsertRequest struct {
|
||||
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
|
||||
func (c Compute) CDInsert(ctx context.Context, req CDInsertRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
@@ -26,9 +32,14 @@ func (c Compute) CDInsert(ctx context.Context, req CDInsertRequest) (bool, error
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
reqWrapped := wrapperCDInsertRequest{
|
||||
CDInsertRequest: req,
|
||||
AsyncMode: false,
|
||||
}
|
||||
|
||||
url := "/cloudapi/compute/cdInsert"
|
||||
|
||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
@@ -37,5 +48,28 @@ func (c Compute) CDInsert(ctx context.Context, req CDInsertRequest) (bool, error
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
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,6 +31,12 @@ type ChangeIPRequest struct {
|
||||
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
|
||||
func (c Compute) ChangeIP(ctx context.Context, req ChangeIPRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
@@ -38,9 +44,14 @@ func (c Compute) ChangeIP(ctx context.Context, req ChangeIPRequest) (bool, error
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
reqWrapped := wrapperChangeIPRequest{
|
||||
ChangeIPRequest: req,
|
||||
AsyncMode: false,
|
||||
}
|
||||
|
||||
url := "/cloudapi/compute/changeIp"
|
||||
|
||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
@@ -52,3 +63,25 @@ func (c Compute) ChangeIP(ctx context.Context, req ChangeIPRequest) (bool, error
|
||||
|
||||
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,8 +3,9 @@ package compute
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// ChangeLinkStateRequest struct to change link state
|
||||
@@ -23,6 +24,12 @@ type ChangeLinkStateRequest struct {
|
||||
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
|
||||
func (c Compute) ChangeLinkState(ctx context.Context, req ChangeLinkStateRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
@@ -30,9 +37,14 @@ func (c Compute) ChangeLinkState(ctx context.Context, req ChangeLinkStateRequest
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
reqWrapped := wrapperChangeLinkStateRequest{
|
||||
ChangeLinkStateRequest: req,
|
||||
AsyncMode: false,
|
||||
}
|
||||
|
||||
url := "/cloudapi/compute/changeLinkState"
|
||||
|
||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
@@ -41,5 +53,28 @@ func (c Compute) ChangeLinkState(ctx context.Context, req ChangeLinkStateRequest
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
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,6 +23,12 @@ type ChangeMTURequest struct {
|
||||
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
|
||||
func (c Compute) ChangeMTU(ctx context.Context, req ChangeMTURequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
@@ -30,9 +36,14 @@ func (c Compute) ChangeMTU(ctx context.Context, req ChangeMTURequest) (bool, err
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
reqWrapped := wrapperChangeMTURequest{
|
||||
ChangeMTURequest: req,
|
||||
AsyncMode: false,
|
||||
}
|
||||
|
||||
url := "/cloudapi/compute/change_mtu"
|
||||
|
||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
@@ -44,3 +55,25 @@ func (c Compute) ChangeMTU(ctx context.Context, req ChangeMTURequest) (bool, err
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
@@ -24,7 +24,13 @@ type ChangeSecGroupsRequest struct {
|
||||
|
||||
// Flag indicating whether security groups are enabled for this interface
|
||||
// Required: false
|
||||
EnableSecGroups bool `url:"enable_secgroups,omitempty" json:"enable_secgroups,omitempty"`
|
||||
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
|
||||
@@ -34,9 +40,14 @@ func (c Compute) ChangeSecGroups(ctx context.Context, req ChangeSecGroupsRequest
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
reqWrapped := wrapperChangeSecGroupsRequest{
|
||||
ChangeSecGroupsRequest: req,
|
||||
AsyncMode: false,
|
||||
}
|
||||
|
||||
url := "/cloudapi/compute/change_security_groups"
|
||||
|
||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
@@ -48,3 +59,25 @@ func (c Compute) ChangeSecGroups(ctx context.Context, req ChangeSecGroupsRequest
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
@@ -3,8 +3,8 @@ 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"
|
||||
)
|
||||
|
||||
@@ -18,6 +18,10 @@ type CloneRequest struct {
|
||||
// Required: true
|
||||
Name string `url:"name" json:"name" validate:"required"`
|
||||
|
||||
// ID of the Storage Policy
|
||||
// Required: true
|
||||
StoragePolicyID uint64 `url:"storage_policy_id" json:"storage_policy_id" validate:"required"`
|
||||
|
||||
// Timestamp of the parent's snapshot to create clone from
|
||||
// Required: false
|
||||
SnapshotTimestamp uint64 `url:"snapshotTimestamp,omitempty" json:"snapshotTimestamp,omitempty"`
|
||||
@@ -30,26 +34,62 @@ type CloneRequest struct {
|
||||
// Default: false
|
||||
// Required: false
|
||||
Force bool `url:"force" json:"force"`
|
||||
|
||||
// The name of the pool to migrate disks to
|
||||
// Required: false
|
||||
PoolName string `url:"pool_name" json:"pool_name"`
|
||||
|
||||
// The ID of the SEP to migrate disks to
|
||||
// Required: false
|
||||
SEPID uint64 `url:"sep_id" json:"sep_id"`
|
||||
}
|
||||
|
||||
type wrapperCloneRequest struct {
|
||||
CloneRequest
|
||||
|
||||
AsyncMode bool `url:"asyncMode" json:"asyncMode"`
|
||||
}
|
||||
|
||||
// Clone clones compute instance
|
||||
func (c Compute) Clone(ctx context.Context, req CloneRequest) (uint64, error) {
|
||||
func (c Compute) Clone(ctx context.Context, req CloneRequest) (string, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return 0, validators.ValidationErrors(validators.GetErrors(err))
|
||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
reqWrapped := wrapperCloneRequest{
|
||||
CloneRequest: req,
|
||||
AsyncMode: false,
|
||||
}
|
||||
|
||||
url := "/cloudapi/compute/clone"
|
||||
|
||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
res, err := c.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, reqWrapped)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
return "", err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseUint(string(res), 10, 64)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
return string(res), nil
|
||||
}
|
||||
|
||||
return result, 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 {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return string(res), nil
|
||||
}
|
||||
|
||||
41
pkg/cloudapi/compute/clone_abort.go
Normal file
41
pkg/cloudapi/compute/clone_abort.go
Normal file
@@ -0,0 +1,41 @@
|
||||
package compute
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// CloneAbortRequest struct to abort a compute clone
|
||||
type CloneAbortRequest struct {
|
||||
// ID of compute instance
|
||||
// Required: true
|
||||
ComputeID uint64 `url:"compute_id" json:"compute_id" validate:"required"`
|
||||
}
|
||||
|
||||
// CloneAbort aborts a compute clone
|
||||
func (c Compute) CloneAbort(ctx context.Context, req CloneAbortRequest) (ListCloneAbort, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudapi/compute/clone_abort"
|
||||
|
||||
res, err := c.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var result ListCloneAbort
|
||||
|
||||
err = json.Unmarshal(res, &result)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
40
pkg/cloudapi/compute/clone_status.go
Normal file
40
pkg/cloudapi/compute/clone_status.go
Normal file
@@ -0,0 +1,40 @@
|
||||
package compute
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// GetCloneStatusRequest struct to get information about compute clone status
|
||||
type GetCloneStatusRequest struct {
|
||||
// ID of compute instance
|
||||
// Required: true
|
||||
ComputeID uint64 `url:"compute_id" json:"compute_id" validate:"required"`
|
||||
}
|
||||
|
||||
// GetCloneStatus gets information about compute clone status as a RecordCloneStatus struct
|
||||
func (c Compute) GetCloneStatus(ctx context.Context, req GetCloneStatusRequest) ([]RecordCloneStatus, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudapi/compute/clone_status"
|
||||
|
||||
res, err := c.client.DecortApiCall(ctx, http.MethodGet, url, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
cloneStatus := make([]RecordCloneStatus, 0)
|
||||
|
||||
err = json.Unmarshal(res, &cloneStatus)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return cloneStatus, nil
|
||||
}
|
||||
@@ -3,7 +3,6 @@ package compute
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
@@ -27,47 +26,15 @@ type wrapperCreateTemplateRequest struct {
|
||||
}
|
||||
|
||||
// CreateTemplate create template from compute instance
|
||||
func (c Compute) CreateTemplate(ctx context.Context, req CreateTemplateRequest) (uint64, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return 0, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
reqWrapped := wrapperCreateTemplateRequest{
|
||||
CreateTemplateRequest: req,
|
||||
AsyncMode: false,
|
||||
}
|
||||
|
||||
url := "/cloudapi/compute/createTemplate"
|
||||
|
||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseUint(string(res), 10, 64)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// CreateTemplateAsync create template from compute instance
|
||||
func (c Compute) CreateTemplateAsync(ctx context.Context, req CreateTemplateRequest) (string, error) {
|
||||
func (c Compute) CreateTemplate(ctx context.Context, req CreateTemplateRequest) (string, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
reqWrapped := wrapperCreateTemplateRequest{
|
||||
CreateTemplateRequest: req,
|
||||
AsyncMode: true,
|
||||
}
|
||||
|
||||
url := "/cloudapi/compute/createTemplate"
|
||||
|
||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
@@ -23,6 +23,12 @@ type DeleteRequest struct {
|
||||
DetachDisks bool `url:"detachDisks,omitempty" json:"detachDisks,omitempty"`
|
||||
}
|
||||
|
||||
type wrapperDeleteRequest struct {
|
||||
DeleteRequest
|
||||
|
||||
AsyncMode bool `url:"asyncMode"`
|
||||
}
|
||||
|
||||
// Delete deletes compute
|
||||
func (c Compute) Delete(ctx context.Context, req DeleteRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
@@ -30,9 +36,14 @@ func (c Compute) Delete(ctx context.Context, req DeleteRequest) (bool, error) {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
reqWrapped := wrapperDeleteRequest{
|
||||
DeleteRequest: req,
|
||||
AsyncMode: false,
|
||||
}
|
||||
|
||||
url := "/cloudapi/compute/delete"
|
||||
|
||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
@@ -44,3 +55,25 @@ func (c Compute) Delete(ctx context.Context, req DeleteRequest) (bool, error) {
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
39
pkg/cloudapi/compute/delete_cpu_alignment_profile.go
Normal file
39
pkg/cloudapi/compute/delete_cpu_alignment_profile.go
Normal file
@@ -0,0 +1,39 @@
|
||||
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,6 +15,12 @@ type DisableRequest struct {
|
||||
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
|
||||
}
|
||||
|
||||
type wrapperDisableRequest struct {
|
||||
DisableRequest
|
||||
|
||||
AsyncMode bool `url:"asyncMode"`
|
||||
}
|
||||
|
||||
// Disable disables compute
|
||||
func (c Compute) Disable(ctx context.Context, req DisableRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
@@ -22,9 +28,14 @@ func (c Compute) Disable(ctx context.Context, req DisableRequest) (bool, error)
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
reqWrapped := wrapperDisableRequest{
|
||||
DisableRequest: req,
|
||||
AsyncMode: false,
|
||||
}
|
||||
|
||||
url := "/cloudapi/compute/disable"
|
||||
|
||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
@@ -36,3 +47,25 @@ func (c Compute) Disable(ctx context.Context, req DisableRequest) (bool, error)
|
||||
|
||||
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,13 +26,6 @@ type DiskAddRequest struct {
|
||||
// Required: true
|
||||
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
|
||||
// By default the same with boot disk
|
||||
// Required: false
|
||||
@@ -50,6 +43,24 @@ type DiskAddRequest struct {
|
||||
// Specify image id for create disk from template
|
||||
// Required: false
|
||||
ImageID uint64 `url:"imageId,omitempty" json:"imageId,omitempty"`
|
||||
|
||||
// Desired PCI slot (hex string, e.g. "0x1A")
|
||||
// Required: false
|
||||
PCISlot string `url:"pci_slot,omitempty" json:"pci_slot,omitempty"`
|
||||
|
||||
// Desired bus number (hex string, e.g. "0x03")
|
||||
// Required: false
|
||||
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
|
||||
@@ -59,9 +70,14 @@ func (c Compute) DiskAdd(ctx context.Context, req DiskAddRequest) (uint64, error
|
||||
return 0, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
reqWrapped := wrapperDiskAddRequest{
|
||||
DiskAddRequest: req,
|
||||
AsyncMode: false,
|
||||
}
|
||||
|
||||
url := "/cloudapi/compute/diskAdd"
|
||||
|
||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
@@ -73,3 +89,25 @@ func (c Compute) DiskAdd(ctx context.Context, req DiskAddRequest) (uint64, error
|
||||
|
||||
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,9 +18,23 @@ type DiskAttachRequest struct {
|
||||
// Required: true
|
||||
DiskID uint64 `url:"diskId" json:"diskId" validate:"required"`
|
||||
|
||||
// Type of the disk B;D
|
||||
// Desired PCI slot (hex string, e.g. "0x1A")
|
||||
// Required: false
|
||||
DiskType string `url:"diskType,omitempty" json:"diskType,omitempty" validate:"omitempty,computeDiskType"`
|
||||
PCISlot string `url:"pci_slot,omitempty" json:"pci_slot,omitempty"`
|
||||
|
||||
// Desired bus number (hex string, e.g. "0x03")
|
||||
// Required: false
|
||||
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
|
||||
@@ -30,9 +44,14 @@ func (c Compute) DiskAttach(ctx context.Context, req DiskAttachRequest) (bool, e
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
reqWrapped := wrapperDiskAttachRequest{
|
||||
DiskAttachRequest: req,
|
||||
AsyncMode: false,
|
||||
}
|
||||
|
||||
url := "/cloudapi/compute/diskAttach"
|
||||
|
||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
@@ -44,3 +63,25 @@ func (c Compute) DiskAttach(ctx context.Context, req DiskAttachRequest) (bool, e
|
||||
|
||||
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,6 +23,12 @@ type DiskDelRequest struct {
|
||||
Permanently bool `url:"permanently" json:"permanently"`
|
||||
}
|
||||
|
||||
type wrapperDiskDelRequest struct {
|
||||
DiskDelRequest
|
||||
|
||||
AsyncMode bool `url:"asyncMode"`
|
||||
}
|
||||
|
||||
// DiskDel delete disk and detach from compute
|
||||
func (c Compute) DiskDel(ctx context.Context, req DiskDelRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
@@ -30,9 +36,14 @@ func (c Compute) DiskDel(ctx context.Context, req DiskDelRequest) (bool, error)
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
reqWrapped := wrapperDiskDelRequest{
|
||||
DiskDelRequest: req,
|
||||
AsyncMode: false,
|
||||
}
|
||||
|
||||
url := "/cloudapi/compute/diskDel"
|
||||
|
||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
@@ -44,3 +55,25 @@ func (c Compute) DiskDel(ctx context.Context, req DiskDelRequest) (bool, error)
|
||||
|
||||
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,6 +19,12 @@ type DiskDetachRequest struct {
|
||||
DiskID uint64 `url:"diskId" json:"diskId" validate:"required"`
|
||||
}
|
||||
|
||||
type wrapperDiskDetachRequest struct {
|
||||
DiskDetachRequest
|
||||
|
||||
AsyncMode bool `url:"asyncMode"`
|
||||
}
|
||||
|
||||
// DiskDetach detach disk from compute
|
||||
func (c Compute) DiskDetach(ctx context.Context, req DiskDetachRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
@@ -26,9 +32,14 @@ func (c Compute) DiskDetach(ctx context.Context, req DiskDetachRequest) (bool, e
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
reqWrapped := wrapperDiskDetachRequest{
|
||||
DiskDetachRequest: req,
|
||||
AsyncMode: false,
|
||||
}
|
||||
|
||||
url := "/cloudapi/compute/diskDetach"
|
||||
|
||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
@@ -40,3 +51,25 @@ func (c Compute) DiskDetach(ctx context.Context, req DiskDetachRequest) (bool, e
|
||||
|
||||
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,6 +23,12 @@ type DiskQOSRequest struct {
|
||||
Limits string `url:"limits" json:"limits" validate:"required"`
|
||||
}
|
||||
|
||||
type wrapperDiskQOSRequest struct {
|
||||
DiskQOSRequest
|
||||
|
||||
AsyncMode bool `url:"asyncMode"`
|
||||
}
|
||||
|
||||
// DiskQOS change QoS of the disk
|
||||
func (c Compute) DiskQOS(ctx context.Context, req DiskQOSRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
@@ -30,9 +36,14 @@ func (c Compute) DiskQOS(ctx context.Context, req DiskQOSRequest) (bool, error)
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
reqWrapped := wrapperDiskQOSRequest{
|
||||
DiskQOSRequest: req,
|
||||
AsyncMode: false,
|
||||
}
|
||||
|
||||
url := "/cloudapi/compute/diskQos"
|
||||
|
||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
@@ -44,3 +55,25 @@ func (c Compute) DiskQOS(ctx context.Context, req DiskQOSRequest) (bool, error)
|
||||
|
||||
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,6 +23,12 @@ type DiskResizeRequest struct {
|
||||
Size uint64 `url:"size" json:"size" validate:"required"`
|
||||
}
|
||||
|
||||
type wrapperDiskResizeRequest struct {
|
||||
DiskResizeRequest
|
||||
|
||||
AsyncMode bool `url:"asyncMode"`
|
||||
}
|
||||
|
||||
// DiskResize change disk size
|
||||
func (c Compute) DiskResize(ctx context.Context, req DiskResizeRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
@@ -30,9 +36,14 @@ func (c Compute) DiskResize(ctx context.Context, req DiskResizeRequest) (bool, e
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
reqWrapped := wrapperDiskResizeRequest{
|
||||
DiskResizeRequest: req,
|
||||
AsyncMode: false,
|
||||
}
|
||||
|
||||
url := "/cloudapi/compute/diskResize"
|
||||
|
||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
@@ -44,3 +55,25 @@ func (c Compute) DiskResize(ctx context.Context, req DiskResizeRequest) (bool, e
|
||||
|
||||
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,6 +23,12 @@ type DiskSwitchToReplicationRequest struct {
|
||||
StopReplication bool `url:"stopReplication" json:"stopReplication"`
|
||||
}
|
||||
|
||||
type wrapperDiskSwitchToReplicationRequest struct {
|
||||
DiskSwitchToReplicationRequest
|
||||
|
||||
AsyncMode bool `url:"asyncMode"`
|
||||
}
|
||||
|
||||
// DiskSwitchToReplication switches disk to it's replication
|
||||
func (c Compute) DiskSwitchToReplication(ctx context.Context, req DiskSwitchToReplicationRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
@@ -30,9 +36,14 @@ func (c Compute) DiskSwitchToReplication(ctx context.Context, req DiskSwitchToRe
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
reqWrapped := wrapperDiskSwitchToReplicationRequest{
|
||||
DiskSwitchToReplicationRequest: req,
|
||||
AsyncMode: false,
|
||||
}
|
||||
|
||||
url := "/cloudapi/compute/diskSwitchToReplication"
|
||||
|
||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
@@ -44,3 +55,25 @@ func (c Compute) DiskSwitchToReplication(ctx context.Context, req DiskSwitchToRe
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
@@ -55,7 +55,6 @@ var computes = ListComputes{
|
||||
GID: 212,
|
||||
GUID: 48500,
|
||||
ID: 48500,
|
||||
ImageID: 9884,
|
||||
Interfaces: []ItemVNFInterface{},
|
||||
LockStatus: "UNLOCKED",
|
||||
ManagerID: 0,
|
||||
@@ -63,7 +62,7 @@ var computes = ListComputes{
|
||||
MigrationJob: 0,
|
||||
Milestones: 363500,
|
||||
Name: "test",
|
||||
PinnedToStack: true,
|
||||
PinnedToNode: true,
|
||||
RAM: 4096,
|
||||
ReferenceID: "c7cb19ac-af4a-4067-852f-c5572949207e",
|
||||
Registered: true,
|
||||
@@ -82,7 +81,6 @@ var computes = ListComputes{
|
||||
UserManaged: true,
|
||||
VGPUs: []uint64{},
|
||||
VINSConnected: 0,
|
||||
VirtualImageID: 0,
|
||||
ZoneID: 1,
|
||||
},
|
||||
{
|
||||
@@ -118,7 +116,6 @@ var computes = ListComputes{
|
||||
GID: 212,
|
||||
GUID: 48556,
|
||||
ID: 48556,
|
||||
ImageID: 9884,
|
||||
Interfaces: []ItemVNFInterface{},
|
||||
LockStatus: "UNLOCKED",
|
||||
ManagerID: 0,
|
||||
@@ -129,7 +126,7 @@ var computes = ListComputes{
|
||||
RAM: 4096,
|
||||
ReferenceID: "a542c449-5b1c-4f90-88c5-7bb5f8ae68ff",
|
||||
Registered: true,
|
||||
PinnedToStack: true,
|
||||
PinnedToNode: true,
|
||||
ResName: "compute-48556",
|
||||
RGID: 79727,
|
||||
RGName: "sdk_negative_fields_test",
|
||||
@@ -145,7 +142,6 @@ var computes = ListComputes{
|
||||
UserManaged: true,
|
||||
VGPUs: []uint64{},
|
||||
VINSConnected: 0,
|
||||
VirtualImageID: 0,
|
||||
ZoneID: 5,
|
||||
},
|
||||
},
|
||||
|
||||
46
pkg/cloudapi/compute/get_cpu_alignment_profile.go
Normal file
46
pkg/cloudapi/compute/get_cpu_alignment_profile.go
Normal file
@@ -0,0 +1,46 @@
|
||||
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,6 +15,12 @@ type GuestAgentDisableRequest struct {
|
||||
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
|
||||
func (c Compute) GuestAgentDisable(ctx context.Context, req GuestAgentDisableRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
@@ -22,9 +28,14 @@ func (c Compute) GuestAgentDisable(ctx context.Context, req GuestAgentDisableReq
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
reqWrapped := wrapperGuestAgentDisableRequest{
|
||||
GuestAgentDisableRequest: req,
|
||||
AsyncMode: false,
|
||||
}
|
||||
|
||||
url := "/cloudapi/compute/guest_agent_disable"
|
||||
|
||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
@@ -36,3 +47,25 @@ func (c Compute) GuestAgentDisable(ctx context.Context, req GuestAgentDisableReq
|
||||
|
||||
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,6 +15,12 @@ type GuestAgentEnableRequest struct {
|
||||
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
|
||||
func (c Compute) GuestAgentEnable(ctx context.Context, req GuestAgentEnableRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
@@ -22,9 +28,14 @@ func (c Compute) GuestAgentEnable(ctx context.Context, req GuestAgentEnableReque
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
reqWrapped := wrapperGuestAgentEnableRequest{
|
||||
GuestAgentEnableRequest: req,
|
||||
AsyncMode: false,
|
||||
}
|
||||
|
||||
url := "/cloudapi/compute/guest_agent_enable"
|
||||
|
||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
@@ -36,3 +47,25 @@ func (c Compute) GuestAgentEnable(ctx context.Context, req GuestAgentEnableReque
|
||||
|
||||
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,6 +23,12 @@ type GuestAgentExecuteRequest struct {
|
||||
Arguments string `url:"arguments" json:"arguments" validate:"required"`
|
||||
}
|
||||
|
||||
type wrapperGuestAgentExecuteRequest struct {
|
||||
GuestAgentExecuteRequest
|
||||
|
||||
AsyncMode bool `url:"asyncMode"`
|
||||
}
|
||||
|
||||
// Execute guest agent command
|
||||
func (c Compute) GuestAgentExecuteRequest(ctx context.Context, req GuestAgentExecuteRequest) (map[string]interface{}, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
@@ -30,9 +36,14 @@ func (c Compute) GuestAgentExecuteRequest(ctx context.Context, req GuestAgentExe
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
reqWrapped := wrapperGuestAgentExecuteRequest{
|
||||
GuestAgentExecuteRequest: req,
|
||||
AsyncMode: false,
|
||||
}
|
||||
|
||||
url := "/cloudapi/compute/guest_agent_execute"
|
||||
|
||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -46,3 +57,25 @@ func (c Compute) GuestAgentExecuteRequest(ctx context.Context, req GuestAgentExe
|
||||
|
||||
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,6 +15,12 @@ type GuestAgentFeatureUpdateRequest struct {
|
||||
ComputeID uint64 `url:"compute_id" json:"compute_id" validate:"required"`
|
||||
}
|
||||
|
||||
type wrapperGuestAgentFeatureUpdateRequest struct {
|
||||
GuestAgentFeatureUpdateRequest
|
||||
|
||||
AsyncMode bool `url:"asyncMode"`
|
||||
}
|
||||
|
||||
// Feature update guest agent
|
||||
func (c Compute) GuestAgentFeatureUpdate(ctx context.Context, req GuestAgentFeatureUpdateRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
@@ -22,9 +28,14 @@ func (c Compute) GuestAgentFeatureUpdate(ctx context.Context, req GuestAgentFeat
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
reqWrapped := wrapperGuestAgentFeatureUpdateRequest{
|
||||
GuestAgentFeatureUpdateRequest: req,
|
||||
AsyncMode: false,
|
||||
}
|
||||
|
||||
url := "/cloudapi/compute/guest_agent_feature_update"
|
||||
|
||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
@@ -36,3 +47,25 @@ func (c Compute) GuestAgentFeatureUpdate(ctx context.Context, req GuestAgentFeat
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
@@ -19,6 +19,12 @@ type MigrateToZoneRequest struct {
|
||||
ZoneID uint64 `url:"zoneId" json:"zoneId " validate:"required"`
|
||||
}
|
||||
|
||||
type wrapperMigrateToZoneRequest struct {
|
||||
MigrateToZoneRequest
|
||||
|
||||
AsyncMode bool `url:"asyncMode"`
|
||||
}
|
||||
|
||||
// MoveToRG moves compute instance to new resource group
|
||||
func (c Compute) MigrateToZone(ctx context.Context, req MigrateToZoneRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
@@ -26,9 +32,14 @@ func (c Compute) MigrateToZone(ctx context.Context, req MigrateToZoneRequest) (b
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
reqWrapped := wrapperMigrateToZoneRequest{
|
||||
MigrateToZoneRequest: req,
|
||||
AsyncMode: false,
|
||||
}
|
||||
|
||||
url := "/cloudapi/compute/migrateToZone"
|
||||
|
||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
@@ -40,3 +51,25 @@ func (c Compute) MigrateToZone(ctx context.Context, req MigrateToZoneRequest) (b
|
||||
|
||||
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,6 +83,9 @@ type ListUsageSnapshots []ItemUsageSnapshot
|
||||
|
||||
// Main information about snapshot
|
||||
type ItemSnapshot struct {
|
||||
// Compute info
|
||||
Compute RecordCompute `json:"compute"`
|
||||
|
||||
// List disk ID
|
||||
Disks []uint64 `json:"disks"`
|
||||
|
||||
@@ -92,6 +95,9 @@ type ItemSnapshot struct {
|
||||
// Label
|
||||
Label string `json:"label"`
|
||||
|
||||
// Memory dump image ID
|
||||
MemoryDumpImage uint64 `json:"memory_dump_image"`
|
||||
|
||||
// Timestamp
|
||||
Timestamp uint64 `json:"timestamp"`
|
||||
}
|
||||
@@ -161,6 +167,9 @@ type RecordAffinityRelations struct {
|
||||
|
||||
// Main information about attached network
|
||||
type RecordNetAttach struct {
|
||||
// Bus number
|
||||
BusNumber uint64 `json:"bus_number"`
|
||||
|
||||
// Connection ID
|
||||
ConnID uint64 `json:"connId"`
|
||||
|
||||
@@ -173,6 +182,9 @@ type RecordNetAttach struct {
|
||||
// Enabled
|
||||
Enabled bool `json:"enabled"`
|
||||
|
||||
// Enable security groups
|
||||
EnableSecGroups bool `json:"enable_secgroups"`
|
||||
|
||||
// FLIPGroup ID
|
||||
FLIPGroupID uint64 `json:"flipgroupId"`
|
||||
|
||||
@@ -182,12 +194,18 @@ type RecordNetAttach struct {
|
||||
// IP address
|
||||
IPAddress string `json:"ipAddress"`
|
||||
|
||||
// Libvirt Settings
|
||||
LibvirtSettings LibvirtSettings `json:"libvirtSettings"`
|
||||
|
||||
// Listen SSH
|
||||
ListenSSH bool `json:"listenSsh"`
|
||||
|
||||
// MAC
|
||||
MAC string `json:"mac"`
|
||||
|
||||
// Maximum transmission unit
|
||||
MTU uint64 `json:"mtu"`
|
||||
|
||||
// Name
|
||||
Name string `json:"name"`
|
||||
|
||||
@@ -200,9 +218,18 @@ type RecordNetAttach struct {
|
||||
// Network type
|
||||
NetType string `json:"netType"`
|
||||
|
||||
// Node id
|
||||
NodeID int `json:"nodeId"`
|
||||
|
||||
// PCI slot
|
||||
PCISlot int64 `json:"pciSlot"`
|
||||
|
||||
// SDN interface ID
|
||||
SDNInterfaceID string `json:"sdn_interface_id"`
|
||||
|
||||
// List of security groups
|
||||
SecurityGroups []uint64 `json:"security_groups"`
|
||||
|
||||
// QOS
|
||||
QOS QOS `json:"qos"`
|
||||
|
||||
@@ -212,11 +239,11 @@ type RecordNetAttach struct {
|
||||
// Type
|
||||
Type string `json:"type"`
|
||||
|
||||
// List of trunk tags
|
||||
TrunkTags []uint64 `json:"trunk_tags"`
|
||||
|
||||
// List VNF IDs
|
||||
VNFs []uint64 `json:"vnfs"`
|
||||
|
||||
// Maximum transmission unit
|
||||
MTU uint64 `json:"mtu"`
|
||||
}
|
||||
|
||||
// Detailed information about audit
|
||||
@@ -311,6 +338,9 @@ type RecordCompute struct {
|
||||
// Architecture
|
||||
Architecture string `json:"arch"`
|
||||
|
||||
// Boot image ID
|
||||
BootImageID uint64 `json:"boot_image_id"`
|
||||
|
||||
// Boot order
|
||||
BootOrder []string `json:"bootOrder"`
|
||||
|
||||
@@ -332,6 +362,9 @@ type RecordCompute struct {
|
||||
// List clone IDs
|
||||
Clones []uint64 `json:"clones"`
|
||||
|
||||
// Clock
|
||||
Clock string `json:"clock"`
|
||||
|
||||
// Compute CI ID
|
||||
ComputeCIID uint64 `json:"computeciId"`
|
||||
|
||||
@@ -392,6 +425,9 @@ type RecordCompute struct {
|
||||
// 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"`
|
||||
|
||||
@@ -443,18 +479,27 @@ type RecordCompute struct {
|
||||
// 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 stack
|
||||
PinnedToStack bool `json:"pinnedToStack"`
|
||||
// Pinned to node
|
||||
PinnedToNode bool `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"`
|
||||
|
||||
@@ -509,20 +554,25 @@ type RecordCompute struct {
|
||||
// vGPUs list
|
||||
VGPUs []VGPUItem `json:"vgpus"`
|
||||
|
||||
// Virtual image ID
|
||||
VirtualImageID uint64 `json:"virtualImageId"`
|
||||
|
||||
// Virtual image name
|
||||
VirtualImageName string `json:"virtualImageName"`
|
||||
|
||||
// VNC password
|
||||
VNCPassword string `json:"vncPasswd"`
|
||||
|
||||
// Weight
|
||||
Weight uint64 `json:"weight"`
|
||||
|
||||
// Zone ID
|
||||
// Required: false
|
||||
ZoneID uint64 `json:"zoneId"`
|
||||
}
|
||||
|
||||
type LoaderMetaIso struct {
|
||||
// Name
|
||||
DeviceName string `json:"devicename"`
|
||||
|
||||
// Path
|
||||
Path string `json:"path"`
|
||||
}
|
||||
|
||||
type QemuQuest struct {
|
||||
Enabled bool `json:"enabled"`
|
||||
EnabledAgentFeatures []string `json:"enabled_agent_features"`
|
||||
@@ -531,6 +581,12 @@ type QemuQuest struct {
|
||||
User string `json:"user"`
|
||||
}
|
||||
|
||||
type CPUAlignmentProfile struct {
|
||||
Model string `json:"model"`
|
||||
Name string `json:"name"`
|
||||
Vendor string `json:"vendor"`
|
||||
}
|
||||
|
||||
type VGPUItem struct {
|
||||
// ID
|
||||
ID uint64 `json:"id"`
|
||||
@@ -755,15 +811,33 @@ type ItemComputeDisk struct {
|
||||
// Account ID
|
||||
AccountID uint64 `json:"accountId"`
|
||||
|
||||
// Discard
|
||||
Discard string `json:"discard"`
|
||||
|
||||
// Block Size
|
||||
BlockSize string `json:"block_size"`
|
||||
|
||||
// Boot partition
|
||||
BootPartition uint64 `json:"bootPartition"`
|
||||
|
||||
// Bus number
|
||||
BusNumber uint64 `json:"bus_number"`
|
||||
|
||||
// Chache
|
||||
Cache string `json:"cache"`
|
||||
|
||||
// Created by
|
||||
CreatedBy string `json:"createdBy"`
|
||||
|
||||
// Created time
|
||||
CreatedTime uint64 `json:"createdTime"`
|
||||
|
||||
// Device name
|
||||
DeviceName string `json:"devicename"`
|
||||
|
||||
// Deleted by
|
||||
DeletedBy string `json:"deletedBy"`
|
||||
|
||||
// Deleted time
|
||||
DeletedTime uint64 `json:"deletedTime"`
|
||||
|
||||
@@ -788,6 +862,9 @@ type ItemComputeDisk struct {
|
||||
// Image ID
|
||||
ImageID uint64 `json:"imageId"`
|
||||
|
||||
// Independent
|
||||
Independent bool `json:"independent"`
|
||||
|
||||
// List image IDs
|
||||
Images []uint64 `json:"images"`
|
||||
|
||||
@@ -824,6 +901,9 @@ type ItemComputeDisk struct {
|
||||
// Present to
|
||||
PresentTo map[string]uint64 `json:"presentTo"`
|
||||
|
||||
// Provision
|
||||
Provision string `json:"provision"`
|
||||
|
||||
// Purge time
|
||||
PurgeTime uint64 `json:"purgeTime"`
|
||||
|
||||
@@ -874,6 +954,12 @@ type ItemComputeDisk struct {
|
||||
|
||||
// Updated by
|
||||
UpdatedBy string `json:"updatedBy"`
|
||||
|
||||
// UpdatedTime
|
||||
UpdatedTime uint64 `json:"updatedTime"`
|
||||
|
||||
// Read-only
|
||||
ReadOnly bool `json:"read_only"`
|
||||
}
|
||||
|
||||
type ItemReplication struct {
|
||||
@@ -994,6 +1080,9 @@ type ItemCompute struct {
|
||||
// Architecture
|
||||
Architecture string `json:"arch"`
|
||||
|
||||
// Boot image ID
|
||||
BootImageID uint64 `json:"boot_image_id"`
|
||||
|
||||
// Boot order
|
||||
BootOrder []string `json:"bootOrder"`
|
||||
|
||||
@@ -1012,6 +1101,9 @@ type ItemCompute struct {
|
||||
// Clone reference
|
||||
CloneReference uint64 `json:"cloneReference"`
|
||||
|
||||
// Clock
|
||||
Clock string `json:"clock"`
|
||||
|
||||
// List clone IDs
|
||||
Clones []uint64 `json:"clones"`
|
||||
|
||||
@@ -1066,9 +1158,6 @@ type ItemCompute struct {
|
||||
// ID
|
||||
ID uint64 `json:"id"`
|
||||
|
||||
// Image ID
|
||||
ImageID uint64 `json:"imageId"`
|
||||
|
||||
// List interfaces
|
||||
Interfaces ListInterfaces `json:"interfaces"`
|
||||
|
||||
@@ -1108,8 +1197,8 @@ type ItemCompute struct {
|
||||
//NumaNodeId
|
||||
NumaNodeId int64 `json:"numaNodeId"`
|
||||
|
||||
// Pinned to stack
|
||||
PinnedToStack bool `json:"pinnedToStack"`
|
||||
// Pinned to node
|
||||
PinnedToNode bool `json:"pinnedToNode"`
|
||||
|
||||
// PreferredCPU
|
||||
PreferredCPU []int64 `json:"preferredCpu"`
|
||||
@@ -1117,9 +1206,18 @@ type ItemCompute struct {
|
||||
// Number of RAM
|
||||
RAM uint64 `json:"ram"`
|
||||
|
||||
// Name of OS
|
||||
OSVersion string `json:"os_version"`
|
||||
|
||||
// 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"`
|
||||
|
||||
// Reference ID
|
||||
ReferenceID string `json:"referenceId"`
|
||||
|
||||
@@ -1174,8 +1272,8 @@ type ItemCompute struct {
|
||||
// VINS connected
|
||||
VINSConnected uint64 `json:"vinsConnected"`
|
||||
|
||||
// Virtual image ID
|
||||
VirtualImageID uint64 `json:"virtualImageId"`
|
||||
// Weight
|
||||
Weight uint64 `json:"weight"`
|
||||
|
||||
// Zone ID
|
||||
ZoneID uint64 `json:"zoneId"`
|
||||
@@ -1188,6 +1286,12 @@ type ListInfoDisks []InfoDisk
|
||||
type InfoDisk struct {
|
||||
// ID
|
||||
ID uint64 `json:"id"`
|
||||
|
||||
// SEP ID
|
||||
SepID int64 `json:"sepId"`
|
||||
|
||||
// Read-only
|
||||
ReadOnly bool `json:"read_only"`
|
||||
}
|
||||
|
||||
// List information about computes
|
||||
@@ -1288,8 +1392,8 @@ type ItemPCIDevice struct {
|
||||
// Resource group ID
|
||||
RGID uint64 `json:"rgId"`
|
||||
|
||||
// Stack ID
|
||||
StackID uint64 `json:"stackId"`
|
||||
// Node ID
|
||||
NodeID uint64 `json:"nodeId"`
|
||||
|
||||
// Status
|
||||
Status string `json:"status"`
|
||||
@@ -1306,3 +1410,46 @@ type ListPCIDevices struct {
|
||||
// Entry count
|
||||
EntryCount uint64 `json:"entryCount"`
|
||||
}
|
||||
|
||||
type RecordCloneStatus struct {
|
||||
// Disk ID
|
||||
DiskID int `json:"disk_id"`
|
||||
|
||||
// Clone 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
|
||||
Type int `json:"type"`
|
||||
|
||||
// Copy speed
|
||||
Bandwidth int `json:"bandwidth"`
|
||||
|
||||
// Current progress
|
||||
Cur int `json:"cur"`
|
||||
|
||||
// Total size
|
||||
End int `json:"end"`
|
||||
|
||||
// Operation status
|
||||
Ready bool `json:"ready"`
|
||||
|
||||
// Progress percent
|
||||
ProgressPercent int `json:"progress_percent"`
|
||||
}
|
||||
|
||||
@@ -34,6 +34,12 @@ type MoveToRGRequest struct {
|
||||
ForceStop bool `url:"forceStop,omitempty" json:"forceStop,omitempty"`
|
||||
}
|
||||
|
||||
type wrapperMoveToRGRequest struct {
|
||||
MoveToRGRequest
|
||||
|
||||
AsyncMode bool `url:"asyncMode"`
|
||||
}
|
||||
|
||||
// MoveToRG moves compute instance to new resource group
|
||||
func (c Compute) MoveToRG(ctx context.Context, req MoveToRGRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
@@ -41,9 +47,14 @@ func (c Compute) MoveToRG(ctx context.Context, req MoveToRGRequest) (bool, error
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
reqWrapped := wrapperMoveToRGRequest{
|
||||
MoveToRGRequest: req,
|
||||
AsyncMode: false,
|
||||
}
|
||||
|
||||
url := "/cloudapi/compute/moveToRg"
|
||||
|
||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
@@ -55,3 +66,25 @@ func (c Compute) MoveToRG(ctx context.Context, req MoveToRGRequest) (bool, error
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ type NetAttachRequest struct {
|
||||
// 'VFNIC' for connect to vfpool
|
||||
// 'DPDK' for connect to DPDK
|
||||
// `EMPTY` for connect empty network
|
||||
// `SDT` for connect to SDN
|
||||
// `SDN` for connect to SDN
|
||||
// `TRUNK` for connect to TRUNK
|
||||
// Required: true
|
||||
NetType string `url:"netType" json:"netType" validate:"computex86NetType"`
|
||||
@@ -39,12 +39,32 @@ type NetAttachRequest struct {
|
||||
// Required: false
|
||||
MACAddr string `url:"mac_addr,omitempty" json:"mac_addr,omitempty"`
|
||||
|
||||
// Used only for EXTNET and DPDK
|
||||
// For DPDK must be 1-9216
|
||||
// For EXTNET must be 1500-9216
|
||||
// Used for EXTNET, TRUNK and DPDK
|
||||
// Must be 1500-9216
|
||||
// Required: false
|
||||
MTU uint64 `url:"mtu,omitempty" json:"mtu,omitempty" validate:"omitempty,mtu"`
|
||||
|
||||
// Net mask
|
||||
// Used only to DPDK or VFNIC net type
|
||||
// Required: false
|
||||
NetMask uint64 `url:"netMask,omitempty" json:"netMask,omitempty"`
|
||||
|
||||
// SDN Segment ID
|
||||
// Required: false
|
||||
SDNSegmentID string `url:"sdn_segment_id,omitempty" json:"sdn_segment_id,omitempty"`
|
||||
|
||||
// SDN Object Group IDs
|
||||
// Required: false
|
||||
SDNObjectGroupIDs []string `url:"sdn_object_group_ids,omitempty" json:"sdn_object_group_ids,omitempty"`
|
||||
|
||||
// SDN Logical Port Display Name
|
||||
// Required: false
|
||||
SDNLogicalPortDisplayName string `url:"sdn_logical_port_display_name,omitempty" json:"sdn_logical_port_display_name,omitempty"`
|
||||
|
||||
// SDN Logical Port Description
|
||||
// Required: false
|
||||
SDNLogicalPortDescription string `url:"sdn_logical_port_description,omitempty" json:"sdn_logical_port_description,omitempty"`
|
||||
|
||||
// Unique identifier of logical port on SDN side
|
||||
// Required: false
|
||||
SDNInterfaceID string `url:"sdn_interface_id,omitempty" json:"sdn_interface_id,omitempty" validate:"omitempty"`
|
||||
@@ -54,6 +74,7 @@ type NetAttachRequest struct {
|
||||
SecGroups []uint64 `url:"security_groups,omitempty" json:"security_groups,omitempty"`
|
||||
|
||||
// Flag indicating whether security groups are enabled for this interface
|
||||
// Not applicable to netType VFNIC, TRUNK, or SDN
|
||||
// Required: false
|
||||
EnableSecGroups bool `url:"enable_secgroups,omitempty" json:"enable_secgroups,omitempty"`
|
||||
|
||||
@@ -62,6 +83,12 @@ type NetAttachRequest struct {
|
||||
Enabled interface{} `url:"enabled,omitempty" json:"enabled,omitempty" validate:"omitempty,isBool"`
|
||||
}
|
||||
|
||||
type wrapperNetAttachRequest struct {
|
||||
NetAttachRequest
|
||||
|
||||
AsyncMode bool `url:"asyncMode"`
|
||||
}
|
||||
|
||||
// NetAttach attaches network to compute and gets info about network
|
||||
func (c Compute) NetAttach(ctx context.Context, req NetAttachRequest) (*RecordNetAttach, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
@@ -69,9 +96,14 @@ func (c Compute) NetAttach(ctx context.Context, req NetAttachRequest) (*RecordNe
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
reqWrapped := wrapperNetAttachRequest{
|
||||
NetAttachRequest: req,
|
||||
AsyncMode: false,
|
||||
}
|
||||
|
||||
url := "/cloudapi/compute/netAttach"
|
||||
|
||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -85,3 +117,25 @@ func (c Compute) NetAttach(ctx context.Context, req NetAttachRequest) (*RecordNe
|
||||
|
||||
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,6 +23,12 @@ type NetDetachRequest struct {
|
||||
MAC string `url:"mac,omitempty" json:"mac,omitempty"`
|
||||
}
|
||||
|
||||
type wrapperNetDetachRequest struct {
|
||||
NetDetachRequest
|
||||
|
||||
AsyncMode bool `url:"asyncMode"`
|
||||
}
|
||||
|
||||
// NetDetach detaches network from compute
|
||||
func (c Compute) NetDetach(ctx context.Context, req NetDetachRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
@@ -30,9 +36,14 @@ func (c Compute) NetDetach(ctx context.Context, req NetDetachRequest) (bool, err
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
reqWrapped := wrapperNetDetachRequest{
|
||||
NetDetachRequest: req,
|
||||
AsyncMode: false,
|
||||
}
|
||||
|
||||
url := "/cloudapi/compute/netDetach"
|
||||
|
||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
@@ -44,3 +55,25 @@ func (c Compute) NetDetach(ctx context.Context, req NetDetachRequest) (bool, err
|
||||
|
||||
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,6 +15,12 @@ type PauseRequest struct {
|
||||
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
|
||||
}
|
||||
|
||||
type wrapperPauseRequest struct {
|
||||
PauseRequest
|
||||
|
||||
AsyncMode bool `url:"asyncMode"`
|
||||
}
|
||||
|
||||
// Pause pause compute
|
||||
func (c Compute) Pause(ctx context.Context, req PauseRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
@@ -22,9 +28,14 @@ func (c Compute) Pause(ctx context.Context, req PauseRequest) (bool, error) {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
reqWrapped := wrapperPauseRequest{
|
||||
PauseRequest: req,
|
||||
AsyncMode: false,
|
||||
}
|
||||
|
||||
url := "/cloudapi/compute/pause"
|
||||
|
||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
@@ -36,3 +47,25 @@ func (c Compute) Pause(ctx context.Context, req PauseRequest) (bool, error) {
|
||||
|
||||
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,6 +33,12 @@ type PFWAddRequest struct {
|
||||
Proto string `url:"proto" json:"proto" validate:"proto"`
|
||||
}
|
||||
|
||||
type wrapperPFWAddRequest struct {
|
||||
PFWAddRequest
|
||||
|
||||
AsyncMode bool `url:"asyncMode"`
|
||||
}
|
||||
|
||||
// PFWAdd add port forward rule
|
||||
func (c Compute) PFWAdd(ctx context.Context, req PFWAddRequest) (uint64, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
@@ -40,9 +46,14 @@ func (c Compute) PFWAdd(ctx context.Context, req PFWAddRequest) (uint64, error)
|
||||
return 0, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
reqWrapped := wrapperPFWAddRequest{
|
||||
PFWAddRequest: req,
|
||||
AsyncMode: false,
|
||||
}
|
||||
|
||||
url := "/cloudapi/compute/pfwAdd"
|
||||
|
||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
@@ -54,3 +65,25 @@ func (c Compute) PFWAdd(ctx context.Context, req PFWAddRequest) (uint64, error)
|
||||
|
||||
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,6 +36,12 @@ type PFWDelRequest struct {
|
||||
Proto string `url:"proto,omitempty" json:"proto,omitempty"`
|
||||
}
|
||||
|
||||
type wrapperPFWDelRequest struct {
|
||||
PFWDelRequest
|
||||
|
||||
AsyncMode bool `url:"asyncMode"`
|
||||
}
|
||||
|
||||
// PFWDel deletes port forward rule
|
||||
func (c Compute) PFWDel(ctx context.Context, req PFWDelRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
@@ -43,9 +49,14 @@ func (c Compute) PFWDel(ctx context.Context, req PFWDelRequest) (bool, error) {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
reqWrapped := wrapperPFWDelRequest{
|
||||
PFWDelRequest: req,
|
||||
AsyncMode: false,
|
||||
}
|
||||
|
||||
url := "/cloudapi/compute/pfwDel"
|
||||
|
||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
@@ -57,3 +68,25 @@ func (c Compute) PFWDel(ctx context.Context, req PFWDelRequest) (bool, error) {
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
76
pkg/cloudapi/compute/pin_to_node.go
Normal file
76
pkg/cloudapi/compute/pin_to_node.go
Normal file
@@ -0,0 +1,76 @@
|
||||
package compute
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// PinToNodeRequest struct to pin compute to node
|
||||
type PinToNodeRequest struct {
|
||||
// ID of the compute instance
|
||||
// Required: true
|
||||
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
|
||||
|
||||
// Auto start when node restarted
|
||||
// Required: false
|
||||
// Default: false
|
||||
AutoStart bool `url:"autoStart" json:"autoStart"`
|
||||
}
|
||||
|
||||
type wrapperPinToNodeRequest struct {
|
||||
PinToNodeRequest
|
||||
|
||||
AsyncMode bool `url:"asyncMode"`
|
||||
}
|
||||
|
||||
// PinToNode pin compute to current node
|
||||
func (c Compute) PinToNode(ctx context.Context, req PinToNodeRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
reqWrapped := wrapperPinToNodeRequest{
|
||||
PinToNodeRequest: req,
|
||||
AsyncMode: false,
|
||||
}
|
||||
|
||||
url := "/cloudapi/compute/pin_to_node"
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
// 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
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
package compute
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// PinToStackRequest struct to pin compute to stack
|
||||
type PinToStackRequest struct {
|
||||
// ID of the compute instance
|
||||
// Required: true
|
||||
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
|
||||
|
||||
// Auto start when node restarted
|
||||
// Required: false
|
||||
// Default: false
|
||||
AutoStart bool `url:"autoStart" json:"autoStart"`
|
||||
}
|
||||
|
||||
// PinToStack pin compute to current stack
|
||||
func (c Compute) PinToStack(ctx context.Context, req PinToStackRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudapi/compute/pinToStack"
|
||||
|
||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseBool(string(res))
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
@@ -15,6 +15,12 @@ type PowerCycleRequest struct {
|
||||
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
|
||||
}
|
||||
|
||||
type wrapperPowerCycleRequest struct {
|
||||
PowerCycleRequest
|
||||
|
||||
AsyncMode bool `url:"asyncMode"`
|
||||
}
|
||||
|
||||
// PowerCycle makes force stop and start compute
|
||||
func (c Compute) PowerCycle(ctx context.Context, req PowerCycleRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
@@ -22,9 +28,14 @@ func (c Compute) PowerCycle(ctx context.Context, req PowerCycleRequest) (bool, e
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
reqWrapped := wrapperPowerCycleRequest{
|
||||
PowerCycleRequest: req,
|
||||
AsyncMode: false,
|
||||
}
|
||||
|
||||
url := "/cloudapi/compute/powerCycle"
|
||||
|
||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
@@ -36,3 +47,25 @@ func (c Compute) PowerCycle(ctx context.Context, req PowerCycleRequest) (bool, e
|
||||
|
||||
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,6 +15,12 @@ type RebootRequest struct {
|
||||
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
|
||||
}
|
||||
|
||||
type wrapperRebootRequest struct {
|
||||
RebootRequest
|
||||
|
||||
AsyncMode bool `url:"asyncMode"`
|
||||
}
|
||||
|
||||
// Reboot reboots compute
|
||||
func (c Compute) Reboot(ctx context.Context, req RebootRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
@@ -22,9 +28,14 @@ func (c Compute) Reboot(ctx context.Context, req RebootRequest) (bool, error) {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
reqWrapped := wrapperRebootRequest{
|
||||
RebootRequest: req,
|
||||
AsyncMode: false,
|
||||
}
|
||||
|
||||
url := "/cloudapi/compute/reboot"
|
||||
|
||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
@@ -36,3 +47,25 @@ func (c Compute) Reboot(ctx context.Context, req RebootRequest) (bool, error) {
|
||||
|
||||
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,13 +15,17 @@ type RedeployRequest struct {
|
||||
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
|
||||
|
||||
// Storage policy id of compute. The rules of the specified storage policy will be used.
|
||||
// Required: true
|
||||
StoragePolicyID uint64 `url:"storage_policy_id" json:"storage_policy_id" validate:"required"`
|
||||
// Required: false
|
||||
StoragePolicyID uint64 `url:"storage_policy_id,omitempty" json:"storage_policy_id,omitempty"`
|
||||
|
||||
// ID of the new OS image, if image change is required
|
||||
// Required: false
|
||||
ImageID uint64 `url:"imageId,omitempty" json:"imageId,omitempty"`
|
||||
|
||||
// The OS version that will be installed on the virtual machine
|
||||
// Required: false
|
||||
OSVersion string `url:"os_version,omitempty" json:"os_version,omitempty"`
|
||||
|
||||
// new size for the boot disk in GB, if boot disk size change is required
|
||||
// Required: false
|
||||
DiskSize uint64 `url:"diskSize,omitempty" json:"diskSize,omitempty"`
|
||||
@@ -40,6 +44,12 @@ type RedeployRequest struct {
|
||||
ForceStop bool `url:"forceStop,omitempty" json:"forceStop,omitempty"`
|
||||
}
|
||||
|
||||
type wrapperRedeployRequest struct {
|
||||
RedeployRequest
|
||||
|
||||
AsyncMode bool `url:"asyncMode"`
|
||||
}
|
||||
|
||||
// Redeploy redeploys compute
|
||||
func (c Compute) Redeploy(ctx context.Context, req RedeployRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
@@ -47,9 +57,14 @@ func (c Compute) Redeploy(ctx context.Context, req RedeployRequest) (bool, error
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
reqWrapped := wrapperRedeployRequest{
|
||||
RedeployRequest: req,
|
||||
AsyncMode: false,
|
||||
}
|
||||
|
||||
url := "/cloudapi/compute/redeploy"
|
||||
|
||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
@@ -61,3 +76,25 @@ func (c Compute) Redeploy(ctx context.Context, req RedeployRequest) (bool, error
|
||||
|
||||
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,6 +15,12 @@ type ResetRequest struct {
|
||||
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
|
||||
}
|
||||
|
||||
type wrapperResetRequest struct {
|
||||
ResetRequest
|
||||
|
||||
AsyncMode bool `url:"asyncMode"`
|
||||
}
|
||||
|
||||
// Reset resets compute
|
||||
func (c Compute) Reset(ctx context.Context, req ResetRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
@@ -22,9 +28,14 @@ func (c Compute) Reset(ctx context.Context, req ResetRequest) (bool, error) {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
reqWrapped := wrapperResetRequest{
|
||||
ResetRequest: req,
|
||||
AsyncMode: false,
|
||||
}
|
||||
|
||||
url := "/cloudapi/compute/reset"
|
||||
|
||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
@@ -36,3 +47,25 @@ func (c Compute) Reset(ctx context.Context, req ResetRequest) (bool, error) {
|
||||
|
||||
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,6 +43,12 @@ func (r ResizeRequest) GetRAM() map[string]uint64 {
|
||||
return res
|
||||
}
|
||||
|
||||
type wrapperResizeRequest struct {
|
||||
ResizeRequest
|
||||
|
||||
AsyncMode bool `url:"asyncMode"`
|
||||
}
|
||||
|
||||
// Resize resizes compute instance
|
||||
func (c Compute) Resize(ctx context.Context, req ResizeRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
@@ -50,9 +56,14 @@ func (c Compute) Resize(ctx context.Context, req ResizeRequest) (bool, error) {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
reqWrapped := wrapperResizeRequest{
|
||||
ResizeRequest: req,
|
||||
AsyncMode: false,
|
||||
}
|
||||
|
||||
url := "/cloudapi/compute/resize"
|
||||
|
||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
@@ -64,3 +75,25 @@ func (c Compute) Resize(ctx context.Context, req ResizeRequest) (bool, error) {
|
||||
|
||||
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,6 +3,7 @@ package compute
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
@@ -14,16 +15,54 @@ type RestoreRequest struct {
|
||||
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
|
||||
}
|
||||
|
||||
type wrapperRestoreRequest struct {
|
||||
RestoreRequest
|
||||
|
||||
AsyncMode bool `url:"asyncMode"`
|
||||
}
|
||||
|
||||
// Restore restores compute from recycle bin
|
||||
func (c Compute) Restore(ctx context.Context, req RestoreRequest) (string, error) {
|
||||
func (c Compute) Restore(ctx context.Context, req RestoreRequest) (bool, 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)
|
||||
if err != nil {
|
||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
reqWrapped := wrapperRestoreRequest{
|
||||
RestoreRequest: req,
|
||||
AsyncMode: true,
|
||||
}
|
||||
|
||||
url := "/cloudapi/compute/restore"
|
||||
|
||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
@@ -15,6 +15,12 @@ type ResumeRequest struct {
|
||||
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
|
||||
}
|
||||
|
||||
type wrapperResumeRequest struct {
|
||||
ResumeRequest
|
||||
|
||||
AsyncMode bool `url:"asyncMode"`
|
||||
}
|
||||
|
||||
// Resume resume Compute from paused state
|
||||
func (c Compute) Resume(ctx context.Context, req ResumeRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
@@ -22,9 +28,14 @@ func (c Compute) Resume(ctx context.Context, req ResumeRequest) (bool, error) {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
reqWrapped := wrapperResumeRequest{
|
||||
ResumeRequest: req,
|
||||
AsyncMode: false,
|
||||
}
|
||||
|
||||
url := "/cloudapi/compute/resume"
|
||||
|
||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
@@ -36,3 +47,25 @@ func (c Compute) Resume(ctx context.Context, req ResumeRequest) (bool, error) {
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
43
pkg/cloudapi/compute/set_cpu_alignment_profile.go
Normal file
43
pkg/cloudapi/compute/set_cpu_alignment_profile.go
Normal file
@@ -0,0 +1,43 @@
|
||||
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,20 +16,37 @@ type SnapshotCreateRequest struct {
|
||||
|
||||
// Text label for snapshot.
|
||||
// Must be unique among this compute snapshots
|
||||
// Allowed characters: a-z, 0-9, spaces, punctuation except '<' and '>'
|
||||
// Maximum length: 36 characters
|
||||
// Required: true
|
||||
Label string `url:"label" json:"label" validate:"required"`
|
||||
Label string `url:"label" json:"label" validate:"required,max=36,excludesall=<>"`
|
||||
|
||||
// Create snapshot with memory dump
|
||||
// Required: false
|
||||
// Default: false
|
||||
WithMemory bool `url:"with_memory" json:"with_memory"`
|
||||
}
|
||||
|
||||
// SnapshotCreate create compute snapshot
|
||||
type wrapperSnapshotCreateRequest struct {
|
||||
SnapshotCreateRequest
|
||||
AsyncMode bool `url:"asyncMode"`
|
||||
}
|
||||
|
||||
// SnapshotCreate creates compute snapshot
|
||||
func (c Compute) SnapshotCreate(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: false,
|
||||
}
|
||||
|
||||
url := "/cloudapi/compute/snapshotCreate"
|
||||
|
||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
@@ -38,3 +55,25 @@ func (c Compute) SnapshotCreate(ctx context.Context, req SnapshotCreateRequest)
|
||||
|
||||
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,6 +17,16 @@ type SnapshotRollbackRequest struct {
|
||||
// Text label of snapshot to rollback
|
||||
// Required: true
|
||||
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
|
||||
@@ -26,9 +36,14 @@ func (c Compute) SnapshotRollback(ctx context.Context, req SnapshotRollbackReque
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
reqWrapped := wrapperSnapshotRollbackRequest{
|
||||
SnapshotRollbackRequest: req,
|
||||
AsyncMode: false,
|
||||
}
|
||||
|
||||
url := "/cloudapi/compute/snapshotRollback"
|
||||
|
||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
@@ -40,3 +55,25 @@ func (c Compute) SnapshotRollback(ctx context.Context, req SnapshotRollbackReque
|
||||
|
||||
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,6 +19,12 @@ type StartRequest struct {
|
||||
AltBootID uint64 `url:"altBootId,omitempty" json:"altBootId,omitempty"`
|
||||
}
|
||||
|
||||
type wrapperStartRequest struct {
|
||||
StartRequest
|
||||
|
||||
AsyncMode bool `url:"asyncMode"`
|
||||
}
|
||||
|
||||
// Start starts compute
|
||||
func (c Compute) Start(ctx context.Context, req StartRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
@@ -26,9 +32,14 @@ func (c Compute) Start(ctx context.Context, req StartRequest) (bool, error) {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
reqWrapped := wrapperStartRequest{
|
||||
StartRequest: req,
|
||||
AsyncMode: false,
|
||||
}
|
||||
|
||||
url := "/cloudapi/compute/start"
|
||||
|
||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
@@ -40,3 +51,25 @@ func (c Compute) Start(ctx context.Context, req StartRequest) (bool, error) {
|
||||
|
||||
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,6 +19,12 @@ type StopRequest struct {
|
||||
Force bool `url:"force,omitempty" json:"force,omitempty"`
|
||||
}
|
||||
|
||||
type wrapperStopRequest struct {
|
||||
StopRequest
|
||||
|
||||
AsyncMode bool `url:"asyncMode"`
|
||||
}
|
||||
|
||||
// Stop stops compute
|
||||
func (c Compute) Stop(ctx context.Context, req StopRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
@@ -26,9 +32,14 @@ func (c Compute) Stop(ctx context.Context, req StopRequest) (bool, error) {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
reqWrapped := wrapperStopRequest{
|
||||
StopRequest: req,
|
||||
AsyncMode: false,
|
||||
}
|
||||
|
||||
url := "/cloudapi/compute/stop"
|
||||
|
||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
@@ -40,3 +51,25 @@ func (c Compute) Stop(ctx context.Context, req StopRequest) (bool, error) {
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
@@ -8,21 +8,21 @@ import (
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// UnpinFromStackRequest struct for unpin from stack
|
||||
type UnpinFromStackRequest struct {
|
||||
// UnpinFromNodeRequest struct for unpin from node
|
||||
type UnpinFromNodeRequest struct {
|
||||
// ID of the compute instance
|
||||
// Required: true
|
||||
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
|
||||
}
|
||||
|
||||
// UnpinFromStack unpins compute from current stack
|
||||
func (c Compute) UnpinFromStack(ctx context.Context, req UnpinFromStackRequest) (bool, error) {
|
||||
// UnpinFromNode unpins compute from current node
|
||||
func (c Compute) UnpinFromNode(ctx context.Context, req UnpinFromNodeRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudapi/compute/unpinFromStack"
|
||||
url := "/cloudapi/compute/unpin_from_node"
|
||||
|
||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
@@ -65,6 +65,15 @@ type UpdateRequest struct {
|
||||
// Does this machine supports hot resize, true or false
|
||||
// Required: false
|
||||
HotResize interface{} `url:"hotResize,omitempty" json:"hotResize,omitempty" validate:"omitempty,isBool"`
|
||||
|
||||
// The OS version that will be installed on the virtual machine
|
||||
// Required: false
|
||||
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"`
|
||||
}
|
||||
|
||||
// Update updates some properties of the compute
|
||||
|
||||
@@ -30,10 +30,6 @@ type CreateRequest struct {
|
||||
// Required: false
|
||||
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
||||
|
||||
// Max IOPS disk can perform defaults to 2000
|
||||
// Required: false
|
||||
IOPS uint64 `url:"iops,omitempty" json:"iops,omitempty"`
|
||||
|
||||
// Storage endpoint provider ID to create disk
|
||||
// Required: false
|
||||
SEPID uint64 `url:"sep_id,omitempty" json:"sep_id,omitempty"`
|
||||
|
||||
@@ -48,7 +48,6 @@ var disks = ListDisks{
|
||||
Snapshots: []ItemSnapshot{},
|
||||
Status: "ASSIGNED",
|
||||
TechStatus: techStatusAllocated,
|
||||
Type: "B",
|
||||
VMID: 48500,
|
||||
},
|
||||
{
|
||||
@@ -92,7 +91,6 @@ var disks = ListDisks{
|
||||
Snapshots: []ItemSnapshot{},
|
||||
Status: "ASSIGNED",
|
||||
TechStatus: techStatusAllocated,
|
||||
Type: "B",
|
||||
VMID: 48502,
|
||||
},
|
||||
},
|
||||
@@ -224,7 +222,6 @@ var searchDisks = ListSearchDisks{
|
||||
Snapshots: []ItemSnapshot{},
|
||||
Status: "ASSIGNED",
|
||||
TechStatus: techStatusAllocated,
|
||||
Type: "B",
|
||||
VMID: 48500,
|
||||
},
|
||||
ItemDisk{
|
||||
@@ -268,7 +265,6 @@ var searchDisks = ListSearchDisks{
|
||||
Snapshots: []ItemSnapshot{},
|
||||
Status: "ASSIGNED",
|
||||
TechStatus: techStatusAllocated,
|
||||
Type: "B",
|
||||
VMID: 48502,
|
||||
},
|
||||
}
|
||||
@@ -360,7 +356,6 @@ func TestListSearchDisks_SortByCreatedTime(t *testing.T) {
|
||||
var unattachedDisks = ListDisksUnattached{
|
||||
Data: []ItemDiskUnattached{
|
||||
{
|
||||
CKey: "",
|
||||
Meta: []interface{}{
|
||||
"cloudbroker",
|
||||
"disk",
|
||||
@@ -408,11 +403,9 @@ var unattachedDisks = ListDisksUnattached{
|
||||
Snapshots: nil,
|
||||
Status: "CREATED",
|
||||
TechStatus: techStatusAllocated,
|
||||
Type: "D",
|
||||
VMID: 0,
|
||||
},
|
||||
{
|
||||
CKey: "",
|
||||
Meta: []interface{}{
|
||||
"cloudbroker",
|
||||
"disk",
|
||||
@@ -463,7 +456,6 @@ var unattachedDisks = ListDisksUnattached{
|
||||
Snapshots: nil,
|
||||
Status: "CREATED",
|
||||
TechStatus: techStatusAllocated,
|
||||
Type: "B",
|
||||
VMID: 0,
|
||||
},
|
||||
},
|
||||
|
||||
@@ -38,14 +38,14 @@ type ListRequest struct {
|
||||
// Required: false
|
||||
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
|
||||
// Required: false
|
||||
SEPID uint64 `url:"sepId,omitempty" json:"sepId,omitempty"`
|
||||
|
||||
// Find by storage policy id
|
||||
// Required: false
|
||||
StoragePolicyID uint64 `url:"storage_policy_id,omitempty" json:"storage_policy_id,omitempty"`
|
||||
|
||||
// Find by pool name
|
||||
// Required: false
|
||||
Pool string `url:"pool,omitempty" json:"pool,omitempty"`
|
||||
@@ -61,6 +61,14 @@ type ListRequest struct {
|
||||
// Page size
|
||||
// Required: false
|
||||
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
|
||||
|
||||
@@ -34,10 +34,6 @@ type ListDeletedRequest struct {
|
||||
// Required: false
|
||||
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)
|
||||
// Required: false
|
||||
SortBy string `url:"sortBy,omitempty" json:"sortBy,omitempty" validate:"omitempty,sortBy"`
|
||||
|
||||
@@ -1,52 +0,0 @@
|
||||
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,10 +26,6 @@ type ListUnattachedRequest struct {
|
||||
// Required: false
|
||||
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
|
||||
// Required: false
|
||||
AccountID uint64 `url:"accountId,omitempty" json:"accountId,omitempty"`
|
||||
@@ -38,6 +34,10 @@ type ListUnattachedRequest struct {
|
||||
// Required: false
|
||||
SEPID uint64 `url:"sepId,omitempty" json:"sepId,omitempty"`
|
||||
|
||||
// Find by storage policy id
|
||||
// Required: false
|
||||
StoragePolicyID uint64 `url:"storage_policy_id,omitempty" json:"storage_policy_id,omitempty"`
|
||||
|
||||
// Find by pool name
|
||||
// Required: false
|
||||
Pool string `url:"pool,omitempty" json:"pool,omitempty"`
|
||||
|
||||
@@ -11,9 +11,18 @@ type ItemDisk struct {
|
||||
// Account name
|
||||
AccountName string `json:"accountName"`
|
||||
|
||||
// Discard
|
||||
Discard string `json:"discard"`
|
||||
|
||||
// Block size of disk
|
||||
BlockSize string `json:"block_size"`
|
||||
|
||||
// Computes
|
||||
Computes map[string]string `json:"computes"`
|
||||
|
||||
// Computes read only
|
||||
ComputesReadOnly map[string]bool `json:"computes_read_only"`
|
||||
|
||||
//Created by
|
||||
CreatedBy string `json:"createdBy"`
|
||||
|
||||
@@ -44,6 +53,9 @@ type ItemDisk struct {
|
||||
// Image ID
|
||||
ImageID uint64 `json:"imageId"`
|
||||
|
||||
// Independent
|
||||
Independent bool `json:"independent"`
|
||||
|
||||
// List of image IDs
|
||||
Images []uint64 `json:"images"`
|
||||
|
||||
@@ -80,6 +92,9 @@ type ItemDisk struct {
|
||||
// Present to
|
||||
PresentTo map[string]uint64 `json:"presentTo"`
|
||||
|
||||
// Provision
|
||||
Provision string `json:"provision"`
|
||||
|
||||
// Purge time
|
||||
PurgeTime uint64 `json:"purgeTime"`
|
||||
|
||||
@@ -128,9 +143,6 @@ type ItemDisk struct {
|
||||
// Need to clean before destroy
|
||||
ToClean bool `json:"to_clean"`
|
||||
|
||||
// Type
|
||||
Type string `json:"type"`
|
||||
|
||||
// Virtual machine ID
|
||||
VMID uint64 `json:"vmid"`
|
||||
|
||||
@@ -139,12 +151,12 @@ type ItemDisk struct {
|
||||
|
||||
// Updated by
|
||||
UpdatedBy string `json:"updatedBy"`
|
||||
|
||||
// Cache mode of disk
|
||||
Cache string `json:"cache"`
|
||||
}
|
||||
|
||||
type ItemDiskUnattached struct {
|
||||
// CKey
|
||||
CKey string `json:"_ckey"`
|
||||
|
||||
// Meta
|
||||
Meta []interface{} `json:"_meta"`
|
||||
|
||||
@@ -157,9 +169,18 @@ type ItemDiskUnattached struct {
|
||||
// Access Control List
|
||||
ACL map[string]interface{} `json:"acl"`
|
||||
|
||||
// Discard
|
||||
Discard string `json:"discard"`
|
||||
|
||||
// Block size of disk
|
||||
BlockSize string `json:"block_size"`
|
||||
|
||||
// Boot Partition
|
||||
BootPartition uint64 `json:"bootPartition"`
|
||||
|
||||
// Cache
|
||||
Cache string `json:"cache"`
|
||||
|
||||
// Created time
|
||||
CreatedTime uint64 `json:"createdTime"`
|
||||
|
||||
@@ -226,6 +247,9 @@ type ItemDiskUnattached struct {
|
||||
// Present to
|
||||
PresentTo map[string]uint64 `json:"presentTo"`
|
||||
|
||||
// Provision
|
||||
Provision string `json:"provision"`
|
||||
|
||||
// Purge attempts
|
||||
PurgeAttempts uint64 `json:"purgeAttempts"`
|
||||
|
||||
@@ -268,8 +292,11 @@ type ItemDiskUnattached struct {
|
||||
// Tech status
|
||||
TechStatus string `json:"techStatus"`
|
||||
|
||||
// Type
|
||||
Type string `json:"type"`
|
||||
// Need to clean before destroy
|
||||
ToClean bool `json:"to_clean"`
|
||||
|
||||
// ID of the Storage Policy
|
||||
StoragePolicyID uint64 `json:"storage_policy_id"`
|
||||
|
||||
// Virtual machine ID
|
||||
VMID uint64 `json:"vmid"`
|
||||
@@ -375,9 +402,18 @@ type RecordDisk struct {
|
||||
// Account name
|
||||
AccountName string `json:"accountName"`
|
||||
|
||||
// Discard
|
||||
Discard string `json:"discard"`
|
||||
|
||||
// Block size of disk
|
||||
BlockSize string `json:"block_size"`
|
||||
|
||||
// Computes
|
||||
Computes map[string]string `json:"computes"`
|
||||
|
||||
// Computes read only
|
||||
ComputesReadOnly map[string]bool `json:"computes_read_only"`
|
||||
|
||||
// Created by
|
||||
CreatedBy string `json:"createdBy"`
|
||||
|
||||
@@ -408,6 +444,9 @@ type RecordDisk struct {
|
||||
// Image ID
|
||||
ImageID uint64 `json:"imageId"`
|
||||
|
||||
// Independent
|
||||
Independent bool `json:"independent"`
|
||||
|
||||
// List of image IDs
|
||||
Images []uint64 `json:"images"`
|
||||
|
||||
@@ -444,6 +483,9 @@ type RecordDisk struct {
|
||||
// Present to
|
||||
PresentTo map[string]uint64 `json:"presentTo"`
|
||||
|
||||
// Provision
|
||||
Provision string `json:"provision"`
|
||||
|
||||
// Purge time
|
||||
PurgeTime uint64 `json:"purgeTime"`
|
||||
|
||||
@@ -492,9 +534,6 @@ type RecordDisk struct {
|
||||
// Need to clean before destroy
|
||||
ToClean bool `json:"to_clean"`
|
||||
|
||||
// Type
|
||||
Type string `json:"type"`
|
||||
|
||||
// Virtual machine ID
|
||||
VMID uint64 `json:"vmid"`
|
||||
|
||||
@@ -503,6 +542,9 @@ type RecordDisk struct {
|
||||
|
||||
// Updated by
|
||||
UpdatedBy string `json:"updatedBy"`
|
||||
|
||||
// Cache mode of disk
|
||||
Cache string `json:"cache"`
|
||||
}
|
||||
|
||||
type ItemReplication struct {
|
||||
@@ -524,11 +566,3 @@ type ItemReplication struct {
|
||||
// VolumeID
|
||||
VolumeID string `json:"volumeId"`
|
||||
}
|
||||
|
||||
type ListTypes struct {
|
||||
// Data
|
||||
Data []interface{} `json:"data"`
|
||||
|
||||
// Entry count
|
||||
EntryCount uint64 `json:"entryCount"`
|
||||
}
|
||||
|
||||
@@ -13,6 +13,9 @@ type ItemExtNet struct {
|
||||
|
||||
// Status
|
||||
Status string `json:"status"`
|
||||
|
||||
// Free IPs
|
||||
FreeIPs uint64 `json:"freeIps"`
|
||||
}
|
||||
|
||||
// Extend information about external network
|
||||
|
||||
@@ -34,10 +34,6 @@ type ListRequest struct {
|
||||
// Required: false
|
||||
AccountId uint64 `url:"accountId,omitempty" json:"accountId,omitempty"`
|
||||
|
||||
// Find by resource group ID
|
||||
// Required: false
|
||||
RGID uint64 `url:"rgId,omitempty" json:"rgId,omitempty"`
|
||||
|
||||
// Find by id
|
||||
// Required: false
|
||||
ByID uint64 `url:"by_id,omitempty" json:"by_id,omitempty"`
|
||||
|
||||
@@ -85,12 +85,6 @@ type RecordFLIPGroup struct {
|
||||
// Network
|
||||
Network string `json:"network"`
|
||||
|
||||
// Resource group ID
|
||||
RGID uint64 `json:"rgId"`
|
||||
|
||||
// Resource group name
|
||||
RGName string `json:"rgName"`
|
||||
|
||||
// Status
|
||||
Status string `json:"status"`
|
||||
|
||||
|
||||
@@ -19,9 +19,8 @@ type CreateVirtualRequest struct {
|
||||
TargetID uint64 `url:"targetId" json:"targetId" validate:"required"`
|
||||
|
||||
// AccountID to make the virtual image exclusive
|
||||
// Required: false
|
||||
// Default: 0
|
||||
AccountID uint64 `url:"accountId,omitempty" json:"accountId,omitempty"`
|
||||
// Required: true
|
||||
AccountID uint64 `url:"accountId" json:"accountId" validate:"required"`
|
||||
}
|
||||
|
||||
// CreateVirtual creates virtual image
|
||||
|
||||
@@ -28,7 +28,7 @@ type ListRequest struct {
|
||||
|
||||
// Find by type
|
||||
// Required: false
|
||||
TypeImage string `url:"typeImage,omitempty" json:"typeImage,omitempty"`
|
||||
TypeImage []string `url:"typeImage,omitempty" json:"typeImage,omitempty"`
|
||||
|
||||
// Find by image size
|
||||
// Required: false
|
||||
@@ -69,6 +69,10 @@ type ListRequest struct {
|
||||
// Find by enabled True or False
|
||||
// Required: false
|
||||
Enabled interface{} `url:"enabled,omitempty" json:"enabled,omitempty" validate:"omitempty,isBool"`
|
||||
|
||||
// Find by storage policy id
|
||||
// Required: false
|
||||
StoragePolicyID uint64 `url:"storage_policy_id,omitempty" json:"storage_policy_id,omitempty"`
|
||||
}
|
||||
|
||||
// List gets list of available images as a ListImages struct, optionally filtering by account ID
|
||||
|
||||
@@ -50,6 +50,9 @@ type ItemImage struct {
|
||||
// Status
|
||||
Status string `json:"status"`
|
||||
|
||||
// Storage policy ID
|
||||
StoragePolicyID uint64 `json:"storage_policy_id"`
|
||||
|
||||
// Type
|
||||
Type string `json:"type"`
|
||||
|
||||
@@ -89,9 +92,6 @@ type RecordImage struct {
|
||||
// UNCPathj
|
||||
UNCPath string `json:"UNCPath"`
|
||||
|
||||
// CKey
|
||||
CKey string `json:"_ckey"`
|
||||
|
||||
// Account ID
|
||||
AccountID uint64 `json:"accountId"`
|
||||
|
||||
@@ -140,12 +140,18 @@ type RecordImage struct {
|
||||
// ID
|
||||
ID uint64 `json:"id"`
|
||||
|
||||
// Independent
|
||||
Independent bool `json:"independent"`
|
||||
|
||||
// Last modified
|
||||
LastModified uint64 `json:"lastModified"`
|
||||
|
||||
// Link to
|
||||
LinkTo uint64 `json:"linkTo"`
|
||||
|
||||
// Links to
|
||||
LinksTo []uint64 `json:"linksTo"`
|
||||
|
||||
// Milestones
|
||||
Milestones uint64 `json:"milestones"`
|
||||
|
||||
@@ -197,6 +203,9 @@ type RecordImage struct {
|
||||
// Tech status
|
||||
TechStatus string `json:"techStatus"`
|
||||
|
||||
// Need to clean before destroy
|
||||
ToClean bool `json:"to_clean"`
|
||||
|
||||
// Type
|
||||
Type string `json:"type"`
|
||||
|
||||
|
||||
@@ -169,6 +169,7 @@ type CreateRequest struct {
|
||||
|
||||
// Type of the emulated system, Q35 or i440fx
|
||||
// Required: false
|
||||
// Default: Q35
|
||||
Chipset string `url:"chipset,omitempty" json:"chipset,omitempty" validate:"omitempty,chipset"`
|
||||
|
||||
// Zone ID
|
||||
|
||||
@@ -24,6 +24,7 @@ type WorkerAddRequest struct {
|
||||
|
||||
// Type of the emulated system, Q35 or i440fx
|
||||
// Required: false
|
||||
// Default: Q35
|
||||
Chipset string `url:"chipset,omitempty" json:"chipset,omitempty" validate:"omitempty,chipset"`
|
||||
}
|
||||
|
||||
|
||||
@@ -66,6 +66,7 @@ type WorkersGroupAddRequest struct {
|
||||
|
||||
// Type of the emulated system, Q35 or i440fx
|
||||
// Required: false
|
||||
// Default: Q35
|
||||
Chipset string `url:"chipset,omitempty" json:"chipset,omitempty" validate:"omitempty,chipset"`
|
||||
}
|
||||
|
||||
|
||||
@@ -30,15 +30,36 @@ type Interface struct {
|
||||
// Required: false
|
||||
IPAddr string `url:"ipAddr,omitempty" json:"ipAddr,omitempty"`
|
||||
|
||||
// Maximum transmission unit, must be 1-9216
|
||||
// Used only to DPDK net type
|
||||
// Used for EXTNET, TRUNK and DPDK
|
||||
// Must be 1500-9216
|
||||
// Required: false
|
||||
MTU uint64 `url:"mtu,omitempty" json:"mtu,omitempty" validate:"omitempty,mtu"`
|
||||
|
||||
// Net mask
|
||||
// Used only to DPDK or VFNIC net type
|
||||
// Required: false
|
||||
NetMask uint64 `url:"netMask,omitempty" json:"netMask,omitempty"`
|
||||
|
||||
// MAC address to assign to this VM when connecting to the specified network
|
||||
// Required: false
|
||||
MAC string `url:"mac,omitempty" json:"mac,omitempty" validate:"omitempty"`
|
||||
|
||||
// SDN Segment ID
|
||||
// Required: false
|
||||
SDNSegmentID string `url:"sdn_segment_id,omitempty" json:"sdn_segment_id,omitempty"`
|
||||
|
||||
// SDN Object Group IDs
|
||||
// Required: false
|
||||
SDNObjectGroupIDs []string `url:"sdn_object_group_ids,omitempty" json:"sdn_object_group_ids,omitempty"`
|
||||
|
||||
// SDN Logical Port Display Name
|
||||
// Required: false
|
||||
SDNLogicalPortDisplayName string `url:"sdn_logical_port_display_name,omitempty" json:"sdn_logical_port_display_name,omitempty"`
|
||||
|
||||
// SDN Logical Port Description
|
||||
// Required: false
|
||||
SDNLogicalPortDescription string `url:"sdn_logical_port_description,omitempty" json:"sdn_logical_port_description,omitempty"`
|
||||
|
||||
// SDN interface id
|
||||
// Required: false
|
||||
SDNInterfaceID string `url:"sdn_interface_id,omitempty" json:"sdn_interface_id,omitempty"`
|
||||
@@ -48,6 +69,7 @@ type Interface struct {
|
||||
SecGroups []uint64 `url:"security_groups,omitempty" json:"security_groups,omitempty"`
|
||||
|
||||
// Flag indicating whether security groups are enabled for this interface
|
||||
// Not applicable to netType VFNIC, TRUNK, or SDN
|
||||
// Required: false
|
||||
EnableSecGroups bool `url:"enable_secgroups,omitempty" json:"enable_secgroups,omitempty"`
|
||||
|
||||
@@ -121,6 +143,10 @@ type CreateRequest struct {
|
||||
// Required: false
|
||||
ImageID uint64 `url:"imageId,omitempty" json:"imageId,omitempty"`
|
||||
|
||||
// The OS version that will be installed on the virtual machine
|
||||
// Required: false
|
||||
OSVersion string `url:"os_version,omitempty" json:"os_version,omitempty"`
|
||||
|
||||
// Size of the boot disk in GB
|
||||
// Required: false
|
||||
BootDisk uint64 `url:"bootDisk,omitempty" json:"bootDisk,omitempty"`
|
||||
@@ -158,14 +184,6 @@ type CreateRequest struct {
|
||||
// Required: false
|
||||
Start bool `url:"start" json:"start"`
|
||||
|
||||
// System name
|
||||
// Required: false
|
||||
IS string `url:"IS,omitempty" json:"IS,omitempty"`
|
||||
|
||||
// Compute purpose
|
||||
// Required: false
|
||||
IPAType string `url:"ipaType,omitempty" json:"ipaType,omitempty"`
|
||||
|
||||
// Custom fields for compute. Must be a dict
|
||||
// Required: false
|
||||
CustomFields string `url:"customFields,omitempty" json:"customFields,omitempty"`
|
||||
@@ -185,6 +203,7 @@ type CreateRequest struct {
|
||||
|
||||
// Type of the emulated system, Q35 or i440fx
|
||||
// Required: false
|
||||
// Default: Q35
|
||||
Chipset string `url:"chipset,omitempty" json:"chipset,omitempty" validate:"omitempty,chipset"`
|
||||
|
||||
// Use Huge Pages to allocate RAM of the virtual machine. The system must be pre-configured by allocating Huge Pages on the physical node
|
||||
@@ -199,6 +218,15 @@ type CreateRequest struct {
|
||||
// Zone ID
|
||||
// Required: false
|
||||
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"`
|
||||
}
|
||||
|
||||
// GetRAM returns RAM field values
|
||||
@@ -226,7 +254,7 @@ func (k KVMX86) Create(ctx context.Context, req CreateRequest) (uint64, error) {
|
||||
|
||||
var interfaces []string
|
||||
|
||||
if req.Interfaces != nil && len(req.Interfaces) != 0 {
|
||||
if len(req.Interfaces) != 0 {
|
||||
interfaces = make([]string, 0, len(req.Interfaces))
|
||||
|
||||
for i := range req.Interfaces {
|
||||
@@ -243,7 +271,7 @@ func (k KVMX86) Create(ctx context.Context, req CreateRequest) (uint64, error) {
|
||||
|
||||
var dataDisks []string
|
||||
|
||||
if req.DataDisks != nil && len(req.DataDisks) != 0 {
|
||||
if len(req.DataDisks) != 0 {
|
||||
dataDisks = make([]string, 0, len(req.DataDisks))
|
||||
|
||||
for i := range req.DataDisks {
|
||||
|
||||
@@ -63,8 +63,27 @@ type CreateBlankRequest struct {
|
||||
|
||||
// Type of the emulated system, Q35 or i440fx
|
||||
// Required: false
|
||||
// Default: Q35
|
||||
Chipset string `url:"chipset,omitempty" json:"chipset,omitempty" validate:"omitempty,chipset"`
|
||||
|
||||
// Use Huge Pages to allocate RAM of the virtual machine. The system must be pre-configured by allocating Huge Pages on the physical node
|
||||
// Required: false
|
||||
// Default: false
|
||||
HPBacked bool `url:"hp_backed" json:"hp_backed"`
|
||||
|
||||
// Run VM on dedicated CPUs. To use this feature, the system must be pre-configured by allocating CPUs on the physical node
|
||||
// Required: false
|
||||
// Default: false
|
||||
CPUPin bool `url:"cpu_pin" json:"cpu_pin"`
|
||||
|
||||
// Rule for VM placement with NUMA affinity.
|
||||
// Possible values - none (placement without NUMA affinity),
|
||||
// strict (strictly with NUMA affinity, if not possible - do not start VM),
|
||||
// loose (use NUMA affinity if possible)
|
||||
// Required: false
|
||||
// Default: none
|
||||
NumaAffinity string `url:"numa_affinity,omitempty" json:"numa_affinity,omitempty" validate:"omitempty,numaAffinity"`
|
||||
|
||||
// Text description of this VM
|
||||
// Required: false
|
||||
Description string `url:"desc,omitempty" json:"desc,omitempty"`
|
||||
@@ -92,6 +111,19 @@ type CreateBlankRequest struct {
|
||||
// Zone ID
|
||||
// Required: false
|
||||
ZoneID uint64 `url:"zoneId,omitempty" json:"zoneId,omitempty"`
|
||||
|
||||
// The OS version that will be installed on the virtual machine
|
||||
// Required: false
|
||||
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"`
|
||||
}
|
||||
|
||||
// GetRAM returns RAM field values
|
||||
@@ -119,7 +151,7 @@ func (k KVMX86) CreateBlank(ctx context.Context, req CreateBlankRequest) (uint64
|
||||
|
||||
var interfaces []string
|
||||
|
||||
if req.Interfaces != nil && len(req.Interfaces) != 0 {
|
||||
if len(req.Interfaces) != 0 {
|
||||
interfaces = make([]string, 0, len(req.Interfaces))
|
||||
|
||||
for i := range req.Interfaces {
|
||||
@@ -136,7 +168,7 @@ func (k KVMX86) CreateBlank(ctx context.Context, req CreateBlankRequest) (uint64
|
||||
|
||||
var dataDisks []string
|
||||
|
||||
if req.DataDisks != nil && len(req.DataDisks) != 0 {
|
||||
if len(req.DataDisks) != 0 {
|
||||
dataDisks = make([]string, 0, len(req.DataDisks))
|
||||
|
||||
for i := range req.DataDisks {
|
||||
|
||||
@@ -38,8 +38,8 @@ type CreateRequest struct {
|
||||
HighlyAvailable bool `url:"highlyAvailable,omitempty" json:"highlyAvailable,omitempty"`
|
||||
|
||||
// Start now Load balancer
|
||||
// Required: true
|
||||
Start bool `url:"start" json:"start" validate:"required"`
|
||||
// Required: false
|
||||
Start interface{} `url:"start,omitempty" json:"start,omitempty" validate:"omitempty,isBool"`
|
||||
|
||||
// Text description of this load balancer
|
||||
// Required: false
|
||||
|
||||
@@ -16,22 +16,22 @@ type HighlyAvailableRequest struct {
|
||||
}
|
||||
|
||||
// HighlyAvailable makes load balancer highly available
|
||||
func (l LB) HighlyAvailable(ctx context.Context, req HighlyAvailableRequest) (uint64, error) {
|
||||
func (l LB) HighlyAvailable(ctx context.Context, req HighlyAvailableRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return 0, validators.ValidationErrors(validators.GetErrors(err))
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudapi/lb/makeHighlyAvailable"
|
||||
|
||||
res, err := l.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
return false, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseUint(string(res), 10, 64)
|
||||
result, err := strconv.ParseBool(string(res))
|
||||
if err != nil {
|
||||
return 0, err
|
||||
return false, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user