Compare commits

..

14 Commits

Author SHA1 Message Date
dayterr
b3fccfb000 v1.16.1
v1.16.1
2026-08-28 16:50:10 +03:00
eb195dd992 v1.16.0 2026-08-21 19:11:14 +04:00
d7b8f08b4d v1.15.7 2026-07-31 16:20:40 +04:00
bd2d22f456 v1.15.6 2026-07-17 16:09:24 +04:00
dayterr
416a6c4263 v1.15.5
v1.15.5
2026-07-10 15:37:02 +03:00
6ff4b83368 v1.15.4 2026-07-02 14:24:06 +03:00
118b48c3bc v1.15.3 2026-06-26 16:39:51 +04:00
dayterr
cd5d1c9d0b v1.15.2
v1.15.2
2026-06-19 16:40:41 +03:00
f5a632654b v1.15.1 2026-06-11 16:35:48 +04:00
fea00bbb42 v1.15.0 2026-06-05 17:18:01 +03:00
dayterr
e9adcfec1c v1.14.11 2026-05-29 17:47:13 +03:00
f6bc14c7be v1.14.10 2026-05-22 19:24:55 +03:00
dayterr
f93065e8b1 v1.14.9 2026-05-08 14:10:06 +03:00
dayterr
2bd93e92c2 v1.14.8 2026-04-17 17:04:11 +03:00
400 changed files with 12578 additions and 3230 deletions

View File

@@ -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

View File

@@ -1,20 +1,117 @@
## Version 1.14.7
## Version 1.16.1
Методы `Audits` в cloudapi/compute, cloudbroker/compute, cloudapi/account, cloudbroker/account, cloudapi/vins, cloudbroker/vins, cloudapi/rg и cloudbroker/rg стали deprecated и в следующих версиях будут удалены, вместо них необходимо использовать метод `List` в cloudapi/audit и cloudbroker/audit с соответствующими фильтрами
Методы `AccessGrant`, `AccessGrantToPool`, `AccessRevoke`, `AccessRevokeToPool` в cloudbroker/sep стали deprecated и в следующих версиях будут удалены
Методы `ComputeCISet`, `ComputeCIUnset`, `GetAudits` в cloudbroker/compute и `GetAudits` в cloudapi/compute стали deprecated и будут удалены в следующих версиях
Методы `ComputeCISet`, `ComputeCIUnset` в cloudbroker/image стали deprecated и будут удалены в следующих версиях
Все методы группы `.SDN()` находятся в альфа-версии.
### 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: |
### Добавлено
#### SDN Hypervisors
| Идентификатор<br>задачи | Описание |
#### account
| Идентификатор задачи | Описание |
| --- | --- |
| BGOS-518 | Группа методов Hypervisors |
| BGOS-1007 | Структура запроса `AddACLAccessRequest` и метод `AddACLAccess` в cloudapi/account и в cloudbroker/account |
| BGOS-1007 | Структура запроса `DelACLAccessRequest` и метод `DelACLAccess` в cloudapi/account и в cloudbroker/account |
| BGOS-1007 | Структура запроса `UpdateACLAccessRequest` и метод `UpdateACLAccess` в cloudapi/account и в cloudbroker/account |
#### SDN Version
| Идентификатор<br>задачи | Описание |
#### backup
| Идентификатор задачи | Описание |
| --- | --- |
| BGOS-838 | Группа методов Version |
| BGOS-1012 | Методы `AbortDisksBackup`, `BackupDisksWithSpeed`, `Info` и `SetBackupSpeed` в cloudbroker/backup |
| BGOS-1012 | Структуры ответов `ListDisksWithSpeed` и `TotalBackupsInfo` в cloudbroker/backup |
| BGOS-1018 | Опциональное поле `Speed` в структуры запроса `CreateDiskBackupRequest` и `Disk` в cloudbroker/backup |
#### 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-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 |
#### extnet
| Идентификатор задачи | Описание |
| --- | --- |
| BGOS-1013 | Опциональное поле `AutoAssignable` в структуру запроса `AddReserveIPRequest` в cloudbroker/extnet |
| BGOS-1013 | Опциональное поле `AutoAssignable` в структуру запроса `GetReservedIP` в cloudbroker/extnet и cloudapi/extnet |
| BGOS-1013 | Вычисляемое поле `AutoAssignable` в структуру ответа `Reservations` в cloudbroker/extnet и cloudapi/extnet |
#### kvmx86
| Идентификатор задачи | Описание |
| --- | --- |
| BGOS-1014 | Опциональное поле `MemoryBalloonMode` в структуры запроса `CreateRequest` и `CreateBlankRequest` в cloudapi/kvmx86 |
| BGOS-1014 | Опциональное поле `MemoryBalloonMode` в структуры запроса `CreateRequest`, `CreateBlankRequest` и `MassCreateRequest` в cloudbroker/kvmx86 |
#### 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-1011 | Вычисляемое поле `ProfileName` в структуру ответа `ItemVGPU` в cloudbroker/vgpu и cloudapi/vgpu |
### Удалено
#### account
| Идентификатор задачи | Описание |
| --- | --- |
| BGOS-1021 | Вычисляемое поле `CanBeDeleted` из структуры ответа `ListRecordACL` в cloudapi/account |
#### network qos policy
| Идентификатор задачи | Описание |
| --- | --- |
| 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 |
#### pcidevice
| Идентификатор задачи | Описание |
| --- | --- |
| BGOS-990 | Опциональное поле `RGID` из структуры запроса `ListRequest` в cloudapi/pcidevice и из структур запроса `CreateRequest` и `ListRequest` в cloudbroker/pcidevice |
| BGOS-990 | Вычисляемое поле `RGID` из структуры ответа `ItemPCIDevice` в cloudapi/pcidevice и из структуры ответа `ItemPCIDevice` в cloudbroker/pcidevice |

View File

