From eb195dd992b80d67b4d9ca41327107f4fa07bca7 Mon Sep 17 00:00:00 2001 From: Arseniy Volkov Date: Fri, 21 Aug 2026 17:52:28 +0400 Subject: [PATCH] v1.16.0 --- CHANGELOG.md | 210 ++++++++++++++++-- README.md | 7 + internal/constants/constants.go | 1 + internal/validators/custom.go | 6 + internal/validators/messages.go | 6 + internal/validators/validator.go | 5 + internal/validators/values.go | 4 +- pkg/cloudapi/account/audits.go | 40 ---- pkg/cloudapi/account/delete.go | 36 --- pkg/cloudapi/account/disable_enable.go | 60 ----- .../get_consumed_cloud_units_by_type.go | 51 ----- .../account/get_reserved_account_units.go | 47 ---- pkg/cloudapi/account/models.go | 101 ++++++++- pkg/cloudapi/bservice/group_add.go | 7 +- pkg/cloudapi/compute/audits.go | 76 ------- pkg/cloudapi/compute/change_qos_policies.go | 84 +++++++ pkg/cloudapi/compute/get_audits.go | 40 ---- pkg/cloudapi/compute/list_pci_device.go | 4 - pkg/cloudapi/compute/models.go | 142 ++++-------- pkg/cloudapi/compute/net_attach.go | 4 + pkg/cloudapi/compute/update.go | 5 + pkg/cloudapi/disks/create.go | 37 ++- pkg/cloudapi/disks/list.go | 2 +- pkg/cloudapi/k8s/create.go | 2 +- .../k8s/update_worker_nodes_meta_data.go | 2 +- pkg/cloudapi/kvmx86/create.go | 58 ++++- pkg/cloudapi/kvmx86/create_blank.go | 5 + pkg/cloudapi/locations/models.go | 3 + pkg/cloudapi/network_qos_policy.go | 10 + pkg/cloudapi/qospolicy/create.go | 46 ++++ pkg/cloudapi/qospolicy/create_rule.go | 93 ++++++++ pkg/cloudapi/qospolicy/delete.go | 37 +++ pkg/cloudapi/qospolicy/delete_rule.go | 41 ++++ pkg/cloudapi/qospolicy/filter.go | 89 ++++++++ pkg/cloudapi/qospolicy/filter_test.go | 97 ++++++++ pkg/cloudapi/qospolicy/get.go | 43 ++++ pkg/cloudapi/qospolicy/list.go | 89 ++++++++ pkg/cloudapi/qospolicy/models.go | 122 ++++++++++ pkg/cloudapi/qospolicy/qos_policy.go | 15 ++ pkg/cloudapi/qospolicy/sorting.go | 39 ++++ pkg/cloudapi/qospolicy/update.go | 52 +++++ pkg/cloudapi/rg/audits.go | 40 ---- pkg/cloudapi/tasks/list.go | 8 + pkg/cloudapi/tasks/models.go | 3 + pkg/cloudapi/user/get_audit.go | 61 ----- .../user/is_valid_invite_user_token.go | 44 ---- pkg/cloudapi/user/models.go | 48 ++-- pkg/cloudapi/vgpu/list.go | 22 +- pkg/cloudapi/vgpu/models.go | 58 +++-- pkg/cloudapi/vins/audits.go | 40 ---- pkg/cloudapi/vins/models.go | 3 + pkg/cloudapi/zone/models.go | 18 ++ pkg/cloudbroker/account/audits.go | 40 ---- pkg/cloudbroker/account/disable.go | 38 ---- pkg/cloudbroker/account/enable.go | 38 ---- pkg/cloudbroker/account/models.go | 52 ++++- pkg/cloudbroker/bservice/group_add.go | 7 +- pkg/cloudbroker/compute/audits.go | 76 ------- .../compute/change_qos_policies.go | 84 +++++++ pkg/cloudbroker/compute/computeci_set.go | 42 ---- pkg/cloudbroker/compute/computeci_unset.go | 38 ---- pkg/cloudbroker/compute/get_audits.go | 40 ---- pkg/cloudbroker/compute/get_log.go | 36 --- pkg/cloudbroker/compute/list_pci_device.go | 4 - pkg/cloudbroker/compute/models.go | 142 ++++-------- pkg/cloudbroker/compute/net_attach.go | 4 + pkg/cloudbroker/compute/update.go | 5 + pkg/cloudbroker/disks/create.go | 35 ++- pkg/cloudbroker/disks/list.go | 2 +- pkg/cloudbroker/disks/migrate.go | 39 +++- .../grid/execute_maintenance_script.go | 46 ---- pkg/cloudbroker/grid/list_emails.go | 37 --- pkg/cloudbroker/grid/models.go | 6 + pkg/cloudbroker/grid/services_restart.go | 42 ---- pkg/cloudbroker/group/get.go | 46 ---- pkg/cloudbroker/image/computeci_set.go | 42 ---- pkg/cloudbroker/image/computeci_unset.go | 38 ---- pkg/cloudbroker/k8s/create.go | 2 +- .../k8s/update_worker_nodes_meta_data.go | 2 +- pkg/cloudbroker/kvmx86/create.go | 58 ++++- pkg/cloudbroker/kvmx86/create_blank.go | 5 + pkg/cloudbroker/kvmx86/mass_create.go | 9 + pkg/cloudbroker/network_qos_policy.go | 10 + pkg/cloudbroker/node/models.go | 2 +- pkg/cloudbroker/qospolicy/create.go | 46 ++++ pkg/cloudbroker/qospolicy/create_rule.go | 94 ++++++++ pkg/cloudbroker/qospolicy/delete.go | 37 +++ pkg/cloudbroker/qospolicy/delete_rule.go | 41 ++++ pkg/cloudbroker/qospolicy/filter.go | 89 ++++++++ pkg/cloudbroker/qospolicy/filter_test.go | 97 ++++++++ pkg/cloudbroker/qospolicy/get.go | 43 ++++ pkg/cloudbroker/qospolicy/list.go | 88 ++++++++ pkg/cloudbroker/qospolicy/models.go | 122 ++++++++++ pkg/cloudbroker/qospolicy/qos_policy.go | 15 ++ pkg/cloudbroker/qospolicy/sorting.go | 39 ++++ pkg/cloudbroker/qospolicy/update.go | 52 +++++ pkg/cloudbroker/resmon/models.go | 11 +- pkg/cloudbroker/rg/audits.go | 40 ---- pkg/cloudbroker/rg/create.go | 4 + pkg/cloudbroker/sep/access_grant.go | 43 ---- pkg/cloudbroker/sep/access_grant_to_pool.go | 50 ----- pkg/cloudbroker/sep/access_revoke.go | 42 ---- pkg/cloudbroker/sep/access_revoke_to_pool.go | 50 ----- pkg/cloudbroker/tasks/list.go | 8 + pkg/cloudbroker/tasks/models.go | 3 + pkg/cloudbroker/user/get_audit.go | 62 ------ pkg/cloudbroker/vgpu/allocate.go | 37 --- pkg/cloudbroker/vgpu/create.go | 23 +- pkg/cloudbroker/vgpu/deallocate.go | 41 ---- pkg/cloudbroker/vgpu/destroy.go | 9 +- pkg/cloudbroker/vgpu/list.go | 24 +- pkg/cloudbroker/vgpu/models.go | 55 +++-- pkg/cloudbroker/vins/audits.go | 40 ---- pkg/cloudbroker/zone/models.go | 18 ++ tests/platform_upgrade/cloud_test.go | 42 ++++ tests/platform_upgrade/request_map.go | 97 ++++---- 116 files changed, 2719 insertions(+), 1973 deletions(-) delete mode 100644 pkg/cloudapi/account/audits.go delete mode 100644 pkg/cloudapi/account/delete.go delete mode 100644 pkg/cloudapi/account/disable_enable.go delete mode 100644 pkg/cloudapi/account/get_consumed_cloud_units_by_type.go delete mode 100644 pkg/cloudapi/account/get_reserved_account_units.go delete mode 100644 pkg/cloudapi/compute/audits.go create mode 100644 pkg/cloudapi/compute/change_qos_policies.go delete mode 100644 pkg/cloudapi/compute/get_audits.go create mode 100644 pkg/cloudapi/network_qos_policy.go create mode 100644 pkg/cloudapi/qospolicy/create.go create mode 100644 pkg/cloudapi/qospolicy/create_rule.go create mode 100644 pkg/cloudapi/qospolicy/delete.go create mode 100644 pkg/cloudapi/qospolicy/delete_rule.go create mode 100644 pkg/cloudapi/qospolicy/filter.go create mode 100644 pkg/cloudapi/qospolicy/filter_test.go create mode 100644 pkg/cloudapi/qospolicy/get.go create mode 100644 pkg/cloudapi/qospolicy/list.go create mode 100644 pkg/cloudapi/qospolicy/models.go create mode 100644 pkg/cloudapi/qospolicy/qos_policy.go create mode 100644 pkg/cloudapi/qospolicy/sorting.go create mode 100644 pkg/cloudapi/qospolicy/update.go delete mode 100644 pkg/cloudapi/rg/audits.go delete mode 100644 pkg/cloudapi/user/get_audit.go delete mode 100644 pkg/cloudapi/user/is_valid_invite_user_token.go delete mode 100644 pkg/cloudapi/vins/audits.go delete mode 100644 pkg/cloudbroker/account/audits.go delete mode 100644 pkg/cloudbroker/account/disable.go delete mode 100644 pkg/cloudbroker/account/enable.go delete mode 100644 pkg/cloudbroker/compute/audits.go create mode 100644 pkg/cloudbroker/compute/change_qos_policies.go delete mode 100644 pkg/cloudbroker/compute/computeci_set.go delete mode 100644 pkg/cloudbroker/compute/computeci_unset.go delete mode 100644 pkg/cloudbroker/compute/get_audits.go delete mode 100644 pkg/cloudbroker/compute/get_log.go delete mode 100644 pkg/cloudbroker/grid/execute_maintenance_script.go delete mode 100644 pkg/cloudbroker/grid/list_emails.go delete mode 100644 pkg/cloudbroker/grid/services_restart.go delete mode 100644 pkg/cloudbroker/group/get.go delete mode 100644 pkg/cloudbroker/image/computeci_set.go delete mode 100644 pkg/cloudbroker/image/computeci_unset.go create mode 100644 pkg/cloudbroker/network_qos_policy.go create mode 100644 pkg/cloudbroker/qospolicy/create.go create mode 100644 pkg/cloudbroker/qospolicy/create_rule.go create mode 100644 pkg/cloudbroker/qospolicy/delete.go create mode 100644 pkg/cloudbroker/qospolicy/delete_rule.go create mode 100644 pkg/cloudbroker/qospolicy/filter.go create mode 100644 pkg/cloudbroker/qospolicy/filter_test.go create mode 100644 pkg/cloudbroker/qospolicy/get.go create mode 100644 pkg/cloudbroker/qospolicy/list.go create mode 100644 pkg/cloudbroker/qospolicy/models.go create mode 100644 pkg/cloudbroker/qospolicy/qos_policy.go create mode 100644 pkg/cloudbroker/qospolicy/sorting.go create mode 100644 pkg/cloudbroker/qospolicy/update.go delete mode 100644 pkg/cloudbroker/rg/audits.go delete mode 100644 pkg/cloudbroker/sep/access_grant.go delete mode 100644 pkg/cloudbroker/sep/access_grant_to_pool.go delete mode 100644 pkg/cloudbroker/sep/access_revoke.go delete mode 100644 pkg/cloudbroker/sep/access_revoke_to_pool.go delete mode 100644 pkg/cloudbroker/user/get_audit.go delete mode 100644 pkg/cloudbroker/vgpu/allocate.go delete mode 100644 pkg/cloudbroker/vgpu/deallocate.go delete mode 100644 pkg/cloudbroker/vins/audits.go diff --git a/CHANGELOG.md b/CHANGELOG.md index 3f7682a..56cb944 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,35 +1,209 @@ -## Version 1.15.7 - -Методы `Audits` в cloudapi/compute, cloudbroker/compute, cloudapi/account, cloudbroker/account, cloudapi/vins, cloudbroker/vins, cloudapi/rg и cloudbroker/rg стали deprecated и будут удалены в версии 1.16, вместо них необходимо использовать метод `List` в cloudapi/audit и cloudbroker/audit с соответствующими фильтрами -Методы `AccessGrant`, `AccessGrantToPool`, `AccessRevoke`, `AccessRevokeToPool` в cloudbroker/sep стали deprecated и будут удалены в версии 1.16 -Методы `ComputeCISet`, `ComputeCIUnset`, `GetAudits` в cloudbroker/compute и `GetAudits` в cloudapi/compute стали deprecated и будут удалены в версии 1.16 -Методы `ComputeCISet`, `ComputeCIUnset` в cloudbroker/image стали deprecated и будут удалены в версии 1.16 -Методы `Delete`, `Disable`, `Enable`, `GetConsumedCloudUnitsByType`, `GetReservedAccountUnits` в cloudapi/account стали deprecated и будут удалены в версии 1.16 -Методы `Disable`, `Enable` в cloudbroker/account стали deprecated и будут удалены в версии 1.16 -Метод `IsValidInviteUserToken` в cloudapi/user стал deprecated и будет удален в версии 1.16 -Метод `GetLog` в cloudbroker/compute стал deprecated и будет удален в версии 1.16 -Методы `ExecuteMaintenanceScript`, `ListEmails`, `ServicesRestart` в cloudbroker/grid стали deprecated и будут удалены в версии 1.16 -Метод `Get` в cloudbroker/group стал deprecated и будет удален в версии 1.16 +## Version 1.16.0 +Метод `ConfigFieldEdit` в cloudbroker/sep стал deprecated и в следующих версиях будет удалён ### Добавлено +#### Общее +| Идентификатор задачи | Описание | +| --- | --- | +| BGOS-991 | Допустимые значения `vgpu` и `pcidevice` в валидатор возможностей гипервизора ComputeFeatures | + +#### account +| Идентификатор задачи | Описание | +| --- | --- | +| BGOS-986 | Вычисляемое поле `EnableDefaultGateway` в структуру ответа `ItemVINS` в cloudbroker/account и cloudapi/account | +| BGOS-989 | Вычисляемые поля `Starting`, `Stopping`, `Paused`, `Pausing`, `Merge`, `Migrating`, `MigratingIn`, `MigratingOut`, `Down`, `Scheduled`, `BackupStopped`, `BackupRunning`, `Snapcreate`, `Cloning` и `Rollback` в структуры ответа `Computes` и `RGComputes` в cloudapi/account | +| BGOS-989 | Вычисляемые поля `Starting`, `Stopping`, `Paused`, `Pausing`, `Merge`, `Migrating`, `MigratingIn`, `MigratingOut`, `Down`, `Scheduled`, `BackupStopped`, `BackupRunning`, `Snapcreate`, `Cloning` и `Rollback` в структуру ответа `Computes` в cloudbroker/account | + #### compute | Идентификатор задачи | Описание | | --- | --- | -| BGOS-966 | Вычисляемое поле `CPUSet` в структуру ответа `RecordMigrateStorageInfo` в cloudbroker/compute | -| BGOS-966 | Вычисляемое поля `Clock`, `CPUAlignmentProfile` и `Weight` в структуру `ShadowCompute` в cloudbroker/compute | -| BGOS-966 | Вычисляемое поле `EnableDefaultGateway` в структуру `ItemShadowComputeInterface` в cloudbroker/compute | +| BGOS-977 | Вычисляемое поле `ImageID` в структуру ответа `InfoDisk` в cloudbroker/compute и cloudapi/compute | +| BGOS-978 | Вычисляемое поле `WatchdogAction` в структуры ответа `RecordCompute` и `ItemCompute` в cloudapi/compute | +| BGOS-978 | Вычисляемое поле `WatchdogAction` в структуры ответа `RecordCompute` и `InfoCompute` в cloudbroker/compute | +| BGOS-979 | Опциональное поле `WatchdogAction` в структуру запроса `UpdateRequest` в cloudapi/compute и cloudbroker/compute | +| BGOS-994 | Вычисляемое поле `QoSPolicies` в структуру ответа `ItemVNFInterface` в cloudapi/compute | +| BGOS-994 | Вычисляемое поле `QoSPolicies` в структуру ответа `ItemInterface` в cloudbroker/compute | +| BGOS-994 | Опциональное поле `QoSPolicies` в структуру запроса `NetAttachRequest` в cloudapi/compute и cloudbroker/compute | +| BGOS-994 | Методы `ChangeQoSPolicies` и `ChangeQoSPoliciesAsync` в cloudbroker/compute и cloudapi/compute | +| BGOS-995 | Вычисляемые поля `ComputeID`, `BusNumber`, `DeviceReference`, `MdevUUID`, `ParentPCIAddress`, `ProfileReference` и `SplitMode` в структуру ответа `ItemVGPU` в cloudbroker/compute и cloudapi/compute | +| BGOS-999 | Вычисляемое поле `AccountIDs` в структуру ответа `ItemPCIDevice` в cloudbroker/compute и cloudapi/compute | + +#### disks +| Идентификатор задачи | Описание | +| --- | --- | +| BGOS-976 | Метод `CreateAsync` в cloudapi/disks | +| BGOS-976 | Методы `CreateAsync` и `MigrateAsync` в cloudbroker/disks | + +#### grid +| Идентификатор задачи | Описание | +| --- | --- | +| BGOS-1000 | Вычисляемые поля `ReservedCPU` и `ReservedRAM` в структуру ответа `RecordSettingsGrid` в cloudbroker/grid | + +#### kvmx86 +| Идентификатор задачи | Описание | +| --- | --- | +| BGOS-979 | Опциональное поле `WatchdogAction` в структуры запроса `CreateRequest` и `CreateBlankRequest` в cloudapi/kvmx86 | +| BGOS-979 | Опциональное поле `WatchdogAction` в структуры запроса `CreateRequest`, `CreateBlankRequest` и `MassCreateRequest` в cloudbroker/kvmx86 | +| BGOS-983 | Метод `CreateAsync` в cloudbroker/kvmx86 и cloudapi/kvmx86 | +| BGOS-984 | Опциональное поле `ReadOnly` в структуру запроса `DataDisk` в cloudbroker/kvmx86 и cloudapi/kvmx86 | +| BGOS-994 | Опциональное поле `QoSPolicies` в структуру запроса `Interface` в cloudbroker/kvmx86 и cloudapi/kvmx86 | +| BGOS-994 | Опциональное поле `QoSPolicies` в структуру запроса `InterfaceMassCreate` в cloudbroker/kvmx86 | + +#### locations +| Идентификатор задачи | Описание | +| --- | --- | +| BGOS-992 | Вычисляемое поле `Budget` в структуру ответа `ItemLocation` в cloudapi/locations | + +#### network qos policy +| Идентификатор задачи | Описание | +| --- | --- | +| BGOS-993 | Группа ручек `QoSPolicy` в cloudbroker/qospolicy и cloudapi/qospolicy | + +#### resmon +| Идентификатор задачи | Описание | +| --- | --- | +| BGOS-981 | Вычисляемое поле `TotalVCPUs` в структуру ответа `GetByNodePoint` в cloudbroker/resmon | + +#### rg +| Идентификатор задачи | Описание | +| --- | --- | +| BGOS-998 | Опциональное поле `IPCIDR` в структуру запроса `CreateRequest` в cloudbroker/rg | + +#### tasks +| Идентификатор задачи | Описание | +| --- | --- | +| BGOS-996 | Опицональные поля `CreatedTimeAt` и `CreatedTimeTo` в структуру запроса `ListRequest` в cloudapi/tasks и cloudbroker/tasks | +| BGOS-996 | Вычисляемое поле `CreatedTime` в структуру ответа `RecordAsyncTask` в cloudapi/tasks | +| BGOS-996 | Вычисляемое поле `CreatedTime` в структуру ответа `ItemTask` в cloudbroker/tasks | + +#### user +| Идентификатор задачи | Описание | +| --- | --- | +| BGOS-988 | Вычисляемые поля `Destroying`, `Confirmed` и `Deleted` в структуру ответа `Accounts` в cloudapi/user | +| BGOS-988 | Вычисляемые поля `Starting`, `Stopping`, `Paused`, `Pausing`, `Merge`, `Migrating`, `MigratingIn`, `MigratingOut`, `Down`, `Scheduled`, `BackupStopped`, `BackupRunning`, `Snapcreate`, `Cloning` и `Rollback` в структуру ответа `Computes` в cloudapi/user | +| BGOS-988 | Вычисляемые поля `Modeled`, `Created`, `Deleted`, `Deleting`, `Destroying`, `Disabling`, `Enabling` и `Restoring` в структуру ответа `RGs` в cloudapi/user | + +#### vins +| Идентификатор задачи | Описание | +| --- | --- | +| BGOS-986 | Вычисляемое поле `EnableDefaultGateway` в структуру ответа `ItemVINS` в cloudapi/vins | + +#### vgpu +| Идентификатор задачи | Описание | +| --- | --- | +| BGOS-980 | Опциональные поля `AccountIDs`, `MDEVType` и `PCIAddress` в структуру запроса `CreateRequest` в cloudbroker/vgpu | +| BGOS-980 | Опциональное поле `SplitMode` в структуру запроса `ListRequest` в cloudbroker/vgpu и cloudapi/vgpu | +| BGOS-980 | Вычисляемые поля `ComputeID`, `DeviceReference`, `MdevUUID`, `ParentPCIAddress`, `ProfileReference` и `SplitMode` в структуру ответа `ItemVGPU` в cloudbroker/vgpu и cloudapi/vgpu | +| BGOS-980 | Вычисляемое поле `BusNumber` в структуру ответа `ItemVGPU` в cloudbroker/vgpu | + +#### zone +| Идентификатор задачи | Описание | +| --- | --- | +| BGOS-997 | Вычисляемые поля `SDRS`, `SDRSMode` и `LoggingLevel` в структуры ответа `RecordZone` и `ItemZone` в cloudapi/zone и cloudbroker/zone | + + +### Изменено + +#### bservice +| Идентификатор задачи | Описание | +| --- | --- | +| BGOS-1003 | Тип опционального поля `UserData` в структуре запроса `GroupAddRequest` сo `string` на `interface{}` в cloudbroker/bservice и cloudapi/bservice | + +#### compute +| Идентификатор задачи | Описание | +| --- | --- | +| BGOS-995 | Название вычисляемого поля `AccountID` на `AccountIDs` и тип с `uint64` на `[]uint64` в структуре ответа `ItemVGPU` в cloudbroker/compute и cloudapi/compute | +| BGOS-995 | Тип вычисляемого поля `VGPUs` с `[]VGPUItem` на `[]ItemVGPU` в структурах ответов `RecordCompute` и `SnapRecordCompute` в cloudbroker/compute и cloudapi/compute | + +#### disks +| Идентификатор задачи | Описание | +| --- | --- | +| BGOS-987 | Тип опционального поля `Status` в структуре запроса `ListRequest` с `string` на `[]string` в cloudbroker/disks и cloudapi/disks | + +#### k8s +| Идентификатор задачи | Описание | +| --- | --- | +| BGOS-1002 | Тип опционального поля `UserData` в структурах запросов `CreateRequest` и `UpdateWorkerNodesMetaDataRequest` со `string` на `interface{}` в cloudbroker/k8s и cloudapi/k8s | #### node | Идентификатор задачи | Описание | | --- | --- | -| BGOS-968 | Вычисляемое поле `OVSDPDKCores` в структуру ответа `DPDK` в cloudbroker/node | +| BGOS-982 | Тип вычисляемого поля `Total` с `ResourcesInfo` на `FreeResourcesInfo` в структуре ответа `ConsumptionInfo` в cloudbroker/node | + +#### vgpu +| Идентификатор задачи | Описание | +| --- | --- | +| BGOS-980 | Тип опционального поля `ProfileID` в структуре запроса `CreateRequest` с `uint64` на `string` в cloudbroker/vgpu | +| BGOS-980 | Название вычисляемого поля `AccountID` на `AccountIDs` и тип с `uint64` на `[]uint64` в структуре ответа `ItemVGPU` в cloudbroker/vgpu и cloudapi/vgpu | +| BGOS-980 | Название опционального поля `NID` на `NodeID` в структуре запроса `ListRequest` в cloudbroker/vgpu и cloudapi/vgpu | + ### Удалено -#### node +#### account | Идентификатор задачи | Описание | | --- | --- | -| BGOS-968 | Вычисляемое поле `PMDCPU` из структуры ответа `DPDK` в cloudbroker/node | \ No newline at end of file +| BGOS-975 | Метод `Audits` из cloudapi/account и cloudbroker/account | +| BGOS-975 | Методы `Delete`, `Disable`, `Enable`, `GetConsumedCloudUnitsByType` и `GetReservedAccountUnits` из cloudapi/account | +| BGOS-975 | Методы `Disable` и `Enable` из cloudbroker/account | + +#### compute +| Идентификатор задачи | Описание | +| --- | --- | +| BGOS-975 | Метод `Audits` из cloudapi/compute и cloudbroker/compute | +| BGOS-975 | Методы `ComputeCISet`, `ComputeCIUnset`, `GetLog` и `GetAudits` из cloudbroker/compute | +| BGOS-975 | Метод `GetAudits` из cloudapi/compute | +| BGOS-995 | Вычисляемые поля `LastClaimedBy`, `Mode`, `ProfileID`, `RAM`, `ReferenceID`, `RGID`, `Type` и `VMID` из структуры `ItemVGPU` в cloudbroker/compute и cloudapi/compute | +| BGOS-995 | Cтруктура `VGPUItem` в cloudbroker/compute и cloudapi/compute | +| BGOS-999 | Вычисляемое поле `RGID` из структуры ответа `ItemPCIDevice` в cloudbroker/compute и cloudapi/compute | +| BGOS-999 | Опциональное поле `RGID` из структуры запроса `ListPCIDeviceRequest` в cloudbroker/compute и cloudapi/compute | + +#### grid +| Идентификатор задачи | Описание | +| --- | --- | +| BGOS-975 | Методы `ExecuteMaintenanceScript`, `ListEmails` и `ServicesRestart` из cloudbroker/grid | + +#### group +| Идентификатор задачи | Описание | +| --- | --- | +| BGOS-975 | Метод `Get` из cloudbroker/group | + +#### image +| Идентификатор задачи | Описание | +| --- | --- | +| BGOS-975 | Методы `ComputeCISet` и `ComputeCIUnset` из cloudbroker/image | + +#### rg +| Идентификатор задачи | Описание | +| --- | --- | +| BGOS-975 | Метод `Audits` из cloudapi/rg и cloudbroker/rg | + +#### sep +| Идентификатор задачи | Описание | +| --- | --- | +| BGOS-975 | Методы `AccessGrant`, `AccessGrantToPool`, `AccessRevoke` и `AccessRevokeToPool` из cloudbroker/sep | + +#### user +| Идентификатор задачи | Описание | +| --- | --- | +| BGOS-975 | Метод `IsValidInviteUserToken` из cloudapi/user | +| BGOS-975 | Метод `GetAudit` из cloudapi/user и cloudbroker/user | +| BGOS-988 | Структуры `CSs` и `VMs` из структуры ответа `BriefResources` из cloudapi/user | +| BGOS-988 | Вычисляемое поле `Enabled` из структур ответов `Accounts` и `RGs` из cloudapi/user | + +#### vins +| Идентификатор задачи | Описание | +| --- | --- | +| BGOS-975 | Метод `Audits` из cloudapi/vins и cloudbroker/vins | + +#### vgpu +| Идентификатор задачи | Описание | +| --- | --- | +| BGOS-980 | Опциональные поля `RGID` и `Allocate` из структуры запроса `CreateRequest` в cloudbroker/vgpu | +| BGOS-980 | Опциональные поле `Force` из структуры запроса `DestroyRequest` в cloudbroker/vgpu | +| BGOS-980 | Опциональные поля `Type`, `Mode` и `RGID` из структуры запроса `ListRequest` в cloudbroker/vgpu и cloudapi/vgpu | +| BGOS-980 | Вычисляемые поля `LastClaimedBy`, `Mode`, `ProfileID`, `RAM`, `ReferenceID`, `RGID`, `Type` и `VMID` из структуры ответа `ItemVGPU` в cloudbroker/vgpu и cloudapi/vgpu | +| BGOS-980 | Методы `Allocate` и `Deallocate` из cloudbroker/vgpu | \ No newline at end of file diff --git a/README.md b/README.md index 47cc1cd..fe23535 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,7 @@ Decort SDK - это библиотека, написанная на языке G - Версия 1.13.х Decort-SDK соответствует 4.5.0 версии платформы - Версия 1.14.х Decort-SDK соответствует 4.6.0 версии платформы - Версия 1.15.х Decort-SDK соответствует 4.7.0 версии платформы + - Версия 1.16.х Decort-SDK соответствует 4.8.0 версии платформы ## Оглавление @@ -125,6 +126,7 @@ go get -u repository.basistech.ru/BASIS/decort-golang-sdk - `LB` - управление балансировщиками нагрузки; - `Locations` - получение информации о grid площадки; - `Prometheus` - получение статистики prometheus; +- `QoS Policy` - управление политиками качества обслуживания сети; - `RG` - управление ресурсными группами аккаунта; - `Security group` – управление группами безопасности; - `SEP` - управление storage endpoint (sep); @@ -161,6 +163,7 @@ go get -u repository.basistech.ru/BASIS/decort-golang-sdk - `Node` - управление нодами платформы; - `PCIDevice` - управление устройствами; - `Prometheus` - получение статистики prometheus; +- `QoS Policy` - управление политиками качества обслуживания сети; - `Resmon` - получение статистики resource monitoring; - `RG` - управление ресурсными группами аккаунта; - `Security group` – управление группами безопасности; @@ -338,6 +341,7 @@ func main() { - `pkg/cloudapi/lb` - для `LB` - `pkg/cloudapi/locations` - для `Locations` - `pkg/cloudapi/prometheus` - для `Prometheus` + - `pkg/cloudapi/qospolicy` - для `QoS Policy` - `pkg/cloudapi/rg` - для `RG` - `pkg/cloudapi/secgroup` - для `Security group` - `pkg/cloudapi/sep` - для `SEP` @@ -369,6 +373,7 @@ func main() { - `pkg/cloudbroker/node` - для `Node` - `pkg/cloudbroker/pcidevice` - для `PCIDevice` - `pkg/cloudbroker/prometheus` - для `Prometheus` + - `pkg/cloudbroker/qospolicy` - для `QoS Policy` - `pkg/cloudbroker/resmon` - для `Resmon` - `pkg/cloudbroker/rg` - для `RG` - `pkg/cloudbroker/secgroup` - для `Security group` @@ -537,6 +542,7 @@ func main() { - `.LB()` - для работы с `LB` - `.Locations()` - для работы с `Locations` - `.Prometheus()` - для работы с `Prometheus` + - `.QoSPolicy()` - для работы с `QoS Policy` - `.RG()` - для работы с `RG` - `.SecurityGroup()` - для работы с `Security Group` - `.SEP()` - для работы с `SEP` @@ -570,6 +576,7 @@ func main() { - `.Node()` - для работы с `Node` - `.PCIDevice()` - для работы с `PCIDevice` - `.Prometheus()` - для работы с `Prometheus` + - `.QoSPolicy()` - для работы с `QoS Policy` - `.Resmon()` - для работы с `Resmon` - `.RG()` - для работы с `RG` - `.SecurityGroup()` - для работы с `Security Group` diff --git a/internal/constants/constants.go b/internal/constants/constants.go index 737c781..6350e6f 100644 --- a/internal/constants/constants.go +++ b/internal/constants/constants.go @@ -28,6 +28,7 @@ var FileName = map[string]string{ var K8sValues = []string{"labels", "taints", "annotations, additionalSANs"} var VersionMap = map[string]string{ + "4.8.0": "-", "4.7.0": "-", "4.6.0": "-", "4.5.0": "-", diff --git a/internal/validators/custom.go b/internal/validators/custom.go index 676d476..089e4dc 100644 --- a/internal/validators/custom.go +++ b/internal/validators/custom.go @@ -488,3 +488,9 @@ func sepDescriptionValidator(fe validator.FieldLevel) bool { ok, _ := regexp.MatchString(`^[a-zA-Zа-яА-ЯёЁ0-9_.\[\]()\-]*$`, fe.Field().String()) return ok } + +func watchdogActionValidator(fe validator.FieldLevel) bool { + fieldValue := fe.Field().String() + + return IsInSlice(fieldValue, watchdogActionVaues) +} diff --git a/internal/validators/messages.go b/internal/validators/messages.go index dca4fc4..6ba8e2a 100644 --- a/internal/validators/messages.go +++ b/internal/validators/messages.go @@ -15,6 +15,10 @@ func errorMessage(fe validator.FieldError) string { // Common Validators case "required": return fmt.Sprintf("%s %s is required", prefix, fe.Field()) + case "required_without_all": + return fmt.Sprintf("%s at least one of the following must be specified: %s", + prefix, + joinValues(append([]string{fe.Field()}, strings.Fields(fe.Param())...))) case "gt": return fmt.Sprintf("%s %s can't be less or equal to zero", prefix, fe.Field()) case "min": @@ -25,6 +29,8 @@ func errorMessage(fe validator.FieldError) string { return fmt.Sprintf("%s %s: unexpected URL format", prefix, fe.Field()) case "email": return fmt.Sprintf("%s %s: unexpected E-Mail format", prefix, fe.Field()) + case "mac": + return fmt.Sprintf("%s %s: unexpected MAC address format", prefix, fe.Field()) case "isBool": return fmt.Sprintf("%s %s: must be bool type", prefix, fe.Field()) case "isString": diff --git a/internal/validators/validator.go b/internal/validators/validator.go index 47444d6..ed23a73 100644 --- a/internal/validators/validator.go +++ b/internal/validators/validator.go @@ -326,5 +326,10 @@ func registerAllValidators(validate *validator.Validate) error { return err } + err = validate.RegisterValidation("watchdogAction", watchdogActionValidator) + if err != nil { + return err + } + return nil } diff --git a/internal/validators/values.go b/internal/validators/values.go index 17adc27..18eb2f0 100644 --- a/internal/validators/values.go +++ b/internal/validators/values.go @@ -47,7 +47,7 @@ var ( vmActionValues = []string{"stop", "move"} - computeFeaturesValues = []string{"hugepages", "numa", "cpupin", "vfnic", "dpdk", "changemac", "trunk"} + computeFeaturesValues = []string{"hugepages", "numa", "cpupin", "vfnic", "dpdk", "changemac", "trunk", "vgpu", "pcidevice"} networkInterfaceNamingValues = []string{"eth", "ens"} @@ -80,6 +80,8 @@ var ( ipTypeValues = []string{"v4, v6"} sepTechStatusValues = []string{"ENABLED", "DISABLED"} + + watchdogActionVaues = []string{"reset", "shutdown", "poweroff", "pause", "none"} ) const ( diff --git a/pkg/cloudapi/account/audits.go b/pkg/cloudapi/account/audits.go deleted file mode 100644 index 267a656..0000000 --- a/pkg/cloudapi/account/audits.go +++ /dev/null @@ -1,40 +0,0 @@ -package account - -import ( - "context" - "encoding/json" - "net/http" - - "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" -) - -// AuditsRequest struct to give list of account audits -type AuditsRequest struct { - // ID of the account - // Required: true - AccountID uint64 `url:"accountId" json:"accountId" validate:"required"` -} - -// Audits gets audit records for the specified account object -func (a Account) Audits(ctx context.Context, req AuditsRequest) (ListAudits, error) { - err := validators.ValidateRequest(req) - if err != nil { - return nil, validators.ValidationErrors(validators.GetErrors(err)) - } - - url := "/cloudapi/account/audits" - - res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req) - if err != nil { - return nil, err - } - - list := ListAudits{} - - err = json.Unmarshal(res, &list) - if err != nil { - return nil, err - } - - return list, nil -} diff --git a/pkg/cloudapi/account/delete.go b/pkg/cloudapi/account/delete.go deleted file mode 100644 index a8f2f02..0000000 --- a/pkg/cloudapi/account/delete.go +++ /dev/null @@ -1,36 +0,0 @@ -package account - -import ( - "context" - "net/http" - - "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" -) - -// DeleteRequest struct to delete account -type DeleteRequest struct { - // ID of account to delete - // Required: true - AccountID uint64 `url:"accountId" json:"accountId" validate:"required"` - - // Whether to completely delete the account - // Required: false - Permanently bool `url:"permanently,omitempty" json:"permanently,omitempty"` -} - -// Delete completes delete an account from the system Returns true if account is deleted or was already deleted or never existed -func (a Account) Delete(ctx context.Context, req DeleteRequest) (string, error) { - err := validators.ValidateRequest(req) - if err != nil { - return "", validators.ValidationErrors(validators.GetErrors(err)) - } - - url := "/cloudapi/account/delete" - - result, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req) - if err != nil { - return "", err - } - - return string(result), nil -} diff --git a/pkg/cloudapi/account/disable_enable.go b/pkg/cloudapi/account/disable_enable.go deleted file mode 100644 index 3eb98d4..0000000 --- a/pkg/cloudapi/account/disable_enable.go +++ /dev/null @@ -1,60 +0,0 @@ -package account - -import ( - "context" - "net/http" - "strconv" - - "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" -) - -// DisableEnableRequest struct to change status of account -type DisableEnableRequest struct { - // ID of account - // Required: true - AccountID uint64 `url:"accountId" json:"accountId" validate:"required"` -} - -// Disable disables an account -func (a Account) Disable(ctx context.Context, req DisableEnableRequest) (bool, error) { - err := validators.ValidateRequest(req) - if err != nil { - return false, validators.ValidationErrors(validators.GetErrors(err)) - } - - url := "/cloudapi/account/disable" - - res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req) - if err != nil { - return false, err - } - - result, err := strconv.ParseBool(string(res)) - if err != nil { - return false, err - } - - return result, nil -} - -// Enable enables an account -func (a Account) Enable(ctx context.Context, req DisableEnableRequest) (bool, error) { - err := validators.ValidateRequest(req) - if err != nil { - return false, validators.ValidationErrors(validators.GetErrors(err)) - } - - url := "/cloudapi/account/enable" - - res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req) - if err != nil { - return false, err - } - - result, err := strconv.ParseBool(string(res)) - if err != nil { - return false, err - } - - return result, nil -} diff --git a/pkg/cloudapi/account/get_consumed_cloud_units_by_type.go b/pkg/cloudapi/account/get_consumed_cloud_units_by_type.go deleted file mode 100644 index ec81d5c..0000000 --- a/pkg/cloudapi/account/get_consumed_cloud_units_by_type.go +++ /dev/null @@ -1,51 +0,0 @@ -package account - -import ( - "context" - "net/http" - "strconv" - - "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" -) - -// GetConsumedCloudUnitsByTypeRequest struct to calculate the currently consumed cloud units of the specified type for all cloudspaces and resource groups in the account -type GetConsumedCloudUnitsByTypeRequest struct { - // ID an account - // Required: true - AccountID uint64 `url:"accountId" json:"accountId" validate:"required"` - - // Cloud unit resource type - // Required: true - CUType string `url:"cutype" json:"cutype" validate:"required,accountCUType"` -} - -// GetConsumedCloudUnitsByType calculates the currently consumed cloud units of the specified type for all cloudspaces -// and resource groups in the account. -// Possible types of cloud units are include: -// -// - CU_M: returns consumed memory in MB -// - CU_C: returns number of virtual cpu cores -// - CU_D: returns consumed virtual disk storage in GB -// - CU_DM: returns consumed max virtual disk storage in GB -// - CU_I: returns number of public IPs -// - gpu_units: return number of GPU units -func (a Account) GetConsumedCloudUnitsByType(ctx context.Context, req GetConsumedCloudUnitsByTypeRequest) (float64, error) { - err := validators.ValidateRequest(req) - if err != nil { - return 0, validators.ValidationErrors(validators.GetErrors(err)) - } - - url := "/cloudapi/account/getConsumedCloudUnitsByType" - - res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req) - if err != nil { - return 0, err - } - - result, err := strconv.ParseFloat(string(res), 64) - if err != nil { - return 0, err - } - - return result, nil -} diff --git a/pkg/cloudapi/account/get_reserved_account_units.go b/pkg/cloudapi/account/get_reserved_account_units.go deleted file mode 100644 index d076596..0000000 --- a/pkg/cloudapi/account/get_reserved_account_units.go +++ /dev/null @@ -1,47 +0,0 @@ -package account - -import ( - "context" - "encoding/json" - "net/http" - - "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" -) - -// GetReservedAccountUnitsRequest struct to calculate the reserved units for all cloudspaces and resource groups in the account -type GetReservedAccountUnitsRequest struct { - // ID an account - // Required: true - AccountID uint64 `url:"accountId" json:"accountId" validate:"required"` -} - -// GetReservedAccountUnits calculates the reserved units for all cloudspaces and resource groups in the account. -// Calculated cloud units are returned in a dict which includes: -// -// - CU_M: reserved memory in MB -// - CU_C: number of cpu cores -// - CU_D: reserved vdisk storage in GB -// - CU_DM: reserved max vdisk storage in GB -// - CU_I: number of public IPs -func (a Account) GetReservedAccountUnits(ctx context.Context, req GetReservedAccountUnitsRequest) (*ResourceLimits, error) { - err := validators.ValidateRequest(req) - if err != nil { - return nil, validators.ValidationErrors(validators.GetErrors(err)) - } - - url := "/cloudapi/account/getReservedAccountUnits" - - res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req) - if err != nil { - return nil, err - } - - info := ResourceLimits{} - - err = json.Unmarshal(res, &info) - if err != nil { - return nil, err - } - - return &info, nil -} diff --git a/pkg/cloudapi/account/models.go b/pkg/cloudapi/account/models.go index 0df8a28..9f6c9d5 100644 --- a/pkg/cloudapi/account/models.go +++ b/pkg/cloudapi/account/models.go @@ -203,11 +203,56 @@ type ListResourceConsumption struct { // Information about computes type Computes struct { + // Number of starting computes + Starting uint64 `json:"STARTING"` + // Number of started computes - Started uint64 `json:"started"` + Started uint64 `json:"STARTED"` + + // Number of stopping computes + Stopping uint64 `json:"STOPPING"` // Number of stopped computes - Stopped uint64 `json:"stopped"` + Stopped uint64 `json:"STOPPED"` + + // Number of paused computes + Paused uint64 `json:"PAUSED"` + + // Number of pausing computes + Pausing uint64 `json:"PAUSING"` + + // Number of merging computes + Merge uint64 `json:"MERGE"` + + // Number of migrating computes + Migrating uint64 `json:"MIGRATING"` + + // Number of computes migrating in + MigratingIn uint64 `json:"MIGRATING_IN"` + + // Number of computes migrating out + MigratingOut uint64 `json:"MIGRATING_OUT"` + + // Number of computes in down status + Down uint64 `json:"DOWN"` + + // Number of scheduled computes + Scheduled uint64 `json:"SCHEDULED"` + + // Number of computes with stopped backup + BackupStopped uint64 `json:"BACKUP_STOPPED"` + + // Number of computes with running backup + BackupRunning uint64 `json:"BACKUP_RUNNING"` + + // Number of computes creating a snapshot + Snapcreate uint64 `json:"SNAPCREATE"` + + // Number of cloning computes + Cloning uint64 `json:"CLONING"` + + // Number of computes being rolled back + Rollback uint64 `json:"ROLLBACK"` } // Information about machines @@ -455,6 +500,9 @@ type ItemVINS struct { // Deleted time DeletedTime uint64 `json:"deletedTime"` + // Enable Default Gateway + EnableDefaultGateway bool `json:"enable_default_gateway"` + // External IP ExternalIP string `json:"externalIP"` @@ -524,11 +572,56 @@ type ListAudits []ItemAudit // Information compute in resource group type RGComputes struct { + // Number of starting computes + Starting uint64 `json:"STARTING"` + // Number of started computes - Started uint64 `json:"Started"` + Started uint64 `json:"STARTED"` + + // Number of stopping computes + Stopping uint64 `json:"STOPPING"` // Number of stopped computes - Stopped uint64 `json:"Stopped"` + Stopped uint64 `json:"STOPPED"` + + // Number of paused computes + Paused uint64 `json:"PAUSED"` + + // Number of pausing computes + Pausing uint64 `json:"PAUSING"` + + // Number of merging computes + Merge uint64 `json:"MERGE"` + + // Number of migrating computes + Migrating uint64 `json:"MIGRATING"` + + // Number of computes migrating in + MigratingIn uint64 `json:"MIGRATING_IN"` + + // Number of computes migrating out + MigratingOut uint64 `json:"MIGRATING_OUT"` + + // Number of computes in down status + Down uint64 `json:"DOWN"` + + // Number of scheduled computes + Scheduled uint64 `json:"SCHEDULED"` + + // Number of computes with stopped backup + BackupStopped uint64 `json:"BACKUP_STOPPED"` + + // Number of computes with running backup + BackupRunning uint64 `json:"BACKUP_RUNNING"` + + // Number of computes creating a snapshot + Snapcreate uint64 `json:"SNAPCREATE"` + + // Number of cloning computes + Cloning uint64 `json:"CLONING"` + + // Number of computes being rolled back + Rollback uint64 `json:"ROLLBACK"` } // Resources of Resource group diff --git a/pkg/cloudapi/bservice/group_add.go b/pkg/cloudapi/bservice/group_add.go index 888d570..2d21225 100644 --- a/pkg/cloudapi/bservice/group_add.go +++ b/pkg/cloudapi/bservice/group_add.go @@ -5,6 +5,7 @@ import ( "net/http" "strconv" + "repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants" "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" ) @@ -62,9 +63,9 @@ type GroupAddRequest struct { // Required: false TimeoutStart uint64 `url:"timeoutStart,omitempty" json:"timeoutStart,omitempty"` - // Meta data for working group computes, format YAML "user_data": 1111 + // Meta data for working group computes, format yaml string or json object // Required: false - UserData string `url:"userData,omitempty" json:"userData,omitempty"` + UserData interface{} `url:"userData,omitempty" json:"userData,omitempty"` // Chipset "i440fx" or "Q35 // Default value : Q35 @@ -97,7 +98,7 @@ func (b BService) GroupAdd(ctx context.Context, req GroupAddRequest) (uint64, er url := "/cloudapi/bservice/groupAdd" - res, err := b.client.DecortApiCall(ctx, http.MethodPost, url, req) + res, err := b.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req) if err != nil { return 0, err } diff --git a/pkg/cloudapi/compute/audits.go b/pkg/cloudapi/compute/audits.go deleted file mode 100644 index e69bdf8..0000000 --- a/pkg/cloudapi/compute/audits.go +++ /dev/null @@ -1,76 +0,0 @@ -package compute - -import ( - "context" - "encoding/json" - "net/http" - - "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" -) - -// AuditsRequest struct to get audit records -type AuditsRequest struct { - // ID of the compute - // Required: true - ComputeID uint64 `url:"compute_id" json:"compute_id" validate:"required"` - - // Find all audits after point in time - // Required: false - TimestampAT uint64 `url:"timestamp_at,omitempty" json:"timestamp_at,omitempty"` - - // Find all audits before point in time - // Required: false - TimestampTO uint64 `url:"timestamp_to,omitempty" json:"timestamp_to,omitempty"` - - // Find by user - // Required: false - User string `url:"user,omitempty" json:"user,omitempty"` - - // Find by api endpoints - // Required: false - Call string `url:"call,omitempty" json:"call,omitempty"` - - // Sort by one of supported fields, format ± - // Required: false - SortBy string `url:"sort_by,omitempty" json:"sort_by,omitempty"` - - // Page number - // Required: false - Page uint64 `url:"page,omitempty" json:"page,omitempty"` - - // Page size - // Required: false - Size uint64 `url:"size,omitempty" json:"size,omitempty"` - - // Find by HTTP min status code - // Required: false - MinStatusCode uint64 `url:"min_status_code,omitempty" json:"min_status_code,omitempty"` - - // Find by HTTP max status code - // Required: false - MaxStatusCode uint64 `url:"max_status_code,omitempty" json:"max_status_code,omitempty"` -} - -// Audits gets audit records for the specified compute object -func (c Compute) Audits(ctx context.Context, req AuditsRequest) (*ListAudits, error) { - err := validators.ValidateRequest(req) - if err != nil { - return nil, validators.ValidationErrors(validators.GetErrors(err)) - } - - url := "/cloudapi/compute/audits" - - res, err := c.client.DecortApiCall(ctx, http.MethodGet, url, req) - if err != nil { - return nil, err - } - - list := ListAudits{} - - err = json.Unmarshal(res, &list) - if err != nil { - return nil, err - } - - return &list, nil -} diff --git a/pkg/cloudapi/compute/change_qos_policies.go b/pkg/cloudapi/compute/change_qos_policies.go new file mode 100644 index 0000000..6add3f4 --- /dev/null +++ b/pkg/cloudapi/compute/change_qos_policies.go @@ -0,0 +1,84 @@ +package compute + +import ( + "context" + "net/http" + "strconv" + + "repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants" + "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" +) + +type ChangeQoSPoliciesRequest struct { + // Compute ID + // Required: true + ComputeID uint64 `url:"compute_id" json:"compute_id" validate:"required"` + + // Interface IP or MAC address + // Required: true + Interface string `url:"interface" json:"interface" validate:"required"` + + // List of QoS Policy IDs to assign to this interface + // Required: false + QoSPolicyIDs []uint64 `url:"qos_policy_ids,omitempty" json:"qos_policy_ids,omitempty"` +} + +type wrapperChangeQoSPoliciesRequest struct { + ChangeQoSPoliciesRequest + + AsyncMode bool `url:"asyncMode"` +} + +// ChangeQoSPolicies change qos policies for compute +func (c Compute) ChangeQoSPolicies(ctx context.Context, req ChangeQoSPoliciesRequest) (bool, error) { + err := validators.ValidateRequest(req) + if err != nil { + return false, validators.ValidationErrors(validators.GetErrors(err)) + } + + reqWrapped := wrapperChangeQoSPoliciesRequest{ + ChangeQoSPoliciesRequest: req, + AsyncMode: false, + } + + url := "/cloudapi/compute/change_qos_policies" + + res, err := c.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, reqWrapped) + if err != nil { + return false, err + } + + result, err := strconv.ParseBool(string(res)) + if err != nil { + return false, err + } + + return result, nil +} + +// ChangeQoSPolicies change qos policies for compute with AsyncMode +func (c Compute) ChangeQoSPoliciesAsync(ctx context.Context, req ChangeQoSPoliciesRequest) (bool, error) { + err := validators.ValidateRequest(req) + if err != nil { + return false, validators.ValidationErrors(validators.GetErrors(err)) + } + + reqWrapped := wrapperChangeQoSPoliciesRequest{ + ChangeQoSPoliciesRequest: req, + AsyncMode: true, + } + + url := "/cloudapi/compute/change_qos_policies" + + res, err := c.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, reqWrapped) + if err != nil { + return false, err + } + + result, err := strconv.ParseBool(string(res)) + if err != nil { + return false, err + } + + return result, nil +} diff --git a/pkg/cloudapi/compute/get_audits.go b/pkg/cloudapi/compute/get_audits.go deleted file mode 100644 index fa47a4f..0000000 --- a/pkg/cloudapi/compute/get_audits.go +++ /dev/null @@ -1,40 +0,0 @@ -package compute - -import ( - "context" - "encoding/json" - "net/http" - - "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" -) - -// GetAuditsRequest struct to get compute audits -type GetAuditsRequest struct { - // ID of compute instance - // Required: true - ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"` -} - -// GetAudits gets compute audits -func (c Compute) GetAudits(ctx context.Context, req GetAuditsRequest) (ListShortAudits, error) { - err := validators.ValidateRequest(req) - if err != nil { - return nil, validators.ValidationErrors(validators.GetErrors(err)) - } - - url := "/cloudapi/compute/getAudits" - - res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req) - if err != nil { - return nil, err - } - - list := ListShortAudits{} - - err = json.Unmarshal(res, &list) - if err != nil { - return nil, err - } - - return list, nil -} diff --git a/pkg/cloudapi/compute/list_pci_device.go b/pkg/cloudapi/compute/list_pci_device.go index 2c84179..60148d9 100644 --- a/pkg/cloudapi/compute/list_pci_device.go +++ b/pkg/cloudapi/compute/list_pci_device.go @@ -14,10 +14,6 @@ type ListPCIDeviceRequest struct { // Required: true ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"` - // Find by resource group ID - // Required: false - RGID uint64 `url:"rgId,omitempty" json:"rgId,omitempty"` - // Find by device id // Required: false DevID uint64 `url:"devId,omitempty" json:"devId,omitempty"` diff --git a/pkg/cloudapi/compute/models.go b/pkg/cloudapi/compute/models.go index 5ffb113..ea7e3f0 100644 --- a/pkg/cloudapi/compute/models.go +++ b/pkg/cloudapi/compute/models.go @@ -558,11 +558,14 @@ type RecordCompute struct { Userdata interface{} `json:"userdata"` // vGPUs list - VGPUs []VGPUItem `json:"vgpus"` + VGPUs []ItemVGPU `json:"vgpus"` // VNC password VNCPassword string `json:"vncPasswd"` + // Watchdog action + WatchdogAction string `json:"watchdog_action"` + // Weight Weight uint64 `json:"weight"` @@ -813,7 +816,7 @@ type SnapRecordCompute struct { Userdata interface{} `json:"userdata"` // vGPUs list - VGPUs []VGPUItem `json:"vgpus"` + VGPUs []ItemVGPU `json:"vgpus"` // VNC password VNCPassword string `json:"vncPasswd"` @@ -848,65 +851,6 @@ type CPUAlignmentProfile struct { Vendor string `json:"vendor"` } -type VGPUItem struct { - // ID - ID uint64 `json:"id"` - - // GID - GID uint64 `json:"gid"` - - // Type - Type string `json:"type"` - - // Mode - Mode string `json:"mode"` - - // Status - Status string `json:"status"` - - // ProfileID - ProfileID uint64 `json:"profileId"` - - // RAM - RAM uint64 `json:"ram"` - - // LastUpdateTime - LastUpdateTime uint64 `json:"lastUpdateTime"` - - // CreatedTime - CreatedTime uint64 `json:"createdTime"` - - // DeletedTime - DeletedTime uint64 `json:"deletedTime"` - - // VMID - VMID uint64 `json:"vmid"` - - // PGPuid - PGPuid uint64 `json:"pgpuid"` - - // ReferenceID - ReferenceID string `json:"referenceId"` - - // AccountID - AccountID uint64 `json:"accountId"` - - // RgID - RgID uint64 `json:"rgId"` - - // LastClaimedBy - LastClaimedBy uint64 `json:"lastClaimedBy"` - - // PCISlot - PCISlot uint64 `json:"pciSlot"` - - // BusNumber - BusNumber uint64 `json:"bus_number"` - - // GUID - GUID uint64 `json:"guid"` -} - // Information about libvirt settings type LibvirtSettings struct { // TX mode @@ -1038,6 +982,9 @@ type ItemVNFInterface struct { // QOS QOS QOS `json:"qos"` + // List of QoS Policy IDs + QoSPolicies []uint64 `json:"qos_policies"` + // List of security groups SecGroups []uint64 `json:"security_groups"` @@ -1551,6 +1498,9 @@ type ItemCompute struct { // VINS connected VINSConnected uint64 `json:"vinsConnected"` + // Watchdog action + WatchdogAction string `json:"watchdog_action"` + // Weight Weight uint64 `json:"weight"` @@ -1569,6 +1519,9 @@ type InfoDisk struct { // SEP ID SepID int64 `json:"sepId"` + // Image ID + ImageID uint64 `json:"imageId"` + // Read-only ReadOnly bool `json:"read_only"` } @@ -1593,59 +1546,56 @@ type ListVGPUs struct { // Main information about vgpu device type ItemVGPU struct { - // Account ID - AccountID uint64 `json:"accountId"` + // Account IDs + AccountIDs []uint64 `json:"account_ids"` - // Created Time - CreatedTime uint64 `json:"createdTime"` + // Bus number + BusNumber int `json:"bus_number"` - // Deleted Time - DeletedTime uint64 `json:"deletedTime"` + // ComputeID + ComputeID uint64 `json:"compute_id"` - // GID + // Created time + CreatedTime uint64 `json:"created_time"` + + // Deleted time + DeletedTime uint64 `json:"deleted_time"` + + // Device Reference + DeviceReference string `json:"device_reference"` + + //Grid ID GID uint64 `json:"gid"` // GUID GUID uint64 `json:"guid"` - // ID + // VGPU ID ID uint64 `json:"id"` - // Last Claimed By - LastClaimedBy uint64 `json:"lastClaimedBy"` + // Last Update time + LastUpdateTime uint64 `json:"last_update_time"` - // Last Update Time - LastUpdateTime uint64 `json:"lastUpdateTime"` + // Mdev UUID + MdevUUID string `json:"mdev_uuid"` - // Mode - Mode string `json:"mode"` + // Parent PCI Address + ParentPCIAddress string `json:"parent_pci_address"` // PCI Slot - PCISlot uint64 `json:"pciSlot"` + PCISlot uint64 `json:"pci_slot"` - // PGPUID - PGPUID uint64 `json:"pgpuid"` + // PGPU ID + PGPUID uint64 `json:"pgpu_id"` - // Profile ID - ProfileID uint64 `json:"profileId"` + // Profile Reference + ProfileReference string `json:"profile_reference"` - // RAM - RAM uint64 `json:"ram"` - - // Reference ID - ReferenceID string `json:"referenceId"` - - // RG ID - RGID uint64 `json:"rgId"` + // Split Mode + SplitMode string `json:"split_mode"` // Status Status string `json:"status"` - - // Type - Type string `json:"type"` - - // VM ID - VMID uint64 `json:"vmid"` } // Main information about PCI device @@ -1668,8 +1618,8 @@ type ItemPCIDevice struct { // Name Name string `json:"name"` - // Resource group ID - RGID uint64 `json:"rgId"` + // Account IDs + AccountIDs []uint64 `json:"account_ids"` // Node ID NodeID uint64 `json:"nodeId"` diff --git a/pkg/cloudapi/compute/net_attach.go b/pkg/cloudapi/compute/net_attach.go index 81a0bd0..56e4e7d 100644 --- a/pkg/cloudapi/compute/net_attach.go +++ b/pkg/cloudapi/compute/net_attach.go @@ -86,6 +86,10 @@ type NetAttachRequest struct { // Required: false // Default: true EnableDefaultGateway interface{} `url:"enable_default_gateway,omitempty" json:"enable_default_gateway,omitempty" validate:"omitempty,isBool"` + + // List of QoS Policy IDs to apply to this interface (default: []), Allow used only with netType VINS, EXTNET and DPDK + // Required: false + QoSPolicies []uint64 `url:"qos_policies,omitempty" json:"qos_policies,omitempty"` } type wrapperNetAttachRequest struct { diff --git a/pkg/cloudapi/compute/update.go b/pkg/cloudapi/compute/update.go index 99cecec..54b095d 100644 --- a/pkg/cloudapi/compute/update.go +++ b/pkg/cloudapi/compute/update.go @@ -74,6 +74,11 @@ type UpdateRequest struct { // Required: false // Default: null Clock string `url:"clock,omitempty" json:"clock,omitempty"` + + // Watchdog action + // Required: false + // Default: reset + WatchdogAction string `url:"watchdog_action,omitempty" json:"watchdog_action,omitempty" validate:"omitempty,watchdogAction"` } // Update updates some properties of the compute diff --git a/pkg/cloudapi/disks/create.go b/pkg/cloudapi/disks/create.go index f4e3dfb..a489599 100644 --- a/pkg/cloudapi/disks/create.go +++ b/pkg/cloudapi/disks/create.go @@ -39,7 +39,13 @@ type CreateRequest struct { Pool string `url:"pool,omitempty" json:"pool,omitempty"` } -// Create creates a disk +type wrapperCreateRequest struct { + CreateRequest + + AsyncMode bool `url:"async_mode" json:"async_mode"` +} + +// Create creates a disk in sync mode func (d Disks) Create(ctx context.Context, req CreateRequest) (uint64, error) { err := validators.ValidateRequest(req) if err != nil { @@ -48,7 +54,12 @@ func (d Disks) Create(ctx context.Context, req CreateRequest) (uint64, error) { url := "/cloudapi/disks/create" - res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, req) + wrappedReq := wrapperCreateRequest{ + CreateRequest: req, + AsyncMode: false, + } + + res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, wrappedReq) if err != nil { return 0, err } @@ -60,3 +71,25 @@ func (d Disks) Create(ctx context.Context, req CreateRequest) (uint64, error) { return result, nil } + +// Create creates a disk in async mode +func (d Disks) CreateAsync(ctx context.Context, req CreateRequest) (string, error) { + err := validators.ValidateRequest(req) + if err != nil { + return "", validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudapi/disks/create" + + wrappedReq := wrapperCreateRequest{ + CreateRequest: req, + AsyncMode: true, + } + + res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, wrappedReq) + if err != nil { + return "", err + } + + return string(res), nil +} diff --git a/pkg/cloudapi/disks/list.go b/pkg/cloudapi/disks/list.go index 0ea935b..fdadecb 100644 --- a/pkg/cloudapi/disks/list.go +++ b/pkg/cloudapi/disks/list.go @@ -28,7 +28,7 @@ type ListRequest struct { // Find by status // Required: false - Status string `url:"status,omitempty" json:"status,omitempty"` + Status []string `url:"status,omitempty" json:"status,omitempty"` // Find by shared, true or false // Required: false diff --git a/pkg/cloudapi/k8s/create.go b/pkg/cloudapi/k8s/create.go index a8e9a14..568e172 100644 --- a/pkg/cloudapi/k8s/create.go +++ b/pkg/cloudapi/k8s/create.go @@ -157,7 +157,7 @@ type CreateRequest struct { // Meta data for working group computes, format YAML "user_data": 1111 // Required: false - UserData string `url:"userData,omitempty" json:"userData,omitempty"` + UserData interface{} `url:"userData,omitempty" json:"userData,omitempty"` // Use only selected ExtNet for infrastructure connections // Required: false diff --git a/pkg/cloudapi/k8s/update_worker_nodes_meta_data.go b/pkg/cloudapi/k8s/update_worker_nodes_meta_data.go index 6b1a0f8..e69effa 100644 --- a/pkg/cloudapi/k8s/update_worker_nodes_meta_data.go +++ b/pkg/cloudapi/k8s/update_worker_nodes_meta_data.go @@ -20,7 +20,7 @@ type UpdateWorkerNodesMetaDataRequest struct { // Meta data for working group computes, format YAML "user_data": 1111 // Required: true - UserData string `url:"userData" json:"userData" validate:"required"` + UserData interface{} `url:"userData" json:"userData" validate:"required"` } // UpdateWorkerNodesMetaData adds worker nodes to a kubernetes cluster diff --git a/pkg/cloudapi/kvmx86/create.go b/pkg/cloudapi/kvmx86/create.go index 3a212a8..6cbdbb4 100644 --- a/pkg/cloudapi/kvmx86/create.go +++ b/pkg/cloudapi/kvmx86/create.go @@ -2,6 +2,7 @@ package kvmx86 import ( "context" + "encoding/json" "net/http" "strconv" @@ -81,6 +82,10 @@ type Interface struct { // Default: true // Required: false EnableDefaultGateway interface{} `url:"enable_default_gateway,omitempty" json:"enable_default_gateway,omitempty" validate:"omitempty,isBool"` + + // List of QoS Policy IDs to apply to this interface (default: []), Allow used only with netType VINS, EXTNET and DPDK + // Required: false + QoSPolicies []uint64 `url:"qos_policies,omitempty" json:"qos_policies,omitempty"` } // DataDisk detailed struct for DataDisks field in CreateRequest and CreateBlankRequest @@ -114,6 +119,11 @@ type DataDisk struct { // Specify image id for create disk from template // Required: false ImageID uint64 `url:"imageId,omitempty" json:"imageId,omitempty"` + + // Attach disk in read-only mode + // Required: false + // Default: false + ReadOnly bool `url:"read_only,omitempty" json:"read_only,omitempty"` } // CreateRequest struct to create KVM x86 VM @@ -199,12 +209,12 @@ type CreateRequest struct { // loose (use NUMA affinity if possible) // Required: false // Default: none - NumaAffinity string `url:"numaAffinity,omitempty" json:"numaAffinity,omitempty" validate:"omitempty,numaAffinity"` + NumaAffinity string `url:"numa_affinity,omitempty" json:"numa_affinity,omitempty" validate:"omitempty,numaAffinity"` // Run VM on dedicated CPUs. To use this feature, the system must be pre-configured by allocating CPUs on the physical node // Required: false // Default: false - CPUPin bool `url:"cpupin" json:"cpupin"` + CPUPin bool `url:"cpu_pin" json:"cpu_pin"` // Type of the emulated system, Q35 or i440fx // Required: false @@ -214,7 +224,7 @@ type CreateRequest struct { // Use Huge Pages to allocate RAM of the virtual machine. The system must be pre-configured by allocating Huge Pages on the physical node // Required: false // Default: false - HPBacked bool `url:"hpBacked" json:"hpBacked"` + HPBacked bool `url:"hp_backed" json:"hp_backed"` // Recommended isolated CPUs. Field is ignored if compute.cpupin=False or compute.pinned=False // Required: false @@ -232,6 +242,11 @@ type CreateRequest struct { // Required: false // Default: default Clock string `url:"clock,omitempty" json:"clock,omitempty"` + + // Watchdog action + // Required: false + // Default: reset + WatchdogAction string `url:"watchdog_action,omitempty" json:"watchdog_action,omitempty" validate:"omitempty,watchdogAction"` } // GetRAM returns RAM field values @@ -243,6 +258,11 @@ func (r CreateRequest) GetRAM() map[string]uint64 { return res } +type wrapperCreateRequest struct { + CreateRequest + AsyncMode bool `json:"asyncMode"` +} + // Create creates KVM x86 VM based on specified OS image func (k KVMX86) Create(ctx context.Context, req CreateRequest) (uint64, error) { err := validators.ValidateRequest(req) @@ -252,10 +272,40 @@ func (k KVMX86) Create(ctx context.Context, req CreateRequest) (uint64, error) { url := "/cloudapi/kvmx86/create" - res, err := k.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req) + res, err := k.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, wrapperCreateRequest{ + CreateRequest: req, + AsyncMode: false, + }) if err != nil { return 0, err } return strconv.ParseUint(string(res), 10, 64) } + +// CreateAsync creates KVM x86 VM based on specified OS image in async mode +func (k KVMX86) CreateAsync(ctx context.Context, req CreateRequest) (string, error) { + err := validators.ValidateRequest(req) + if err != nil { + return "", validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudapi/kvmx86/create" + + res, err := k.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, wrapperCreateRequest{ + CreateRequest: req, + AsyncMode: true, + }) + if err != nil { + return "", err + } + + var taskID string + + err = json.Unmarshal(res, &taskID) + if err != nil { + return "", err + } + + return taskID, nil +} diff --git a/pkg/cloudapi/kvmx86/create_blank.go b/pkg/cloudapi/kvmx86/create_blank.go index 1be5b9b..e29b413 100644 --- a/pkg/cloudapi/kvmx86/create_blank.go +++ b/pkg/cloudapi/kvmx86/create_blank.go @@ -124,6 +124,11 @@ type CreateBlankRequest struct { // Required: false // Default: default Clock string `url:"clock,omitempty" json:"clock,omitempty"` + + // Watchdog action + // Required: false + // Default: reset + WatchdogAction string `url:"watchdog_action,omitempty" json:"watchdog_action,omitempty" validate:"omitempty,watchdogAction"` } // GetRAM returns RAM field values diff --git a/pkg/cloudapi/locations/models.go b/pkg/cloudapi/locations/models.go index 16db21e..a83b5b2 100644 --- a/pkg/cloudapi/locations/models.go +++ b/pkg/cloudapi/locations/models.go @@ -5,6 +5,9 @@ type ItemLocation struct { // AuthBroker AuthBroker []string `json:"authBroker"` + // Budget + Budget bool `json:"budget"` + // Grid ID GID uint64 `json:"gid"` diff --git a/pkg/cloudapi/network_qos_policy.go b/pkg/cloudapi/network_qos_policy.go new file mode 100644 index 0000000..76db9c1 --- /dev/null +++ b/pkg/cloudapi/network_qos_policy.go @@ -0,0 +1,10 @@ +package cloudapi + +import ( + qospolicy "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/qospolicy" +) + +// Accessing the QoS Policy method group +func (ca *CloudAPI) QoSPolicy() *qospolicy.QoSPolicy { + return qospolicy.New(ca.client) +} diff --git a/pkg/cloudapi/qospolicy/create.go b/pkg/cloudapi/qospolicy/create.go new file mode 100644 index 0000000..72d72b9 --- /dev/null +++ b/pkg/cloudapi/qospolicy/create.go @@ -0,0 +1,46 @@ +package qospolicy + +import ( + "context" + "net/http" + "strconv" + + "repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants" + "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" +) + +type CreateRequest struct { + // Account ID that owns QoS policy + // Required: true + AccountID uint64 `url:"account_id" json:"account_id" validate:"required"` + + // QoS policy name + // Required: true + Name string `url:"name" json:"name" validate:"required"` + + // QoS policy description + // Required: false + Description string `url:"description,omitempty" json:"description,omitempty"` +} + +// Create creates a new QoS policy +func (qp QoSPolicy) Create(ctx context.Context, req CreateRequest) (uint64, error) { + err := validators.ValidateRequest(req) + if err != nil { + return 0, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudapi/network_qos_policy/create" + + res, err := qp.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req) + if err != nil { + return 0, err + } + + result, err := strconv.ParseUint(string(res), 10, 64) + if err != nil { + return 0, err + } + + return result, nil +} diff --git a/pkg/cloudapi/qospolicy/create_rule.go b/pkg/cloudapi/qospolicy/create_rule.go new file mode 100644 index 0000000..c8dc2a4 --- /dev/null +++ b/pkg/cloudapi/qospolicy/create_rule.go @@ -0,0 +1,93 @@ +package qospolicy + +import ( + "context" + "net/http" + "strconv" + + "repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants" + "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" +) + +type CreateRuleRequest struct { + // ID of the parent QoS policy this rule belongs to + // Required: true + QoSPolicyID uint64 `url:"qos_policy_id" json:"qos_policy_id" validate:"required"` + + // QoS policy rule description + // Default: "" + // Required: false + Description string `url:"description,omitempty" json:"description,omitempty"` + + // Rule priority in OVS (higher number = higher priority) + // Possible values: [0, 65535] + // Required: true + Priority *uint64 `url:"priority" json:"priority" validate:"required,min=0,max=65535"` + + // Traffic direction + // Required: true + Direction string `url:"direction" json:"direction" validate:"required,oneof=outbound"` + + // IP protocol to match + // Possible values: tcp, udp, icmp + // Required: true + Protocol string `url:"protocol" json:"protocol" validate:"required,oneof=tcp udp icmp"` + + // Priority Code Point. L2 marking + // Possible values: [0, 7] + // Required: false + PCPTag *uint64 `url:"pcp_tag,omitempty" json:"pcp_tag,omitempty" validate:"required_without_all=DSCPValue,omitempty,min=0,max=7"` + + // DSCP value (0-63). L3 marking + // Possible values: [0, 63] + // Required: false + DSCPValue *uint64 `url:"dscp_value,omitempty" json:"dscp_value,omitempty" validate:"required_without_all=PCPTag,omitempty,min=0,max=63"` + + // Source IP address for traffic filtering + // Required: false + SrcIP string `url:"src_ip,omitempty" json:"src_ip,omitempty"` + + // Destination IP address for traffic filtering + // Required: false + DstIP string `url:"dst_ip,omitempty" json:"dst_ip,omitempty"` + + // Source MAC address for traffic filtering + // Required: false + SrcMAC string `url:"src_mac,omitempty" json:"src_mac,omitempty" validate:"omitempty,mac"` + + // Destination MAC address for traffic filtering + // Required: false + DstMAC string `url:"dst_mac,omitempty" json:"dst_mac,omitempty" validate:"omitempty,mac"` + + // Source port for traffic filtering (TCP/UDP only) + // Possible values: [1, 65535] + // Required: false + SrcPort uint64 `url:"src_port,omitempty" json:"src_port,omitempty" validate:"omitempty,min=1,max=65535"` + + // Destination port for traffic filtering (TCP/UDP only) + // Possible values: [1, 65535] + // Required: false + DstPort uint64 `url:"dst_port,omitempty" json:"dst_port,omitempty" validate:"omitempty,min=1,max=65535"` +} + +// CreateRule creates a new rule for a QoS policy +func (qp QoSPolicy) CreateRule(ctx context.Context, req CreateRuleRequest) (uint64, error) { + err := validators.ValidateRequest(req) + if err != nil { + return 0, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudapi/network_qos_policy/create_rule" + + res, err := qp.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req) + if err != nil { + return 0, err + } + + result, err := strconv.ParseUint(string(res), 10, 64) + if err != nil { + return 0, err + } + + return result, nil +} diff --git a/pkg/cloudapi/qospolicy/delete.go b/pkg/cloudapi/qospolicy/delete.go new file mode 100644 index 0000000..515e0d0 --- /dev/null +++ b/pkg/cloudapi/qospolicy/delete.go @@ -0,0 +1,37 @@ +package qospolicy + +import ( + "context" + "net/http" + "strconv" + + "repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants" + "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" +) + +type DeleteRequest struct { + // QoS policy ID + // Required: true + QoSPolicyID uint64 `url:"qos_policy_id" json:"qos_policy_id" validate:"required"` +} + +func (qp QoSPolicy) Delete(ctx context.Context, req DeleteRequest) (bool, error) { + err := validators.ValidateRequest(req) + if err != nil { + return false, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudapi/network_qos_policy/delete" + + res, err := qp.client.DecortApiCallCtype(ctx, http.MethodDelete, url, constants.MIMEJSON, req) + if err != nil { + return false, err + } + + result, err := strconv.ParseBool(string(res)) + if err != nil { + return false, err + } + + return result, nil +} diff --git a/pkg/cloudapi/qospolicy/delete_rule.go b/pkg/cloudapi/qospolicy/delete_rule.go new file mode 100644 index 0000000..955d459 --- /dev/null +++ b/pkg/cloudapi/qospolicy/delete_rule.go @@ -0,0 +1,41 @@ +package qospolicy + +import ( + "context" + "net/http" + "strconv" + + "repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants" + "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" +) + +type DeleteRuleRequest struct { + // ID of the QoS policy + // Required: true + QoSPolicyID uint64 `url:"qos_policy_id" json:"qos_policy_id" validate:"required"` + + // ID of the rule to delete + // Required: true + RuleID uint64 `url:"rule_id" json:"rule_id" validate:"required"` +} + +func (qp QoSPolicy) DeleteRule(ctx context.Context, req DeleteRuleRequest) (bool, error) { + err := validators.ValidateRequest(req) + if err != nil { + return false, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudapi/network_qos_policy/delete_rule" + + res, err := qp.client.DecortApiCallCtype(ctx, http.MethodDelete, url, constants.MIMEJSON, req) + if err != nil { + return false, err + } + + result, err := strconv.ParseBool(string(res)) + if err != nil { + return false, err + } + + return result, nil +} diff --git a/pkg/cloudapi/qospolicy/filter.go b/pkg/cloudapi/qospolicy/filter.go new file mode 100644 index 0000000..ec368d8 --- /dev/null +++ b/pkg/cloudapi/qospolicy/filter.go @@ -0,0 +1,89 @@ +package qospolicy + +// FilterByID returns ListQoSPolicies with specified ID +func (lqp ListQoSPolicies) FilterByID(id uint64) ListQoSPolicies { + predicate := func(iqp ItemQoSPolicy) bool { + return iqp.ID == id + } + + return lqp.FilterFunc(predicate) +} + +// FilterByName returns ListQoSPolicies with specified Name +func (lqp ListQoSPolicies) FilterByName(name string) ListQoSPolicies { + predicate := func(iqp ItemQoSPolicy) bool { + return iqp.Name == name + } + + return lqp.FilterFunc(predicate) +} + +// FilterByAccountID returns ListQoSPolicies with specified AccountID +func (lqp ListQoSPolicies) FilterByAccountID(accountID uint64) ListQoSPolicies { + predicate := func(iqp ItemQoSPolicy) bool { + return iqp.AccountID == accountID + } + + return lqp.FilterFunc(predicate) +} + +// FilterByStatus returns ListQoSPolicies with specified Status +func (lqp ListQoSPolicies) FilterByStatus(status string) ListQoSPolicies { + predicate := func(iqp ItemQoSPolicy) bool { + return iqp.Status == status + } + + return lqp.FilterFunc(predicate) +} + +// FilterByDescription returns ListQoSPolicies with specified Description +func (lqp ListQoSPolicies) FilterByDescription(description string) ListQoSPolicies { + predicate := func(iqp ItemQoSPolicy) bool { + return iqp.Description == description + } + + return lqp.FilterFunc(predicate) +} + +// FilterByCreatedBy returns ListQoSPolicies with specified CreatedBy +func (lqp ListQoSPolicies) FilterByCreatedBy(createdBy string) ListQoSPolicies { + predicate := func(iqp ItemQoSPolicy) bool { + return iqp.CreatedBy == createdBy + } + + return lqp.FilterFunc(predicate) +} + +// FilterByUpdatedBy returns ListQoSPolicies with specified UpdatedBy +func (lqp ListQoSPolicies) FilterByUpdatedBy(updatedBy string) ListQoSPolicies { + predicate := func(iqp ItemQoSPolicy) bool { + return iqp.UpdatedBy == updatedBy + } + + return lqp.FilterFunc(predicate) +} + +// FilterFunc allows filtering ListQoSPolicies based on a user-specified predicate +func (lqp ListQoSPolicies) FilterFunc(predicate func(ItemQoSPolicy) bool) ListQoSPolicies { + var result ListQoSPolicies + + for _, item := range lqp.Data { + if predicate(item) { + result.Data = append(result.Data, item) + } + } + + result.EntryCount = uint64(len(result.Data)) + + return result +} + +// FindOne returns first found ListQoSPolicies +// If none was found, returns an empty struct +func (lqp ListQoSPolicies) FindOne() ItemQoSPolicy { + if len(lqp.Data) == 0 { + return ItemQoSPolicy{} + } + + return lqp.Data[0] +} diff --git a/pkg/cloudapi/qospolicy/filter_test.go b/pkg/cloudapi/qospolicy/filter_test.go new file mode 100644 index 0000000..cf5ef72 --- /dev/null +++ b/pkg/cloudapi/qospolicy/filter_test.go @@ -0,0 +1,97 @@ +package qospolicy + +import "testing" + +var qosPolicies = ListQoSPolicies{ + Data: []ItemQoSPolicy{ + { + ID: 1, + AccountID: 1, + Name: "qos1", + Description: "some desc", + Status: "ENABLED", + CreatedBy: "user", + }, + { + ID: 3, + AccountID: 3, + Name: "qos3", + Description: "some desc", + Status: "ENABLED", + CreatedBy: "anotheruser", + }, + { + ID: 5, + AccountID: 3, + Name: "qos5", + Description: "some other desc", + Status: "DISABLED", + CreatedBy: "anotheruser", + UpdatedBy: "user", + }, + }, + EntryCount: 3, +} + +func TestFilterByID(t *testing.T) { + actual := qosPolicies.FilterByID(1).FindOne() + if actual.ID != 1 { + t.Fatal("expected ID 1, found: ", actual.ID) + } +} + +func TestFilterByName(t *testing.T) { + actual := qosPolicies.FilterByName("qos3").FindOne() + if actual.Name != "qos3" { + t.Fatal("expected Name qos3, found: ", actual.Name) + } +} + +func TestFilterByDescription(t *testing.T) { + actual := qosPolicies.FilterByDescription("some desc") + + if len(actual.Data) != 2 { + t.Fatal("expected 2 found, actual: ", len(actual.Data)) + } + + for _, item := range actual.Data { + if item.Description != "some desc" { + t.Fatal("expected Description 'some desc', found: ", item.Description) + } + } +} + +func TestFilterByAccountID(t *testing.T) { + actual := qosPolicies.FilterByAccountID(1).FindOne() + if actual.AccountID != 1 { + t.Fatal("expected AccountID 1, found: ", actual.AccountID) + } +} + +func TestFilterByStatus(t *testing.T) { + actual := qosPolicies.FilterByStatus("DISABLED").FindOne() + if actual.Status != "DISABLED" { + t.Fatal("expected Status DISABLED, found: ", actual.Status) + } +} + +func TestFilterByCreatedBy(t *testing.T) { + actual := qosPolicies.FilterByCreatedBy("anotheruser") + + if len(actual.Data) != 2 { + t.Fatal("expected 2 found, actual: ", len(actual.Data)) + } + + for _, item := range actual.Data { + if item.CreatedBy != "anotheruser" { + t.Fatal("expected CreatedBy 'anotheruser', found: ", item.CreatedBy) + } + } +} + +func TestFilterByUpdatedBy(t *testing.T) { + actual := qosPolicies.FilterByUpdatedBy("user").FindOne() + if actual.UpdatedBy != "user" { + t.Fatal("expected UpdatedBy 'user', found: ", actual.UpdatedBy) + } +} diff --git a/pkg/cloudapi/qospolicy/get.go b/pkg/cloudapi/qospolicy/get.go new file mode 100644 index 0000000..41230a2 --- /dev/null +++ b/pkg/cloudapi/qospolicy/get.go @@ -0,0 +1,43 @@ +package qospolicy + +import ( + "context" + "encoding/json" + "net/http" + + "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" +) + +type GetRequest struct { + // QoS policy ID + // Required: true + QoSPolicyID uint64 `url:"qos_policy_id" json:"qos_policy_id" validate:"required"` +} + +func (qp QoSPolicy) Get(ctx context.Context, req GetRequest) (*RecordQoSPolicy, error) { + res, err := qp.GetRaw(ctx, req) + if err != nil { + return nil, err + } + + info := RecordQoSPolicy{} + + err = json.Unmarshal(res, &info) + if err != nil { + return nil, err + } + + return &info, nil +} + +func (qp QoSPolicy) GetRaw(ctx context.Context, req GetRequest) ([]byte, error) { + err := validators.ValidateRequest(req) + if err != nil { + return nil, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudapi/network_qos_policy/get" + + res, err := qp.client.DecortApiCall(ctx, http.MethodGet, url, req) + return res, err +} diff --git a/pkg/cloudapi/qospolicy/list.go b/pkg/cloudapi/qospolicy/list.go new file mode 100644 index 0000000..4a3da06 --- /dev/null +++ b/pkg/cloudapi/qospolicy/list.go @@ -0,0 +1,89 @@ +package qospolicy + +import ( + "context" + "encoding/json" + "net/http" + + "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" +) + +type ListRequest struct { + // Page number + // Required: false + Page uint64 `url:"page,omitempty" json:"page,omitempty"` + + // Page size + // Required: false + Size uint64 `url:"size,omitempty" json:"size,omitempty"` + + // Find QoS policy by id + // Required: false + ByID uint64 `url:"by_id,omitempty" json:"by_id,omitempty"` + + // Find by account id + // Required: false + AccountID uint64 `url:"account_id,omitempty" json:"account_id,omitempty"` + + // Find by QoS policy name + // Required: false + Name string `url:"name,omitempty" json:"name,omitempty"` + + // Find by QoS policy description + // Required: false + Description string `url:"description,omitempty" json:"description,omitempty"` + + // Find by QoS policy status + // Possible values: ENABLED, DISABLED, DESTROYED + // Required: false + Status string `url:"status,omitempty" json:"status,omitempty"` + + // Find by created after time (unix timestamp) + // Required: false + CreatedMin uint64 `url:"created_min,omitempty" json:"created_min,omitempty"` + + // Find by created before time (unix timestamp) + // Required: false + CreatedMax uint64 `url:"created_max,omitempty" json:"created_max,omitempty"` + + // Find by updated after time (unix timestamp) + // Required: false + UpdatedMin uint64 `url:"updated_min,omitempty" json:"updated_min,omitempty"` + + // Find by updated before time (unix timestamp) + // Required: false + UpdatedMax uint64 `url:"updated_max,omitempty" json:"updated_max,omitempty"` + + // Sort by one of supported fields, format ± + // Required: false + SortBy string `url:"sort_by,omitempty" json:"sort_by,omitempty"` +} + +// List gets list of QoS policies as a ListQosPolicies struct +func (qp QoSPolicy) List(ctx context.Context, req ListRequest) (*ListQoSPolicies, error) { + res, err := qp.ListRaw(ctx, req) + if err != nil { + return nil, err + } + + list := ListQoSPolicies{} + + err = json.Unmarshal(res, &list) + if err != nil { + return nil, err + } + + return &list, nil +} + +// ListRaw gets list of QoS policies as an array of bytes +func (qp QoSPolicy) ListRaw(ctx context.Context, req ListRequest) ([]byte, error) { + if err := validators.ValidateRequest(req); err != nil { + return nil, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudapi/network_qos_policy/list" + + res, err := qp.client.DecortApiCall(ctx, http.MethodGet, url, req) + return res, err +} diff --git a/pkg/cloudapi/qospolicy/models.go b/pkg/cloudapi/qospolicy/models.go new file mode 100644 index 0000000..fc17c8f --- /dev/null +++ b/pkg/cloudapi/qospolicy/models.go @@ -0,0 +1,122 @@ +package qospolicy + +type ListQoSPolicies struct { + // List + Data []ItemQoSPolicy `json:"data"` + + // Entry count + EntryCount uint64 `json:"entryCount"` +} + +type ItemQoSPolicy struct { + // ID of the QoS policy + ID uint64 `json:"id"` + + // GUID + GUID uint64 `json:"guid"` + + // Account ID that owns the QoS policy + AccountID uint64 `json:"account_id"` + + // Name of the QoS policy + Name string `json:"name"` + + // Description of the QoS policy + Description string `json:"description"` + + // Status of the QoS policy + Status string `json:"status"` + + // Created at (unix timestamp) + CreatedAt uint64 `json:"created_at"` + + // Updated at (unix timestamp) + UpdatedAt uint64 `json:"updated_at"` + + // Created by + CreatedBy string `json:"created_by"` + + // Updated by + UpdatedBy string `json:"updated_by"` + + // List of rules + Rules Rules `json:"rules"` +} + +type RecordQoSPolicy struct { + // ID of the QoS policy + ID uint64 `json:"id"` + + // GUID + GUID uint64 `json:"guid"` + + // Account ID that owns the QoS policy + AccountID uint64 `json:"account_id"` + + // Name of the QoS policy + Name string `json:"name"` + + // Description of the QoS policy + Description string `json:"description"` + + // Status of the QoS policy + Status string `json:"status"` + + // Created at (unix timestamp) + CreatedAt uint64 `json:"created_at"` + + // Updated at (unix timestamp) + UpdatedAt uint64 `json:"updated_at"` + + // Created by + CreatedBy string `json:"created_by"` + + // Updated by + UpdatedBy string `json:"updated_by"` + + // List of rules + Rules Rules `json:"rules"` +} + +type Rules []Rule + +type Rule struct { + // ID of the rule + ID uint64 `json:"id"` + + // Description of the rule + Description string `json:"description"` + + // Rule priority in OVS (higher number = higher priority) + Priority uint64 `json:"priority"` + + // Traffic direction + Direction string `json:"direction"` + + // IP protocol + Protocol string `json:"protocol"` + + // Priority Code Point (0-7). L2 marking + PCPTag uint64 `json:"pcp_tag"` + + // DSCP value (0-63). L3 marking + DSCPValue uint64 `json:"dscp_value"` + + // Source IP address + SrcIP string `json:"src_ip"` + + // Destination IP address + DstIP string `json:"dst_ip"` + + // Source MAC address + SrcMAC string `json:"src_mac"` + + // Destination MAC address + DstMAC string `json:"dst_mac"` + + // Source port + SrcPort uint64 `json:"src_port"` + + // Destination port + DstPort uint64 `json:"dst_port"` +} diff --git a/pkg/cloudapi/qospolicy/qos_policy.go b/pkg/cloudapi/qospolicy/qos_policy.go new file mode 100644 index 0000000..f93580e --- /dev/null +++ b/pkg/cloudapi/qospolicy/qos_policy.go @@ -0,0 +1,15 @@ +package qospolicy + +import "repository.basistech.ru/BASIS/decort-golang-sdk/interfaces" + +// Structure for creating request to QoS policy +type QoSPolicy struct { + client interfaces.Caller +} + +// Builder for QoS policy endpoint +func New(client interfaces.Caller) *QoSPolicy { + return &QoSPolicy{ + client: client, + } +} diff --git a/pkg/cloudapi/qospolicy/sorting.go b/pkg/cloudapi/qospolicy/sorting.go new file mode 100644 index 0000000..aa89049 --- /dev/null +++ b/pkg/cloudapi/qospolicy/sorting.go @@ -0,0 +1,39 @@ +package qospolicy + +import "sort" + +// SortByCreatedAt sorts ListQosPolicies by the CreatedAt field in ascending order +// If inverse param is set to true, the order is reversed +func (lqp ListQoSPolicies) SortByCreatedAt(inverse bool) ListQoSPolicies { + if len(lqp.Data) < 2 { + return lqp + } + + sort.Slice(lqp.Data, func(i, j int) bool { + if inverse { + return lqp.Data[i].CreatedAt > lqp.Data[j].CreatedAt + } + + return lqp.Data[i].CreatedAt < lqp.Data[j].CreatedAt + }) + + return lqp +} + +// SortByUpdatedAt sorts ListQosPolicies by the UpdatedAt field in ascending order +// If inverse param is set to true, the order is reversed +func (lqp ListQoSPolicies) SortByUpdatedAt(inverse bool) ListQoSPolicies { + if len(lqp.Data) < 2 { + return lqp + } + + sort.Slice(lqp.Data, func(i, j int) bool { + if inverse { + return lqp.Data[i].UpdatedAt > lqp.Data[j].UpdatedAt + } + + return lqp.Data[i].UpdatedAt < lqp.Data[j].UpdatedAt + }) + + return lqp +} diff --git a/pkg/cloudapi/qospolicy/update.go b/pkg/cloudapi/qospolicy/update.go new file mode 100644 index 0000000..c6d7739 --- /dev/null +++ b/pkg/cloudapi/qospolicy/update.go @@ -0,0 +1,52 @@ +package qospolicy + +import ( + "context" + "encoding/json" + "net/http" + + "repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants" + "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" +) + +type UpdateRequest struct { + // QoS policy ID + // Required: true + QoSPolicyID uint64 `url:"qos_policy_id" json:"qos_policy_id" validate:"required"` + + // New QoS policy name + // Required: false + Name string `url:"name,omitempty" json:"name,omitempty"` + + // New QoS policy description + // Required: false + Description string `url:"description,omitempty" json:"description,omitempty"` +} + +func (qp QoSPolicy) Update(ctx context.Context, req UpdateRequest) (*RecordQoSPolicy, error) { + res, err := qp.UpdateRaw(ctx, req) + if err != nil { + return nil, err + } + + info := RecordQoSPolicy{} + + err = json.Unmarshal(res, &info) + if err != nil { + return nil, err + } + + return &info, nil +} + +func (qp QoSPolicy) UpdateRaw(ctx context.Context, req UpdateRequest) ([]byte, error) { + err := validators.ValidateRequest(req) + if err != nil { + return nil, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudapi/network_qos_policy/update" + + res, err := qp.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req) + return res, err +} diff --git a/pkg/cloudapi/rg/audits.go b/pkg/cloudapi/rg/audits.go deleted file mode 100644 index 8cbe016..0000000 --- a/pkg/cloudapi/rg/audits.go +++ /dev/null @@ -1,40 +0,0 @@ -package rg - -import ( - "context" - "encoding/json" - "net/http" - - "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" -) - -// AuditsRequest struct to get audit -type AuditsRequest struct { - // Resource group ID - // Required: true - RGID uint64 `url:"rgId" json:"rgId" validate:"required"` -} - -// Audits gets audit records for the specified resource group object -func (r RG) Audits(ctx context.Context, req AuditsRequest) (ListAudits, error) { - err := validators.ValidateRequest(req) - if err != nil { - return nil, validators.ValidationErrors(validators.GetErrors(err)) - } - - url := "/cloudapi/rg/audits" - - res, err := r.client.DecortApiCall(ctx, http.MethodPost, url, req) - if err != nil { - return nil, err - } - - list := ListAudits{} - - err = json.Unmarshal(res, &list) - if err != nil { - return nil, err - } - - return list, nil -} diff --git a/pkg/cloudapi/tasks/list.go b/pkg/cloudapi/tasks/list.go index a2db764..9a55412 100644 --- a/pkg/cloudapi/tasks/list.go +++ b/pkg/cloudapi/tasks/list.go @@ -38,6 +38,14 @@ type ListRequest struct { // Required: false UpdateTimeTo uint64 `url:"updateTimeTo,omitempty" json:"updateTimeTo,omitempty"` + // Find all tasks created after point in time (unixtime) + // Required: false + CreatedTimeAt uint64 `url:"createdTimeAt,omitempty" json:"createdTimeAt,omitempty"` + + // Find all tasks created before point in time (unixtime) + // Required: false + CreatedTimeTo uint64 `url:"createdTimeTo,omitempty" json:"createdTimeTo,omitempty"` + // Page number // Default: 0 // Default: 0 diff --git a/pkg/cloudapi/tasks/models.go b/pkg/cloudapi/tasks/models.go index 0680d41..ee5e5b7 100644 --- a/pkg/cloudapi/tasks/models.go +++ b/pkg/cloudapi/tasks/models.go @@ -41,6 +41,9 @@ type RecordAsyncTask struct { // Updated time UpdatedTime uint64 `json:"updatedTime"` + + // Time of creation + CreatedTime uint64 `json:"createdTime"` } // Detailed information about task diff --git a/pkg/cloudapi/user/get_audit.go b/pkg/cloudapi/user/get_audit.go deleted file mode 100644 index 3253c88..0000000 --- a/pkg/cloudapi/user/get_audit.go +++ /dev/null @@ -1,61 +0,0 @@ -package user - -import ( - "context" - "encoding/json" - "net/http" -) - -// GetAuditRequest struct for getting user's audits. -type GetAuditRequest struct { - // Find by api call. - // Required: false - Call string `url:"call,omitempty" json:"call,omitempty"` - - // Find all audits after point in time (unixtime) - // Required: false - TimestampAt uint64 `url:"timestampAt,omitempty" json:"timestampAt,omitempty"` - - // Find all audits before point in time (unixtime) - // Required: false - TimestampTo uint64 `url:"timestampTo,omitempty" json:"timestampTo,omitempty"` - - // find by HTTP max status code - // Required: false - MaxStatusCode uint64 `url:"maxStatusCode,omitempty" json:"maxStatusCode,omitempty"` - - // find by HTTP min status code - // Required: false - MinStatusCode uint64 `url:"minStatusCode,omitempty" json:"minStatusCode,omitempty"` - - // 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, maximum - 100. - // Required: false - Size uint64 `url:"size,omitempty" json:"size,omitempty"` -} - -// GetAudit gets user's audits. -func (u User) GetAudit(ctx context.Context, req GetAuditRequest) (ListAudits, error) { - url := "/cloudapi/user/getAudit" - - res, err := u.client.DecortApiCall(ctx, http.MethodPost, url, req) - if err != nil { - return ListAudits{}, err - } - - list := ListAudits{} - - err = json.Unmarshal(res, &list) - if err != nil { - return ListAudits{}, err - } - - return list, nil -} diff --git a/pkg/cloudapi/user/is_valid_invite_user_token.go b/pkg/cloudapi/user/is_valid_invite_user_token.go deleted file mode 100644 index 250d05a..0000000 --- a/pkg/cloudapi/user/is_valid_invite_user_token.go +++ /dev/null @@ -1,44 +0,0 @@ -package user - -import ( - "context" - "net/http" - "strconv" - - "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" -) - -// GetRequest struct to check if the inviteusertoken and emailaddress pair are valid and matching. -type IsValidInviteUserTokenRequest struct { - // InviteUserToken - // The token that was previously sent to the invited user email - // Required: true - InviteUserToken string `url:"inviteusertoken" json:"inviteusertoken" validate:"required"` - - // EmailAddress - // Email address for the user - // Required: true - EmailAddress string `url:"emailaddress" json:"emailaddress" validate:"required"` -} - -// IsValidInviteUserToken checks if the inviteusertoken and emailaddress pair are valid and matching. -func (u User) IsValidInviteUserToken(ctx context.Context, req IsValidInviteUserTokenRequest) (bool, error) { - err := validators.ValidateRequest(req) - if err != nil { - return false, validators.ValidationErrors(validators.GetErrors(err)) - } - - url := "/cloudapi/user/isValidInviteUserToken" - - res, err := u.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 -} diff --git a/pkg/cloudapi/user/models.go b/pkg/cloudapi/user/models.go index d9c982c..1b337f1 100644 --- a/pkg/cloudapi/user/models.go +++ b/pkg/cloudapi/user/models.go @@ -78,35 +78,47 @@ func (s *StatusCode) UnmarshalJSON(b []byte) error { type BriefResources struct { Accounts Accounts `json:"Accounts,omitempty"` - CSs CSs `json:"CSs,omitempty"` Computes Computes `json:"Computes,omitempty"` RGs RGs `json:"RGs,omitempty"` - VMs VMs `json:"VMs,omitempty"` } type Accounts struct { - Disabled uint64 `json:"DISABLED,omitempty"` - Enabled uint64 `json:"ENABLED,omitempty"` -} - -type CSs struct { - Disabled uint64 `json:"DISABLED,omitempty"` - Enabled uint64 `json:"ENABLED,omitempty"` + Destroying uint64 `json:"DESTROYING,omitempty"` + Confirmed uint64 `json:"CONFIRMED,omitempty"` + Disabled uint64 `json:"DISABLED,omitempty"` + Deleted uint64 `json:"DELETED,omitempty"` } type Computes struct { - Started uint64 `json:"Started,omitempty"` - Stopped uint64 `json:"Stopped,omitempty"` + Starting uint64 `json:"STARTING,omitempty"` + Started uint64 `json:"STARTED,omitempty"` + Stopping uint64 `json:"STOPPING,omitempty"` + Stopped uint64 `json:"STOPPED,omitempty"` + Paused uint64 `json:"PAUSED,omitempty"` + Pausing uint64 `json:"PAUSING,omitempty"` + Merge uint64 `json:"MERGE,omitempty"` + Migrating uint64 `json:"MIGRATING,omitempty"` + MigratingIn uint64 `json:"MIGRATING_IN,omitempty"` + MigratingOut uint64 `json:"MIGRATING_OUT,omitempty"` + Down uint64 `json:"DOWN,omitempty"` + Scheduled uint64 `json:"SCHEDULED,omitempty"` + BackupStopped uint64 `json:"BACKUP_STOPPED,omitempty"` + BackupRunning uint64 `json:"BACKUP_RUNNING,omitempty"` + SnapСreate uint64 `json:"SNAPCREATE,omitempty"` + Cloning uint64 `json:"CLONING,omitempty"` + Rollback uint64 `json:"ROLLBACK,omitempty"` } type RGs struct { - Disabled uint64 `json:"DISABLED,omitempty"` - Enabled uint64 `json:"ENABLED,omitempty"` -} - -type VMs struct { - Halted uint64 `json:"Halted,omitempty"` - Running uint64 `json:"Running,omitempty"` + Modeled uint64 `json:"MODELED,omitempty"` + Created uint64 `json:"CREATED,omitempty"` + Deleted uint64 `json:"DELETED,omitempty"` + Deleting uint64 `json:"DELETING,omitempty"` + Destroying uint64 `json:"DESTROYING,omitempty"` + Disabled uint64 `json:"DISABLED,omitempty"` + Disabling uint64 `json:"DISABLING,omitempty"` + Enabling uint64 `json:"ENABLING,omitempty"` + Restoring uint64 `json:"RESTORING,omitempty"` } type APIsEndpoints struct { diff --git a/pkg/cloudapi/vgpu/list.go b/pkg/cloudapi/vgpu/list.go index a7d7454..f51facc 100644 --- a/pkg/cloudapi/vgpu/list.go +++ b/pkg/cloudapi/vgpu/list.go @@ -18,33 +18,29 @@ type ListRequest struct { // Required: false Status string `url:"status,omitempty" json:"status,omitempty"` - // Find by vgpu type + // Find by mode // Required: false - Type string `url:"type,omitempty" json:"type,omitempty"` + SplitMode string `url:"split_mode,omitempty" json:"split_mode,omitempty"` - // Find by vgpu mode + // Find by id node // Required: false - Mode string `url:"mode,omitempty" json:"mode,omitempty"` - - // Find by id resgroup - // Required: false - RGID uint64 `url:"rgId,omitempty" json:"rgId,omitempty"` + NodeID uint64 `url:"node_id,omitempty" json:"node_id,omitempty"` // Find by account id // Required: false - AccountID uint64 `url:"accountId,omitempty" json:"accountId,omitempty"` + AccountID uint64 `url:"account_id,omitempty" json:"account_id,omitempty"` // Find by compute id // Required: false - ComputeID uint64 `url:"computeId,omitempty" json:"computeId,omitempty"` + ComputeID uint64 `url:"compute_id,omitempty" json:"compute_id,omitempty"` // Find by pgpu id // Required: false - PGPUID uint64 `url:"pgpuId,omitempty" json:"pgpuId,omitempty"` + PGPUID uint64 `url:"pgpu_id,omitempty" json:"pgpu_id,omitempty"` // Sort by one of supported fields, format +|-(field) // Required: false - SortBy string `url:"sortBy,omitempty" json:"sortBy,omitempty" validate:"omitempty,sortBy"` + SortBy string `url:"sort_by,omitempty" json:"sort_by,omitempty" validate:"omitempty,sortBy"` // Page number // Required: false @@ -83,6 +79,6 @@ func (v VGPU) ListRaw(ctx context.Context, req ListRequest) ([]byte, error) { url := "/cloudapi/vgpu/list" - res, err := v.client.DecortApiCall(ctx, http.MethodPost, url, req) + res, err := v.client.DecortApiCall(ctx, http.MethodGet, url, req) return res, err } diff --git a/pkg/cloudapi/vgpu/models.go b/pkg/cloudapi/vgpu/models.go index 696f4bf..8c96a9f 100644 --- a/pkg/cloudapi/vgpu/models.go +++ b/pkg/cloudapi/vgpu/models.go @@ -1,14 +1,23 @@ package vgpu type ItemVGPU struct { - // Account ID - AccountID uint64 `json:"accountId"` + // Account IDs + AccountIDs []uint64 `json:"account_ids"` + + // Bus number + BusNumber int `json:"bus_number"` + + // ComputeID + ComputeID uint64 `json:"compute_id"` // Created time - CreatedTime uint64 `json:"createdTime"` + CreatedTime uint64 `json:"created_time"` // Deleted time - DeletedTime uint64 `json:"deletedTime"` + DeletedTime uint64 `json:"deleted_time"` + + // Device Reference + DeviceReference string `json:"device_reference"` //Grid ID GID uint64 `json:"gid"` @@ -19,44 +28,29 @@ type ItemVGPU struct { // VGPU ID ID uint64 `json:"id"` - // Last claimed by - LastClaimedBy uint64 `json:"lastClaimedBy"` + // Last Update time + LastUpdateTime uint64 `json:"last_update_time"` - // Last update time - LastUpdateTime uint64 `json:"lastUpdateTime"` + // Mdev UUID + MdevUUID string `json:"mdev_uuid"` - // Mode - Mode string `json:"mode"` - - // Bus number - BusNumber int `json:"bus_number"` + // Parent PCI Address + ParentPCIAddress string `json:"parent_pci_address"` // PCI Slot - PCISlot int `json:"pciSlot"` + PCISlot uint64 `json:"pci_slot"` - // PGPUID - PGPUID uint64 `json:"pgpuid"` + // PGPU ID + PGPUID uint64 `json:"pgpu_id"` - // Profile ID - ProfileID uint64 `json:"profileId"` + // Profile Reference + ProfileReference string `json:"profile_reference"` - // RAM - RAM uint64 `json:"ram"` - - // Reference ID - ReferenceID string `json:"referenceId"` - - // RGID - RGID uint64 `json:"rgId"` + // Split Mode + SplitMode string `json:"split_mode"` // Status Status string `json:"status"` - - // Type - Type string `json:"type"` - - // VMID - VMID uint64 `json:"vmid"` } // List of VGPU diff --git a/pkg/cloudapi/vins/audits.go b/pkg/cloudapi/vins/audits.go deleted file mode 100644 index 8288dbe..0000000 --- a/pkg/cloudapi/vins/audits.go +++ /dev/null @@ -1,40 +0,0 @@ -package vins - -import ( - "context" - "encoding/json" - "net/http" - - "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" -) - -// AuditsRequest struct to get audits -type AuditsRequest struct { - // ID of the VINS - // Required: true - VINSID uint64 `url:"vinsId" json:"vinsId" validate:"required"` -} - -// Audits gets audit records for the specified VINS object -func (v VINS) Audits(ctx context.Context, req AuditsRequest) (ListAudits, error) { - err := validators.ValidateRequest(req) - if err != nil { - return nil, validators.ValidationErrors(validators.GetErrors(err)) - } - - url := "/cloudapi/vins/audits" - - res, err := v.client.DecortApiCall(ctx, http.MethodPost, url, req) - if err != nil { - return nil, err - } - - list := ListAudits{} - - err = json.Unmarshal(res, &list) - if err != nil { - return nil, err - } - - return list, nil -} diff --git a/pkg/cloudapi/vins/models.go b/pkg/cloudapi/vins/models.go index 86851c1..5f6bf89 100644 --- a/pkg/cloudapi/vins/models.go +++ b/pkg/cloudapi/vins/models.go @@ -20,6 +20,9 @@ type ItemVINS struct { // Deleted time DeletedTime uint64 `json:"deletedTime"` + // Enable Default Gateway + EnableDefaultGateway bool `json:"enable_default_gateway"` + // External IP ExternalIP string `json:"externalIP"` diff --git a/pkg/cloudapi/zone/models.go b/pkg/cloudapi/zone/models.go index 34eda0f..62fbc2d 100644 --- a/pkg/cloudapi/zone/models.go +++ b/pkg/cloudapi/zone/models.go @@ -117,6 +117,15 @@ type RecordZone struct { // Reserved RAM ReservedRAM uint64 `json:"reserved_ram"` + + // Storage Distributed Resource Scheduler + SDRS bool `json:"sdrs"` + + // Mode of SDRS + SDRSMode string `json:"sdrs_mode"` + + // Minimal level of logs + LoggingLevel string `json:"logging_level"` } // A zone item from a list @@ -195,4 +204,13 @@ type ItemZone struct { // Reserved RAM ReservedRAM uint64 `json:"reserved_ram"` + + // Storage Distributed Resource Scheduler + SDRS bool `json:"sdrs"` + + // Mode of SDRS + SDRSMode string `json:"sdrs_mode"` + + // Minimal level of logs + LoggingLevel string `json:"logging_level"` } diff --git a/pkg/cloudbroker/account/audits.go b/pkg/cloudbroker/account/audits.go deleted file mode 100644 index 2e1169d..0000000 --- a/pkg/cloudbroker/account/audits.go +++ /dev/null @@ -1,40 +0,0 @@ -package account - -import ( - "context" - "encoding/json" - "net/http" - - "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" -) - -// AuditsRequest struct to give list of account audits -type AuditsRequest struct { - // ID of the account - // Required: true - AccountID uint64 `url:"accountId" json:"accountId" validate:"required"` -} - -// Audits gets audit records for the specified account object -func (a Account) Audits(ctx context.Context, req AuditsRequest) (ListAudits, error) { - err := validators.ValidateRequest(req) - if err != nil { - return nil, validators.ValidationErrors(validators.GetErrors(err)) - } - - url := "/cloudbroker/account/audits" - - res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req) - if err != nil { - return nil, err - } - - list := ListAudits{} - - err = json.Unmarshal(res, &list) - if err != nil { - return nil, err - } - - return list, nil -} diff --git a/pkg/cloudbroker/account/disable.go b/pkg/cloudbroker/account/disable.go deleted file mode 100644 index a4f62da..0000000 --- a/pkg/cloudbroker/account/disable.go +++ /dev/null @@ -1,38 +0,0 @@ -package account - -import ( - "context" - "net/http" - "strconv" - - "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" -) - -// DisableRequest struct to disable account -type DisableRequest struct { - // ID of account - // Required: true - AccountID uint64 `url:"accountId" json:"accountId" validate:"required"` -} - -// Disable disables an account -func (a Account) Disable(ctx context.Context, req DisableRequest) (bool, error) { - err := validators.ValidateRequest(req) - if err != nil { - return false, validators.ValidationErrors(validators.GetErrors(err)) - } - - url := "/cloudbroker/account/disable" - - res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req) - if err != nil { - return false, err - } - - result, err := strconv.ParseBool(string(res)) - if err != nil { - return false, err - } - - return result, nil -} diff --git a/pkg/cloudbroker/account/enable.go b/pkg/cloudbroker/account/enable.go deleted file mode 100644 index 50609b2..0000000 --- a/pkg/cloudbroker/account/enable.go +++ /dev/null @@ -1,38 +0,0 @@ -package account - -import ( - "context" - "net/http" - "strconv" - - "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" -) - -// EnableRequest struct to enable account -type EnableRequest struct { - // ID of account - // Required: true - AccountID uint64 `url:"accountId" json:"accountId" validate:"required"` -} - -// Enable enables an account -func (a Account) Enable(ctx context.Context, req EnableRequest) (bool, error) { - err := validators.ValidateRequest(req) - if err != nil { - return false, validators.ValidationErrors(validators.GetErrors(err)) - } - - url := "/cloudbroker/account/enable" - - res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req) - if err != nil { - return false, err - } - - result, err := strconv.ParseBool(string(res)) - if err != nil { - return false, err - } - - return result, nil -} diff --git a/pkg/cloudbroker/account/models.go b/pkg/cloudbroker/account/models.go index e748623..0c6e026 100644 --- a/pkg/cloudbroker/account/models.go +++ b/pkg/cloudbroker/account/models.go @@ -456,11 +456,56 @@ type ItemFLIPGroup struct { // Computes info type Computes struct { + // Starting + Starting uint64 `json:"STARTING"` + // Started - Started uint64 `json:"Started"` + Started uint64 `json:"STARTED"` + + // Stopping + Stopping uint64 `json:"STOPPING"` // Stopped - Stopped uint64 `json:"Stopped"` + Stopped uint64 `json:"STOPPED"` + + // Paused + Paused uint64 `json:"PAUSED"` + + // Pausing + Pausing uint64 `json:"PAUSING"` + + // Merge + Merge uint64 `json:"MERGE"` + + // Migrating + Migrating uint64 `json:"MIGRATING"` + + // Migrating in + MigratingIn uint64 `json:"MIGRATING_IN"` + + // Migrating out + MigratingOut uint64 `json:"MIGRATING_OUT"` + + // Down + Down uint64 `json:"DOWN"` + + // Scheduled + Scheduled uint64 `json:"SCHEDULED"` + + // Backup stopped + BackupStopped uint64 `json:"BACKUP_STOPPED"` + + // Backup running + BackupRunning uint64 `json:"BACKUP_RUNNING"` + + // Snapcreate + Snapcreate uint64 `json:"SNAPCREATE"` + + // Cloning + Cloning uint64 `json:"CLONING"` + + // Rollback + Rollback uint64 `json:"ROLLBACK"` } // Limits @@ -579,6 +624,9 @@ type ItemVINS struct { // Deleted time DeletedTime uint64 `json:"deletedTime"` + // Enable Default Gateway + EnableDefaultGateway bool `json:"enable_default_gateway"` + // External IP ExternalIP string `json:"externalIP"` diff --git a/pkg/cloudbroker/bservice/group_add.go b/pkg/cloudbroker/bservice/group_add.go index cea02b5..bb9ebab 100644 --- a/pkg/cloudbroker/bservice/group_add.go +++ b/pkg/cloudbroker/bservice/group_add.go @@ -5,6 +5,7 @@ import ( "net/http" "strconv" + "repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants" "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" ) @@ -62,9 +63,9 @@ type GroupAddRequest struct { // Required: false TimeoutStart uint64 `url:"timeoutStart,omitempty" json:"timeoutStart,omitempty"` - // Meta data for working group computes, format YAML "user_data": 1111 + // Meta data for working group computes, format yaml string or json object // Required: false - UserData string `url:"userData,omitempty" json:"userData,omitempty"` + UserData interface{} `url:"userData,omitempty" json:"userData,omitempty"` // Chipset "i440fx" or "Q35 // Default value : Q35 @@ -97,7 +98,7 @@ func (b BService) GroupAdd(ctx context.Context, req GroupAddRequest) (uint64, er url := "/cloudbroker/bservice/groupAdd" - res, err := b.client.DecortApiCall(ctx, http.MethodPost, url, req) + res, err := b.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req) if err != nil { return 0, err } diff --git a/pkg/cloudbroker/compute/audits.go b/pkg/cloudbroker/compute/audits.go deleted file mode 100644 index 6ee690a..0000000 --- a/pkg/cloudbroker/compute/audits.go +++ /dev/null @@ -1,76 +0,0 @@ -package compute - -import ( - "context" - "encoding/json" - "net/http" - - "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" -) - -// AuditsRequest struct to get audit records -type AuditsRequest struct { - // ID of the compute - // Required: true - ComputeID uint64 `url:"compute_id" json:"compute_id" validate:"required"` - - // Find all audits after point in time - // Required: false - TimestampAT uint64 `url:"timestamp_at,omitempty" json:"timestamp_at,omitempty"` - - // Find all audits before point in time - // Required: false - TimestampTO uint64 `url:"timestamp_to,omitempty" json:"timestamp_to,omitempty"` - - // Find by user - // Required: false - User string `url:"user,omitempty" json:"user,omitempty"` - - // Find by api endpoints - // Required: false - Call string `url:"call,omitempty" json:"call,omitempty"` - - // Sort by one of supported fields, format ± - // Required: false - SortBy string `url:"sort_by,omitempty" json:"sort_by,omitempty"` - - // Page number - // Required: false - Page uint64 `url:"page,omitempty" json:"page,omitempty"` - - // Page size - // Required: false - Size uint64 `url:"size,omitempty" json:"size,omitempty"` - - // Find by HTTP min status code - // Required: false - MinStatusCode uint64 `url:"min_status_code,omitempty" json:"min_status_code,omitempty"` - - // Find by HTTP max status code - // Required: false - MaxStatusCode uint64 `url:"max_status_code,omitempty" json:"max_status_code,omitempty"` -} - -// Audits gets audit records for the specified compute object -func (c Compute) Audits(ctx context.Context, req AuditsRequest) (*ListDetailedAudits, error) { - err := validators.ValidateRequest(req) - if err != nil { - return nil, validators.ValidationErrors(validators.GetErrors(err)) - } - - url := "/cloudbroker/compute/audits" - - res, err := c.client.DecortApiCall(ctx, http.MethodGet, url, req) - if err != nil { - return nil, err - } - - list := ListDetailedAudits{} - - err = json.Unmarshal(res, &list) - if err != nil { - return nil, err - } - - return &list, nil -} diff --git a/pkg/cloudbroker/compute/change_qos_policies.go b/pkg/cloudbroker/compute/change_qos_policies.go new file mode 100644 index 0000000..0bf74a2 --- /dev/null +++ b/pkg/cloudbroker/compute/change_qos_policies.go @@ -0,0 +1,84 @@ +package compute + +import ( + "context" + "net/http" + "strconv" + + "repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants" + "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" +) + +type ChangeQoSPoliciesRequest struct { + // Compute ID + // Required: true + ComputeID uint64 `url:"compute_id" json:"compute_id" validate:"required"` + + // Interface IP or MAC address + // Required: true + Interface string `url:"interface" json:"interface" validate:"required"` + + // List of QoS Policy IDs to assign to this interface + // Required: false + QoSPolicyIDs []uint64 `url:"qos_policy_ids,omitempty" json:"qos_policy_ids,omitempty"` +} + +type wrapperChangeQoSPoliciesRequest struct { + ChangeQoSPoliciesRequest + + AsyncMode bool `url:"asyncMode"` +} + +// ChangeQoSPolicies change qos policies for compute +func (c Compute) ChangeQoSPolicies(ctx context.Context, req ChangeQoSPoliciesRequest) (bool, error) { + err := validators.ValidateRequest(req) + if err != nil { + return false, validators.ValidationErrors(validators.GetErrors(err)) + } + + reqWrapped := wrapperChangeQoSPoliciesRequest{ + ChangeQoSPoliciesRequest: req, + AsyncMode: false, + } + + url := "/cloudbroker/compute/change_qos_policies" + + res, err := c.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, reqWrapped) + if err != nil { + return false, err + } + + result, err := strconv.ParseBool(string(res)) + if err != nil { + return false, err + } + + return result, nil +} + +// ChangeQoSPolicies change qos policies for compute with AsyncMode +func (c Compute) ChangeQoSPoliciesAsync(ctx context.Context, req ChangeQoSPoliciesRequest) (bool, error) { + err := validators.ValidateRequest(req) + if err != nil { + return false, validators.ValidationErrors(validators.GetErrors(err)) + } + + reqWrapped := wrapperChangeQoSPoliciesRequest{ + ChangeQoSPoliciesRequest: req, + AsyncMode: true, + } + + url := "/cloudbroker/compute/change_qos_policies" + + res, err := c.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, reqWrapped) + if err != nil { + return false, err + } + + result, err := strconv.ParseBool(string(res)) + if err != nil { + return false, err + } + + return result, nil +} diff --git a/pkg/cloudbroker/compute/computeci_set.go b/pkg/cloudbroker/compute/computeci_set.go deleted file mode 100644 index 515812a..0000000 --- a/pkg/cloudbroker/compute/computeci_set.go +++ /dev/null @@ -1,42 +0,0 @@ -package compute - -import ( - "context" - "net/http" - "strconv" - - "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" -) - -// ComputeCISetRequest struct to set compute CI -type ComputeCISetRequest struct { - // ID of compute instance - // Required: true - ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"` - - // ID of the Compute CI - // Required: true - ComputeCIID uint64 `url:"computeciId" json:"computeciId" validate:"required"` -} - -// ComputeCISet sets compute CI ID for compute -func (c Compute) ComputeCISet(ctx context.Context, req ComputeCISetRequest) (bool, error) { - err := validators.ValidateRequest(req) - if err != nil { - return false, validators.ValidationErrors(validators.GetErrors(err)) - } - - url := "/cloudbroker/compute/computeciSet" - - 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 -} diff --git a/pkg/cloudbroker/compute/computeci_unset.go b/pkg/cloudbroker/compute/computeci_unset.go deleted file mode 100644 index 8696e0d..0000000 --- a/pkg/cloudbroker/compute/computeci_unset.go +++ /dev/null @@ -1,38 +0,0 @@ -package compute - -import ( - "context" - "net/http" - "strconv" - - "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" -) - -// ComputeCIUnsetRequest struct to unset compute CI -type ComputeCIUnsetRequest struct { - // ID of compute instance - // Required: true - ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"` -} - -// ComputeCIUnset unsets compute CI ID from compute -func (c Compute) ComputeCIUnset(ctx context.Context, req ComputeCIUnsetRequest) (bool, error) { - err := validators.ValidateRequest(req) - if err != nil { - return false, validators.ValidationErrors(validators.GetErrors(err)) - } - - url := "/cloudbroker/compute/computeciUnset" - - 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 -} diff --git a/pkg/cloudbroker/compute/get_audits.go b/pkg/cloudbroker/compute/get_audits.go deleted file mode 100644 index 0f627a4..0000000 --- a/pkg/cloudbroker/compute/get_audits.go +++ /dev/null @@ -1,40 +0,0 @@ -package compute - -import ( - "context" - "encoding/json" - "net/http" - - "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" -) - -// GetAuditsRequest struct to get compute audits -type GetAuditsRequest struct { - // ID of compute instance - // Required: true - ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"` -} - -// GetAudits gets compute audits -func (c Compute) GetAudits(ctx context.Context, req GetAuditsRequest) (ListAudits, error) { - err := validators.ValidateRequest(req) - if err != nil { - return nil, validators.ValidationErrors(validators.GetErrors(err)) - } - - url := "/cloudbroker/compute/getAudits" - - res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req) - if err != nil { - return nil, err - } - - list := ListAudits{} - - err = json.Unmarshal(res, &list) - if err != nil { - return nil, err - } - - return list, nil -} diff --git a/pkg/cloudbroker/compute/get_log.go b/pkg/cloudbroker/compute/get_log.go deleted file mode 100644 index fd154bd..0000000 --- a/pkg/cloudbroker/compute/get_log.go +++ /dev/null @@ -1,36 +0,0 @@ -package compute - -import ( - "context" - "net/http" - - "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" -) - -// GetLogRequest struct to get compute logs -type GetLogRequest struct { - // ID of compute instance to get log for - // Required: true - ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"` - - // Path to log file - // Required: true - Path string `url:"path" json:"path" validate:"required"` -} - -// GetLog gets compute's log file by path -func (c Compute) GetLog(ctx context.Context, req GetLogRequest) (string, error) { - err := validators.ValidateRequest(req) - if err != nil { - return "", validators.ValidationErrors(validators.GetErrors(err)) - } - - url := "/cloudbroker/compute/getLog" - - res, err := c.client.DecortApiCall(ctx, http.MethodGet, url, req) - if err != nil { - return "", err - } - - return string(res), nil -} diff --git a/pkg/cloudbroker/compute/list_pci_device.go b/pkg/cloudbroker/compute/list_pci_device.go index 366a63a..b39a590 100644 --- a/pkg/cloudbroker/compute/list_pci_device.go +++ b/pkg/cloudbroker/compute/list_pci_device.go @@ -14,10 +14,6 @@ type ListPCIDeviceRequest struct { // Required: true ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"` - // Find by resource group ID - // Required: false - RGID uint64 `url:"rgId,omitempty" json:"rgId,omitempty"` - // Find by device id // Required: false DevID uint64 `url:"devId,omitempty" json:"devId,omitempty"` diff --git a/pkg/cloudbroker/compute/models.go b/pkg/cloudbroker/compute/models.go index ee06ece..d4c0409 100644 --- a/pkg/cloudbroker/compute/models.go +++ b/pkg/cloudbroker/compute/models.go @@ -651,6 +651,9 @@ type ItemInterface struct { // QOS QOS QOS `json:"qos"` + // List of QoS Policy IDs + QoSPolicies []uint64 `json:"qos_policies"` + // List of security groups SecGroups []uint64 `json:"security_groups"` @@ -924,6 +927,9 @@ type InfoCompute struct { // VINS connected VINSConnected uint64 `json:"vinsConnected"` + // Watchdog action + WatchdogAction string `json:"watchdog_action"` + // Weight Weight uint64 `json:"weight"` @@ -1224,11 +1230,14 @@ type RecordCompute struct { Userdata interface{} `json:"userdata"` // List VGPU - VGPUs []VGPUItem `json:"vgpus"` + VGPUs []ItemVGPU `json:"vgpus"` // VNC password VNCPassword string `json:"vncPasswd"` + // Watchdog action + WatchdogAction string `json:"watchdog_action"` + // Weight Weight uint64 `json:"weight"` @@ -1491,7 +1500,7 @@ type SnapRecordCompute struct { Userdata interface{} `json:"userdata"` // List VGPU - VGPUs []VGPUItem `json:"vgpus"` + VGPUs []ItemVGPU `json:"vgpus"` // VNC password VNCPassword string `json:"vncPasswd"` @@ -1511,65 +1520,6 @@ type LoaderMetaIso struct { Path string `json:"path"` } -type VGPUItem struct { - // ID - ID uint64 `json:"id"` - - // GID - GID uint64 `json:"gid"` - - // Type - Type string `json:"type"` - - // Mode - Mode string `json:"mode"` - - // Status - Status string `json:"status"` - - // ProfileID - ProfileID uint64 `json:"profileId"` - - // RAM - RAM uint64 `json:"ram"` - - // LastUpdateTime - LastUpdateTime uint64 `json:"lastUpdateTime"` - - // CreatedTime - CreatedTime uint64 `json:"createdTime"` - - // DeletedTime - DeletedTime uint64 `json:"deletedTime"` - - // VMID - VMID uint64 `json:"vmid"` - - // PGPuid - PGPuid uint64 `json:"pgpuid"` - - // ReferenceID - ReferenceID string `json:"referenceId"` - - // AccountID - AccountID uint64 `json:"accountId"` - - // RgID - RgID uint64 `json:"rgId"` - - // LastClaimedBy - LastClaimedBy uint64 `json:"lastClaimedBy"` - - // PCISlot - PCISlot uint64 `json:"pciSlot"` - - // BusNumber - BusNumber uint64 `json:"bus_number"` - - // GUID - GUID uint64 `json:"guid"` -} - // Information about of disk IDs type ListInfoDisks []InfoDisk @@ -1614,6 +1564,9 @@ type InfoDisk struct { // SEP ID SepID int64 `json:"sepId"` + // Image ID + ImageID uint64 `json:"imageId"` + // Read-only ReadOnly bool `json:"read_only"` } @@ -1674,8 +1627,8 @@ type ItemPCIDevice struct { // Name Name string `json:"name"` - // Resource group ID - RGID uint64 `json:"rgId"` + // Account IDs + AccountIDs []uint64 `json:"account_ids"` // Node ID NodeID uint64 `json:"nodeId"` @@ -1707,59 +1660,56 @@ type ListVGPUs struct { // Main information about vgpu device type ItemVGPU struct { - // Account ID - AccountID uint64 `json:"accountId"` + // Account IDs + AccountIDs []uint64 `json:"account_ids"` - // Created Time - CreatedTime uint64 `json:"createdTime"` + // Bus number + BusNumber int `json:"bus_number"` - // Deleted Time - DeletedTime uint64 `json:"deletedTime"` + // ComputeID + ComputeID uint64 `json:"compute_id"` - // GID + // Created time + CreatedTime uint64 `json:"created_time"` + + // Deleted time + DeletedTime uint64 `json:"deleted_time"` + + // Device Reference + DeviceReference string `json:"device_reference"` + + //Grid ID GID uint64 `json:"gid"` // GUID GUID uint64 `json:"guid"` - // ID + // VGPU ID ID uint64 `json:"id"` - // Last Claimed By - LastClaimedBy uint64 `json:"lastClaimedBy"` + // Last Update time + LastUpdateTime uint64 `json:"last_update_time"` - // Last Update Time - LastUpdateTime uint64 `json:"lastUpdateTime"` + // Mdev UUID + MdevUUID string `json:"mdev_uuid"` - // Mode - Mode string `json:"mode"` + // Parent PCI Address + ParentPCIAddress string `json:"parent_pci_address"` // PCI Slot - PCISlot uint64 `json:"pciSlot"` + PCISlot uint64 `json:"pci_slot"` - // PGPUID - PGPUID uint64 `json:"pgpuid"` + // PGPU ID + PGPUID uint64 `json:"pgpu_id"` - // Profile ID - ProfileID uint64 `json:"profileId"` + // Profile Reference + ProfileReference string `json:"profile_reference"` - // RAM - RAM uint64 `json:"ram"` - - // Reference ID - ReferenceID string `json:"referenceId"` - - // RG ID - RGID uint64 `json:"rgId"` + // Split Mode + SplitMode string `json:"split_mode"` // Status Status string `json:"status"` - - // Type - Type string `json:"type"` - - // VM ID - VMID uint64 `json:"vmid"` } type ListMigrateStorage struct { diff --git a/pkg/cloudbroker/compute/net_attach.go b/pkg/cloudbroker/compute/net_attach.go index e6f54bb..627ce73 100644 --- a/pkg/cloudbroker/compute/net_attach.go +++ b/pkg/cloudbroker/compute/net_attach.go @@ -86,6 +86,10 @@ type NetAttachRequest struct { // Required: false // Default: true EnableDefaultGateway interface{} `url:"enable_default_gateway,omitempty" json:"enable_default_gateway,omitempty" validate:"omitempty,isBool"` + + // List of QoS Policy IDs to apply to this interface (default: []), Allow used only with netType VINS, EXTNET and DPDK + // Required: false + QoSPolicies []uint64 `url:"qos_policies,omitempty" json:"qos_policies,omitempty"` } type wrapperNetAttachRequest struct { diff --git a/pkg/cloudbroker/compute/update.go b/pkg/cloudbroker/compute/update.go index 2dbc48c..8734b8b 100644 --- a/pkg/cloudbroker/compute/update.go +++ b/pkg/cloudbroker/compute/update.go @@ -78,6 +78,11 @@ type UpdateRequest struct { // Required: false // Default: null Clock string `url:"clock,omitempty" json:"clock,omitempty"` + + // Watchdog action + // Required: false + // Default: reset + WatchdogAction string `url:"watchdog_action,omitempty" json:"watchdog_action,omitempty" validate:"omitempty,watchdogAction"` } // Update updates some properties of the compute diff --git a/pkg/cloudbroker/disks/create.go b/pkg/cloudbroker/disks/create.go index d6f33de..477800d 100644 --- a/pkg/cloudbroker/disks/create.go +++ b/pkg/cloudbroker/disks/create.go @@ -47,6 +47,12 @@ type CreateRequest struct { Discard string `url:"discard,omitempty" json:"discard,omitempty"` } +type wrapperCreateRequest struct { + CreateRequest + + AsyncMode bool `url:"async_mode" json:"async_mode"` +} + // Create creates a disk func (d Disks) Create(ctx context.Context, req CreateRequest) (uint64, error) { err := validators.ValidateRequest(req) @@ -56,7 +62,12 @@ func (d Disks) Create(ctx context.Context, req CreateRequest) (uint64, error) { url := "/cloudbroker/disks/create" - res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, req) + wrappedReq := wrapperCreateRequest{ + CreateRequest: req, + AsyncMode: false, + } + + res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, wrappedReq) if err != nil { return 0, err } @@ -68,3 +79,25 @@ func (d Disks) Create(ctx context.Context, req CreateRequest) (uint64, error) { return result, nil } + +// Create creates a disk in async mode +func (d Disks) CreateAsync(ctx context.Context, req CreateRequest) (string, error) { + err := validators.ValidateRequest(req) + if err != nil { + return "", validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/disks/create" + + wrappedReq := wrapperCreateRequest{ + CreateRequest: req, + AsyncMode: true, + } + + res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, wrappedReq) + if err != nil { + return "", err + } + + return string(res), nil +} diff --git a/pkg/cloudbroker/disks/list.go b/pkg/cloudbroker/disks/list.go index e9b2093..5af38ef 100644 --- a/pkg/cloudbroker/disks/list.go +++ b/pkg/cloudbroker/disks/list.go @@ -28,7 +28,7 @@ type ListRequest struct { // Find by status // Required: false - Status string `url:"status,omitempty" json:"status,omitempty"` + Status []string `url:"status,omitempty" json:"status,omitempty"` // Find by shared, true or false // Required: false diff --git a/pkg/cloudbroker/disks/migrate.go b/pkg/cloudbroker/disks/migrate.go index b990b1c..6f300c5 100644 --- a/pkg/cloudbroker/disks/migrate.go +++ b/pkg/cloudbroker/disks/migrate.go @@ -26,16 +26,51 @@ type MigrateRequest struct { StoragePolicyID uint64 `url:"storage_policy_id" json:"storage_policy_id" validate:"required"` } -// Move moves disk to another sep, pool and storage policy +type wrapperMigrateRequest struct { + MigrateRequest + + AsyncMode bool `url:"async_mode" json:"async_mode"` +} + +// Move moves disk to another sep, pool and storage policy in sync mode func (c Disks) Migrate(ctx context.Context, req MigrateRequest) (string, error) { err := validators.ValidateRequest(req) if err != nil { return "", validators.ValidationErrors(validators.GetErrors(err)) } + wrappedReq := wrapperMigrateRequest{ + MigrateRequest: req, + AsyncMode: false, + } + url := "/cloudbroker/disks/migrate" - res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req) + res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, wrappedReq) + if err != nil { + return "", err + } + + result := string(res) + + return result, nil +} + +// Move moves disk to another sep, pool and storage policy in async mode +func (c Disks) MigrateAsync(ctx context.Context, req MigrateRequest) (string, error) { + err := validators.ValidateRequest(req) + if err != nil { + return "", validators.ValidationErrors(validators.GetErrors(err)) + } + + wrappedReq := wrapperMigrateRequest{ + MigrateRequest: req, + AsyncMode: true, + } + + url := "/cloudbroker/disks/migrate" + + res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, wrappedReq) if err != nil { return "", err } diff --git a/pkg/cloudbroker/grid/execute_maintenance_script.go b/pkg/cloudbroker/grid/execute_maintenance_script.go deleted file mode 100644 index 8f64049..0000000 --- a/pkg/cloudbroker/grid/execute_maintenance_script.go +++ /dev/null @@ -1,46 +0,0 @@ -package grid - -import ( - "context" - "net/http" - "strconv" - - "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" -) - -// ExecuteMaintenanceScriptRequest struct to execute script -type ExecuteMaintenanceScriptRequest struct { - // Grid (platform) ID - // Required: true - GID uint64 `url:"gid" json:"gid" validate:"required"` - - // Type of nodes you want to apply the action on - // Required: true - NodesType string `url:"nodestype" json:"nodestype" validate:"required"` - - // The script you want to run - // Required: true - Script string `url:"script" json:"script" validate:"required"` -} - -// ExecuteMaintenanceScript executes maintenance script -func (g Grid) ExecuteMaintenanceScript(ctx context.Context, req ExecuteMaintenanceScriptRequest) (bool, error) { - err := validators.ValidateRequest(req) - if err != nil { - return false, validators.ValidationErrors(validators.GetErrors(err)) - } - - url := "/cloudbroker/grid/executeMaintenanceScript" - - res, err := g.client.DecortApiCall(ctx, http.MethodPost, url, req) - if err != nil { - return false, err - } - - result, err := strconv.ParseBool(string(res)) - if err != nil { - return false, err - } - - return result, nil -} diff --git a/pkg/cloudbroker/grid/list_emails.go b/pkg/cloudbroker/grid/list_emails.go deleted file mode 100644 index a1f253b..0000000 --- a/pkg/cloudbroker/grid/list_emails.go +++ /dev/null @@ -1,37 +0,0 @@ -package grid - -import ( - "context" - "encoding/json" - "net/http" -) - -// ListEmailsRequest struct for getting list of email addresses of users -type ListEmailsRequest struct { - // Page number - // Required: false - Page uint64 `url:"page,omitempty" json:"page,omitempty"` - - // Page size - // Required: false - Size uint64 `url:"size,omitempty" json:"size,omitempty"` -} - -// ListEmails returns list of email addresses of users -func (g Grid) ListEmails(ctx context.Context, req ListEmailsRequest) (*ListEmails, error) { - url := "/cloudbroker/grid/listEmails" - - res, err := g.client.DecortApiCall(ctx, http.MethodPost, url, req) - if err != nil { - return nil, err - } - - list := ListEmails{} - - err = json.Unmarshal(res, &list) - if err != nil { - return nil, err - } - - return &list, nil -} diff --git a/pkg/cloudbroker/grid/models.go b/pkg/cloudbroker/grid/models.go index 727c2c0..83cd808 100644 --- a/pkg/cloudbroker/grid/models.go +++ b/pkg/cloudbroker/grid/models.go @@ -226,6 +226,12 @@ type RecordSettingsGrid struct { //Prometheus Prometheus Prometheus `json:"prometheus"` + //Reserved CPU + ReservedCPU uint64 `json:"reserved_cpu"` + + //Reserved RAM + ReservedRAM uint64 `json:"reserved_ram"` + //Vins max prereservation num VinsMaxPreReservationsNum int `json:"vinsMaxPreReservationsNum"` diff --git a/pkg/cloudbroker/grid/services_restart.go b/pkg/cloudbroker/grid/services_restart.go deleted file mode 100644 index 33175e2..0000000 --- a/pkg/cloudbroker/grid/services_restart.go +++ /dev/null @@ -1,42 +0,0 @@ -package grid - -import ( - "context" - "net/http" - "strconv" - - "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" -) - -// ServicesRestartRequest struct to restart services -type ServicesRestartRequest struct { - // Grid (platform) ID - // Required: true - GID uint64 `url:"gid" json:"gid" validate:"required"` - - // Node ID - // Required: true - NID uint64 `url:"nid" json:"nid" validate:"required"` -} - -// ServicesRestart restarts decort services on the node -func (g Grid) ServicesRestart(ctx context.Context, req ServicesRestartRequest) (bool, error) { - err := validators.ValidateRequest(req) - if err != nil { - return false, validators.ValidationErrors(validators.GetErrors(err)) - } - - url := "/cloudbroker/grid/servicesRestart" - - res, err := g.client.DecortApiCall(ctx, http.MethodPost, url, req) - if err != nil { - return false, err - } - - result, err := strconv.ParseBool(string(res)) - if err != nil { - return false, err - } - - return result, nil -} diff --git a/pkg/cloudbroker/group/get.go b/pkg/cloudbroker/group/get.go deleted file mode 100644 index 8c3c710..0000000 --- a/pkg/cloudbroker/group/get.go +++ /dev/null @@ -1,46 +0,0 @@ -package group - -import ( - "context" - "encoding/json" - "net/http" - - "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" -) - -// GetRequest struct to get details of the specified group. -type GetRequest struct { - // Group ID - // Required: true - GroupID string `url:"groupId" json:"groupId" validate:"required"` -} - -// Get gets details of the specified group as an ItemGroup struct -func (g Group) Get(ctx context.Context, req GetRequest) (*ItemGroup, error) { - res, err := g.GetRaw(ctx, req) - if err != nil { - return nil, err - } - - info := ItemGroup{} - - err = json.Unmarshal(res, &info) - if err != nil { - return nil, err - } - - return &info, nil -} - -// GetRaw gets details of the specified group as an array of bytes -func (g Group) GetRaw(ctx context.Context, req GetRequest) ([]byte, error) { - err := validators.ValidateRequest(req) - if err != nil { - return nil, validators.ValidationErrors(validators.GetErrors(err)) - } - - url := "/cloudbroker/group/get" - - res, err := g.client.DecortApiCall(ctx, http.MethodPost, url, req) - return res, err -} diff --git a/pkg/cloudbroker/image/computeci_set.go b/pkg/cloudbroker/image/computeci_set.go deleted file mode 100644 index b966b1d..0000000 --- a/pkg/cloudbroker/image/computeci_set.go +++ /dev/null @@ -1,42 +0,0 @@ -package image - -import ( - "context" - "net/http" - "strconv" - - "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" -) - -// ComputeCISetRequest struct to set compute CI -type ComputeCISetRequest struct { - // ID of the image - // Required: true - ImageID uint64 `url:"imageId" json:"imageId" validate:"required"` - - // ID of the compute CI - // Required: true - ComputeCIID uint64 `url:"computeciId" json:"computeciId" validate:"required"` -} - -// ComputeCISet sets compute CI ID for image -func (i Image) ComputeCISet(ctx context.Context, req ComputeCISetRequest) (bool, error) { - err := validators.ValidateRequest(req) - if err != nil { - return false, validators.ValidationErrors(validators.GetErrors(err)) - } - - url := "/cloudbroker/image/computeciSet" - - res, err := i.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 -} diff --git a/pkg/cloudbroker/image/computeci_unset.go b/pkg/cloudbroker/image/computeci_unset.go deleted file mode 100644 index 286ab3d..0000000 --- a/pkg/cloudbroker/image/computeci_unset.go +++ /dev/null @@ -1,38 +0,0 @@ -package image - -import ( - "context" - "net/http" - "strconv" - - "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" -) - -// ComputeCIUnsetRequest struct to unset compute CI -type ComputeCIUnsetRequest struct { - // ID of the image - // Required: true - ImageID uint64 `url:"imageId" json:"imageId" validate:"required"` -} - -// ComputeCIUnset unsets compute CI ID from image -func (i Image) ComputeCIUnset(ctx context.Context, req ComputeCIUnsetRequest) (bool, error) { - err := validators.ValidateRequest(req) - if err != nil { - return false, validators.ValidationErrors(validators.GetErrors(err)) - } - - url := "/cloudbroker/image/computeciUnset" - - res, err := i.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 -} diff --git a/pkg/cloudbroker/k8s/create.go b/pkg/cloudbroker/k8s/create.go index c812601..93303dd 100644 --- a/pkg/cloudbroker/k8s/create.go +++ b/pkg/cloudbroker/k8s/create.go @@ -159,7 +159,7 @@ type CreateRequest struct { // Meta data for working group computes, format YAML "user_data": 1111 // Required: false - UserData string `url:"userData,omitempty" json:"userData,omitempty"` + UserData interface{} `url:"userData,omitempty" json:"userData,omitempty"` // Use only selected ExtNet for infrastructure connections // Required: false diff --git a/pkg/cloudbroker/k8s/update_worker_nodes_meta_data.go b/pkg/cloudbroker/k8s/update_worker_nodes_meta_data.go index 6865a65..6944b6b 100644 --- a/pkg/cloudbroker/k8s/update_worker_nodes_meta_data.go +++ b/pkg/cloudbroker/k8s/update_worker_nodes_meta_data.go @@ -20,7 +20,7 @@ type UpdateWorkerNodesMetaDataRequest struct { // Meta data for working group computes, format YAML "user_data": 1111 // Required: true - UserData string `url:"userData" json:"userData" validate:"required"` + UserData interface{} `url:"userData" json:"userData" validate:"required"` } // UpdateWorkerNodesMetaData adds worker nodes to a kubernetes cluster diff --git a/pkg/cloudbroker/kvmx86/create.go b/pkg/cloudbroker/kvmx86/create.go index 2ff2513..a90b6ac 100644 --- a/pkg/cloudbroker/kvmx86/create.go +++ b/pkg/cloudbroker/kvmx86/create.go @@ -2,6 +2,7 @@ package kvmx86 import ( "context" + "encoding/json" "net/http" "strconv" @@ -79,6 +80,10 @@ type Interface struct { // SDN Logical Port Description // Required: false SDNLogicalPortDescription string `url:"sdn_logical_port_description,omitempty" json:"sdn_logical_port_description,omitempty"` + + // List of QoS Policy IDs to apply to this interface (default: []), Allow used only with netType VINS, EXTNET and DPDK + // Required: false + QoSPolicies []uint64 `url:"qos_policies,omitempty" json:"qos_policies,omitempty"` } // DataDisk detailed struct for DataDisks field in CreateRequest, CreateBlankRequest and MassCreateRequest @@ -120,6 +125,11 @@ type DataDisk struct { // Discard // Required: false Discard string `url:"discard,omitempty" json:"discard,omitempty"` + + // Attach disk in read-only mode + // Required: false + // Default: false + ReadOnly bool `url:"read_only,omitempty" json:"read_only,omitempty"` } // CreateRequest struct to create KVM x86 VM @@ -209,12 +219,12 @@ type CreateRequest struct { // loose (use NUMA affinity if possible) // Required: false // Default: none - NumaAffinity string `url:"numaAffinity,omitempty" json:"numaAffinity,omitempty" validate:"omitempty,numaAffinity"` + NumaAffinity string `url:"numa_affinity,omitempty" json:"numa_affinity,omitempty" validate:"omitempty,numaAffinity"` // Run VM on dedicated CPUs. To use this feature, the system must be pre-configured by allocating CPUs on the physical node // Required: false // Default: false - CPUPin bool `url:"cpupin" json:"cpupin"` + CPUPin bool `url:"cpu_pin" json:"cpu_pin"` // Type of the emulated system, Q35 or i440fx // Required: false @@ -224,7 +234,7 @@ type CreateRequest struct { // Use Huge Pages to allocate RAM of the virtual machine. The system must be pre-configured by allocating Huge Pages on the physical node // Required: false // Default: false - HPBacked bool `url:"hpBacked" json:"hpBacked"` + HPBacked bool `url:"hp_backed" json:"hp_backed"` // Recommended isolated CPUs. Field is ignored if compute.cpupin=False or compute.pinned=False // Required: false @@ -255,6 +265,11 @@ type CreateRequest struct { // Required: false // Default: default Clock string `url:"clock,omitempty" json:"clock,omitempty"` + + // Watchdog action + // Required: false + // Default: reset + WatchdogAction string `url:"watchdog_action,omitempty" json:"watchdog_action,omitempty" validate:"omitempty,watchdogAction"` } // GetRAM returns RAM field values @@ -266,6 +281,11 @@ func (r CreateRequest) GetRAM() map[string]uint64 { return res } +type wrapperCreateRequest struct { + CreateRequest + AsyncMode bool `json:"asyncMode"` +} + // Create creates KVM PowerPC VM based on specified OS image func (k KVMX86) Create(ctx context.Context, req CreateRequest) (uint64, error) { err := validators.ValidateRequest(req) @@ -275,10 +295,40 @@ func (k KVMX86) Create(ctx context.Context, req CreateRequest) (uint64, error) { url := "/cloudbroker/kvmx86/create" - res, err := k.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req) + res, err := k.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, wrapperCreateRequest{ + CreateRequest: req, + AsyncMode: false, + }) if err != nil { return 0, err } return strconv.ParseUint(string(res), 10, 64) } + +// CreateAsync creates KVM x86 VM based on specified OS image in async mode +func (k KVMX86) CreateAsync(ctx context.Context, req CreateRequest) (string, error) { + err := validators.ValidateRequest(req) + if err != nil { + return "", validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/kvmx86/create" + + res, err := k.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, wrapperCreateRequest{ + CreateRequest: req, + AsyncMode: true, + }) + if err != nil { + return "", err + } + + var taskID string + + err = json.Unmarshal(res, &taskID) + if err != nil { + return "", err + } + + return taskID, nil +} diff --git a/pkg/cloudbroker/kvmx86/create_blank.go b/pkg/cloudbroker/kvmx86/create_blank.go index 99861ef..e0f3769 100644 --- a/pkg/cloudbroker/kvmx86/create_blank.go +++ b/pkg/cloudbroker/kvmx86/create_blank.go @@ -137,6 +137,11 @@ type CreateBlankRequest struct { // Required: false // Default: default Clock string `url:"clock,omitempty" json:"clock,omitempty"` + + // Watchdog action + // Required: false + // Default: reset + WatchdogAction string `url:"watchdog_action,omitempty" json:"watchdog_action,omitempty" validate:"omitempty,watchdogAction"` } // GetRAM returns RAM field values diff --git a/pkg/cloudbroker/kvmx86/mass_create.go b/pkg/cloudbroker/kvmx86/mass_create.go index 39ea9fc..e22cae1 100644 --- a/pkg/cloudbroker/kvmx86/mass_create.go +++ b/pkg/cloudbroker/kvmx86/mass_create.go @@ -76,6 +76,10 @@ type InterfaceMassCreate struct { // SDN Logical Port Description // Required: false SDNLogicalPortDescription string `url:"sdn_logical_port_description,omitempty" json:"sdn_logical_port_description,omitempty"` + + // List of QoS Policy IDs to apply to this interface (default: []), Allow used only with netType VINS, EXTNET and DPDK + // Required: false + QoSPolicies []uint64 `url:"qos_policies,omitempty" json:"qos_policies,omitempty"` } // MassCreateRequest struct to mass create KVM x86 @@ -183,6 +187,11 @@ type MassCreateRequest struct { // Required: false // Default: default Clock string `url:"clock,omitempty" json:"clock,omitempty"` + + // Watchdog action + // Required: false + // Default: reset + WatchdogAction string `url:"watchdog_action,omitempty" json:"watchdog_action,omitempty" validate:"omitempty,watchdogAction"` } // GetRAM returns RAM field values diff --git a/pkg/cloudbroker/network_qos_policy.go b/pkg/cloudbroker/network_qos_policy.go new file mode 100644 index 0000000..d6b41de --- /dev/null +++ b/pkg/cloudbroker/network_qos_policy.go @@ -0,0 +1,10 @@ +package cloudbroker + +import ( + "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/qospolicy" +) + +// Accessing the QoS Policy method group +func (cb *CloudBroker) QoSPolicy() *qospolicy.QoSPolicy { + return qospolicy.New(cb.client) +} diff --git a/pkg/cloudbroker/node/models.go b/pkg/cloudbroker/node/models.go index 3ac495e..e96fc21 100644 --- a/pkg/cloudbroker/node/models.go +++ b/pkg/cloudbroker/node/models.go @@ -117,7 +117,7 @@ type ConsumptionInfo struct { Reserved ResourcesInfo `json:"reserved"` // Total resources - Total ResourcesInfo `json:"total"` + Total FreeResourcesInfo `json:"total"` } // Free Resources Info diff --git a/pkg/cloudbroker/qospolicy/create.go b/pkg/cloudbroker/qospolicy/create.go new file mode 100644 index 0000000..76fed9e --- /dev/null +++ b/pkg/cloudbroker/qospolicy/create.go @@ -0,0 +1,46 @@ +package qospolicy + +import ( + "context" + "net/http" + "strconv" + + "repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants" + "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" +) + +type CreateRequest struct { + // Account ID that owns QoS policy + // Required: true + AccountID uint64 `url:"account_id" json:"account_id" validate:"required"` + + // QoS policy name + // Required: true + Name string `url:"name" json:"name" validate:"required"` + + // QoS policy description + // Required: false + Description string `url:"description,omitempty" json:"description,omitempty"` +} + +// Create creates a new QoS policy +func (qp QoSPolicy) Create(ctx context.Context, req CreateRequest) (uint64, error) { + err := validators.ValidateRequest(req) + if err != nil { + return 0, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/network_qos_policy/create" + + res, err := qp.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req) + if err != nil { + return 0, err + } + + result, err := strconv.ParseUint(string(res), 10, 64) + if err != nil { + return 0, err + } + + return result, nil +} diff --git a/pkg/cloudbroker/qospolicy/create_rule.go b/pkg/cloudbroker/qospolicy/create_rule.go new file mode 100644 index 0000000..0adbe2b --- /dev/null +++ b/pkg/cloudbroker/qospolicy/create_rule.go @@ -0,0 +1,94 @@ +package qospolicy + +import ( + "context" + "net/http" + "strconv" + + "repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants" + "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" +) + +type CreateRuleRequest struct { + // ID of the parent QoS policy this rule belongs to + // Required: true + QoSPolicyID uint64 `url:"qos_policy_id" json:"qos_policy_id" validate:"required"` + + // QoS policy rule description + // Default: "" + // Required: false + Description string `url:"description,omitempty" json:"description,omitempty"` + + // Rule priority in OVS (higher number = higher priority) + // Possible values: [0, 65535] + // Required: true + Priority *uint64 `url:"priority" json:"priority" validate:"required,min=0,max=65535"` + + // Traffic direction + // Possible values: outbound + // Required: true + Direction string `url:"direction" json:"direction" validate:"required,oneof=outbound"` + + // IP protocol to match + // Possible values: tcp, udp, icmp + // Required: true + Protocol string `url:"protocol" json:"protocol" validate:"required,oneof=tcp udp icmp"` + + // Priority Code Point. L2 marking + // Possible values: [0, 7] + // Required: false + PCPTag *uint64 `url:"pcp_tag,omitempty" json:"pcp_tag,omitempty" validate:"required_without_all=DSCPValue,omitempty,min=0,max=7"` + + // DSCP value (0-63). L3 marking + // Possible values: [0, 63] + // Required: false + DSCPValue *uint64 `url:"dscp_value,omitempty" json:"dscp_value,omitempty" validate:"required_without_all=PCPTag,omitempty,min=0,max=63"` + + // Source IP address for traffic filtering + // Required: false + SrcIP string `url:"src_ip,omitempty" json:"src_ip,omitempty"` + + // Destination IP address for traffic filtering + // Required: false + DstIP string `url:"dst_ip,omitempty" json:"dst_ip,omitempty"` + + // Source MAC address for traffic filtering + // Required: false + SrcMAC string `url:"src_mac,omitempty" json:"src_mac,omitempty" validate:"omitempty,mac"` + + // Destination MAC address for traffic filtering + // Required: false + DstMAC string `url:"dst_mac,omitempty" json:"dst_mac,omitempty" validate:"omitempty,mac"` + + // Source port for traffic filtering (TCP/UDP only) + // Possible values: [1, 65535] + // Required: false + SrcPort uint64 `url:"src_port,omitempty" json:"src_port,omitempty" validate:"omitempty,min=1,max=65535"` + + // Destination port for traffic filtering (TCP/UDP only) + // Possible values: [1, 65535] + // Required: false + DstPort uint64 `url:"dst_port,omitempty" json:"dst_port,omitempty" validate:"omitempty,min=1,max=65535"` +} + +// CreateRule creates a new rule for a QoS policy +func (qp QoSPolicy) CreateRule(ctx context.Context, req CreateRuleRequest) (uint64, error) { + err := validators.ValidateRequest(req) + if err != nil { + return 0, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/network_qos_policy/create_rule" + + res, err := qp.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req) + if err != nil { + return 0, err + } + + result, err := strconv.ParseUint(string(res), 10, 64) + if err != nil { + return 0, err + } + + return result, nil +} diff --git a/pkg/cloudbroker/qospolicy/delete.go b/pkg/cloudbroker/qospolicy/delete.go new file mode 100644 index 0000000..3f60227 --- /dev/null +++ b/pkg/cloudbroker/qospolicy/delete.go @@ -0,0 +1,37 @@ +package qospolicy + +import ( + "context" + "net/http" + "strconv" + + "repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants" + "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" +) + +type DeleteRequest struct { + // QoS policy ID + // Required: true + QoSPolicyID uint64 `url:"qos_policy_id" json:"qos_policy_id" validate:"required"` +} + +func (qp QoSPolicy) Delete(ctx context.Context, req DeleteRequest) (bool, error) { + err := validators.ValidateRequest(req) + if err != nil { + return false, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/network_qos_policy/delete" + + res, err := qp.client.DecortApiCallCtype(ctx, http.MethodDelete, url, constants.MIMEJSON, req) + if err != nil { + return false, err + } + + result, err := strconv.ParseBool(string(res)) + if err != nil { + return false, err + } + + return result, nil +} diff --git a/pkg/cloudbroker/qospolicy/delete_rule.go b/pkg/cloudbroker/qospolicy/delete_rule.go new file mode 100644 index 0000000..4d3a789 --- /dev/null +++ b/pkg/cloudbroker/qospolicy/delete_rule.go @@ -0,0 +1,41 @@ +package qospolicy + +import ( + "context" + "net/http" + "strconv" + + "repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants" + "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" +) + +type DeleteRuleRequest struct { + // ID of the QoS policy + // Required: true + QoSPolicyID uint64 `url:"qos_policy_id" json:"qos_policy_id" validate:"required"` + + // ID of the rule to delete + // Required: true + RuleID uint64 `url:"rule_id" json:"rule_id" validate:"required"` +} + +func (qp QoSPolicy) DeleteRule(ctx context.Context, req DeleteRuleRequest) (bool, error) { + err := validators.ValidateRequest(req) + if err != nil { + return false, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/network_qos_policy/delete_rule" + + res, err := qp.client.DecortApiCallCtype(ctx, http.MethodDelete, url, constants.MIMEJSON, req) + if err != nil { + return false, err + } + + result, err := strconv.ParseBool(string(res)) + if err != nil { + return false, err + } + + return result, nil +} diff --git a/pkg/cloudbroker/qospolicy/filter.go b/pkg/cloudbroker/qospolicy/filter.go new file mode 100644 index 0000000..60a0cdd --- /dev/null +++ b/pkg/cloudbroker/qospolicy/filter.go @@ -0,0 +1,89 @@ +package qospolicy + +// FilterByID returns ListQoSPolicies with specified ID +func (lqp ListQoSPolicies) FilterByID(id uint64) ListQoSPolicies { + predicate := func(iqp ItemQoSPolicy) bool { + return iqp.ID == id + } + + return lqp.FilterFunc(predicate) +} + +// FilterByName returns ListQoSPolicies with specified Name +func (lqp ListQoSPolicies) FilterByName(name string) ListQoSPolicies { + predicate := func(iqp ItemQoSPolicy) bool { + return iqp.Name == name + } + + return lqp.FilterFunc(predicate) +} + +// FilterByAccountID returns ListQoSPolicies with specified AccountID +func (lqp ListQoSPolicies) FilterByAccountID(accountID uint64) ListQoSPolicies { + predicate := func(iqp ItemQoSPolicy) bool { + return iqp.AccountID == accountID + } + + return lqp.FilterFunc(predicate) +} + +// FilterByStatus returns ListQoSPolicies with specified Status +func (lqp ListQoSPolicies) FilterByStatus(status string) ListQoSPolicies { + predicate := func(iqp ItemQoSPolicy) bool { + return iqp.Status == status + } + + return lqp.FilterFunc(predicate) +} + +// FilterByDescription returns ListQoSPolicies with specified Description +func (lqp ListQoSPolicies) FilterByDescription(description string) ListQoSPolicies { + predicate := func(iqp ItemQoSPolicy) bool { + return iqp.Description == description + } + + return lqp.FilterFunc(predicate) +} + +// FilterByCreatedBy returns ListQoSPolicies with specified CreatedBy +func (lqp ListQoSPolicies) FilterByCreatedBy(createdBy string) ListQoSPolicies { + predicate := func(iqp ItemQoSPolicy) bool { + return iqp.CreatedBy == createdBy + } + + return lqp.FilterFunc(predicate) +} + +// FilterByUpdatedBy returns ListQoSPolicies with specified UpdatedBy +func (lqp ListQoSPolicies) FilterByUpdatedBy(updatedBy string) ListQoSPolicies { + predicate := func(iqp ItemQoSPolicy) bool { + return iqp.UpdatedBy == updatedBy + } + + return lqp.FilterFunc(predicate) +} + +// FilterFunc allows filtering ListQoSPolicies based on a user-specified predicate +func (lqp ListQoSPolicies) FilterFunc(predicate func(ItemQoSPolicy) bool) ListQoSPolicies { + var result ListQoSPolicies + + for _, item := range lqp.Data { + if predicate(item) { + result.Data = append(result.Data, item) + } + } + + result.EntryCount = uint64(len(result.Data)) + + return result +} + +// FindOne returns first found ItemQoSPolicy +// If none was found, returns an empty struct +func (lqp ListQoSPolicies) FindOne() ItemQoSPolicy { + if len(lqp.Data) == 0 { + return ItemQoSPolicy{} + } + + return lqp.Data[0] +} diff --git a/pkg/cloudbroker/qospolicy/filter_test.go b/pkg/cloudbroker/qospolicy/filter_test.go new file mode 100644 index 0000000..cf5ef72 --- /dev/null +++ b/pkg/cloudbroker/qospolicy/filter_test.go @@ -0,0 +1,97 @@ +package qospolicy + +import "testing" + +var qosPolicies = ListQoSPolicies{ + Data: []ItemQoSPolicy{ + { + ID: 1, + AccountID: 1, + Name: "qos1", + Description: "some desc", + Status: "ENABLED", + CreatedBy: "user", + }, + { + ID: 3, + AccountID: 3, + Name: "qos3", + Description: "some desc", + Status: "ENABLED", + CreatedBy: "anotheruser", + }, + { + ID: 5, + AccountID: 3, + Name: "qos5", + Description: "some other desc", + Status: "DISABLED", + CreatedBy: "anotheruser", + UpdatedBy: "user", + }, + }, + EntryCount: 3, +} + +func TestFilterByID(t *testing.T) { + actual := qosPolicies.FilterByID(1).FindOne() + if actual.ID != 1 { + t.Fatal("expected ID 1, found: ", actual.ID) + } +} + +func TestFilterByName(t *testing.T) { + actual := qosPolicies.FilterByName("qos3").FindOne() + if actual.Name != "qos3" { + t.Fatal("expected Name qos3, found: ", actual.Name) + } +} + +func TestFilterByDescription(t *testing.T) { + actual := qosPolicies.FilterByDescription("some desc") + + if len(actual.Data) != 2 { + t.Fatal("expected 2 found, actual: ", len(actual.Data)) + } + + for _, item := range actual.Data { + if item.Description != "some desc" { + t.Fatal("expected Description 'some desc', found: ", item.Description) + } + } +} + +func TestFilterByAccountID(t *testing.T) { + actual := qosPolicies.FilterByAccountID(1).FindOne() + if actual.AccountID != 1 { + t.Fatal("expected AccountID 1, found: ", actual.AccountID) + } +} + +func TestFilterByStatus(t *testing.T) { + actual := qosPolicies.FilterByStatus("DISABLED").FindOne() + if actual.Status != "DISABLED" { + t.Fatal("expected Status DISABLED, found: ", actual.Status) + } +} + +func TestFilterByCreatedBy(t *testing.T) { + actual := qosPolicies.FilterByCreatedBy("anotheruser") + + if len(actual.Data) != 2 { + t.Fatal("expected 2 found, actual: ", len(actual.Data)) + } + + for _, item := range actual.Data { + if item.CreatedBy != "anotheruser" { + t.Fatal("expected CreatedBy 'anotheruser', found: ", item.CreatedBy) + } + } +} + +func TestFilterByUpdatedBy(t *testing.T) { + actual := qosPolicies.FilterByUpdatedBy("user").FindOne() + if actual.UpdatedBy != "user" { + t.Fatal("expected UpdatedBy 'user', found: ", actual.UpdatedBy) + } +} diff --git a/pkg/cloudbroker/qospolicy/get.go b/pkg/cloudbroker/qospolicy/get.go new file mode 100644 index 0000000..6982b94 --- /dev/null +++ b/pkg/cloudbroker/qospolicy/get.go @@ -0,0 +1,43 @@ +package qospolicy + +import ( + "context" + "encoding/json" + "net/http" + + "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" +) + +type GetRequest struct { + // QoS policy ID + // Required: true + QoSPolicyID uint64 `url:"qos_policy_id" json:"qos_policy_id" validate:"required"` +} + +func (qp QoSPolicy) Get(ctx context.Context, req GetRequest) (*RecordQoSPolicy, error) { + res, err := qp.GetRaw(ctx, req) + if err != nil { + return nil, err + } + + info := RecordQoSPolicy{} + + err = json.Unmarshal(res, &info) + if err != nil { + return nil, err + } + + return &info, nil +} + +func (qp QoSPolicy) GetRaw(ctx context.Context, req GetRequest) ([]byte, error) { + err := validators.ValidateRequest(req) + if err != nil { + return nil, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/network_qos_policy/get" + + res, err := qp.client.DecortApiCall(ctx, http.MethodGet, url, req) + return res, err +} diff --git a/pkg/cloudbroker/qospolicy/list.go b/pkg/cloudbroker/qospolicy/list.go new file mode 100644 index 0000000..9126cae --- /dev/null +++ b/pkg/cloudbroker/qospolicy/list.go @@ -0,0 +1,88 @@ +package qospolicy + +import ( + "context" + "encoding/json" + "net/http" + + "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" +) + +type ListRequest struct { + // Page number + // Required: false + Page uint64 `url:"page,omitempty" json:"page,omitempty"` + + // Page size + // Required: false + Size uint64 `url:"size,omitempty" json:"size,omitempty"` + + // Find QoS policy by id + // Required: false + ByID uint64 `url:"by_id,omitempty" json:"by_id,omitempty"` + + // Find by account id + // Required: false + AccountID uint64 `url:"account_id,omitempty" json:"account_id,omitempty"` + + // Find by QoS policy name + // Required: false + Name string `url:"name,omitempty" json:"name,omitempty"` + + // Find by QoS policy description + // Required: false + Description string `url:"description,omitempty" json:"description,omitempty"` + + // Find by QoS policy status + // Required: false + Status string `url:"status,omitempty" json:"status,omitempty"` + + // Find by created after time (unix timestamp) + // Required: false + CreatedMin uint64 `url:"created_min,omitempty" json:"created_min,omitempty"` + + // Find by created before time (unix timestamp) + // Required: false + CreatedMax uint64 `url:"created_max,omitempty" json:"created_max,omitempty"` + + // Find by updated after time (unix timestamp) + // Required: false + UpdatedMin uint64 `url:"updated_min,omitempty" json:"updated_min,omitempty"` + + // Find by updated before time (unix timestamp) + // Required: false + UpdatedMax uint64 `url:"updated_max,omitempty" json:"updated_max,omitempty"` + + // Sort by one of supported fields, format ± + // Required: false + SortBy string `url:"sort_by,omitempty" json:"sort_by,omitempty"` +} + +// List gets list of QoS policies as a ListQoSPolicies struct +func (qp QoSPolicy) List(ctx context.Context, req ListRequest) (*ListQoSPolicies, error) { + res, err := qp.ListRaw(ctx, req) + if err != nil { + return nil, err + } + + list := ListQoSPolicies{} + + err = json.Unmarshal(res, &list) + if err != nil { + return nil, err + } + + return &list, nil +} + +// ListRaw gets list of QoS policies as an array of bytes +func (qp QoSPolicy) ListRaw(ctx context.Context, req ListRequest) ([]byte, error) { + if err := validators.ValidateRequest(req); err != nil { + return nil, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/network_qos_policy/list" + + res, err := qp.client.DecortApiCall(ctx, http.MethodGet, url, req) + return res, err +} diff --git a/pkg/cloudbroker/qospolicy/models.go b/pkg/cloudbroker/qospolicy/models.go new file mode 100644 index 0000000..fc17c8f --- /dev/null +++ b/pkg/cloudbroker/qospolicy/models.go @@ -0,0 +1,122 @@ +package qospolicy + +type ListQoSPolicies struct { + // List + Data []ItemQoSPolicy `json:"data"` + + // Entry count + EntryCount uint64 `json:"entryCount"` +} + +type ItemQoSPolicy struct { + // ID of the QoS policy + ID uint64 `json:"id"` + + // GUID + GUID uint64 `json:"guid"` + + // Account ID that owns the QoS policy + AccountID uint64 `json:"account_id"` + + // Name of the QoS policy + Name string `json:"name"` + + // Description of the QoS policy + Description string `json:"description"` + + // Status of the QoS policy + Status string `json:"status"` + + // Created at (unix timestamp) + CreatedAt uint64 `json:"created_at"` + + // Updated at (unix timestamp) + UpdatedAt uint64 `json:"updated_at"` + + // Created by + CreatedBy string `json:"created_by"` + + // Updated by + UpdatedBy string `json:"updated_by"` + + // List of rules + Rules Rules `json:"rules"` +} + +type RecordQoSPolicy struct { + // ID of the QoS policy + ID uint64 `json:"id"` + + // GUID + GUID uint64 `json:"guid"` + + // Account ID that owns the QoS policy + AccountID uint64 `json:"account_id"` + + // Name of the QoS policy + Name string `json:"name"` + + // Description of the QoS policy + Description string `json:"description"` + + // Status of the QoS policy + Status string `json:"status"` + + // Created at (unix timestamp) + CreatedAt uint64 `json:"created_at"` + + // Updated at (unix timestamp) + UpdatedAt uint64 `json:"updated_at"` + + // Created by + CreatedBy string `json:"created_by"` + + // Updated by + UpdatedBy string `json:"updated_by"` + + // List of rules + Rules Rules `json:"rules"` +} + +type Rules []Rule + +type Rule struct { + // ID of the rule + ID uint64 `json:"id"` + + // Description of the rule + Description string `json:"description"` + + // Rule priority in OVS (higher number = higher priority) + Priority uint64 `json:"priority"` + + // Traffic direction + Direction string `json:"direction"` + + // IP protocol + Protocol string `json:"protocol"` + + // Priority Code Point (0-7). L2 marking + PCPTag uint64 `json:"pcp_tag"` + + // DSCP value (0-63). L3 marking + DSCPValue uint64 `json:"dscp_value"` + + // Source IP address + SrcIP string `json:"src_ip"` + + // Destination IP address + DstIP string `json:"dst_ip"` + + // Source MAC address + SrcMAC string `json:"src_mac"` + + // Destination MAC address + DstMAC string `json:"dst_mac"` + + // Source port + SrcPort uint64 `json:"src_port"` + + // Destination port + DstPort uint64 `json:"dst_port"` +} diff --git a/pkg/cloudbroker/qospolicy/qos_policy.go b/pkg/cloudbroker/qospolicy/qos_policy.go new file mode 100644 index 0000000..f93580e --- /dev/null +++ b/pkg/cloudbroker/qospolicy/qos_policy.go @@ -0,0 +1,15 @@ +package qospolicy + +import "repository.basistech.ru/BASIS/decort-golang-sdk/interfaces" + +// Structure for creating request to QoS policy +type QoSPolicy struct { + client interfaces.Caller +} + +// Builder for QoS policy endpoint +func New(client interfaces.Caller) *QoSPolicy { + return &QoSPolicy{ + client: client, + } +} diff --git a/pkg/cloudbroker/qospolicy/sorting.go b/pkg/cloudbroker/qospolicy/sorting.go new file mode 100644 index 0000000..5109dea --- /dev/null +++ b/pkg/cloudbroker/qospolicy/sorting.go @@ -0,0 +1,39 @@ +package qospolicy + +import "sort" + +// SortByCreatedAt sorts ListQoSPolicies by the CreatedAt field in ascending order +// If inverse param is set to true, the order is reversed +func (lqp ListQoSPolicies) SortByCreatedAt(inverse bool) ListQoSPolicies { + if len(lqp.Data) < 2 { + return lqp + } + + sort.Slice(lqp.Data, func(i, j int) bool { + if inverse { + return lqp.Data[i].CreatedAt > lqp.Data[j].CreatedAt + } + + return lqp.Data[i].CreatedAt < lqp.Data[j].CreatedAt + }) + + return lqp +} + +// SortByUpdatedAt sorts ListQoSPolicies by the UpdatedAt field in ascending order +// If inverse param is set to true, the order is reversed +func (lqp ListQoSPolicies) SortByUpdatedAt(inverse bool) ListQoSPolicies { + if len(lqp.Data) < 2 { + return lqp + } + + sort.Slice(lqp.Data, func(i, j int) bool { + if inverse { + return lqp.Data[i].UpdatedAt > lqp.Data[j].UpdatedAt + } + + return lqp.Data[i].UpdatedAt < lqp.Data[j].UpdatedAt + }) + + return lqp +} diff --git a/pkg/cloudbroker/qospolicy/update.go b/pkg/cloudbroker/qospolicy/update.go new file mode 100644 index 0000000..48a6820 --- /dev/null +++ b/pkg/cloudbroker/qospolicy/update.go @@ -0,0 +1,52 @@ +package qospolicy + +import ( + "context" + "encoding/json" + "net/http" + + "repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants" + "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" +) + +type UpdateRequest struct { + // QoS policy ID + // Required: true + QoSPolicyID uint64 `url:"qos_policy_id" json:"qos_policy_id" validate:"required"` + + // New QoS policy name + // Required: false + Name string `url:"name,omitempty" json:"name,omitempty"` + + // New QoS policy description + // Required: false + Description string `url:"description,omitempty" json:"description,omitempty"` +} + +func (qp QoSPolicy) Update(ctx context.Context, req UpdateRequest) (*RecordQoSPolicy, error) { + res, err := qp.UpdateRaw(ctx, req) + if err != nil { + return nil, err + } + + info := RecordQoSPolicy{} + + err = json.Unmarshal(res, &info) + if err != nil { + return nil, err + } + + return &info, nil +} + +func (qp QoSPolicy) UpdateRaw(ctx context.Context, req UpdateRequest) ([]byte, error) { + err := validators.ValidateRequest(req) + if err != nil { + return nil, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/network_qos_policy/update" + + res, err := qp.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req) + return res, err +} diff --git a/pkg/cloudbroker/resmon/models.go b/pkg/cloudbroker/resmon/models.go index d6de1a5..ae4f506 100644 --- a/pkg/cloudbroker/resmon/models.go +++ b/pkg/cloudbroker/resmon/models.go @@ -63,11 +63,12 @@ type ItemStorage struct { type GetByNodeData []GetByNodePoint type GetByNodePoint struct { - Usage NodeUsage `json:"usage"` - CPUInfo CPUinfoByNode `json:"cpuInfo"` - Name string `json:"name"` - ID uint64 `json:"id"` - UID string `json:"uid"` + Usage NodeUsage `json:"usage"` + CPUInfo CPUinfoByNode `json:"cpuInfo"` + Name string `json:"name"` + ID uint64 `json:"id"` + UID string `json:"uid"` + TotalVCPUs uint64 `json:"total_vcpus"` } type NodeUsage struct { diff --git a/pkg/cloudbroker/rg/audits.go b/pkg/cloudbroker/rg/audits.go deleted file mode 100644 index 20403cd..0000000 --- a/pkg/cloudbroker/rg/audits.go +++ /dev/null @@ -1,40 +0,0 @@ -package rg - -import ( - "context" - "encoding/json" - "net/http" - - "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" -) - -// AuditsRequest struct to get audit -type AuditsRequest struct { - // Resource group ID - // Required: true - RGID uint64 `url:"rgId" json:"rgId" validate:"required"` -} - -// Audits gets audit records for the specified resource group object -func (r RG) Audits(ctx context.Context, req AuditsRequest) (ListAudits, error) { - err := validators.ValidateRequest(req) - if err != nil { - return nil, validators.ValidationErrors(validators.GetErrors(err)) - } - - url := "/cloudbroker/rg/audits" - - res, err := r.client.DecortApiCall(ctx, http.MethodPost, url, req) - if err != nil { - return nil, err - } - - list := ListAudits{} - - err = json.Unmarshal(res, &list) - if err != nil { - return nil, err - } - - return list, nil -} diff --git a/pkg/cloudbroker/rg/create.go b/pkg/cloudbroker/rg/create.go index 6485c26..a4d9908 100644 --- a/pkg/cloudbroker/rg/create.go +++ b/pkg/cloudbroker/rg/create.go @@ -61,6 +61,10 @@ type CreateRequest struct { // Required: false Description string `url:"desc,omitempty" json:"desc,omitempty"` + // Private network IP CIDR if default network PRIVATE + // Required: false + IPCIDR string `url:"ipcidr,omitempty" json:"ipcidr,omitempty"` + // External network ID // Required: false ExtNetID uint64 `url:"extNetId,omitempty" json:"extNetId,omitempty"` diff --git a/pkg/cloudbroker/sep/access_grant.go b/pkg/cloudbroker/sep/access_grant.go deleted file mode 100644 index 7968da6..0000000 --- a/pkg/cloudbroker/sep/access_grant.go +++ /dev/null @@ -1,43 +0,0 @@ -package sep - -import ( - "context" - "net/http" - "strconv" - - "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" -) - -// AccessGrantRequest struct to grant access to SEP -type AccessGrantRequest struct { - // Storage endpoint provider ID - // Required: true - SEPID uint64 `url:"sep_id" json:"sep_id" validate:"required"` - - // Account ID to grant access to the specified SEP. If 0, - // the SEP will be available for all accounts with no exceptions - // Required: true - AccountID uint64 `url:"account_id" json:"account_id" validate:"required"` -} - -// AccessGrant grants access to SEP -func (s SEP) AccessGrant(ctx context.Context, req AccessGrantRequest) (bool, error) { - err := validators.ValidateRequest(req) - if err != nil { - return false, validators.ValidationErrors(validators.GetErrors(err)) - } - - url := "/cloudbroker/sep/accessGrant" - - res, err := s.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 -} diff --git a/pkg/cloudbroker/sep/access_grant_to_pool.go b/pkg/cloudbroker/sep/access_grant_to_pool.go deleted file mode 100644 index c5a9cf9..0000000 --- a/pkg/cloudbroker/sep/access_grant_to_pool.go +++ /dev/null @@ -1,50 +0,0 @@ -package sep - -import ( - "context" - "net/http" - "strconv" - - "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" -) - -// AccessGrantToPoolRequest struct to grant access to pool SEP -type AccessGrantToPoolRequest struct { - // Storage endpoint provider ID - // Required: true - SEPID uint64 `url:"sep_id" json:"sep_id" validate:"required"` - - // Pool name - // Required: true - PoolName string `url:"pool_name" json:"pool_name" validate:"required"` - - // Account ID to grant access to the specified pool SEP - // Required: false - AccountID uint64 `url:"account_id,omitempty" json:"account_id,omitempty"` - - // Resource group to grant access to the specified pool SEP - // Required: false - RGID uint64 `url:"resgroup_id,omitempty" json:"resgroup_id,omitempty"` -} - -// AccessGrantToPool grants access to pool SEP -func (s SEP) AccessGrantToPool(ctx context.Context, req AccessGrantToPoolRequest) (bool, error) { - err := validators.ValidateRequest(req) - if err != nil { - return false, validators.ValidationErrors(validators.GetErrors(err)) - } - - url := "/cloudbroker/sep/accessGrantToPool" - - res, err := s.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 -} diff --git a/pkg/cloudbroker/sep/access_revoke.go b/pkg/cloudbroker/sep/access_revoke.go deleted file mode 100644 index 8ccff2f..0000000 --- a/pkg/cloudbroker/sep/access_revoke.go +++ /dev/null @@ -1,42 +0,0 @@ -package sep - -import ( - "context" - "net/http" - "strconv" - - "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" -) - -// AccessRevokeRequest struct to revoke access to SEP -type AccessRevokeRequest struct { - // Storage endpoint provider ID - // Required: true - SEPID uint64 `url:"sep_id" json:"sep_id" validate:"required"` - - // Account ID to revoke access to the specified SEP - // Required: true - AccountID uint64 `url:"account_id" json:"account_id" validate:"required"` -} - -// AccessRevoke revokes access to SEP -func (s SEP) AccessRevoke(ctx context.Context, req AccessRevokeRequest) (bool, error) { - err := validators.ValidateRequest(req) - if err != nil { - return false, validators.ValidationErrors(validators.GetErrors(err)) - } - - url := "/cloudbroker/sep/accessRevoke" - - res, err := s.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 -} diff --git a/pkg/cloudbroker/sep/access_revoke_to_pool.go b/pkg/cloudbroker/sep/access_revoke_to_pool.go deleted file mode 100644 index ea5f850..0000000 --- a/pkg/cloudbroker/sep/access_revoke_to_pool.go +++ /dev/null @@ -1,50 +0,0 @@ -package sep - -import ( - "context" - "net/http" - "strconv" - - "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" -) - -// AccessRevokeToPoolRequest struct to revoke access to pool SEP -type AccessRevokeToPoolRequest struct { - // Storage endpoint provider ID - // Required: true - SEPID uint64 `url:"sep_id" json:"sep_id" validate:"required"` - - // Pool name - // Required: true - PoolName string `url:"pool_name" json:"pool_name" validate:"required"` - - // Account ID to grant access to the specified pool SEP - // Required: false - AccountID uint64 `url:"account_id,omitempty" json:"account_id,omitempty"` - - // Resource group ID to grant access to the specified pool SEP - // Required: false - RGID uint64 `url:"resgroup_id,omitempty" json:"resgroup_id,omitempty"` -} - -// AccessRevokeToPool revokes access to pool SEP -func (s SEP) AccessRevokeToPool(ctx context.Context, req AccessRevokeToPoolRequest) (bool, error) { - err := validators.ValidateRequest(req) - if err != nil { - return false, validators.ValidationErrors(validators.GetErrors(err)) - } - - url := "/cloudbroker/sep/accessRevokeToPool" - - res, err := s.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 -} diff --git a/pkg/cloudbroker/tasks/list.go b/pkg/cloudbroker/tasks/list.go index d6b549a..4028a8e 100644 --- a/pkg/cloudbroker/tasks/list.go +++ b/pkg/cloudbroker/tasks/list.go @@ -38,6 +38,14 @@ type ListRequest struct { // Required: false UpdateTimeTo uint64 `url:"updateTimeTo,omitempty" json:"updateTimeTo,omitempty"` + // Find all tasks created after point in time (unixtime) + // Required: false + CreatedTimeAt uint64 `url:"createdTimeAt,omitempty" json:"createdTimeAt,omitempty"` + + // Find all tasks created after before in time (unixtime) + // Required: false + CreatedTimeTo uint64 `url:"createdTimeTo,omitempty" json:"createdTimeTo,omitempty"` + // Page number // Default: 0 // Default: 0 diff --git a/pkg/cloudbroker/tasks/models.go b/pkg/cloudbroker/tasks/models.go index 43b7c17..94696f9 100644 --- a/pkg/cloudbroker/tasks/models.go +++ b/pkg/cloudbroker/tasks/models.go @@ -48,6 +48,9 @@ type ItemTask struct { // Updated time UpdatedTime uint64 `json:"updatedTime"` + + // Time of creation + CreatedTime uint64 `json:"createdTime"` } // List of tasks diff --git a/pkg/cloudbroker/user/get_audit.go b/pkg/cloudbroker/user/get_audit.go deleted file mode 100644 index b7c6b2b..0000000 --- a/pkg/cloudbroker/user/get_audit.go +++ /dev/null @@ -1,62 +0,0 @@ -package user - -import ( - "context" - "encoding/json" - "net/http" -) - -// GetAuditRequest struct for getting user's audits. -type GetAuditRequest struct { - // Name of user (get audits for current user if set to empty). - // Required: false - Username string `url:"username,omitempty" json:"username,omitempty"` - - // Find by api call. - // Required: false - Call string `url:"call,omitempty" json:"call,omitempty"` - - // Find by HTTP status code - // Required: false - StatusCode uint64 `url:"statuscode,omitempty" json:"statuscode,omitempty"` - - // Find all audits after point in time (unixtime) - // Required: false - TimestampAt uint64 `url:"timestampAt,omitempty" json:"timestampAt,omitempty"` - - // Find all audits before point in time (unixtime) - // Required: false - TimestampTo uint64 `url:"timestampTo,omitempty" json:"timestampTo,omitempty"` - - // Sort by a field, format +|-(field) - // Default: -timestamp - // 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, maximum - 100. - // Required: false - Size uint64 `url:"size,omitempty" json:"size,omitempty"` -} - -// GetAudit gets user's audits. -func (u User) GetAudit(ctx context.Context, req GetAuditRequest) (ListAudits, error) { - url := "/cloudbroker/user/getAudit" - - res, err := u.client.DecortApiCall(ctx, http.MethodPost, url, req) - if err != nil { - return ListAudits{}, err - } - - list := ListAudits{} - - err = json.Unmarshal(res, &list) - if err != nil { - return ListAudits{}, err - } - - return list, nil -} diff --git a/pkg/cloudbroker/vgpu/allocate.go b/pkg/cloudbroker/vgpu/allocate.go deleted file mode 100644 index 2893aa2..0000000 --- a/pkg/cloudbroker/vgpu/allocate.go +++ /dev/null @@ -1,37 +0,0 @@ -package vgpu - -import ( - "context" - "net/http" - "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" - "strconv" -) - -// AllocateRequest struct for allocating VGPU -type AllocateRequest struct { - // Virtual GPU ID - // Required: true - VGPUID uint64 `url:"vgpuId" json:"vgpuId" validate:"required"` -} - -// Allocate allocates GPU -func (v VGPU) Allocate(ctx context.Context, req AllocateRequest) (bool, error) { - err := validators.ValidateRequest(req) - if err != nil { - return false, validators.ValidationErrors(validators.GetErrors(err)) - } - - url := "/cloudbroker/vgpu/allocate" - - res, err := v.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 -} diff --git a/pkg/cloudbroker/vgpu/create.go b/pkg/cloudbroker/vgpu/create.go index 90f6384..b0b8967 100644 --- a/pkg/cloudbroker/vgpu/create.go +++ b/pkg/cloudbroker/vgpu/create.go @@ -3,27 +3,32 @@ package vgpu import ( "context" "net/http" - "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" "strconv" + + "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" ) // CreateRequest struct for creating VGPU type CreateRequest struct { // ID of pGPU // Required: true - PGPUID uint64 `url:"pgpuId" json:"pgpuId" validate:"required"` - - // ID of the target resource group. - // Required: true - RGID uint64 `url:"rgId" json:"rgId" validate:"required"` + PGPUID uint64 `url:"pgpu_id" json:"pgpu_id" validate:"required"` // Virtual profile id // Required: false - ProfileID uint64 `url:"profileId,omitempty" json:"profileId,omitempty"` + ProfileID string `url:"profile_id,omitempty" json:"profile_id,omitempty"` - // Allocate vgpu after creation + // MDEV Type // Required: false - Allocate bool `url:"allocate,omitempty" json:"allocate,omitempty"` + MDEVType string `url:"mdev_type,omitempty" json:"mdev_type,omitempty"` + + // PCI Address + // Required: false + PCIAddress string `url:"pci_address,omitempty" json:"pci_address,omitempty"` + + // Account IDs + // Required: false + AccountIDs []uint64 `url:"account_ids,omitempty" json:"account_ids,omitempty"` } // Create creates VGPU diff --git a/pkg/cloudbroker/vgpu/deallocate.go b/pkg/cloudbroker/vgpu/deallocate.go deleted file mode 100644 index 81b67cf..0000000 --- a/pkg/cloudbroker/vgpu/deallocate.go +++ /dev/null @@ -1,41 +0,0 @@ -package vgpu - -import ( - "context" - "net/http" - "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" - "strconv" -) - -// DeallocateRequest struct for deallocating VGPU -type DeallocateRequest struct { - // Virtual GPU ID - // Required: true - VGPUID uint64 `url:"vgpuId" json:"vgpuId" validate:"required"` - - // Force delete (detach from compute) - // Required: false - Force bool `url:"force,omitempty" json:"force,omitempty"` -} - -// Deallocate releases GPU resources -func (v VGPU) Deallocate(ctx context.Context, req DeallocateRequest) (bool, error) { - err := validators.ValidateRequest(req) - if err != nil { - return false, validators.ValidationErrors(validators.GetErrors(err)) - } - - url := "/cloudbroker/vgpu/deallocate" - - res, err := v.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 -} diff --git a/pkg/cloudbroker/vgpu/destroy.go b/pkg/cloudbroker/vgpu/destroy.go index ab03c95..8564538 100644 --- a/pkg/cloudbroker/vgpu/destroy.go +++ b/pkg/cloudbroker/vgpu/destroy.go @@ -3,19 +3,16 @@ package vgpu import ( "context" "net/http" - "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" "strconv" + + "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" ) // DestroyRequest struct for destroying VGPU type DestroyRequest struct { // Virtual GPU ID // Required: true - VGPUID uint64 `url:"vgpuId" json:"vgpuId" validate:"required"` - - // Force delete (deallocate and detach from compute) - // Required: false - Force bool `url:"force,omitempty" json:"force,omitempty"` + VGPUID uint64 `url:"vgpu_id" json:"vgpu_id" validate:"required"` } // Destroy destroys VGPU diff --git a/pkg/cloudbroker/vgpu/list.go b/pkg/cloudbroker/vgpu/list.go index b051641..fbccd47 100644 --- a/pkg/cloudbroker/vgpu/list.go +++ b/pkg/cloudbroker/vgpu/list.go @@ -18,37 +18,29 @@ type ListRequest struct { // Required: false Status string `url:"status,omitempty" json:"status,omitempty"` - // Find by vgpu type + // Find by mode // Required: false - Type string `url:"type,omitempty" json:"type,omitempty"` - - // Find by vgpu mode - // Required: false - Mode string `url:"mode,omitempty" json:"mode,omitempty"` - - // Find by id resgroup - // Required: false - RGID uint64 `url:"rgId,omitempty" json:"rgId,omitempty"` + SplitMode string `url:"split_mode,omitempty" json:"split_mode,omitempty"` // Find by id node // Required: false - NID uint64 `url:"nid,omitempty" json:"nid,omitempty"` + NodeID uint64 `url:"node_id,omitempty" json:"node_id,omitempty"` // Find by account id // Required: false - AccountID uint64 `url:"accountId,omitempty" json:"accountId,omitempty"` + AccountID uint64 `url:"account_id,omitempty" json:"account_id,omitempty"` // Find by compute id // Required: false - ComputeID uint64 `url:"computeId,omitempty" json:"computeId,omitempty"` + ComputeID uint64 `url:"compute_id,omitempty" json:"compute_id,omitempty"` // Find by pgpu id // Required: false - PGPUID uint64 `url:"pgpuId,omitempty" json:"pgpuId,omitempty"` + PGPUID uint64 `url:"pgpu_id,omitempty" json:"pgpu_id,omitempty"` // Sort by one of supported fields, format +|-(field) // Required: false - SortBy string `url:"sortBy,omitempty" json:"sortBy,omitempty" validate:"omitempty,sortBy"` + SortBy string `url:"sort_by,omitempty" json:"sort_by,omitempty" validate:"omitempty,sortBy"` // Page number // Required: false @@ -87,6 +79,6 @@ func (v VGPU) ListRaw(ctx context.Context, req ListRequest) ([]byte, error) { url := "/cloudbroker/vgpu/list" - res, err := v.client.DecortApiCall(ctx, http.MethodPost, url, req) + res, err := v.client.DecortApiCall(ctx, http.MethodGet, url, req) return res, err } diff --git a/pkg/cloudbroker/vgpu/models.go b/pkg/cloudbroker/vgpu/models.go index c7fa695..27ab6b1 100644 --- a/pkg/cloudbroker/vgpu/models.go +++ b/pkg/cloudbroker/vgpu/models.go @@ -7,14 +7,23 @@ type ItemVGPU struct { // Meta Meta []interface{} `json:"_meta"` - // Account ID - AccountID uint64 `json:"accountId"` + // Account IDs + AccountIDs []uint64 `json:"account_ids"` + + // Bus number + BusNumber int `json:"bus_number"` + + // ComputeID + ComputeID uint64 `json:"compute_id"` // Created time - CreatedTime uint64 `json:"createdTime"` + CreatedTime uint64 `json:"created_time"` // Deleted time - DeletedTime uint64 `json:"deletedTime"` + DeletedTime uint64 `json:"deleted_time"` + + // Device Reference + DeviceReference string `json:"device_reference"` //Grid ID GID uint64 `json:"gid"` @@ -25,41 +34,29 @@ type ItemVGPU struct { // VGPU ID ID uint64 `json:"id"` - // Last claimed by - LastClaimedBy uint64 `json:"lastClaimedBy"` + // Last Update time + LastUpdateTime uint64 `json:"last_update_time"` - // Last update time - LastUpdateTime uint64 `json:"lastUpdateTime"` + // Mdev UUID + MdevUUID string `json:"mdev_uuid"` - // Mode - Mode string `json:"mode"` + // Parent PCI Address + ParentPCIAddress string `json:"parent_pci_address"` // PCI Slot - PCISlot interface{} `json:"pciSlot"` + PCISlot uint64 `json:"pci_slot"` - // PGPUID - PGPUID uint64 `json:"pgpuid"` + // PGPU ID + PGPUID uint64 `json:"pgpu_id"` - // Profile ID - ProfileID interface{} `json:"profileId"` + // Profile Reference + ProfileReference string `json:"profile_reference"` - // RAM - RAM uint64 `json:"ram"` - - // Reference ID - ReferenceID interface{} `json:"referenceId"` - - // RGID - RGID uint64 `json:"rgId"` + // Split Mode + SplitMode string `json:"split_mode"` // Status Status string `json:"status"` - - // Type - Type string `json:"type"` - - // VMID - VMID uint64 `json:"vmid"` } // List of VGPU diff --git a/pkg/cloudbroker/vins/audits.go b/pkg/cloudbroker/vins/audits.go deleted file mode 100644 index af345e7..0000000 --- a/pkg/cloudbroker/vins/audits.go +++ /dev/null @@ -1,40 +0,0 @@ -package vins - -import ( - "context" - "encoding/json" - "net/http" - - "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" -) - -// AuditsRequest struct to get audits -type AuditsRequest struct { - // ID of the VINS - // Required: true - VINSID uint64 `url:"vinsId" json:"vinsId" validate:"required"` -} - -// Audits gets audit records for the specified VINS object -func (v VINS) Audits(ctx context.Context, req AuditsRequest) (ListAudits, error) { - err := validators.ValidateRequest(req) - if err != nil { - return nil, validators.ValidationErrors(validators.GetErrors(err)) - } - - url := "/cloudbroker/vins/audits" - - res, err := v.client.DecortApiCall(ctx, http.MethodPost, url, req) - if err != nil { - return nil, err - } - - list := ListAudits{} - - err = json.Unmarshal(res, &list) - if err != nil { - return nil, err - } - - return list, nil -} diff --git a/pkg/cloudbroker/zone/models.go b/pkg/cloudbroker/zone/models.go index 61e83a0..b3e6d99 100644 --- a/pkg/cloudbroker/zone/models.go +++ b/pkg/cloudbroker/zone/models.go @@ -183,6 +183,15 @@ type RecordZone struct { // Reserved RAM ReservedRAM uint64 `json:"reserved_ram"` + + // Storage Distributed Resource Scheduler + SDRS bool `json:"sdrs"` + + // Mode of SDRS + SDRSMode string `json:"sdrs_mode"` + + // Minimal level of logs + LoggingLevel string `json:"logging_level"` } // A zone item from a list @@ -261,4 +270,13 @@ type ItemZone struct { // Reserved RAM ReservedRAM uint64 `json:"reserved_ram"` + + // Storage Distributed Resource Scheduler + SDRS bool `json:"sdrs"` + + // Mode of SDRS + SDRSMode string `json:"sdrs_mode"` + + // Minimal level of logs + LoggingLevel string `json:"logging_level"` } diff --git a/tests/platform_upgrade/cloud_test.go b/tests/platform_upgrade/cloud_test.go index d640233..6dbf7b1 100644 --- a/tests/platform_upgrade/cloud_test.go +++ b/tests/platform_upgrade/cloud_test.go @@ -16,6 +16,7 @@ import ( "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/k8s" "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/lb" "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/locations" + "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/qospolicy" "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/rg" "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/secgroup" "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/sep" @@ -49,6 +50,7 @@ import ( lb_cb "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/lb" node_cb "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/node" pcidevice_cb "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/pcidevice" + qospolicy_cb "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/qospolicy" rg_cb "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/rg" secgroup_cb "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/secgroup" sep_cb "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/sep" @@ -288,6 +290,26 @@ func TestGetListCloudAPI(t *testing.T) { } getResult("Locations list", bytes, locations.ListLocations{}, t) + // QoS policy + // List + bytes, err = client.CloudAPI().QoSPolicy().ListRaw(context.Background(), qospolicy.ListRequest{}) + if err != nil { + t.Error(err) + } + getResult("QoS policy list", bytes, qospolicy.ListQoSPolicies{}, t) + // Get + listQosPolicies, _ := client.CloudAPI().QoSPolicy().List(context.Background(), qospolicy.ListRequest{}) + if len(listQosPolicies.Data) > 0 { + id := listQosPolicies.Data[0].ID + bytes, err = client.CloudAPI().QoSPolicy().GetRaw(context.Background(), qospolicy.GetRequest{QoSPolicyID: id}) + if err != nil { + t.Error(err) + } + getResult("QoS policy get", bytes, qospolicy.RecordQoSPolicy{}, t) + } else { + t.Errorf("Can not test QoS policy get because QoS policy list is empty") + } + // RG // List bytes, err = client.CloudAPI().RG().ListRaw(context.Background(), rg.ListRequest{}) @@ -748,6 +770,26 @@ func TestGetListCloudbroker(t *testing.T) { } getResult("Pcidevice list", bytes, pcidevice_cb.ListPCIDevices{}, t) + // QoS policy + // List + bytes, err = client.CloudBroker().QoSPolicy().ListRaw(context.Background(), qospolicy_cb.ListRequest{}) + if err != nil { + t.Error(err) + } + getResult("QoS policy list", bytes, qospolicy_cb.ListQoSPolicies{}, t) + // Get + listQosPolicies, _ := client.CloudBroker().QoSPolicy().List(context.Background(), qospolicy_cb.ListRequest{}) + if len(listQosPolicies.Data) > 0 { + id := listQosPolicies.Data[0].ID + bytes, err = client.CloudBroker().QoSPolicy().GetRaw(context.Background(), qospolicy_cb.GetRequest{QoSPolicyID: id}) + if err != nil { + t.Error(err) + } + getResult("QoS policy get", bytes, qospolicy_cb.RecordQoSPolicy{}, t) + } else { + t.Errorf("Can not test QoS policy get because QoS policy list is empty") + } + // RG // List bytes, err = client.CloudBroker().RG().ListRaw(context.Background(), rg_cb.ListRequest{}) diff --git a/tests/platform_upgrade/request_map.go b/tests/platform_upgrade/request_map.go index f976b18..4a7eea1 100644 --- a/tests/platform_upgrade/request_map.go +++ b/tests/platform_upgrade/request_map.go @@ -17,6 +17,7 @@ import ( "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/locations" "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/pcidevice" "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/prometheus" + "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/qospolicy" "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/rg" "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/secgroup" "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/sep" @@ -58,6 +59,7 @@ import ( node_cb "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/node" pcidevice_cb "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/pcidevice" prometheus_cb "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/prometheus" + qospolicy_cb "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/qospolicy" rg_cb "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/rg" secgroup_cb "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/secgroup" sep_cb "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/sep" @@ -82,29 +84,23 @@ type EmptyStruct struct{} func getRequestsMapCloudAPI() map[string]interface{} { return map[string]interface{}{ // account - "/restmachine/cloudapi/account/addUser": account.AddUserRequest{}, - "/restmachine/cloudapi/account/audits": account.AuditsRequest{}, - "/restmachine/cloudapi/account/delete": account.DeleteRequest{}, - "/restmachine/cloudapi/account/deleteUser": account.DeleteUserRequest{}, - "/restmachine/cloudapi/account/disable": account.DisableEnableRequest{}, - "/restmachine/cloudapi/account/enable": account.DisableEnableRequest{}, - "/restmachine/cloudapi/account/get": account.GetRequest{}, - "/restmachine/cloudapi/account/getConsumedAccountUnits": account.GetConsumedAccountUnitsRequest{}, - "/restmachine/cloudapi/account/getConsumedCloudUnitsByType": account.GetConsumedCloudUnitsByTypeRequest{}, - "/restmachine/cloudapi/account/getReservedAccountUnits": account.GetReservedAccountUnitsRequest{}, - "/restmachine/cloudapi/account/getResourceConsumption": account.GetResourceConsumptionRequest{}, - "/restmachine/cloudapi/account/list": account.ListRequest{}, - "/restmachine/cloudapi/account/listComputes": account.ListComputesRequest{}, - "/restmachine/cloudapi/account/listDeleted": account.ListDeletedRequest{}, - "/restmachine/cloudapi/account/listDisks": account.ListDisksRequest{}, - "/restmachine/cloudapi/account/listFlipGroups": account.ListFLIPGroupsRequest{}, - "/restmachine/cloudapi/account/listRG": account.ListRGRequest{}, - "/restmachine/cloudapi/account/listResourceConsumption": EmptyStruct{}, - "/restmachine/cloudapi/account/listTemplates": account.ListTemplatesRequest{}, - "/restmachine/cloudapi/account/listVins": account.ListVINSRequest{}, - "/restmachine/cloudapi/account/restore": account.RestoreRequest{}, - "/restmachine/cloudapi/account/update": account.UpdateRequest{}, - "/restmachine/cloudapi/account/updateUser": account.UpdateUserRequest{}, + "/restmachine/cloudapi/account/addUser": account.AddUserRequest{}, + "/restmachine/cloudapi/account/deleteUser": account.DeleteUserRequest{}, + "/restmachine/cloudapi/account/get": account.GetRequest{}, + "/restmachine/cloudapi/account/getConsumedAccountUnits": account.GetConsumedAccountUnitsRequest{}, + "/restmachine/cloudapi/account/getResourceConsumption": account.GetResourceConsumptionRequest{}, + "/restmachine/cloudapi/account/list": account.ListRequest{}, + "/restmachine/cloudapi/account/listComputes": account.ListComputesRequest{}, + "/restmachine/cloudapi/account/listDeleted": account.ListDeletedRequest{}, + "/restmachine/cloudapi/account/listDisks": account.ListDisksRequest{}, + "/restmachine/cloudapi/account/listFlipGroups": account.ListFLIPGroupsRequest{}, + "/restmachine/cloudapi/account/listRG": account.ListRGRequest{}, + "/restmachine/cloudapi/account/listResourceConsumption": EmptyStruct{}, + "/restmachine/cloudapi/account/listTemplates": account.ListTemplatesRequest{}, + "/restmachine/cloudapi/account/listVins": account.ListVINSRequest{}, + "/restmachine/cloudapi/account/restore": account.RestoreRequest{}, + "/restmachine/cloudapi/account/update": account.UpdateRequest{}, + "/restmachine/cloudapi/account/updateUser": account.UpdateUserRequest{}, //audit "/restmachine/cloudapi/audit/get": audit.GetRequest{}, @@ -153,13 +149,13 @@ func getRequestsMapCloudAPI() map[string]interface{} { "/restmachine/cloudapi/compute/antiAffinityRulesClear": compute.AffinityRulesClearRequest{}, "/restmachine/cloudapi/compute/attachGpu": compute.AttachGPURequest{}, "/restmachine/cloudapi/compute/attachPciDevice": compute.AttachPCIDeviceRequest{}, - "/restmachine/cloudapi/compute/audits": compute.AuditsRequest{}, "/restmachine/cloudapi/compute/bootDiskSet": compute.BootDiskSetRequest{}, "/restmachine/cloudapi/compute/bootOrderGet": compute.BootOrderGetRequest{}, "/restmachine/cloudapi/compute/bootOrderSet": compute.BootOrderSetRequest{}, "/restmachine/cloudapi/compute/cdEject": compute.CDEjectRequest{}, "/restmachine/cloudapi/compute/cdInsert": compute.CDInsertRequest{}, "/restmachine/cloudapi/compute/changeLinkState": compute.ChangeLinkStateRequest{}, + "/restmachine/cloudapi/compute/change_qos_policies": compute.ChangeQoSPoliciesRequest{}, "/restmachine/cloudapi/compute/change_security_groups": compute.ChangeSecGroupsRequest{}, "/restmachine/cloudapi/compute/clone": compute.CloneRequest{}, "/restmachine/cloudapi/compute/clone_abort": compute.CloneAbortRequest{}, @@ -183,7 +179,6 @@ func getRequestsMapCloudAPI() map[string]interface{} { "/restmachine/cloudapi/compute/enable": compute.EnableRequest{}, "/restmachine/cloudapi/compute/get": compute.GetRequest{}, "/restmachine/cloudapi/compute/get_cpu_alignment_profile": compute.GetCPUAlignmentProfileRequest{}, - "/restmachine/cloudapi/compute/getAudits": compute.GetAuditsRequest{}, "/restmachine/cloudapi/compute/getConsoleUrl": compute.GetConsoleURLRequest{}, "/restmachine/cloudapi/compute/getCustomFields": compute.GetCustomFieldsRequest{}, "/restmachine/cloudapi/compute/getLog": compute.GetLogRequest{}, @@ -378,13 +373,21 @@ func getRequestsMapCloudAPI() map[string]interface{} { "/restmachine/cloudapi/prometheus/computeMemoryUsage": prometheus.ComputeMemoryUsageRequest{}, "/restmachine/cloudapi/prometheus/computeMemoryUnused": prometheus.ComputeMemoryUnusedRequest{}, + // network_qos_policy + "/restmachine/cloudapi/network_qos_policy/create": qospolicy.CreateRequest{}, + "/restmachine/cloudapi/network_qos_policy/create_rule": qospolicy.CreateRuleRequest{}, + "/restmachine/cloudapi/network_qos_policy/delete": qospolicy.DeleteRequest{}, + "/restmachine/cloudapi/network_qos_policy/delete_rule": qospolicy.DeleteRuleRequest{}, + "/restmachine/cloudapi/network_qos_policy/get": qospolicy.GetRequest{}, + "/restmachine/cloudapi/network_qos_policy/list": qospolicy.ListRequest{}, + "/restmachine/cloudapi/network_qos_policy/update": qospolicy.UpdateRequest{}, + // rg "/restmachine/cloudapi/rg/accessGrant": rg.AccessGrantRequest{}, "/restmachine/cloudapi/rg/accessRevoke": rg.AccessRevokeRequest{}, "/restmachine/cloudapi/rg/affinityGroupComputes": rg.AffinityGroupComputesRequest{}, "/restmachine/cloudapi/rg/affinityGroupsGet": rg.AffinityGroupsGetRequest{}, "/restmachine/cloudapi/rg/affinityGroupsList": rg.AffinityGroupsListRequest{}, - "/restmachine/cloudapi/rg/audits": rg.AuditsRequest{}, "/restmachine/cloudapi/rg/create": rg.CreateRequest{}, "/restmachine/cloudapi/rg/delete": rg.DeleteRequest{}, "/restmachine/cloudapi/rg/disable": rg.DisableRequest{}, @@ -435,9 +438,7 @@ func getRequestsMapCloudAPI() map[string]interface{} { "/restmachine/cloudapi/user/authenticate": user.AuthenticateRequest{}, "/restmachine/cloudapi/user/brief": EmptyStruct{}, "/restmachine/cloudapi/user/get": user.GetRequest{}, - "/restmachine/cloudapi/user/getAudit": user.GetAuditRequest{}, "/restmachine/cloudapi/user/getResourceConsumption": EmptyStruct{}, - "/restmachine/cloudapi/user/isValidInviteUserToken": user.IsValidInviteUserTokenRequest{}, "/restmachine/cloudapi/user/search": user.SearchRequest{}, "/restmachine/cloudapi/user/setData": user.SetDataRequest{}, @@ -449,7 +450,6 @@ func getRequestsMapCloudAPI() map[string]interface{} { "/restmachine/cloudapi/vgpu/list": vgpu.ListRequest{}, // vins - "/restmachine/cloudapi/vins/audits": vins.AuditsRequest{}, "/restmachine/cloudapi/vins/createInAccount": vins.CreateInAccountRequest{}, "/restmachine/cloudapi/vins/createInRG": vins.CreateInRGRequest{}, "/restmachine/cloudapi/vins/delete": vins.DeleteRequest{}, @@ -489,15 +489,12 @@ func getRequestsMapCloudbroker() map[string]interface{} { // account_cb "/restmachine/cloudbroker/account/addUser": account_cb.AddUserRequest{}, "/restmachine/cloudbroker/account/add_storage_policy": account_cb.AddStoragePolicyRequest{}, - "/restmachine/cloudbroker/account/audits": account_cb.AuditsRequest{}, "/restmachine/cloudbroker/account/create": account_cb.CreateRequest{}, "/restmachine/cloudbroker/account/del_storage_policy": account_cb.DelStoragePolicyRequest{}, "/restmachine/cloudbroker/account/delete": account_cb.DeleteRequest{}, "/restmachine/cloudbroker/account/deleteAccounts": account_cb.DeleteAccountsRequest{}, "/restmachine/cloudbroker/account/deleteUser": account_cb.DeleteUserRequest{}, - "/restmachine/cloudbroker/account/disable": account_cb.DisableRequest{}, "/restmachine/cloudbroker/account/disableAccounts": account_cb.DisableAccountsRequest{}, - "/restmachine/cloudbroker/account/enable": account_cb.EnableRequest{}, "/restmachine/cloudbroker/account/enableAccounts": account_cb.EnableAccountsRequest{}, "/restmachine/cloudbroker/account/get": account_cb.GetRequest{}, "/restmachine/cloudbroker/account/getResourceConsumption": account_cb.GetResourceConsumptionRequest{}, @@ -569,21 +566,19 @@ func getRequestsMapCloudbroker() map[string]interface{} { "/restmachine/cloudbroker/compute/antiAffinityRulesClear": compute_cb.AffinityRulesClearRequest{}, "/restmachine/cloudbroker/compute/attachGpu": compute_cb.AttachGPURequest{}, "/restmachine/cloudbroker/compute/attachPciDevice": compute_cb.AttachPCIDeviceRequest{}, - "/restmachine/cloudbroker/compute/audits": compute_cb.AuditsRequest{}, "/restmachine/cloudbroker/compute/bootDiskSet": compute_cb.BootDiskSetRequest{}, "/restmachine/cloudbroker/compute/bootOrderGet": compute_cb.BootOrderGetRequest{}, "/restmachine/cloudbroker/compute/bootOrderSet": compute_cb.BootOrderSetRequest{}, "/restmachine/cloudbroker/compute/cdEject": compute_cb.CDEjectRequest{}, "/restmachine/cloudbroker/compute/cdInsert": compute_cb.CDInsertRequest{}, "/restmachine/cloudbroker/compute/changeLinkState": compute_cb.ChangeLinkStateRequest{}, + "/restmachine/cloudbroker/compute/change_qos_policies": compute.ChangeQoSPoliciesRequest{}, "/restmachine/cloudbroker/compute/change_mtu": compute_cb.ChangeMTURequest{}, "/restmachine/cloudbroker/compute/check_compute_placement": compute_cb.CheckComputePlacementRequest{}, "/restmachine/cloudbroker/compute/change_security_groups": compute_cb.ChangeSecGroupsRequest{}, "/restmachine/cloudbroker/compute/clone": compute_cb.CloneRequest{}, "/restmachine/cloudbroker/compute/clone_abort": compute_cb.CloneAbortRequest{}, "/restmachine/cloudbroker/compute/clone_status": compute_cb.GetCloneStatusRequest{}, - "/restmachine/cloudbroker/compute/computeciSet": compute_cb.ComputeCISetRequest{}, - "/restmachine/cloudbroker/compute/computeciUnset": compute_cb.ComputeCIUnsetRequest{}, "/restmachine/cloudbroker/compute/createTemplate": compute_cb.CreateTemplateRequest{}, "/restmachine/cloudbroker/compute/createTemplateFromBlank": compute_cb.CreateTemplateFromBlankRequest{}, "/restmachine/cloudbroker/compute/delete": compute_cb.DeleteRequest{}, @@ -603,10 +598,8 @@ func getRequestsMapCloudbroker() map[string]interface{} { "/restmachine/cloudbroker/compute/enable": compute_cb.EnableRequest{}, "/restmachine/cloudbroker/compute/get": compute_cb.GetRequest{}, "/restmachine/cloudbroker/compute/get_cpu_alignment_profile": compute_cb.GetCPUAlignmentProfileRequest{}, - "/restmachine/cloudbroker/compute/getAudits": compute_cb.GetAuditsRequest{}, "/restmachine/cloudbroker/compute/getConsoleUrl": compute_cb.GetConsoleURLRequest{}, "/restmachine/cloudbroker/compute/getCustomFields": compute_cb.GetCustomFieldsRequest{}, - "/restmachine/cloudbroker/compute/getLog": compute_cb.GetLogRequest{}, "/restmachine/cloudbroker/compute/list": compute_cb.ListRequest{}, "/restmachine/cloudbroker/compute/listDeleted": compute_cb.ListDeletedRequest{}, "/restmachine/cloudbroker/compute/listPciDevice": compute_cb.ListPCIDeviceRequest{}, @@ -761,18 +754,15 @@ func getRequestsMapCloudbroker() map[string]interface{} { // grid "/restmachine/cloudbroker/grid/addCustomBackupPath": grid_cb.AddCustomBackupPathRequest{}, "/restmachine/cloudbroker/grid/changeSettings": grid_cb.ChangeSettingsRequest{}, - "/restmachine/cloudbroker/grid/executeMaintenanceScript": grid_cb.ExecuteMaintenanceScriptRequest{}, "/restmachine/cloudbroker/grid/get": grid_cb.GetRequest{}, "/restmachine/cloudbroker/grid/getBackup": grid_cb.GetBackupRequest{}, "/restmachine/cloudbroker/grid/getDiagnosis": grid_cb.GetDiagnosisRequest{}, "/restmachine/cloudbroker/grid/getResourceConsumption": grid_cb.GetResourceConsumptionRequest{}, "/restmachine/cloudbroker/grid/list": grid_cb.ListRequest{}, - "/restmachine/cloudbroker/grid/listEmails": grid_cb.ListEmailsRequest{}, "/restmachine/cloudbroker/grid/listResourceConsumption": EmptyStruct{}, "/restmachine/cloudbroker/grid/purgeLogs": grid_cb.PurgeLogsRequest{}, "/restmachine/cloudbroker/grid/removeCustomBackupPath": grid_cb.RemoveCustomBackupPathRequest{}, "/restmachine/cloudbroker/grid/rename": grid_cb.RenameRequest{}, - "/restmachine/cloudbroker/grid/servicesRestart": grid_cb.ServicesRestartRequest{}, "/restmachine/cloudbroker/grid/setCpuAllocationParameter": grid_cb.SetCPUAllocationParameterRequest{}, "/restmachine/cloudbroker/grid/setCpuAllocationRatio": grid_cb.SetCPUAllocationRatioRequest{}, "/restmachine/cloudbroker/grid/setCpuAllocationRatioForVM": grid_cb.SetCPUAllocationRatioForVMRequest{}, @@ -783,13 +773,10 @@ func getRequestsMapCloudbroker() map[string]interface{} { "/restmachine/cloudbroker/grid/set_resources_limit": grid_cb.SetResourcesLimitRequest{}, // group - "/restmachine/cloudbroker/group/get": group_cb.GetRequest{}, "/restmachine/cloudbroker/group/list": group_cb.ListRequest{}, // image "/restmachine/cloudbroker/image/change_storage_policy": image_cb.ChangeStoragePolicyRequest{}, - "/restmachine/cloudbroker/image/computeciSet": image_cb.ComputeCISetRequest{}, - "/restmachine/cloudbroker/image/computeciUnset": image_cb.ComputeCIUnsetRequest{}, "/restmachine/cloudbroker/image/createCDROMImage": image_cb.CreateCDROMImageRequest{}, "/restmachine/cloudbroker/image/createImage": image_cb.CreateRequest{}, "/restmachine/cloudbroker/image/createVirtual": image_cb.CreateVirtualRequest{}, @@ -940,6 +927,15 @@ func getRequestsMapCloudbroker() map[string]interface{} { "/restmachine/cloudbroker/prometheus/computeMemoryUsage": prometheus_cb.ComputeMemoryUsageRequest{}, "/restmachine/cloudbroker/prometheus/computeMemoryUnused": prometheus_cb.ComputeMemoryUnusedRequest{}, + // network_qos_policy + "/restmachine/cloudbroker/network_qos_policy/create": qospolicy_cb.CreateRequest{}, + "/restmachine/cloudbroker/network_qos_policy/create_rule": qospolicy_cb.CreateRuleRequest{}, + "/restmachine/cloudbroker/network_qos_policy/delete": qospolicy_cb.DeleteRequest{}, + "/restmachine/cloudbroker/network_qos_policy/delete_rule": qospolicy_cb.DeleteRuleRequest{}, + "/restmachine/cloudbroker/network_qos_policy/get": qospolicy_cb.GetRequest{}, + "/restmachine/cloudbroker/network_qos_policy/list": qospolicy_cb.ListRequest{}, + "/restmachine/cloudbroker/network_qos_policy/update": qospolicy_cb.UpdateRequest{}, + // rg "/restmachine/cloudbroker/rg/accessGrant": rg_cb.AccessGrantRequest{}, "/restmachine/cloudbroker/rg/accessRevoke": rg_cb.AccessRevokeRequest{}, @@ -947,7 +943,6 @@ func getRequestsMapCloudbroker() map[string]interface{} { "/restmachine/cloudbroker/rg/affinityGroupComputes": rg_cb.AffinityGroupComputesRequest{}, "/restmachine/cloudbroker/rg/affinityGroupsGet": rg_cb.AffinityGroupsGetRequest{}, "/restmachine/cloudbroker/rg/affinityGroupsList": rg_cb.AffinityGroupsListRequest{}, - "/restmachine/cloudbroker/rg/audits": rg_cb.AuditsRequest{}, "/restmachine/cloudbroker/rg/create": rg_cb.CreateRequest{}, "/restmachine/cloudbroker/rg/del_storage_policy": rg_cb.DelStoragePolicyRequest{}, "/restmachine/cloudbroker/rg/delete": rg_cb.DeleteRequest{}, @@ -985,10 +980,6 @@ func getRequestsMapCloudbroker() map[string]interface{} { "/restmachine/cloudbroker/security_group/update": secgroup_cb.UpdateRequest{}, // sep - "/restmachine/cloudbroker/sep/accessGrant": sep_cb.AccessGrantRequest{}, - "/restmachine/cloudbroker/sep/accessGrantToPool": sep_cb.AccessGrantToPoolRequest{}, - "/restmachine/cloudbroker/sep/accessRevoke": sep_cb.AccessRevokeRequest{}, - "/restmachine/cloudbroker/sep/accessRevokeToPool": sep_cb.AccessRevokeToPoolRequest{}, "/restmachine/cloudbroker/sep/addConsumerNodes": sep_cb.AddConsumerNodesRequest{}, "/restmachine/cloudbroker/sep/addPool": sep_cb.AddPoolRequest{}, "/restmachine/cloudbroker/sep/addProviderNodes": sep_cb.AddProviderNodesRequest{}, @@ -1050,7 +1041,6 @@ func getRequestsMapCloudbroker() map[string]interface{} { "/restmachine/cloudbroker/user/deleteByGuid": user_cb.DeleteByGUIDRequest{}, "/restmachine/cloudbroker/user/deleteUsers": user_cb.DeleteUsersRequest{}, "/restmachine/cloudbroker/user/get": user_cb.GetRequest{}, - "/restmachine/cloudbroker/user/getAudit": user_cb.GetAuditRequest{}, "/restmachine/cloudbroker/user/getMatchingUsernames": user_cb.GetMatchingUsernamesRequest{}, "/restmachine/cloudbroker/user/list": user_cb.ListRequest{}, "/restmachine/cloudbroker/user/unblock": user_cb.UnblockRequest{}, @@ -1065,14 +1055,11 @@ func getRequestsMapCloudbroker() map[string]interface{} { "/restmachine/cloudbroker/vfpool/update": vfpool_cb.UpdateRequest{}, // vgpu - "/restmachine/cloudbroker/vgpu/allocate": vgpu_cb.AllocateRequest{}, - "/restmachine/cloudbroker/vgpu/create": vgpu_cb.CreateRequest{}, - "/restmachine/cloudbroker/vgpu/deallocate": vgpu_cb.DeallocateRequest{}, - "/restmachine/cloudbroker/vgpu/destroy": vgpu_cb.DestroyRequest{}, - "/restmachine/cloudbroker/vgpu/list": vgpu_cb.ListRequest{}, + "/restmachine/cloudbroker/vgpu/create": vgpu_cb.CreateRequest{}, + "/restmachine/cloudbroker/vgpu/destroy": vgpu_cb.DestroyRequest{}, + "/restmachine/cloudbroker/vgpu/list": vgpu_cb.ListRequest{}, // vins - "/restmachine/cloudbroker/vins/audits": vins_cb.AuditsRequest{}, "/restmachine/cloudbroker/vins/createInAccount": vins_cb.CreateInAccountRequest{}, "/restmachine/cloudbroker/vins/createInRG": vins_cb.CreateInRGRequest{}, "/restmachine/cloudbroker/vins/defaultQosUpdate": vins_cb.DefaultQOSUpdateRequest{},