From b3fccfb000dbffc611fce154d323500b99119b4f Mon Sep 17 00:00:00 2001 From: dayterr Date: Fri, 28 Aug 2026 16:36:41 +0300 Subject: [PATCH] v1.16.1 v1.16.1 --- .golangci.yml | 16 +- CHANGELOG.md | 238 ++++++------------ internal/validators/custom.go | 8 +- internal/validators/validator.go | 5 + internal/validators/values.go | 4 +- pkg/cloudapi/account/add_acl_access.go | 40 +++ pkg/cloudapi/account/add_user.go | 2 + pkg/cloudapi/account/del_acl_access.go | 39 +++ pkg/cloudapi/account/delete_user.go | 2 + pkg/cloudapi/account/models.go | 3 - pkg/cloudapi/account/update_acl_access.go | 40 +++ pkg/cloudapi/account/update_user.go | 2 + pkg/cloudapi/compute/add_acl_access.go | 40 +++ pkg/cloudapi/compute/del_acl_access.go | 39 +++ pkg/cloudapi/compute/get_acl_access.go | 44 ++++ pkg/cloudapi/compute/models.go | 61 +++++ pkg/cloudapi/compute/net_attach.go | 7 +- pkg/cloudapi/compute/update.go | 5 + pkg/cloudapi/compute/update_acl_access.go | 40 +++ pkg/cloudapi/compute/user_grant.go | 2 + pkg/cloudapi/compute/user_list.go | 2 + pkg/cloudapi/compute/user_revoke.go | 2 + pkg/cloudapi/compute/user_update.go | 2 + .../disks/change_disk_storage_policy.go | 41 ++- pkg/cloudapi/disks/delete.go | 41 ++- pkg/cloudapi/disks/delete_disks.go | 41 ++- pkg/cloudapi/disks/ids.go | 2 +- pkg/cloudapi/disks/limitio.go | 43 +++- pkg/cloudapi/disks/rename.go | 41 ++- pkg/cloudapi/disks/replicate.go | 43 +++- pkg/cloudapi/disks/replication_resume.go | 41 ++- pkg/cloudapi/disks/replication_reverse.go | 41 ++- pkg/cloudapi/disks/replication_start.go | 42 +++- pkg/cloudapi/disks/replication_stop.go | 41 ++- pkg/cloudapi/disks/replication_suspend.go | 41 ++- pkg/cloudapi/disks/resize.go | 44 +++- pkg/cloudapi/disks/restore.go | 41 ++- pkg/cloudapi/disks/share.go | 41 ++- pkg/cloudapi/disks/snapshot_delete.go | 41 ++- pkg/cloudapi/disks/snapshot_rollback.go | 42 +++- pkg/cloudapi/disks/unshare.go | 41 ++- pkg/cloudapi/extnet/get_reserved_ip.go | 5 + pkg/cloudapi/extnet/models.go | 17 +- pkg/cloudapi/kvmx86/create.go | 5 + pkg/cloudapi/kvmx86/create_blank.go | 5 + pkg/cloudapi/pcidevice/list.go | 4 +- pkg/cloudapi/pcidevice/models.go | 4 +- pkg/cloudapi/qospolicy/filter.go | 18 -- pkg/cloudapi/qospolicy/filter_test.go | 25 -- pkg/cloudapi/qospolicy/models.go | 24 -- pkg/cloudapi/qospolicy/sorting.go | 39 --- pkg/cloudapi/rg/access_grant.go | 2 + pkg/cloudapi/rg/access_revoke.go | 2 + pkg/cloudapi/rg/add_acl_access.go | 40 +++ pkg/cloudapi/rg/del_acl_access.go | 39 +++ pkg/cloudapi/rg/get_acl_access.go | 44 ++++ pkg/cloudapi/rg/models.go | 38 +++ pkg/cloudapi/rg/update_acl_access.go | 40 +++ pkg/cloudapi/vgpu/models.go | 3 + pkg/cloudbroker/account/add_acl_access.go | 40 +++ pkg/cloudbroker/account/add_user.go | 2 + pkg/cloudbroker/account/del_acl_access.go | 39 +++ pkg/cloudbroker/account/delete_user.go | 2 + pkg/cloudbroker/account/update_acl_access.go | 40 +++ pkg/cloudbroker/account/update_user.go | 2 + pkg/cloudbroker/backup/abort_disks_backup.go | 38 +++ .../backup/backup_disks_with_speed.go | 40 +++ pkg/cloudbroker/backup/create_disk_backup.go | 4 + pkg/cloudbroker/backup/create_disks_backup.go | 4 + pkg/cloudbroker/backup/info.go | 40 +++ pkg/cloudbroker/backup/models.go | 50 ++++ pkg/cloudbroker/backup/set_backup_speed.go | 46 ++++ pkg/cloudbroker/compute/add_acl_access.go | 40 +++ pkg/cloudbroker/compute/del_acl_access.go | 39 +++ pkg/cloudbroker/compute/get_acl_access.go | 44 ++++ pkg/cloudbroker/compute/models.go | 63 +++++ pkg/cloudbroker/compute/net_attach.go | 7 +- pkg/cloudbroker/compute/update.go | 5 + pkg/cloudbroker/compute/update_acl_access.go | 40 +++ pkg/cloudbroker/compute/user_grant.go | 2 + pkg/cloudbroker/compute/user_list.go | 2 + pkg/cloudbroker/compute/user_revoke.go | 2 + pkg/cloudbroker/compute/user_update.go | 2 + .../disks/change_disk_storage_policy.go | 41 ++- pkg/cloudbroker/disks/delete.go | 41 ++- pkg/cloudbroker/disks/delete_disks.go | 41 ++- pkg/cloudbroker/disks/depresent.go | 44 +++- pkg/cloudbroker/disks/ids.go | 1 - pkg/cloudbroker/disks/limit_io.go | 43 +++- pkg/cloudbroker/disks/migrate_abort.go | 41 ++- pkg/cloudbroker/disks/present.go | 44 +++- pkg/cloudbroker/disks/rename.go | 41 ++- pkg/cloudbroker/disks/replicate.go | 43 +++- pkg/cloudbroker/disks/replication_resume.go | 41 ++- pkg/cloudbroker/disks/replication_reverse.go | 41 ++- pkg/cloudbroker/disks/replication_start.go | 42 +++- pkg/cloudbroker/disks/replication_stop.go | 41 ++- pkg/cloudbroker/disks/replication_suspend.go | 41 ++- pkg/cloudbroker/disks/resize.go | 44 +++- pkg/cloudbroker/disks/restore.go | 41 ++- pkg/cloudbroker/disks/share.go | 41 ++- pkg/cloudbroker/disks/snapshot_delete.go | 41 ++- pkg/cloudbroker/disks/snapshot_rollback.go | 41 ++- pkg/cloudbroker/disks/unshare.go | 41 ++- pkg/cloudbroker/disks/update.go | 41 ++- pkg/cloudbroker/extnet/add_reserved_ip.go | 5 + pkg/cloudbroker/extnet/get_reserved_ip.go | 5 + pkg/cloudbroker/extnet/models.go | 17 +- pkg/cloudbroker/kvmx86/create.go | 5 + pkg/cloudbroker/kvmx86/create_blank.go | 5 + pkg/cloudbroker/kvmx86/mass_create.go | 5 + .../node/pci_device_driver_to_kernel.go | 5 + pkg/cloudbroker/pcidevice/access_grant.go | 38 +++ pkg/cloudbroker/pcidevice/access_revoke.go | 38 +++ pkg/cloudbroker/pcidevice/create.go | 11 +- pkg/cloudbroker/pcidevice/list.go | 4 +- pkg/cloudbroker/pcidevice/models.go | 4 +- pkg/cloudbroker/qospolicy/filter.go | 18 -- pkg/cloudbroker/qospolicy/filter_test.go | 25 -- pkg/cloudbroker/qospolicy/models.go | 24 -- pkg/cloudbroker/qospolicy/sorting.go | 39 --- pkg/cloudbroker/rg/access_grant.go | 2 + pkg/cloudbroker/rg/access_revoke.go | 2 + pkg/cloudbroker/rg/add_acl_access.go | 40 +++ pkg/cloudbroker/rg/del_acl_access.go | 39 +++ pkg/cloudbroker/rg/get_acl_access.go | 44 ++++ pkg/cloudbroker/rg/models.go | 38 +++ pkg/cloudbroker/rg/update_acl_access.go | 40 +++ pkg/cloudbroker/sep/config_field_edit.go | 2 + pkg/cloudbroker/vgpu/models.go | 3 + tests/platform_upgrade/request_map.go | 50 +++- 131 files changed, 3204 insertions(+), 478 deletions(-) create mode 100644 pkg/cloudapi/account/add_acl_access.go create mode 100644 pkg/cloudapi/account/del_acl_access.go create mode 100644 pkg/cloudapi/account/update_acl_access.go create mode 100644 pkg/cloudapi/compute/add_acl_access.go create mode 100644 pkg/cloudapi/compute/del_acl_access.go create mode 100644 pkg/cloudapi/compute/get_acl_access.go create mode 100644 pkg/cloudapi/compute/update_acl_access.go delete mode 100644 pkg/cloudapi/qospolicy/sorting.go create mode 100644 pkg/cloudapi/rg/add_acl_access.go create mode 100644 pkg/cloudapi/rg/del_acl_access.go create mode 100644 pkg/cloudapi/rg/get_acl_access.go create mode 100644 pkg/cloudapi/rg/update_acl_access.go create mode 100644 pkg/cloudbroker/account/add_acl_access.go create mode 100644 pkg/cloudbroker/account/del_acl_access.go create mode 100644 pkg/cloudbroker/account/update_acl_access.go create mode 100644 pkg/cloudbroker/backup/abort_disks_backup.go create mode 100644 pkg/cloudbroker/backup/backup_disks_with_speed.go create mode 100644 pkg/cloudbroker/backup/info.go create mode 100644 pkg/cloudbroker/backup/set_backup_speed.go create mode 100644 pkg/cloudbroker/compute/add_acl_access.go create mode 100644 pkg/cloudbroker/compute/del_acl_access.go create mode 100644 pkg/cloudbroker/compute/get_acl_access.go create mode 100644 pkg/cloudbroker/compute/update_acl_access.go create mode 100644 pkg/cloudbroker/pcidevice/access_grant.go create mode 100644 pkg/cloudbroker/pcidevice/access_revoke.go delete mode 100644 pkg/cloudbroker/qospolicy/sorting.go create mode 100644 pkg/cloudbroker/rg/add_acl_access.go create mode 100644 pkg/cloudbroker/rg/del_acl_access.go create mode 100644 pkg/cloudbroker/rg/get_acl_access.go create mode 100644 pkg/cloudbroker/rg/update_acl_access.go diff --git a/.golangci.yml b/.golangci.yml index c74c72f..5bd576f 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,3 +1,4 @@ +version: "2" linters: enable: - bodyclose @@ -5,19 +6,20 @@ linters: - dogsled - errorlint - exhaustive - - exportloopref - - exhaustive - #- gocognit - goconst - #- gocyclo - gosec - makezero - #- nestif + - musttag - nilerr + - noctx - prealloc + - revive + - staticcheck - unconvert - unparam - - noctx - + - unused + exclusions: + presets: + - comments issues: max-same-issues: 0 diff --git a/CHANGELOG.md b/CHANGELOG.md index 56cb944..d3c3b14 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,144 +1,99 @@ -## Version 1.16.0 +## Version 1.16.1 -Метод `ConfigFieldEdit` в cloudbroker/sep стал deprecated и в следующих версиях будет удалён + +### Deprecated + +Перечисленные методы будут удалены в `v1.17` + +| Метод | CloudAPI | CloudBroker | +| --- | --- | --- | +| `account/AddUser` | :heavy_check_mark: | :heavy_check_mark: | +| `account/DeleteUser` | :heavy_check_mark: | :heavy_check_mark: | +| `account/UpdateUser` | :heavy_check_mark: | :heavy_check_mark: | +| `compute/UserGrant` | :heavy_check_mark: | :heavy_check_mark: | +| `compute/UserList` | :heavy_check_mark: | :heavy_check_mark: | +| `compute/UserRevoke` | :heavy_check_mark: | :heavy_check_mark: | +| `compute/UserUpdate` | :heavy_check_mark: | :heavy_check_mark: | +| `rg/AccessGrant` | :heavy_check_mark: | :heavy_check_mark: | +| `rg/AccessRevoke` | :heavy_check_mark: | :heavy_check_mark: | +| `sep/ConfigFieldEdit` | :x: | :heavy_check_mark: | ### Добавлено -#### Общее -| Идентификатор задачи | Описание | -| --- | --- | -| 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 | +| BGOS-1007 | Структура запроса `AddACLAccessRequest` и метод `AddACLAccess` в cloudapi/account и в cloudbroker/account | +| BGOS-1007 | Структура запроса `DelACLAccessRequest` и метод `DelACLAccess` в cloudapi/account и в cloudbroker/account | +| BGOS-1007 | Структура запроса `UpdateACLAccessRequest` и метод `UpdateACLAccess` в cloudapi/account и в cloudbroker/account | + +#### backup +| Идентификатор задачи | Описание | +| --- | --- | +| BGOS-1012 | Методы `AbortDisksBackup`, `BackupDisksWithSpeed`, `Info` и `SetBackupSpeed` в cloudbroker/backup | +| BGOS-1012 | Структуры ответов `ListDisksWithSpeed` и `TotalBackupsInfo` в cloudbroker/backup | +| BGOS-1018 | Опциональное поле `Speed` в структуры запроса `CreateDiskBackupRequest` и `Disk` в cloudbroker/backup | + #### 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 | +| BGOS-1009 | Структура запроса `AddACLAccessRequest` и метод `AddACLAccess` в cloudapi/compute и в cloudbroker/compute | +| BGOS-1009 | Структура запроса `DeleteACLAccessRequest` и метод `DeleteACLAccess` в cloudapi/compute и в cloudbroker/compute | +| BGOS-1009 | Структура запроса `UpdateACLAccessRequest` и метод `UpdateACLAccess` в cloudapi/compute и в cloudbroker/compute | +| BGOS-1009 | Структура запроса `GetACLAccessRequest` и метод `GetACLAccess` в cloudapi/compute и в cloudbroker/compute | +| BGOS-1014 | Вычисляемое поле `MemoryBalloonMode` в структуры ответа `ItemCompute` и `RecordCompute` в cloudapi/compute | +| BGOS-1014 | Вычисляемое поле `MemoryBalloonMode` в структуры ответа `InfoCompute` и `RecordCompute` в cloudbroker/compute | +| BGOS-1014 | Опциональное поле `MemoryBalloonMode` в структуру запроса `UpdateRequest` в cloudbroker/compute и cloudapi/compute | +| BGOS-1016 | Вычисляемое поле `ProfileName` в структуру ответа `ItemVGPU` в cloudbroker/compute и cloudapi/compute | +| BGOS-1019 | Вычисляемое поле `QoSPolicies` в структуру ответа `ItemShadowComputeInterface` в cloudbroker/compute | #### disks | Идентификатор задачи | Описание | | --- | --- | -| BGOS-976 | Метод `CreateAsync` в cloudapi/disks | -| BGOS-976 | Методы `CreateAsync` и `MigrateAsync` в cloudbroker/disks | +| BGOS-1015 | Методы `DeleteAsync`, `DeleteDisksAsync`, `LimitIOAsync`, `RenameAsync`, `ReplicateAsync`, `ReplicationResumeAsync`, `ReplicationReverseAsync`, `ReplicationStartAsync`, `ReplicationStopAsync`, `ReplicationSuspendAsync`, `Resize2Async`, `RestoreAsync`, `ShareAsync`, `UnshareAsync`, `SnapshotDeleteAsync`, `SnapshotRollbackAsync`, `ChangeDiskStoragePolicyAsync` в cloudapi/disks | +| BGOS-1015 | Методы `DeleteAsync`, `DeleteDisksAsync`, `DepresentAsync`, `LimitIOAsync`, `MigrateAbortAsync`, `PresentAsync`, `RenameAsync`, `ReplicateAsync`, `ReplicationResumeAsync`, `ReplicationReverseAsync`, `ReplicationStartAsync`, `ReplicationStopAsync`, `ReplicationSuspendAsync`, `Resize2Async`, `RestoreAsync`, `ShareAsync`, `UnshareAsync`, `SnapshotDeleteAsync`, `SnapshotRollbackAsync`, `ChangeDiskStoragePolicyAsync`, `UpdateAsync` в cloudbroker/disks | -#### grid +#### extnet | Идентификатор задачи | Описание | | --- | --- | -| BGOS-1000 | Вычисляемые поля `ReservedCPU` и `ReservedRAM` в структуру ответа `RecordSettingsGrid` в cloudbroker/grid | +| BGOS-1013 | Опциональное поле `AutoAssignable` в структуру запроса `AddReserveIPRequest` в cloudbroker/extnet | +| BGOS-1013 | Опциональное поле `AutoAssignable` в структуру запроса `GetReservedIP` в cloudbroker/extnet и cloudapi/extnet | +| BGOS-1013 | Вычисляемое поле `AutoAssignable` в структуру ответа `Reservations` в cloudbroker/extnet и cloudapi/extnet | #### 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 | +| BGOS-1014 | Опциональное поле `MemoryBalloonMode` в структуры запроса `CreateRequest` и `CreateBlankRequest` в cloudapi/kvmx86 | +| BGOS-1014 | Опциональное поле `MemoryBalloonMode` в структуры запроса `CreateRequest`, `CreateBlankRequest` и `MassCreateRequest` в cloudbroker/kvmx86 | #### node | Идентификатор задачи | Описание | | --- | --- | -| BGOS-982 | Тип вычисляемого поля `Total` с `ResourcesInfo` на `FreeResourcesInfo` в структуре ответа `ConsumptionInfo` в cloudbroker/node | +| BGOS-1020 | Опциональное поле `Mode` в структуру запроса `PCIDeviceDriverToKernelRequest` в cloudbroker/node | + +#### pcidevice +| Идентификатор задачи | Описание | +| --- | --- | +| BGOS-990 | Опциональное поле `AccountID` в структуру запроса `ListRequest` в cloudapi/pcidevice и в структуры запроса `CreateRequest` и `ListRequest` в cloudbroker/pcidevice | +| BGOS-990 | Вычисляемое поле `AccountID` в структуру ответа `ItemPCIDevice` в cloudapi/pcidevice и в структуру ответа `ItemPCIDevice` в cloudbroker/pcidevice | +| BGOS-990 | Метод `AccessGrant` и структура запроса `AccessGrantRequest` в cloudbroker/pcidevice | +| BGOS-990 | Метод `AccessRevoke` и структура запроса `AccessRevokeRequest` в cloudbroker/pcidevice | + +#### rg +| Идентификатор задачи | Описание | +| --- | --- | +| BGOS-1008 | Структура запроса `AddACLAccessRequest` и метод `AddACLAccess` в cloudapi/rg и в cloudbroker/rg | +| BGOS-1008 | Структура запроса `DeleteACLAccessRequest` и метод `DeleteACLAccess` в cloudapi/rg и в cloudbroker/rg | +| BGOS-1008 | Структура запроса `UpdateACLAccessRequest` и метод `UpdateACLAccess` в cloudapi/rg и в cloudbroker/rg | +| BGOS-1008 | Структура запроса `GetACLAccessRequest` и метод `GetACLAccess` в cloudapi/rg и в cloudbroker/rg | + #### 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 | +| BGOS-1011 | Вычисляемое поле `ProfileName` в структуру ответа `ItemVGPU` в cloudbroker/vgpu и cloudapi/vgpu | ### Удалено @@ -146,64 +101,17 @@ #### account | Идентификатор задачи | Описание | | --- | --- | -| BGOS-975 | Метод `Audits` из cloudapi/account и cloudbroker/account | -| BGOS-975 | Методы `Delete`, `Disable`, `Enable`, `GetConsumedCloudUnitsByType` и `GetReservedAccountUnits` из cloudapi/account | -| BGOS-975 | Методы `Disable` и `Enable` из cloudbroker/account | +| BGOS-1021 | Вычисляемое поле `CanBeDeleted` из структуры ответа `ListRecordACL` в cloudapi/account | -#### compute +#### network qos policy | Идентификатор задачи | Описание | | --- | --- | -| 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 | +| BGOS-1017 | Вычисляемые поля `CreatedAt`, `UpdatedAt`, `CreatedBy` и `UpdatedBy` из структур ответа `ItemQoSPolicy` и `RecordQoSPolicy` в cloudapi/qospolicy и cloudbroker/qospolicy | +| BGOS-1017 | Методы `FilterByCreatedBy` и `FilterByUpdatedBy` из cloudapi/qospolicy и cloudbroker/qospolicy | +| BGOS-1017 | Методы `SortByCreatedAt` и `SortByUpdatedAt` из cloudapi/qospolicy и cloudbroker/qospolicy | -#### grid +#### pcidevice | Идентификатор задачи | Описание | | --- | --- | -| 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 +| BGOS-990 | Опциональное поле `RGID` из структуры запроса `ListRequest` в cloudapi/pcidevice и из структур запроса `CreateRequest` и `ListRequest` в cloudbroker/pcidevice | +| BGOS-990 | Вычисляемое поле `RGID` из структуры ответа `ItemPCIDevice` в cloudapi/pcidevice и из структуры ответа `ItemPCIDevice` в cloudbroker/pcidevice | diff --git a/internal/validators/custom.go b/internal/validators/custom.go index 089e4dc..8df3f3c 100644 --- a/internal/validators/custom.go +++ b/internal/validators/custom.go @@ -492,5 +492,11 @@ func sepDescriptionValidator(fe validator.FieldLevel) bool { func watchdogActionValidator(fe validator.FieldLevel) bool { fieldValue := fe.Field().String() - return IsInSlice(fieldValue, watchdogActionVaues) + return IsInSlice(fieldValue, watchdogActionValues) +} + +func memoryBalloonModeValidator(fe validator.FieldLevel) bool { + fieldValue := fe.Field().String() + + return IsInSlice(fieldValue, memoryBalloonModeValues) } diff --git a/internal/validators/validator.go b/internal/validators/validator.go index ed23a73..9ee1cd2 100644 --- a/internal/validators/validator.go +++ b/internal/validators/validator.go @@ -331,5 +331,10 @@ func registerAllValidators(validate *validator.Validate) error { return err } + err = validate.RegisterValidation("memoryBalloonMode", memoryBalloonModeValidator) + if err != nil { + return err + } + return nil } diff --git a/internal/validators/values.go b/internal/validators/values.go index 18eb2f0..73ccbfe 100644 --- a/internal/validators/values.go +++ b/internal/validators/values.go @@ -81,7 +81,9 @@ var ( sepTechStatusValues = []string{"ENABLED", "DISABLED"} - watchdogActionVaues = []string{"reset", "shutdown", "poweroff", "pause", "none"} + watchdogActionValues = []string{"reset", "shutdown", "poweroff", "pause", "none"} + + memoryBalloonModeValues = []string{"auto", "legacy", "none"} ) const ( diff --git a/pkg/cloudapi/account/add_acl_access.go b/pkg/cloudapi/account/add_acl_access.go new file mode 100644 index 0000000..17345fd --- /dev/null +++ b/pkg/cloudapi/account/add_acl_access.go @@ -0,0 +1,40 @@ +package account + +import ( + "context" + "net/http" + "strconv" + + "repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants" + "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" +) + +// AddACLAccessRequest adds ACL access to an account +type AddACLAccessRequest struct { + ID uint64 `url:"id" json:"id" validate:"required"` + AccessType string `url:"accesstype" json:"accesstype" validate:"required"` + Usernames []string `url:"usernames,omitempty" json:"usernames,omitempty"` + APIAccesses []uint64 `url:"apiaccesses,omitempty" json:"apiaccesses,omitempty"` +} + +// AddACLAccess adds ACL access to an account. +func (a Account) AddACLAccess(ctx context.Context, req AddACLAccessRequest) (bool, error) { + err := validators.ValidateRequest(req) + if err != nil { + return false, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudapi/account/add_acl_access" + + res, err := a.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req) + if err != nil { + return false, err + } + + result, err := strconv.ParseBool(string(res)) + if err != nil { + return false, err + } + + return result, nil +} diff --git a/pkg/cloudapi/account/add_user.go b/pkg/cloudapi/account/add_user.go index 9f3ae16..43e853f 100644 --- a/pkg/cloudapi/account/add_user.go +++ b/pkg/cloudapi/account/add_user.go @@ -27,6 +27,8 @@ type AddUserRequest struct { } // AddUser gives a user access rights. +// +// Deprecated: will be removed in SDK v1.17 func (a Account) AddUser(ctx context.Context, req AddUserRequest) (bool, error) { err := validators.ValidateRequest(req) if err != nil { diff --git a/pkg/cloudapi/account/del_acl_access.go b/pkg/cloudapi/account/del_acl_access.go new file mode 100644 index 0000000..00dfb22 --- /dev/null +++ b/pkg/cloudapi/account/del_acl_access.go @@ -0,0 +1,39 @@ +package account + +import ( + "context" + "net/http" + "strconv" + + "repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants" + "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" +) + +// DelACLAccessRequest deletes ACL access from an account +type DelACLAccessRequest struct { + ID uint64 `url:"id" json:"id" validate:"required"` + Usernames []string `url:"usernames,omitempty" json:"usernames,omitempty"` + APIAccesses []uint64 `url:"apiaccesses,omitempty" json:"apiaccesses,omitempty"` +} + +// DelACLAccess deletes ACL access from an account. +func (a Account) DeleteACLAccess(ctx context.Context, req DelACLAccessRequest) (bool, error) { + err := validators.ValidateRequest(req) + if err != nil { + return false, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudapi/account/del_acl_access" + + res, err := a.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req) + if err != nil { + return false, err + } + + result, err := strconv.ParseBool(string(res)) + if err != nil { + return false, err + } + + return result, nil +} diff --git a/pkg/cloudapi/account/delete_user.go b/pkg/cloudapi/account/delete_user.go index 9aed43d..ec0ff6f 100644 --- a/pkg/cloudapi/account/delete_user.go +++ b/pkg/cloudapi/account/delete_user.go @@ -20,6 +20,8 @@ type DeleteUserRequest struct { } // DeleteUser revokes user access from the account +// +// Deprecated: will be removed in SDK v1.17 func (a Account) DeleteUser(ctx context.Context, req DeleteUserRequest) (bool, error) { err := validators.ValidateRequest(req) if err != nil { diff --git a/pkg/cloudapi/account/models.go b/pkg/cloudapi/account/models.go index 9f6c9d5..a807831 100644 --- a/pkg/cloudapi/account/models.go +++ b/pkg/cloudapi/account/models.go @@ -19,9 +19,6 @@ type ListRecordACL struct { // Account owner ID UgroupID string `json:"userGroupId"` - - // Is it possible to remove - CanBeDeleted bool `json:"canBeDeleted"` } // Access Control List diff --git a/pkg/cloudapi/account/update_acl_access.go b/pkg/cloudapi/account/update_acl_access.go new file mode 100644 index 0000000..8744958 --- /dev/null +++ b/pkg/cloudapi/account/update_acl_access.go @@ -0,0 +1,40 @@ +package account + +import ( + "context" + "net/http" + "strconv" + + "repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants" + "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" +) + +// UpdateACLAccessRequest updates ACL access in an account +type UpdateACLAccessRequest struct { + ID uint64 `url:"id" json:"id" validate:"required"` + AccessType string `url:"accesstype" json:"accesstype" validate:"required"` + Usernames []string `url:"usernames,omitempty" json:"usernames,omitempty"` + APIAccesses []uint64 `url:"apiaccesses,omitempty" json:"apiaccesses,omitempty"` +} + +// UpdateACLAccess updates ACL access in an account. +func (a Account) UpdateACLAccess(ctx context.Context, req UpdateACLAccessRequest) (bool, error) { + err := validators.ValidateRequest(req) + if err != nil { + return false, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudapi/account/update_acl_access" + + res, err := a.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req) + if err != nil { + return false, err + } + + result, err := strconv.ParseBool(string(res)) + if err != nil { + return false, err + } + + return result, nil +} diff --git a/pkg/cloudapi/account/update_user.go b/pkg/cloudapi/account/update_user.go index 672079e..0fa05c6 100644 --- a/pkg/cloudapi/account/update_user.go +++ b/pkg/cloudapi/account/update_user.go @@ -27,6 +27,8 @@ type UpdateUserRequest struct { } // UpdateUser updates user access rights +// +// Deprecated: will be removed in SDK v1.17 func (a Account) UpdateUser(ctx context.Context, req UpdateUserRequest) (bool, error) { err := validators.ValidateRequest(req) if err != nil { diff --git a/pkg/cloudapi/compute/add_acl_access.go b/pkg/cloudapi/compute/add_acl_access.go new file mode 100644 index 0000000..90378c6 --- /dev/null +++ b/pkg/cloudapi/compute/add_acl_access.go @@ -0,0 +1,40 @@ +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" +) + +// AddACLAccessRequest adds ACL access to a vm +type AddACLAccessRequest struct { + ID uint64 `url:"id" json:"id" validate:"required"` + AccessType string `url:"accesstype" json:"accesstype" validate:"required"` + Usernames []string `url:"usernames,omitempty" json:"usernames,omitempty"` + APIAccesses []uint64 `url:"apiaccesses,omitempty" json:"apiaccesses,omitempty"` +} + +// AddACLAccess adds ACL access to a vm. +func (c Compute) AddACLAccess(ctx context.Context, req AddACLAccessRequest) (bool, error) { + err := validators.ValidateRequest(req) + if err != nil { + return false, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudapi/compute/add_acl_access" + + res, err := c.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req) + if err != nil { + return false, err + } + + result, err := strconv.ParseBool(string(res)) + if err != nil { + return false, err + } + + return result, nil +} diff --git a/pkg/cloudapi/compute/del_acl_access.go b/pkg/cloudapi/compute/del_acl_access.go new file mode 100644 index 0000000..a09dac0 --- /dev/null +++ b/pkg/cloudapi/compute/del_acl_access.go @@ -0,0 +1,39 @@ +package compute + +import ( + "context" + "net/http" + "strconv" + + "repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants" + "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" +) + +// DeleteACLAccessRequest deletes ACL access from a vm +type DeleteACLAccessRequest struct { + ID uint64 `url:"id" json:"id" validate:"required"` + Usernames []string `url:"usernames,omitempty" json:"usernames,omitempty"` + APIAccesses []uint64 `url:"apiaccesses,omitempty" json:"apiaccesses,omitempty"` +} + +// DeleteACLAccess deletes ACL access from a vm. +func (c Compute) DeleteACLAccess(ctx context.Context, req DeleteACLAccessRequest) (bool, error) { + err := validators.ValidateRequest(req) + if err != nil { + return false, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudapi/compute/del_acl_access" + + res, err := c.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req) + if err != nil { + return false, err + } + + result, err := strconv.ParseBool(string(res)) + if err != nil { + return false, err + } + + return result, nil +} diff --git a/pkg/cloudapi/compute/get_acl_access.go b/pkg/cloudapi/compute/get_acl_access.go new file mode 100644 index 0000000..a7adb66 --- /dev/null +++ b/pkg/cloudapi/compute/get_acl_access.go @@ -0,0 +1,44 @@ +package compute + +import ( + "context" + "encoding/json" + "net/http" + + "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" +) + +// GetACLAccessRequest struct to get detailed information about ACL account in a vm +type GetACLAccessRequest struct { + ID uint64 `url:"id" json:"id" validate:"required"` +} + +// Get gets current configuration of the ACL access in a vm as a RecordRGACLAccess struct +func (c Compute) GetACLAccess(ctx context.Context, req GetACLAccessRequest) (*RecordComputeACLAccess, error) { + res, err := c.GetACLAccessRaw(ctx, req) + if err != nil { + return nil, err + } + + info := RecordComputeACLAccess{} + + err = json.Unmarshal(res, &info) + if err != nil { + return nil, err + } + + return &info, nil +} + +// GetACLAccessRaw gets current configuration of the ACL access in a vm as an array of bytes +func (c Compute) GetACLAccessRaw(ctx context.Context, req GetACLAccessRequest) ([]byte, error) { + err := validators.ValidateRequest(req) + if err != nil { + return nil, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudapi/compute/get_acl_access" + + res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req) + return res, err +} diff --git a/pkg/cloudapi/compute/models.go b/pkg/cloudapi/compute/models.go index ea7e3f0..f3a89b0 100644 --- a/pkg/cloudapi/compute/models.go +++ b/pkg/cloudapi/compute/models.go @@ -446,6 +446,9 @@ type RecordCompute struct { // Manager type ManagerType string `json:"managerType"` + // Memory balloon mode + MemoryBalloonMode string `json:"memory_balloon_mode"` + // Migration job MigrationJob uint64 `json:"migrationjob"` @@ -574,6 +577,58 @@ type RecordCompute struct { ZoneID uint64 `json:"zoneId"` } +// Detailed information about ACL Access in a compute +type RecordComputeACLAccess struct { + // Data + Data DataACL `json:"data"` + + // Entry count + EntryCount uint64 `json:"entryCount"` +} + +// Data ACL +type DataACL struct { + // RG ACL list + RGACLList []RGACL `json:"rgACL"` + + // Account ACL list + AccountACLList []AccountACL `json:"accountACL"` + + // Compute ACL list + ComputeACLList []ComputeACL `json:"computeACL"` +} + +// RG ACL info +type RGACL struct { + Right string `json:"right"` + GUID string `json:"guid"` + UserGroupID string `json:"userGroupId"` + Status string `json:"status"` + Type string `json:"type"` + Explicit bool `json:"explicit"` +} + +// Account ACL info +type AccountACL struct { + Right string `json:"right"` + GUID string `json:"guid"` + UserGroupID string `json:"userGroupId"` + Status string `json:"status"` + Type string `json:"type"` + Explicit bool `json:"explicit"` +} + +// Compute ACL info + +type ComputeACL struct { + Right string `json:"right"` + GUID string `json:"guid"` + UserGroupID string `json:"userGroupId"` + Status string `json:"status"` + Type string `json:"type"` + Explicit bool `json:"explicit"` +} + type SnapRecordCompute struct { // Access Control List ACL ListACL `json:"acl"` @@ -1396,6 +1451,9 @@ type ItemCompute struct { // Manager type ManagerType string `json:"managerType"` + // Memory balloon mode + MemoryBalloonMode string `json:"memory_balloon_mode"` + // Migration job MigrationJob uint64 `json:"migrationjob"` @@ -1591,6 +1649,9 @@ type ItemVGPU struct { // Profile Reference ProfileReference string `json:"profile_reference"` + // Profile Name + ProfileName string `json:"profile_name"` + // Split Mode SplitMode string `json:"split_mode"` diff --git a/pkg/cloudapi/compute/net_attach.go b/pkg/cloudapi/compute/net_attach.go index 56e4e7d..5f544ab 100644 --- a/pkg/cloudapi/compute/net_attach.go +++ b/pkg/cloudapi/compute/net_attach.go @@ -5,6 +5,7 @@ import ( "encoding/json" "net/http" + "repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants" "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" ) @@ -95,7 +96,7 @@ type NetAttachRequest struct { type wrapperNetAttachRequest struct { NetAttachRequest - AsyncMode bool `url:"asyncMode"` + AsyncMode bool `url:"asyncMode" json:"asyncMode"` } // NetAttach attaches network to compute and gets info about network @@ -112,7 +113,7 @@ func (c Compute) NetAttach(ctx context.Context, req NetAttachRequest) (*RecordNe url := "/cloudapi/compute/netAttach" - res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped) + res, err := c.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, reqWrapped) if err != nil { return nil, err } @@ -141,7 +142,7 @@ func (c Compute) NetAttachAsync(ctx context.Context, req NetAttachRequest) (stri url := "/cloudapi/compute/netAttach" - res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped) + res, err := c.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, reqWrapped) if err != nil { return "", err } diff --git a/pkg/cloudapi/compute/update.go b/pkg/cloudapi/compute/update.go index 54b095d..a6a1895 100644 --- a/pkg/cloudapi/compute/update.go +++ b/pkg/cloudapi/compute/update.go @@ -79,6 +79,11 @@ type UpdateRequest struct { // Required: false // Default: reset WatchdogAction string `url:"watchdog_action,omitempty" json:"watchdog_action,omitempty" validate:"omitempty,watchdogAction"` + + // Memory balloon mode. One of ["auto","legacy","none"] + // Required: false + // Default: "auto" + MemoryBalloonMode string `url:"memory_balloon_mode,omitempty" json:"memory_balloon_mode,omitempty" validate:"omitempty,memoryBalloonMode"` } // Update updates some properties of the compute diff --git a/pkg/cloudapi/compute/update_acl_access.go b/pkg/cloudapi/compute/update_acl_access.go new file mode 100644 index 0000000..076de69 --- /dev/null +++ b/pkg/cloudapi/compute/update_acl_access.go @@ -0,0 +1,40 @@ +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" +) + +// UpdateACLAccessRequest updates ACL access in a vm +type UpdateACLAccessRequest struct { + ID uint64 `url:"id" json:"id" validate:"required"` + AccessType string `url:"accesstype" json:"accesstype" validate:"required"` + Usernames []string `url:"usernames,omitempty" json:"usernames,omitempty"` + APIAccesses []uint64 `url:"apiaccesses,omitempty" json:"apiaccesses,omitempty"` +} + +// UpdateACLAccess updates ACL access in a vm. +func (c Compute) UpdateACLAccess(ctx context.Context, req UpdateACLAccessRequest) (bool, error) { + err := validators.ValidateRequest(req) + if err != nil { + return false, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudapi/compute/update_acl_access" + + res, err := c.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req) + if err != nil { + return false, err + } + + result, err := strconv.ParseBool(string(res)) + if err != nil { + return false, err + } + + return result, nil +} diff --git a/pkg/cloudapi/compute/user_grant.go b/pkg/cloudapi/compute/user_grant.go index 9420ab8..ecd82da 100644 --- a/pkg/cloudapi/compute/user_grant.go +++ b/pkg/cloudapi/compute/user_grant.go @@ -28,6 +28,8 @@ type UserGrantRequest struct { } // UserGrant grants user access to the compute +// +// Deprecated: will be removed in SDK v1.17 func (c Compute) UserGrant(ctx context.Context, req UserGrantRequest) (bool, error) { err := validators.ValidateRequest(req) if err != nil { diff --git a/pkg/cloudapi/compute/user_list.go b/pkg/cloudapi/compute/user_list.go index 0938d8c..a9d7a49 100644 --- a/pkg/cloudapi/compute/user_list.go +++ b/pkg/cloudapi/compute/user_list.go @@ -16,6 +16,8 @@ type UserListRequest struct { } // UserList gets users list for compute +// +// Deprecated: will be removed in SDK v1.17 func (c Compute) UserList(ctx context.Context, req UserListRequest) (*ListUsers, error) { err := validators.ValidateRequest(req) if err != nil { diff --git a/pkg/cloudapi/compute/user_revoke.go b/pkg/cloudapi/compute/user_revoke.go index 9897959..0f8cc53 100644 --- a/pkg/cloudapi/compute/user_revoke.go +++ b/pkg/cloudapi/compute/user_revoke.go @@ -20,6 +20,8 @@ type UserRevokeRequest struct { } // UserRevoke revokes user access to the compute +// +// Deprecated: will be removed in SDK v1.17 func (c Compute) UserRevoke(ctx context.Context, req UserRevokeRequest) (bool, error) { err := validators.ValidateRequest(req) if err != nil { diff --git a/pkg/cloudapi/compute/user_update.go b/pkg/cloudapi/compute/user_update.go index 623bc01..08d76d8 100644 --- a/pkg/cloudapi/compute/user_update.go +++ b/pkg/cloudapi/compute/user_update.go @@ -28,6 +28,8 @@ type UserUpdateRequest struct { } // UserUpdate updates user access to the compute +// +// Deprecated: will be removed in SDK v1.17 func (c Compute) UserUpdate(ctx context.Context, req UserUpdateRequest) (bool, error) { err := validators.ValidateRequest(req) if err != nil { diff --git a/pkg/cloudapi/disks/change_disk_storage_policy.go b/pkg/cloudapi/disks/change_disk_storage_policy.go index 4221a4e..5f55f96 100644 --- a/pkg/cloudapi/disks/change_disk_storage_policy.go +++ b/pkg/cloudapi/disks/change_disk_storage_policy.go @@ -2,6 +2,7 @@ package disks import ( "context" + "encoding/json" "net/http" "strconv" @@ -19,6 +20,12 @@ type ChangeDiskStoragePolicyRequest struct { StoragePolicyID uint64 `url:"storage_policy_id" json:"storage_policy_id" validate:"required"` } +type wrapperChangeDiskStoragePolicyRequest struct { + ChangeDiskStoragePolicyRequest + + AsyncMode bool `url:"async_mode" json:"async_mode"` +} + // ChangeDiskStoragePolicy changes storage policy for disk func (d Disks) ChangeDiskStoragePolicy(ctx context.Context, req ChangeDiskStoragePolicyRequest) (bool, error) { err := validators.ValidateRequest(req) @@ -28,7 +35,12 @@ func (d Disks) ChangeDiskStoragePolicy(ctx context.Context, req ChangeDiskStorag url := "/cloudapi/disks/change_disk_storage_policy" - res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, req) + wrappedReq := wrapperChangeDiskStoragePolicyRequest{ + ChangeDiskStoragePolicyRequest: req, + AsyncMode: false, + } + + res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, wrappedReq) if err != nil { return false, err } @@ -40,3 +52,30 @@ func (d Disks) ChangeDiskStoragePolicy(ctx context.Context, req ChangeDiskStorag return result, nil } + +// ChangeDiskStoragePolicyAsync changes storage policy for disk in async mode +func (d Disks) ChangeDiskStoragePolicyAsync(ctx context.Context, req ChangeDiskStoragePolicyRequest) (string, error) { + err := validators.ValidateRequest(req) + if err != nil { + return "", validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudapi/disks/change_disk_storage_policy" + + wrappedReq := wrapperChangeDiskStoragePolicyRequest{ + ChangeDiskStoragePolicyRequest: req, + AsyncMode: true, + } + + res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, wrappedReq) + if err != nil { + return "", err + } + + var result string + if err := json.Unmarshal(res, &result); err != nil { + return "", err + } + + return result, nil +} diff --git a/pkg/cloudapi/disks/delete.go b/pkg/cloudapi/disks/delete.go index 37f3123..67c429f 100644 --- a/pkg/cloudapi/disks/delete.go +++ b/pkg/cloudapi/disks/delete.go @@ -2,6 +2,7 @@ package disks import ( "context" + "encoding/json" "net/http" "strconv" @@ -23,6 +24,12 @@ type DeleteRequest struct { Permanently bool `url:"permanently,omitempty" json:"permanently,omitempty"` } +type wrapperDeleteRequest struct { + DeleteRequest + + AsyncMode bool `url:"async_mode" json:"async_mode"` +} + // Delete deletes disk by ID func (d Disks) Delete(ctx context.Context, req DeleteRequest) (bool, error) { err := validators.ValidateRequest(req) @@ -32,7 +39,12 @@ func (d Disks) Delete(ctx context.Context, req DeleteRequest) (bool, error) { url := "/cloudapi/disks/delete" - res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, req) + wrappedReq := wrapperDeleteRequest{ + DeleteRequest: req, + AsyncMode: false, + } + + res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, wrappedReq) if err != nil { return false, err } @@ -44,3 +56,30 @@ func (d Disks) Delete(ctx context.Context, req DeleteRequest) (bool, error) { return result, nil } + +// DeleteAsync deletes disk by ID in async mode +func (d Disks) DeleteAsync(ctx context.Context, req DeleteRequest) (string, error) { + err := validators.ValidateRequest(req) + if err != nil { + return "", validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudapi/disks/delete" + + wrappedReq := wrapperDeleteRequest{ + DeleteRequest: req, + AsyncMode: true, + } + + res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, wrappedReq) + if err != nil { + return "", err + } + + var result string + if err := json.Unmarshal(res, &result); err != nil { + return "", err + } + + return result, nil +} diff --git a/pkg/cloudapi/disks/delete_disks.go b/pkg/cloudapi/disks/delete_disks.go index 29ff230..1847ff9 100644 --- a/pkg/cloudapi/disks/delete_disks.go +++ b/pkg/cloudapi/disks/delete_disks.go @@ -2,6 +2,7 @@ package disks import ( "context" + "encoding/json" "net/http" "strconv" @@ -19,6 +20,12 @@ type DisksDeleteRequest struct { Permanently bool `url:"permanently,omitempty" json:"permanently,omitempty"` } +type wrapperDisksDeleteRequest struct { + DisksDeleteRequest + + AsyncMode bool `url:"async_mode" json:"async_mode"` +} + // DeleteDisks deletes multiple disks permanently func (d Disks) DeleteDisks(ctx context.Context, req DisksDeleteRequest) (bool, error) { err := validators.ValidateRequest(req) @@ -28,7 +35,12 @@ func (d Disks) DeleteDisks(ctx context.Context, req DisksDeleteRequest) (bool, e url := "/cloudapi/disks/deleteDisks" - res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, req) + wrappedReq := wrapperDisksDeleteRequest{ + DisksDeleteRequest: req, + AsyncMode: false, + } + + res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, wrappedReq) if err != nil { return false, err } @@ -40,3 +52,30 @@ func (d Disks) DeleteDisks(ctx context.Context, req DisksDeleteRequest) (bool, e return result, nil } + +// DeleteDisksAsync deletes multiple disks permanently in async mode +func (d Disks) DeleteDisksAsync(ctx context.Context, req DisksDeleteRequest) (string, error) { + err := validators.ValidateRequest(req) + if err != nil { + return "", validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudapi/disks/deleteDisks" + + wrappedReq := wrapperDisksDeleteRequest{ + DisksDeleteRequest: req, + AsyncMode: true, + } + + res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, wrappedReq) + if err != nil { + return "", err + } + + var result string + if err := json.Unmarshal(res, &result); err != nil { + return "", err + } + + return result, nil +} diff --git a/pkg/cloudapi/disks/ids.go b/pkg/cloudapi/disks/ids.go index a904b38..6b2e593 100644 --- a/pkg/cloudapi/disks/ids.go +++ b/pkg/cloudapi/disks/ids.go @@ -25,4 +25,4 @@ func (lsd ListSearchDisks) IDs() []uint64 { res = append(res, d.ID) } return res -} \ No newline at end of file +} diff --git a/pkg/cloudapi/disks/limitio.go b/pkg/cloudapi/disks/limitio.go index 0550dcc..1737c5f 100644 --- a/pkg/cloudapi/disks/limitio.go +++ b/pkg/cloudapi/disks/limitio.go @@ -2,6 +2,7 @@ package disks import ( "context" + "encoding/json" "net/http" "strconv" @@ -71,6 +72,12 @@ type LimitIORequest struct { SizeIOPSSec uint64 `url:"size_iops_sec,omitempty" json:"size_iops_sec,omitempty"` } +type wrapperLimitIORequest struct { + LimitIORequest + + AsyncMode bool `url:"async_mode" json:"async_mode"` +} + // LimitIO limit IO for a certain disk // total and read/write options are not allowed to be combined // see http://libvirt.org/formatdomain.html#elementsDisks iotune section for more details @@ -82,7 +89,12 @@ func (d Disks) LimitIO(ctx context.Context, req LimitIORequest) (bool, error) { url := "/cloudapi/disks/limitIO" - res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, req) + wrappedReq := wrapperLimitIORequest{ + LimitIORequest: req, + AsyncMode: false, + } + + res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, wrappedReq) if err != nil { return false, err } @@ -94,3 +106,32 @@ func (d Disks) LimitIO(ctx context.Context, req LimitIORequest) (bool, error) { return result, nil } + +// LimitIOAsync limits IO for a certain disk in async mode +// total and read/write options are not allowed to be combined +// see http://libvirt.org/formatdomain.html#elementsDisks iotune section for more details +func (d Disks) LimitIOAsync(ctx context.Context, req LimitIORequest) (string, error) { + err := validators.ValidateRequest(req) + if err != nil { + return "", validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudapi/disks/limitIO" + + wrappedReq := wrapperLimitIORequest{ + LimitIORequest: req, + AsyncMode: true, + } + + res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, wrappedReq) + if err != nil { + return "", err + } + + var result string + if err := json.Unmarshal(res, &result); err != nil { + return "", err + } + + return result, nil +} diff --git a/pkg/cloudapi/disks/rename.go b/pkg/cloudapi/disks/rename.go index cf9eda0..f30ce84 100644 --- a/pkg/cloudapi/disks/rename.go +++ b/pkg/cloudapi/disks/rename.go @@ -2,6 +2,7 @@ package disks import ( "context" + "encoding/json" "net/http" "strconv" @@ -19,6 +20,12 @@ type RenameRequest struct { Name string `url:"name" json:"name" validate:"required"` } +type wrapperRenameRequest struct { + RenameRequest + + AsyncMode bool `url:"async_mode" json:"async_mode"` +} + // Rename renames disk func (d Disks) Rename(ctx context.Context, req RenameRequest) (bool, error) { err := validators.ValidateRequest(req) @@ -28,7 +35,12 @@ func (d Disks) Rename(ctx context.Context, req RenameRequest) (bool, error) { url := "/cloudapi/disks/rename" - res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, req) + wrappedReq := wrapperRenameRequest{ + RenameRequest: req, + AsyncMode: false, + } + + res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, wrappedReq) if err != nil { return false, err } @@ -40,3 +52,30 @@ func (d Disks) Rename(ctx context.Context, req RenameRequest) (bool, error) { return result, nil } + +// RenameAsync renames disk in async mode +func (d Disks) RenameAsync(ctx context.Context, req RenameRequest) (string, error) { + err := validators.ValidateRequest(req) + if err != nil { + return "", validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudapi/disks/rename" + + wrappedReq := wrapperRenameRequest{ + RenameRequest: req, + AsyncMode: true, + } + + res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, wrappedReq) + if err != nil { + return "", err + } + + var result string + if err := json.Unmarshal(res, &result); err != nil { + return "", err + } + + return result, nil +} diff --git a/pkg/cloudapi/disks/replicate.go b/pkg/cloudapi/disks/replicate.go index 0af3af9..d4cadf2 100644 --- a/pkg/cloudapi/disks/replicate.go +++ b/pkg/cloudapi/disks/replicate.go @@ -2,6 +2,7 @@ package disks import ( "context" + "encoding/json" "net/http" "strconv" @@ -31,6 +32,12 @@ type ReplicateRequest struct { StoragePolicyID uint64 `url:"storage_policy_id" json:"storage_policy_id" validate:"required"` } +type wrapperReplicateRequest struct { + ReplicateRequest + + AsyncMode bool `url:"async_mode" json:"async_mode"` +} + // Replicate create an empty disk in chosen SEP and pool combination. // Starts replication between chosen disk and newly created disk // Note: only TATLIN type SEP are supported for replications between @@ -42,7 +49,12 @@ func (d Disks) Replicate(ctx context.Context, req ReplicateRequest) (uint64, err url := "/cloudapi/disks/replicate" - res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, req) + wrappedReq := wrapperReplicateRequest{ + ReplicateRequest: req, + AsyncMode: false, + } + + res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, wrappedReq) if err != nil { return 0, err } @@ -54,3 +66,32 @@ func (d Disks) Replicate(ctx context.Context, req ReplicateRequest) (uint64, err return result, nil } + +// ReplicateAsync creates an empty disk in chosen SEP and pool combination in async mode. +// Starts replication between chosen disk and newly created disk +// Note: only TATLIN type SEP are supported for replications between +func (d Disks) ReplicateAsync(ctx context.Context, req ReplicateRequest) (string, error) { + err := validators.ValidateRequest(req) + if err != nil { + return "", validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudapi/disks/replicate" + + wrappedReq := wrapperReplicateRequest{ + ReplicateRequest: req, + AsyncMode: true, + } + + res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, wrappedReq) + if err != nil { + return "", err + } + + var result string + if err := json.Unmarshal(res, &result); err != nil { + return "", err + } + + return result, nil +} diff --git a/pkg/cloudapi/disks/replication_resume.go b/pkg/cloudapi/disks/replication_resume.go index e0c205c..31c7b21 100644 --- a/pkg/cloudapi/disks/replication_resume.go +++ b/pkg/cloudapi/disks/replication_resume.go @@ -2,6 +2,7 @@ package disks import ( "context" + "encoding/json" "net/http" "strconv" @@ -15,6 +16,12 @@ type ReplicationResumeRequest struct { DiskID uint64 `url:"diskId" json:"diskId" validate:"required"` } +type wrapperReplicationResumeRequest struct { + ReplicationResumeRequest + + AsyncMode bool `url:"async_mode" json:"async_mode"` +} + // ReplicationResume resume suspended replication func (d Disks) ReplicationResume(ctx context.Context, req ReplicationResumeRequest) (bool, error) { err := validators.ValidateRequest(req) @@ -24,7 +31,12 @@ func (d Disks) ReplicationResume(ctx context.Context, req ReplicationResumeReque url := "/cloudapi/disks/replicationResume" - res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, req) + wrappedReq := wrapperReplicationResumeRequest{ + ReplicationResumeRequest: req, + AsyncMode: false, + } + + res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, wrappedReq) if err != nil { return false, err } @@ -36,3 +48,30 @@ func (d Disks) ReplicationResume(ctx context.Context, req ReplicationResumeReque return result, nil } + +// ReplicationResumeAsync resumes suspended replication in async mode +func (d Disks) ReplicationResumeAsync(ctx context.Context, req ReplicationResumeRequest) (string, error) { + err := validators.ValidateRequest(req) + if err != nil { + return "", validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudapi/disks/replicationResume" + + wrappedReq := wrapperReplicationResumeRequest{ + ReplicationResumeRequest: req, + AsyncMode: true, + } + + res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, wrappedReq) + if err != nil { + return "", err + } + + var result string + if err := json.Unmarshal(res, &result); err != nil { + return "", err + } + + return result, nil +} diff --git a/pkg/cloudapi/disks/replication_reverse.go b/pkg/cloudapi/disks/replication_reverse.go index 56cc96f..5cb9d86 100644 --- a/pkg/cloudapi/disks/replication_reverse.go +++ b/pkg/cloudapi/disks/replication_reverse.go @@ -2,6 +2,7 @@ package disks import ( "context" + "encoding/json" "net/http" "strconv" @@ -15,6 +16,12 @@ type ReplicationReverseRequest struct { DiskID uint64 `url:"diskId" json:"diskId" validate:"required"` } +type wrapperReplicationReverseRequest struct { + ReplicationReverseRequest + + AsyncMode bool `url:"async_mode" json:"async_mode"` +} + // ReplicationReverse change role between disks replications func (d Disks) ReplicationReverse(ctx context.Context, req ReplicationReverseRequest) (bool, error) { err := validators.ValidateRequest(req) @@ -24,7 +31,12 @@ func (d Disks) ReplicationReverse(ctx context.Context, req ReplicationReverseReq url := "/cloudapi/disks/replicationReverse" - res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, req) + wrappedReq := wrapperReplicationReverseRequest{ + ReplicationReverseRequest: req, + AsyncMode: false, + } + + res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, wrappedReq) if err != nil { return false, err } @@ -36,3 +48,30 @@ func (d Disks) ReplicationReverse(ctx context.Context, req ReplicationReverseReq return result, nil } + +// ReplicationReverseAsync changes role between disks replications in async mode +func (d Disks) ReplicationReverseAsync(ctx context.Context, req ReplicationReverseRequest) (string, error) { + err := validators.ValidateRequest(req) + if err != nil { + return "", validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudapi/disks/replicationReverse" + + wrappedReq := wrapperReplicationReverseRequest{ + ReplicationReverseRequest: req, + AsyncMode: true, + } + + res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, wrappedReq) + if err != nil { + return "", err + } + + var result string + if err := json.Unmarshal(res, &result); err != nil { + return "", err + } + + return result, nil +} diff --git a/pkg/cloudapi/disks/replication_start.go b/pkg/cloudapi/disks/replication_start.go index 6cda86c..516feb2 100644 --- a/pkg/cloudapi/disks/replication_start.go +++ b/pkg/cloudapi/disks/replication_start.go @@ -2,6 +2,7 @@ package disks import ( "context" + "encoding/json" "net/http" "strconv" @@ -19,6 +20,12 @@ type ReplicationStartRequest struct { TargetDiskID uint64 `url:"targetDiskId" json:"targetDiskId" validate:"required"` } +type wrapperReplicationStartRequest struct { + ReplicationStartRequest + + AsyncMode bool `url:"async_mode" json:"async_mode"` +} + // ReplicationStart starts replication between two chosen disks. It's required for both disks to have same size to avoid replication conflicts // Note: Source disk's SEP and target SEP supported only of TATLIN type. func (d Disks) ReplicationStart(ctx context.Context, req ReplicationStartRequest) (bool, error) { @@ -29,7 +36,12 @@ func (d Disks) ReplicationStart(ctx context.Context, req ReplicationStartRequest url := "/cloudapi/disks/replicationStart" - res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, req) + wrappedReq := wrapperReplicationStartRequest{ + ReplicationStartRequest: req, + AsyncMode: false, + } + + res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, wrappedReq) if err != nil { return false, err } @@ -41,3 +53,31 @@ func (d Disks) ReplicationStart(ctx context.Context, req ReplicationStartRequest return result, nil } + +// ReplicationStartAsync starts replication between two chosen disks in async mode. It's required for both disks to have same size to avoid replication conflicts +// Note: Source disk's SEP and target SEP supported only of TATLIN type. +func (d Disks) ReplicationStartAsync(ctx context.Context, req ReplicationStartRequest) (string, error) { + err := validators.ValidateRequest(req) + if err != nil { + return "", validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudapi/disks/replicationStart" + + wrappedReq := wrapperReplicationStartRequest{ + ReplicationStartRequest: req, + AsyncMode: true, + } + + res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, wrappedReq) + if err != nil { + return "", err + } + + var result string + if err := json.Unmarshal(res, &result); err != nil { + return "", err + } + + return result, nil +} diff --git a/pkg/cloudapi/disks/replication_stop.go b/pkg/cloudapi/disks/replication_stop.go index cd4b4fd..cff7173 100644 --- a/pkg/cloudapi/disks/replication_stop.go +++ b/pkg/cloudapi/disks/replication_stop.go @@ -2,6 +2,7 @@ package disks import ( "context" + "encoding/json" "net/http" "strconv" @@ -15,6 +16,12 @@ type ReplicationStopRequest struct { DiskID uint64 `url:"diskId" json:"diskId" validate:"required"` } +type wrapperReplicationStopRequest struct { + ReplicationStopRequest + + AsyncMode bool `url:"async_mode" json:"async_mode"` +} + // ReplicationStop remove replication between disks completely func (d Disks) ReplicationStop(ctx context.Context, req ReplicationStopRequest) (bool, error) { err := validators.ValidateRequest(req) @@ -24,7 +31,12 @@ func (d Disks) ReplicationStop(ctx context.Context, req ReplicationStopRequest) url := "/cloudapi/disks/replicationStop" - res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, req) + wrappedReq := wrapperReplicationStopRequest{ + ReplicationStopRequest: req, + AsyncMode: false, + } + + res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, wrappedReq) if err != nil { return false, err } @@ -36,3 +48,30 @@ func (d Disks) ReplicationStop(ctx context.Context, req ReplicationStopRequest) return result, nil } + +// ReplicationStopAsync removes replication between disks completely in async mode +func (d Disks) ReplicationStopAsync(ctx context.Context, req ReplicationStopRequest) (string, error) { + err := validators.ValidateRequest(req) + if err != nil { + return "", validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudapi/disks/replicationStop" + + wrappedReq := wrapperReplicationStopRequest{ + ReplicationStopRequest: req, + AsyncMode: true, + } + + res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, wrappedReq) + if err != nil { + return "", err + } + + var result string + if err := json.Unmarshal(res, &result); err != nil { + return "", err + } + + return result, nil +} diff --git a/pkg/cloudapi/disks/replication_suspend.go b/pkg/cloudapi/disks/replication_suspend.go index 607f226..1b2eedb 100644 --- a/pkg/cloudapi/disks/replication_suspend.go +++ b/pkg/cloudapi/disks/replication_suspend.go @@ -2,6 +2,7 @@ package disks import ( "context" + "encoding/json" "net/http" "strconv" @@ -15,6 +16,12 @@ type ReplicationSuspendRequest struct { DiskID uint64 `url:"diskId" json:"diskId" validate:"required"` } +type wrapperReplicationSuspendRequest struct { + ReplicationSuspendRequest + + AsyncMode bool `url:"async_mode" json:"async_mode"` +} + // ReplicationSuspend pause replication with possibility to resume from pause moment func (d Disks) ReplicationSuspend(ctx context.Context, req ReplicationSuspendRequest) (bool, error) { err := validators.ValidateRequest(req) @@ -24,7 +31,12 @@ func (d Disks) ReplicationSuspend(ctx context.Context, req ReplicationSuspendReq url := "/cloudapi/disks/replicationSuspend" - res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, req) + wrappedReq := wrapperReplicationSuspendRequest{ + ReplicationSuspendRequest: req, + AsyncMode: false, + } + + res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, wrappedReq) if err != nil { return false, err } @@ -36,3 +48,30 @@ func (d Disks) ReplicationSuspend(ctx context.Context, req ReplicationSuspendReq return result, nil } + +// ReplicationSuspendAsync pauses replication with possibility to resume from pause moment in async mode +func (d Disks) ReplicationSuspendAsync(ctx context.Context, req ReplicationSuspendRequest) (string, error) { + err := validators.ValidateRequest(req) + if err != nil { + return "", validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudapi/disks/replicationSuspend" + + wrappedReq := wrapperReplicationSuspendRequest{ + ReplicationSuspendRequest: req, + AsyncMode: true, + } + + res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, wrappedReq) + if err != nil { + return "", err + } + + var result string + if err := json.Unmarshal(res, &result); err != nil { + return "", err + } + + return result, nil +} diff --git a/pkg/cloudapi/disks/resize.go b/pkg/cloudapi/disks/resize.go index 5d538fe..c879c8e 100644 --- a/pkg/cloudapi/disks/resize.go +++ b/pkg/cloudapi/disks/resize.go @@ -2,6 +2,7 @@ package disks import ( "context" + "encoding/json" "net/http" "strconv" @@ -19,6 +20,12 @@ type ResizeRequest struct { Size uint64 `url:"size" json:"size" validate:"required"` } +type wrapperResizeRequest struct { + ResizeRequest + + AsyncMode bool `url:"async_mode" json:"async_mode"` +} + // Resize2 resize disk // Returns 200 if disk is resized online, else will return 202, // in that case please stop and start your machine after changing the disk size, for your changes to be reflected. @@ -31,7 +38,12 @@ func (d Disks) Resize2(ctx context.Context, req ResizeRequest) (bool, error) { url := "/cloudapi/disks/resize2" - res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, req) + wrappedReq := wrapperResizeRequest{ + ResizeRequest: req, + AsyncMode: false, + } + + res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, wrappedReq) if err != nil { return false, err } @@ -43,3 +55,33 @@ func (d Disks) Resize2(ctx context.Context, req ResizeRequest) (bool, error) { return result, nil } + +// Resize2Async resizes disk in async mode +// Returns 200 if disk is resized online, else will return 202, +// in that case please stop and start your machine after changing the disk size, for your changes to be reflected. +// This method will not be used for disks, assigned to "old" virtual machines. Only unassigned disks and disks, assigned with computes. +func (d Disks) Resize2Async(ctx context.Context, req ResizeRequest) (string, error) { + err := validators.ValidateRequest(req) + if err != nil { + return "", validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudapi/disks/resize2" + + wrappedReq := wrapperResizeRequest{ + ResizeRequest: req, + AsyncMode: true, + } + + res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, wrappedReq) + if err != nil { + return "", err + } + + var result string + if err := json.Unmarshal(res, &result); err != nil { + return "", err + } + + return result, nil +} diff --git a/pkg/cloudapi/disks/restore.go b/pkg/cloudapi/disks/restore.go index a5db0bd..c2f69c8 100644 --- a/pkg/cloudapi/disks/restore.go +++ b/pkg/cloudapi/disks/restore.go @@ -2,6 +2,7 @@ package disks import ( "context" + "encoding/json" "net/http" "strconv" @@ -15,6 +16,12 @@ type RestoreRequest struct { DiskID uint64 `url:"diskId" json:"diskId" validate:"required"` } +type wrapperRestoreRequest struct { + RestoreRequest + + AsyncMode bool `url:"async_mode" json:"async_mode"` +} + // Restore restores a deleted unattached disk from recycle bin func (d Disks) Restore(ctx context.Context, req RestoreRequest) (bool, error) { err := validators.ValidateRequest(req) @@ -24,7 +31,12 @@ func (d Disks) Restore(ctx context.Context, req RestoreRequest) (bool, error) { url := "/cloudapi/disks/restore" - res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, req) + wrappedReq := wrapperRestoreRequest{ + RestoreRequest: req, + AsyncMode: false, + } + + res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, wrappedReq) if err != nil { return false, err } @@ -36,3 +48,30 @@ func (d Disks) Restore(ctx context.Context, req RestoreRequest) (bool, error) { return result, nil } + +// RestoreAsync restores a deleted unattached disk from recycle bin in async mode +func (d Disks) RestoreAsync(ctx context.Context, req RestoreRequest) (string, error) { + err := validators.ValidateRequest(req) + if err != nil { + return "", validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudapi/disks/restore" + + wrappedReq := wrapperRestoreRequest{ + RestoreRequest: req, + AsyncMode: true, + } + + res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, wrappedReq) + if err != nil { + return "", err + } + + var result string + if err := json.Unmarshal(res, &result); err != nil { + return "", err + } + + return result, nil +} diff --git a/pkg/cloudapi/disks/share.go b/pkg/cloudapi/disks/share.go index 46ef253..8a7c52e 100644 --- a/pkg/cloudapi/disks/share.go +++ b/pkg/cloudapi/disks/share.go @@ -2,6 +2,7 @@ package disks import ( "context" + "encoding/json" "net/http" "strconv" @@ -15,6 +16,12 @@ type ShareRequest struct { DiskID uint64 `url:"diskId" json:"diskId" validate:"required"` } +type wrapperShareRequest struct { + ShareRequest + + AsyncMode bool `url:"async_mode" json:"async_mode"` +} + // Share shares data disk func (d Disks) Share(ctx context.Context, req ShareRequest) (bool, error) { err := validators.ValidateRequest(req) @@ -24,7 +31,12 @@ func (d Disks) Share(ctx context.Context, req ShareRequest) (bool, error) { url := "/cloudapi/disks/share" - res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, req) + wrappedReq := wrapperShareRequest{ + ShareRequest: req, + AsyncMode: false, + } + + res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, wrappedReq) if err != nil { return false, err } @@ -36,3 +48,30 @@ func (d Disks) Share(ctx context.Context, req ShareRequest) (bool, error) { return result, nil } + +// ShareAsync shares data disk in async mode +func (d Disks) ShareAsync(ctx context.Context, req ShareRequest) (string, error) { + err := validators.ValidateRequest(req) + if err != nil { + return "", validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudapi/disks/share" + + wrappedReq := wrapperShareRequest{ + ShareRequest: req, + AsyncMode: true, + } + + res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, wrappedReq) + if err != nil { + return "", err + } + + var result string + if err := json.Unmarshal(res, &result); err != nil { + return "", err + } + + return result, nil +} diff --git a/pkg/cloudapi/disks/snapshot_delete.go b/pkg/cloudapi/disks/snapshot_delete.go index 406904c..0c230e3 100644 --- a/pkg/cloudapi/disks/snapshot_delete.go +++ b/pkg/cloudapi/disks/snapshot_delete.go @@ -2,6 +2,7 @@ package disks import ( "context" + "encoding/json" "net/http" "strconv" @@ -19,6 +20,12 @@ type SnapshotDeleteRequest struct { Label string `url:"label" json:"label" validate:"required"` } +type wrapperSnapshotDeleteRequest struct { + SnapshotDeleteRequest + + AsyncMode bool `url:"async_mode" json:"async_mode"` +} + // SnapshotDelete deletes a snapshot func (d Disks) SnapshotDelete(ctx context.Context, req SnapshotDeleteRequest) (bool, error) { err := validators.ValidateRequest(req) @@ -28,7 +35,12 @@ func (d Disks) SnapshotDelete(ctx context.Context, req SnapshotDeleteRequest) (b url := "/cloudapi/disks/snapshotDelete" - res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, req) + wrappedReq := wrapperSnapshotDeleteRequest{ + SnapshotDeleteRequest: req, + AsyncMode: false, + } + + res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, wrappedReq) if err != nil { return false, err } @@ -40,3 +52,30 @@ func (d Disks) SnapshotDelete(ctx context.Context, req SnapshotDeleteRequest) (b return result, nil } + +// SnapshotDeleteAsync deletes a snapshot in async mode +func (d Disks) SnapshotDeleteAsync(ctx context.Context, req SnapshotDeleteRequest) (string, error) { + err := validators.ValidateRequest(req) + if err != nil { + return "", validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudapi/disks/snapshotDelete" + + wrappedReq := wrapperSnapshotDeleteRequest{ + SnapshotDeleteRequest: req, + AsyncMode: true, + } + + res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, wrappedReq) + if err != nil { + return "", err + } + + var result string + if err := json.Unmarshal(res, &result); err != nil { + return "", err + } + + return result, nil +} diff --git a/pkg/cloudapi/disks/snapshot_rollback.go b/pkg/cloudapi/disks/snapshot_rollback.go index 44bf578..1b07a1e 100644 --- a/pkg/cloudapi/disks/snapshot_rollback.go +++ b/pkg/cloudapi/disks/snapshot_rollback.go @@ -2,6 +2,7 @@ package disks import ( "context" + "encoding/json" "net/http" "strconv" @@ -23,6 +24,12 @@ type SnapshotRollbackRequest struct { TimeStamp uint64 `url:"timestamp,omitempty" json:"timestamp,omitempty"` } +type wrapperSnapshotRollbackRequest struct { + SnapshotRollbackRequest + + AsyncMode bool `url:"async_mode" json:"async_mode"` +} + // SnapshotRollback rollbacks an individual disk snapshot func (d Disks) SnapshotRollback(ctx context.Context, req SnapshotRollbackRequest) (bool, error) { err := validators.ValidateRequest(req) @@ -32,7 +39,12 @@ func (d Disks) SnapshotRollback(ctx context.Context, req SnapshotRollbackRequest url := "/cloudapi/disks/snapshotRollback" - res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, req) + wrappedReq := wrapperSnapshotRollbackRequest{ + SnapshotRollbackRequest: req, + AsyncMode: false, + } + + res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, wrappedReq) if err != nil { return false, err } @@ -43,5 +55,31 @@ func (d Disks) SnapshotRollback(ctx context.Context, req SnapshotRollbackRequest } return result, nil - +} + +// SnapshotRollbackAsync rollbacks an individual disk snapshot in async mode +func (d Disks) SnapshotRollbackAsync(ctx context.Context, req SnapshotRollbackRequest) (string, error) { + err := validators.ValidateRequest(req) + if err != nil { + return "", validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudapi/disks/snapshotRollback" + + wrappedReq := wrapperSnapshotRollbackRequest{ + SnapshotRollbackRequest: req, + AsyncMode: true, + } + + res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, wrappedReq) + if err != nil { + return "", err + } + + var result string + if err := json.Unmarshal(res, &result); err != nil { + return "", err + } + + return result, nil } diff --git a/pkg/cloudapi/disks/unshare.go b/pkg/cloudapi/disks/unshare.go index 94c5893..9a46478 100644 --- a/pkg/cloudapi/disks/unshare.go +++ b/pkg/cloudapi/disks/unshare.go @@ -2,6 +2,7 @@ package disks import ( "context" + "encoding/json" "net/http" "strconv" @@ -15,6 +16,12 @@ type UnshareRequest struct { DiskID uint64 `url:"diskId" json:"diskId" validate:"required"` } +type wrapperUnshareRequest struct { + UnshareRequest + + AsyncMode bool `url:"async_mode" json:"async_mode"` +} + // Unshare unshares data disk func (d Disks) Unshare(ctx context.Context, req UnshareRequest) (bool, error) { err := validators.ValidateRequest(req) @@ -24,7 +31,12 @@ func (d Disks) Unshare(ctx context.Context, req UnshareRequest) (bool, error) { url := "/cloudapi/disks/unshare" - res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, req) + wrappedReq := wrapperUnshareRequest{ + UnshareRequest: req, + AsyncMode: false, + } + + res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, wrappedReq) if err != nil { return false, err } @@ -36,3 +48,30 @@ func (d Disks) Unshare(ctx context.Context, req UnshareRequest) (bool, error) { return result, nil } + +// UnshareAsync unshares data disk in async mode +func (d Disks) UnshareAsync(ctx context.Context, req UnshareRequest) (string, error) { + err := validators.ValidateRequest(req) + if err != nil { + return "", validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudapi/disks/unshare" + + wrappedReq := wrapperUnshareRequest{ + UnshareRequest: req, + AsyncMode: true, + } + + res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, wrappedReq) + if err != nil { + return "", err + } + + var result string + if err := json.Unmarshal(res, &result); err != nil { + return "", err + } + + return result, nil +} diff --git a/pkg/cloudapi/extnet/get_reserved_ip.go b/pkg/cloudapi/extnet/get_reserved_ip.go index 2cea1a3..e6683fd 100644 --- a/pkg/cloudapi/extnet/get_reserved_ip.go +++ b/pkg/cloudapi/extnet/get_reserved_ip.go @@ -17,6 +17,11 @@ type GetReservedIP struct { // Field for specifying the ID of extnet whose reservation information we want to receive // Required: false ExtNetID uint64 `url:"extnetId,omitempty" json:"extnetId,omitempty"` + + // Flag indicating whether the reserved IP can be auto-assigned + // Required: false + // Default: null + AutoAssignable interface{} `url:"auto_assignable,omitempty" json:"auto_assignable,omitempty" validate:"omitempty,isBool"` } // GetReservedIP gets information about reserved address or address poll as a slice of RecordReservedIP struct diff --git a/pkg/cloudapi/extnet/models.go b/pkg/cloudapi/extnet/models.go index a525908..4474d60 100644 --- a/pkg/cloudapi/extnet/models.go +++ b/pkg/cloudapi/extnet/models.go @@ -269,12 +269,13 @@ type RecordReservedIP struct { } type Reservations struct { - AccountID int `json:"account_id"` - ClientType string `json:"clientType"` - DomainName string `json:"domainname"` - Hostname string `json:"hostname"` - IP string `json:"ip"` - Mac string `json:"mac"` - Type string `json:"type"` - VMID int `json:"vmId"` + AccountID int `json:"account_id"` + ClientType string `json:"clientType"` + DomainName string `json:"domainname"` + Hostname string `json:"hostname"` + IP string `json:"ip"` + Mac string `json:"mac"` + Type string `json:"type"` + VMID int `json:"vmId"` + AutoAssignable bool `json:"auto_assignable"` } diff --git a/pkg/cloudapi/kvmx86/create.go b/pkg/cloudapi/kvmx86/create.go index 6cbdbb4..b97e18c 100644 --- a/pkg/cloudapi/kvmx86/create.go +++ b/pkg/cloudapi/kvmx86/create.go @@ -247,6 +247,11 @@ type CreateRequest struct { // Required: false // Default: reset WatchdogAction string `url:"watchdog_action,omitempty" json:"watchdog_action,omitempty" validate:"omitempty,watchdogAction"` + + // Memory balloon mode. One of ["auto","legacy","none"] + // Required: false + // Default: "auto" + MemoryBalloonMode string `url:"memory_balloon_mode,omitempty" json:"memory_balloon_mode,omitempty" validate:"omitempty,memoryBalloonMode"` } // GetRAM returns RAM field values diff --git a/pkg/cloudapi/kvmx86/create_blank.go b/pkg/cloudapi/kvmx86/create_blank.go index e29b413..3fe66fc 100644 --- a/pkg/cloudapi/kvmx86/create_blank.go +++ b/pkg/cloudapi/kvmx86/create_blank.go @@ -129,6 +129,11 @@ type CreateBlankRequest struct { // Required: false // Default: reset WatchdogAction string `url:"watchdog_action,omitempty" json:"watchdog_action,omitempty" validate:"omitempty,watchdogAction"` + + // Memory balloon mode. One of ["auto","legacy","none"] + // Required: false + // Default: "auto" + MemoryBalloonMode string `url:"memory_balloon_mode,omitempty" json:"memory_balloon_mode,omitempty" validate:"omitempty,memoryBalloonMode"` } // GetRAM returns RAM field values diff --git a/pkg/cloudapi/pcidevice/list.go b/pkg/cloudapi/pcidevice/list.go index 1975eb1..f702593 100644 --- a/pkg/cloudapi/pcidevice/list.go +++ b/pkg/cloudapi/pcidevice/list.go @@ -22,9 +22,9 @@ type ListRequest struct { // Required: false Name string `url:"name,omitempty" json:"name,omitempty"` - // Find by rgId + // Find by account ID // Required: false - RGID uint64 `url:"rgId,omitempty" json:"rgId,omitempty"` + AccountID uint64 `url:"account_id,omitempty" json:"account_id,omitempty"` // Find by status // Required: false diff --git a/pkg/cloudapi/pcidevice/models.go b/pkg/cloudapi/pcidevice/models.go index 61c8a83..1d64524 100644 --- a/pkg/cloudapi/pcidevice/models.go +++ b/pkg/cloudapi/pcidevice/models.go @@ -26,8 +26,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/qospolicy/filter.go b/pkg/cloudapi/qospolicy/filter.go index ec368d8..20b3c8d 100644 --- a/pkg/cloudapi/qospolicy/filter.go +++ b/pkg/cloudapi/qospolicy/filter.go @@ -45,24 +45,6 @@ func (lqp ListQoSPolicies) FilterByDescription(description string) ListQoSPolici 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 diff --git a/pkg/cloudapi/qospolicy/filter_test.go b/pkg/cloudapi/qospolicy/filter_test.go index cf5ef72..3513350 100644 --- a/pkg/cloudapi/qospolicy/filter_test.go +++ b/pkg/cloudapi/qospolicy/filter_test.go @@ -10,7 +10,6 @@ var qosPolicies = ListQoSPolicies{ Name: "qos1", Description: "some desc", Status: "ENABLED", - CreatedBy: "user", }, { ID: 3, @@ -18,7 +17,6 @@ var qosPolicies = ListQoSPolicies{ Name: "qos3", Description: "some desc", Status: "ENABLED", - CreatedBy: "anotheruser", }, { ID: 5, @@ -26,8 +24,6 @@ var qosPolicies = ListQoSPolicies{ Name: "qos5", Description: "some other desc", Status: "DISABLED", - CreatedBy: "anotheruser", - UpdatedBy: "user", }, }, EntryCount: 3, @@ -74,24 +70,3 @@ func TestFilterByStatus(t *testing.T) { 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/models.go b/pkg/cloudapi/qospolicy/models.go index fc17c8f..48b8017 100644 --- a/pkg/cloudapi/qospolicy/models.go +++ b/pkg/cloudapi/qospolicy/models.go @@ -27,18 +27,6 @@ type ItemQoSPolicy struct { // 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"` } @@ -62,18 +50,6 @@ type RecordQoSPolicy struct { // 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"` } diff --git a/pkg/cloudapi/qospolicy/sorting.go b/pkg/cloudapi/qospolicy/sorting.go deleted file mode 100644 index aa89049..0000000 --- a/pkg/cloudapi/qospolicy/sorting.go +++ /dev/null @@ -1,39 +0,0 @@ -package qospolicy - -import "sort" - -// SortByCreatedAt sorts ListQosPolicies by the CreatedAt field in ascending order -// If inverse param is set to true, the order is reversed -func (lqp ListQoSPolicies) SortByCreatedAt(inverse bool) ListQoSPolicies { - if len(lqp.Data) < 2 { - return lqp - } - - sort.Slice(lqp.Data, func(i, j int) bool { - if inverse { - return lqp.Data[i].CreatedAt > lqp.Data[j].CreatedAt - } - - return lqp.Data[i].CreatedAt < lqp.Data[j].CreatedAt - }) - - return lqp -} - -// SortByUpdatedAt sorts ListQosPolicies by the UpdatedAt field in ascending order -// If inverse param is set to true, the order is reversed -func (lqp ListQoSPolicies) SortByUpdatedAt(inverse bool) ListQoSPolicies { - if len(lqp.Data) < 2 { - return lqp - } - - sort.Slice(lqp.Data, func(i, j int) bool { - if inverse { - return lqp.Data[i].UpdatedAt > lqp.Data[j].UpdatedAt - } - - return lqp.Data[i].UpdatedAt < lqp.Data[j].UpdatedAt - }) - - return lqp -} diff --git a/pkg/cloudapi/rg/access_grant.go b/pkg/cloudapi/rg/access_grant.go index 5e731c3..4996e8f 100644 --- a/pkg/cloudapi/rg/access_grant.go +++ b/pkg/cloudapi/rg/access_grant.go @@ -27,6 +27,8 @@ type AccessGrantRequest struct { } // AccessGrant grants user or group access to the resource group as specified +// +// Deprecated: will be removed in SDK v1.17 func (r RG) AccessGrant(ctx context.Context, req AccessGrantRequest) (bool, error) { err := validators.ValidateRequest(req) if err != nil { diff --git a/pkg/cloudapi/rg/access_revoke.go b/pkg/cloudapi/rg/access_revoke.go index 792ef3f..e92f8d4 100644 --- a/pkg/cloudapi/rg/access_revoke.go +++ b/pkg/cloudapi/rg/access_revoke.go @@ -20,6 +20,8 @@ type AccessRevokeRequest struct { } // AccessRevoke revokes specified user or group access from the resource group +// +// Deprecated: will be removed in SDK v1.17 func (r RG) AccessRevoke(ctx context.Context, req AccessRevokeRequest) (bool, error) { err := validators.ValidateRequest(req) if err != nil { diff --git a/pkg/cloudapi/rg/add_acl_access.go b/pkg/cloudapi/rg/add_acl_access.go new file mode 100644 index 0000000..bf7cb31 --- /dev/null +++ b/pkg/cloudapi/rg/add_acl_access.go @@ -0,0 +1,40 @@ +package rg + +import ( + "context" + "net/http" + "strconv" + + "repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants" + "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" +) + +// AddACLAccessRequest adds ACL access to a resource group +type AddACLAccessRequest struct { + ID uint64 `url:"id" json:"id" validate:"required"` + AccessType string `url:"accesstype" json:"accesstype" validate:"required"` + Usernames []string `url:"usernames,omitempty" json:"usernames,omitempty"` + APIAccesses []uint64 `url:"apiaccesses,omitempty" json:"apiaccesses,omitempty"` +} + +// AddACLAccess adds ACL access to a resource group. +func (r RG) AddACLAccess(ctx context.Context, req AddACLAccessRequest) (bool, error) { + err := validators.ValidateRequest(req) + if err != nil { + return false, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudapi/rg/add_acl_access" + + res, err := r.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req) + if err != nil { + return false, err + } + + result, err := strconv.ParseBool(string(res)) + if err != nil { + return false, err + } + + return result, nil +} diff --git a/pkg/cloudapi/rg/del_acl_access.go b/pkg/cloudapi/rg/del_acl_access.go new file mode 100644 index 0000000..1c01c86 --- /dev/null +++ b/pkg/cloudapi/rg/del_acl_access.go @@ -0,0 +1,39 @@ +package rg + +import ( + "context" + "net/http" + "strconv" + + "repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants" + "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" +) + +// DeleteACLAccessRequest deletes ACL access from a resource group +type DeleteACLAccessRequest struct { + ID uint64 `url:"id" json:"id" validate:"required"` + Usernames []string `url:"usernames,omitempty" json:"usernames,omitempty"` + APIAccesses []uint64 `url:"apiaccesses,omitempty" json:"apiaccesses,omitempty"` +} + +// DeleteACLAccess deletes ACL access from a resource group. +func (r RG) DeleteACLAccess(ctx context.Context, req DeleteACLAccessRequest) (bool, error) { + err := validators.ValidateRequest(req) + if err != nil { + return false, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudapi/rg/del_acl_access" + + res, err := r.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req) + if err != nil { + return false, err + } + + result, err := strconv.ParseBool(string(res)) + if err != nil { + return false, err + } + + return result, nil +} diff --git a/pkg/cloudapi/rg/get_acl_access.go b/pkg/cloudapi/rg/get_acl_access.go new file mode 100644 index 0000000..f6a109e --- /dev/null +++ b/pkg/cloudapi/rg/get_acl_access.go @@ -0,0 +1,44 @@ +package rg + +import ( + "context" + "encoding/json" + "net/http" + + "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" +) + +// GetACLAccessRequest struct to get detailed information about ACL account in a resource group +type GetACLAccessRequest struct { + ID uint64 `url:"id" json:"id" validate:"required"` +} + +// Get gets current configuration of the ACL access in a resource group as a RecordRGACLAccess struct +func (r RG) GetACLAccess(ctx context.Context, req GetACLAccessRequest) (*RecordRGACLAccess, error) { + res, err := r.GetACLAccessRaw(ctx, req) + if err != nil { + return nil, err + } + + info := RecordRGACLAccess{} + + err = json.Unmarshal(res, &info) + if err != nil { + return nil, err + } + + return &info, nil +} + +// GetACLAccessRaw gets current configuration of the ACL access in a resource group as an array of bytes +func (r RG) GetACLAccessRaw(ctx context.Context, req GetACLAccessRequest) ([]byte, error) { + err := validators.ValidateRequest(req) + if err != nil { + return nil, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudapi/rg/get_acl_access" + + res, err := r.client.DecortApiCall(ctx, http.MethodPost, url, req) + return res, err +} diff --git a/pkg/cloudapi/rg/models.go b/pkg/cloudapi/rg/models.go index 4988e95..5cfe453 100644 --- a/pkg/cloudapi/rg/models.go +++ b/pkg/cloudapi/rg/models.go @@ -159,6 +159,44 @@ type RecordResourceGroup struct { Computes []uint64 `json:"vms"` } +// Detailed information about ACL Access in a resource group +type RecordRGACLAccess struct { + // Data + Data DataACL `json:"data"` + + // Entry count + EntryCount uint64 `json:"entryCount"` +} + +// Data ACL +type DataACL struct { + // RG ACL list + RGACLList []RGACL `json:"rgACL"` + + // Account ACL list + AccountACL []AccountACL `json:"accountACL"` +} + +// RG ACL info +type RGACL struct { + Right string `json:"right"` + GUID string `json:"guid"` + UserGroupID string `json:"userGroupId"` + Status string `json:"status"` + Type string `json:"type"` + Explicit bool `json:"explicit"` +} + +// Account ACL info +type AccountACL struct { + Right string `json:"right"` + GUID string `json:"guid"` + UserGroupID string `json:"userGroupId"` + Status string `json:"status"` + Type string `json:"type"` + Explicit bool `json:"explicit"` +} + // Main information about resource group type ItemResourceGroup struct { // diff --git a/pkg/cloudapi/rg/update_acl_access.go b/pkg/cloudapi/rg/update_acl_access.go new file mode 100644 index 0000000..c03aa34 --- /dev/null +++ b/pkg/cloudapi/rg/update_acl_access.go @@ -0,0 +1,40 @@ +package rg + +import ( + "context" + "net/http" + "strconv" + + "repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants" + "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" +) + +// UpdateACLAccessRequest updates ACL access in a resource group +type UpdateACLAccessRequest struct { + ID uint64 `url:"id" json:"id" validate:"required"` + AccessType string `url:"accesstype" json:"accesstype" validate:"required"` + Usernames []string `url:"usernames,omitempty" json:"usernames,omitempty"` + APIAccesses []uint64 `url:"apiaccesses,omitempty" json:"apiaccesses,omitempty"` +} + +// UpdateACLAccess updates ACL access in a resource group. +func (r RG) UpdateACLAccess(ctx context.Context, req UpdateACLAccessRequest) (bool, error) { + err := validators.ValidateRequest(req) + if err != nil { + return false, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudapi/rg/update_acl_access" + + res, err := r.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req) + if err != nil { + return false, err + } + + result, err := strconv.ParseBool(string(res)) + if err != nil { + return false, err + } + + return result, nil +} diff --git a/pkg/cloudapi/vgpu/models.go b/pkg/cloudapi/vgpu/models.go index 8c96a9f..4c9c11e 100644 --- a/pkg/cloudapi/vgpu/models.go +++ b/pkg/cloudapi/vgpu/models.go @@ -46,6 +46,9 @@ type ItemVGPU struct { // Profile Reference ProfileReference string `json:"profile_reference"` + // Profile Name + ProfileName string `json:"profile_name"` + // Split Mode SplitMode string `json:"split_mode"` diff --git a/pkg/cloudbroker/account/add_acl_access.go b/pkg/cloudbroker/account/add_acl_access.go new file mode 100644 index 0000000..c39832d --- /dev/null +++ b/pkg/cloudbroker/account/add_acl_access.go @@ -0,0 +1,40 @@ +package account + +import ( + "context" + "net/http" + "strconv" + + "repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants" + "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" +) + +// AddACLAccessRequest adds ACL access to an account +type AddACLAccessRequest struct { + ID uint64 `url:"id" json:"id" validate:"required"` + AccessType string `url:"accesstype" json:"accesstype" validate:"required"` + Usernames []string `url:"usernames,omitempty" json:"usernames,omitempty"` + APIAccesses []uint64 `url:"apiaccesses,omitempty" json:"apiaccesses,omitempty"` +} + +// AddACLAccess adds ACL access to an account. +func (a Account) AddACLAccess(ctx context.Context, req AddACLAccessRequest) (bool, error) { + err := validators.ValidateRequest(req) + if err != nil { + return false, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/account/add_acl_access" + + res, err := a.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req) + if err != nil { + return false, err + } + + result, err := strconv.ParseBool(string(res)) + if err != nil { + return false, err + } + + return result, nil +} diff --git a/pkg/cloudbroker/account/add_user.go b/pkg/cloudbroker/account/add_user.go index 4da1f89..00528b6 100644 --- a/pkg/cloudbroker/account/add_user.go +++ b/pkg/cloudbroker/account/add_user.go @@ -27,6 +27,8 @@ type AddUserRequest struct { } // AddUser gives a user access rights. +// +// Deprecated: will be removed in SDK v1.17 func (a Account) AddUser(ctx context.Context, req AddUserRequest) (bool, error) { err := validators.ValidateRequest(req) if err != nil { diff --git a/pkg/cloudbroker/account/del_acl_access.go b/pkg/cloudbroker/account/del_acl_access.go new file mode 100644 index 0000000..da36555 --- /dev/null +++ b/pkg/cloudbroker/account/del_acl_access.go @@ -0,0 +1,39 @@ +package account + +import ( + "context" + "net/http" + "strconv" + + "repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants" + "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" +) + +// DelACLAccessRequest deletes ACL access from an account +type DelACLAccessRequest struct { + ID uint64 `url:"id" json:"id" validate:"required"` + Usernames []string `url:"usernames,omitempty" json:"usernames,omitempty"` + APIAccesses []uint64 `url:"apiaccesses,omitempty" json:"apiaccesses,omitempty"` +} + +// DelACLAccess deletes ACL access from an account. +func (a Account) DeleteACLAccess(ctx context.Context, req DelACLAccessRequest) (bool, error) { + err := validators.ValidateRequest(req) + if err != nil { + return false, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/account/del_acl_access" + + res, err := a.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req) + if err != nil { + return false, err + } + + result, err := strconv.ParseBool(string(res)) + if err != nil { + return false, err + } + + return result, nil +} diff --git a/pkg/cloudbroker/account/delete_user.go b/pkg/cloudbroker/account/delete_user.go index 73180df..6679570 100644 --- a/pkg/cloudbroker/account/delete_user.go +++ b/pkg/cloudbroker/account/delete_user.go @@ -20,6 +20,8 @@ type DeleteUserRequest struct { } // DeleteUser revokes user access from the account +// +// Deprecated: will be removed in SDK v1.17 func (a Account) DeleteUser(ctx context.Context, req DeleteUserRequest) (bool, error) { err := validators.ValidateRequest(req) if err != nil { diff --git a/pkg/cloudbroker/account/update_acl_access.go b/pkg/cloudbroker/account/update_acl_access.go new file mode 100644 index 0000000..5bb7fd0 --- /dev/null +++ b/pkg/cloudbroker/account/update_acl_access.go @@ -0,0 +1,40 @@ +package account + +import ( + "context" + "net/http" + "strconv" + + "repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants" + "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" +) + +// UpdateACLAccessRequest updates ACL access in an account +type UpdateACLAccessRequest struct { + ID uint64 `url:"id" json:"id" validate:"required"` + AccessType string `url:"accesstype" json:"accesstype" validate:"required"` + Usernames []string `url:"usernames,omitempty" json:"usernames,omitempty"` + APIAccesses []uint64 `url:"apiaccesses,omitempty" json:"apiaccesses,omitempty"` +} + +// UpdateACLAccess updates ACL access in an account. +func (a Account) UpdateACLAccess(ctx context.Context, req UpdateACLAccessRequest) (bool, error) { + err := validators.ValidateRequest(req) + if err != nil { + return false, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/account/update_acl_access" + + res, err := a.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req) + if err != nil { + return false, err + } + + result, err := strconv.ParseBool(string(res)) + if err != nil { + return false, err + } + + return result, nil +} diff --git a/pkg/cloudbroker/account/update_user.go b/pkg/cloudbroker/account/update_user.go index 0626145..a07decf 100644 --- a/pkg/cloudbroker/account/update_user.go +++ b/pkg/cloudbroker/account/update_user.go @@ -27,6 +27,8 @@ type UpdateUserRequest struct { } // UpdateUser updates user access rights +// +// Deprecated: will be removed in SDK v1.17 func (a Account) UpdateUser(ctx context.Context, req UpdateUserRequest) (bool, error) { err := validators.ValidateRequest(req) if err != nil { diff --git a/pkg/cloudbroker/backup/abort_disks_backup.go b/pkg/cloudbroker/backup/abort_disks_backup.go new file mode 100644 index 0000000..4aa71ec --- /dev/null +++ b/pkg/cloudbroker/backup/abort_disks_backup.go @@ -0,0 +1,38 @@ +package backup + +import ( + "context" + "net/http" + "strconv" + + "repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants" + "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" +) + +type AbortDisksBackupRequest struct { + // Compute ID + // Required: true + ComputeID uint64 `url:"compute_id" json:"compute_id" validate:"required"` +} + +// AbortDisksBackup aborts disks backup +func (b Backup) AbortDisksBackup(ctx context.Context, req AbortDisksBackupRequest) (bool, error) { + err := validators.ValidateRequest(req) + if err != nil { + return false, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/backup/abort_disks_backup" + + res, err := b.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req) + if err != nil { + return false, err + } + + result, err := strconv.ParseBool(string(res)) + if err != nil { + return false, err + } + + return result, nil +} diff --git a/pkg/cloudbroker/backup/backup_disks_with_speed.go b/pkg/cloudbroker/backup/backup_disks_with_speed.go new file mode 100644 index 0000000..f1dc34a --- /dev/null +++ b/pkg/cloudbroker/backup/backup_disks_with_speed.go @@ -0,0 +1,40 @@ +package backup + +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 BackupDisksWithSpeedRequest struct { + // Compute ID + // Required: true + ComputeID uint64 `url:"compute_id" json:"compute_id" validate:"required"` +} + +// Get backup disk list and speeds for a compute +func (b Backup) BackupDisksWithSpeed(ctx context.Context, req BackupDisksWithSpeedRequest) (ListDisksWithSpeed, error) { + err := validators.ValidateRequest(req) + if err != nil { + return nil, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/backup/backup_disks_with_speed" + + res, err := b.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req) + if err != nil { + return nil, err + } + + result := make(ListDisksWithSpeed, 0) + + err = json.Unmarshal(res, &result) + if err != nil { + return nil, err + } + + return result, nil +} diff --git a/pkg/cloudbroker/backup/create_disk_backup.go b/pkg/cloudbroker/backup/create_disk_backup.go index 14b5fc8..5f294f4 100644 --- a/pkg/cloudbroker/backup/create_disk_backup.go +++ b/pkg/cloudbroker/backup/create_disk_backup.go @@ -22,6 +22,10 @@ type CreateDiskBackupRequest struct { // Backup path // Required: true BackupPath string `url:"backupPath" json:"backupPath" validate:"required"` + + // Backup speed in Mb/s. 0 means no limits. Applicable only for STARTED computes + // Required: false + Speed uint64 `url:"speed,omitempty" json:"speed,omitempty"` } type wrapperCreateDiskBackupRequest struct { diff --git a/pkg/cloudbroker/backup/create_disks_backup.go b/pkg/cloudbroker/backup/create_disks_backup.go index 843bc37..e14f100 100644 --- a/pkg/cloudbroker/backup/create_disks_backup.go +++ b/pkg/cloudbroker/backup/create_disks_backup.go @@ -15,6 +15,10 @@ type Disk struct { // Backup path BackupPath string `url:"backupPath" json:"backupPath" validate:"required"` + + // Backup speed in Mb/s. 0 means no limits. Applicable only for STARTED computes + // Required: false + Speed uint64 `url:"speed,omitempty" json:"speed,omitempty"` } // CreateDisksBackupRequest struct for creating disks backup diff --git a/pkg/cloudbroker/backup/info.go b/pkg/cloudbroker/backup/info.go new file mode 100644 index 0000000..bcf700a --- /dev/null +++ b/pkg/cloudbroker/backup/info.go @@ -0,0 +1,40 @@ +package backup + +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 InfoRequest struct { + // Compute ID + // Required: true + ComputeID uint64 `url:"compute_id" json:"compute_id" validate:"required"` +} + +// Information about all backups running on the machine +func (b Backup) Info(ctx context.Context, req InfoRequest) (*TotalBackupsInfo, error) { + err := validators.ValidateRequest(req) + if err != nil { + return nil, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/backup/info" + + res, err := b.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req) + if err != nil { + return nil, err + } + + result := TotalBackupsInfo{} + + err = json.Unmarshal(res, &result) + if err != nil { + return nil, err + } + + return &result, nil +} diff --git a/pkg/cloudbroker/backup/models.go b/pkg/cloudbroker/backup/models.go index 7553740..fd754fe 100644 --- a/pkg/cloudbroker/backup/models.go +++ b/pkg/cloudbroker/backup/models.go @@ -29,3 +29,53 @@ type InfoRestoredDisk struct { // RestoreDisksFromFile response type ListInfoRestoredDisk []InfoRestoredDisk + +// Main info about all backups running on the machine +type TotalBackupsInfo struct { + // Backup type + Type uint64 `json:"type"` + + // Time elapsed, ms + TimeElapsedMs uint64 `json:"time_elapsed_ms"` + + // Time remaining, ms + TimeRemainingMs uint64 `json:"time_remaining_ms"` + + // Total data size, bytes + DataTotalBytes uint64 `json:"data_total_bytes"` + + // Processed data size, bytes + DataProcessedBytes uint64 `json:"data_processed_bytes"` + + // Remaining data size, bytes + DataRemainingBytes uint64 `json:"data_remaining_bytes"` + + // Total memory size, bytes + MemTotalBytes uint64 `json:"mem_total_bytes"` + + // Processed memory size, bytes + MemProcessedBytes uint64 `json:"mem_processed_bytes"` + + // Remaining memory size, bytes + MemRemainingBytes uint64 `json:"mem_remaining_bytes"` + + // Total file size, bytes + FileTotalBytes uint64 `json:"file_total_bytes"` + + // Processed file size, bytes + FileProcessedBytes uint64 `json:"file_processed_bytes"` + + // Remaining file size, bytes + FileRemainingBytes uint64 `json:"file_remaining_bytes"` +} + +// List of disk names and backup speed +type ListDisksWithSpeed []DiskWithSpeed + +type DiskWithSpeed struct { + // Device name + Device string `json:"device"` + + // Backup speed limit in MB/s; 0 means unlimited + Speed uint64 `json:"speed"` +} diff --git a/pkg/cloudbroker/backup/set_backup_speed.go b/pkg/cloudbroker/backup/set_backup_speed.go new file mode 100644 index 0000000..c6f160a --- /dev/null +++ b/pkg/cloudbroker/backup/set_backup_speed.go @@ -0,0 +1,46 @@ +package backup + +import ( + "context" + "net/http" + "strconv" + + "repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants" + "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" +) + +type SetBackupSpeedRequest struct { + // Compute ID + // Required: true + ComputeID uint64 `url:"compute_id" json:"compute_id" validate:"required"` + + // Device to set backup speed ongit + // Required: true + Device string `url:"device" json:"device" validate:"required"` + + // New backup speed in Mb/s. 0 means no limits + // Required: true + Speed uint64 `url:"speed" json:"speed" validate:"required"` +} + +// Set speed limit for device backup on ruining machine +func (b Backup) SetBackupSpeed(ctx context.Context, req SetBackupSpeedRequest) (bool, error) { + err := validators.ValidateRequest(req) + if err != nil { + return false, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/backup/set_backup_speed" + + res, err := b.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req) + if err != nil { + return false, err + } + + result, err := strconv.ParseBool(string(res)) + if err != nil { + return false, err + } + + return result, nil +} diff --git a/pkg/cloudbroker/compute/add_acl_access.go b/pkg/cloudbroker/compute/add_acl_access.go new file mode 100644 index 0000000..3317067 --- /dev/null +++ b/pkg/cloudbroker/compute/add_acl_access.go @@ -0,0 +1,40 @@ +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" +) + +// AddACLAccessRequest adds ACL access to a vm +type AddACLAccessRequest struct { + ID uint64 `url:"id" json:"id" validate:"required"` + AccessType string `url:"accesstype" json:"accesstype" validate:"required"` + Usernames []string `url:"usernames,omitempty" json:"usernames,omitempty"` + APIAccesses []uint64 `url:"apiaccesses,omitempty" json:"apiaccesses,omitempty"` +} + +// AddACLAccess adds ACL access to a vm. +func (c Compute) AddACLAccess(ctx context.Context, req AddACLAccessRequest) (bool, error) { + err := validators.ValidateRequest(req) + if err != nil { + return false, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/compute/add_acl_access" + + res, err := c.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req) + if err != nil { + return false, err + } + + result, err := strconv.ParseBool(string(res)) + if err != nil { + return false, err + } + + return result, nil +} diff --git a/pkg/cloudbroker/compute/del_acl_access.go b/pkg/cloudbroker/compute/del_acl_access.go new file mode 100644 index 0000000..1350427 --- /dev/null +++ b/pkg/cloudbroker/compute/del_acl_access.go @@ -0,0 +1,39 @@ +package compute + +import ( + "context" + "net/http" + "strconv" + + "repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants" + "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" +) + +// DeleteACLAccessRequest deletes ACL access from a vm +type DeleteACLAccessRequest struct { + ID uint64 `url:"id" json:"id" validate:"required"` + Usernames []string `url:"usernames,omitempty" json:"usernames,omitempty"` + APIAccesses []uint64 `url:"apiaccesses,omitempty" json:"apiaccesses,omitempty"` +} + +// DeleteACLAccess deletes ACL access from a vm. +func (c Compute) DeleteACLAccess(ctx context.Context, req DeleteACLAccessRequest) (bool, error) { + err := validators.ValidateRequest(req) + if err != nil { + return false, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/compute/del_acl_access" + + res, err := c.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req) + if err != nil { + return false, err + } + + result, err := strconv.ParseBool(string(res)) + if err != nil { + return false, err + } + + return result, nil +} diff --git a/pkg/cloudbroker/compute/get_acl_access.go b/pkg/cloudbroker/compute/get_acl_access.go new file mode 100644 index 0000000..33d5894 --- /dev/null +++ b/pkg/cloudbroker/compute/get_acl_access.go @@ -0,0 +1,44 @@ +package compute + +import ( + "context" + "encoding/json" + "net/http" + + "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" +) + +// GetACLAccessRequest struct to get detailed information about ACL account in a vm +type GetACLAccessRequest struct { + ID uint64 `url:"id" json:"id" validate:"required"` +} + +// Get gets current configuration of the ACL access in a vm as a RecordRGACLAccess struct +func (c Compute) GetACLAccess(ctx context.Context, req GetACLAccessRequest) (*RecordComputeACLAccess, error) { + res, err := c.GetACLAccessRaw(ctx, req) + if err != nil { + return nil, err + } + + info := RecordComputeACLAccess{} + + err = json.Unmarshal(res, &info) + if err != nil { + return nil, err + } + + return &info, nil +} + +// GetACLAccessRaw gets current configuration of the ACL access in a vm as an array of bytes +func (c Compute) GetACLAccessRaw(ctx context.Context, req GetACLAccessRequest) ([]byte, error) { + err := validators.ValidateRequest(req) + if err != nil { + return nil, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/compute/get_acl_access" + + res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req) + return res, err +} diff --git a/pkg/cloudbroker/compute/models.go b/pkg/cloudbroker/compute/models.go index d4c0409..b7adc8c 100644 --- a/pkg/cloudbroker/compute/models.go +++ b/pkg/cloudbroker/compute/models.go @@ -816,6 +816,9 @@ type InfoCompute struct { // Manager type ManagerType string `json:"managerType"` + // Memory balloon mode + MemoryBalloonMode string `json:"memory_balloon_mode"` + // Migration job MigrationJob uint64 `json:"migrationjob"` @@ -1109,6 +1112,9 @@ type RecordCompute struct { // Manager type ManagerType string `json:"managerType"` + // Memory balloon mode + MemoryBalloonMode string `json:"memory_balloon_mode"` + // Migration job MigrationJob uint64 `json:"migrationjob"` @@ -1248,6 +1254,57 @@ type RecordCompute struct { _ uint64 `json:"nodeId"` } +// Detailed information about ACL Access in a compute +type RecordComputeACLAccess struct { + // Data + Data DataACL `json:"data"` + + // Entry count + EntryCount uint64 `json:"entryCount"` +} + +// Data ACL +type DataACL struct { + // RG ACL list + RGACLList []RGACL `json:"rgACL"` + + // Account ACL list + AccountACLList []AccountACL `json:"accountACL"` + + // Compute ACL list + ComputeACLList []ComputeACL `json:"computeACL"` +} + +// RG ACL info +type RGACL struct { + Right string `json:"right"` + GUID string `json:"guid"` + UserGroupID string `json:"userGroupId"` + Status string `json:"status"` + Type string `json:"type"` + Explicit bool `json:"explicit"` +} + +// Account ACL info +type AccountACL struct { + Right string `json:"right"` + GUID string `json:"guid"` + UserGroupID string `json:"userGroupId"` + Status string `json:"status"` + Type string `json:"type"` + Explicit bool `json:"explicit"` +} + +// Compute ACL info +type ComputeACL struct { + Right string `json:"right"` + GUID string `json:"guid"` + UserGroupID string `json:"userGroupId"` + Status string `json:"status"` + Type string `json:"type"` + Explicit bool `json:"explicit"` +} + // SnapRecordCompute is RecordCompute but without the SnapSets field type SnapRecordCompute struct { // Account ID @@ -1705,6 +1762,9 @@ type ItemVGPU struct { // Profile Reference ProfileReference string `json:"profile_reference"` + // Profile Name + ProfileName string `json:"profile_name"` + // Split Mode SplitMode string `json:"split_mode"` @@ -2123,6 +2183,9 @@ type ItemShadowComputeInterface struct { // QOS QOS QOS `json:"qos"` + // List of QoS Policy IDs + QoSPolicies []uint64 `json:"qos_policies"` + // Libvirt settings LibvirtSettings LibvirtSettings `json:"libvirtSettings"` diff --git a/pkg/cloudbroker/compute/net_attach.go b/pkg/cloudbroker/compute/net_attach.go index 627ce73..fac2539 100644 --- a/pkg/cloudbroker/compute/net_attach.go +++ b/pkg/cloudbroker/compute/net_attach.go @@ -5,6 +5,7 @@ import ( "encoding/json" "net/http" + "repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants" "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" ) @@ -95,7 +96,7 @@ type NetAttachRequest struct { type wrapperNetAttachRequest struct { NetAttachRequest - AsyncMode bool `url:"asyncMode"` + AsyncMode bool `url:"asyncMode" json:"asyncMode"` } // NetAttach attaches network to compute and gets info about network @@ -112,7 +113,7 @@ func (c Compute) NetAttach(ctx context.Context, req NetAttachRequest) (*RecordNe url := "/cloudbroker/compute/netAttach" - res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped) + res, err := c.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, reqWrapped) if err != nil { return nil, err } @@ -141,7 +142,7 @@ func (c Compute) NetAttachAsync(ctx context.Context, req NetAttachRequest) (stri url := "/cloudbroker/compute/netAttach" - res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped) + res, err := c.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, reqWrapped) if err != nil { return "", err } diff --git a/pkg/cloudbroker/compute/update.go b/pkg/cloudbroker/compute/update.go index 8734b8b..3d9670a 100644 --- a/pkg/cloudbroker/compute/update.go +++ b/pkg/cloudbroker/compute/update.go @@ -83,6 +83,11 @@ type UpdateRequest struct { // Required: false // Default: reset WatchdogAction string `url:"watchdog_action,omitempty" json:"watchdog_action,omitempty" validate:"omitempty,watchdogAction"` + + // Memory balloon mode. One of ["auto","legacy","none"] + // Required: false + // Default: "auto" + MemoryBalloonMode string `url:"memory_balloon_mode,omitempty" json:"memory_balloon_mode,omitempty" validate:"omitempty,memoryBalloonMode"` } // Update updates some properties of the compute diff --git a/pkg/cloudbroker/compute/update_acl_access.go b/pkg/cloudbroker/compute/update_acl_access.go new file mode 100644 index 0000000..002ed4b --- /dev/null +++ b/pkg/cloudbroker/compute/update_acl_access.go @@ -0,0 +1,40 @@ +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" +) + +// UpdateACLAccessRequest updates ACL access in a vm +type UpdateACLAccessRequest struct { + ID uint64 `url:"id" json:"id" validate:"required"` + AccessType string `url:"accesstype" json:"accesstype" validate:"required"` + Usernames []string `url:"usernames,omitempty" json:"usernames,omitempty"` + APIAccesses []uint64 `url:"apiaccesses,omitempty" json:"apiaccesses,omitempty"` +} + +// UpdateACLAccess updates ACL access in a vm. +func (c Compute) UpdateACLAccess(ctx context.Context, req UpdateACLAccessRequest) (bool, error) { + err := validators.ValidateRequest(req) + if err != nil { + return false, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/compute/update_acl_access" + + res, err := c.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req) + if err != nil { + return false, err + } + + result, err := strconv.ParseBool(string(res)) + if err != nil { + return false, err + } + + return result, nil +} diff --git a/pkg/cloudbroker/compute/user_grant.go b/pkg/cloudbroker/compute/user_grant.go index f270958..42f4365 100644 --- a/pkg/cloudbroker/compute/user_grant.go +++ b/pkg/cloudbroker/compute/user_grant.go @@ -28,6 +28,8 @@ type UserGrantRequest struct { } // UserGrant grants user access to the compute +// +// Deprecated: will be removed in SDK v1.17 func (c Compute) UserGrant(ctx context.Context, req UserGrantRequest) (bool, error) { err := validators.ValidateRequest(req) if err != nil { diff --git a/pkg/cloudbroker/compute/user_list.go b/pkg/cloudbroker/compute/user_list.go index 384bae4..41999ce 100644 --- a/pkg/cloudbroker/compute/user_list.go +++ b/pkg/cloudbroker/compute/user_list.go @@ -16,6 +16,8 @@ type UserListRequest struct { } // UserList gets users list for compute +// +// Deprecated: will be removed in SDK v1.17 func (c Compute) UserList(ctx context.Context, req UserListRequest) (*ListUsers, error) { err := validators.ValidateRequest(req) if err != nil { diff --git a/pkg/cloudbroker/compute/user_revoke.go b/pkg/cloudbroker/compute/user_revoke.go index 1e04011..b2771cf 100644 --- a/pkg/cloudbroker/compute/user_revoke.go +++ b/pkg/cloudbroker/compute/user_revoke.go @@ -20,6 +20,8 @@ type UserRevokeRequest struct { } // UserRevoke revokes user access to the compute +// +// Deprecated: will be removed in SDK v1.17 func (c Compute) UserRevoke(ctx context.Context, req UserRevokeRequest) (bool, error) { err := validators.ValidateRequest(req) if err != nil { diff --git a/pkg/cloudbroker/compute/user_update.go b/pkg/cloudbroker/compute/user_update.go index 67fe425..3dd3df4 100644 --- a/pkg/cloudbroker/compute/user_update.go +++ b/pkg/cloudbroker/compute/user_update.go @@ -28,6 +28,8 @@ type UserUpdateRequest struct { } // UserUpdate updates user access to the compute +// +// Deprecated: will be removed in SDK v1.17 func (c Compute) UserUpdate(ctx context.Context, req UserUpdateRequest) (bool, error) { err := validators.ValidateRequest(req) if err != nil { diff --git a/pkg/cloudbroker/disks/change_disk_storage_policy.go b/pkg/cloudbroker/disks/change_disk_storage_policy.go index 3d96fdf..769142c 100644 --- a/pkg/cloudbroker/disks/change_disk_storage_policy.go +++ b/pkg/cloudbroker/disks/change_disk_storage_policy.go @@ -2,6 +2,7 @@ package disks import ( "context" + "encoding/json" "net/http" "strconv" @@ -19,6 +20,12 @@ type ChangeDiskStoragePolicyRequest struct { StoragePolicyID uint64 `url:"storage_policy_id" json:"storage_policy_id" validate:"required"` } +type wrapperChangeDiskStoragePolicyRequest struct { + ChangeDiskStoragePolicyRequest + + AsyncMode bool `url:"async_mode" json:"async_mode"` +} + // ChangeDiskStoragePolicy changes storage policy for disk func (d Disks) ChangeDiskStoragePolicy(ctx context.Context, req ChangeDiskStoragePolicyRequest) (bool, error) { err := validators.ValidateRequest(req) @@ -28,7 +35,12 @@ func (d Disks) ChangeDiskStoragePolicy(ctx context.Context, req ChangeDiskStorag url := "/cloudbroker/disks/change_disk_storage_policy" - res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, req) + wrappedReq := wrapperChangeDiskStoragePolicyRequest{ + ChangeDiskStoragePolicyRequest: req, + AsyncMode: false, + } + + res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, wrappedReq) if err != nil { return false, err } @@ -40,3 +52,30 @@ func (d Disks) ChangeDiskStoragePolicy(ctx context.Context, req ChangeDiskStorag return result, nil } + +// ChangeDiskStoragePolicyAsync changes storage policy for disk in async mode +func (d Disks) ChangeDiskStoragePolicyAsync(ctx context.Context, req ChangeDiskStoragePolicyRequest) (string, error) { + err := validators.ValidateRequest(req) + if err != nil { + return "", validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/disks/change_disk_storage_policy" + + wrappedReq := wrapperChangeDiskStoragePolicyRequest{ + ChangeDiskStoragePolicyRequest: req, + AsyncMode: true, + } + + res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, wrappedReq) + if err != nil { + return "", err + } + + var result string + if err := json.Unmarshal(res, &result); err != nil { + return "", err + } + + return result, nil +} diff --git a/pkg/cloudbroker/disks/delete.go b/pkg/cloudbroker/disks/delete.go index 6fff9b3..d43e4c8 100644 --- a/pkg/cloudbroker/disks/delete.go +++ b/pkg/cloudbroker/disks/delete.go @@ -2,6 +2,7 @@ package disks import ( "context" + "encoding/json" "net/http" "strconv" @@ -27,6 +28,12 @@ type DeleteRequest struct { Name string `url:"name,omitempty" json:"name,omitempty"` } +type wrapperDeleteRequest struct { + DeleteRequest + + AsyncMode bool `url:"async_mode" json:"async_mode"` +} + // Delete deletes disk by ID func (d Disks) Delete(ctx context.Context, req DeleteRequest) (bool, error) { err := validators.ValidateRequest(req) @@ -36,7 +43,12 @@ func (d Disks) Delete(ctx context.Context, req DeleteRequest) (bool, error) { url := "/cloudbroker/disks/delete" - res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, req) + wrappedReq := wrapperDeleteRequest{ + DeleteRequest: req, + AsyncMode: false, + } + + res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, wrappedReq) if err != nil { return false, err } @@ -48,3 +60,30 @@ func (d Disks) Delete(ctx context.Context, req DeleteRequest) (bool, error) { return result, nil } + +// Delete deletes disk by ID in async mode +func (d Disks) DeleteAsync(ctx context.Context, req DeleteRequest) (string, error) { + err := validators.ValidateRequest(req) + if err != nil { + return "", validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/disks/delete" + + wrappedReq := wrapperDeleteRequest{ + DeleteRequest: req, + AsyncMode: true, + } + + res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, wrappedReq) + if err != nil { + return "", err + } + + var result string + if err := json.Unmarshal(res, &result); err != nil { + return "", err + } + + return result, nil +} diff --git a/pkg/cloudbroker/disks/delete_disks.go b/pkg/cloudbroker/disks/delete_disks.go index 536bb3d..42c7b9c 100644 --- a/pkg/cloudbroker/disks/delete_disks.go +++ b/pkg/cloudbroker/disks/delete_disks.go @@ -2,6 +2,7 @@ package disks import ( "context" + "encoding/json" "net/http" "strconv" @@ -19,6 +20,12 @@ type DeleteDisksRequest struct { Permanently bool `url:"permanently,omitempty" json:"permanently,omitempty"` } +type wrapperDeleteDisksRequest struct { + DeleteDisksRequest + + AsyncMode bool `url:"async_mode" json:"async_mode"` +} + // DeleteDisks deletes multiple disks permanently func (d Disks) DeleteDisks(ctx context.Context, req DeleteDisksRequest) (bool, error) { err := validators.ValidateRequest(req) @@ -28,7 +35,12 @@ func (d Disks) DeleteDisks(ctx context.Context, req DeleteDisksRequest) (bool, e url := "/cloudbroker/disks/deleteDisks" - res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, req) + wrappedReq := wrapperDeleteDisksRequest{ + DeleteDisksRequest: req, + AsyncMode: false, + } + + res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, wrappedReq) if err != nil { return false, err } @@ -40,3 +52,30 @@ func (d Disks) DeleteDisks(ctx context.Context, req DeleteDisksRequest) (bool, e return result, nil } + +// DeleteDisks deletes multiple disks permanently in async mode +func (d Disks) DeleteDisksAsync(ctx context.Context, req DeleteDisksRequest) (string, error) { + err := validators.ValidateRequest(req) + if err != nil { + return "", validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/disks/deleteDisks" + + wrappedReq := wrapperDeleteDisksRequest{ + DeleteDisksRequest: req, + AsyncMode: true, + } + + res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, wrappedReq) + if err != nil { + return "", err + } + + var result string + if err := json.Unmarshal(res, &result); err != nil { + return "", err + } + + return result, nil +} diff --git a/pkg/cloudbroker/disks/depresent.go b/pkg/cloudbroker/disks/depresent.go index f8db779..0c38c1f 100644 --- a/pkg/cloudbroker/disks/depresent.go +++ b/pkg/cloudbroker/disks/depresent.go @@ -2,9 +2,11 @@ package disks import ( "context" + "encoding/json" "net/http" - "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" "strconv" + + "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" ) // DepresentRequest struct to depresent disk from node @@ -18,6 +20,12 @@ type DepresentRequest struct { NodeID uint64 `url:"nodeId" json:"nodeId" validate:"required"` } +type wrapperDepresentRequest struct { + DepresentRequest + + AsyncMode bool `url:"async_mode" json:"async_mode"` +} + // Depresent depresents disk from node func (d Disks) Depresent(ctx context.Context, req DepresentRequest) (bool, error) { err := validators.ValidateRequest(req) @@ -27,7 +35,12 @@ func (d Disks) Depresent(ctx context.Context, req DepresentRequest) (bool, error url := "/cloudbroker/disks/depresent" - res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, req) + wrappedReq := wrapperDepresentRequest{ + DepresentRequest: req, + AsyncMode: false, + } + + res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, wrappedReq) if err != nil { return false, err } @@ -39,3 +52,30 @@ func (d Disks) Depresent(ctx context.Context, req DepresentRequest) (bool, error return result, nil } + +// Depresent depresents disk from node in async mode +func (d Disks) DepresentAsync(ctx context.Context, req DepresentRequest) (string, error) { + err := validators.ValidateRequest(req) + if err != nil { + return "", validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/disks/depresent" + + wrappedReq := wrapperDepresentRequest{ + DepresentRequest: req, + AsyncMode: true, + } + + res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, wrappedReq) + if err != nil { + return "", err + } + + var result string + if err := json.Unmarshal(res, &result); err != nil { + return "", err + } + + return result, nil +} diff --git a/pkg/cloudbroker/disks/ids.go b/pkg/cloudbroker/disks/ids.go index bed9508..41adece 100644 --- a/pkg/cloudbroker/disks/ids.go +++ b/pkg/cloudbroker/disks/ids.go @@ -17,4 +17,3 @@ func (ldu ListUnattachedDisks) IDs() []uint64 { } return res } - diff --git a/pkg/cloudbroker/disks/limit_io.go b/pkg/cloudbroker/disks/limit_io.go index 693b8f6..d25ed68 100644 --- a/pkg/cloudbroker/disks/limit_io.go +++ b/pkg/cloudbroker/disks/limit_io.go @@ -2,6 +2,7 @@ package disks import ( "context" + "encoding/json" "net/http" "strconv" @@ -71,6 +72,12 @@ type LimitIORequest struct { SizeIOPSSec uint64 `url:"size_iops_sec,omitempty" json:"size_iops_sec,omitempty"` } +type wrapperLimitIORequest struct { + LimitIORequest + + AsyncMode bool `url:"async_mode" json:"async_mode"` +} + // LimitIO limits IO for a certain disk // total and read/write options are not allowed to be combined // see http://libvirt.org/formatdomain.html#elementsDisks iotune section for more details @@ -82,7 +89,12 @@ func (d Disks) LimitIO(ctx context.Context, req LimitIORequest) (bool, error) { url := "/cloudbroker/disks/limitIO" - res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, req) + wrappedReq := wrapperLimitIORequest{ + LimitIORequest: req, + AsyncMode: false, + } + + res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, wrappedReq) if err != nil { return false, err } @@ -94,3 +106,32 @@ func (d Disks) LimitIO(ctx context.Context, req LimitIORequest) (bool, error) { return result, nil } + +// LimitIOAsync limits IO for a certain disk in async mode +// total and read/write options are not allowed to be combined +// see http://libvirt.org/formatdomain.html#elementsDisks iotune section for more details +func (d Disks) LimitIOAsync(ctx context.Context, req LimitIORequest) (string, error) { + err := validators.ValidateRequest(req) + if err != nil { + return "", validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/disks/limitIO" + + wrappedReq := wrapperLimitIORequest{ + LimitIORequest: req, + AsyncMode: true, + } + + res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, wrappedReq) + if err != nil { + return "", err + } + + var result string + if err := json.Unmarshal(res, &result); err != nil { + return "", err + } + + return result, nil +} diff --git a/pkg/cloudbroker/disks/migrate_abort.go b/pkg/cloudbroker/disks/migrate_abort.go index 2be3a14..8ec636e 100644 --- a/pkg/cloudbroker/disks/migrate_abort.go +++ b/pkg/cloudbroker/disks/migrate_abort.go @@ -2,6 +2,7 @@ package disks import ( "context" + "encoding/json" "net/http" "strconv" @@ -15,6 +16,12 @@ type MigrateAbortRequest struct { DiskID uint64 `url:"disk_id" json:"disk_id" validate:"required"` } +type wrapperMigrateAbortRequest struct { + MigrateAbortRequest + + AsyncMode bool `url:"async_mode" json:"async_mode"` +} + // MigrateAbort aborts disk migration func (c Disks) MigrateAbort(ctx context.Context, req MigrateAbortRequest) (bool, error) { err := validators.ValidateRequest(req) @@ -24,7 +31,12 @@ func (c Disks) MigrateAbort(ctx context.Context, req MigrateAbortRequest) (bool, url := "/cloudbroker/disks/migrate_abort" - res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req) + wrappedReq := wrapperMigrateAbortRequest{ + MigrateAbortRequest: req, + AsyncMode: false, + } + + res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, wrappedReq) if err != nil { return false, err } @@ -36,3 +48,30 @@ func (c Disks) MigrateAbort(ctx context.Context, req MigrateAbortRequest) (bool, return result, nil } + +// MigrateAbortAsync aborts disk migration in async mode +func (c Disks) MigrateAbortAsync(ctx context.Context, req MigrateAbortRequest) (string, error) { + err := validators.ValidateRequest(req) + if err != nil { + return "", validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/disks/migrate_abort" + + wrappedReq := wrapperMigrateAbortRequest{ + MigrateAbortRequest: req, + AsyncMode: true, + } + + res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, wrappedReq) + if err != nil { + return "", err + } + + var result string + if err := json.Unmarshal(res, &result); err != nil { + return "", err + } + + return result, nil +} diff --git a/pkg/cloudbroker/disks/present.go b/pkg/cloudbroker/disks/present.go index f0de67b..701081b 100644 --- a/pkg/cloudbroker/disks/present.go +++ b/pkg/cloudbroker/disks/present.go @@ -2,9 +2,11 @@ package disks import ( "context" + "encoding/json" "net/http" - "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" "strconv" + + "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" ) // PresentRequest struct to present disk to node @@ -18,6 +20,12 @@ type PresentRequest struct { NodeID uint64 `url:"nodeId" json:"nodeId" validate:"required"` } +type wrapperPresentRequest struct { + PresentRequest + + AsyncMode bool `url:"async_mode" json:"async_mode"` +} + // Present presents disk to node func (d Disks) Present(ctx context.Context, req PresentRequest) (bool, error) { err := validators.ValidateRequest(req) @@ -27,7 +35,12 @@ func (d Disks) Present(ctx context.Context, req PresentRequest) (bool, error) { url := "/cloudbroker/disks/present" - res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, req) + wrappedReq := wrapperPresentRequest{ + PresentRequest: req, + AsyncMode: false, + } + + res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, wrappedReq) if err != nil { return false, err } @@ -39,3 +52,30 @@ func (d Disks) Present(ctx context.Context, req PresentRequest) (bool, error) { return result, nil } + +// PresentAsync presents disk to node in async mode +func (d Disks) PresentAsync(ctx context.Context, req PresentRequest) (string, error) { + err := validators.ValidateRequest(req) + if err != nil { + return "", validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/disks/present" + + wrappedReq := wrapperPresentRequest{ + PresentRequest: req, + AsyncMode: true, + } + + res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, wrappedReq) + if err != nil { + return "", err + } + + var result string + if err := json.Unmarshal(res, &result); err != nil { + return "", err + } + + return result, nil +} diff --git a/pkg/cloudbroker/disks/rename.go b/pkg/cloudbroker/disks/rename.go index 2c21ed4..b77ffc0 100644 --- a/pkg/cloudbroker/disks/rename.go +++ b/pkg/cloudbroker/disks/rename.go @@ -2,6 +2,7 @@ package disks import ( "context" + "encoding/json" "net/http" "strconv" @@ -19,6 +20,12 @@ type RenameRequest struct { Name string `url:"name" json:"name" validate:"required"` } +type wrapperRenameRequest struct { + RenameRequest + + AsyncMode bool `url:"async_mode" json:"async_mode"` +} + // Rename renames disk func (d Disks) Rename(ctx context.Context, req RenameRequest) (bool, error) { err := validators.ValidateRequest(req) @@ -28,7 +35,12 @@ func (d Disks) Rename(ctx context.Context, req RenameRequest) (bool, error) { url := "/cloudbroker/disks/rename" - res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, req) + wrappedReq := wrapperRenameRequest{ + RenameRequest: req, + AsyncMode: false, + } + + res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, wrappedReq) if err != nil { return false, err } @@ -40,3 +52,30 @@ func (d Disks) Rename(ctx context.Context, req RenameRequest) (bool, error) { return result, nil } + +// RenameAsync renames disk in async mode +func (d Disks) RenameAsync(ctx context.Context, req RenameRequest) (string, error) { + err := validators.ValidateRequest(req) + if err != nil { + return "", validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/disks/rename" + + wrappedReq := wrapperRenameRequest{ + RenameRequest: req, + AsyncMode: true, + } + + res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, wrappedReq) + if err != nil { + return "", err + } + + var result string + if err := json.Unmarshal(res, &result); err != nil { + return "", err + } + + return result, nil +} diff --git a/pkg/cloudbroker/disks/replicate.go b/pkg/cloudbroker/disks/replicate.go index ca2ecce..596ef34 100644 --- a/pkg/cloudbroker/disks/replicate.go +++ b/pkg/cloudbroker/disks/replicate.go @@ -2,6 +2,7 @@ package disks import ( "context" + "encoding/json" "net/http" "strconv" @@ -31,6 +32,12 @@ type ReplicateRequest struct { StoragePolicyID uint64 `url:"storage_policy_id" json:"storage_policy_id" validate:"required"` } +type wrapperReplicateRequest struct { + ReplicateRequest + + AsyncMode bool `url:"async_mode" json:"async_mode"` +} + // Replicate create an empty disk in chosen SEP and pool combination. // Starts replication between chosen disk and newly created disk // Note: only TATLIN type SEP are supported for replications between @@ -42,7 +49,12 @@ func (d Disks) Replicate(ctx context.Context, req ReplicateRequest) (uint64, err url := "/cloudbroker/disks/replicate" - res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, req) + wrappedReq := wrapperReplicateRequest{ + ReplicateRequest: req, + AsyncMode: false, + } + + res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, wrappedReq) if err != nil { return 0, err } @@ -54,3 +66,32 @@ func (d Disks) Replicate(ctx context.Context, req ReplicateRequest) (uint64, err return result, nil } + +// ReplicateAsync creates an empty disk in chosen SEP and pool combination in async mode. +// Starts replication between chosen disk and newly created disk +// Note: only TATLIN type SEP are supported for replications between +func (d Disks) ReplicateAsync(ctx context.Context, req ReplicateRequest) (string, error) { + err := validators.ValidateRequest(req) + if err != nil { + return "", validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/disks/replicate" + + wrappedReq := wrapperReplicateRequest{ + ReplicateRequest: req, + AsyncMode: true, + } + + res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, wrappedReq) + if err != nil { + return "", err + } + + var result string + if err := json.Unmarshal(res, &result); err != nil { + return "", err + } + + return result, nil +} diff --git a/pkg/cloudbroker/disks/replication_resume.go b/pkg/cloudbroker/disks/replication_resume.go index cde360c..7d0d37d 100644 --- a/pkg/cloudbroker/disks/replication_resume.go +++ b/pkg/cloudbroker/disks/replication_resume.go @@ -2,6 +2,7 @@ package disks import ( "context" + "encoding/json" "net/http" "strconv" @@ -15,6 +16,12 @@ type ReplicationResumeRequest struct { DiskID uint64 `url:"diskId" json:"diskId" validate:"required"` } +type wrapperReplicationResumeRequest struct { + ReplicationResumeRequest + + AsyncMode bool `url:"async_mode" json:"async_mode"` +} + // ReplicationResume resume suspended replication func (d Disks) ReplicationResume(ctx context.Context, req ReplicationResumeRequest) (bool, error) { err := validators.ValidateRequest(req) @@ -24,7 +31,12 @@ func (d Disks) ReplicationResume(ctx context.Context, req ReplicationResumeReque url := "/cloudbroker/disks/replicationResume" - res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, req) + wrappedReq := wrapperReplicationResumeRequest{ + ReplicationResumeRequest: req, + AsyncMode: false, + } + + res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, wrappedReq) if err != nil { return false, err } @@ -36,3 +48,30 @@ func (d Disks) ReplicationResume(ctx context.Context, req ReplicationResumeReque return result, nil } + +// ReplicationResumeAsync resumes suspended replication in async mode +func (d Disks) ReplicationResumeAsync(ctx context.Context, req ReplicationResumeRequest) (string, error) { + err := validators.ValidateRequest(req) + if err != nil { + return "", validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/disks/replicationResume" + + wrappedReq := wrapperReplicationResumeRequest{ + ReplicationResumeRequest: req, + AsyncMode: true, + } + + res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, wrappedReq) + if err != nil { + return "", err + } + + var result string + if err := json.Unmarshal(res, &result); err != nil { + return "", err + } + + return result, nil +} diff --git a/pkg/cloudbroker/disks/replication_reverse.go b/pkg/cloudbroker/disks/replication_reverse.go index bdfe1e9..527d14a 100644 --- a/pkg/cloudbroker/disks/replication_reverse.go +++ b/pkg/cloudbroker/disks/replication_reverse.go @@ -2,6 +2,7 @@ package disks import ( "context" + "encoding/json" "net/http" "strconv" @@ -15,6 +16,12 @@ type ReplicationReverseRequest struct { DiskID uint64 `url:"diskId" json:"diskId" validate:"required"` } +type wrapperReplicationReverseRequest struct { + ReplicationReverseRequest + + AsyncMode bool `url:"async_mode" json:"async_mode"` +} + // ReplicationReverse change role between disks replications func (d Disks) ReplicationReverse(ctx context.Context, req ReplicationReverseRequest) (bool, error) { err := validators.ValidateRequest(req) @@ -24,7 +31,12 @@ func (d Disks) ReplicationReverse(ctx context.Context, req ReplicationReverseReq url := "/cloudbroker/disks/replicationReverse" - res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, req) + wrappedReq := wrapperReplicationReverseRequest{ + ReplicationReverseRequest: req, + AsyncMode: false, + } + + res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, wrappedReq) if err != nil { return false, err } @@ -36,3 +48,30 @@ func (d Disks) ReplicationReverse(ctx context.Context, req ReplicationReverseReq return result, nil } + +// ReplicationReverseAsync changes role between disks replications in async mode +func (d Disks) ReplicationReverseAsync(ctx context.Context, req ReplicationReverseRequest) (string, error) { + err := validators.ValidateRequest(req) + if err != nil { + return "", validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/disks/replicationReverse" + + wrappedReq := wrapperReplicationReverseRequest{ + ReplicationReverseRequest: req, + AsyncMode: true, + } + + res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, wrappedReq) + if err != nil { + return "", err + } + + var result string + if err := json.Unmarshal(res, &result); err != nil { + return "", err + } + + return result, nil +} diff --git a/pkg/cloudbroker/disks/replication_start.go b/pkg/cloudbroker/disks/replication_start.go index ed21089..0ef7517 100644 --- a/pkg/cloudbroker/disks/replication_start.go +++ b/pkg/cloudbroker/disks/replication_start.go @@ -2,6 +2,7 @@ package disks import ( "context" + "encoding/json" "net/http" "strconv" @@ -19,6 +20,12 @@ type ReplicationStartRequest struct { TargetDiskID uint64 `url:"targetDiskId" json:"targetDiskId" validate:"required"` } +type wrapperReplicationStartRequest struct { + ReplicationStartRequest + + AsyncMode bool `url:"async_mode" json:"async_mode"` +} + // ReplicationStart starts replication between two chosen disks. It's required for both disks to have same size to avoid replication conflicts // Note: Source disk's SEP and target SEP supported only of TATLIN type. func (d Disks) ReplicationStart(ctx context.Context, req ReplicationStartRequest) (bool, error) { @@ -29,7 +36,12 @@ func (d Disks) ReplicationStart(ctx context.Context, req ReplicationStartRequest url := "/cloudbroker/disks/replicationStart" - res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, req) + wrappedReq := wrapperReplicationStartRequest{ + ReplicationStartRequest: req, + AsyncMode: false, + } + + res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, wrappedReq) if err != nil { return false, err } @@ -41,3 +53,31 @@ func (d Disks) ReplicationStart(ctx context.Context, req ReplicationStartRequest return result, nil } + +// ReplicationStartAsync starts replication between two chosen disks in async mode. It's required for both disks to have same size to avoid replication conflicts +// Note: Source disk's SEP and target SEP supported only of TATLIN type. +func (d Disks) ReplicationStartAsync(ctx context.Context, req ReplicationStartRequest) (string, error) { + err := validators.ValidateRequest(req) + if err != nil { + return "", validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/disks/replicationStart" + + wrappedReq := wrapperReplicationStartRequest{ + ReplicationStartRequest: req, + AsyncMode: true, + } + + res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, wrappedReq) + if err != nil { + return "", err + } + + var result string + if err := json.Unmarshal(res, &result); err != nil { + return "", err + } + + return result, nil +} diff --git a/pkg/cloudbroker/disks/replication_stop.go b/pkg/cloudbroker/disks/replication_stop.go index 86a805e..74427f1 100644 --- a/pkg/cloudbroker/disks/replication_stop.go +++ b/pkg/cloudbroker/disks/replication_stop.go @@ -2,6 +2,7 @@ package disks import ( "context" + "encoding/json" "net/http" "strconv" @@ -15,6 +16,12 @@ type ReplicationStopRequest struct { DiskID uint64 `url:"diskId" json:"diskId" validate:"required"` } +type wrapperReplicationStopRequest struct { + ReplicationStopRequest + + AsyncMode bool `url:"async_mode" json:"async_mode"` +} + // ReplicationStop remove replication between disks completely func (d Disks) ReplicationStop(ctx context.Context, req ReplicationStopRequest) (bool, error) { err := validators.ValidateRequest(req) @@ -24,7 +31,12 @@ func (d Disks) ReplicationStop(ctx context.Context, req ReplicationStopRequest) url := "/cloudbroker/disks/replicationStop" - res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, req) + wrappedReq := wrapperReplicationStopRequest{ + ReplicationStopRequest: req, + AsyncMode: false, + } + + res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, wrappedReq) if err != nil { return false, err } @@ -36,3 +48,30 @@ func (d Disks) ReplicationStop(ctx context.Context, req ReplicationStopRequest) return result, nil } + +// ReplicationStopAsync removes replication between disks completely in async mode +func (d Disks) ReplicationStopAsync(ctx context.Context, req ReplicationStopRequest) (string, error) { + err := validators.ValidateRequest(req) + if err != nil { + return "", validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/disks/replicationStop" + + wrappedReq := wrapperReplicationStopRequest{ + ReplicationStopRequest: req, + AsyncMode: true, + } + + res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, wrappedReq) + if err != nil { + return "", err + } + + var result string + if err := json.Unmarshal(res, &result); err != nil { + return "", err + } + + return result, nil +} diff --git a/pkg/cloudbroker/disks/replication_suspend.go b/pkg/cloudbroker/disks/replication_suspend.go index a28b397..ecc4d71 100644 --- a/pkg/cloudbroker/disks/replication_suspend.go +++ b/pkg/cloudbroker/disks/replication_suspend.go @@ -2,6 +2,7 @@ package disks import ( "context" + "encoding/json" "net/http" "strconv" @@ -15,6 +16,12 @@ type ReplicationSuspendRequest struct { DiskID uint64 `url:"diskId" json:"diskId" validate:"required"` } +type wrapperReplicationSuspendRequest struct { + ReplicationSuspendRequest + + AsyncMode bool `url:"async_mode" json:"async_mode"` +} + // ReplicationSuspend pause replication with possibility to resume from pause moment func (d Disks) ReplicationSuspend(ctx context.Context, req ReplicationSuspendRequest) (bool, error) { err := validators.ValidateRequest(req) @@ -24,7 +31,12 @@ func (d Disks) ReplicationSuspend(ctx context.Context, req ReplicationSuspendReq url := "/cloudbroker/disks/replicationSuspend" - res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, req) + wrappedReq := wrapperReplicationSuspendRequest{ + ReplicationSuspendRequest: req, + AsyncMode: false, + } + + res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, wrappedReq) if err != nil { return false, err } @@ -36,3 +48,30 @@ func (d Disks) ReplicationSuspend(ctx context.Context, req ReplicationSuspendReq return result, nil } + +// ReplicationSuspendAsync pauses replication with possibility to resume from pause moment in async mode +func (d Disks) ReplicationSuspendAsync(ctx context.Context, req ReplicationSuspendRequest) (string, error) { + err := validators.ValidateRequest(req) + if err != nil { + return "", validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/disks/replicationSuspend" + + wrappedReq := wrapperReplicationSuspendRequest{ + ReplicationSuspendRequest: req, + AsyncMode: true, + } + + res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, wrappedReq) + if err != nil { + return "", err + } + + var result string + if err := json.Unmarshal(res, &result); err != nil { + return "", err + } + + return result, nil +} diff --git a/pkg/cloudbroker/disks/resize.go b/pkg/cloudbroker/disks/resize.go index dc5622d..54ba212 100644 --- a/pkg/cloudbroker/disks/resize.go +++ b/pkg/cloudbroker/disks/resize.go @@ -2,6 +2,7 @@ package disks import ( "context" + "encoding/json" "net/http" "strconv" @@ -19,6 +20,12 @@ type ResizeRequest struct { Size uint64 `url:"size" json:"size" validate:"required"` } +type wrapperResizeRequest struct { + ResizeRequest + + AsyncMode bool `url:"async_mode" json:"async_mode"` +} + // Resize2 resize disk // Returns 200 if disk is resized online, else will return 202, // in that case please stop and start your machine after changing the disk size, for your changes to be reflected. @@ -31,7 +38,12 @@ func (d Disks) Resize2(ctx context.Context, req ResizeRequest) (bool, error) { url := "/cloudbroker/disks/resize2" - res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, req) + wrappedReq := wrapperResizeRequest{ + ResizeRequest: req, + AsyncMode: false, + } + + res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, wrappedReq) if err != nil { return false, err } @@ -43,3 +55,33 @@ func (d Disks) Resize2(ctx context.Context, req ResizeRequest) (bool, error) { return result, nil } + +// Resize2Async resizes disk in async mode +// Returns 200 if disk is resized online, else will return 202, +// in that case please stop and start your machine after changing the disk size, for your changes to be reflected. +// This method will not be used for disks, assigned to "old" virtual machines. Only unassigned disks and disks, assigned with computes. +func (d Disks) Resize2Async(ctx context.Context, req ResizeRequest) (string, error) { + err := validators.ValidateRequest(req) + if err != nil { + return "", validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/disks/resize2" + + wrappedReq := wrapperResizeRequest{ + ResizeRequest: req, + AsyncMode: true, + } + + res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, wrappedReq) + if err != nil { + return "", err + } + + var result string + if err := json.Unmarshal(res, &result); err != nil { + return "", err + } + + return result, nil +} diff --git a/pkg/cloudbroker/disks/restore.go b/pkg/cloudbroker/disks/restore.go index d52d5b4..2ef2c9f 100644 --- a/pkg/cloudbroker/disks/restore.go +++ b/pkg/cloudbroker/disks/restore.go @@ -2,6 +2,7 @@ package disks import ( "context" + "encoding/json" "net/http" "strconv" @@ -15,6 +16,12 @@ type RestoreRequest struct { DiskID uint64 `url:"diskId" json:"diskId" validate:"required"` } +type wrapperRestoreRequest struct { + RestoreRequest + + AsyncMode bool `url:"async_mode" json:"async_mode"` +} + // Restore restores a deleted unattached disk from recycle bin func (d Disks) Restore(ctx context.Context, req RestoreRequest) (bool, error) { err := validators.ValidateRequest(req) @@ -24,7 +31,12 @@ func (d Disks) Restore(ctx context.Context, req RestoreRequest) (bool, error) { url := "/cloudbroker/disks/restore" - res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, req) + wrappedReq := wrapperRestoreRequest{ + RestoreRequest: req, + AsyncMode: false, + } + + res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, wrappedReq) if err != nil { return false, err } @@ -36,3 +48,30 @@ func (d Disks) Restore(ctx context.Context, req RestoreRequest) (bool, error) { return result, nil } + +// RestoreAsync restores a deleted unattached disk from recycle bin in async mode +func (d Disks) RestoreAsync(ctx context.Context, req RestoreRequest) (string, error) { + err := validators.ValidateRequest(req) + if err != nil { + return "", validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/disks/restore" + + wrappedReq := wrapperRestoreRequest{ + RestoreRequest: req, + AsyncMode: true, + } + + res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, wrappedReq) + if err != nil { + return "", err + } + + var result string + if err := json.Unmarshal(res, &result); err != nil { + return "", err + } + + return result, nil +} diff --git a/pkg/cloudbroker/disks/share.go b/pkg/cloudbroker/disks/share.go index 57e94cc..a9e12b2 100644 --- a/pkg/cloudbroker/disks/share.go +++ b/pkg/cloudbroker/disks/share.go @@ -2,6 +2,7 @@ package disks import ( "context" + "encoding/json" "net/http" "strconv" @@ -15,6 +16,12 @@ type ShareRequest struct { DiskID uint64 `url:"diskId" json:"diskId" validate:"required"` } +type wrapperShareRequest struct { + ShareRequest + + AsyncMode bool `url:"async_mode" json:"async_mode"` +} + // Share shares data disk func (d Disks) Share(ctx context.Context, req ShareRequest) (bool, error) { err := validators.ValidateRequest(req) @@ -24,7 +31,12 @@ func (d Disks) Share(ctx context.Context, req ShareRequest) (bool, error) { url := "/cloudbroker/disks/share" - res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, req) + wrappedReq := wrapperShareRequest{ + ShareRequest: req, + AsyncMode: false, + } + + res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, wrappedReq) if err != nil { return false, err } @@ -36,3 +48,30 @@ func (d Disks) Share(ctx context.Context, req ShareRequest) (bool, error) { return result, nil } + +// ShareAsync shares data disk in async mode +func (d Disks) ShareAsync(ctx context.Context, req ShareRequest) (string, error) { + err := validators.ValidateRequest(req) + if err != nil { + return "", validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/disks/share" + + wrappedReq := wrapperShareRequest{ + ShareRequest: req, + AsyncMode: true, + } + + res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, wrappedReq) + if err != nil { + return "", err + } + + var result string + if err := json.Unmarshal(res, &result); err != nil { + return "", err + } + + return result, nil +} diff --git a/pkg/cloudbroker/disks/snapshot_delete.go b/pkg/cloudbroker/disks/snapshot_delete.go index c39647a..42984e3 100644 --- a/pkg/cloudbroker/disks/snapshot_delete.go +++ b/pkg/cloudbroker/disks/snapshot_delete.go @@ -2,6 +2,7 @@ package disks import ( "context" + "encoding/json" "net/http" "strconv" @@ -19,6 +20,12 @@ type SnapshotDeleteRequest struct { Label string `url:"label" json:"label" validate:"required"` } +type wrapperSnapshotDeleteRequest struct { + SnapshotDeleteRequest + + AsyncMode bool `url:"async_mode" json:"async_mode"` +} + // SnapshotDelete deletes a snapshot func (d Disks) SnapshotDelete(ctx context.Context, req SnapshotDeleteRequest) (bool, error) { err := validators.ValidateRequest(req) @@ -28,7 +35,12 @@ func (d Disks) SnapshotDelete(ctx context.Context, req SnapshotDeleteRequest) (b url := "/cloudbroker/disks/snapshotDelete" - res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, req) + wrappedReq := wrapperSnapshotDeleteRequest{ + SnapshotDeleteRequest: req, + AsyncMode: false, + } + + res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, wrappedReq) if err != nil { return false, err } @@ -40,3 +52,30 @@ func (d Disks) SnapshotDelete(ctx context.Context, req SnapshotDeleteRequest) (b return result, nil } + +// SnapshotDeleteAsync deletes a snapshot in async mode +func (d Disks) SnapshotDeleteAsync(ctx context.Context, req SnapshotDeleteRequest) (string, error) { + err := validators.ValidateRequest(req) + if err != nil { + return "", validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/disks/snapshotDelete" + + wrappedReq := wrapperSnapshotDeleteRequest{ + SnapshotDeleteRequest: req, + AsyncMode: true, + } + + res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, wrappedReq) + if err != nil { + return "", err + } + + var result string + if err := json.Unmarshal(res, &result); err != nil { + return "", err + } + + return result, nil +} diff --git a/pkg/cloudbroker/disks/snapshot_rollback.go b/pkg/cloudbroker/disks/snapshot_rollback.go index 2b4a195..abf745d 100644 --- a/pkg/cloudbroker/disks/snapshot_rollback.go +++ b/pkg/cloudbroker/disks/snapshot_rollback.go @@ -2,6 +2,7 @@ package disks import ( "context" + "encoding/json" "net/http" "strconv" @@ -23,6 +24,12 @@ type SnapshotRollbackRequest struct { TimeStamp uint64 `url:"timestamp,omitempty" json:"timestamp,omitempty"` } +type wrapperSnapshotRollbackRequest struct { + SnapshotRollbackRequest + + AsyncMode bool `url:"async_mode" json:"async_mode"` +} + // SnapshotRollback rollbacks an individual disk snapshot func (d Disks) SnapshotRollback(ctx context.Context, req SnapshotRollbackRequest) (bool, error) { err := validators.ValidateRequest(req) @@ -32,7 +39,12 @@ func (d Disks) SnapshotRollback(ctx context.Context, req SnapshotRollbackRequest url := "/cloudbroker/disks/snapshotRollback" - res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, req) + wrappedReq := wrapperSnapshotRollbackRequest{ + SnapshotRollbackRequest: req, + AsyncMode: false, + } + + res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, wrappedReq) if err != nil { return false, err } @@ -44,3 +56,30 @@ func (d Disks) SnapshotRollback(ctx context.Context, req SnapshotRollbackRequest return result, nil } + +// SnapshotRollbackAsync rollbacks an individual disk snapshot in async mode +func (d Disks) SnapshotRollbackAsync(ctx context.Context, req SnapshotRollbackRequest) (string, error) { + err := validators.ValidateRequest(req) + if err != nil { + return "", validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/disks/snapshotRollback" + + wrappedReq := wrapperSnapshotRollbackRequest{ + SnapshotRollbackRequest: req, + AsyncMode: true, + } + + res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, wrappedReq) + if err != nil { + return "", err + } + + var result string + if err := json.Unmarshal(res, &result); err != nil { + return "", err + } + + return result, nil +} diff --git a/pkg/cloudbroker/disks/unshare.go b/pkg/cloudbroker/disks/unshare.go index bd3ff3b..b28d7ae 100644 --- a/pkg/cloudbroker/disks/unshare.go +++ b/pkg/cloudbroker/disks/unshare.go @@ -2,6 +2,7 @@ package disks import ( "context" + "encoding/json" "net/http" "strconv" @@ -15,6 +16,12 @@ type UnshareRequest struct { DiskID uint64 `url:"diskId" json:"diskId" validate:"required"` } +type wrapperUnshareRequest struct { + UnshareRequest + + AsyncMode bool `url:"async_mode" json:"async_mode"` +} + // Unshare unshares data disk func (d Disks) Unshare(ctx context.Context, req UnshareRequest) (bool, error) { err := validators.ValidateRequest(req) @@ -24,7 +31,12 @@ func (d Disks) Unshare(ctx context.Context, req UnshareRequest) (bool, error) { url := "/cloudbroker/disks/unshare" - res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, req) + wrappedReq := wrapperUnshareRequest{ + UnshareRequest: req, + AsyncMode: false, + } + + res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, wrappedReq) if err != nil { return false, err } @@ -36,3 +48,30 @@ func (d Disks) Unshare(ctx context.Context, req UnshareRequest) (bool, error) { return result, nil } + +// UnshareAsync unshares data disk in async mode +func (d Disks) UnshareAsync(ctx context.Context, req UnshareRequest) (string, error) { + err := validators.ValidateRequest(req) + if err != nil { + return "", validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/disks/unshare" + + wrappedReq := wrapperUnshareRequest{ + UnshareRequest: req, + AsyncMode: true, + } + + res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, wrappedReq) + if err != nil { + return "", err + } + + var result string + if err := json.Unmarshal(res, &result); err != nil { + return "", err + } + + return result, nil +} diff --git a/pkg/cloudbroker/disks/update.go b/pkg/cloudbroker/disks/update.go index 44d4e7f..e8f1ef1 100644 --- a/pkg/cloudbroker/disks/update.go +++ b/pkg/cloudbroker/disks/update.go @@ -2,6 +2,7 @@ package disks import ( "context" + "encoding/json" "net/http" "strconv" @@ -27,6 +28,12 @@ type UpdateRequest struct { BlockSize string `url:"block_size,omitempty" json:"block_size,omitempty"` } +type wrapperUpdateRequest struct { + UpdateRequest + + AsyncMode bool `url:"async_mode" json:"async_mode"` +} + // Update updates disk func (d Disks) Update(ctx context.Context, req UpdateRequest) (bool, error) { err := validators.ValidateRequest(req) @@ -36,7 +43,12 @@ func (d Disks) Update(ctx context.Context, req UpdateRequest) (bool, error) { url := "/cloudbroker/disks/update" - res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, req) + wrappedReq := wrapperUpdateRequest{ + UpdateRequest: req, + AsyncMode: false, + } + + res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, wrappedReq) if err != nil { return false, err } @@ -48,3 +60,30 @@ func (d Disks) Update(ctx context.Context, req UpdateRequest) (bool, error) { return result, nil } + +// UpdateAsync updates disk in async mode +func (d Disks) UpdateAsync(ctx context.Context, req UpdateRequest) (string, error) { + err := validators.ValidateRequest(req) + if err != nil { + return "", validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/disks/update" + + wrappedReq := wrapperUpdateRequest{ + UpdateRequest: req, + AsyncMode: true, + } + + res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, wrappedReq) + if err != nil { + return "", err + } + + var result string + if err := json.Unmarshal(res, &result); err != nil { + return "", err + } + + return result, nil +} diff --git a/pkg/cloudbroker/extnet/add_reserved_ip.go b/pkg/cloudbroker/extnet/add_reserved_ip.go index 015143f..909cbc5 100644 --- a/pkg/cloudbroker/extnet/add_reserved_ip.go +++ b/pkg/cloudbroker/extnet/add_reserved_ip.go @@ -25,6 +25,11 @@ type AddReserveIPRequest struct { // List of IPs for specifying the desired address // Required: false IPs []string `url:"ips,omitempty" json:"ips,omitempty"` + + // Flag indicating whether the reserved IP can be auto-assigned + // Required: false + // Default: true + AutoAssignable interface{} `url:"auto_assignable,omitempty" json:"auto_assignable,omitempty" validate:"omitempty,isBool"` } // AddReserveIP reserves address or address poll to external network for account ID diff --git a/pkg/cloudbroker/extnet/get_reserved_ip.go b/pkg/cloudbroker/extnet/get_reserved_ip.go index 30ed2b2..75c0818 100644 --- a/pkg/cloudbroker/extnet/get_reserved_ip.go +++ b/pkg/cloudbroker/extnet/get_reserved_ip.go @@ -17,6 +17,11 @@ type GetReservedIP struct { // Field for specifying the ID of extnet whose reservation information we want to receive // Required: false ExtNetID uint64 `url:"extnetId,omitempty" json:"extnetId,omitempty"` + + // Flag indicating whether the reserved IP can be auto-assigned + // Required: false + // Default: null + AutoAssignable interface{} `url:"auto_assignable,omitempty" json:"auto_assignable,omitempty" validate:"omitempty,isBool"` } // GetReservedIP gets information about reserved address or address poll as a slice of RecordReservedIP struct diff --git a/pkg/cloudbroker/extnet/models.go b/pkg/cloudbroker/extnet/models.go index a84c7f6..01d7f8c 100644 --- a/pkg/cloudbroker/extnet/models.go +++ b/pkg/cloudbroker/extnet/models.go @@ -293,12 +293,13 @@ type RecordReservedIP struct { } type Reservations struct { - AccountID int `json:"account_id"` - ClientType string `json:"clientType"` - DomainName string `json:"domainname"` - Hostname string `json:"hostname"` - IP string `json:"ip"` - Mac string `json:"mac"` - Type string `json:"type"` - VMID int `json:"vmId"` + AccountID int `json:"account_id"` + ClientType string `json:"clientType"` + DomainName string `json:"domainname"` + Hostname string `json:"hostname"` + IP string `json:"ip"` + Mac string `json:"mac"` + Type string `json:"type"` + VMID int `json:"vmId"` + AutoAssignable bool `json:"auto_assignable"` } diff --git a/pkg/cloudbroker/kvmx86/create.go b/pkg/cloudbroker/kvmx86/create.go index a90b6ac..10d12c9 100644 --- a/pkg/cloudbroker/kvmx86/create.go +++ b/pkg/cloudbroker/kvmx86/create.go @@ -270,6 +270,11 @@ type CreateRequest struct { // Required: false // Default: reset WatchdogAction string `url:"watchdog_action,omitempty" json:"watchdog_action,omitempty" validate:"omitempty,watchdogAction"` + + // Memory balloon mode. One of ["auto","legacy","none"] + // Required: false + // Default: "auto" + MemoryBalloonMode string `url:"memory_balloon_mode,omitempty" json:"memory_balloon_mode,omitempty" validate:"omitempty,memoryBalloonMode"` } // GetRAM returns RAM field values diff --git a/pkg/cloudbroker/kvmx86/create_blank.go b/pkg/cloudbroker/kvmx86/create_blank.go index e0f3769..542340d 100644 --- a/pkg/cloudbroker/kvmx86/create_blank.go +++ b/pkg/cloudbroker/kvmx86/create_blank.go @@ -142,6 +142,11 @@ type CreateBlankRequest struct { // Required: false // Default: reset WatchdogAction string `url:"watchdog_action,omitempty" json:"watchdog_action,omitempty" validate:"omitempty,watchdogAction"` + + // Memory balloon mode. One of ["auto","legacy","none"] + // Required: false + // Default: "auto" + MemoryBalloonMode string `url:"memory_balloon_mode,omitempty" json:"memory_balloon_mode,omitempty" validate:"omitempty,memoryBalloonMode"` } // GetRAM returns RAM field values diff --git a/pkg/cloudbroker/kvmx86/mass_create.go b/pkg/cloudbroker/kvmx86/mass_create.go index e22cae1..249ae29 100644 --- a/pkg/cloudbroker/kvmx86/mass_create.go +++ b/pkg/cloudbroker/kvmx86/mass_create.go @@ -192,6 +192,11 @@ type MassCreateRequest struct { // Required: false // Default: reset WatchdogAction string `url:"watchdog_action,omitempty" json:"watchdog_action,omitempty" validate:"omitempty,watchdogAction"` + + // Memory balloon mode. One of ["auto","legacy","none"] + // Required: false + // Default: "auto" + MemoryBalloonMode string `url:"memory_balloon_mode,omitempty" json:"memory_balloon_mode,omitempty" validate:"omitempty,memoryBalloonMode"` } // GetRAM returns RAM field values diff --git a/pkg/cloudbroker/node/pci_device_driver_to_kernel.go b/pkg/cloudbroker/node/pci_device_driver_to_kernel.go index d85962a..24a6132 100644 --- a/pkg/cloudbroker/node/pci_device_driver_to_kernel.go +++ b/pkg/cloudbroker/node/pci_device_driver_to_kernel.go @@ -18,6 +18,11 @@ type PCIDeviceDriverToKernelRequest struct { // Hardware path of the PCI device, e.g. 0000:81:00.0 // Required: true HWPath string `url:"hw_path" json:"hw_path" validate:"required,pciDeviceHWPath"` + + // Mode of binding the PCI device driver to kernel + // Default: safe + // Required: false + Mode string `url:"mode,omitempty" json:"mode,omitempty" validate:"omitempty,oneof=safe unsafe"` } // PCIDeviceDriverToKernel binds PCI device driver to kernel diff --git a/pkg/cloudbroker/pcidevice/access_grant.go b/pkg/cloudbroker/pcidevice/access_grant.go new file mode 100644 index 0000000..922ad30 --- /dev/null +++ b/pkg/cloudbroker/pcidevice/access_grant.go @@ -0,0 +1,38 @@ +package pcidevice + +import ( + "context" + "net/http" + "strconv" + + "repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants" + "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" +) + +// AccessGrant struct to grant access to a PCI device +type AccessGrantRequest struct { + DeviceID uint64 `url:"device_id" json:"device_id" validate:"required"` + AccountIDs []uint64 `url:"account_ids" json:"account_ids" validate:"required"` +} + +// AccessGrant grants access to a PCI device +func (p PCIDevice) AccessGrant(ctx context.Context, req AccessGrantRequest) (bool, error) { + err := validators.ValidateRequest(req) + if err != nil { + return false, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/pcidevice/access_grant" + + res, err := p.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req) + if err != nil { + return false, err + } + + result, err := strconv.ParseBool(string(res)) + if err != nil { + return false, err + } + + return result, nil +} diff --git a/pkg/cloudbroker/pcidevice/access_revoke.go b/pkg/cloudbroker/pcidevice/access_revoke.go new file mode 100644 index 0000000..c54ba1e --- /dev/null +++ b/pkg/cloudbroker/pcidevice/access_revoke.go @@ -0,0 +1,38 @@ +package pcidevice + +import ( + "context" + "net/http" + "strconv" + + "repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants" + "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" +) + +// AccessRevoke struct to revoke access from a PCI device +type AccessRevokeRequest struct { + DeviceID uint64 `url:"device_id" json:"device_id" validate:"required"` + AccountIDs []uint64 `url:"account_ids" json:"account_ids" validate:"required"` +} + +// AccessRevoke revokes access from a PCI device +func (p PCIDevice) AccessRevoke(ctx context.Context, req AccessRevokeRequest) (bool, error) { + err := validators.ValidateRequest(req) + if err != nil { + return false, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/pcidevice/access_revoke" + + res, err := p.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req) + if err != nil { + return false, err + } + + result, err := strconv.ParseBool(string(res)) + if err != nil { + return false, err + } + + return result, nil +} diff --git a/pkg/cloudbroker/pcidevice/create.go b/pkg/cloudbroker/pcidevice/create.go index ff2de1c..9c41c2a 100644 --- a/pkg/cloudbroker/pcidevice/create.go +++ b/pkg/cloudbroker/pcidevice/create.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" ) @@ -14,10 +15,6 @@ type CreateRequest struct { // Required: true NodeID uint64 `url:"node_id" json:"node_id" validate:"required"` - // Resource group ID - // Required: true - RGID uint64 `url:"rgId" json:"rgId" validate:"required"` - // Name of device // Required: true Name string `url:"name" json:"name" validate:"required"` @@ -30,6 +27,10 @@ type CreateRequest struct { // Description, just for information // Required: false Description string `url:"description,omitempty" json:"description,omitempty"` + + // Account IDs + // Required: false + AccountIDs []uint64 `url:"account_ids,omitempty" json:"account_ids,omitempty"` } // Create creates PCI Device @@ -41,7 +42,7 @@ func (p PCIDevice) Create(ctx context.Context, req CreateRequest) (uint64, error url := "/cloudbroker/pcidevice/create" - res, err := p.client.DecortApiCall(ctx, http.MethodPost, url, req) + res, err := p.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req) if err != nil { return 0, err } diff --git a/pkg/cloudbroker/pcidevice/list.go b/pkg/cloudbroker/pcidevice/list.go index 78cc305..b1d57b6 100644 --- a/pkg/cloudbroker/pcidevice/list.go +++ b/pkg/cloudbroker/pcidevice/list.go @@ -22,9 +22,9 @@ type ListRequest struct { // Required: false Name string `url:"name,omitempty" json:"name,omitempty"` - // Find by rgId + // Find by account ID // Required: false - RGID uint64 `url:"rgId,omitempty" json:"rgId,omitempty"` + AccountID uint64 `url:"account_id,omitempty" json:"account_id,omitempty"` // Find by status // Required: false diff --git a/pkg/cloudbroker/pcidevice/models.go b/pkg/cloudbroker/pcidevice/models.go index 61c8a83..1d64524 100644 --- a/pkg/cloudbroker/pcidevice/models.go +++ b/pkg/cloudbroker/pcidevice/models.go @@ -26,8 +26,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/cloudbroker/qospolicy/filter.go b/pkg/cloudbroker/qospolicy/filter.go index 60a0cdd..738fb9b 100644 --- a/pkg/cloudbroker/qospolicy/filter.go +++ b/pkg/cloudbroker/qospolicy/filter.go @@ -45,24 +45,6 @@ func (lqp ListQoSPolicies) FilterByDescription(description string) ListQoSPolici 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 diff --git a/pkg/cloudbroker/qospolicy/filter_test.go b/pkg/cloudbroker/qospolicy/filter_test.go index cf5ef72..3513350 100644 --- a/pkg/cloudbroker/qospolicy/filter_test.go +++ b/pkg/cloudbroker/qospolicy/filter_test.go @@ -10,7 +10,6 @@ var qosPolicies = ListQoSPolicies{ Name: "qos1", Description: "some desc", Status: "ENABLED", - CreatedBy: "user", }, { ID: 3, @@ -18,7 +17,6 @@ var qosPolicies = ListQoSPolicies{ Name: "qos3", Description: "some desc", Status: "ENABLED", - CreatedBy: "anotheruser", }, { ID: 5, @@ -26,8 +24,6 @@ var qosPolicies = ListQoSPolicies{ Name: "qos5", Description: "some other desc", Status: "DISABLED", - CreatedBy: "anotheruser", - UpdatedBy: "user", }, }, EntryCount: 3, @@ -74,24 +70,3 @@ func TestFilterByStatus(t *testing.T) { 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/models.go b/pkg/cloudbroker/qospolicy/models.go index fc17c8f..48b8017 100644 --- a/pkg/cloudbroker/qospolicy/models.go +++ b/pkg/cloudbroker/qospolicy/models.go @@ -27,18 +27,6 @@ type ItemQoSPolicy struct { // 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"` } @@ -62,18 +50,6 @@ type RecordQoSPolicy struct { // 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"` } diff --git a/pkg/cloudbroker/qospolicy/sorting.go b/pkg/cloudbroker/qospolicy/sorting.go deleted file mode 100644 index 5109dea..0000000 --- a/pkg/cloudbroker/qospolicy/sorting.go +++ /dev/null @@ -1,39 +0,0 @@ -package qospolicy - -import "sort" - -// SortByCreatedAt sorts ListQoSPolicies by the CreatedAt field in ascending order -// If inverse param is set to true, the order is reversed -func (lqp ListQoSPolicies) SortByCreatedAt(inverse bool) ListQoSPolicies { - if len(lqp.Data) < 2 { - return lqp - } - - sort.Slice(lqp.Data, func(i, j int) bool { - if inverse { - return lqp.Data[i].CreatedAt > lqp.Data[j].CreatedAt - } - - return lqp.Data[i].CreatedAt < lqp.Data[j].CreatedAt - }) - - return lqp -} - -// SortByUpdatedAt sorts ListQoSPolicies by the UpdatedAt field in ascending order -// If inverse param is set to true, the order is reversed -func (lqp ListQoSPolicies) SortByUpdatedAt(inverse bool) ListQoSPolicies { - if len(lqp.Data) < 2 { - return lqp - } - - sort.Slice(lqp.Data, func(i, j int) bool { - if inverse { - return lqp.Data[i].UpdatedAt > lqp.Data[j].UpdatedAt - } - - return lqp.Data[i].UpdatedAt < lqp.Data[j].UpdatedAt - }) - - return lqp -} diff --git a/pkg/cloudbroker/rg/access_grant.go b/pkg/cloudbroker/rg/access_grant.go index 747e94e..acd6a23 100644 --- a/pkg/cloudbroker/rg/access_grant.go +++ b/pkg/cloudbroker/rg/access_grant.go @@ -28,6 +28,8 @@ type AccessGrantRequest struct { } // AccessGrant grants user or group access to the resource group as specified +// +// Deprecated: will be removed in SDK v1.17 func (r RG) AccessGrant(ctx context.Context, req AccessGrantRequest) (bool, error) { err := validators.ValidateRequest(req) if err != nil { diff --git a/pkg/cloudbroker/rg/access_revoke.go b/pkg/cloudbroker/rg/access_revoke.go index 01b5d8f..934fe6d 100644 --- a/pkg/cloudbroker/rg/access_revoke.go +++ b/pkg/cloudbroker/rg/access_revoke.go @@ -20,6 +20,8 @@ type AccessRevokeRequest struct { } // AccessRevoke revokes specified user or group access from the resource group +// +// Deprecated: will be removed in SDK v1.17 func (r RG) AccessRevoke(ctx context.Context, req AccessRevokeRequest) (bool, error) { err := validators.ValidateRequest(req) if err != nil { diff --git a/pkg/cloudbroker/rg/add_acl_access.go b/pkg/cloudbroker/rg/add_acl_access.go new file mode 100644 index 0000000..d952723 --- /dev/null +++ b/pkg/cloudbroker/rg/add_acl_access.go @@ -0,0 +1,40 @@ +package rg + +import ( + "context" + "net/http" + "strconv" + + "repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants" + "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" +) + +// AddACLAccessRequest adds ACL access to a resource group +type AddACLAccessRequest struct { + ID uint64 `url:"id" json:"id" validate:"required"` + AccessType string `url:"accesstype" json:"accesstype" validate:"required"` + Usernames []string `url:"usernames,omitempty" json:"usernames,omitempty"` + APIAccesses []uint64 `url:"apiaccesses,omitempty" json:"apiaccesses,omitempty"` +} + +// AddACLAccess adds ACL access to a resource group. +func (r RG) AddACLAccess(ctx context.Context, req AddACLAccessRequest) (bool, error) { + err := validators.ValidateRequest(req) + if err != nil { + return false, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/rg/add_acl_access" + + res, err := r.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req) + if err != nil { + return false, err + } + + result, err := strconv.ParseBool(string(res)) + if err != nil { + return false, err + } + + return result, nil +} diff --git a/pkg/cloudbroker/rg/del_acl_access.go b/pkg/cloudbroker/rg/del_acl_access.go new file mode 100644 index 0000000..2845a77 --- /dev/null +++ b/pkg/cloudbroker/rg/del_acl_access.go @@ -0,0 +1,39 @@ +package rg + +import ( + "context" + "net/http" + "strconv" + + "repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants" + "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" +) + +// DeleteACLAccessRequest deletes ACL access from a resource group +type DeleteACLAccessRequest struct { + ID uint64 `url:"id" json:"id" validate:"required"` + Usernames []string `url:"usernames,omitempty" json:"usernames,omitempty"` + APIAccesses []uint64 `url:"apiaccesses,omitempty" json:"apiaccesses,omitempty"` +} + +// DeleteACLAccess deletes ACL access from a resource group. +func (r RG) DeleteACLAccess(ctx context.Context, req DeleteACLAccessRequest) (bool, error) { + err := validators.ValidateRequest(req) + if err != nil { + return false, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/rg/del_acl_access" + + res, err := r.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req) + if err != nil { + return false, err + } + + result, err := strconv.ParseBool(string(res)) + if err != nil { + return false, err + } + + return result, nil +} diff --git a/pkg/cloudbroker/rg/get_acl_access.go b/pkg/cloudbroker/rg/get_acl_access.go new file mode 100644 index 0000000..9ac5c63 --- /dev/null +++ b/pkg/cloudbroker/rg/get_acl_access.go @@ -0,0 +1,44 @@ +package rg + +import ( + "context" + "encoding/json" + "net/http" + + "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" +) + +// GetACLAccessRequest struct to get detailed information about ACL account in a resource group +type GetACLAccessRequest struct { + ID uint64 `url:"id" json:"id" validate:"required"` +} + +// Get gets current configuration of the ACL access in a resource group as a RecordRGACLAccess struct +func (r RG) GetACLAccess(ctx context.Context, req GetACLAccessRequest) (*RecordRGACLAccess, error) { + res, err := r.GetACLAccessRaw(ctx, req) + if err != nil { + return nil, err + } + + info := RecordRGACLAccess{} + + err = json.Unmarshal(res, &info) + if err != nil { + return nil, err + } + + return &info, nil +} + +// GetACLAccessRaw gets current configuration of the ACL access in a resource group as an array of bytes +func (r RG) GetACLAccessRaw(ctx context.Context, req GetACLAccessRequest) ([]byte, error) { + err := validators.ValidateRequest(req) + if err != nil { + return nil, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/rg/get_acl_access" + + res, err := r.client.DecortApiCall(ctx, http.MethodPost, url, req) + return res, err +} diff --git a/pkg/cloudbroker/rg/models.go b/pkg/cloudbroker/rg/models.go index 241577f..516d0ec 100644 --- a/pkg/cloudbroker/rg/models.go +++ b/pkg/cloudbroker/rg/models.go @@ -134,6 +134,44 @@ type RecordRG struct { ItemRG } +// Detailed information about ACL Access in a resource group +type RecordRGACLAccess struct { + // Data + Data DataACL `json:"data"` + + // Entry count + EntryCount uint64 `json:"entryCount"` +} + +// Data ACL +type DataACL struct { + // RG ACL list + RGACLList []RGACL `json:"rgACL"` + + // Account ACL list + AccountACL []AccountACL `json:"accountACL"` +} + +// RG ACL info +type RGACL struct { + Right string `json:"right"` + GUID string `json:"guid"` + UserGroupID string `json:"userGroupId"` + Status string `json:"status"` + Type string `json:"type"` + Explicit bool `json:"explicit"` +} + +// Account ACL info +type AccountACL struct { + Right string `json:"right"` + GUID string `json:"guid"` + UserGroupID string `json:"userGroupId"` + Status string `json:"status"` + Type string `json:"type"` + Explicit bool `json:"explicit"` +} + // Main information about resource group type ItemRG struct { // Account ID diff --git a/pkg/cloudbroker/rg/update_acl_access.go b/pkg/cloudbroker/rg/update_acl_access.go new file mode 100644 index 0000000..69c0181 --- /dev/null +++ b/pkg/cloudbroker/rg/update_acl_access.go @@ -0,0 +1,40 @@ +package rg + +import ( + "context" + "net/http" + "strconv" + + "repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants" + "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" +) + +// UpdateACLAccessRequest updates ACL access in a resource group +type UpdateACLAccessRequest struct { + ID uint64 `url:"id" json:"id" validate:"required"` + AccessType string `url:"accesstype" json:"accesstype" validate:"required"` + Usernames []string `url:"usernames,omitempty" json:"usernames,omitempty"` + APIAccesses []uint64 `url:"apiaccesses,omitempty" json:"apiaccesses,omitempty"` +} + +// UpdateACLAccess updates ACL access in a resource group. +func (r RG) UpdateACLAccess(ctx context.Context, req UpdateACLAccessRequest) (bool, error) { + err := validators.ValidateRequest(req) + if err != nil { + return false, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/rg/update_acl_access" + + res, err := r.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req) + if err != nil { + return false, err + } + + result, err := strconv.ParseBool(string(res)) + if err != nil { + return false, err + } + + return result, nil +} diff --git a/pkg/cloudbroker/sep/config_field_edit.go b/pkg/cloudbroker/sep/config_field_edit.go index 3465ee9..6879983 100644 --- a/pkg/cloudbroker/sep/config_field_edit.go +++ b/pkg/cloudbroker/sep/config_field_edit.go @@ -34,6 +34,8 @@ type ConfigFieldEditRequest struct { } // ConfigFieldEdit edits SEP config field value +// +// Deprecated: will be removed in SDK v1.17 func (s SEP) ConfigFieldEdit(ctx context.Context, req ConfigFieldEditRequest) (*RecordConfigFieldEdit, error) { err := validators.ValidateRequest(req) if err != nil { diff --git a/pkg/cloudbroker/vgpu/models.go b/pkg/cloudbroker/vgpu/models.go index 27ab6b1..17baa11 100644 --- a/pkg/cloudbroker/vgpu/models.go +++ b/pkg/cloudbroker/vgpu/models.go @@ -52,6 +52,9 @@ type ItemVGPU struct { // Profile Reference ProfileReference string `json:"profile_reference"` + // Profile Name + ProfileName string `json:"profile_name"` + // Split Mode SplitMode string `json:"split_mode"` diff --git a/tests/platform_upgrade/request_map.go b/tests/platform_upgrade/request_map.go index 4a7eea1..72d117a 100644 --- a/tests/platform_upgrade/request_map.go +++ b/tests/platform_upgrade/request_map.go @@ -101,6 +101,9 @@ func getRequestsMapCloudAPI() map[string]interface{} { "/restmachine/cloudapi/account/restore": account.RestoreRequest{}, "/restmachine/cloudapi/account/update": account.UpdateRequest{}, "/restmachine/cloudapi/account/updateUser": account.UpdateUserRequest{}, + "/restmachine/cloudapi/account/add_acl_access": account.AddACLAccessRequest{}, + "/restmachine/cloudapi/account/del_acl_access": account.DelACLAccessRequest{}, + "/restmachine/cloudapi/account/update_acl_access": account.UpdateACLAccessRequest{}, //audit "/restmachine/cloudapi/audit/get": audit.GetRequest{}, @@ -226,6 +229,10 @@ func getRequestsMapCloudAPI() map[string]interface{} { "/restmachine/cloudapi/compute/guest_agent_feature_get": compute.GuestAgentFeatureGetRequest{}, "/restmachine/cloudapi/compute/guest_agent_feature_update": compute.GuestAgentFeatureUpdateRequest{}, "/restmachine/cloudapi/compute/migrateToZone": compute.MigrateToZoneRequest{}, + "/restmachine/cloudapi/rg/add_acl_access": compute.AddACLAccessRequest{}, + "/restmachine/cloudapi/rg/del_acl_access": compute.DeleteACLAccessRequest{}, + "/restmachine/cloudapi/rg/update_acl_access": compute.UpdateACLAccessRequest{}, + "restmachine/cloudapi/rg/get_acl_access": compute.GetACLAccessRequest{}, // disks "/restmachine/cloudapi/disks/change_disk_storage_policy": disks.ChangeDiskStoragePolicyRequest{}, @@ -408,6 +415,10 @@ func getRequestsMapCloudAPI() map[string]interface{} { "/restmachine/cloudapi/rg/removeDefNet": rg.RemoveDefNetRequest{}, "/restmachine/cloudapi/rg/add_storage_policy": rg.AddStoragePolicyRequest{}, "/restmachine/cloudapi/rg/del_storage_policy": rg.DelStoragePolicyRequest{}, + "/restmachine/cloudapi/rg/add_acl_access": rg.AddACLAccessRequest{}, + "/restmachine/cloudapi/rg/del_acl_access": rg.DeleteACLAccessRequest{}, + "/restmachine/cloudapi/rg/update_acl_access": rg.UpdateACLAccessRequest{}, + "restmachine/cloudapi/rg/get_acl_access": rg.GetACLAccessRequest{}, // security_group "/restmachine/cloudapi/security_group/create": secgroup.CreateRequest{}, @@ -518,6 +529,9 @@ func getRequestsMapCloudbroker() map[string]interface{} { "/restmachine/cloudbroker/account/updateUser": account_cb.UpdateUserRequest{}, "/restmachine/cloudbroker/account/addZone": account_cb.AddZoneRequest{}, "/restmachine/cloudbroker/account/removeZone": account_cb.RemoveZoneRequest{}, + "/restmachine/cloudbroker/account/add_acl_access": account_cb.AddACLAccessRequest{}, + "/restmachine/cloudbroker/account/del_acl_access": account_cb.DelACLAccessRequest{}, + "/restmachine/cloudbroker/account/update_acl_access": account_cb.UpdateACLAccessRequest{}, // apiaccess_cb "/restmachine/cloudbroker/apiaccess/apisExclude": apiaccess_cb.APIsExcludeRequest{}, @@ -544,12 +558,16 @@ func getRequestsMapCloudbroker() map[string]interface{} { "/restmachine/cloudbroker/audit/exportAuditsToFile": EmptyStruct{}, // backup_cb - "/restmachine/cloudbroker/backup/createDiskBackup": backup_cb.CreateDiskBackupRequest{}, - "/restmachine/cloudbroker/backup/createDisksBackup": backup_cb.CreateDisksBackupRequest{}, - "/restmachine/cloudbroker/backup/deleteDiskBackup": backup_cb.DeleteDiskBackupRequest{}, - "/restmachine/cloudbroker/backup/listBackupPaths": backup_cb.ListBackupPathsRequest{}, - "/restmachine/cloudbroker/backup/restoreDiskFromBackup": backup_cb.RestoreDiskFromBackupRequest{}, - "/restmachine/cloudbroker/backup/restoreDisksFromBackup": backup_cb.RestoreDisksFromBackupRequest{}, + "/restmachine/cloudbroker/backup/abort_disks_backup": backup_cb.AbortDisksBackupRequest{}, + "/restmachine/cloudbroker/backup/backup_disks_with_speed": backup_cb.BackupDisksWithSpeedRequest{}, + "/restmachine/cloudbroker/backup/createDiskBackup": backup_cb.CreateDiskBackupRequest{}, + "/restmachine/cloudbroker/backup/createDisksBackup": backup_cb.CreateDisksBackupRequest{}, + "/restmachine/cloudbroker/backup/deleteDiskBackup": backup_cb.DeleteDiskBackupRequest{}, + "/restmachine/cloudbroker/backup/info": backup_cb.InfoRequest{}, + "/restmachine/cloudbroker/backup/listBackupPaths": backup_cb.ListBackupPathsRequest{}, + "/restmachine/cloudbroker/backup/restoreDiskFromBackup": backup_cb.RestoreDiskFromBackupRequest{}, + "/restmachine/cloudbroker/backup/restoreDisksFromBackup": backup_cb.RestoreDisksFromBackupRequest{}, + "/restmachine/cloudbroker/backup/set_backup_speed": backup_cb.SetBackupSpeedRequest{}, // compute_cb "/restmachine/cloudbroker/compute/abort_shared_snapshot_merge": compute_cb.AbortSharedSnapshotMergeRequest{}, @@ -664,6 +682,10 @@ func getRequestsMapCloudbroker() map[string]interface{} { "/restmachine/cloudbroker/compute/migrate_abort": compute_cb.MigrateAbortRequest{}, "/restmachine/cloudbroker/compute/start_migration_out": compute_cb.StartMigrationOutRequest{}, "/restmachine/cloudbroker/compute/stop_migration_out": compute_cb.StopMigrationOutRequest{}, + "/restmachine/cloudbroker/rg/add_acl_access": compute_cb.AddACLAccessRequest{}, + "/restmachine/cloudbroker/rg/del_acl_access": compute_cb.DeleteACLAccessRequest{}, + "/restmachine/cloudbroker/rg/update_acl_access": compute_cb.UpdateACLAccessRequest{}, + "restmachine/cloudbroker/rg/get_acl_access": compute_cb.GetACLAccessRequest{}, // disks "/restmachine/cloudbroker/disks/change_disk_storage_policy": disks_cb.ChangeDiskStoragePolicyRequest{}, @@ -904,11 +926,13 @@ func getRequestsMapCloudbroker() map[string]interface{} { "/restmachine/cloudbroker/node/install": node_cb.InstallRequest{}, // pcidevice - "/restmachine/cloudbroker/pcidevice/create": pcidevice_cb.CreateRequest{}, - "/restmachine/cloudbroker/pcidevice/delete": pcidevice_cb.DeleteRequest{}, - "/restmachine/cloudbroker/pcidevice/disable": pcidevice_cb.DisableRequest{}, - "/restmachine/cloudbroker/pcidevice/enable": pcidevice_cb.EnableRequest{}, - "/restmachine/cloudbroker/pcidevice/list": pcidevice_cb.ListRequest{}, + "/restmachine/cloudbroker/pcidevice/create": pcidevice_cb.CreateRequest{}, + "/restmachine/cloudbroker/pcidevice/delete": pcidevice_cb.DeleteRequest{}, + "/restmachine/cloudbroker/pcidevice/disable": pcidevice_cb.DisableRequest{}, + "/restmachine/cloudbroker/pcidevice/enable": pcidevice_cb.EnableRequest{}, + "/restmachine/cloudbroker/pcidevice/list": pcidevice_cb.ListRequest{}, + "/restmachine/cloudbroker/pcidevice/access_grant": pcidevice_cb.AccessGrantRequest{}, + "/restmachine/cloudbroker/pcidevice/access_revoke": pcidevice_cb.AccessRevokeRequest{}, // prometheus "/restmachine/cloudbroker/prometheus/computeTransmitPackets": prometheus_cb.ComputeTransmitPacketsRequest{}, @@ -969,6 +993,10 @@ func getRequestsMapCloudbroker() map[string]interface{} { "/restmachine/cloudbroker/rg/updateResourceTypes": rg_cb.UpdateResourceTypesRequest{}, "/restmachine/cloudbroker/rg/usage": rg_cb.UsageRequest{}, "/restmachine/cloudbroker/rg/removeDefNet": rg_cb.RemoveDefNetRequest{}, + "/restmachine/cloudbroker/rg/add_acl_access": rg_cb.AddACLAccessRequest{}, + "/restmachine/cloudbroker/rg/del_acl_access": rg_cb.DeleteACLAccessRequest{}, + "/restmachine/cloudbroker/rg/update_acl_access": rg_cb.UpdateACLAccessRequest{}, + "restmachine/cloudbroker/rg/get_acl_access": rg_cb.GetACLAccessRequest{}, // security_group "/restmachine/cloudbroker/security_group/create": secgroup_cb.CreateRequest{},