@@ -19,6 +19,8 @@ Decort SDK - это библиотека, написанная на языке G
- Версия 1.12.х Decort-SDK соответствует 4.4.0 версии платформы
- Версия 1.13.х Decort-SDK соответствует 4.5.0 версии платформы
- Версия 1.14.х Decort-SDK соответствует 4.6.0 версии платформы
- Версия 1.15.х Decort-SDK соответствует 4.7.0 версии платформы
- Версия 1.16.х Decort-SDK соответствует 4.8.0 версии платформы
## Оглавление
@@ -124,6 +126,7 @@ go get -u repository.basistech.ru/BASIS/decort-golang-sdk
- `LB` - управление балансировщиками нагрузки;
- `Locations` - получение информации о grid площадки;
- `Prometheus` - получение статистики prometheus;
- `QoS Policy` - управление политиками качества обслуживания сети;
- `RG` - управление ресурсными группами аккаунта;
- `Security group` управление группами безопасности;
- `SEP` - управление storage endpoint (sep);
@@ -132,6 +135,7 @@ go get -u repository.basistech.ru/BASIS/decort-golang-sdk
- `Trunk` - получение информации о транковых портах;
- `VFPool` - управление пулом виртуальных сетевых функций;
- `VINS` - управление виртуальными изолированными сетями;
- `VGPU` - управление виртуальными графическими процессорами;
- `Zone` - управление зонами.
### Cloudbroker
@@ -159,8 +163,8 @@ go get -u repository.basistech.ru/BASIS/decort-golang-sdk
- `Node` - управление нодами платформы;
- `PCIDevice` - управление устройствами;
- `Prometheus` - получение статистики prometheus;
- `QoS Policy` - управление политиками качества обслуживания сети;
- `Resmon` - получение статистики resource monitoring;
- `ResourceOptimizer` - управление инструментом оптимизации ресурсов (DRS);
- `RG` - управление ресурсными группами аккаунта;
- `Security group` управление группами безопасности;
- `SEP` - управление storage endpoint (sep);
@@ -337,6 +341,7 @@ func main() {
- `pkg/cloudapi/lb` - для `LB`
- `pkg/cloudapi/locations` - для `Locations`
- `pkg/cloudapi/prometheus` - для `Prometheus`
- `pkg/cloudapi/qospolicy` - для `QoS Policy`
- `pkg/cloudapi/rg` - для `RG`
- `pkg/cloudapi/secgroup` - для `Security group`
- `pkg/cloudapi/sep` - для `SEP`
@@ -345,6 +350,7 @@ func main() {
- `pkg/cloudapi/trunk` - для `Trunk`
- `pkg/cloudapi/vfpool` - для `VFPool`
- `pkg/cloudapi/vins` - для `VINS`
- `pkg/cloudapi/vgpu` - для `VGPU`
- `pkg/cloudapi/zone` - для `Zone`
- **cloudbroker**:
- `pkg/cloudbroker/account` - для `Account`
@@ -367,8 +373,8 @@ func main() {
- `pkg/cloudbroker/node` - для `Node`
- `pkg/cloudbroker/pcidevice` - для `PCIDevice`
- `pkg/cloudbroker/prometheus` - для `Prometheus`
- `pkg/cloudbroker/qospolicy` - для `QoS Policy`
- `pkg/cloudbroker/resmon` - для `Resmon`
- `pkg/cloudbroker/resource_optimizer` - для `ResourceOptimizer`
- `pkg/cloudbroker/rg` - для `RG`
- `pkg/cloudbroker/secgroup` - для `Security group`
- `pkg/cloudbroker/sep` - для `SEP`
@@ -536,6 +542,7 @@ func main() {
- `.LB()` - для работы с `LB`
- `.Locations()` - для работы с `Locations`
- `.Prometheus()` - для работы с `Prometheus`
- `.QoSPolicy()` - для работы с `QoS Policy`
- `.RG()` - для работы с `RG`
- `.SecurityGroup()` - для работы с `Security Group`
- `.SEP()` - для работы с `SEP`
@@ -544,6 +551,7 @@ func main() {
- `.Trunk()` - для работы с `Trunk`
- `.VFPool()` - для работы с `VFPool`
- `.VINS()` - для работы с `VINS`
- `.VGPU()` - для работы с `VGPU`
- `.Zone()` - для работы с `Zone`
Доступные методы для `.CloudBroker()`:
@@ -568,8 +576,8 @@ func main() {
- `.Node()` - для работы с `Node`
- `.PCIDevice()` - для работы с `PCIDevice`
- `.Prometheus()` - для работы с `Prometheus`
- `.QoSPolicy()` - для работы с `QoS Policy`
- `.Resmon()` - для работы с `Resmon`
- `.ResourceOptimizer()` - для работы с `ResourceOptimizer`
- `.RG()` - для работы с `RG`
- `.SecurityGroup()` - для работы с `Security Group`
- `.SEP()` - для работы с `SEP`

View File

@@ -34,8 +34,12 @@ type DecortClient struct {
mutex *sync.Mutex
}
// Сlient builder
// Client builder
func New(cfg config.Config) *DecortClient {
if err := validators.ValidateConfig(cfg); err != nil {
panic(validators.ValidationErrors(validators.GetErrors(err)))
}
if cfg.Retries == 0 {
cfg.Retries = 5
}

View File

@@ -16,6 +16,7 @@ import (
"github.com/google/go-querystring/query"
"repository.basistech.ru/BASIS/decort-golang-sdk/config"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/sdn"
@@ -38,6 +39,10 @@ type tokenJSON struct {
// Сlient builder
func NewBVS(cfg config.BVSConfig) *BVSDecortClient {
if err := validators.ValidateConfig(cfg); err != nil {
panic(validators.ValidationErrors(validators.GetErrors(err)))
}
if cfg.Retries == 0 {
cfg.Retries = 5
}

View File

@@ -28,6 +28,8 @@ var FileName = map[string]string{
var K8sValues = []string{"labels", "taints", "annotations, additionalSANs"}
var VersionMap = map[string]string{
"4.8.0": "-",
"4.7.0": "-",
"4.6.0": "-",
"4.5.0": "-",
"4.4.0": "-",

View File

@@ -350,6 +350,10 @@ func isBoolTypeValidator(fe validator.FieldLevel) bool {
return fe.Field().CanConvert(reflect.TypeOf(true))
}
func isStringTypeValidator(fe validator.FieldLevel) bool {
return fe.Field().Kind() == reflect.String
}
func urlValidartor(fl validator.FieldLevel) bool {
fieldValues := fl.Field().String()
@@ -464,3 +468,35 @@ func sepTechStatusValidator(fe validator.FieldLevel) bool {
return IsInSlice(fieldValue, sepTechStatusValues)
}
// pciDeviceHWPathValidator is used to validate PCI device hardware path fields (e.g. 0000:81:00.0)
func pciDeviceHWPathValidator(fe validator.FieldLevel) bool {
fieldValue := fe.Field().String()
ok, _ := regexp.MatchString(`^[0-9a-fA-F]{4}:[0-9a-fA-F]{2}:[0-9a-fA-F]{2}\.[0-7]$`, fieldValue)
return ok
}
// sepNameValidator is used to validate SEP name fields
func sepNameValidator(fe validator.FieldLevel) bool {
ok, _ := regexp.MatchString(`^[a-zA-Zа-яА-ЯёЁ0-9][a-zA-Zа-яА-ЯёЁ0-9_.\[\]()\-]*$`, fe.Field().String())
return ok
}
// sepDescriptionValidator is used to validate SEP description fields
func sepDescriptionValidator(fe validator.FieldLevel) bool {
ok, _ := regexp.MatchString(`^[a-zA-Zа-яА-ЯёЁ0-9_.\[\]()\-]*$`, fe.Field().String())
return ok
}
func watchdogActionValidator(fe validator.FieldLevel) bool {
fieldValue := fe.Field().String()
return IsInSlice(fieldValue, watchdogActionValues)
}
func memoryBalloonModeValidator(fe validator.FieldLevel) bool {
fieldValue := fe.Field().String()
return IsInSlice(fieldValue, memoryBalloonModeValues)
}

View File

@@ -15,6 +15,10 @@ func errorMessage(fe validator.FieldError) string {
// Common Validators
case "required":
return fmt.Sprintf("%s %s is required", prefix, fe.Field())
case "required_without_all":
return fmt.Sprintf("%s at least one of the following must be specified: %s",
prefix,
joinValues(append([]string{fe.Field()}, strings.Fields(fe.Param())...)))
case "gt":
return fmt.Sprintf("%s %s can't be less or equal to zero", prefix, fe.Field())
case "min":
@@ -25,8 +29,12 @@ func errorMessage(fe validator.FieldError) string {
return fmt.Sprintf("%s %s: unexpected URL format", prefix, fe.Field())
case "email":
return fmt.Sprintf("%s %s: unexpected E-Mail format", prefix, fe.Field())
case "mac":
return fmt.Sprintf("%s %s: unexpected MAC address format", prefix, fe.Field())
case "isBool":
return fmt.Sprintf("%s %s: must be bool type", prefix, fe.Field())
case "isString":
return fmt.Sprintf("%s %s: must be string type", prefix, fe.Field())
case "accessType":
return fmt.Sprintf("%s %s must be one of the following: %s",

View File

@@ -231,6 +231,11 @@ func registerAllValidators(validate *validator.Validate) error {
return err
}
err = validate.RegisterValidation("isString", isStringTypeValidator)
if err != nil {
return err
}
err = validate.RegisterValidation("url", urlValidartor)
if err != nil {
return err
@@ -306,5 +311,30 @@ func registerAllValidators(validate *validator.Validate) error {
return err
}
err = validate.RegisterValidation("pciDeviceHWPath", pciDeviceHWPathValidator)
if err != nil {
return err
}
err = validate.RegisterValidation("sepName", sepNameValidator)
if err != nil {
return err
}
err = validate.RegisterValidation("sepDescription", sepDescriptionValidator)
if err != nil {
return err
}
err = validate.RegisterValidation("watchdogAction", watchdogActionValidator)
if err != nil {
return err
}
err = validate.RegisterValidation("memoryBalloonMode", memoryBalloonModeValidator)
if err != nil {
return err
}
return nil
}

View File

@@ -47,7 +47,7 @@ var (
vmActionValues = []string{"stop", "move"}
computeFeaturesValues = []string{"hugepages", "numa", "cpupin", "vfnic", "dpdk", "changemac", "trunk"}
computeFeaturesValues = []string{"hugepages", "numa", "cpupin", "vfnic", "dpdk", "changemac", "trunk", "vgpu", "pcidevice"}
networkInterfaceNamingValues = []string{"eth", "ens"}
@@ -80,6 +80,10 @@ var (
ipTypeValues = []string{"v4, v6"}
sepTechStatusValues = []string{"ENABLED", "DISABLED"}
watchdogActionValues = []string{"reset", "shutdown", "poweroff", "pause", "none"}
memoryBalloonModeValues = []string{"auto", "legacy", "none"}
)
const (

View File

@@ -16,6 +16,7 @@ import (
"github.com/google/go-querystring/query"
"repository.basistech.ru/BASIS/decort-golang-sdk/config"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/sdn"
@@ -32,6 +33,10 @@ type LegacyDecortClient struct {
// Legacy client builder
func NewLegacy(cfg config.LegacyConfig) *LegacyDecortClient {
if err := validators.ValidateConfig(cfg); err != nil {
panic(validators.ValidationErrors(validators.GetErrors(err)))
}
if cfg.Retries == 0 {
cfg.Retries = 5
}

View File

@@ -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
}

View File

@@ -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 {

View File

@@ -1,40 +0,0 @@
package account
import (
"context"
"encoding/json"
"net/http"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
// AuditsRequest struct to give list of account audits
type AuditsRequest struct {
// ID of the account
// Required: true
AccountID uint64 `url:"accountId" json:"accountId" validate:"required"`
}
// Audits gets audit records for the specified account object
func (a Account) Audits(ctx context.Context, req AuditsRequest) (ListAudits, error) {
err := validators.ValidateRequest(req)
if err != nil {
return nil, validators.ValidationErrors(validators.GetErrors(err))
}
url := "/cloudapi/account/audits"
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
if err != nil {
return nil, err
}
list := ListAudits{}
err = json.Unmarshal(res, &list)
if err != nil {
return nil, err
}
return list, nil
}

View File

@@ -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
}

View File

@@ -1,36 +0,0 @@
package account
import (
"context"
"net/http"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
// DeleteRequest struct to delete account
type DeleteRequest struct {
// ID of account to delete
// Required: true
AccountID uint64 `url:"accountId" json:"accountId" validate:"required"`
// Whether to completely delete the account
// Required: false
Permanently bool `url:"permanently,omitempty" json:"permanently,omitempty"`
}
// Delete completes delete an account from the system Returns true if account is deleted or was already deleted or never existed
func (a Account) Delete(ctx context.Context, req DeleteRequest) (string, error) {
err := validators.ValidateRequest(req)
if err != nil {
return "", validators.ValidationErrors(validators.GetErrors(err))
}
url := "/cloudapi/account/delete"
result, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
if err != nil {
return "", err
}
return string(result), nil
}

View File

@@ -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 {

View File

@@ -1,60 +0,0 @@
package account
import (
"context"
"net/http"
"strconv"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
// DisableEnableRequest struct to change status of account
type DisableEnableRequest struct {
// ID of account
// Required: true
AccountID uint64 `url:"accountId" json:"accountId" validate:"required"`
}
// Disable disables an account
func (a Account) Disable(ctx context.Context, req DisableEnableRequest) (bool, error) {
err := validators.ValidateRequest(req)
if err != nil {
return false, validators.ValidationErrors(validators.GetErrors(err))
}
url := "/cloudapi/account/disable"
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
if err != nil {
return false, err
}
result, err := strconv.ParseBool(string(res))
if err != nil {
return false, err
}
return result, nil
}
// Enable enables an account
func (a Account) Enable(ctx context.Context, req DisableEnableRequest) (bool, error) {
err := validators.ValidateRequest(req)
if err != nil {
return false, validators.ValidationErrors(validators.GetErrors(err))
}
url := "/cloudapi/account/enable"
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
if err != nil {
return false, err
}
result, err := strconv.ParseBool(string(res))
if err != nil {
return false, err
}
return result, nil
}

View File

@@ -1,51 +0,0 @@
package account
import (
"context"
"net/http"
"strconv"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
// GetConsumedCloudUnitsByTypeRequest struct to calculate the currently consumed cloud units of the specified type for all cloudspaces and resource groups in the account
type GetConsumedCloudUnitsByTypeRequest struct {
// ID an account
// Required: true
AccountID uint64 `url:"accountId" json:"accountId" validate:"required"`
// Cloud unit resource type
// Required: true
CUType string `url:"cutype" json:"cutype" validate:"required,accountCUType"`
}
// GetConsumedCloudUnitsByType calculates the currently consumed cloud units of the specified type for all cloudspaces
// and resource groups in the account.
// Possible types of cloud units are include:
//
// - CU_M: returns consumed memory in MB
// - CU_C: returns number of virtual cpu cores
// - CU_D: returns consumed virtual disk storage in GB
// - CU_DM: returns consumed max virtual disk storage in GB
// - CU_I: returns number of public IPs
// - gpu_units: return number of GPU units
func (a Account) GetConsumedCloudUnitsByType(ctx context.Context, req GetConsumedCloudUnitsByTypeRequest) (float64, error) {
err := validators.ValidateRequest(req)
if err != nil {
return 0, validators.ValidationErrors(validators.GetErrors(err))
}
url := "/cloudapi/account/getConsumedCloudUnitsByType"
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
if err != nil {
return 0, err
}
result, err := strconv.ParseFloat(string(res), 64)
if err != nil {
return 0, err
}
return result, nil
}

View File

@@ -1,47 +0,0 @@
package account
import (
"context"
"encoding/json"
"net/http"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
// GetReservedAccountUnitsRequest struct to calculate the reserved units for all cloudspaces and resource groups in the account
type GetReservedAccountUnitsRequest struct {
// ID an account
// Required: true
AccountID uint64 `url:"accountId" json:"accountId" validate:"required"`
}
// GetReservedAccountUnits calculates the reserved units for all cloudspaces and resource groups in the account.
// Calculated cloud units are returned in a dict which includes:
//
// - CU_M: reserved memory in MB
// - CU_C: number of cpu cores
// - CU_D: reserved vdisk storage in GB
// - CU_DM: reserved max vdisk storage in GB
// - CU_I: number of public IPs
func (a Account) GetReservedAccountUnits(ctx context.Context, req GetReservedAccountUnitsRequest) (*ResourceLimits, error) {
err := validators.ValidateRequest(req)
if err != nil {
return nil, validators.ValidationErrors(validators.GetErrors(err))
}
url := "/cloudapi/account/getReservedAccountUnits"
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
if err != nil {
return nil, err
}
info := ResourceLimits{}
err = json.Unmarshal(res, &info)
if err != nil {
return nil, err
}
return &info, nil
}

View File

@@ -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
@@ -203,11 +200,56 @@ type ListResourceConsumption struct {
// Information about computes
type Computes struct {
// Number of starting computes
Starting uint64 `json:"STARTING"`
// Number of started computes
Started uint64 `json:"started"`
Started uint64 `json:"STARTED"`
// Number of stopping computes
Stopping uint64 `json:"STOPPING"`
// Number of stopped computes
Stopped uint64 `json:"stopped"`
Stopped uint64 `json:"STOPPED"`
// Number of paused computes
Paused uint64 `json:"PAUSED"`
// Number of pausing computes
Pausing uint64 `json:"PAUSING"`
// Number of merging computes
Merge uint64 `json:"MERGE"`
// Number of migrating computes
Migrating uint64 `json:"MIGRATING"`
// Number of computes migrating in
MigratingIn uint64 `json:"MIGRATING_IN"`
// Number of computes migrating out
MigratingOut uint64 `json:"MIGRATING_OUT"`
// Number of computes in down status
Down uint64 `json:"DOWN"`
// Number of scheduled computes
Scheduled uint64 `json:"SCHEDULED"`
// Number of computes with stopped backup
BackupStopped uint64 `json:"BACKUP_STOPPED"`
// Number of computes with running backup
BackupRunning uint64 `json:"BACKUP_RUNNING"`
// Number of computes creating a snapshot
Snapcreate uint64 `json:"SNAPCREATE"`
// Number of cloning computes
Cloning uint64 `json:"CLONING"`
// Number of computes being rolled back
Rollback uint64 `json:"ROLLBACK"`
}
// Information about machines
@@ -252,7 +294,7 @@ type RecordAccount struct {
CPUAllocationParameter string `json:"cpu_allocation_parameter"`
// CPU allocation ratio
CPUAllocationRatio float64 `json:"cpu_allocation_ratio"`
CPUAllocationRatio uint64 `json:"cpu_allocation_ratio"`
// Created by
CreatedBy string `json:"createdBy"`
@@ -455,6 +497,9 @@ type ItemVINS struct {
// Deleted time
DeletedTime uint64 `json:"deletedTime"`
// Enable Default Gateway
EnableDefaultGateway bool `json:"enable_default_gateway"`
// External IP
ExternalIP string `json:"externalIP"`
@@ -524,11 +569,56 @@ type ListAudits []ItemAudit
// Information compute in resource group
type RGComputes struct {
// Number of starting computes
Starting uint64 `json:"STARTING"`
// Number of started computes
Started uint64 `json:"Started"`
Started uint64 `json:"STARTED"`
// Number of stopping computes
Stopping uint64 `json:"STOPPING"`
// Number of stopped computes
Stopped uint64 `json:"Stopped"`
Stopped uint64 `json:"STOPPED"`
// Number of paused computes
Paused uint64 `json:"PAUSED"`
// Number of pausing computes
Pausing uint64 `json:"PAUSING"`
// Number of merging computes
Merge uint64 `json:"MERGE"`
// Number of migrating computes
Migrating uint64 `json:"MIGRATING"`
// Number of computes migrating in
MigratingIn uint64 `json:"MIGRATING_IN"`
// Number of computes migrating out
MigratingOut uint64 `json:"MIGRATING_OUT"`
// Number of computes in down status
Down uint64 `json:"DOWN"`
// Number of scheduled computes
Scheduled uint64 `json:"SCHEDULED"`
// Number of computes with stopped backup
BackupStopped uint64 `json:"BACKUP_STOPPED"`
// Number of computes with running backup
BackupRunning uint64 `json:"BACKUP_RUNNING"`
// Number of computes creating a snapshot
Snapcreate uint64 `json:"SNAPCREATE"`
// Number of cloning computes
Cloning uint64 `json:"CLONING"`
// Number of computes being rolled back
Rollback uint64 `json:"ROLLBACK"`
}
// Resources of Resource group

View File

@@ -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
}

View File

@@ -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 {

View File

@@ -5,6 +5,7 @@ import (
"net/http"
"strconv"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
@@ -62,9 +63,9 @@ type GroupAddRequest struct {
// Required: false
TimeoutStart uint64 `url:"timeoutStart,omitempty" json:"timeoutStart,omitempty"`
// Meta data for working group computes, format YAML "user_data": 1111
// Meta data for working group computes, format yaml string or json object
// Required: false
UserData string `url:"userData,omitempty" json:"userData,omitempty"`
UserData interface{} `url:"userData,omitempty" json:"userData,omitempty"`
// Chipset "i440fx" or "Q35
// Default value : Q35
@@ -97,7 +98,7 @@ func (b BService) GroupAdd(ctx context.Context, req GroupAddRequest) (uint64, er
url := "/cloudapi/bservice/groupAdd"
res, err := b.client.DecortApiCall(ctx, http.MethodPost, url, req)
res, err := b.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
if err != nil {
return 0, err
}

View File

@@ -18,6 +18,11 @@ type AbortSharedSnapshotMergeRequest struct {
Label string `url:"label" json:"label" validate:"required"`
}
type wrapperAbortSharedSnapshotMergeRequest struct {
AbortSharedSnapshotMergeRequest
AsyncMode bool `url:"asyncMode"`
}
// AbortSharedSnapshotMerge shared snapshots merge abort
func (c Compute) AbortSharedSnapshotMerge(ctx context.Context, req AbortSharedSnapshotMergeRequest) (string, error) {
err := validators.ValidateRequest(req)
@@ -25,9 +30,36 @@ func (c Compute) AbortSharedSnapshotMerge(ctx context.Context, req AbortSharedSn
return "", validators.ValidationErrors(validators.GetErrors(err))
}
reqWrapped := wrapperAbortSharedSnapshotMergeRequest{
AbortSharedSnapshotMergeRequest: req,
AsyncMode: false,
}
url := "/cloudapi/compute/abort_shared_snapshot_merge"
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
if err != nil {
return "", err
}
return string(res), nil
}
// AbortSharedSnapshotMergeAsync shared snapshots merge abort in async mode
func (c Compute) AbortSharedSnapshotMergeAsync(ctx context.Context, req AbortSharedSnapshotMergeRequest) (string, error) {
err := validators.ValidateRequest(req)
if err != nil {
return "", validators.ValidationErrors(validators.GetErrors(err))
}
reqWrapped := wrapperAbortSharedSnapshotMergeRequest{
AbortSharedSnapshotMergeRequest: req,
AsyncMode: true,
}
url := "/cloudapi/compute/abort_shared_snapshot_merge"
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
if err != nil {
return "", err
}

View File

@@ -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
}

View File

@@ -1,76 +0,0 @@
package compute
import (
"context"
"encoding/json"
"net/http"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
// AuditsRequest struct to get audit records
type AuditsRequest struct {
// ID of the compute
// Required: true
ComputeID uint64 `url:"compute_id" json:"compute_id" validate:"required"`
// Find all audits after point in time
// Required: false
TimestampAT uint64 `url:"timestamp_at,omitempty" json:"timestamp_at,omitempty"`
// Find all audits before point in time
// Required: false
TimestampTO uint64 `url:"timestamp_to,omitempty" json:"timestamp_to,omitempty"`
// Find by user
// Required: false
User string `url:"user,omitempty" json:"user,omitempty"`
// Find by api endpoints
// Required: false
Call string `url:"call,omitempty" json:"call,omitempty"`
// Sort by one of supported fields, format ±<field>
// Required: false
SortBy string `url:"sort_by,omitempty" json:"sort_by,omitempty"`
// Page number
// Required: false
Page uint64 `url:"page,omitempty" json:"page,omitempty"`
// Page size
// Required: false
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
// Find by HTTP min status code
// Required: false
MinStatusCode uint64 `url:"min_status_code,omitempty" json:"min_status_code,omitempty"`
// Find by HTTP max status code
// Required: false
MaxStatusCode uint64 `url:"max_status_code,omitempty" json:"max_status_code,omitempty"`
}
// Audits gets audit records for the specified compute object
func (c Compute) Audits(ctx context.Context, req AuditsRequest) (*ListAudits, error) {
err := validators.ValidateRequest(req)
if err != nil {
return nil, validators.ValidationErrors(validators.GetErrors(err))
}
url := "/cloudapi/compute/audits"
res, err := c.client.DecortApiCall(ctx, http.MethodGet, url, req)
if err != nil {
return nil, err
}
list := ListAudits{}
err = json.Unmarshal(res, &list)
if err != nil {
return nil, err
}
return &list, nil
}

View File

@@ -15,6 +15,12 @@ type CDEjectRequest struct {
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
}
type wrapperCDEjectRequest struct {
CDEjectRequest
AsyncMode bool `url:"asyncMode"`
}
// CDEject eject CD image to compute's CD-ROM
func (c Compute) CDEject(ctx context.Context, req CDEjectRequest) (bool, error) {
err := validators.ValidateRequest(req)
@@ -22,9 +28,14 @@ func (c Compute) CDEject(ctx context.Context, req CDEjectRequest) (bool, error)
return false, validators.ValidationErrors(validators.GetErrors(err))
}
reqWrapped := wrapperCDEjectRequest{
CDEjectRequest: req,
AsyncMode: false,
}
url := "/cloudapi/compute/cdEject"
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
if err != nil {
return false, err
}
@@ -33,5 +44,28 @@ func (c Compute) CDEject(ctx context.Context, req CDEjectRequest) (bool, error)
if err != nil {
return false, err
}
return result, nil
}
// CDEjectAsync ejects CD image to compute's CD-ROM with AsyncMode
func (c Compute) CDEjectAsync(ctx context.Context, req CDEjectRequest) (string, error) {
err := validators.ValidateRequest(req)
if err != nil {
return "", validators.ValidationErrors(validators.GetErrors(err))
}
reqWrapped := wrapperCDEjectRequest{
CDEjectRequest: req,
AsyncMode: true,
}
url := "/cloudapi/compute/cdEject"
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
if err != nil {
return "", err
}
return string(res), nil
}

View File

@@ -19,6 +19,12 @@ type CDInsertRequest struct {
CDROMID uint64 `url:"cdromId" json:"cdromId" validate:"required"`
}
type wrapperCDInsertRequest struct {
CDInsertRequest
AsyncMode bool `url:"asyncMode"`
}
// CDInsert insert new CD image to compute's CD-ROM
func (c Compute) CDInsert(ctx context.Context, req CDInsertRequest) (bool, error) {
err := validators.ValidateRequest(req)
@@ -26,9 +32,14 @@ func (c Compute) CDInsert(ctx context.Context, req CDInsertRequest) (bool, error
return false, validators.ValidationErrors(validators.GetErrors(err))
}
reqWrapped := wrapperCDInsertRequest{
CDInsertRequest: req,
AsyncMode: false,
}
url := "/cloudapi/compute/cdInsert"
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
if err != nil {
return false, err
}
@@ -37,5 +48,28 @@ func (c Compute) CDInsert(ctx context.Context, req CDInsertRequest) (bool, error
if err != nil {
return false, err
}
return result, nil
}
// CDInsertAsync inserts new CD image to compute's CD-ROM with AsyncMode
func (c Compute) CDInsertAsync(ctx context.Context, req CDInsertRequest) (string, error) {
err := validators.ValidateRequest(req)
if err != nil {
return "", validators.ValidationErrors(validators.GetErrors(err))
}
reqWrapped := wrapperCDInsertRequest{
CDInsertRequest: req,
AsyncMode: true,
}
url := "/cloudapi/compute/cdInsert"
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
if err != nil {
return "", err
}
return string(res), nil
}

View File

@@ -31,6 +31,12 @@ type ChangeIPRequest struct {
IPAddr string `url:"ip_addr" json:"ip_addr" validate:"required"`
}
type wrapperChangeIPRequest struct {
ChangeIPRequest
AsyncMode bool `url:"asyncMode"`
}
// ChangeIP change reserved IP for compute instance
func (c Compute) ChangeIP(ctx context.Context, req ChangeIPRequest) (bool, error) {
err := validators.ValidateRequest(req)
@@ -38,9 +44,14 @@ func (c Compute) ChangeIP(ctx context.Context, req ChangeIPRequest) (bool, error
return false, validators.ValidationErrors(validators.GetErrors(err))
}
reqWrapped := wrapperChangeIPRequest{
ChangeIPRequest: req,
AsyncMode: false,
}
url := "/cloudapi/compute/changeIp"
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
if err != nil {
return false, err
}
@@ -52,3 +63,25 @@ func (c Compute) ChangeIP(ctx context.Context, req ChangeIPRequest) (bool, error
return result, nil
}
// ChangeIPAsync change reserved IP for compute instance with AsyncMode
func (c Compute) ChangeIPAsync(ctx context.Context, req ChangeIPRequest) (string, error) {
err := validators.ValidateRequest(req)
if err != nil {
return "", validators.ValidationErrors(validators.GetErrors(err))
}
reqWrapped := wrapperChangeIPRequest{
ChangeIPRequest: req,
AsyncMode: true,
}
url := "/cloudapi/compute/changeIp"
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
if err != nil {
return "", err
}
return string(res), nil
}

View File

@@ -3,8 +3,9 @@ package compute
import (
"context"
"net/http"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
"strconv"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
// ChangeLinkStateRequest struct to change link state
@@ -23,6 +24,12 @@ type ChangeLinkStateRequest struct {
State string `url:"state" json:"state" validate:"required,interfaceState"`
}
type wrapperChangeLinkStateRequest struct {
ChangeLinkStateRequest
AsyncMode bool `url:"asyncMode"`
}
// ChangeLinkState changes the status link virtual of compute
func (c Compute) ChangeLinkState(ctx context.Context, req ChangeLinkStateRequest) (bool, error) {
err := validators.ValidateRequest(req)
@@ -30,9 +37,14 @@ func (c Compute) ChangeLinkState(ctx context.Context, req ChangeLinkStateRequest
return false, validators.ValidationErrors(validators.GetErrors(err))
}
reqWrapped := wrapperChangeLinkStateRequest{
ChangeLinkStateRequest: req,
AsyncMode: false,
}
url := "/cloudapi/compute/changeLinkState"
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
if err != nil {
return false, err
}
@@ -41,5 +53,28 @@ func (c Compute) ChangeLinkState(ctx context.Context, req ChangeLinkStateRequest
if err != nil {
return false, err
}
return result, nil
}
// ChangeLinkStateAsync changes the status link virtual of compute with AsyncMode
func (c Compute) ChangeLinkStateAsync(ctx context.Context, req ChangeLinkStateRequest) (string, error) {
err := validators.ValidateRequest(req)
if err != nil {
return "", validators.ValidationErrors(validators.GetErrors(err))
}
reqWrapped := wrapperChangeLinkStateRequest{
ChangeLinkStateRequest: req,
AsyncMode: true,
}
url := "/cloudapi/compute/changeLinkState"
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
if err != nil {
return "", err
}
return string(res), nil
}

View File

@@ -23,6 +23,12 @@ type ChangeMTURequest struct {
MTU uint64 `url:"mtu" json:"mtu" validate:"required" validate:"omitempty,mtu"`
}
type wrapperChangeMTURequest struct {
ChangeMTURequest
AsyncMode bool `url:"asyncMode"`
}
// ChangeMTU change MTU for compute instance
func (c Compute) ChangeMTU(ctx context.Context, req ChangeMTURequest) (bool, error) {
err := validators.ValidateRequest(req)
@@ -30,9 +36,14 @@ func (c Compute) ChangeMTU(ctx context.Context, req ChangeMTURequest) (bool, err
return false, validators.ValidationErrors(validators.GetErrors(err))
}
reqWrapped := wrapperChangeMTURequest{
ChangeMTURequest: req,
AsyncMode: false,
}
url := "/cloudapi/compute/change_mtu"
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
if err != nil {
return false, err
}
@@ -44,3 +55,25 @@ func (c Compute) ChangeMTU(ctx context.Context, req ChangeMTURequest) (bool, err
return result, nil
}
// ChangeMTUAsync change MTU for compute instance with AsyncMode
func (c Compute) ChangeMTUAsync(ctx context.Context, req ChangeMTURequest) (string, error) {
err := validators.ValidateRequest(req)
if err != nil {
return "", validators.ValidationErrors(validators.GetErrors(err))
}
reqWrapped := wrapperChangeMTURequest{
ChangeMTURequest: req,
AsyncMode: true,
}
url := "/cloudapi/compute/change_mtu"
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
if err != nil {
return "", err
}
return string(res), nil
}

View File

@@ -0,0 +1,84 @@
package compute
import (
"context"
"net/http"
"strconv"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
type ChangeQoSPoliciesRequest struct {
// Compute ID
// Required: true
ComputeID uint64 `url:"compute_id" json:"compute_id" validate:"required"`
// Interface IP or MAC address
// Required: true
Interface string `url:"interface" json:"interface" validate:"required"`
// List of QoS Policy IDs to assign to this interface
// Required: false
QoSPolicyIDs []uint64 `url:"qos_policy_ids,omitempty" json:"qos_policy_ids,omitempty"`
}
type wrapperChangeQoSPoliciesRequest struct {
ChangeQoSPoliciesRequest
AsyncMode bool `url:"asyncMode"`
}
// ChangeQoSPolicies change qos policies for compute
func (c Compute) ChangeQoSPolicies(ctx context.Context, req ChangeQoSPoliciesRequest) (bool, error) {
err := validators.ValidateRequest(req)
if err != nil {
return false, validators.ValidationErrors(validators.GetErrors(err))
}
reqWrapped := wrapperChangeQoSPoliciesRequest{
ChangeQoSPoliciesRequest: req,
AsyncMode: false,
}
url := "/cloudapi/compute/change_qos_policies"
res, err := c.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, reqWrapped)
if err != nil {
return false, err
}
result, err := strconv.ParseBool(string(res))
if err != nil {
return false, err
}
return result, nil
}
// ChangeQoSPolicies change qos policies for compute with AsyncMode
func (c Compute) ChangeQoSPoliciesAsync(ctx context.Context, req ChangeQoSPoliciesRequest) (bool, error) {
err := validators.ValidateRequest(req)
if err != nil {
return false, validators.ValidationErrors(validators.GetErrors(err))
}
reqWrapped := wrapperChangeQoSPoliciesRequest{
ChangeQoSPoliciesRequest: req,
AsyncMode: true,
}
url := "/cloudapi/compute/change_qos_policies"
res, err := c.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, reqWrapped)
if err != nil {
return false, err
}
result, err := strconv.ParseBool(string(res))
if err != nil {
return false, err
}
return result, nil
}

View File

@@ -27,6 +27,12 @@ type ChangeSecGroupsRequest struct {
EnableSecGroups interface{} `url:"enable_secgroups,omitempty" json:"enable_secgroups,omitempty" validate:"omitempty,isBool"`
}
type wrapperChangeSecGroupsRequest struct {
ChangeSecGroupsRequest
AsyncMode bool `url:"asyncMode"`
}
// ChangeSecGroups changes security groups for compute
func (c Compute) ChangeSecGroups(ctx context.Context, req ChangeSecGroupsRequest) (bool, error) {
err := validators.ValidateRequest(req)
@@ -34,9 +40,14 @@ func (c Compute) ChangeSecGroups(ctx context.Context, req ChangeSecGroupsRequest
return false, validators.ValidationErrors(validators.GetErrors(err))
}
reqWrapped := wrapperChangeSecGroupsRequest{
ChangeSecGroupsRequest: req,
AsyncMode: false,
}
url := "/cloudapi/compute/change_security_groups"
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
if err != nil {
return false, err
}
@@ -48,3 +59,25 @@ func (c Compute) ChangeSecGroups(ctx context.Context, req ChangeSecGroupsRequest
return result, nil
}
// ChangeSecGroupsAsync changes security groups for compute with AsyncMode
func (c Compute) ChangeSecGroupsAsync(ctx context.Context, req ChangeSecGroupsRequest) (string, error) {
err := validators.ValidateRequest(req)
if err != nil {
return "", validators.ValidationErrors(validators.GetErrors(err))
}
reqWrapped := wrapperChangeSecGroupsRequest{
ChangeSecGroupsRequest: req,
AsyncMode: true,
}
url := "/cloudapi/compute/change_security_groups"
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
if err != nil {
return "", err
}
return string(res), nil
}

View File

@@ -44,6 +44,12 @@ type CloneRequest struct {
SEPID uint64 `url:"sep_id" json:"sep_id"`
}
type wrapperCloneRequest struct {
CloneRequest
AsyncMode bool `url:"asyncMode" json:"asyncMode"`
}
// Clone clones compute instance
func (c Compute) Clone(ctx context.Context, req CloneRequest) (string, error) {
err := validators.ValidateRequest(req)
@@ -51,9 +57,36 @@ func (c Compute) Clone(ctx context.Context, req CloneRequest) (string, error) {
return "", validators.ValidationErrors(validators.GetErrors(err))
}
reqWrapped := wrapperCloneRequest{
CloneRequest: req,
AsyncMode: false,
}
url := "/cloudapi/compute/clone"
res, err := c.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
res, err := c.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, reqWrapped)
if err != nil {
return "", err
}
return string(res), nil
}
// CloneAsync clones compute instance with AsyncMode
func (c Compute) CloneAsync(ctx context.Context, req CloneRequest) (string, error) {
err := validators.ValidateRequest(req)
if err != nil {
return "", validators.ValidationErrors(validators.GetErrors(err))
}
reqWrapped := wrapperCloneRequest{
CloneRequest: req,
AsyncMode: true,
}
url := "/cloudapi/compute/clone"
res, err := c.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, reqWrapped)
if err != nil {
return "", err
}

View File

@@ -0,0 +1,39 @@
package compute
import (
"context"
"net/http"
"strconv"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
// 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
}

View File

@@ -23,6 +23,12 @@ type DeleteRequest struct {
DetachDisks bool `url:"detachDisks,omitempty" json:"detachDisks,omitempty"`
}
type wrapperDeleteRequest struct {
DeleteRequest
AsyncMode bool `url:"asyncMode"`
}
// Delete deletes compute
func (c Compute) Delete(ctx context.Context, req DeleteRequest) (bool, error) {
err := validators.ValidateRequest(req)
@@ -30,9 +36,14 @@ func (c Compute) Delete(ctx context.Context, req DeleteRequest) (bool, error) {
return false, validators.ValidationErrors(validators.GetErrors(err))
}
reqWrapped := wrapperDeleteRequest{
DeleteRequest: req,
AsyncMode: false,
}
url := "/cloudapi/compute/delete"
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
if err != nil {
return false, err
}
@@ -44,3 +55,25 @@ func (c Compute) Delete(ctx context.Context, req DeleteRequest) (bool, error) {
return result, nil
}
// DeleteAsync deletes compute with AsyncMode
func (c Compute) DeleteAsync(ctx context.Context, req DeleteRequest) (string, error) {
err := validators.ValidateRequest(req)
if err != nil {
return "", validators.ValidationErrors(validators.GetErrors(err))
}
reqWrapped := wrapperDeleteRequest{
DeleteRequest: req,
AsyncMode: true,
}
url := "/cloudapi/compute/delete"
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
if err != nil {
return "", err
}
return string(res), nil
}

View File

@@ -0,0 +1,39 @@
package compute
import (
"context"
"net/http"
"strconv"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
// DeleteCPUAlignmentProfileRequest struct to delete CPU alignment profile for computes
type DeleteCPUAlignmentProfileRequest struct {
// IDs of the compute instances
// Required: true
ComputeIDs []uint64 `url:"compute_ids" json:"compute_ids" validate:"min=1"`
}
// DeleteCPUAlignmentProfile deletes CPU alignment profile for computes
func (c Compute) DeleteCPUAlignmentProfile(ctx context.Context, req DeleteCPUAlignmentProfileRequest) (bool, error) {
err := validators.ValidateRequest(req)
if err != nil {
return false, validators.ValidationErrors(validators.GetErrors(err))
}
url := "/cloudapi/compute/delete_cpu_alignment_profile"
res, err := c.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
if err != nil {
return false, err
}
result, err := strconv.ParseBool(string(res))
if err != nil {
return false, err
}
return result, nil
}

View File

@@ -15,6 +15,12 @@ type DisableRequest struct {
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
}
type wrapperDisableRequest struct {
DisableRequest
AsyncMode bool `url:"asyncMode"`
}
// Disable disables compute
func (c Compute) Disable(ctx context.Context, req DisableRequest) (bool, error) {
err := validators.ValidateRequest(req)
@@ -22,9 +28,14 @@ func (c Compute) Disable(ctx context.Context, req DisableRequest) (bool, error)
return false, validators.ValidationErrors(validators.GetErrors(err))
}
reqWrapped := wrapperDisableRequest{
DisableRequest: req,
AsyncMode: false,
}
url := "/cloudapi/compute/disable"
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
if err != nil {
return false, err
}
@@ -36,3 +47,25 @@ func (c Compute) Disable(ctx context.Context, req DisableRequest) (bool, error)
return result, nil
}
// DisableAsync disables compute with AsyncMode
func (c Compute) DisableAsync(ctx context.Context, req DisableRequest) (string, error) {
err := validators.ValidateRequest(req)
if err != nil {
return "", validators.ValidationErrors(validators.GetErrors(err))
}
reqWrapped := wrapperDisableRequest{
DisableRequest: req,
AsyncMode: true,
}
url := "/cloudapi/compute/disable"
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
if err != nil {
return "", err
}
return string(res), nil
}

View File

@@ -51,6 +51,16 @@ type DiskAddRequest struct {
// Desired bus number (hex string, e.g. "0x03")
// Required: false
BusNumber string `url:"bus_number,omitempty" json:"bus_number,omitempty"`
// Mount disk in read-only mode
// Required: false
ReadOnly bool `url:"read_only,omitempty" json:"read_only,omitempty"`
}
type wrapperDiskAddRequest struct {
DiskAddRequest
AsyncMode bool `url:"asyncMode"`
}
// DiskAdd creates new disk and attach to compute
@@ -60,9 +70,14 @@ func (c Compute) DiskAdd(ctx context.Context, req DiskAddRequest) (uint64, error
return 0, validators.ValidationErrors(validators.GetErrors(err))
}
reqWrapped := wrapperDiskAddRequest{
DiskAddRequest: req,
AsyncMode: false,
}
url := "/cloudapi/compute/diskAdd"
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
if err != nil {
return 0, err
}
@@ -74,3 +89,25 @@ func (c Compute) DiskAdd(ctx context.Context, req DiskAddRequest) (uint64, error
return result, nil
}
// DiskAddAsync creates new disk and attach to compute with AsyncMode
func (c Compute) DiskAddAsync(ctx context.Context, req DiskAddRequest) (string, error) {
err := validators.ValidateRequest(req)
if err != nil {
return "", validators.ValidationErrors(validators.GetErrors(err))
}
reqWrapped := wrapperDiskAddRequest{
DiskAddRequest: req,
AsyncMode: true,
}
url := "/cloudapi/compute/diskAdd"
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
if err != nil {
return "", err
}
return string(res), nil
}

View File

@@ -25,6 +25,16 @@ type DiskAttachRequest struct {
// Desired bus number (hex string, e.g. "0x03")
// Required: false
BusNumber string `url:"bus_number,omitempty" json:"bus_number,omitempty"`
// Mount disk in read-only mode
// Required: false
ReadOnly bool `url:"read_only,omitempty" json:"read_only,omitempty"`
}
type wrapperDiskAttachRequest struct {
DiskAttachRequest
AsyncMode bool `url:"asyncMode"`
}
// DiskAttach attach disk to compute
@@ -34,9 +44,14 @@ func (c Compute) DiskAttach(ctx context.Context, req DiskAttachRequest) (bool, e
return false, validators.ValidationErrors(validators.GetErrors(err))
}
reqWrapped := wrapperDiskAttachRequest{
DiskAttachRequest: req,
AsyncMode: false,
}
url := "/cloudapi/compute/diskAttach"
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
if err != nil {
return false, err
}
@@ -48,3 +63,25 @@ func (c Compute) DiskAttach(ctx context.Context, req DiskAttachRequest) (bool, e
return result, nil
}
// DiskAttachAsync attaches disk to compute with AsyncMode
func (c Compute) DiskAttachAsync(ctx context.Context, req DiskAttachRequest) (string, error) {
err := validators.ValidateRequest(req)
if err != nil {
return "", validators.ValidationErrors(validators.GetErrors(err))
}
reqWrapped := wrapperDiskAttachRequest{
DiskAttachRequest: req,
AsyncMode: true,
}
url := "/cloudapi/compute/diskAttach"
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
if err != nil {
return "", err
}
return string(res), nil
}

View File

@@ -23,6 +23,12 @@ type DiskDelRequest struct {
Permanently bool `url:"permanently" json:"permanently"`
}
type wrapperDiskDelRequest struct {
DiskDelRequest
AsyncMode bool `url:"asyncMode"`
}
// DiskDel delete disk and detach from compute
func (c Compute) DiskDel(ctx context.Context, req DiskDelRequest) (bool, error) {
err := validators.ValidateRequest(req)
@@ -30,9 +36,14 @@ func (c Compute) DiskDel(ctx context.Context, req DiskDelRequest) (bool, error)
return false, validators.ValidationErrors(validators.GetErrors(err))
}
reqWrapped := wrapperDiskDelRequest{
DiskDelRequest: req,
AsyncMode: false,
}
url := "/cloudapi/compute/diskDel"
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
if err != nil {
return false, err
}
@@ -44,3 +55,25 @@ func (c Compute) DiskDel(ctx context.Context, req DiskDelRequest) (bool, error)
return result, nil
}
// DiskDelAsync deletes disk and detaches from compute with AsyncMode
func (c Compute) DiskDelAsync(ctx context.Context, req DiskDelRequest) (string, error) {
err := validators.ValidateRequest(req)
if err != nil {
return "", validators.ValidationErrors(validators.GetErrors(err))
}
reqWrapped := wrapperDiskDelRequest{
DiskDelRequest: req,
AsyncMode: true,
}
url := "/cloudapi/compute/diskDel"
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
if err != nil {
return "", err
}
return string(res), nil
}

View File

@@ -19,6 +19,12 @@ type DiskDetachRequest struct {
DiskID uint64 `url:"diskId" json:"diskId" validate:"required"`
}
type wrapperDiskDetachRequest struct {
DiskDetachRequest
AsyncMode bool `url:"asyncMode"`
}
// DiskDetach detach disk from compute
func (c Compute) DiskDetach(ctx context.Context, req DiskDetachRequest) (bool, error) {
err := validators.ValidateRequest(req)
@@ -26,9 +32,14 @@ func (c Compute) DiskDetach(ctx context.Context, req DiskDetachRequest) (bool, e
return false, validators.ValidationErrors(validators.GetErrors(err))
}
reqWrapped := wrapperDiskDetachRequest{
DiskDetachRequest: req,
AsyncMode: false,
}
url := "/cloudapi/compute/diskDetach"
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
if err != nil {
return false, err
}
@@ -40,3 +51,25 @@ func (c Compute) DiskDetach(ctx context.Context, req DiskDetachRequest) (bool, e
return result, nil
}
// DiskDetachAsync detaches disk from compute with AsyncMode
func (c Compute) DiskDetachAsync(ctx context.Context, req DiskDetachRequest) (string, error) {
err := validators.ValidateRequest(req)
if err != nil {
return "", validators.ValidationErrors(validators.GetErrors(err))
}
reqWrapped := wrapperDiskDetachRequest{
DiskDetachRequest: req,
AsyncMode: true,
}
url := "/cloudapi/compute/diskDetach"
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
if err != nil {
return "", err
}
return string(res), nil
}

View File

@@ -23,6 +23,12 @@ type DiskQOSRequest struct {
Limits string `url:"limits" json:"limits" validate:"required"`
}
type wrapperDiskQOSRequest struct {
DiskQOSRequest
AsyncMode bool `url:"asyncMode"`
}
// DiskQOS change QoS of the disk
func (c Compute) DiskQOS(ctx context.Context, req DiskQOSRequest) (bool, error) {
err := validators.ValidateRequest(req)
@@ -30,9 +36,14 @@ func (c Compute) DiskQOS(ctx context.Context, req DiskQOSRequest) (bool, error)
return false, validators.ValidationErrors(validators.GetErrors(err))
}
reqWrapped := wrapperDiskQOSRequest{
DiskQOSRequest: req,
AsyncMode: false,
}
url := "/cloudapi/compute/diskQos"
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
if err != nil {
return false, err
}
@@ -44,3 +55,25 @@ func (c Compute) DiskQOS(ctx context.Context, req DiskQOSRequest) (bool, error)
return result, nil
}
// DiskQOSAsync changes QoS of the disk with AsyncMode
func (c Compute) DiskQOSAsync(ctx context.Context, req DiskQOSRequest) (string, error) {
err := validators.ValidateRequest(req)
if err != nil {
return "", validators.ValidationErrors(validators.GetErrors(err))
}
reqWrapped := wrapperDiskQOSRequest{
DiskQOSRequest: req,
AsyncMode: true,
}
url := "/cloudapi/compute/diskQos"
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
if err != nil {
return "", err
}
return string(res), nil
}

View File

@@ -23,6 +23,12 @@ type DiskResizeRequest struct {
Size uint64 `url:"size" json:"size" validate:"required"`
}
type wrapperDiskResizeRequest struct {
DiskResizeRequest
AsyncMode bool `url:"asyncMode"`
}
// DiskResize change disk size
func (c Compute) DiskResize(ctx context.Context, req DiskResizeRequest) (bool, error) {
err := validators.ValidateRequest(req)
@@ -30,9 +36,14 @@ func (c Compute) DiskResize(ctx context.Context, req DiskResizeRequest) (bool, e
return false, validators.ValidationErrors(validators.GetErrors(err))
}
reqWrapped := wrapperDiskResizeRequest{
DiskResizeRequest: req,
AsyncMode: false,
}
url := "/cloudapi/compute/diskResize"
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
if err != nil {
return false, err
}
@@ -44,3 +55,25 @@ func (c Compute) DiskResize(ctx context.Context, req DiskResizeRequest) (bool, e
return result, nil
}
// DiskResizeAsync changes disk size with AsyncMode
func (c Compute) DiskResizeAsync(ctx context.Context, req DiskResizeRequest) (string, error) {
err := validators.ValidateRequest(req)
if err != nil {
return "", validators.ValidationErrors(validators.GetErrors(err))
}
reqWrapped := wrapperDiskResizeRequest{
DiskResizeRequest: req,
AsyncMode: true,
}
url := "/cloudapi/compute/diskResize"
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
if err != nil {
return "", err
}
return string(res), nil
}

View File

@@ -23,6 +23,12 @@ type DiskSwitchToReplicationRequest struct {
StopReplication bool `url:"stopReplication" json:"stopReplication"`
}
type wrapperDiskSwitchToReplicationRequest struct {
DiskSwitchToReplicationRequest
AsyncMode bool `url:"asyncMode"`
}
// DiskSwitchToReplication switches disk to it's replication
func (c Compute) DiskSwitchToReplication(ctx context.Context, req DiskSwitchToReplicationRequest) (bool, error) {
err := validators.ValidateRequest(req)
@@ -30,9 +36,14 @@ func (c Compute) DiskSwitchToReplication(ctx context.Context, req DiskSwitchToRe
return false, validators.ValidationErrors(validators.GetErrors(err))
}
reqWrapped := wrapperDiskSwitchToReplicationRequest{
DiskSwitchToReplicationRequest: req,
AsyncMode: false,
}
url := "/cloudapi/compute/diskSwitchToReplication"
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
if err != nil {
return false, err
}
@@ -44,3 +55,25 @@ func (c Compute) DiskSwitchToReplication(ctx context.Context, req DiskSwitchToRe
return result, nil
}
// DiskSwitchToReplicationAsync switches disk to it's replication with AsyncMode
func (c Compute) DiskSwitchToReplicationAsync(ctx context.Context, req DiskSwitchToReplicationRequest) (string, error) {
err := validators.ValidateRequest(req)
if err != nil {
return "", validators.ValidationErrors(validators.GetErrors(err))
}
reqWrapped := wrapperDiskSwitchToReplicationRequest{
DiskSwitchToReplicationRequest: req,
AsyncMode: true,
}
url := "/cloudapi/compute/diskSwitchToReplication"
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
if err != nil {
return "", err
}
return string(res), nil
}

View File

@@ -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
}

View File

@@ -1,40 +0,0 @@
package compute
import (
"context"
"encoding/json"
"net/http"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
// GetAuditsRequest struct to get compute audits
type GetAuditsRequest struct {
// ID of compute instance
// Required: true
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
}
// GetAudits gets compute audits
func (c Compute) GetAudits(ctx context.Context, req GetAuditsRequest) (ListShortAudits, error) {
err := validators.ValidateRequest(req)
if err != nil {
return nil, validators.ValidationErrors(validators.GetErrors(err))
}
url := "/cloudapi/compute/getAudits"
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
if err != nil {
return nil, err
}
list := ListShortAudits{}
err = json.Unmarshal(res, &list)
if err != nil {
return nil, err
}
return list, nil
}

View File

@@ -0,0 +1,46 @@
package compute
import (
"context"
"encoding/json"
"net/http"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
// GetCPUAlignmentProfileRequest struct to get CPU alignment profile for compute
type GetCPUAlignmentProfileRequest struct {
// ID of the compute instance
// Required: true
ComputeID uint64 `url:"compute_id" json:"compute_id" validate:"required"`
}
// GetCPUAlignmentProfile gets CPU alignment profile for compute
func (c Compute) GetCPUAlignmentProfile(ctx context.Context, req GetCPUAlignmentProfileRequest) (*CPUAlignmentProfile, error) {
res, err := c.GetCPUAlignmentProfileRaw(ctx, req)
if err != nil {
return nil, err
}
info := CPUAlignmentProfile{}
err = json.Unmarshal(res, &info)
if err != nil {
return nil, err
}
return &info, nil
}
// GetCPUAlignmentProfileRaw gets CPU alignment profile for compute as an array of bytes
func (c Compute) GetCPUAlignmentProfileRaw(ctx context.Context, req GetCPUAlignmentProfileRequest) ([]byte, error) {
err := validators.ValidateRequest(req)
if err != nil {
return nil, validators.ValidationErrors(validators.GetErrors(err))
}
url := "/cloudapi/compute/get_cpu_alignment_profile"
res, err := c.client.DecortApiCall(ctx, http.MethodGet, url, req)
return res, err
}

View File

@@ -15,6 +15,12 @@ type GuestAgentDisableRequest struct {
ComputeID uint64 `url:"compute_id" json:"compute_id" validate:"required"`
}
type wrapperGuestAgentDisableRequest struct {
GuestAgentDisableRequest
AsyncMode bool `url:"asyncMode"`
}
// Disable guest agent at a specific compute
func (c Compute) GuestAgentDisable(ctx context.Context, req GuestAgentDisableRequest) (bool, error) {
err := validators.ValidateRequest(req)
@@ -22,9 +28,14 @@ func (c Compute) GuestAgentDisable(ctx context.Context, req GuestAgentDisableReq
return false, validators.ValidationErrors(validators.GetErrors(err))
}
reqWrapped := wrapperGuestAgentDisableRequest{
GuestAgentDisableRequest: req,
AsyncMode: false,
}
url := "/cloudapi/compute/guest_agent_disable"
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
if err != nil {
return false, err
}
@@ -36,3 +47,25 @@ func (c Compute) GuestAgentDisable(ctx context.Context, req GuestAgentDisableReq
return result, nil
}
// GuestAgentDisableAsync disables guest agent at a specific compute with AsyncMode
func (c Compute) GuestAgentDisableAsync(ctx context.Context, req GuestAgentDisableRequest) (string, error) {
err := validators.ValidateRequest(req)
if err != nil {
return "", validators.ValidationErrors(validators.GetErrors(err))
}
reqWrapped := wrapperGuestAgentDisableRequest{
GuestAgentDisableRequest: req,
AsyncMode: true,
}
url := "/cloudapi/compute/guest_agent_disable"
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
if err != nil {
return "", err
}
return string(res), nil
}

View File

@@ -15,6 +15,12 @@ type GuestAgentEnableRequest struct {
ComputeID uint64 `url:"compute_id" json:"compute_id" validate:"required"`
}
type wrapperGuestAgentEnableRequest struct {
GuestAgentEnableRequest
AsyncMode bool `url:"asyncMode"`
}
// Enable guest agent at a specific compute
func (c Compute) GuestAgentEnable(ctx context.Context, req GuestAgentEnableRequest) (bool, error) {
err := validators.ValidateRequest(req)
@@ -22,9 +28,14 @@ func (c Compute) GuestAgentEnable(ctx context.Context, req GuestAgentEnableReque
return false, validators.ValidationErrors(validators.GetErrors(err))
}
reqWrapped := wrapperGuestAgentEnableRequest{
GuestAgentEnableRequest: req,
AsyncMode: false,
}
url := "/cloudapi/compute/guest_agent_enable"
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
if err != nil {
return false, err
}
@@ -36,3 +47,25 @@ func (c Compute) GuestAgentEnable(ctx context.Context, req GuestAgentEnableReque
return result, nil
}
// GuestAgentEnableAsync enables guest agent at a specific compute with AsyncMode
func (c Compute) GuestAgentEnableAsync(ctx context.Context, req GuestAgentEnableRequest) (string, error) {
err := validators.ValidateRequest(req)
if err != nil {
return "", validators.ValidationErrors(validators.GetErrors(err))
}
reqWrapped := wrapperGuestAgentEnableRequest{
GuestAgentEnableRequest: req,
AsyncMode: true,
}
url := "/cloudapi/compute/guest_agent_enable"
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
if err != nil {
return "", err
}
return string(res), nil
}

View File

@@ -23,6 +23,12 @@ type GuestAgentExecuteRequest struct {
Arguments string `url:"arguments" json:"arguments" validate:"required"`
}
type wrapperGuestAgentExecuteRequest struct {
GuestAgentExecuteRequest
AsyncMode bool `url:"asyncMode"`
}
// Execute guest agent command
func (c Compute) GuestAgentExecuteRequest(ctx context.Context, req GuestAgentExecuteRequest) (map[string]interface{}, error) {
err := validators.ValidateRequest(req)
@@ -30,9 +36,14 @@ func (c Compute) GuestAgentExecuteRequest(ctx context.Context, req GuestAgentExe
return nil, validators.ValidationErrors(validators.GetErrors(err))
}
reqWrapped := wrapperGuestAgentExecuteRequest{
GuestAgentExecuteRequest: req,
AsyncMode: false,
}
url := "/cloudapi/compute/guest_agent_execute"
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
if err != nil {
return nil, err
}
@@ -46,3 +57,25 @@ func (c Compute) GuestAgentExecuteRequest(ctx context.Context, req GuestAgentExe
return result, nil
}
// GuestAgentExecuteRequestAsync executes guest agent command with AsyncMode
func (c Compute) GuestAgentExecuteRequestAsync(ctx context.Context, req GuestAgentExecuteRequest) (string, error) {
err := validators.ValidateRequest(req)
if err != nil {
return "", validators.ValidationErrors(validators.GetErrors(err))
}
reqWrapped := wrapperGuestAgentExecuteRequest{
GuestAgentExecuteRequest: req,
AsyncMode: true,
}
url := "/cloudapi/compute/guest_agent_execute"
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
if err != nil {
return "", err
}
return string(res), nil
}

View File

@@ -15,6 +15,12 @@ type GuestAgentFeatureUpdateRequest struct {
ComputeID uint64 `url:"compute_id" json:"compute_id" validate:"required"`
}
type wrapperGuestAgentFeatureUpdateRequest struct {
GuestAgentFeatureUpdateRequest
AsyncMode bool `url:"asyncMode"`
}
// Feature update guest agent
func (c Compute) GuestAgentFeatureUpdate(ctx context.Context, req GuestAgentFeatureUpdateRequest) (bool, error) {
err := validators.ValidateRequest(req)
@@ -22,9 +28,14 @@ func (c Compute) GuestAgentFeatureUpdate(ctx context.Context, req GuestAgentFeat
return false, validators.ValidationErrors(validators.GetErrors(err))
}
reqWrapped := wrapperGuestAgentFeatureUpdateRequest{
GuestAgentFeatureUpdateRequest: req,
AsyncMode: false,
}
url := "/cloudapi/compute/guest_agent_feature_update"
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
if err != nil {
return false, err
}
@@ -36,3 +47,25 @@ func (c Compute) GuestAgentFeatureUpdate(ctx context.Context, req GuestAgentFeat
return result, nil
}
// GuestAgentFeatureUpdateAsync feature updates guest agent with AsyncMode
func (c Compute) GuestAgentFeatureUpdateAsync(ctx context.Context, req GuestAgentFeatureUpdateRequest) (string, error) {
err := validators.ValidateRequest(req)
if err != nil {
return "", validators.ValidationErrors(validators.GetErrors(err))
}
reqWrapped := wrapperGuestAgentFeatureUpdateRequest{
GuestAgentFeatureUpdateRequest: req,
AsyncMode: true,
}
url := "/cloudapi/compute/guest_agent_feature_update"
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
if err != nil {
return "", err
}
return string(res), nil
}

View File

@@ -14,10 +14,6 @@ type ListPCIDeviceRequest struct {
// Required: true
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
// Find by resource group ID
// Required: false
RGID uint64 `url:"rgId,omitempty" json:"rgId,omitempty"`
// Find by device id
// Required: false
DevID uint64 `url:"devId,omitempty" json:"devId,omitempty"`

View File

@@ -19,6 +19,12 @@ type MigrateToZoneRequest struct {
ZoneID uint64 `url:"zoneId" json:"zoneId " validate:"required"`
}
type wrapperMigrateToZoneRequest struct {
MigrateToZoneRequest
AsyncMode bool `url:"asyncMode"`
}
// MoveToRG moves compute instance to new resource group
func (c Compute) MigrateToZone(ctx context.Context, req MigrateToZoneRequest) (bool, error) {
err := validators.ValidateRequest(req)
@@ -26,9 +32,14 @@ func (c Compute) MigrateToZone(ctx context.Context, req MigrateToZoneRequest) (b
return false, validators.ValidationErrors(validators.GetErrors(err))
}
reqWrapped := wrapperMigrateToZoneRequest{
MigrateToZoneRequest: req,
AsyncMode: false,
}
url := "/cloudapi/compute/migrateToZone"
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
if err != nil {
return false, err
}
@@ -40,3 +51,25 @@ func (c Compute) MigrateToZone(ctx context.Context, req MigrateToZoneRequest) (b
return result, nil
}
// MigrateToZoneAsync moves compute to another zone with AsyncMode
func (c Compute) MigrateToZoneAsync(ctx context.Context, req MigrateToZoneRequest) (string, error) {
err := validators.ValidateRequest(req)
if err != nil {
return "", validators.ValidationErrors(validators.GetErrors(err))
}
reqWrapped := wrapperMigrateToZoneRequest{
MigrateToZoneRequest: req,
AsyncMode: true,
}
url := "/cloudapi/compute/migrateToZone"
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
if err != nil {
return "", err
}
return string(res), nil
}

View File

@@ -83,7 +83,10 @@ type ListUsageSnapshots []ItemUsageSnapshot
// Main information about snapshot
type ItemSnapshot struct {
// List disk ID
// Compute info
Compute RecordCompute `json:"compute"`
// List of disk IDs
Disks []uint64 `json:"disks"`
// GUID
@@ -92,6 +95,9 @@ type ItemSnapshot struct {
// Label
Label string `json:"label"`
// Memory dump image ID
MemoryDumpImage uint64 `json:"memory_dump_image"`
// Timestamp
Timestamp uint64 `json:"timestamp"`
}
@@ -176,6 +182,9 @@ type RecordNetAttach struct {
// Enabled
Enabled bool `json:"enabled"`
// Enable default gateway
EnableDefaultGateway bool `json:"enable_default_gateway"`
// Enable security groups
EnableSecGroups bool `json:"enable_secgroups"`
@@ -356,6 +365,325 @@ type RecordCompute struct {
// List clone IDs
Clones []uint64 `json:"clones"`
// Clock
Clock string `json:"clock"`
// Compute CI ID
ComputeCIID uint64 `json:"computeciId"`
// CPU Pin
CPUPin bool `json:"cpupin"`
// Number of cores
CPU uint64 `json:"cpus"`
// Created by
CreatedBy string `json:"createdBy"`
// Created time
CreatedTime uint64 `json:"createdTime"`
// Custom fields items
CustomFields map[string]interface{} `json:"customFields"`
// Deleted by
DeletedBy string `json:"deletedBy"`
// Deleted time
DeletedTime uint64 `json:"deletedTime"`
// Description
Description string `json:"desc"`
// Devices
Devices interface{} `json:"devices"`
// List disks in compute
Disks ListComputeDisks `json:"disks"`
// Driver
Driver string `json:"driver"`
// Grid ID
GID uint64 `json:"gid"`
// GUID
GUID uint64 `json:"guid"`
// HPBacked
HPBacked bool `json:"hpBacked"`
// Hot resize
HotResize bool `json:"hotResize"`
// ID
ID uint64 `json:"id"`
// Image ID
ImageID uint64 `json:"imageId"`
// Image name
ImageName string `json:"imageName"`
// List interfaces
Interfaces ListInterfaces `json:"interfaces"`
// Loader meta iso information
LoaderMetaIso LoaderMetaIso `json:"loaderMetaIso"`
// Live migration job ID
LiveMigrationJobID uint64 `json:"live_migration_job_id"`
// Loader type
LoaderType string `json:"loaderType"`
// Lock status
LockStatus string `json:"lockStatus"`
// Manager ID
ManagerID uint64 `json:"managerId"`
// Manager type
ManagerType string `json:"managerType"`
// Memory balloon mode
MemoryBalloonMode string `json:"memory_balloon_mode"`
// Migration job
MigrationJob uint64 `json:"migrationjob"`
// Milestones
Milestones uint64 `json:"milestones"`
// Name
Name string `json:"name"`
// NeedReboot
NeedReboot bool `json:"needReboot"`
// Network interface naming
NetworkInterfaceNaming string `json:"networkInterfaceNaming"`
// Numa Affinity
NumaAffinity string `json:"numaAffinity"`
//NumaNodeId
NumaNodeId int64 `json:"numaNodeId"`
// Natable VINS ID
NatableVINSID uint64 `json:"natableVinsId"`
// Natable VINS IP
NatableVINSIP string `json:"natableVinsIp"`
// Natable VINS Name
NatableVINSName string `json:"natableVinsName"`
// Natable VINS network
NatableVINSNetwork string `json:"natableVinsNetwork"`
// Natable VINS network name
NatableVINSNetworkName string `json:"natableVinsNetworkName"`
// Name of OS
OSVersion string `json:"os_version"`
// List OS Users
OSUsers ListOSUser `json:"osUsers"`
// Pinned to node
PinnedToNode bool `json:"pinnedToNode"`
// PreferredCPU
PreferredCPU []int64 `json:"preferredCpu"`
// CPU alignment profile
CPUAlignmentProfile CPUAlignmentProfile `json:"cpu_alignment_profile"`
// Qemu_quest
QemuQuest QemuQuest `json:"qemu_guest"`
// ReadOnly indicates read-only mode state
ReadOnly bool `json:"read_only"`
// Number of RAM
RAM uint64 `json:"ram"`
// Reference ID
ReferenceID string `json:"referenceId"`
// Registered or not
Registered bool `json:"registered"`
// Whether a compute has been resized online
ResizedOnline bool `json:"resizedOnline"`
// Resource name
ResName string `json:"resName"`
// Reserved Node Cpus
ReservedNodeCpus []uint64 `json:"reservedNodeCpus"`
// Resource group ID
RGID uint64 `json:"rgId"`
// Resource group name
RGName string `json:"rgName"`
// List snapsets
SnapSets ListSnapSets `json:"snapSets"`
// Stateless SepID
StatelessSepID int64 `json:"statelessSepId"`
// Stateless SepType
StatelessSepType string `json:"statelessSepType"`
// Status
Status string `json:"status"`
// Tags
Tags map[string]string `json:"tags"`
// Tech status
TechStatus string `json:"techStatus"`
// Updated by
UpdatedBy string `json:"updatedBy"`
// Updated time
UpdatedTime uint64 `json:"updatedTime"`
// User Managed or not
UserManaged bool `json:"userManaged"`
// Userdata
Userdata interface{} `json:"userdata"`
// vGPUs list
VGPUs []ItemVGPU `json:"vgpus"`
// VNC password
VNCPassword string `json:"vncPasswd"`
// Watchdog action
WatchdogAction string `json:"watchdog_action"`
// Weight
Weight uint64 `json:"weight"`
// Zone ID
// Required: false
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"`
// Account ID
AccountID uint64 `json:"accountId"`
// Account name
AccountName string `json:"accountName"`
// Affinity label
AffinityLabel string `json:"affinityLabel"`
// List affinity rules
AffinityRules ListRules `json:"affinityRules"`
// Affinity weight
AffinityWeight uint64 `json:"affinityWeight"`
// List anti affinity rules
AntiAffinityRules ListRules `json:"antiAffinityRules"`
// Auto start when node restarted
AutoStart bool `json:"autoStart"`
// Architecture
Architecture string `json:"arch"`
// Boot image ID
BootImageID uint64 `json:"boot_image_id"`
// Boot order
BootOrder []string `json:"bootOrder"`
// Boot type
BootType string `json:"bootType"`
// Boot disk size
BootDiskSize uint64 `json:"bootdiskSize"`
// CD Image Id
CdImageId uint64 `json:"cdImageId"`
// Chipset
Chipset string `json:"chipset"`
// Clone reference
CloneReference uint64 `json:"cloneReference"`
// List clone IDs
Clones []uint64 `json:"clones"`
// Clock
Clock string `json:"clock"`
// Compute CI ID
ComputeCIID uint64 `json:"computeciId"`
@@ -449,6 +777,9 @@ type RecordCompute struct {
// Network interface naming
NetworkInterfaceNaming string `json:"networkInterfaceNaming"`
// Node ID
NodeID uint64 `json:"node_id"`
// Numa Affinity
NumaAffinity string `json:"numaAffinity"`
@@ -477,11 +808,14 @@ type RecordCompute struct {
OSUsers ListOSUser `json:"osUsers"`
// Pinned to node
PinnedToNode bool `json:"pinnedToNode"`
PinnedToNode int64 `json:"pinnedToNode"`
// PreferredCPU
PreferredCPU []int64 `json:"preferredCpu"`
// CPU alignment profile
CPUAlignmentProfile CPUAlignmentProfile `json:"cpu_alignment_profile"`
// Qemu_quest
QemuQuest QemuQuest `json:"qemu_guest"`
@@ -509,9 +843,6 @@ type RecordCompute struct {
// Resource group name
RGName string `json:"rgName"`
// List snapsets
SnapSets ListSnapSets `json:"snapSets"`
// Stateless SepID
StatelessSepID int64 `json:"statelessSepId"`
@@ -540,7 +871,7 @@ type RecordCompute struct {
Userdata interface{} `json:"userdata"`
// vGPUs list
VGPUs []VGPUItem `json:"vgpus"`
VGPUs []ItemVGPU `json:"vgpus"`
// VNC password
VNCPassword string `json:"vncPasswd"`
@@ -552,6 +883,7 @@ type RecordCompute struct {
// Required: false
ZoneID uint64 `json:"zoneId"`
}
type LoaderMetaIso struct {
// Name
DeviceName string `json:"devicename"`
@@ -568,63 +900,10 @@ type QemuQuest struct {
User string `json:"user"`
}
type VGPUItem struct {
// ID
ID uint64 `json:"id"`
// GID
GID uint64 `json:"gid"`
// Type
Type string `json:"type"`
// Mode
Mode string `json:"mode"`
// Status
Status string `json:"status"`
// ProfileID
ProfileID uint64 `json:"profileId"`
// RAM
RAM uint64 `json:"ram"`
// LastUpdateTime
LastUpdateTime uint64 `json:"lastUpdateTime"`
// CreatedTime
CreatedTime uint64 `json:"createdTime"`
// DeletedTime
DeletedTime uint64 `json:"deletedTime"`
// VMID
VMID uint64 `json:"vmid"`
// PGPuid
PGPuid uint64 `json:"pgpuid"`
// ReferenceID
ReferenceID string `json:"referenceId"`
// AccountID
AccountID uint64 `json:"accountId"`
// RgID
RgID uint64 `json:"rgId"`
// LastClaimedBy
LastClaimedBy uint64 `json:"lastClaimedBy"`
// PCISlot
PCISlot uint64 `json:"pciSlot"`
// BusNumber
BusNumber uint64 `json:"bus_number"`
// GUID
GUID uint64 `json:"guid"`
type CPUAlignmentProfile struct {
Model string `json:"model"`
Name string `json:"name"`
Vendor string `json:"vendor"`
}
// Information about libvirt settings
@@ -671,7 +950,10 @@ type ListOSUser []ItemOSUser
// Main information about snapsets
type ItemSnapSet struct {
// List disk IDs
// Compute info
Compute SnapRecordCompute `json:"compute"`
// List disk ID
Disks []uint64 `json:"disks"`
// GUID
@@ -680,6 +962,9 @@ type ItemSnapSet struct {
// Label
Label string `json:"label"`
// Memory dump image ID
MemoryDumpImage uint64 `json:"memory_dump_image"`
// Timestamp
Timestamp uint64 `json:"timestamp"`
}
@@ -704,6 +989,9 @@ type ItemVNFInterface struct {
// Enabled
Enabled bool `json:"enabled"`
// Enable default gateway
EnableDefaultGateway bool `json:"enable_default_gateway"`
// Enable security groups
EnableSecGroups bool `json:"enable_secgroups"`
@@ -749,6 +1037,9 @@ type ItemVNFInterface struct {
// QOS
QOS QOS `json:"qos"`
// List of QoS Policy IDs
QoSPolicies []uint64 `json:"qos_policies"`
// List of security groups
SecGroups []uint64 `json:"security_groups"`
@@ -792,8 +1083,8 @@ type ItemComputeDisk struct {
// Account ID
AccountID uint64 `json:"accountId"`
// BLK Discard
BLKDiscard bool `json:"blkdiscard"`
// Discard
Discard string `json:"discard"`
// Block Size
BlockSize string `json:"block_size"`
@@ -938,6 +1229,9 @@ type ItemComputeDisk struct {
// UpdatedTime
UpdatedTime uint64 `json:"updatedTime"`
// Read-only
ReadOnly bool `json:"read_only"`
}
type ItemReplication struct {
@@ -968,6 +1262,9 @@ type SnapshotExtend struct {
// Label
Label string `json:"label"`
// Pool name
PoolName string `json:"poolName"`
// Reference ID
ReferenceID string `json:"referenceId"`
@@ -1079,6 +1376,9 @@ type ItemCompute struct {
// Clone reference
CloneReference uint64 `json:"cloneReference"`
// Clock
Clock string `json:"clock"`
// List clone IDs
Clones []uint64 `json:"clones"`
@@ -1151,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"`
@@ -1160,6 +1463,9 @@ type ItemCompute struct {
// Name
Name string `json:"name"`
// Node ID
NodeID uint64 `json:"node_id"`
// NeedReboot
NeedReboot bool `json:"needReboot"`
@@ -1184,6 +1490,9 @@ type ItemCompute struct {
// Name of OS
OSVersion string `json:"os_version"`
// CPU alignment profile
CPUAlignmentProfile CPUAlignmentProfile `json:"cpu_alignment_profile"`
// Qemu_quest
QemuQuest QemuQuest `json:"qemu_guest"`
@@ -1196,6 +1505,9 @@ type ItemCompute struct {
// Registered
Registered bool `json:"registered"`
// Whether a compute has been resized online
ResizedOnline bool `json:"resizedOnline"`
// Resource name
ResName string `json:"resName"`
@@ -1244,6 +1556,9 @@ type ItemCompute struct {
// VINS connected
VINSConnected uint64 `json:"vinsConnected"`
// Watchdog action
WatchdogAction string `json:"watchdog_action"`
// Weight
Weight uint64 `json:"weight"`
@@ -1261,6 +1576,12 @@ type InfoDisk struct {
// SEP ID
SepID int64 `json:"sepId"`
// Image ID
ImageID uint64 `json:"imageId"`
// Read-only
ReadOnly bool `json:"read_only"`
}
// List information about computes
@@ -1283,59 +1604,59 @@ type ListVGPUs struct {
// Main information about vgpu device
type ItemVGPU struct {
// Account ID
AccountID uint64 `json:"accountId"`
// Account IDs
AccountIDs []uint64 `json:"account_ids"`
// Created Time
CreatedTime uint64 `json:"createdTime"`
// Bus number
BusNumber int `json:"bus_number"`
// Deleted Time
DeletedTime uint64 `json:"deletedTime"`
// ComputeID
ComputeID uint64 `json:"compute_id"`
// GID
// Created time
CreatedTime uint64 `json:"created_time"`
// Deleted time
DeletedTime uint64 `json:"deleted_time"`
// Device Reference
DeviceReference string `json:"device_reference"`
//Grid ID
GID uint64 `json:"gid"`
// GUID
GUID uint64 `json:"guid"`
// ID
// VGPU ID
ID uint64 `json:"id"`
// Last Claimed By
LastClaimedBy uint64 `json:"lastClaimedBy"`
// Last Update time
LastUpdateTime uint64 `json:"last_update_time"`
// Last Update Time
LastUpdateTime uint64 `json:"lastUpdateTime"`
// Mdev UUID
MdevUUID string `json:"mdev_uuid"`
// Mode
Mode string `json:"mode"`
// Parent PCI Address
ParentPCIAddress string `json:"parent_pci_address"`
// PCI Slot
PCISlot uint64 `json:"pciSlot"`
PCISlot uint64 `json:"pci_slot"`
// PGPUID
PGPUID uint64 `json:"pgpuid"`
// PGPU ID
PGPUID uint64 `json:"pgpu_id"`
// Profile ID
ProfileID uint64 `json:"profileId"`
// Profile Reference
ProfileReference string `json:"profile_reference"`
// RAM
RAM uint64 `json:"ram"`
// Profile Name
ProfileName string `json:"profile_name"`
// Reference ID
ReferenceID string `json:"referenceId"`
// RG ID
RGID uint64 `json:"rgId"`
// Split Mode
SplitMode string `json:"split_mode"`
// Status
Status string `json:"status"`
// Type
Type string `json:"type"`
// VM ID
VMID uint64 `json:"vmid"`
}
// Main information about PCI device
@@ -1358,8 +1679,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"`

View File

@@ -34,6 +34,12 @@ type MoveToRGRequest struct {
ForceStop bool `url:"forceStop,omitempty" json:"forceStop,omitempty"`
}
type wrapperMoveToRGRequest struct {
MoveToRGRequest
AsyncMode bool `url:"asyncMode"`
}
// MoveToRG moves compute instance to new resource group
func (c Compute) MoveToRG(ctx context.Context, req MoveToRGRequest) (bool, error) {
err := validators.ValidateRequest(req)
@@ -41,9 +47,14 @@ func (c Compute) MoveToRG(ctx context.Context, req MoveToRGRequest) (bool, error
return false, validators.ValidationErrors(validators.GetErrors(err))
}
reqWrapped := wrapperMoveToRGRequest{
MoveToRGRequest: req,
AsyncMode: false,
}
url := "/cloudapi/compute/moveToRg"
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
if err != nil {
return false, err
}
@@ -55,3 +66,25 @@ func (c Compute) MoveToRG(ctx context.Context, req MoveToRGRequest) (bool, error
return result, nil
}
// MoveToRGAsync moves compute instance to new resource group with AsyncMode
func (c Compute) MoveToRGAsync(ctx context.Context, req MoveToRGRequest) (string, error) {
err := validators.ValidateRequest(req)
if err != nil {
return "", validators.ValidationErrors(validators.GetErrors(err))
}
reqWrapped := wrapperMoveToRGRequest{
MoveToRGRequest: req,
AsyncMode: true,
}
url := "/cloudapi/compute/moveToRg"
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
if err != nil {
return "", err
}
return string(res), nil
}

View File

@@ -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"
)
@@ -53,9 +54,9 @@ type NetAttachRequest struct {
// Required: false
SDNSegmentID string `url:"sdn_segment_id,omitempty" json:"sdn_segment_id,omitempty"`
// SDN Object Group ID
// SDN Object Group IDs
// Required: false
SDNObjectGroupID string `url:"sdn_object_group_id,omitempty" json:"sdn_object_group_id,omitempty"`
SDNObjectGroupIDs []string `url:"sdn_object_group_ids,omitempty" json:"sdn_object_group_ids,omitempty"`
// SDN Logical Port Display Name
// Required: false
@@ -81,6 +82,21 @@ type NetAttachRequest struct {
// Flag indicating whether this interface is enabled (only for VINS, EXTNET, DPDK, SDN, TRUNK)
// Required: false
Enabled interface{} `url:"enabled,omitempty" json:"enabled,omitempty" validate:"omitempty,isBool"`
// Flag indicating whether default gateway is enabled for this interface
// Required: false
// Default: true
EnableDefaultGateway interface{} `url:"enable_default_gateway,omitempty" json:"enable_default_gateway,omitempty" validate:"omitempty,isBool"`
// List of QoS Policy IDs to apply to this interface (default: []), Allow used only with netType VINS, EXTNET and DPDK
// Required: false
QoSPolicies []uint64 `url:"qos_policies,omitempty" json:"qos_policies,omitempty"`
}
type wrapperNetAttachRequest struct {
NetAttachRequest
AsyncMode bool `url:"asyncMode" json:"asyncMode"`
}
// NetAttach attaches network to compute and gets info about network
@@ -90,9 +106,14 @@ func (c Compute) NetAttach(ctx context.Context, req NetAttachRequest) (*RecordNe
return nil, validators.ValidationErrors(validators.GetErrors(err))
}
reqWrapped := wrapperNetAttachRequest{
NetAttachRequest: req,
AsyncMode: false,
}
url := "/cloudapi/compute/netAttach"
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
res, err := c.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, reqWrapped)
if err != nil {
return nil, err
}
@@ -106,3 +127,25 @@ func (c Compute) NetAttach(ctx context.Context, req NetAttachRequest) (*RecordNe
return &info, nil
}
// NetAttachAsync attaches network to compute with AsyncMode
func (c Compute) NetAttachAsync(ctx context.Context, req NetAttachRequest) (string, error) {
err := validators.ValidateRequest(req)
if err != nil {
return "", validators.ValidationErrors(validators.GetErrors(err))
}
reqWrapped := wrapperNetAttachRequest{
NetAttachRequest: req,
AsyncMode: true,
}
url := "/cloudapi/compute/netAttach"
res, err := c.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, reqWrapped)
if err != nil {
return "", err
}
return string(res), nil
}

View File

@@ -23,6 +23,12 @@ type NetDetachRequest struct {
MAC string `url:"mac,omitempty" json:"mac,omitempty"`
}
type wrapperNetDetachRequest struct {
NetDetachRequest
AsyncMode bool `url:"asyncMode"`
}
// NetDetach detaches network from compute
func (c Compute) NetDetach(ctx context.Context, req NetDetachRequest) (bool, error) {
err := validators.ValidateRequest(req)
@@ -30,9 +36,14 @@ func (c Compute) NetDetach(ctx context.Context, req NetDetachRequest) (bool, err
return false, validators.ValidationErrors(validators.GetErrors(err))
}
reqWrapped := wrapperNetDetachRequest{
NetDetachRequest: req,
AsyncMode: false,
}
url := "/cloudapi/compute/netDetach"
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
if err != nil {
return false, err
}
@@ -44,3 +55,25 @@ func (c Compute) NetDetach(ctx context.Context, req NetDetachRequest) (bool, err
return result, nil
}
// NetDetachAsync detaches network from compute with AsyncMode
func (c Compute) NetDetachAsync(ctx context.Context, req NetDetachRequest) (string, error) {
err := validators.ValidateRequest(req)
if err != nil {
return "", validators.ValidationErrors(validators.GetErrors(err))
}
reqWrapped := wrapperNetDetachRequest{
NetDetachRequest: req,
AsyncMode: true,
}
url := "/cloudapi/compute/netDetach"
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
if err != nil {
return "", err
}
return string(res), nil
}

View File

@@ -15,6 +15,12 @@ type PauseRequest struct {
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
}
type wrapperPauseRequest struct {
PauseRequest
AsyncMode bool `url:"asyncMode"`
}
// Pause pause compute
func (c Compute) Pause(ctx context.Context, req PauseRequest) (bool, error) {
err := validators.ValidateRequest(req)
@@ -22,9 +28,14 @@ func (c Compute) Pause(ctx context.Context, req PauseRequest) (bool, error) {
return false, validators.ValidationErrors(validators.GetErrors(err))
}
reqWrapped := wrapperPauseRequest{
PauseRequest: req,
AsyncMode: false,
}
url := "/cloudapi/compute/pause"
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
if err != nil {
return false, err
}
@@ -36,3 +47,25 @@ func (c Compute) Pause(ctx context.Context, req PauseRequest) (bool, error) {
return result, nil
}
// PauseAsync pauses compute with AsyncMode
func (c Compute) PauseAsync(ctx context.Context, req PauseRequest) (string, error) {
err := validators.ValidateRequest(req)
if err != nil {
return "", validators.ValidationErrors(validators.GetErrors(err))
}
reqWrapped := wrapperPauseRequest{
PauseRequest: req,
AsyncMode: true,
}
url := "/cloudapi/compute/pause"
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
if err != nil {
return "", err
}
return string(res), nil
}

View File

@@ -33,6 +33,12 @@ type PFWAddRequest struct {
Proto string `url:"proto" json:"proto" validate:"proto"`
}
type wrapperPFWAddRequest struct {
PFWAddRequest
AsyncMode bool `url:"asyncMode"`
}
// PFWAdd add port forward rule
func (c Compute) PFWAdd(ctx context.Context, req PFWAddRequest) (uint64, error) {
err := validators.ValidateRequest(req)
@@ -40,9 +46,14 @@ func (c Compute) PFWAdd(ctx context.Context, req PFWAddRequest) (uint64, error)
return 0, validators.ValidationErrors(validators.GetErrors(err))
}
reqWrapped := wrapperPFWAddRequest{
PFWAddRequest: req,
AsyncMode: false,
}
url := "/cloudapi/compute/pfwAdd"
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
if err != nil {
return 0, err
}
@@ -54,3 +65,25 @@ func (c Compute) PFWAdd(ctx context.Context, req PFWAddRequest) (uint64, error)
return result, nil
}
// PFWAddAsync adds port forward rule with AsyncMode
func (c Compute) PFWAddAsync(ctx context.Context, req PFWAddRequest) (string, error) {
err := validators.ValidateRequest(req)
if err != nil {
return "", validators.ValidationErrors(validators.GetErrors(err))
}
reqWrapped := wrapperPFWAddRequest{
PFWAddRequest: req,
AsyncMode: true,
}
url := "/cloudapi/compute/pfwAdd"
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
if err != nil {
return "", err
}
return string(res), nil
}

View File

@@ -36,6 +36,12 @@ type PFWDelRequest struct {
Proto string `url:"proto,omitempty" json:"proto,omitempty"`
}
type wrapperPFWDelRequest struct {
PFWDelRequest
AsyncMode bool `url:"asyncMode"`
}
// PFWDel deletes port forward rule
func (c Compute) PFWDel(ctx context.Context, req PFWDelRequest) (bool, error) {
err := validators.ValidateRequest(req)
@@ -43,9 +49,14 @@ func (c Compute) PFWDel(ctx context.Context, req PFWDelRequest) (bool, error) {
return false, validators.ValidationErrors(validators.GetErrors(err))
}
reqWrapped := wrapperPFWDelRequest{
PFWDelRequest: req,
AsyncMode: false,
}
url := "/cloudapi/compute/pfwDel"
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
if err != nil {
return false, err
}
@@ -57,3 +68,25 @@ func (c Compute) PFWDel(ctx context.Context, req PFWDelRequest) (bool, error) {
return result, nil
}
// PFWDelAsync deletes port forward rule with AsyncMode
func (c Compute) PFWDelAsync(ctx context.Context, req PFWDelRequest) (string, error) {
err := validators.ValidateRequest(req)
if err != nil {
return "", validators.ValidationErrors(validators.GetErrors(err))
}
reqWrapped := wrapperPFWDelRequest{
PFWDelRequest: req,
AsyncMode: true,
}
url := "/cloudapi/compute/pfwDel"
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
if err != nil {
return "", err
}
return string(res), nil
}

View File

@@ -20,6 +20,12 @@ type PinToNodeRequest struct {
AutoStart bool `url:"autoStart" json:"autoStart"`
}
type wrapperPinToNodeRequest struct {
PinToNodeRequest
AsyncMode bool `url:"asyncMode"`
}
// PinToNode pin compute to current node
func (c Compute) PinToNode(ctx context.Context, req PinToNodeRequest) (bool, error) {
err := validators.ValidateRequest(req)
@@ -27,9 +33,14 @@ func (c Compute) PinToNode(ctx context.Context, req PinToNodeRequest) (bool, err
return false, validators.ValidationErrors(validators.GetErrors(err))
}
reqWrapped := wrapperPinToNodeRequest{
PinToNodeRequest: req,
AsyncMode: false,
}
url := "/cloudapi/compute/pin_to_node"
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
if err != nil {
return false, err
}
@@ -41,3 +52,25 @@ func (c Compute) PinToNode(ctx context.Context, req PinToNodeRequest) (bool, err
return result, nil
}
// PinToNodeAsync pins compute to current node with AsyncMode
func (c Compute) PinToNodeAsync(ctx context.Context, req PinToNodeRequest) (string, error) {
err := validators.ValidateRequest(req)
if err != nil {
return "", validators.ValidationErrors(validators.GetErrors(err))
}
reqWrapped := wrapperPinToNodeRequest{
PinToNodeRequest: req,
AsyncMode: true,
}
url := "/cloudapi/compute/pin_to_node"
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
if err != nil {
return "", err
}
return string(res), nil
}

View File

@@ -15,6 +15,12 @@ type PowerCycleRequest struct {
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
}
type wrapperPowerCycleRequest struct {
PowerCycleRequest
AsyncMode bool `url:"asyncMode"`
}
// PowerCycle makes force stop and start compute
func (c Compute) PowerCycle(ctx context.Context, req PowerCycleRequest) (bool, error) {
err := validators.ValidateRequest(req)
@@ -22,9 +28,14 @@ func (c Compute) PowerCycle(ctx context.Context, req PowerCycleRequest) (bool, e
return false, validators.ValidationErrors(validators.GetErrors(err))
}
reqWrapped := wrapperPowerCycleRequest{
PowerCycleRequest: req,
AsyncMode: false,
}
url := "/cloudapi/compute/powerCycle"
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
if err != nil {
return false, err
}
@@ -36,3 +47,25 @@ func (c Compute) PowerCycle(ctx context.Context, req PowerCycleRequest) (bool, e
return result, nil
}
// PowerCycleAsync makes force stop and start compute with AsyncMode
func (c Compute) PowerCycleAsync(ctx context.Context, req PowerCycleRequest) (string, error) {
err := validators.ValidateRequest(req)
if err != nil {
return "", validators.ValidationErrors(validators.GetErrors(err))
}
reqWrapped := wrapperPowerCycleRequest{
PowerCycleRequest: req,
AsyncMode: true,
}
url := "/cloudapi/compute/powerCycle"
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
if err != nil {
return "", err
}
return string(res), nil
}

View File

@@ -15,6 +15,12 @@ type RebootRequest struct {
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
}
type wrapperRebootRequest struct {
RebootRequest
AsyncMode bool `url:"asyncMode"`
}
// Reboot reboots compute
func (c Compute) Reboot(ctx context.Context, req RebootRequest) (bool, error) {
err := validators.ValidateRequest(req)
@@ -22,9 +28,14 @@ func (c Compute) Reboot(ctx context.Context, req RebootRequest) (bool, error) {
return false, validators.ValidationErrors(validators.GetErrors(err))
}
reqWrapped := wrapperRebootRequest{
RebootRequest: req,
AsyncMode: false,
}
url := "/cloudapi/compute/reboot"
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
if err != nil {
return false, err
}
@@ -36,3 +47,25 @@ func (c Compute) Reboot(ctx context.Context, req RebootRequest) (bool, error) {
return result, nil
}
// RebootAsync reboots compute with AsyncMode
func (c Compute) RebootAsync(ctx context.Context, req RebootRequest) (string, error) {
err := validators.ValidateRequest(req)
if err != nil {
return "", validators.ValidationErrors(validators.GetErrors(err))
}
reqWrapped := wrapperRebootRequest{
RebootRequest: req,
AsyncMode: true,
}
url := "/cloudapi/compute/reboot"
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
if err != nil {
return "", err
}
return string(res), nil
}

View File

@@ -15,7 +15,7 @@ type RedeployRequest struct {
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
// Storage policy id of compute. The rules of the specified storage policy will be used.
// Required: true
// Required: false
StoragePolicyID uint64 `url:"storage_policy_id,omitempty" json:"storage_policy_id,omitempty"`
// ID of the new OS image, if image change is required
@@ -44,6 +44,12 @@ type RedeployRequest struct {
ForceStop bool `url:"forceStop,omitempty" json:"forceStop,omitempty"`
}
type wrapperRedeployRequest struct {
RedeployRequest
AsyncMode bool `url:"asyncMode"`
}
// Redeploy redeploys compute
func (c Compute) Redeploy(ctx context.Context, req RedeployRequest) (bool, error) {
err := validators.ValidateRequest(req)
@@ -51,9 +57,14 @@ func (c Compute) Redeploy(ctx context.Context, req RedeployRequest) (bool, error
return false, validators.ValidationErrors(validators.GetErrors(err))
}
reqWrapped := wrapperRedeployRequest{
RedeployRequest: req,
AsyncMode: false,
}
url := "/cloudapi/compute/redeploy"
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
if err != nil {
return false, err
}
@@ -65,3 +76,25 @@ func (c Compute) Redeploy(ctx context.Context, req RedeployRequest) (bool, error
return result, nil
}
// RedeployAsync redeploys compute with AsyncMode
func (c Compute) RedeployAsync(ctx context.Context, req RedeployRequest) (string, error) {
err := validators.ValidateRequest(req)
if err != nil {
return "", validators.ValidationErrors(validators.GetErrors(err))
}
reqWrapped := wrapperRedeployRequest{
RedeployRequest: req,
AsyncMode: true,
}
url := "/cloudapi/compute/redeploy"
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
if err != nil {
return "", err
}
return string(res), nil
}

View File

@@ -15,6 +15,12 @@ type ResetRequest struct {
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
}
type wrapperResetRequest struct {
ResetRequest
AsyncMode bool `url:"asyncMode"`
}
// Reset resets compute
func (c Compute) Reset(ctx context.Context, req ResetRequest) (bool, error) {
err := validators.ValidateRequest(req)
@@ -22,9 +28,14 @@ func (c Compute) Reset(ctx context.Context, req ResetRequest) (bool, error) {
return false, validators.ValidationErrors(validators.GetErrors(err))
}
reqWrapped := wrapperResetRequest{
ResetRequest: req,
AsyncMode: false,
}
url := "/cloudapi/compute/reset"
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
if err != nil {
return false, err
}
@@ -36,3 +47,25 @@ func (c Compute) Reset(ctx context.Context, req ResetRequest) (bool, error) {
return result, nil
}
// ResetAsync resets compute with AsyncMode
func (c Compute) ResetAsync(ctx context.Context, req ResetRequest) (string, error) {
err := validators.ValidateRequest(req)
if err != nil {
return "", validators.ValidationErrors(validators.GetErrors(err))
}
reqWrapped := wrapperResetRequest{
ResetRequest: req,
AsyncMode: true,
}
url := "/cloudapi/compute/reset"
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
if err != nil {
return "", err
}
return string(res), nil
}

View File

@@ -43,6 +43,12 @@ func (r ResizeRequest) GetRAM() map[string]uint64 {
return res
}
type wrapperResizeRequest struct {
ResizeRequest
AsyncMode bool `url:"asyncMode"`
}
// Resize resizes compute instance
func (c Compute) Resize(ctx context.Context, req ResizeRequest) (bool, error) {
err := validators.ValidateRequest(req)
@@ -50,9 +56,14 @@ func (c Compute) Resize(ctx context.Context, req ResizeRequest) (bool, error) {
return false, validators.ValidationErrors(validators.GetErrors(err))
}
reqWrapped := wrapperResizeRequest{
ResizeRequest: req,
AsyncMode: false,
}
url := "/cloudapi/compute/resize"
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
if err != nil {
return false, err
}
@@ -64,3 +75,25 @@ func (c Compute) Resize(ctx context.Context, req ResizeRequest) (bool, error) {
return result, nil
}
// ResizeAsync resizes compute instance with AsyncMode
func (c Compute) ResizeAsync(ctx context.Context, req ResizeRequest) (string, error) {
err := validators.ValidateRequest(req)
if err != nil {
return "", validators.ValidationErrors(validators.GetErrors(err))
}
reqWrapped := wrapperResizeRequest{
ResizeRequest: req,
AsyncMode: true,
}
url := "/cloudapi/compute/resize"
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
if err != nil {
return "", err
}
return string(res), nil
}

View File

@@ -3,6 +3,7 @@ package compute
import (
"context"
"net/http"
"strconv"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
@@ -14,16 +15,54 @@ type RestoreRequest struct {
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
}
type wrapperRestoreRequest struct {
RestoreRequest
AsyncMode bool `url:"asyncMode"`
}
// Restore restores compute from recycle bin
func (c Compute) Restore(ctx context.Context, req RestoreRequest) (string, error) {
func (c Compute) Restore(ctx context.Context, req RestoreRequest) (bool, error) {
err := validators.ValidateRequest(req)
if err != nil {
return false, validators.ValidationErrors(validators.GetErrors(err))
}
reqWrapped := wrapperRestoreRequest{
RestoreRequest: req,
AsyncMode: false,
}
url := "/cloudapi/compute/restore"
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
if err != nil {
return false, err
}
result, err := strconv.ParseBool(string(res))
if err != nil {
return false, err
}
return result, nil
}
// RestoreAsync restores compute from recycle bin with AsyncMode
func (c Compute) RestoreAsync(ctx context.Context, req RestoreRequest) (string, error) {
err := validators.ValidateRequest(req)
if err != nil {
return "", validators.ValidationErrors(validators.GetErrors(err))
}
reqWrapped := wrapperRestoreRequest{
RestoreRequest: req,
AsyncMode: true,
}
url := "/cloudapi/compute/restore"
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
if err != nil {
return "", err
}

View File

@@ -15,6 +15,12 @@ type ResumeRequest struct {
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
}
type wrapperResumeRequest struct {
ResumeRequest
AsyncMode bool `url:"asyncMode"`
}
// Resume resume Compute from paused state
func (c Compute) Resume(ctx context.Context, req ResumeRequest) (bool, error) {
err := validators.ValidateRequest(req)
@@ -22,9 +28,14 @@ func (c Compute) Resume(ctx context.Context, req ResumeRequest) (bool, error) {
return false, validators.ValidationErrors(validators.GetErrors(err))
}
reqWrapped := wrapperResumeRequest{
ResumeRequest: req,
AsyncMode: false,
}
url := "/cloudapi/compute/resume"
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
if err != nil {
return false, err
}
@@ -36,3 +47,25 @@ func (c Compute) Resume(ctx context.Context, req ResumeRequest) (bool, error) {
return result, nil
}
// ResumeAsync resumes Compute from paused state with AsyncMode
func (c Compute) ResumeAsync(ctx context.Context, req ResumeRequest) (string, error) {
err := validators.ValidateRequest(req)
if err != nil {
return "", validators.ValidationErrors(validators.GetErrors(err))
}
reqWrapped := wrapperResumeRequest{
ResumeRequest: req,
AsyncMode: true,
}
url := "/cloudapi/compute/resume"
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
if err != nil {
return "", err
}
return string(res), nil
}

View File

@@ -0,0 +1,43 @@
package compute
import (
"context"
"net/http"
"strconv"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
// SetCPUAlignmentProfileRequest struct to set CPU alignment profile for computes
type SetCPUAlignmentProfileRequest struct {
// IDs of the compute instances
// Required: true
ComputeIDs []int64 `url:"compute_ids" json:"compute_ids" validate:"min=1"`
// CPU alignment profile name
// Required: true
CPUAlignmentProfile string `url:"cpu_alignment_profile" json:"cpu_alignment_profile" validate:"required"`
}
// SetCPUAlignmentProfile sets CPU alignment profile for computes
func (c Compute) SetCPUAlignmentProfile(ctx context.Context, req SetCPUAlignmentProfileRequest) (bool, error) {
err := validators.ValidateRequest(req)
if err != nil {
return false, validators.ValidationErrors(validators.GetErrors(err))
}
url := "/cloudapi/compute/set_cpu_alignment_profile"
res, err := c.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
if err != nil {
return false, err
}
result, err := strconv.ParseBool(string(res))
if err != nil {
return false, err
}
return result, nil
}

View File

@@ -20,18 +20,33 @@ type SnapshotCreateRequest struct {
// Maximum length: 36 characters
// Required: true
Label string `url:"label" json:"label" validate:"required,max=36,excludesall=<>"`
// Create snapshot with memory dump
// Required: false
// Default: false
WithMemory bool `url:"with_memory" json:"with_memory"`
}
// SnapshotCreate create compute snapshot
type wrapperSnapshotCreateRequest struct {
SnapshotCreateRequest
AsyncMode bool `url:"asyncMode"`
}
// SnapshotCreate creates compute snapshot
func (c Compute) SnapshotCreate(ctx context.Context, req SnapshotCreateRequest) (string, error) {
err := validators.ValidateRequest(req)
if err != nil {
return "", validators.ValidationErrors(validators.GetErrors(err))
}
reqWrapped := wrapperSnapshotCreateRequest{
SnapshotCreateRequest: req,
AsyncMode: false,
}
url := "/cloudapi/compute/snapshotCreate"
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
if err != nil {
return "", err
}
@@ -40,3 +55,25 @@ func (c Compute) SnapshotCreate(ctx context.Context, req SnapshotCreateRequest)
return result, nil
}
// SnapshotCreateAsync creates compute snapshot in async mode
func (c Compute) SnapshotCreateAsync(ctx context.Context, req SnapshotCreateRequest) (string, error) {
err := validators.ValidateRequest(req)
if err != nil {
return "", validators.ValidationErrors(validators.GetErrors(err))
}
reqWrapped := wrapperSnapshotCreateRequest{
SnapshotCreateRequest: req,
AsyncMode: true,
}
url := "/cloudapi/compute/snapshotCreate"
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
if err != nil {
return "", err
}
return string(res), nil
}

View File

@@ -17,6 +17,16 @@ type SnapshotRollbackRequest struct {
// Text label of snapshot to rollback
// Required: true
Label string `url:"label" json:"label" validate:"required"`
// Rollback with memory dump restore
// Required: false
// Default: true
WithMemory interface{} `url:"with_memory,omitempty" json:"with_memory,omitempty" validate:"omitempty,isBool"`
}
type wrapperSnapshotRollbackRequest struct {
SnapshotRollbackRequest
AsyncMode bool `url:"asyncMode"`
}
// SnapshotRollback rollbacks specified compute snapshot
@@ -26,9 +36,14 @@ func (c Compute) SnapshotRollback(ctx context.Context, req SnapshotRollbackReque
return false, validators.ValidationErrors(validators.GetErrors(err))
}
reqWrapped := wrapperSnapshotRollbackRequest{
SnapshotRollbackRequest: req,
AsyncMode: false,
}
url := "/cloudapi/compute/snapshotRollback"
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
if err != nil {
return false, err
}
@@ -40,3 +55,25 @@ func (c Compute) SnapshotRollback(ctx context.Context, req SnapshotRollbackReque
return result, nil
}
// SnapshotRollbackAsync rollbacks specified compute snapshot in async mode
func (c Compute) SnapshotRollbackAsync(ctx context.Context, req SnapshotRollbackRequest) (string, error) {
err := validators.ValidateRequest(req)
if err != nil {
return "", validators.ValidationErrors(validators.GetErrors(err))
}
reqWrapped := wrapperSnapshotRollbackRequest{
SnapshotRollbackRequest: req,
AsyncMode: true,
}
url := "/cloudapi/compute/snapshotRollback"
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
if err != nil {
return "", err
}
return string(res), nil
}

View File

@@ -19,6 +19,12 @@ type StartRequest struct {
AltBootID uint64 `url:"altBootId,omitempty" json:"altBootId,omitempty"`
}
type wrapperStartRequest struct {
StartRequest
AsyncMode bool `url:"asyncMode"`
}
// Start starts compute
func (c Compute) Start(ctx context.Context, req StartRequest) (bool, error) {
err := validators.ValidateRequest(req)
@@ -26,9 +32,14 @@ func (c Compute) Start(ctx context.Context, req StartRequest) (bool, error) {
return false, validators.ValidationErrors(validators.GetErrors(err))
}
reqWrapped := wrapperStartRequest{
StartRequest: req,
AsyncMode: false,
}
url := "/cloudapi/compute/start"
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
if err != nil {
return false, err
}
@@ -40,3 +51,25 @@ func (c Compute) Start(ctx context.Context, req StartRequest) (bool, error) {
return result, nil
}
// StartAsync starts compute with AsyncMode
func (c Compute) StartAsync(ctx context.Context, req StartRequest) (string, error) {
err := validators.ValidateRequest(req)
if err != nil {
return "", validators.ValidationErrors(validators.GetErrors(err))
}
reqWrapped := wrapperStartRequest{
StartRequest: req,
AsyncMode: true,
}
url := "/cloudapi/compute/start"
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
if err != nil {
return "", err
}
return string(res), nil
}

View File

@@ -19,6 +19,12 @@ type StopRequest struct {
Force bool `url:"force,omitempty" json:"force,omitempty"`
}
type wrapperStopRequest struct {
StopRequest
AsyncMode bool `url:"asyncMode"`
}
// Stop stops compute
func (c Compute) Stop(ctx context.Context, req StopRequest) (bool, error) {
err := validators.ValidateRequest(req)
@@ -26,9 +32,14 @@ func (c Compute) Stop(ctx context.Context, req StopRequest) (bool, error) {
return false, validators.ValidationErrors(validators.GetErrors(err))
}
reqWrapped := wrapperStopRequest{
StopRequest: req,
AsyncMode: false,
}
url := "/cloudapi/compute/stop"
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
if err != nil {
return false, err
}
@@ -40,3 +51,25 @@ func (c Compute) Stop(ctx context.Context, req StopRequest) (bool, error) {
return result, nil
}
// StopAsync stops compute with AsyncMode
func (c Compute) StopAsync(ctx context.Context, req StopRequest) (string, error) {
err := validators.ValidateRequest(req)
if err != nil {
return "", validators.ValidationErrors(validators.GetErrors(err))
}
reqWrapped := wrapperStopRequest{
StopRequest: req,
AsyncMode: true,
}
url := "/cloudapi/compute/stop"
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
if err != nil {
return "", err
}
return string(res), nil
}

View File

@@ -69,6 +69,21 @@ type UpdateRequest struct {
// The OS version that will be installed on the virtual machine
// Required: false
OSVersion string `url:"os_version,omitempty" json:"os_version,omitempty"`
// Clock type for the VM
// Required: false
// Default: null
Clock string `url:"clock,omitempty" json:"clock,omitempty"`
// Watchdog action
// 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

View File

@@ -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
}

View File

@@ -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 {

View File

@@ -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 {

View File

@@ -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 {

View File

@@ -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 {

View File

@@ -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
}

View File

@@ -39,7 +39,13 @@ type CreateRequest struct {
Pool string `url:"pool,omitempty" json:"pool,omitempty"`
}
// Create creates a disk
type wrapperCreateRequest struct {
CreateRequest
AsyncMode bool `url:"async_mode" json:"async_mode"`
}
// Create creates a disk in sync mode
func (d Disks) Create(ctx context.Context, req CreateRequest) (uint64, error) {
err := validators.ValidateRequest(req)
if err != nil {
@@ -48,7 +54,12 @@ func (d Disks) Create(ctx context.Context, req CreateRequest) (uint64, error) {
url := "/cloudapi/disks/create"
res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, req)
wrappedReq := wrapperCreateRequest{
CreateRequest: req,
AsyncMode: false,
}
res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, wrappedReq)
if err != nil {
return 0, err
}
@@ -60,3 +71,25 @@ func (d Disks) Create(ctx context.Context, req CreateRequest) (uint64, error) {
return result, nil
}
// Create creates a disk in async mode
func (d Disks) CreateAsync(ctx context.Context, req CreateRequest) (string, error) {
err := validators.ValidateRequest(req)
if err != nil {
return "", validators.ValidationErrors(validators.GetErrors(err))
}
url := "/cloudapi/disks/create"
wrappedReq := wrapperCreateRequest{
CreateRequest: req,
AsyncMode: true,
}
res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, wrappedReq)
if err != nil {
return "", err
}
return string(res), nil
}

View File

@@ -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
}

View File

@@ -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
}

View File

@@ -25,4 +25,4 @@ func (lsd ListSearchDisks) IDs() []uint64 {
res = append(res, d.ID)
}
return res
}
}

View File

@@ -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
}

View File

@@ -28,7 +28,7 @@ type ListRequest struct {
// Find by status
// Required: false
Status string `url:"status,omitempty" json:"status,omitempty"`
Status []string `url:"status,omitempty" json:"status,omitempty"`
// Find by shared, true or false
// Required: false

View File

@@ -11,8 +11,8 @@ type ItemDisk struct {
// Account name
AccountName string `json:"accountName"`
// BLK Discard
BLKDiscard bool `json:"blkdiscard"`
// Discard
Discard string `json:"discard"`
// Block size of disk
BlockSize string `json:"block_size"`
@@ -20,6 +20,9 @@ type ItemDisk struct {
// Computes
Computes map[string]string `json:"computes"`
// Computes read only
ComputesReadOnly map[string]bool `json:"computes_read_only"`
//Created by
CreatedBy string `json:"createdBy"`
@@ -166,8 +169,8 @@ type ItemDiskUnattached struct {
// Access Control List
ACL map[string]interface{} `json:"acl"`
// BLK Discard
BLKDiscard bool `json:"blkdiscard"`
// Discard
Discard string `json:"discard"`
// Block size of disk
BlockSize string `json:"block_size"`
@@ -328,6 +331,10 @@ type ItemSnapshot struct {
// Label
Label string `json:"label"`
// Pool name
PoolName string `json:"poolName"`
// Reference ID
ReferenceID string `json:"referenceId"`
// Resource ID
@@ -399,8 +406,8 @@ type RecordDisk struct {
// Account name
AccountName string `json:"accountName"`
// BLK Discard
BLKDiscard bool `json:"blkdiscard"`
// Discard
Discard string `json:"discard"`
// Block size of disk
BlockSize string `json:"block_size"`
@@ -408,6 +415,9 @@ type RecordDisk struct {
// Computes
Computes map[string]string `json:"computes"`
// Computes read only
ComputesReadOnly map[string]bool `json:"computes_read_only"`
// Created by
CreatedBy string `json:"createdBy"`

View File

@@ -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
}

View File

@@ -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
}

View File

@@ -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
}

View File

@@ -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
}

View File

@@ -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
}

View File

@@ -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
}

View File

@@ -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
}

View File

@@ -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
}

View File

@@ -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
}

View File

@@ -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
}

View File

@@ -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
}

Some files were not shown because too many files have changed in this diff Show More