Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 71b53b743d | |||
|
|
b3fccfb000 | ||
| eb195dd992 | |||
| d7b8f08b4d | |||
| bd2d22f456 | |||
|
|
416a6c4263 | ||
| 6ff4b83368 | |||
| 118b48c3bc |
@@ -1,3 +1,4 @@
|
|||||||
|
version: "2"
|
||||||
linters:
|
linters:
|
||||||
enable:
|
enable:
|
||||||
- bodyclose
|
- bodyclose
|
||||||
@@ -5,19 +6,20 @@ linters:
|
|||||||
- dogsled
|
- dogsled
|
||||||
- errorlint
|
- errorlint
|
||||||
- exhaustive
|
- exhaustive
|
||||||
- exportloopref
|
|
||||||
- exhaustive
|
|
||||||
#- gocognit
|
|
||||||
- goconst
|
- goconst
|
||||||
#- gocyclo
|
|
||||||
- gosec
|
- gosec
|
||||||
- makezero
|
- makezero
|
||||||
#- nestif
|
- musttag
|
||||||
- nilerr
|
- nilerr
|
||||||
|
- noctx
|
||||||
- prealloc
|
- prealloc
|
||||||
|
- revive
|
||||||
|
- staticcheck
|
||||||
- unconvert
|
- unconvert
|
||||||
- unparam
|
- unparam
|
||||||
- noctx
|
- unused
|
||||||
|
exclusions:
|
||||||
|
presets:
|
||||||
|
- comments
|
||||||
issues:
|
issues:
|
||||||
max-same-issues: 0
|
max-same-issues: 0
|
||||||
|
|||||||
55
CHANGELOG.md
55
CHANGELOG.md
@@ -1,41 +1,60 @@
|
|||||||
## Version 1.15.2
|
## Version 1.16.2
|
||||||
|
|
||||||
Методы `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: |
|
||||||
|
|
||||||
|
|
||||||
### Добавлено
|
### Добавлено
|
||||||
|
|
||||||
#### image
|
#### audit
|
||||||
| Идентификатор задачи | Описание |
|
| Идентификатор задачи | Описание |
|
||||||
| --- | --- |
|
| --- | --- |
|
||||||
| BGOS-916 | Вычисляемые поля `Compute` и `MemoryDumpImage` в структуру ответа `ItemSnapSet` в cloudapi/image |
|
| BGOS-1025 | Вычисляемое поле `PublicSessionID` в структуры ответа `ItemAudit` и `RecordAudit` в cloudbroker/audit и cloudapi/audit |
|
||||||
|
| BGOS-1025 | Опциональное поле `PublicSessionID` в структуру запроса `ListRequest` в cloudbroker/audit и cloudapi/audit |
|
||||||
|
|
||||||
#### node
|
#### grid
|
||||||
| Идентификатор задачи | Описание |
|
| Идентификатор задачи | Описание |
|
||||||
| --- | --- |
|
| --- | --- |
|
||||||
| BGOS-919 | Вычисляемое поле `MaxSupportedGeneration` в структуру ответа `CpuInfo` в cloudbroker/node |
|
| BGOS-1028 | Вычисляемое поле `Budget` в структуры ответа `ItemGridList` и `RecordGrid` в cloudbroker/grid |
|
||||||
|
|
||||||
#### zone
|
#### vins
|
||||||
| Идентификатор задачи | Описание |
|
| Идентификатор задачи | Описание |
|
||||||
| --- | --- |
|
| --- | --- |
|
||||||
| BGOS-914 | Вычисляемые поля `ID`, `Name` и `ConsumedBy` в структуру ответа `RecordConsumption` в cloudbroker/sep |
|
| BGOS-1027 | Вычисляемое поле `QoSPolicies` в структуру ответа `ItemVNFInterface` в cloudbroker/vins и cloudapi/vins |
|
||||||
| BGOS-914 | Структура ответа `ListConsumption` в cloudbroker/sep |
|
|
||||||
|
#### session
|
||||||
|
| Идентификатор задачи | Описание |
|
||||||
|
| --- | --- |
|
||||||
|
| BGOS-1026 | Группа ручек cloudbroker/session |
|
||||||
|
|
||||||
|
|
||||||
### Изменено
|
### Изменено
|
||||||
|
|
||||||
#### account
|
#### network qos policy
|
||||||
| Идентификатор задачи | Описание |
|
| Идентификатор задачи | Описание |
|
||||||
| --- | --- |
|
| --- | --- |
|
||||||
| BGOS-918 | Тип обязательного поля `Ratio` с `float64` на `uint64` в структуре запроса `SetCPUAllocationRatioRequest` в cloudbroker/account |
|
| BGOS-1030 | Тип вычисляемых полей `PCPTag` и `DSCPValue` с `uint64` на `*uint64` в структуре ответа `Rule` в cloudapi/qospolicy и cloudbroker/qospolicy |
|
||||||
|
| BGOS-1030 | Тип опциональных полей `Name` и `Description` с `string` на `*string` в структуре запроса `UpdateRequest` в cloudapi/qospolicy и cloudbroker/qospolicy |
|
||||||
|
|
||||||
#### SEP
|
|
||||||
|
### Удалено
|
||||||
|
|
||||||
|
#### compute
|
||||||
| Идентификатор задачи | Описание |
|
| Идентификатор задачи | Описание |
|
||||||
| --- | --- |
|
| --- | --- |
|
||||||
| BGOS-914 | Тип поля `SEPID` с обязательного на опциональный в структуре запроса `ConsumptionRequest` в cloudbroker/sep |
|
| BGOS-1029 | Опциональное поле `Type` из структуры запроса `ListVGPURequest` в cloudbroker/compute и cloudapi/compute |
|
||||||
| BGOS-914 | Тип ответа метода `Consumption` с `RecordConsumption` на `ListConsumption` в cloudbroker/sep |
|
|
||||||
|
|||||||
10
README.md
10
README.md
@@ -20,6 +20,7 @@ Decort SDK - это библиотека, написанная на языке G
|
|||||||
- Версия 1.13.х Decort-SDK соответствует 4.5.0 версии платформы
|
- Версия 1.13.х Decort-SDK соответствует 4.5.0 версии платформы
|
||||||
- Версия 1.14.х Decort-SDK соответствует 4.6.0 версии платформы
|
- Версия 1.14.х Decort-SDK соответствует 4.6.0 версии платформы
|
||||||
- Версия 1.15.х Decort-SDK соответствует 4.7.0 версии платформы
|
- Версия 1.15.х Decort-SDK соответствует 4.7.0 версии платформы
|
||||||
|
- Версия 1.16.х Decort-SDK соответствует 4.8.0 версии платформы
|
||||||
|
|
||||||
## Оглавление
|
## Оглавление
|
||||||
|
|
||||||
@@ -125,6 +126,7 @@ go get -u repository.basistech.ru/BASIS/decort-golang-sdk
|
|||||||
- `LB` - управление балансировщиками нагрузки;
|
- `LB` - управление балансировщиками нагрузки;
|
||||||
- `Locations` - получение информации о grid площадки;
|
- `Locations` - получение информации о grid площадки;
|
||||||
- `Prometheus` - получение статистики prometheus;
|
- `Prometheus` - получение статистики prometheus;
|
||||||
|
- `QoS Policy` - управление политиками качества обслуживания сети;
|
||||||
- `RG` - управление ресурсными группами аккаунта;
|
- `RG` - управление ресурсными группами аккаунта;
|
||||||
- `Security group` – управление группами безопасности;
|
- `Security group` – управление группами безопасности;
|
||||||
- `SEP` - управление storage endpoint (sep);
|
- `SEP` - управление storage endpoint (sep);
|
||||||
@@ -161,10 +163,12 @@ go get -u repository.basistech.ru/BASIS/decort-golang-sdk
|
|||||||
- `Node` - управление нодами платформы;
|
- `Node` - управление нодами платформы;
|
||||||
- `PCIDevice` - управление устройствами;
|
- `PCIDevice` - управление устройствами;
|
||||||
- `Prometheus` - получение статистики prometheus;
|
- `Prometheus` - получение статистики prometheus;
|
||||||
|
- `QoS Policy` - управление политиками качества обслуживания сети;
|
||||||
- `Resmon` - получение статистики resource monitoring;
|
- `Resmon` - получение статистики resource monitoring;
|
||||||
- `RG` - управление ресурсными группами аккаунта;
|
- `RG` - управление ресурсными группами аккаунта;
|
||||||
- `Security group` – управление группами безопасности;
|
- `Security group` – управление группами безопасности;
|
||||||
- `SEP` - управление storage endpoint (sep);
|
- `SEP` - управление storage endpoint (sep);
|
||||||
|
- `Session` - получение информации о сессиях;
|
||||||
- `Storage policy` – управление политиками хранения;
|
- `Storage policy` – управление политиками хранения;
|
||||||
- `Tasks` - получение информации о ходе выполнения асинхронных задач (например, создание кластера);
|
- `Tasks` - получение информации о ходе выполнения асинхронных задач (например, создание кластера);
|
||||||
- `Trunk` - управление транковыми портами;
|
- `Trunk` - управление транковыми портами;
|
||||||
@@ -338,6 +342,7 @@ func main() {
|
|||||||
- `pkg/cloudapi/lb` - для `LB`
|
- `pkg/cloudapi/lb` - для `LB`
|
||||||
- `pkg/cloudapi/locations` - для `Locations`
|
- `pkg/cloudapi/locations` - для `Locations`
|
||||||
- `pkg/cloudapi/prometheus` - для `Prometheus`
|
- `pkg/cloudapi/prometheus` - для `Prometheus`
|
||||||
|
- `pkg/cloudapi/qospolicy` - для `QoS Policy`
|
||||||
- `pkg/cloudapi/rg` - для `RG`
|
- `pkg/cloudapi/rg` - для `RG`
|
||||||
- `pkg/cloudapi/secgroup` - для `Security group`
|
- `pkg/cloudapi/secgroup` - для `Security group`
|
||||||
- `pkg/cloudapi/sep` - для `SEP`
|
- `pkg/cloudapi/sep` - для `SEP`
|
||||||
@@ -369,10 +374,12 @@ func main() {
|
|||||||
- `pkg/cloudbroker/node` - для `Node`
|
- `pkg/cloudbroker/node` - для `Node`
|
||||||
- `pkg/cloudbroker/pcidevice` - для `PCIDevice`
|
- `pkg/cloudbroker/pcidevice` - для `PCIDevice`
|
||||||
- `pkg/cloudbroker/prometheus` - для `Prometheus`
|
- `pkg/cloudbroker/prometheus` - для `Prometheus`
|
||||||
|
- `pkg/cloudbroker/qospolicy` - для `QoS Policy`
|
||||||
- `pkg/cloudbroker/resmon` - для `Resmon`
|
- `pkg/cloudbroker/resmon` - для `Resmon`
|
||||||
- `pkg/cloudbroker/rg` - для `RG`
|
- `pkg/cloudbroker/rg` - для `RG`
|
||||||
- `pkg/cloudbroker/secgroup` - для `Security group`
|
- `pkg/cloudbroker/secgroup` - для `Security group`
|
||||||
- `pkg/cloudbroker/sep` - для `SEP`
|
- `pkg/cloudbroker/sep` - для `SEP`
|
||||||
|
- `pkg/cloudbroker/session` - для `Session`
|
||||||
- `pkg/cloudbroker/stpolicy` - для `Storage policy`
|
- `pkg/cloudbroker/stpolicy` - для `Storage policy`
|
||||||
- `pkg/cloudbroker/tasks` - для `Tasks`
|
- `pkg/cloudbroker/tasks` - для `Tasks`
|
||||||
- `pkg/cloudbroker/trunk` - для `Trunk`
|
- `pkg/cloudbroker/trunk` - для `Trunk`
|
||||||
@@ -537,6 +544,7 @@ func main() {
|
|||||||
- `.LB()` - для работы с `LB`
|
- `.LB()` - для работы с `LB`
|
||||||
- `.Locations()` - для работы с `Locations`
|
- `.Locations()` - для работы с `Locations`
|
||||||
- `.Prometheus()` - для работы с `Prometheus`
|
- `.Prometheus()` - для работы с `Prometheus`
|
||||||
|
- `.QoSPolicy()` - для работы с `QoS Policy`
|
||||||
- `.RG()` - для работы с `RG`
|
- `.RG()` - для работы с `RG`
|
||||||
- `.SecurityGroup()` - для работы с `Security Group`
|
- `.SecurityGroup()` - для работы с `Security Group`
|
||||||
- `.SEP()` - для работы с `SEP`
|
- `.SEP()` - для работы с `SEP`
|
||||||
@@ -570,10 +578,12 @@ func main() {
|
|||||||
- `.Node()` - для работы с `Node`
|
- `.Node()` - для работы с `Node`
|
||||||
- `.PCIDevice()` - для работы с `PCIDevice`
|
- `.PCIDevice()` - для работы с `PCIDevice`
|
||||||
- `.Prometheus()` - для работы с `Prometheus`
|
- `.Prometheus()` - для работы с `Prometheus`
|
||||||
|
- `.QoSPolicy()` - для работы с `QoS Policy`
|
||||||
- `.Resmon()` - для работы с `Resmon`
|
- `.Resmon()` - для работы с `Resmon`
|
||||||
- `.RG()` - для работы с `RG`
|
- `.RG()` - для работы с `RG`
|
||||||
- `.SecurityGroup()` - для работы с `Security Group`
|
- `.SecurityGroup()` - для работы с `Security Group`
|
||||||
- `.SEP()` - для работы с `SEP`
|
- `.SEP()` - для работы с `SEP`
|
||||||
|
- `.Session()` - для работы с `Session`
|
||||||
- `.StPolicy()` - для работы с `Storage Policy`
|
- `.StPolicy()` - для работы с `Storage Policy`
|
||||||
- `.Tasks()` - для работы с `Tasks`
|
- `.Tasks()` - для работы с `Tasks`
|
||||||
- `.Trunk()` - для работы с `Trunk`
|
- `.Trunk()` - для работы с `Trunk`
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ type DecortClient struct {
|
|||||||
mutex *sync.Mutex
|
mutex *sync.Mutex
|
||||||
}
|
}
|
||||||
|
|
||||||
// Сlient builder
|
// Client builder
|
||||||
func New(cfg config.Config) *DecortClient {
|
func New(cfg config.Config) *DecortClient {
|
||||||
if err := validators.ValidateConfig(cfg); err != nil {
|
if err := validators.ValidateConfig(cfg); err != nil {
|
||||||
panic(validators.ValidationErrors(validators.GetErrors(err)))
|
panic(validators.ValidationErrors(validators.GetErrors(err)))
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ var FileName = map[string]string{
|
|||||||
var K8sValues = []string{"labels", "taints", "annotations, additionalSANs"}
|
var K8sValues = []string{"labels", "taints", "annotations, additionalSANs"}
|
||||||
|
|
||||||
var VersionMap = map[string]string{
|
var VersionMap = map[string]string{
|
||||||
|
"4.8.0": "-",
|
||||||
"4.7.0": "-",
|
"4.7.0": "-",
|
||||||
"4.6.0": "-",
|
"4.6.0": "-",
|
||||||
"4.5.0": "-",
|
"4.5.0": "-",
|
||||||
|
|||||||
@@ -350,6 +350,10 @@ func isBoolTypeValidator(fe validator.FieldLevel) bool {
|
|||||||
return fe.Field().CanConvert(reflect.TypeOf(true))
|
return fe.Field().CanConvert(reflect.TypeOf(true))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func isStringTypeValidator(fe validator.FieldLevel) bool {
|
||||||
|
return fe.Field().Kind() == reflect.String
|
||||||
|
}
|
||||||
|
|
||||||
func urlValidartor(fl validator.FieldLevel) bool {
|
func urlValidartor(fl validator.FieldLevel) bool {
|
||||||
fieldValues := fl.Field().String()
|
fieldValues := fl.Field().String()
|
||||||
|
|
||||||
@@ -484,3 +488,15 @@ func sepDescriptionValidator(fe validator.FieldLevel) bool {
|
|||||||
ok, _ := regexp.MatchString(`^[a-zA-Zа-яА-ЯёЁ0-9_.\[\]()\-]*$`, fe.Field().String())
|
ok, _ := regexp.MatchString(`^[a-zA-Zа-яА-ЯёЁ0-9_.\[\]()\-]*$`, fe.Field().String())
|
||||||
return ok
|
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)
|
||||||
|
}
|
||||||
|
|||||||
@@ -15,6 +15,10 @@ func errorMessage(fe validator.FieldError) string {
|
|||||||
// Common Validators
|
// Common Validators
|
||||||
case "required":
|
case "required":
|
||||||
return fmt.Sprintf("%s %s is required", prefix, fe.Field())
|
return fmt.Sprintf("%s %s is required", prefix, fe.Field())
|
||||||
|
case "required_without_all":
|
||||||
|
return fmt.Sprintf("%s at least one of the following must be specified: %s",
|
||||||
|
prefix,
|
||||||
|
joinValues(append([]string{fe.Field()}, strings.Fields(fe.Param())...)))
|
||||||
case "gt":
|
case "gt":
|
||||||
return fmt.Sprintf("%s %s can't be less or equal to zero", prefix, fe.Field())
|
return fmt.Sprintf("%s %s can't be less or equal to zero", prefix, fe.Field())
|
||||||
case "min":
|
case "min":
|
||||||
@@ -25,8 +29,12 @@ func errorMessage(fe validator.FieldError) string {
|
|||||||
return fmt.Sprintf("%s %s: unexpected URL format", prefix, fe.Field())
|
return fmt.Sprintf("%s %s: unexpected URL format", prefix, fe.Field())
|
||||||
case "email":
|
case "email":
|
||||||
return fmt.Sprintf("%s %s: unexpected E-Mail format", prefix, fe.Field())
|
return fmt.Sprintf("%s %s: unexpected E-Mail format", prefix, fe.Field())
|
||||||
|
case "mac":
|
||||||
|
return fmt.Sprintf("%s %s: unexpected MAC address format", prefix, fe.Field())
|
||||||
case "isBool":
|
case "isBool":
|
||||||
return fmt.Sprintf("%s %s: must be bool type", prefix, fe.Field())
|
return fmt.Sprintf("%s %s: must be bool type", prefix, fe.Field())
|
||||||
|
case "isString":
|
||||||
|
return fmt.Sprintf("%s %s: must be string type", prefix, fe.Field())
|
||||||
|
|
||||||
case "accessType":
|
case "accessType":
|
||||||
return fmt.Sprintf("%s %s must be one of the following: %s",
|
return fmt.Sprintf("%s %s must be one of the following: %s",
|
||||||
|
|||||||
@@ -231,6 +231,11 @@ func registerAllValidators(validate *validator.Validate) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
err = validate.RegisterValidation("isString", isStringTypeValidator)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
err = validate.RegisterValidation("url", urlValidartor)
|
err = validate.RegisterValidation("url", urlValidartor)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -321,5 +326,15 @@ func registerAllValidators(validate *validator.Validate) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
err = validate.RegisterValidation("watchdogAction", watchdogActionValidator)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
err = validate.RegisterValidation("memoryBalloonMode", memoryBalloonModeValidator)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ var (
|
|||||||
|
|
||||||
vmActionValues = []string{"stop", "move"}
|
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"}
|
networkInterfaceNamingValues = []string{"eth", "ens"}
|
||||||
|
|
||||||
@@ -80,6 +80,10 @@ var (
|
|||||||
ipTypeValues = []string{"v4, v6"}
|
ipTypeValues = []string{"v4, v6"}
|
||||||
|
|
||||||
sepTechStatusValues = []string{"ENABLED", "DISABLED"}
|
sepTechStatusValues = []string{"ENABLED", "DISABLED"}
|
||||||
|
|
||||||
|
watchdogActionValues = []string{"reset", "shutdown", "poweroff", "pause", "none"}
|
||||||
|
|
||||||
|
memoryBalloonModeValues = []string{"auto", "legacy", "none"}
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
|||||||
40
pkg/cloudapi/account/add_acl_access.go
Normal file
40
pkg/cloudapi/account/add_acl_access.go
Normal 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
|
||||||
|
}
|
||||||
@@ -27,6 +27,8 @@ type AddUserRequest struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// AddUser gives a user access rights.
|
// 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) {
|
func (a Account) AddUser(ctx context.Context, req AddUserRequest) (bool, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -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
|
|
||||||
}
|
|
||||||
39
pkg/cloudapi/account/del_acl_access.go
Normal file
39
pkg/cloudapi/account/del_acl_access.go
Normal 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
|
||||||
|
}
|
||||||
@@ -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
|
|
||||||
}
|
|
||||||
@@ -20,6 +20,8 @@ type DeleteUserRequest struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// DeleteUser revokes user access from the account
|
// 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) {
|
func (a Account) DeleteUser(ctx context.Context, req DeleteUserRequest) (bool, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -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
|
|
||||||
}
|
|
||||||
@@ -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
|
|
||||||
}
|
|
||||||
@@ -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
|
|
||||||
}
|
|
||||||
@@ -19,9 +19,6 @@ type ListRecordACL struct {
|
|||||||
|
|
||||||
// Account owner ID
|
// Account owner ID
|
||||||
UgroupID string `json:"userGroupId"`
|
UgroupID string `json:"userGroupId"`
|
||||||
|
|
||||||
// Is it possible to remove
|
|
||||||
CanBeDeleted bool `json:"canBeDeleted"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Access Control List
|
// Access Control List
|
||||||
@@ -203,11 +200,56 @@ type ListResourceConsumption struct {
|
|||||||
|
|
||||||
// Information about computes
|
// Information about computes
|
||||||
type Computes struct {
|
type Computes struct {
|
||||||
|
// Number of starting computes
|
||||||
|
Starting uint64 `json:"STARTING"`
|
||||||
|
|
||||||
// Number of started computes
|
// Number of started computes
|
||||||
Started uint64 `json:"started"`
|
Started uint64 `json:"STARTED"`
|
||||||
|
|
||||||
|
// Number of stopping computes
|
||||||
|
Stopping uint64 `json:"STOPPING"`
|
||||||
|
|
||||||
// Number of stopped computes
|
// Number of stopped computes
|
||||||
Stopped uint64 `json:"stopped"`
|
Stopped uint64 `json:"STOPPED"`
|
||||||
|
|
||||||
|
// Number of paused computes
|
||||||
|
Paused uint64 `json:"PAUSED"`
|
||||||
|
|
||||||
|
// Number of pausing computes
|
||||||
|
Pausing uint64 `json:"PAUSING"`
|
||||||
|
|
||||||
|
// Number of merging computes
|
||||||
|
Merge uint64 `json:"MERGE"`
|
||||||
|
|
||||||
|
// Number of migrating computes
|
||||||
|
Migrating uint64 `json:"MIGRATING"`
|
||||||
|
|
||||||
|
// Number of computes migrating in
|
||||||
|
MigratingIn uint64 `json:"MIGRATING_IN"`
|
||||||
|
|
||||||
|
// Number of computes migrating out
|
||||||
|
MigratingOut uint64 `json:"MIGRATING_OUT"`
|
||||||
|
|
||||||
|
// Number of computes in down status
|
||||||
|
Down uint64 `json:"DOWN"`
|
||||||
|
|
||||||
|
// Number of scheduled computes
|
||||||
|
Scheduled uint64 `json:"SCHEDULED"`
|
||||||
|
|
||||||
|
// Number of computes with stopped backup
|
||||||
|
BackupStopped uint64 `json:"BACKUP_STOPPED"`
|
||||||
|
|
||||||
|
// Number of computes with running backup
|
||||||
|
BackupRunning uint64 `json:"BACKUP_RUNNING"`
|
||||||
|
|
||||||
|
// Number of computes creating a snapshot
|
||||||
|
Snapcreate uint64 `json:"SNAPCREATE"`
|
||||||
|
|
||||||
|
// Number of cloning computes
|
||||||
|
Cloning uint64 `json:"CLONING"`
|
||||||
|
|
||||||
|
// Number of computes being rolled back
|
||||||
|
Rollback uint64 `json:"ROLLBACK"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Information about machines
|
// Information about machines
|
||||||
@@ -455,6 +497,9 @@ type ItemVINS struct {
|
|||||||
// Deleted time
|
// Deleted time
|
||||||
DeletedTime uint64 `json:"deletedTime"`
|
DeletedTime uint64 `json:"deletedTime"`
|
||||||
|
|
||||||
|
// Enable Default Gateway
|
||||||
|
EnableDefaultGateway bool `json:"enable_default_gateway"`
|
||||||
|
|
||||||
// External IP
|
// External IP
|
||||||
ExternalIP string `json:"externalIP"`
|
ExternalIP string `json:"externalIP"`
|
||||||
|
|
||||||
@@ -524,11 +569,56 @@ type ListAudits []ItemAudit
|
|||||||
|
|
||||||
// Information compute in resource group
|
// Information compute in resource group
|
||||||
type RGComputes struct {
|
type RGComputes struct {
|
||||||
|
// Number of starting computes
|
||||||
|
Starting uint64 `json:"STARTING"`
|
||||||
|
|
||||||
// Number of started computes
|
// Number of started computes
|
||||||
Started uint64 `json:"Started"`
|
Started uint64 `json:"STARTED"`
|
||||||
|
|
||||||
|
// Number of stopping computes
|
||||||
|
Stopping uint64 `json:"STOPPING"`
|
||||||
|
|
||||||
// Number of stopped computes
|
// Number of stopped computes
|
||||||
Stopped uint64 `json:"Stopped"`
|
Stopped uint64 `json:"STOPPED"`
|
||||||
|
|
||||||
|
// Number of paused computes
|
||||||
|
Paused uint64 `json:"PAUSED"`
|
||||||
|
|
||||||
|
// Number of pausing computes
|
||||||
|
Pausing uint64 `json:"PAUSING"`
|
||||||
|
|
||||||
|
// Number of merging computes
|
||||||
|
Merge uint64 `json:"MERGE"`
|
||||||
|
|
||||||
|
// Number of migrating computes
|
||||||
|
Migrating uint64 `json:"MIGRATING"`
|
||||||
|
|
||||||
|
// Number of computes migrating in
|
||||||
|
MigratingIn uint64 `json:"MIGRATING_IN"`
|
||||||
|
|
||||||
|
// Number of computes migrating out
|
||||||
|
MigratingOut uint64 `json:"MIGRATING_OUT"`
|
||||||
|
|
||||||
|
// Number of computes in down status
|
||||||
|
Down uint64 `json:"DOWN"`
|
||||||
|
|
||||||
|
// Number of scheduled computes
|
||||||
|
Scheduled uint64 `json:"SCHEDULED"`
|
||||||
|
|
||||||
|
// Number of computes with stopped backup
|
||||||
|
BackupStopped uint64 `json:"BACKUP_STOPPED"`
|
||||||
|
|
||||||
|
// Number of computes with running backup
|
||||||
|
BackupRunning uint64 `json:"BACKUP_RUNNING"`
|
||||||
|
|
||||||
|
// Number of computes creating a snapshot
|
||||||
|
Snapcreate uint64 `json:"SNAPCREATE"`
|
||||||
|
|
||||||
|
// Number of cloning computes
|
||||||
|
Cloning uint64 `json:"CLONING"`
|
||||||
|
|
||||||
|
// Number of computes being rolled back
|
||||||
|
Rollback uint64 `json:"ROLLBACK"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Resources of Resource group
|
// Resources of Resource group
|
||||||
|
|||||||
40
pkg/cloudapi/account/update_acl_access.go
Normal file
40
pkg/cloudapi/account/update_acl_access.go
Normal 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
|
||||||
|
}
|
||||||
@@ -27,6 +27,8 @@ type UpdateUserRequest struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// UpdateUser updates user access rights
|
// UpdateUser updates user access rights
|
||||||
|
//
|
||||||
|
// Deprecated: will be removed in SDK v1.17
|
||||||
func (a Account) UpdateUser(ctx context.Context, req UpdateUserRequest) (bool, error) {
|
func (a Account) UpdateUser(ctx context.Context, req UpdateUserRequest) (bool, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -90,6 +90,9 @@ type ListRequest struct {
|
|||||||
// Exclude audit lines from response
|
// Exclude audit lines from response
|
||||||
// Required: false
|
// Required: false
|
||||||
ExcludeAuditLines bool `url:"exclude_audit_lines,omitempty" json:"exclude_audit_lines,omitempty"`
|
ExcludeAuditLines bool `url:"exclude_audit_lines,omitempty" json:"exclude_audit_lines,omitempty"`
|
||||||
|
|
||||||
|
// Public Session ID
|
||||||
|
PublicSessionID string `json:"public_session_id"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// List gets audit records for the specified account object
|
// List gets audit records for the specified account object
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package audit
|
|||||||
|
|
||||||
// Main info about audit
|
// Main info about audit
|
||||||
type RecordAudit struct {
|
type RecordAudit struct {
|
||||||
|
|
||||||
// Arguments
|
// Arguments
|
||||||
Arguments string `json:"args"`
|
Arguments string `json:"args"`
|
||||||
|
|
||||||
@@ -41,6 +40,9 @@ type RecordAudit struct {
|
|||||||
|
|
||||||
// User
|
// User
|
||||||
User string `json:"user"`
|
User string `json:"user"`
|
||||||
|
|
||||||
|
// Public Session ID
|
||||||
|
PublicSessionID string `json:"public_session_id"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Main info about audit
|
// Main info about audit
|
||||||
@@ -81,6 +83,9 @@ type ItemAudit struct {
|
|||||||
// User
|
// User
|
||||||
User string `json:"user"`
|
User string `json:"user"`
|
||||||
|
|
||||||
|
// Public Session ID
|
||||||
|
PublicSessionID string `json:"public_session_id"`
|
||||||
|
|
||||||
// TTL
|
// TTL
|
||||||
TTL string `json:"_ttl"`
|
TTL string `json:"_ttl"`
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants"
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -62,9 +63,9 @@ type GroupAddRequest struct {
|
|||||||
// Required: false
|
// Required: false
|
||||||
TimeoutStart uint64 `url:"timeoutStart,omitempty" json:"timeoutStart,omitempty"`
|
TimeoutStart uint64 `url:"timeoutStart,omitempty" json:"timeoutStart,omitempty"`
|
||||||
|
|
||||||
// Meta data for working group computes, format YAML "user_data": 1111
|
// Meta data for working group computes, format yaml string or json object
|
||||||
// Required: false
|
// Required: false
|
||||||
UserData string `url:"userData,omitempty" json:"userData,omitempty"`
|
UserData interface{} `url:"userData,omitempty" json:"userData,omitempty"`
|
||||||
|
|
||||||
// Chipset "i440fx" or "Q35
|
// Chipset "i440fx" or "Q35
|
||||||
// Default value : Q35
|
// Default value : Q35
|
||||||
@@ -97,7 +98,7 @@ func (b BService) GroupAdd(ctx context.Context, req GroupAddRequest) (uint64, er
|
|||||||
|
|
||||||
url := "/cloudapi/bservice/groupAdd"
|
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 {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
|||||||
40
pkg/cloudapi/compute/add_acl_access.go
Normal file
40
pkg/cloudapi/compute/add_acl_access.go
Normal 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
|
||||||
|
}
|
||||||
@@ -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
|
|
||||||
}
|
|
||||||
84
pkg/cloudapi/compute/change_qos_policies.go
Normal file
84
pkg/cloudapi/compute/change_qos_policies.go
Normal 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
|
||||||
|
}
|
||||||
39
pkg/cloudapi/compute/del_acl_access.go
Normal file
39
pkg/cloudapi/compute/del_acl_access.go
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
package compute
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"net/http"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants"
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
|
)
|
||||||
|
|
||||||
|
// 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
|
||||||
|
}
|
||||||
44
pkg/cloudapi/compute/get_acl_access.go
Normal file
44
pkg/cloudapi/compute/get_acl_access.go
Normal 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
|
||||||
|
}
|
||||||
@@ -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
|
|
||||||
}
|
|
||||||
@@ -14,10 +14,6 @@ type ListPCIDeviceRequest struct {
|
|||||||
// Required: true
|
// Required: true
|
||||||
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
|
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
|
||||||
|
|
||||||
// Find by resource group ID
|
|
||||||
// Required: false
|
|
||||||
RGID uint64 `url:"rgId,omitempty" json:"rgId,omitempty"`
|
|
||||||
|
|
||||||
// Find by device id
|
// Find by device id
|
||||||
// Required: false
|
// Required: false
|
||||||
DevID uint64 `url:"devId,omitempty" json:"devId,omitempty"`
|
DevID uint64 `url:"devId,omitempty" json:"devId,omitempty"`
|
||||||
|
|||||||
@@ -18,10 +18,6 @@ type ListVGPURequest struct {
|
|||||||
// Required: false
|
// Required: false
|
||||||
GPUID uint64 `url:"gpuId,omitempty" json:"gpuId,omitempty"`
|
GPUID uint64 `url:"gpuId,omitempty" json:"gpuId,omitempty"`
|
||||||
|
|
||||||
// Find by type
|
|
||||||
// Required: false
|
|
||||||
Type string `url:"type,omitempty" json:"type,omitempty"`
|
|
||||||
|
|
||||||
// Find by status
|
// Find by status
|
||||||
// Required: false
|
// Required: false
|
||||||
Status string `url:"status,omitempty" json:"status,omitempty"`
|
Status string `url:"status,omitempty" json:"status,omitempty"`
|
||||||
|
|||||||
@@ -182,6 +182,9 @@ type RecordNetAttach struct {
|
|||||||
// Enabled
|
// Enabled
|
||||||
Enabled bool `json:"enabled"`
|
Enabled bool `json:"enabled"`
|
||||||
|
|
||||||
|
// Enable default gateway
|
||||||
|
EnableDefaultGateway bool `json:"enable_default_gateway"`
|
||||||
|
|
||||||
// Enable security groups
|
// Enable security groups
|
||||||
EnableSecGroups bool `json:"enable_secgroups"`
|
EnableSecGroups bool `json:"enable_secgroups"`
|
||||||
|
|
||||||
@@ -443,6 +446,9 @@ type RecordCompute struct {
|
|||||||
// Manager type
|
// Manager type
|
||||||
ManagerType string `json:"managerType"`
|
ManagerType string `json:"managerType"`
|
||||||
|
|
||||||
|
// Memory balloon mode
|
||||||
|
MemoryBalloonMode string `json:"memory_balloon_mode"`
|
||||||
|
|
||||||
// Migration job
|
// Migration job
|
||||||
MigrationJob uint64 `json:"migrationjob"`
|
MigrationJob uint64 `json:"migrationjob"`
|
||||||
|
|
||||||
@@ -509,6 +515,9 @@ type RecordCompute struct {
|
|||||||
// Registered or not
|
// Registered or not
|
||||||
Registered bool `json:"registered"`
|
Registered bool `json:"registered"`
|
||||||
|
|
||||||
|
// Whether a compute has been resized online
|
||||||
|
ResizedOnline bool `json:"resizedOnline"`
|
||||||
|
|
||||||
// Resource name
|
// Resource name
|
||||||
ResName string `json:"resName"`
|
ResName string `json:"resName"`
|
||||||
|
|
||||||
@@ -552,7 +561,317 @@ type RecordCompute struct {
|
|||||||
Userdata interface{} `json:"userdata"`
|
Userdata interface{} `json:"userdata"`
|
||||||
|
|
||||||
// vGPUs list
|
// vGPUs list
|
||||||
VGPUs []VGPUItem `json:"vgpus"`
|
VGPUs []ItemVGPU `json:"vgpus"`
|
||||||
|
|
||||||
|
// VNC password
|
||||||
|
VNCPassword string `json:"vncPasswd"`
|
||||||
|
|
||||||
|
// Watchdog action
|
||||||
|
WatchdogAction string `json:"watchdog_action"`
|
||||||
|
|
||||||
|
// Weight
|
||||||
|
Weight uint64 `json:"weight"`
|
||||||
|
|
||||||
|
// 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"`
|
||||||
|
|
||||||
|
// CPU Pin
|
||||||
|
CPUPin bool `json:"cpupin"`
|
||||||
|
|
||||||
|
// Number of cores
|
||||||
|
CPU uint64 `json:"cpus"`
|
||||||
|
|
||||||
|
// Created by
|
||||||
|
CreatedBy string `json:"createdBy"`
|
||||||
|
|
||||||
|
// Created time
|
||||||
|
CreatedTime uint64 `json:"createdTime"`
|
||||||
|
|
||||||
|
// Custom fields items
|
||||||
|
CustomFields map[string]interface{} `json:"customFields"`
|
||||||
|
|
||||||
|
// Deleted by
|
||||||
|
DeletedBy string `json:"deletedBy"`
|
||||||
|
|
||||||
|
// Deleted time
|
||||||
|
DeletedTime uint64 `json:"deletedTime"`
|
||||||
|
|
||||||
|
// Description
|
||||||
|
Description string `json:"desc"`
|
||||||
|
|
||||||
|
// Devices
|
||||||
|
Devices interface{} `json:"devices"`
|
||||||
|
|
||||||
|
// List disks in compute
|
||||||
|
Disks ListComputeDisks `json:"disks"`
|
||||||
|
|
||||||
|
// Driver
|
||||||
|
Driver string `json:"driver"`
|
||||||
|
|
||||||
|
// Grid ID
|
||||||
|
GID uint64 `json:"gid"`
|
||||||
|
|
||||||
|
// GUID
|
||||||
|
GUID uint64 `json:"guid"`
|
||||||
|
|
||||||
|
// HPBacked
|
||||||
|
HPBacked bool `json:"hpBacked"`
|
||||||
|
|
||||||
|
// Hot resize
|
||||||
|
HotResize bool `json:"hotResize"`
|
||||||
|
|
||||||
|
// ID
|
||||||
|
ID uint64 `json:"id"`
|
||||||
|
|
||||||
|
// Image ID
|
||||||
|
ImageID uint64 `json:"imageId"`
|
||||||
|
|
||||||
|
// Image name
|
||||||
|
ImageName string `json:"imageName"`
|
||||||
|
|
||||||
|
// List interfaces
|
||||||
|
Interfaces ListInterfaces `json:"interfaces"`
|
||||||
|
|
||||||
|
// Loader meta iso information
|
||||||
|
LoaderMetaIso LoaderMetaIso `json:"loaderMetaIso"`
|
||||||
|
|
||||||
|
// Live migration job ID
|
||||||
|
LiveMigrationJobID uint64 `json:"live_migration_job_id"`
|
||||||
|
|
||||||
|
// Loader type
|
||||||
|
LoaderType string `json:"loaderType"`
|
||||||
|
|
||||||
|
// Lock status
|
||||||
|
LockStatus string `json:"lockStatus"`
|
||||||
|
|
||||||
|
// Manager ID
|
||||||
|
ManagerID uint64 `json:"managerId"`
|
||||||
|
|
||||||
|
// Manager type
|
||||||
|
ManagerType string `json:"managerType"`
|
||||||
|
|
||||||
|
// Migration job
|
||||||
|
MigrationJob uint64 `json:"migrationjob"`
|
||||||
|
|
||||||
|
// Milestones
|
||||||
|
Milestones uint64 `json:"milestones"`
|
||||||
|
|
||||||
|
// Name
|
||||||
|
Name string `json:"name"`
|
||||||
|
|
||||||
|
// NeedReboot
|
||||||
|
NeedReboot bool `json:"needReboot"`
|
||||||
|
|
||||||
|
// Network interface naming
|
||||||
|
NetworkInterfaceNaming string `json:"networkInterfaceNaming"`
|
||||||
|
|
||||||
|
// Node ID
|
||||||
|
NodeID uint64 `json:"node_id"`
|
||||||
|
|
||||||
|
// Numa Affinity
|
||||||
|
NumaAffinity string `json:"numaAffinity"`
|
||||||
|
|
||||||
|
//NumaNodeId
|
||||||
|
NumaNodeId int64 `json:"numaNodeId"`
|
||||||
|
|
||||||
|
// Natable VINS ID
|
||||||
|
NatableVINSID uint64 `json:"natableVinsId"`
|
||||||
|
|
||||||
|
// Natable VINS IP
|
||||||
|
NatableVINSIP string `json:"natableVinsIp"`
|
||||||
|
|
||||||
|
// Natable VINS Name
|
||||||
|
NatableVINSName string `json:"natableVinsName"`
|
||||||
|
|
||||||
|
// Natable VINS network
|
||||||
|
NatableVINSNetwork string `json:"natableVinsNetwork"`
|
||||||
|
|
||||||
|
// Natable VINS network name
|
||||||
|
NatableVINSNetworkName string `json:"natableVinsNetworkName"`
|
||||||
|
|
||||||
|
// Name of OS
|
||||||
|
OSVersion string `json:"os_version"`
|
||||||
|
|
||||||
|
// List OS Users
|
||||||
|
OSUsers ListOSUser `json:"osUsers"`
|
||||||
|
|
||||||
|
// Pinned to node
|
||||||
|
PinnedToNode int64 `json:"pinnedToNode"`
|
||||||
|
|
||||||
|
// PreferredCPU
|
||||||
|
PreferredCPU []int64 `json:"preferredCpu"`
|
||||||
|
|
||||||
|
// CPU alignment profile
|
||||||
|
CPUAlignmentProfile CPUAlignmentProfile `json:"cpu_alignment_profile"`
|
||||||
|
|
||||||
|
// Qemu_quest
|
||||||
|
QemuQuest QemuQuest `json:"qemu_guest"`
|
||||||
|
|
||||||
|
// ReadOnly indicates read-only mode state
|
||||||
|
ReadOnly bool `json:"read_only"`
|
||||||
|
|
||||||
|
// Number of RAM
|
||||||
|
RAM uint64 `json:"ram"`
|
||||||
|
|
||||||
|
// Reference ID
|
||||||
|
ReferenceID string `json:"referenceId"`
|
||||||
|
|
||||||
|
// Registered or not
|
||||||
|
Registered bool `json:"registered"`
|
||||||
|
|
||||||
|
// Resource name
|
||||||
|
ResName string `json:"resName"`
|
||||||
|
|
||||||
|
// Reserved Node Cpus
|
||||||
|
ReservedNodeCpus []uint64 `json:"reservedNodeCpus"`
|
||||||
|
|
||||||
|
// Resource group ID
|
||||||
|
RGID uint64 `json:"rgId"`
|
||||||
|
|
||||||
|
// Resource group name
|
||||||
|
RGName string `json:"rgName"`
|
||||||
|
|
||||||
|
// Stateless SepID
|
||||||
|
StatelessSepID int64 `json:"statelessSepId"`
|
||||||
|
|
||||||
|
// Stateless SepType
|
||||||
|
StatelessSepType string `json:"statelessSepType"`
|
||||||
|
|
||||||
|
// Status
|
||||||
|
Status string `json:"status"`
|
||||||
|
|
||||||
|
// Tags
|
||||||
|
Tags map[string]string `json:"tags"`
|
||||||
|
|
||||||
|
// Tech status
|
||||||
|
TechStatus string `json:"techStatus"`
|
||||||
|
|
||||||
|
// Updated by
|
||||||
|
UpdatedBy string `json:"updatedBy"`
|
||||||
|
|
||||||
|
// Updated time
|
||||||
|
UpdatedTime uint64 `json:"updatedTime"`
|
||||||
|
|
||||||
|
// User Managed or not
|
||||||
|
UserManaged bool `json:"userManaged"`
|
||||||
|
|
||||||
|
// Userdata
|
||||||
|
Userdata interface{} `json:"userdata"`
|
||||||
|
|
||||||
|
// vGPUs list
|
||||||
|
VGPUs []ItemVGPU `json:"vgpus"`
|
||||||
|
|
||||||
// VNC password
|
// VNC password
|
||||||
VNCPassword string `json:"vncPasswd"`
|
VNCPassword string `json:"vncPasswd"`
|
||||||
@@ -587,65 +906,6 @@ type CPUAlignmentProfile struct {
|
|||||||
Vendor string `json:"vendor"`
|
Vendor string `json:"vendor"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type VGPUItem struct {
|
|
||||||
// ID
|
|
||||||
ID uint64 `json:"id"`
|
|
||||||
|
|
||||||
// GID
|
|
||||||
GID uint64 `json:"gid"`
|
|
||||||
|
|
||||||
// Type
|
|
||||||
Type string `json:"type"`
|
|
||||||
|
|
||||||
// Mode
|
|
||||||
Mode string `json:"mode"`
|
|
||||||
|
|
||||||
// Status
|
|
||||||
Status string `json:"status"`
|
|
||||||
|
|
||||||
// ProfileID
|
|
||||||
ProfileID uint64 `json:"profileId"`
|
|
||||||
|
|
||||||
// RAM
|
|
||||||
RAM uint64 `json:"ram"`
|
|
||||||
|
|
||||||
// LastUpdateTime
|
|
||||||
LastUpdateTime uint64 `json:"lastUpdateTime"`
|
|
||||||
|
|
||||||
// CreatedTime
|
|
||||||
CreatedTime uint64 `json:"createdTime"`
|
|
||||||
|
|
||||||
// DeletedTime
|
|
||||||
DeletedTime uint64 `json:"deletedTime"`
|
|
||||||
|
|
||||||
// VMID
|
|
||||||
VMID uint64 `json:"vmid"`
|
|
||||||
|
|
||||||
// PGPuid
|
|
||||||
PGPuid uint64 `json:"pgpuid"`
|
|
||||||
|
|
||||||
// ReferenceID
|
|
||||||
ReferenceID string `json:"referenceId"`
|
|
||||||
|
|
||||||
// AccountID
|
|
||||||
AccountID uint64 `json:"accountId"`
|
|
||||||
|
|
||||||
// RgID
|
|
||||||
RgID uint64 `json:"rgId"`
|
|
||||||
|
|
||||||
// LastClaimedBy
|
|
||||||
LastClaimedBy uint64 `json:"lastClaimedBy"`
|
|
||||||
|
|
||||||
// PCISlot
|
|
||||||
PCISlot uint64 `json:"pciSlot"`
|
|
||||||
|
|
||||||
// BusNumber
|
|
||||||
BusNumber uint64 `json:"bus_number"`
|
|
||||||
|
|
||||||
// GUID
|
|
||||||
GUID uint64 `json:"guid"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// Information about libvirt settings
|
// Information about libvirt settings
|
||||||
type LibvirtSettings struct {
|
type LibvirtSettings struct {
|
||||||
// TX mode
|
// TX mode
|
||||||
@@ -691,7 +951,7 @@ type ListOSUser []ItemOSUser
|
|||||||
// Main information about snapsets
|
// Main information about snapsets
|
||||||
type ItemSnapSet struct {
|
type ItemSnapSet struct {
|
||||||
// Compute info
|
// Compute info
|
||||||
Compute RecordCompute `json:"compute"`
|
Compute SnapRecordCompute `json:"compute"`
|
||||||
|
|
||||||
// List disk ID
|
// List disk ID
|
||||||
Disks []uint64 `json:"disks"`
|
Disks []uint64 `json:"disks"`
|
||||||
@@ -729,6 +989,9 @@ type ItemVNFInterface struct {
|
|||||||
// Enabled
|
// Enabled
|
||||||
Enabled bool `json:"enabled"`
|
Enabled bool `json:"enabled"`
|
||||||
|
|
||||||
|
// Enable default gateway
|
||||||
|
EnableDefaultGateway bool `json:"enable_default_gateway"`
|
||||||
|
|
||||||
// Enable security groups
|
// Enable security groups
|
||||||
EnableSecGroups bool `json:"enable_secgroups"`
|
EnableSecGroups bool `json:"enable_secgroups"`
|
||||||
|
|
||||||
@@ -774,6 +1037,9 @@ type ItemVNFInterface struct {
|
|||||||
// QOS
|
// QOS
|
||||||
QOS QOS `json:"qos"`
|
QOS QOS `json:"qos"`
|
||||||
|
|
||||||
|
// List of QoS Policy IDs
|
||||||
|
QoSPolicies []uint64 `json:"qos_policies"`
|
||||||
|
|
||||||
// List of security groups
|
// List of security groups
|
||||||
SecGroups []uint64 `json:"security_groups"`
|
SecGroups []uint64 `json:"security_groups"`
|
||||||
|
|
||||||
@@ -996,6 +1262,9 @@ type SnapshotExtend struct {
|
|||||||
// Label
|
// Label
|
||||||
Label string `json:"label"`
|
Label string `json:"label"`
|
||||||
|
|
||||||
|
// Pool name
|
||||||
|
PoolName string `json:"poolName"`
|
||||||
|
|
||||||
// Reference ID
|
// Reference ID
|
||||||
ReferenceID string `json:"referenceId"`
|
ReferenceID string `json:"referenceId"`
|
||||||
|
|
||||||
@@ -1182,6 +1451,9 @@ type ItemCompute struct {
|
|||||||
// Manager type
|
// Manager type
|
||||||
ManagerType string `json:"managerType"`
|
ManagerType string `json:"managerType"`
|
||||||
|
|
||||||
|
// Memory balloon mode
|
||||||
|
MemoryBalloonMode string `json:"memory_balloon_mode"`
|
||||||
|
|
||||||
// Migration job
|
// Migration job
|
||||||
MigrationJob uint64 `json:"migrationjob"`
|
MigrationJob uint64 `json:"migrationjob"`
|
||||||
|
|
||||||
@@ -1191,6 +1463,9 @@ type ItemCompute struct {
|
|||||||
// Name
|
// Name
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
|
|
||||||
|
// Node ID
|
||||||
|
NodeID uint64 `json:"node_id"`
|
||||||
|
|
||||||
// NeedReboot
|
// NeedReboot
|
||||||
NeedReboot bool `json:"needReboot"`
|
NeedReboot bool `json:"needReboot"`
|
||||||
|
|
||||||
@@ -1230,6 +1505,9 @@ type ItemCompute struct {
|
|||||||
// Registered
|
// Registered
|
||||||
Registered bool `json:"registered"`
|
Registered bool `json:"registered"`
|
||||||
|
|
||||||
|
// Whether a compute has been resized online
|
||||||
|
ResizedOnline bool `json:"resizedOnline"`
|
||||||
|
|
||||||
// Resource name
|
// Resource name
|
||||||
ResName string `json:"resName"`
|
ResName string `json:"resName"`
|
||||||
|
|
||||||
@@ -1278,6 +1556,9 @@ type ItemCompute struct {
|
|||||||
// VINS connected
|
// VINS connected
|
||||||
VINSConnected uint64 `json:"vinsConnected"`
|
VINSConnected uint64 `json:"vinsConnected"`
|
||||||
|
|
||||||
|
// Watchdog action
|
||||||
|
WatchdogAction string `json:"watchdog_action"`
|
||||||
|
|
||||||
// Weight
|
// Weight
|
||||||
Weight uint64 `json:"weight"`
|
Weight uint64 `json:"weight"`
|
||||||
|
|
||||||
@@ -1296,6 +1577,9 @@ type InfoDisk struct {
|
|||||||
// SEP ID
|
// SEP ID
|
||||||
SepID int64 `json:"sepId"`
|
SepID int64 `json:"sepId"`
|
||||||
|
|
||||||
|
// Image ID
|
||||||
|
ImageID uint64 `json:"imageId"`
|
||||||
|
|
||||||
// Read-only
|
// Read-only
|
||||||
ReadOnly bool `json:"read_only"`
|
ReadOnly bool `json:"read_only"`
|
||||||
}
|
}
|
||||||
@@ -1320,59 +1604,59 @@ type ListVGPUs struct {
|
|||||||
|
|
||||||
// Main information about vgpu device
|
// Main information about vgpu device
|
||||||
type ItemVGPU struct {
|
type ItemVGPU struct {
|
||||||
// Account ID
|
// Account IDs
|
||||||
AccountID uint64 `json:"accountId"`
|
AccountIDs []uint64 `json:"account_ids"`
|
||||||
|
|
||||||
// Created Time
|
// Bus number
|
||||||
CreatedTime uint64 `json:"createdTime"`
|
BusNumber int `json:"bus_number"`
|
||||||
|
|
||||||
// Deleted Time
|
// ComputeID
|
||||||
DeletedTime uint64 `json:"deletedTime"`
|
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"`
|
GID uint64 `json:"gid"`
|
||||||
|
|
||||||
// GUID
|
// GUID
|
||||||
GUID uint64 `json:"guid"`
|
GUID uint64 `json:"guid"`
|
||||||
|
|
||||||
// ID
|
// VGPU ID
|
||||||
ID uint64 `json:"id"`
|
ID uint64 `json:"id"`
|
||||||
|
|
||||||
// Last Claimed By
|
// Last Update time
|
||||||
LastClaimedBy uint64 `json:"lastClaimedBy"`
|
LastUpdateTime uint64 `json:"last_update_time"`
|
||||||
|
|
||||||
// Last Update Time
|
// Mdev UUID
|
||||||
LastUpdateTime uint64 `json:"lastUpdateTime"`
|
MdevUUID string `json:"mdev_uuid"`
|
||||||
|
|
||||||
// Mode
|
// Parent PCI Address
|
||||||
Mode string `json:"mode"`
|
ParentPCIAddress string `json:"parent_pci_address"`
|
||||||
|
|
||||||
// PCI Slot
|
// PCI Slot
|
||||||
PCISlot uint64 `json:"pciSlot"`
|
PCISlot uint64 `json:"pci_slot"`
|
||||||
|
|
||||||
// PGPUID
|
// PGPU ID
|
||||||
PGPUID uint64 `json:"pgpuid"`
|
PGPUID uint64 `json:"pgpu_id"`
|
||||||
|
|
||||||
// Profile ID
|
// Profile Reference
|
||||||
ProfileID uint64 `json:"profileId"`
|
ProfileReference string `json:"profile_reference"`
|
||||||
|
|
||||||
// RAM
|
// Profile Name
|
||||||
RAM uint64 `json:"ram"`
|
ProfileName string `json:"profile_name"`
|
||||||
|
|
||||||
// Reference ID
|
// Split Mode
|
||||||
ReferenceID string `json:"referenceId"`
|
SplitMode string `json:"split_mode"`
|
||||||
|
|
||||||
// RG ID
|
|
||||||
RGID uint64 `json:"rgId"`
|
|
||||||
|
|
||||||
// Status
|
// Status
|
||||||
Status string `json:"status"`
|
Status string `json:"status"`
|
||||||
|
|
||||||
// Type
|
|
||||||
Type string `json:"type"`
|
|
||||||
|
|
||||||
// VM ID
|
|
||||||
VMID uint64 `json:"vmid"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Main information about PCI device
|
// Main information about PCI device
|
||||||
@@ -1395,8 +1679,8 @@ type ItemPCIDevice struct {
|
|||||||
// Name
|
// Name
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
|
|
||||||
// Resource group ID
|
// Account IDs
|
||||||
RGID uint64 `json:"rgId"`
|
AccountIDs []uint64 `json:"account_ids"`
|
||||||
|
|
||||||
// Node ID
|
// Node ID
|
||||||
NodeID uint64 `json:"nodeId"`
|
NodeID uint64 `json:"nodeId"`
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants"
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -81,12 +82,21 @@ type NetAttachRequest struct {
|
|||||||
// Flag indicating whether this interface is enabled (only for VINS, EXTNET, DPDK, SDN, TRUNK)
|
// Flag indicating whether this interface is enabled (only for VINS, EXTNET, DPDK, SDN, TRUNK)
|
||||||
// Required: false
|
// Required: false
|
||||||
Enabled interface{} `url:"enabled,omitempty" json:"enabled,omitempty" validate:"omitempty,isBool"`
|
Enabled interface{} `url:"enabled,omitempty" json:"enabled,omitempty" validate:"omitempty,isBool"`
|
||||||
|
|
||||||
|
// Flag indicating whether default gateway is enabled for this interface
|
||||||
|
// Required: false
|
||||||
|
// Default: true
|
||||||
|
EnableDefaultGateway interface{} `url:"enable_default_gateway,omitempty" json:"enable_default_gateway,omitempty" validate:"omitempty,isBool"`
|
||||||
|
|
||||||
|
// List of QoS Policy IDs to apply to this interface (default: []), Allow used only with netType VINS, EXTNET and DPDK
|
||||||
|
// Required: false
|
||||||
|
QoSPolicies []uint64 `url:"qos_policies,omitempty" json:"qos_policies,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type wrapperNetAttachRequest struct {
|
type wrapperNetAttachRequest struct {
|
||||||
NetAttachRequest
|
NetAttachRequest
|
||||||
|
|
||||||
AsyncMode bool `url:"asyncMode"`
|
AsyncMode bool `url:"asyncMode" json:"asyncMode"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// NetAttach attaches network to compute and gets info about network
|
// NetAttach attaches network to compute and gets info about network
|
||||||
@@ -103,7 +113,7 @@ func (c Compute) NetAttach(ctx context.Context, req NetAttachRequest) (*RecordNe
|
|||||||
|
|
||||||
url := "/cloudapi/compute/netAttach"
|
url := "/cloudapi/compute/netAttach"
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
res, err := c.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, reqWrapped)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -132,7 +142,7 @@ func (c Compute) NetAttachAsync(ctx context.Context, req NetAttachRequest) (stri
|
|||||||
|
|
||||||
url := "/cloudapi/compute/netAttach"
|
url := "/cloudapi/compute/netAttach"
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
res, err := c.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, reqWrapped)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -74,6 +74,16 @@ type UpdateRequest struct {
|
|||||||
// Required: false
|
// Required: false
|
||||||
// Default: null
|
// Default: null
|
||||||
Clock string `url:"clock,omitempty" json:"clock,omitempty"`
|
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
|
// Update updates some properties of the compute
|
||||||
|
|||||||
40
pkg/cloudapi/compute/update_acl_access.go
Normal file
40
pkg/cloudapi/compute/update_acl_access.go
Normal 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
|
||||||
|
}
|
||||||
@@ -28,6 +28,8 @@ type UserGrantRequest struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// UserGrant grants user access to the compute
|
// 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) {
|
func (c Compute) UserGrant(ctx context.Context, req UserGrantRequest) (bool, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -16,6 +16,8 @@ type UserListRequest struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// UserList gets users list for compute
|
// 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) {
|
func (c Compute) UserList(ctx context.Context, req UserListRequest) (*ListUsers, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -20,6 +20,8 @@ type UserRevokeRequest struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// UserRevoke revokes user access to the compute
|
// 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) {
|
func (c Compute) UserRevoke(ctx context.Context, req UserRevokeRequest) (bool, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -28,6 +28,8 @@ type UserUpdateRequest struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// UserUpdate updates user access to the compute
|
// 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) {
|
func (c Compute) UserUpdate(ctx context.Context, req UserUpdateRequest) (bool, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package disks
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"encoding/json"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
@@ -19,6 +20,12 @@ type ChangeDiskStoragePolicyRequest struct {
|
|||||||
StoragePolicyID uint64 `url:"storage_policy_id" json:"storage_policy_id" validate:"required"`
|
StoragePolicyID uint64 `url:"storage_policy_id" json:"storage_policy_id" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type wrapperChangeDiskStoragePolicyRequest struct {
|
||||||
|
ChangeDiskStoragePolicyRequest
|
||||||
|
|
||||||
|
AsyncMode bool `url:"async_mode" json:"async_mode"`
|
||||||
|
}
|
||||||
|
|
||||||
// ChangeDiskStoragePolicy changes storage policy for disk
|
// ChangeDiskStoragePolicy changes storage policy for disk
|
||||||
func (d Disks) ChangeDiskStoragePolicy(ctx context.Context, req ChangeDiskStoragePolicyRequest) (bool, error) {
|
func (d Disks) ChangeDiskStoragePolicy(ctx context.Context, req ChangeDiskStoragePolicyRequest) (bool, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
@@ -28,7 +35,12 @@ func (d Disks) ChangeDiskStoragePolicy(ctx context.Context, req ChangeDiskStorag
|
|||||||
|
|
||||||
url := "/cloudapi/disks/change_disk_storage_policy"
|
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 {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
@@ -40,3 +52,30 @@ func (d Disks) ChangeDiskStoragePolicy(ctx context.Context, req ChangeDiskStorag
|
|||||||
|
|
||||||
return result, nil
|
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
|
||||||
|
}
|
||||||
|
|||||||
@@ -39,7 +39,13 @@ type CreateRequest struct {
|
|||||||
Pool string `url:"pool,omitempty" json:"pool,omitempty"`
|
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) {
|
func (d Disks) Create(ctx context.Context, req CreateRequest) (uint64, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -48,7 +54,12 @@ func (d Disks) Create(ctx context.Context, req CreateRequest) (uint64, error) {
|
|||||||
|
|
||||||
url := "/cloudapi/disks/create"
|
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 {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
@@ -60,3 +71,25 @@ func (d Disks) Create(ctx context.Context, req CreateRequest) (uint64, error) {
|
|||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Create creates a disk in async mode
|
||||||
|
func (d Disks) CreateAsync(ctx context.Context, req CreateRequest) (string, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudapi/disks/create"
|
||||||
|
|
||||||
|
wrappedReq := wrapperCreateRequest{
|
||||||
|
CreateRequest: req,
|
||||||
|
AsyncMode: true,
|
||||||
|
}
|
||||||
|
|
||||||
|
res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, wrappedReq)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
|
||||||
|
return string(res), nil
|
||||||
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package disks
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"encoding/json"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
@@ -23,6 +24,12 @@ type DeleteRequest struct {
|
|||||||
Permanently bool `url:"permanently,omitempty" json:"permanently,omitempty"`
|
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
|
// Delete deletes disk by ID
|
||||||
func (d Disks) Delete(ctx context.Context, req DeleteRequest) (bool, error) {
|
func (d Disks) Delete(ctx context.Context, req DeleteRequest) (bool, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
@@ -32,7 +39,12 @@ func (d Disks) Delete(ctx context.Context, req DeleteRequest) (bool, error) {
|
|||||||
|
|
||||||
url := "/cloudapi/disks/delete"
|
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 {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
@@ -44,3 +56,30 @@ func (d Disks) Delete(ctx context.Context, req DeleteRequest) (bool, error) {
|
|||||||
|
|
||||||
return result, nil
|
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
|
||||||
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package disks
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"encoding/json"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
@@ -19,6 +20,12 @@ type DisksDeleteRequest struct {
|
|||||||
Permanently bool `url:"permanently,omitempty" json:"permanently,omitempty"`
|
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
|
// DeleteDisks deletes multiple disks permanently
|
||||||
func (d Disks) DeleteDisks(ctx context.Context, req DisksDeleteRequest) (bool, error) {
|
func (d Disks) DeleteDisks(ctx context.Context, req DisksDeleteRequest) (bool, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
@@ -28,7 +35,12 @@ func (d Disks) DeleteDisks(ctx context.Context, req DisksDeleteRequest) (bool, e
|
|||||||
|
|
||||||
url := "/cloudapi/disks/deleteDisks"
|
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 {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
@@ -40,3 +52,30 @@ func (d Disks) DeleteDisks(ctx context.Context, req DisksDeleteRequest) (bool, e
|
|||||||
|
|
||||||
return result, nil
|
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
|
||||||
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package disks
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"encoding/json"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
@@ -71,6 +72,12 @@ type LimitIORequest struct {
|
|||||||
SizeIOPSSec uint64 `url:"size_iops_sec,omitempty" json:"size_iops_sec,omitempty"`
|
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
|
// LimitIO limit IO for a certain disk
|
||||||
// total and read/write options are not allowed to be combined
|
// total and read/write options are not allowed to be combined
|
||||||
// see http://libvirt.org/formatdomain.html#elementsDisks iotune section for more details
|
// 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"
|
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 {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
@@ -94,3 +106,32 @@ func (d Disks) LimitIO(ctx context.Context, req LimitIORequest) (bool, error) {
|
|||||||
|
|
||||||
return result, nil
|
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
|
||||||
|
}
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ type ListRequest struct {
|
|||||||
|
|
||||||
// Find by status
|
// Find by status
|
||||||
// Required: false
|
// Required: false
|
||||||
Status string `url:"status,omitempty" json:"status,omitempty"`
|
Status []string `url:"status,omitempty" json:"status,omitempty"`
|
||||||
|
|
||||||
// Find by shared, true or false
|
// Find by shared, true or false
|
||||||
// Required: false
|
// Required: false
|
||||||
|
|||||||
@@ -331,6 +331,10 @@ type ItemSnapshot struct {
|
|||||||
// Label
|
// Label
|
||||||
Label string `json:"label"`
|
Label string `json:"label"`
|
||||||
|
|
||||||
|
// Pool name
|
||||||
|
PoolName string `json:"poolName"`
|
||||||
|
|
||||||
|
// Reference ID
|
||||||
ReferenceID string `json:"referenceId"`
|
ReferenceID string `json:"referenceId"`
|
||||||
|
|
||||||
// Resource ID
|
// Resource ID
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package disks
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"encoding/json"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
@@ -19,6 +20,12 @@ type RenameRequest struct {
|
|||||||
Name string `url:"name" json:"name" validate:"required"`
|
Name string `url:"name" json:"name" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type wrapperRenameRequest struct {
|
||||||
|
RenameRequest
|
||||||
|
|
||||||
|
AsyncMode bool `url:"async_mode" json:"async_mode"`
|
||||||
|
}
|
||||||
|
|
||||||
// Rename renames disk
|
// Rename renames disk
|
||||||
func (d Disks) Rename(ctx context.Context, req RenameRequest) (bool, error) {
|
func (d Disks) Rename(ctx context.Context, req RenameRequest) (bool, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
@@ -28,7 +35,12 @@ func (d Disks) Rename(ctx context.Context, req RenameRequest) (bool, error) {
|
|||||||
|
|
||||||
url := "/cloudapi/disks/rename"
|
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 {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
@@ -40,3 +52,30 @@ func (d Disks) Rename(ctx context.Context, req RenameRequest) (bool, error) {
|
|||||||
|
|
||||||
return result, nil
|
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
|
||||||
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package disks
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"encoding/json"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
@@ -31,6 +32,12 @@ type ReplicateRequest struct {
|
|||||||
StoragePolicyID uint64 `url:"storage_policy_id" json:"storage_policy_id" validate:"required"`
|
StoragePolicyID uint64 `url:"storage_policy_id" json:"storage_policy_id" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type wrapperReplicateRequest struct {
|
||||||
|
ReplicateRequest
|
||||||
|
|
||||||
|
AsyncMode bool `url:"async_mode" json:"async_mode"`
|
||||||
|
}
|
||||||
|
|
||||||
// Replicate create an empty disk in chosen SEP and pool combination.
|
// Replicate create an empty disk in chosen SEP and pool combination.
|
||||||
// Starts replication between chosen disk and newly created disk
|
// Starts replication between chosen disk and newly created disk
|
||||||
// Note: only TATLIN type SEP are supported for replications between
|
// 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"
|
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 {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
@@ -54,3 +66,32 @@ func (d Disks) Replicate(ctx context.Context, req ReplicateRequest) (uint64, err
|
|||||||
|
|
||||||
return result, nil
|
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
|
||||||
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package disks
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"encoding/json"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
@@ -15,6 +16,12 @@ type ReplicationResumeRequest struct {
|
|||||||
DiskID uint64 `url:"diskId" json:"diskId" validate:"required"`
|
DiskID uint64 `url:"diskId" json:"diskId" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type wrapperReplicationResumeRequest struct {
|
||||||
|
ReplicationResumeRequest
|
||||||
|
|
||||||
|
AsyncMode bool `url:"async_mode" json:"async_mode"`
|
||||||
|
}
|
||||||
|
|
||||||
// ReplicationResume resume suspended replication
|
// ReplicationResume resume suspended replication
|
||||||
func (d Disks) ReplicationResume(ctx context.Context, req ReplicationResumeRequest) (bool, error) {
|
func (d Disks) ReplicationResume(ctx context.Context, req ReplicationResumeRequest) (bool, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
@@ -24,7 +31,12 @@ func (d Disks) ReplicationResume(ctx context.Context, req ReplicationResumeReque
|
|||||||
|
|
||||||
url := "/cloudapi/disks/replicationResume"
|
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 {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
@@ -36,3 +48,30 @@ func (d Disks) ReplicationResume(ctx context.Context, req ReplicationResumeReque
|
|||||||
|
|
||||||
return result, nil
|
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
|
||||||
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package disks
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"encoding/json"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
@@ -15,6 +16,12 @@ type ReplicationReverseRequest struct {
|
|||||||
DiskID uint64 `url:"diskId" json:"diskId" validate:"required"`
|
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
|
// ReplicationReverse change role between disks replications
|
||||||
func (d Disks) ReplicationReverse(ctx context.Context, req ReplicationReverseRequest) (bool, error) {
|
func (d Disks) ReplicationReverse(ctx context.Context, req ReplicationReverseRequest) (bool, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
@@ -24,7 +31,12 @@ func (d Disks) ReplicationReverse(ctx context.Context, req ReplicationReverseReq
|
|||||||
|
|
||||||
url := "/cloudapi/disks/replicationReverse"
|
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 {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
@@ -36,3 +48,30 @@ func (d Disks) ReplicationReverse(ctx context.Context, req ReplicationReverseReq
|
|||||||
|
|
||||||
return result, nil
|
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
|
||||||
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package disks
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"encoding/json"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
@@ -19,6 +20,12 @@ type ReplicationStartRequest struct {
|
|||||||
TargetDiskID uint64 `url:"targetDiskId" json:"targetDiskId" validate:"required"`
|
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
|
// 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.
|
// Note: Source disk's SEP and target SEP supported only of TATLIN type.
|
||||||
func (d Disks) ReplicationStart(ctx context.Context, req ReplicationStartRequest) (bool, error) {
|
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"
|
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 {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
@@ -41,3 +53,31 @@ func (d Disks) ReplicationStart(ctx context.Context, req ReplicationStartRequest
|
|||||||
|
|
||||||
return result, nil
|
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
|
||||||
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package disks
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"encoding/json"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
@@ -15,6 +16,12 @@ type ReplicationStopRequest struct {
|
|||||||
DiskID uint64 `url:"diskId" json:"diskId" validate:"required"`
|
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
|
// ReplicationStop remove replication between disks completely
|
||||||
func (d Disks) ReplicationStop(ctx context.Context, req ReplicationStopRequest) (bool, error) {
|
func (d Disks) ReplicationStop(ctx context.Context, req ReplicationStopRequest) (bool, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
@@ -24,7 +31,12 @@ func (d Disks) ReplicationStop(ctx context.Context, req ReplicationStopRequest)
|
|||||||
|
|
||||||
url := "/cloudapi/disks/replicationStop"
|
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 {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
@@ -36,3 +48,30 @@ func (d Disks) ReplicationStop(ctx context.Context, req ReplicationStopRequest)
|
|||||||
|
|
||||||
return result, nil
|
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
|
||||||
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package disks
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"encoding/json"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
@@ -15,6 +16,12 @@ type ReplicationSuspendRequest struct {
|
|||||||
DiskID uint64 `url:"diskId" json:"diskId" validate:"required"`
|
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
|
// ReplicationSuspend pause replication with possibility to resume from pause moment
|
||||||
func (d Disks) ReplicationSuspend(ctx context.Context, req ReplicationSuspendRequest) (bool, error) {
|
func (d Disks) ReplicationSuspend(ctx context.Context, req ReplicationSuspendRequest) (bool, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
@@ -24,7 +31,12 @@ func (d Disks) ReplicationSuspend(ctx context.Context, req ReplicationSuspendReq
|
|||||||
|
|
||||||
url := "/cloudapi/disks/replicationSuspend"
|
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 {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
@@ -36,3 +48,30 @@ func (d Disks) ReplicationSuspend(ctx context.Context, req ReplicationSuspendReq
|
|||||||
|
|
||||||
return result, nil
|
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
|
||||||
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package disks
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"encoding/json"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
@@ -19,6 +20,12 @@ type ResizeRequest struct {
|
|||||||
Size uint64 `url:"size" json:"size" validate:"required"`
|
Size uint64 `url:"size" json:"size" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type wrapperResizeRequest struct {
|
||||||
|
ResizeRequest
|
||||||
|
|
||||||
|
AsyncMode bool `url:"async_mode" json:"async_mode"`
|
||||||
|
}
|
||||||
|
|
||||||
// Resize2 resize disk
|
// Resize2 resize disk
|
||||||
// Returns 200 if disk is resized online, else will return 202,
|
// 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.
|
// 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"
|
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 {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
@@ -43,3 +55,33 @@ func (d Disks) Resize2(ctx context.Context, req ResizeRequest) (bool, error) {
|
|||||||
|
|
||||||
return result, nil
|
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
|
||||||
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package disks
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"encoding/json"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
@@ -15,6 +16,12 @@ type RestoreRequest struct {
|
|||||||
DiskID uint64 `url:"diskId" json:"diskId" validate:"required"`
|
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
|
// Restore restores a deleted unattached disk from recycle bin
|
||||||
func (d Disks) Restore(ctx context.Context, req RestoreRequest) (bool, error) {
|
func (d Disks) Restore(ctx context.Context, req RestoreRequest) (bool, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
@@ -24,7 +31,12 @@ func (d Disks) Restore(ctx context.Context, req RestoreRequest) (bool, error) {
|
|||||||
|
|
||||||
url := "/cloudapi/disks/restore"
|
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 {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
@@ -36,3 +48,30 @@ func (d Disks) Restore(ctx context.Context, req RestoreRequest) (bool, error) {
|
|||||||
|
|
||||||
return result, nil
|
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
|
||||||
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package disks
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"encoding/json"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
@@ -15,6 +16,12 @@ type ShareRequest struct {
|
|||||||
DiskID uint64 `url:"diskId" json:"diskId" validate:"required"`
|
DiskID uint64 `url:"diskId" json:"diskId" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type wrapperShareRequest struct {
|
||||||
|
ShareRequest
|
||||||
|
|
||||||
|
AsyncMode bool `url:"async_mode" json:"async_mode"`
|
||||||
|
}
|
||||||
|
|
||||||
// Share shares data disk
|
// Share shares data disk
|
||||||
func (d Disks) Share(ctx context.Context, req ShareRequest) (bool, error) {
|
func (d Disks) Share(ctx context.Context, req ShareRequest) (bool, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
@@ -24,7 +31,12 @@ func (d Disks) Share(ctx context.Context, req ShareRequest) (bool, error) {
|
|||||||
|
|
||||||
url := "/cloudapi/disks/share"
|
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 {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
@@ -36,3 +48,30 @@ func (d Disks) Share(ctx context.Context, req ShareRequest) (bool, error) {
|
|||||||
|
|
||||||
return result, nil
|
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
|
||||||
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package disks
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"encoding/json"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
@@ -19,6 +20,12 @@ type SnapshotDeleteRequest struct {
|
|||||||
Label string `url:"label" json:"label" validate:"required"`
|
Label string `url:"label" json:"label" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type wrapperSnapshotDeleteRequest struct {
|
||||||
|
SnapshotDeleteRequest
|
||||||
|
|
||||||
|
AsyncMode bool `url:"async_mode" json:"async_mode"`
|
||||||
|
}
|
||||||
|
|
||||||
// SnapshotDelete deletes a snapshot
|
// SnapshotDelete deletes a snapshot
|
||||||
func (d Disks) SnapshotDelete(ctx context.Context, req SnapshotDeleteRequest) (bool, error) {
|
func (d Disks) SnapshotDelete(ctx context.Context, req SnapshotDeleteRequest) (bool, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
@@ -28,7 +35,12 @@ func (d Disks) SnapshotDelete(ctx context.Context, req SnapshotDeleteRequest) (b
|
|||||||
|
|
||||||
url := "/cloudapi/disks/snapshotDelete"
|
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 {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
@@ -40,3 +52,30 @@ func (d Disks) SnapshotDelete(ctx context.Context, req SnapshotDeleteRequest) (b
|
|||||||
|
|
||||||
return result, nil
|
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
|
||||||
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package disks
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"encoding/json"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
@@ -23,6 +24,12 @@ type SnapshotRollbackRequest struct {
|
|||||||
TimeStamp uint64 `url:"timestamp,omitempty" json:"timestamp,omitempty"`
|
TimeStamp uint64 `url:"timestamp,omitempty" json:"timestamp,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type wrapperSnapshotRollbackRequest struct {
|
||||||
|
SnapshotRollbackRequest
|
||||||
|
|
||||||
|
AsyncMode bool `url:"async_mode" json:"async_mode"`
|
||||||
|
}
|
||||||
|
|
||||||
// SnapshotRollback rollbacks an individual disk snapshot
|
// SnapshotRollback rollbacks an individual disk snapshot
|
||||||
func (d Disks) SnapshotRollback(ctx context.Context, req SnapshotRollbackRequest) (bool, error) {
|
func (d Disks) SnapshotRollback(ctx context.Context, req SnapshotRollbackRequest) (bool, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
@@ -32,7 +39,12 @@ func (d Disks) SnapshotRollback(ctx context.Context, req SnapshotRollbackRequest
|
|||||||
|
|
||||||
url := "/cloudapi/disks/snapshotRollback"
|
url := "/cloudapi/disks/snapshotRollback"
|
||||||
|
|
||||||
res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
wrappedReq := wrapperSnapshotRollbackRequest{
|
||||||
|
SnapshotRollbackRequest: req,
|
||||||
|
AsyncMode: false,
|
||||||
|
}
|
||||||
|
|
||||||
|
res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, wrappedReq)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
@@ -43,5 +55,31 @@ func (d Disks) SnapshotRollback(ctx context.Context, req SnapshotRollbackRequest
|
|||||||
}
|
}
|
||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// SnapshotRollbackAsync rollbacks an individual disk snapshot in async mode
|
||||||
|
func (d Disks) SnapshotRollbackAsync(ctx context.Context, req SnapshotRollbackRequest) (string, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudapi/disks/snapshotRollback"
|
||||||
|
|
||||||
|
wrappedReq := wrapperSnapshotRollbackRequest{
|
||||||
|
SnapshotRollbackRequest: req,
|
||||||
|
AsyncMode: true,
|
||||||
|
}
|
||||||
|
|
||||||
|
res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, wrappedReq)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
|
||||||
|
var result string
|
||||||
|
if err := json.Unmarshal(res, &result); err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
|
||||||
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package disks
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"encoding/json"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
@@ -15,6 +16,12 @@ type UnshareRequest struct {
|
|||||||
DiskID uint64 `url:"diskId" json:"diskId" validate:"required"`
|
DiskID uint64 `url:"diskId" json:"diskId" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type wrapperUnshareRequest struct {
|
||||||
|
UnshareRequest
|
||||||
|
|
||||||
|
AsyncMode bool `url:"async_mode" json:"async_mode"`
|
||||||
|
}
|
||||||
|
|
||||||
// Unshare unshares data disk
|
// Unshare unshares data disk
|
||||||
func (d Disks) Unshare(ctx context.Context, req UnshareRequest) (bool, error) {
|
func (d Disks) Unshare(ctx context.Context, req UnshareRequest) (bool, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
@@ -24,7 +31,12 @@ func (d Disks) Unshare(ctx context.Context, req UnshareRequest) (bool, error) {
|
|||||||
|
|
||||||
url := "/cloudapi/disks/unshare"
|
url := "/cloudapi/disks/unshare"
|
||||||
|
|
||||||
res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
wrappedReq := wrapperUnshareRequest{
|
||||||
|
UnshareRequest: req,
|
||||||
|
AsyncMode: false,
|
||||||
|
}
|
||||||
|
|
||||||
|
res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, wrappedReq)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
@@ -36,3 +48,30 @@ func (d Disks) Unshare(ctx context.Context, req UnshareRequest) (bool, error) {
|
|||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// UnshareAsync unshares data disk in async mode
|
||||||
|
func (d Disks) UnshareAsync(ctx context.Context, req UnshareRequest) (string, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudapi/disks/unshare"
|
||||||
|
|
||||||
|
wrappedReq := wrapperUnshareRequest{
|
||||||
|
UnshareRequest: req,
|
||||||
|
AsyncMode: true,
|
||||||
|
}
|
||||||
|
|
||||||
|
res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, wrappedReq)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
|
||||||
|
var result string
|
||||||
|
if err := json.Unmarshal(res, &result); err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
|
|||||||
@@ -17,6 +17,11 @@ type GetReservedIP struct {
|
|||||||
// Field for specifying the ID of extnet whose reservation information we want to receive
|
// Field for specifying the ID of extnet whose reservation information we want to receive
|
||||||
// Required: false
|
// Required: false
|
||||||
ExtNetID uint64 `url:"extnetId,omitempty" json:"extnetId,omitempty"`
|
ExtNetID uint64 `url:"extnetId,omitempty" json:"extnetId,omitempty"`
|
||||||
|
|
||||||
|
// Flag indicating whether the reserved IP can be auto-assigned
|
||||||
|
// Required: false
|
||||||
|
// Default: null
|
||||||
|
AutoAssignable interface{} `url:"auto_assignable,omitempty" json:"auto_assignable,omitempty" validate:"omitempty,isBool"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetReservedIP gets information about reserved address or address poll as a slice of RecordReservedIP struct
|
// GetReservedIP gets information about reserved address or address poll as a slice of RecordReservedIP struct
|
||||||
|
|||||||
@@ -269,12 +269,13 @@ type RecordReservedIP struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type Reservations struct {
|
type Reservations struct {
|
||||||
AccountID int `json:"account_id"`
|
AccountID int `json:"account_id"`
|
||||||
ClientType string `json:"clientType"`
|
ClientType string `json:"clientType"`
|
||||||
DomainName string `json:"domainname"`
|
DomainName string `json:"domainname"`
|
||||||
Hostname string `json:"hostname"`
|
Hostname string `json:"hostname"`
|
||||||
IP string `json:"ip"`
|
IP string `json:"ip"`
|
||||||
Mac string `json:"mac"`
|
Mac string `json:"mac"`
|
||||||
Type string `json:"type"`
|
Type string `json:"type"`
|
||||||
VMID int `json:"vmId"`
|
VMID int `json:"vmId"`
|
||||||
|
AutoAssignable bool `json:"auto_assignable"`
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -157,7 +157,7 @@ type CreateRequest struct {
|
|||||||
|
|
||||||
// Meta data for working group computes, format YAML "user_data": 1111
|
// Meta data for working group computes, format YAML "user_data": 1111
|
||||||
// Required: false
|
// Required: false
|
||||||
UserData string `url:"userData,omitempty" json:"userData,omitempty"`
|
UserData interface{} `url:"userData,omitempty" json:"userData,omitempty"`
|
||||||
|
|
||||||
// Use only selected ExtNet for infrastructure connections
|
// Use only selected ExtNet for infrastructure connections
|
||||||
// Required: false
|
// Required: false
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ type UpdateWorkerNodesMetaDataRequest struct {
|
|||||||
|
|
||||||
// Meta data for working group computes, format YAML "user_data": 1111
|
// Meta data for working group computes, format YAML "user_data": 1111
|
||||||
// Required: true
|
// Required: true
|
||||||
UserData string `url:"userData" json:"userData" validate:"required"`
|
UserData interface{} `url:"userData" json:"userData" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// UpdateWorkerNodesMetaData adds worker nodes to a kubernetes cluster
|
// UpdateWorkerNodesMetaData adds worker nodes to a kubernetes cluster
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package kvmx86
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"encoding/json"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
@@ -76,6 +77,15 @@ type Interface struct {
|
|||||||
// Flag indicating whether this interface is enabled (only for VINS, EXTNET, DPDK, SDN, TRUNK)
|
// Flag indicating whether this interface is enabled (only for VINS, EXTNET, DPDK, SDN, TRUNK)
|
||||||
// Required: false
|
// Required: false
|
||||||
Enabled interface{} `url:"enabled,omitempty" json:"enabled,omitempty" validate:"omitempty,isBool"`
|
Enabled interface{} `url:"enabled,omitempty" json:"enabled,omitempty" validate:"omitempty,isBool"`
|
||||||
|
|
||||||
|
// Flag indicating whether default gateway are enabled for this interface, not applicable to netType EXTNET, VFNIC, TRUNK, or SDN
|
||||||
|
// Default: true
|
||||||
|
// Required: false
|
||||||
|
EnableDefaultGateway interface{} `url:"enable_default_gateway,omitempty" json:"enable_default_gateway,omitempty" validate:"omitempty,isBool"`
|
||||||
|
|
||||||
|
// List of QoS Policy IDs to apply to this interface (default: []), Allow used only with netType VINS, EXTNET and DPDK
|
||||||
|
// Required: false
|
||||||
|
QoSPolicies []uint64 `url:"qos_policies,omitempty" json:"qos_policies,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// DataDisk detailed struct for DataDisks field in CreateRequest and CreateBlankRequest
|
// DataDisk detailed struct for DataDisks field in CreateRequest and CreateBlankRequest
|
||||||
@@ -109,6 +119,11 @@ type DataDisk struct {
|
|||||||
// Specify image id for create disk from template
|
// Specify image id for create disk from template
|
||||||
// Required: false
|
// Required: false
|
||||||
ImageID uint64 `url:"imageId,omitempty" json:"imageId,omitempty"`
|
ImageID uint64 `url:"imageId,omitempty" json:"imageId,omitempty"`
|
||||||
|
|
||||||
|
// Attach disk in read-only mode
|
||||||
|
// Required: false
|
||||||
|
// Default: false
|
||||||
|
ReadOnly bool `url:"read_only,omitempty" json:"read_only,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreateRequest struct to create KVM x86 VM
|
// CreateRequest struct to create KVM x86 VM
|
||||||
@@ -194,12 +209,12 @@ type CreateRequest struct {
|
|||||||
// loose (use NUMA affinity if possible)
|
// loose (use NUMA affinity if possible)
|
||||||
// Required: false
|
// Required: false
|
||||||
// Default: none
|
// Default: none
|
||||||
NumaAffinity string `url:"numaAffinity,omitempty" json:"numaAffinity,omitempty" validate:"omitempty,numaAffinity"`
|
NumaAffinity string `url:"numa_affinity,omitempty" json:"numa_affinity,omitempty" validate:"omitempty,numaAffinity"`
|
||||||
|
|
||||||
// Run VM on dedicated CPUs. To use this feature, the system must be pre-configured by allocating CPUs on the physical node
|
// Run VM on dedicated CPUs. To use this feature, the system must be pre-configured by allocating CPUs on the physical node
|
||||||
// Required: false
|
// Required: false
|
||||||
// Default: false
|
// Default: false
|
||||||
CPUPin bool `url:"cpupin" json:"cpupin"`
|
CPUPin bool `url:"cpu_pin" json:"cpu_pin"`
|
||||||
|
|
||||||
// Type of the emulated system, Q35 or i440fx
|
// Type of the emulated system, Q35 or i440fx
|
||||||
// Required: false
|
// Required: false
|
||||||
@@ -209,7 +224,7 @@ type CreateRequest struct {
|
|||||||
// Use Huge Pages to allocate RAM of the virtual machine. The system must be pre-configured by allocating Huge Pages on the physical node
|
// Use Huge Pages to allocate RAM of the virtual machine. The system must be pre-configured by allocating Huge Pages on the physical node
|
||||||
// Required: false
|
// Required: false
|
||||||
// Default: false
|
// Default: false
|
||||||
HPBacked bool `url:"hpBacked" json:"hpBacked"`
|
HPBacked bool `url:"hp_backed" json:"hp_backed"`
|
||||||
|
|
||||||
// Recommended isolated CPUs. Field is ignored if compute.cpupin=False or compute.pinned=False
|
// Recommended isolated CPUs. Field is ignored if compute.cpupin=False or compute.pinned=False
|
||||||
// Required: false
|
// Required: false
|
||||||
@@ -227,6 +242,16 @@ type CreateRequest struct {
|
|||||||
// Required: false
|
// Required: false
|
||||||
// Default: default
|
// Default: default
|
||||||
Clock string `url:"clock,omitempty" json:"clock,omitempty"`
|
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"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetRAM returns RAM field values
|
// GetRAM returns RAM field values
|
||||||
@@ -238,6 +263,11 @@ func (r CreateRequest) GetRAM() map[string]uint64 {
|
|||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type wrapperCreateRequest struct {
|
||||||
|
CreateRequest
|
||||||
|
AsyncMode bool `json:"asyncMode"`
|
||||||
|
}
|
||||||
|
|
||||||
// Create creates KVM x86 VM based on specified OS image
|
// Create creates KVM x86 VM based on specified OS image
|
||||||
func (k KVMX86) Create(ctx context.Context, req CreateRequest) (uint64, error) {
|
func (k KVMX86) Create(ctx context.Context, req CreateRequest) (uint64, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
@@ -247,10 +277,40 @@ func (k KVMX86) Create(ctx context.Context, req CreateRequest) (uint64, error) {
|
|||||||
|
|
||||||
url := "/cloudapi/kvmx86/create"
|
url := "/cloudapi/kvmx86/create"
|
||||||
|
|
||||||
res, err := k.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
|
res, err := k.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, wrapperCreateRequest{
|
||||||
|
CreateRequest: req,
|
||||||
|
AsyncMode: false,
|
||||||
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return strconv.ParseUint(string(res), 10, 64)
|
return strconv.ParseUint(string(res), 10, 64)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CreateAsync creates KVM x86 VM based on specified OS image in async mode
|
||||||
|
func (k KVMX86) CreateAsync(ctx context.Context, req CreateRequest) (string, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudapi/kvmx86/create"
|
||||||
|
|
||||||
|
res, err := k.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, wrapperCreateRequest{
|
||||||
|
CreateRequest: req,
|
||||||
|
AsyncMode: true,
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
|
||||||
|
var taskID string
|
||||||
|
|
||||||
|
err = json.Unmarshal(res, &taskID)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
|
||||||
|
return taskID, nil
|
||||||
|
}
|
||||||
|
|||||||
@@ -124,6 +124,16 @@ type CreateBlankRequest struct {
|
|||||||
// Required: false
|
// Required: false
|
||||||
// Default: default
|
// Default: default
|
||||||
Clock string `url:"clock,omitempty" json:"clock,omitempty"`
|
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"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetRAM returns RAM field values
|
// GetRAM returns RAM field values
|
||||||
|
|||||||
@@ -5,6 +5,9 @@ type ItemLocation struct {
|
|||||||
// AuthBroker
|
// AuthBroker
|
||||||
AuthBroker []string `json:"authBroker"`
|
AuthBroker []string `json:"authBroker"`
|
||||||
|
|
||||||
|
// Budget
|
||||||
|
Budget bool `json:"budget"`
|
||||||
|
|
||||||
// Grid ID
|
// Grid ID
|
||||||
GID uint64 `json:"gid"`
|
GID uint64 `json:"gid"`
|
||||||
|
|
||||||
|
|||||||
10
pkg/cloudapi/network_qos_policy.go
Normal file
10
pkg/cloudapi/network_qos_policy.go
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
package cloudapi
|
||||||
|
|
||||||
|
import (
|
||||||
|
qospolicy "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/qospolicy"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Accessing the QoS Policy method group
|
||||||
|
func (ca *CloudAPI) QoSPolicy() *qospolicy.QoSPolicy {
|
||||||
|
return qospolicy.New(ca.client)
|
||||||
|
}
|
||||||
@@ -22,9 +22,9 @@ type ListRequest struct {
|
|||||||
// Required: false
|
// Required: false
|
||||||
Name string `url:"name,omitempty" json:"name,omitempty"`
|
Name string `url:"name,omitempty" json:"name,omitempty"`
|
||||||
|
|
||||||
// Find by rgId
|
// Find by account ID
|
||||||
// Required: false
|
// Required: false
|
||||||
RGID uint64 `url:"rgId,omitempty" json:"rgId,omitempty"`
|
AccountID uint64 `url:"account_id,omitempty" json:"account_id,omitempty"`
|
||||||
|
|
||||||
// Find by status
|
// Find by status
|
||||||
// Required: false
|
// Required: false
|
||||||
|
|||||||
@@ -26,8 +26,8 @@ type ItemPCIDevice struct {
|
|||||||
// Name
|
// Name
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
|
|
||||||
// Resource group ID
|
// Account IDs
|
||||||
RGID uint64 `json:"rgId"`
|
AccountIDs []uint64 `json:"account_ids"`
|
||||||
|
|
||||||
// Node ID
|
// Node ID
|
||||||
NodeID uint64 `json:"nodeId"`
|
NodeID uint64 `json:"nodeId"`
|
||||||
|
|||||||
46
pkg/cloudapi/qospolicy/create.go
Normal file
46
pkg/cloudapi/qospolicy/create.go
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
package qospolicy
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"net/http"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants"
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
|
)
|
||||||
|
|
||||||
|
type CreateRequest struct {
|
||||||
|
// Account ID that owns QoS policy
|
||||||
|
// Required: true
|
||||||
|
AccountID uint64 `url:"account_id" json:"account_id" validate:"required"`
|
||||||
|
|
||||||
|
// QoS policy name
|
||||||
|
// Required: true
|
||||||
|
Name string `url:"name" json:"name" validate:"required"`
|
||||||
|
|
||||||
|
// QoS policy description
|
||||||
|
// Required: false
|
||||||
|
Description string `url:"description,omitempty" json:"description,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create creates a new QoS policy
|
||||||
|
func (qp QoSPolicy) Create(ctx context.Context, req CreateRequest) (uint64, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
return 0, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudapi/network_qos_policy/create"
|
||||||
|
|
||||||
|
res, err := qp.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err := strconv.ParseUint(string(res), 10, 64)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
93
pkg/cloudapi/qospolicy/create_rule.go
Normal file
93
pkg/cloudapi/qospolicy/create_rule.go
Normal file
@@ -0,0 +1,93 @@
|
|||||||
|
package qospolicy
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"net/http"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants"
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
|
)
|
||||||
|
|
||||||
|
type CreateRuleRequest struct {
|
||||||
|
// ID of the parent QoS policy this rule belongs to
|
||||||
|
// Required: true
|
||||||
|
QoSPolicyID uint64 `url:"qos_policy_id" json:"qos_policy_id" validate:"required"`
|
||||||
|
|
||||||
|
// QoS policy rule description
|
||||||
|
// Default: ""
|
||||||
|
// Required: false
|
||||||
|
Description string `url:"description,omitempty" json:"description,omitempty"`
|
||||||
|
|
||||||
|
// Rule priority in OVS (higher number = higher priority)
|
||||||
|
// Possible values: [0, 65535]
|
||||||
|
// Required: true
|
||||||
|
Priority *uint64 `url:"priority" json:"priority" validate:"required,min=0,max=65535"`
|
||||||
|
|
||||||
|
// Traffic direction
|
||||||
|
// Required: true
|
||||||
|
Direction string `url:"direction" json:"direction" validate:"required,oneof=outbound"`
|
||||||
|
|
||||||
|
// IP protocol to match
|
||||||
|
// Possible values: tcp, udp, icmp
|
||||||
|
// Required: true
|
||||||
|
Protocol string `url:"protocol" json:"protocol" validate:"required,oneof=tcp udp icmp"`
|
||||||
|
|
||||||
|
// Priority Code Point. L2 marking
|
||||||
|
// Possible values: [0, 7]
|
||||||
|
// Required: false
|
||||||
|
PCPTag *uint64 `url:"pcp_tag,omitempty" json:"pcp_tag,omitempty" validate:"required_without_all=DSCPValue,omitempty,min=0,max=7"`
|
||||||
|
|
||||||
|
// DSCP value (0-63). L3 marking
|
||||||
|
// Possible values: [0, 63]
|
||||||
|
// Required: false
|
||||||
|
DSCPValue *uint64 `url:"dscp_value,omitempty" json:"dscp_value,omitempty" validate:"required_without_all=PCPTag,omitempty,min=0,max=63"`
|
||||||
|
|
||||||
|
// Source IP address for traffic filtering
|
||||||
|
// Required: false
|
||||||
|
SrcIP string `url:"src_ip,omitempty" json:"src_ip,omitempty"`
|
||||||
|
|
||||||
|
// Destination IP address for traffic filtering
|
||||||
|
// Required: false
|
||||||
|
DstIP string `url:"dst_ip,omitempty" json:"dst_ip,omitempty"`
|
||||||
|
|
||||||
|
// Source MAC address for traffic filtering
|
||||||
|
// Required: false
|
||||||
|
SrcMAC string `url:"src_mac,omitempty" json:"src_mac,omitempty" validate:"omitempty,mac"`
|
||||||
|
|
||||||
|
// Destination MAC address for traffic filtering
|
||||||
|
// Required: false
|
||||||
|
DstMAC string `url:"dst_mac,omitempty" json:"dst_mac,omitempty" validate:"omitempty,mac"`
|
||||||
|
|
||||||
|
// Source port for traffic filtering (TCP/UDP only)
|
||||||
|
// Possible values: [1, 65535]
|
||||||
|
// Required: false
|
||||||
|
SrcPort uint64 `url:"src_port,omitempty" json:"src_port,omitempty" validate:"omitempty,min=1,max=65535"`
|
||||||
|
|
||||||
|
// Destination port for traffic filtering (TCP/UDP only)
|
||||||
|
// Possible values: [1, 65535]
|
||||||
|
// Required: false
|
||||||
|
DstPort uint64 `url:"dst_port,omitempty" json:"dst_port,omitempty" validate:"omitempty,min=1,max=65535"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateRule creates a new rule for a QoS policy
|
||||||
|
func (qp QoSPolicy) CreateRule(ctx context.Context, req CreateRuleRequest) (uint64, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
return 0, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudapi/network_qos_policy/create_rule"
|
||||||
|
|
||||||
|
res, err := qp.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err := strconv.ParseUint(string(res), 10, 64)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
37
pkg/cloudapi/qospolicy/delete.go
Normal file
37
pkg/cloudapi/qospolicy/delete.go
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
package qospolicy
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"net/http"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants"
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
|
)
|
||||||
|
|
||||||
|
type DeleteRequest struct {
|
||||||
|
// QoS policy ID
|
||||||
|
// Required: true
|
||||||
|
QoSPolicyID uint64 `url:"qos_policy_id" json:"qos_policy_id" validate:"required"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (qp QoSPolicy) Delete(ctx context.Context, req DeleteRequest) (bool, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudapi/network_qos_policy/delete"
|
||||||
|
|
||||||
|
res, err := qp.client.DecortApiCallCtype(ctx, http.MethodDelete, url, constants.MIMEJSON, req)
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err := strconv.ParseBool(string(res))
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
41
pkg/cloudapi/qospolicy/delete_rule.go
Normal file
41
pkg/cloudapi/qospolicy/delete_rule.go
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
package qospolicy
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"net/http"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants"
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
|
)
|
||||||
|
|
||||||
|
type DeleteRuleRequest struct {
|
||||||
|
// ID of the QoS policy
|
||||||
|
// Required: true
|
||||||
|
QoSPolicyID uint64 `url:"qos_policy_id" json:"qos_policy_id" validate:"required"`
|
||||||
|
|
||||||
|
// ID of the rule to delete
|
||||||
|
// Required: true
|
||||||
|
RuleID uint64 `url:"rule_id" json:"rule_id" validate:"required"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (qp QoSPolicy) DeleteRule(ctx context.Context, req DeleteRuleRequest) (bool, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudapi/network_qos_policy/delete_rule"
|
||||||
|
|
||||||
|
res, err := qp.client.DecortApiCallCtype(ctx, http.MethodDelete, url, constants.MIMEJSON, req)
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err := strconv.ParseBool(string(res))
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
71
pkg/cloudapi/qospolicy/filter.go
Normal file
71
pkg/cloudapi/qospolicy/filter.go
Normal file
@@ -0,0 +1,71 @@
|
|||||||
|
package qospolicy
|
||||||
|
|
||||||
|
// FilterByID returns ListQoSPolicies with specified ID
|
||||||
|
func (lqp ListQoSPolicies) FilterByID(id uint64) ListQoSPolicies {
|
||||||
|
predicate := func(iqp ItemQoSPolicy) bool {
|
||||||
|
return iqp.ID == id
|
||||||
|
}
|
||||||
|
|
||||||
|
return lqp.FilterFunc(predicate)
|
||||||
|
}
|
||||||
|
|
||||||
|
// FilterByName returns ListQoSPolicies with specified Name
|
||||||
|
func (lqp ListQoSPolicies) FilterByName(name string) ListQoSPolicies {
|
||||||
|
predicate := func(iqp ItemQoSPolicy) bool {
|
||||||
|
return iqp.Name == name
|
||||||
|
}
|
||||||
|
|
||||||
|
return lqp.FilterFunc(predicate)
|
||||||
|
}
|
||||||
|
|
||||||
|
// FilterByAccountID returns ListQoSPolicies with specified AccountID
|
||||||
|
func (lqp ListQoSPolicies) FilterByAccountID(accountID uint64) ListQoSPolicies {
|
||||||
|
predicate := func(iqp ItemQoSPolicy) bool {
|
||||||
|
return iqp.AccountID == accountID
|
||||||
|
}
|
||||||
|
|
||||||
|
return lqp.FilterFunc(predicate)
|
||||||
|
}
|
||||||
|
|
||||||
|
// FilterByStatus returns ListQoSPolicies with specified Status
|
||||||
|
func (lqp ListQoSPolicies) FilterByStatus(status string) ListQoSPolicies {
|
||||||
|
predicate := func(iqp ItemQoSPolicy) bool {
|
||||||
|
return iqp.Status == status
|
||||||
|
}
|
||||||
|
|
||||||
|
return lqp.FilterFunc(predicate)
|
||||||
|
}
|
||||||
|
|
||||||
|
// FilterByDescription returns ListQoSPolicies with specified Description
|
||||||
|
func (lqp ListQoSPolicies) FilterByDescription(description string) ListQoSPolicies {
|
||||||
|
predicate := func(iqp ItemQoSPolicy) bool {
|
||||||
|
return iqp.Description == description
|
||||||
|
}
|
||||||
|
|
||||||
|
return lqp.FilterFunc(predicate)
|
||||||
|
}
|
||||||
|
|
||||||
|
// FilterFunc allows filtering ListQoSPolicies based on a user-specified predicate
|
||||||
|
func (lqp ListQoSPolicies) FilterFunc(predicate func(ItemQoSPolicy) bool) ListQoSPolicies {
|
||||||
|
var result ListQoSPolicies
|
||||||
|
|
||||||
|
for _, item := range lqp.Data {
|
||||||
|
if predicate(item) {
|
||||||
|
result.Data = append(result.Data, item)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
result.EntryCount = uint64(len(result.Data))
|
||||||
|
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
|
// FindOne returns first found ListQoSPolicies
|
||||||
|
// If none was found, returns an empty struct
|
||||||
|
func (lqp ListQoSPolicies) FindOne() ItemQoSPolicy {
|
||||||
|
if len(lqp.Data) == 0 {
|
||||||
|
return ItemQoSPolicy{}
|
||||||
|
}
|
||||||
|
|
||||||
|
return lqp.Data[0]
|
||||||
|
}
|
||||||
72
pkg/cloudapi/qospolicy/filter_test.go
Normal file
72
pkg/cloudapi/qospolicy/filter_test.go
Normal file
@@ -0,0 +1,72 @@
|
|||||||
|
package qospolicy
|
||||||
|
|
||||||
|
import "testing"
|
||||||
|
|
||||||
|
var qosPolicies = ListQoSPolicies{
|
||||||
|
Data: []ItemQoSPolicy{
|
||||||
|
{
|
||||||
|
ID: 1,
|
||||||
|
AccountID: 1,
|
||||||
|
Name: "qos1",
|
||||||
|
Description: "some desc",
|
||||||
|
Status: "ENABLED",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ID: 3,
|
||||||
|
AccountID: 3,
|
||||||
|
Name: "qos3",
|
||||||
|
Description: "some desc",
|
||||||
|
Status: "ENABLED",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ID: 5,
|
||||||
|
AccountID: 3,
|
||||||
|
Name: "qos5",
|
||||||
|
Description: "some other desc",
|
||||||
|
Status: "DISABLED",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
EntryCount: 3,
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestFilterByID(t *testing.T) {
|
||||||
|
actual := qosPolicies.FilterByID(1).FindOne()
|
||||||
|
if actual.ID != 1 {
|
||||||
|
t.Fatal("expected ID 1, found: ", actual.ID)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestFilterByName(t *testing.T) {
|
||||||
|
actual := qosPolicies.FilterByName("qos3").FindOne()
|
||||||
|
if actual.Name != "qos3" {
|
||||||
|
t.Fatal("expected Name qos3, found: ", actual.Name)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestFilterByDescription(t *testing.T) {
|
||||||
|
actual := qosPolicies.FilterByDescription("some desc")
|
||||||
|
|
||||||
|
if len(actual.Data) != 2 {
|
||||||
|
t.Fatal("expected 2 found, actual: ", len(actual.Data))
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, item := range actual.Data {
|
||||||
|
if item.Description != "some desc" {
|
||||||
|
t.Fatal("expected Description 'some desc', found: ", item.Description)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestFilterByAccountID(t *testing.T) {
|
||||||
|
actual := qosPolicies.FilterByAccountID(1).FindOne()
|
||||||
|
if actual.AccountID != 1 {
|
||||||
|
t.Fatal("expected AccountID 1, found: ", actual.AccountID)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestFilterByStatus(t *testing.T) {
|
||||||
|
actual := qosPolicies.FilterByStatus("DISABLED").FindOne()
|
||||||
|
if actual.Status != "DISABLED" {
|
||||||
|
t.Fatal("expected Status DISABLED, found: ", actual.Status)
|
||||||
|
}
|
||||||
|
}
|
||||||
43
pkg/cloudapi/qospolicy/get.go
Normal file
43
pkg/cloudapi/qospolicy/get.go
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
package qospolicy
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"encoding/json"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
|
)
|
||||||
|
|
||||||
|
type GetRequest struct {
|
||||||
|
// QoS policy ID
|
||||||
|
// Required: true
|
||||||
|
QoSPolicyID uint64 `url:"qos_policy_id" json:"qos_policy_id" validate:"required"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (qp QoSPolicy) Get(ctx context.Context, req GetRequest) (*RecordQoSPolicy, error) {
|
||||||
|
res, err := qp.GetRaw(ctx, req)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
info := RecordQoSPolicy{}
|
||||||
|
|
||||||
|
err = json.Unmarshal(res, &info)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return &info, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (qp QoSPolicy) GetRaw(ctx context.Context, req GetRequest) ([]byte, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudapi/network_qos_policy/get"
|
||||||
|
|
||||||
|
res, err := qp.client.DecortApiCall(ctx, http.MethodGet, url, req)
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
89
pkg/cloudapi/qospolicy/list.go
Normal file
89
pkg/cloudapi/qospolicy/list.go
Normal file
@@ -0,0 +1,89 @@
|
|||||||
|
package qospolicy
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"encoding/json"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
|
)
|
||||||
|
|
||||||
|
type ListRequest struct {
|
||||||
|
// Page number
|
||||||
|
// Required: false
|
||||||
|
Page uint64 `url:"page,omitempty" json:"page,omitempty"`
|
||||||
|
|
||||||
|
// Page size
|
||||||
|
// Required: false
|
||||||
|
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
||||||
|
|
||||||
|
// Find QoS policy by id
|
||||||
|
// Required: false
|
||||||
|
ByID uint64 `url:"by_id,omitempty" json:"by_id,omitempty"`
|
||||||
|
|
||||||
|
// Find by account id
|
||||||
|
// Required: false
|
||||||
|
AccountID uint64 `url:"account_id,omitempty" json:"account_id,omitempty"`
|
||||||
|
|
||||||
|
// Find by QoS policy name
|
||||||
|
// Required: false
|
||||||
|
Name string `url:"name,omitempty" json:"name,omitempty"`
|
||||||
|
|
||||||
|
// Find by QoS policy description
|
||||||
|
// Required: false
|
||||||
|
Description string `url:"description,omitempty" json:"description,omitempty"`
|
||||||
|
|
||||||
|
// Find by QoS policy status
|
||||||
|
// Possible values: ENABLED, DISABLED, DESTROYED
|
||||||
|
// Required: false
|
||||||
|
Status string `url:"status,omitempty" json:"status,omitempty"`
|
||||||
|
|
||||||
|
// Find by created after time (unix timestamp)
|
||||||
|
// Required: false
|
||||||
|
CreatedMin uint64 `url:"created_min,omitempty" json:"created_min,omitempty"`
|
||||||
|
|
||||||
|
// Find by created before time (unix timestamp)
|
||||||
|
// Required: false
|
||||||
|
CreatedMax uint64 `url:"created_max,omitempty" json:"created_max,omitempty"`
|
||||||
|
|
||||||
|
// Find by updated after time (unix timestamp)
|
||||||
|
// Required: false
|
||||||
|
UpdatedMin uint64 `url:"updated_min,omitempty" json:"updated_min,omitempty"`
|
||||||
|
|
||||||
|
// Find by updated before time (unix timestamp)
|
||||||
|
// Required: false
|
||||||
|
UpdatedMax uint64 `url:"updated_max,omitempty" json:"updated_max,omitempty"`
|
||||||
|
|
||||||
|
// Sort by one of supported fields, format ±<field>
|
||||||
|
// Required: false
|
||||||
|
SortBy string `url:"sort_by,omitempty" json:"sort_by,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// List gets list of QoS policies as a ListQosPolicies struct
|
||||||
|
func (qp QoSPolicy) List(ctx context.Context, req ListRequest) (*ListQoSPolicies, error) {
|
||||||
|
res, err := qp.ListRaw(ctx, req)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
list := ListQoSPolicies{}
|
||||||
|
|
||||||
|
err = json.Unmarshal(res, &list)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return &list, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListRaw gets list of QoS policies as an array of bytes
|
||||||
|
func (qp QoSPolicy) ListRaw(ctx context.Context, req ListRequest) ([]byte, error) {
|
||||||
|
if err := validators.ValidateRequest(req); err != nil {
|
||||||
|
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudapi/network_qos_policy/list"
|
||||||
|
|
||||||
|
res, err := qp.client.DecortApiCall(ctx, http.MethodGet, url, req)
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
98
pkg/cloudapi/qospolicy/models.go
Normal file
98
pkg/cloudapi/qospolicy/models.go
Normal file
@@ -0,0 +1,98 @@
|
|||||||
|
package qospolicy
|
||||||
|
|
||||||
|
type ListQoSPolicies struct {
|
||||||
|
// List
|
||||||
|
Data []ItemQoSPolicy `json:"data"`
|
||||||
|
|
||||||
|
// Entry count
|
||||||
|
EntryCount uint64 `json:"entryCount"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ItemQoSPolicy struct {
|
||||||
|
// ID of the QoS policy
|
||||||
|
ID uint64 `json:"id"`
|
||||||
|
|
||||||
|
// GUID
|
||||||
|
GUID uint64 `json:"guid"`
|
||||||
|
|
||||||
|
// Account ID that owns the QoS policy
|
||||||
|
AccountID uint64 `json:"account_id"`
|
||||||
|
|
||||||
|
// Name of the QoS policy
|
||||||
|
Name string `json:"name"`
|
||||||
|
|
||||||
|
// Description of the QoS policy
|
||||||
|
Description string `json:"description"`
|
||||||
|
|
||||||
|
// Status of the QoS policy
|
||||||
|
Status string `json:"status"`
|
||||||
|
|
||||||
|
// List of rules
|
||||||
|
Rules Rules `json:"rules"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type RecordQoSPolicy struct {
|
||||||
|
// ID of the QoS policy
|
||||||
|
ID uint64 `json:"id"`
|
||||||
|
|
||||||
|
// GUID
|
||||||
|
GUID uint64 `json:"guid"`
|
||||||
|
|
||||||
|
// Account ID that owns the QoS policy
|
||||||
|
AccountID uint64 `json:"account_id"`
|
||||||
|
|
||||||
|
// Name of the QoS policy
|
||||||
|
Name string `json:"name"`
|
||||||
|
|
||||||
|
// Description of the QoS policy
|
||||||
|
Description string `json:"description"`
|
||||||
|
|
||||||
|
// Status of the QoS policy
|
||||||
|
Status string `json:"status"`
|
||||||
|
|
||||||
|
// List of rules
|
||||||
|
Rules Rules `json:"rules"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type Rules []Rule
|
||||||
|
|
||||||
|
type Rule struct {
|
||||||
|
// ID of the rule
|
||||||
|
ID uint64 `json:"id"`
|
||||||
|
|
||||||
|
// Description of the rule
|
||||||
|
Description string `json:"description"`
|
||||||
|
|
||||||
|
// Rule priority in OVS (higher number = higher priority)
|
||||||
|
Priority uint64 `json:"priority"`
|
||||||
|
|
||||||
|
// Traffic direction
|
||||||
|
Direction string `json:"direction"`
|
||||||
|
|
||||||
|
// IP protocol
|
||||||
|
Protocol string `json:"protocol"`
|
||||||
|
|
||||||
|
// Priority Code Point (0-7). L2 marking
|
||||||
|
PCPTag *uint64 `json:"pcp_tag"`
|
||||||
|
|
||||||
|
// DSCP value (0-63). L3 marking
|
||||||
|
DSCPValue *uint64 `json:"dscp_value"`
|
||||||
|
|
||||||
|
// Source IP address
|
||||||
|
SrcIP string `json:"src_ip"`
|
||||||
|
|
||||||
|
// Destination IP address
|
||||||
|
DstIP string `json:"dst_ip"`
|
||||||
|
|
||||||
|
// Source MAC address
|
||||||
|
SrcMAC string `json:"src_mac"`
|
||||||
|
|
||||||
|
// Destination MAC address
|
||||||
|
DstMAC string `json:"dst_mac"`
|
||||||
|
|
||||||
|
// Source port
|
||||||
|
SrcPort uint64 `json:"src_port"`
|
||||||
|
|
||||||
|
// Destination port
|
||||||
|
DstPort uint64 `json:"dst_port"`
|
||||||
|
}
|
||||||
15
pkg/cloudapi/qospolicy/qos_policy.go
Normal file
15
pkg/cloudapi/qospolicy/qos_policy.go
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
package qospolicy
|
||||||
|
|
||||||
|
import "repository.basistech.ru/BASIS/decort-golang-sdk/interfaces"
|
||||||
|
|
||||||
|
// Structure for creating request to QoS policy
|
||||||
|
type QoSPolicy struct {
|
||||||
|
client interfaces.Caller
|
||||||
|
}
|
||||||
|
|
||||||
|
// Builder for QoS policy endpoint
|
||||||
|
func New(client interfaces.Caller) *QoSPolicy {
|
||||||
|
return &QoSPolicy{
|
||||||
|
client: client,
|
||||||
|
}
|
||||||
|
}
|
||||||
52
pkg/cloudapi/qospolicy/update.go
Normal file
52
pkg/cloudapi/qospolicy/update.go
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
package qospolicy
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"encoding/json"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants"
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
|
)
|
||||||
|
|
||||||
|
type UpdateRequest struct {
|
||||||
|
// QoS policy ID
|
||||||
|
// Required: true
|
||||||
|
QoSPolicyID uint64 `url:"qos_policy_id" json:"qos_policy_id" validate:"required"`
|
||||||
|
|
||||||
|
// New QoS policy name
|
||||||
|
// Required: false
|
||||||
|
Name *string `url:"name,omitempty" json:"name,omitempty"`
|
||||||
|
|
||||||
|
// New QoS policy description
|
||||||
|
// Required: false
|
||||||
|
Description *string `url:"description,omitempty" json:"description,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (qp QoSPolicy) Update(ctx context.Context, req UpdateRequest) (*RecordQoSPolicy, error) {
|
||||||
|
res, err := qp.UpdateRaw(ctx, req)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
info := RecordQoSPolicy{}
|
||||||
|
|
||||||
|
err = json.Unmarshal(res, &info)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return &info, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (qp QoSPolicy) UpdateRaw(ctx context.Context, req UpdateRequest) ([]byte, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudapi/network_qos_policy/update"
|
||||||
|
|
||||||
|
res, err := qp.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
@@ -27,6 +27,8 @@ type AccessGrantRequest struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// AccessGrant grants user or group access to the resource group as specified
|
// AccessGrant grants user or group access to the resource group as specified
|
||||||
|
//
|
||||||
|
// Deprecated: will be removed in SDK v1.17
|
||||||
func (r RG) AccessGrant(ctx context.Context, req AccessGrantRequest) (bool, error) {
|
func (r RG) AccessGrant(ctx context.Context, req AccessGrantRequest) (bool, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -20,6 +20,8 @@ type AccessRevokeRequest struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// AccessRevoke revokes specified user or group access from the resource group
|
// AccessRevoke revokes specified user or group access from the resource group
|
||||||
|
//
|
||||||
|
// Deprecated: will be removed in SDK v1.17
|
||||||
func (r RG) AccessRevoke(ctx context.Context, req AccessRevokeRequest) (bool, error) {
|
func (r RG) AccessRevoke(ctx context.Context, req AccessRevokeRequest) (bool, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
40
pkg/cloudapi/rg/add_acl_access.go
Normal file
40
pkg/cloudapi/rg/add_acl_access.go
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
package rg
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"net/http"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants"
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
|
)
|
||||||
|
|
||||||
|
// AddACLAccessRequest adds ACL access to a resource group
|
||||||
|
type AddACLAccessRequest struct {
|
||||||
|
ID uint64 `url:"id" json:"id" validate:"required"`
|
||||||
|
AccessType string `url:"accesstype" json:"accesstype" validate:"required"`
|
||||||
|
Usernames []string `url:"usernames,omitempty" json:"usernames,omitempty"`
|
||||||
|
APIAccesses []uint64 `url:"apiaccesses,omitempty" json:"apiaccesses,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddACLAccess adds ACL access to a resource group.
|
||||||
|
func (r RG) AddACLAccess(ctx context.Context, req AddACLAccessRequest) (bool, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudapi/rg/add_acl_access"
|
||||||
|
|
||||||
|
res, err := r.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err := strconv.ParseBool(string(res))
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
@@ -1,40 +0,0 @@
|
|||||||
package rg
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"encoding/json"
|
|
||||||
"net/http"
|
|
||||||
|
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
|
||||||
)
|
|
||||||
|
|
||||||
// AuditsRequest struct to get audit
|
|
||||||
type AuditsRequest struct {
|
|
||||||
// Resource group ID
|
|
||||||
// Required: true
|
|
||||||
RGID uint64 `url:"rgId" json:"rgId" validate:"required"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// Audits gets audit records for the specified resource group object
|
|
||||||
func (r RG) Audits(ctx context.Context, req AuditsRequest) (ListAudits, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/rg/audits"
|
|
||||||
|
|
||||||
res, err := r.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
list := ListAudits{}
|
|
||||||
|
|
||||||
err = json.Unmarshal(res, &list)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return list, nil
|
|
||||||
}
|
|
||||||
@@ -76,6 +76,10 @@ type CreateRequest struct {
|
|||||||
// SDN access group id
|
// SDN access group id
|
||||||
// Required: false
|
// Required: false
|
||||||
SDNAccessGroupID string `url:"sdn_access_group_id,omitempty" json:"sdn_access_group_id,omitempty"`
|
SDNAccessGroupID string `url:"sdn_access_group_id,omitempty" json:"sdn_access_group_id,omitempty"`
|
||||||
|
|
||||||
|
// Enabling default gateway
|
||||||
|
// Required: false
|
||||||
|
EnableDefaultGateway interface{} `url:"enable_default_gateway,omitempty" json:"enable_default_gateway,omitempty" validate:"omitempty,isBool"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type StoragePolicy struct {
|
type StoragePolicy struct {
|
||||||
|
|||||||
39
pkg/cloudapi/rg/del_acl_access.go
Normal file
39
pkg/cloudapi/rg/del_acl_access.go
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
package rg
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"net/http"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants"
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
|
)
|
||||||
|
|
||||||
|
// DeleteACLAccessRequest deletes ACL access from a resource group
|
||||||
|
type DeleteACLAccessRequest struct {
|
||||||
|
ID uint64 `url:"id" json:"id" validate:"required"`
|
||||||
|
Usernames []string `url:"usernames,omitempty" json:"usernames,omitempty"`
|
||||||
|
APIAccesses []uint64 `url:"apiaccesses,omitempty" json:"apiaccesses,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeleteACLAccess deletes ACL access from a resource group.
|
||||||
|
func (r RG) DeleteACLAccess(ctx context.Context, req DeleteACLAccessRequest) (bool, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudapi/rg/del_acl_access"
|
||||||
|
|
||||||
|
res, err := r.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err := strconv.ParseBool(string(res))
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
44
pkg/cloudapi/rg/get_acl_access.go
Normal file
44
pkg/cloudapi/rg/get_acl_access.go
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
package rg
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"encoding/json"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
|
)
|
||||||
|
|
||||||
|
// GetACLAccessRequest struct to get detailed information about ACL account in a resource group
|
||||||
|
type GetACLAccessRequest struct {
|
||||||
|
ID uint64 `url:"id" json:"id" validate:"required"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get gets current configuration of the ACL access in a resource group as a RecordRGACLAccess struct
|
||||||
|
func (r RG) GetACLAccess(ctx context.Context, req GetACLAccessRequest) (*RecordRGACLAccess, error) {
|
||||||
|
res, err := r.GetACLAccessRaw(ctx, req)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
info := RecordRGACLAccess{}
|
||||||
|
|
||||||
|
err = json.Unmarshal(res, &info)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return &info, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetACLAccessRaw gets current configuration of the ACL access in a resource group as an array of bytes
|
||||||
|
func (r RG) GetACLAccessRaw(ctx context.Context, req GetACLAccessRequest) ([]byte, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudapi/rg/get_acl_access"
|
||||||
|
|
||||||
|
res, err := r.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
@@ -159,6 +159,44 @@ type RecordResourceGroup struct {
|
|||||||
Computes []uint64 `json:"vms"`
|
Computes []uint64 `json:"vms"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Detailed information about ACL Access in a resource group
|
||||||
|
type RecordRGACLAccess struct {
|
||||||
|
// Data
|
||||||
|
Data DataACL `json:"data"`
|
||||||
|
|
||||||
|
// Entry count
|
||||||
|
EntryCount uint64 `json:"entryCount"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Data ACL
|
||||||
|
type DataACL struct {
|
||||||
|
// RG ACL list
|
||||||
|
RGACLList []RGACL `json:"rgACL"`
|
||||||
|
|
||||||
|
// Account ACL list
|
||||||
|
AccountACL []AccountACL `json:"accountACL"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// RG ACL info
|
||||||
|
type RGACL struct {
|
||||||
|
Right string `json:"right"`
|
||||||
|
GUID string `json:"guid"`
|
||||||
|
UserGroupID string `json:"userGroupId"`
|
||||||
|
Status string `json:"status"`
|
||||||
|
Type string `json:"type"`
|
||||||
|
Explicit bool `json:"explicit"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Account ACL info
|
||||||
|
type AccountACL struct {
|
||||||
|
Right string `json:"right"`
|
||||||
|
GUID string `json:"guid"`
|
||||||
|
UserGroupID string `json:"userGroupId"`
|
||||||
|
Status string `json:"status"`
|
||||||
|
Type string `json:"type"`
|
||||||
|
Explicit bool `json:"explicit"`
|
||||||
|
}
|
||||||
|
|
||||||
// Main information about resource group
|
// Main information about resource group
|
||||||
type ItemResourceGroup struct {
|
type ItemResourceGroup struct {
|
||||||
//
|
//
|
||||||
|
|||||||
40
pkg/cloudapi/rg/update_acl_access.go
Normal file
40
pkg/cloudapi/rg/update_acl_access.go
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
package rg
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"net/http"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants"
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
|
)
|
||||||
|
|
||||||
|
// UpdateACLAccessRequest updates ACL access in a resource group
|
||||||
|
type UpdateACLAccessRequest struct {
|
||||||
|
ID uint64 `url:"id" json:"id" validate:"required"`
|
||||||
|
AccessType string `url:"accesstype" json:"accesstype" validate:"required"`
|
||||||
|
Usernames []string `url:"usernames,omitempty" json:"usernames,omitempty"`
|
||||||
|
APIAccesses []uint64 `url:"apiaccesses,omitempty" json:"apiaccesses,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdateACLAccess updates ACL access in a resource group.
|
||||||
|
func (r RG) UpdateACLAccess(ctx context.Context, req UpdateACLAccessRequest) (bool, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudapi/rg/update_acl_access"
|
||||||
|
|
||||||
|
res, err := r.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err := strconv.ParseBool(string(res))
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
@@ -38,6 +38,14 @@ type ListRequest struct {
|
|||||||
// Required: false
|
// Required: false
|
||||||
UpdateTimeTo uint64 `url:"updateTimeTo,omitempty" json:"updateTimeTo,omitempty"`
|
UpdateTimeTo uint64 `url:"updateTimeTo,omitempty" json:"updateTimeTo,omitempty"`
|
||||||
|
|
||||||
|
// Find all tasks created after point in time (unixtime)
|
||||||
|
// Required: false
|
||||||
|
CreatedTimeAt uint64 `url:"createdTimeAt,omitempty" json:"createdTimeAt,omitempty"`
|
||||||
|
|
||||||
|
// Find all tasks created before point in time (unixtime)
|
||||||
|
// Required: false
|
||||||
|
CreatedTimeTo uint64 `url:"createdTimeTo,omitempty" json:"createdTimeTo,omitempty"`
|
||||||
|
|
||||||
// Page number
|
// Page number
|
||||||
// Default: 0
|
// Default: 0
|
||||||
// Default: 0
|
// Default: 0
|
||||||
|
|||||||
@@ -41,6 +41,9 @@ type RecordAsyncTask struct {
|
|||||||
|
|
||||||
// Updated time
|
// Updated time
|
||||||
UpdatedTime uint64 `json:"updatedTime"`
|
UpdatedTime uint64 `json:"updatedTime"`
|
||||||
|
|
||||||
|
// Time of creation
|
||||||
|
CreatedTime uint64 `json:"createdTime"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Detailed information about task
|
// Detailed information about task
|
||||||
|
|||||||
@@ -1,61 +0,0 @@
|
|||||||
package user
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"encoding/json"
|
|
||||||
"net/http"
|
|
||||||
)
|
|
||||||
|
|
||||||
// GetAuditRequest struct for getting user's audits.
|
|
||||||
type GetAuditRequest struct {
|
|
||||||
// Find by api call.
|
|
||||||
// Required: false
|
|
||||||
Call string `url:"call,omitempty" json:"call,omitempty"`
|
|
||||||
|
|
||||||
// Find all audits after point in time (unixtime)
|
|
||||||
// Required: false
|
|
||||||
TimestampAt uint64 `url:"timestampAt,omitempty" json:"timestampAt,omitempty"`
|
|
||||||
|
|
||||||
// Find all audits before point in time (unixtime)
|
|
||||||
// Required: false
|
|
||||||
TimestampTo uint64 `url:"timestampTo,omitempty" json:"timestampTo,omitempty"`
|
|
||||||
|
|
||||||
// find by HTTP max status code
|
|
||||||
// Required: false
|
|
||||||
MaxStatusCode uint64 `url:"maxStatusCode,omitempty" json:"maxStatusCode,omitempty"`
|
|
||||||
|
|
||||||
// find by HTTP min status code
|
|
||||||
// Required: false
|
|
||||||
MinStatusCode uint64 `url:"minStatusCode,omitempty" json:"minStatusCode,omitempty"`
|
|
||||||
|
|
||||||
// Sort by one of supported fields, format +|-(field)
|
|
||||||
// Required: false
|
|
||||||
SortBy string `url:"sortBy,omitempty" json:"sortBy,omitempty" validate:"omitempty,sortBy"`
|
|
||||||
|
|
||||||
// Page number.
|
|
||||||
// Required: false
|
|
||||||
Page uint64 `url:"page,omitempty" json:"page,omitempty"`
|
|
||||||
|
|
||||||
// Page size, maximum - 100.
|
|
||||||
// Required: false
|
|
||||||
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetAudit gets user's audits.
|
|
||||||
func (u User) GetAudit(ctx context.Context, req GetAuditRequest) (ListAudits, error) {
|
|
||||||
url := "/cloudapi/user/getAudit"
|
|
||||||
|
|
||||||
res, err := u.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
|
||||||
if err != nil {
|
|
||||||
return ListAudits{}, err
|
|
||||||
}
|
|
||||||
|
|
||||||
list := ListAudits{}
|
|
||||||
|
|
||||||
err = json.Unmarshal(res, &list)
|
|
||||||
if err != nil {
|
|
||||||
return ListAudits{}, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return list, nil
|
|
||||||
}
|
|
||||||
@@ -1,44 +0,0 @@
|
|||||||
package user
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"net/http"
|
|
||||||
"strconv"
|
|
||||||
|
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
|
||||||
)
|
|
||||||
|
|
||||||
// GetRequest struct to check if the inviteusertoken and emailaddress pair are valid and matching.
|
|
||||||
type IsValidInviteUserTokenRequest struct {
|
|
||||||
// InviteUserToken
|
|
||||||
// The token that was previously sent to the invited user email
|
|
||||||
// Required: true
|
|
||||||
InviteUserToken string `url:"inviteusertoken" json:"inviteusertoken" validate:"required"`
|
|
||||||
|
|
||||||
// EmailAddress
|
|
||||||
// Email address for the user
|
|
||||||
// Required: true
|
|
||||||
EmailAddress string `url:"emailaddress" json:"emailaddress" validate:"required"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// IsValidInviteUserToken checks if the inviteusertoken and emailaddress pair are valid and matching.
|
|
||||||
func (u User) IsValidInviteUserToken(ctx context.Context, req IsValidInviteUserTokenRequest) (bool, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/user/isValidInviteUserToken"
|
|
||||||
|
|
||||||
res, err := u.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
|
||||||
if err != nil {
|
|
||||||
return false, err
|
|
||||||
}
|
|
||||||
|
|
||||||
result, err := strconv.ParseBool(string(res))
|
|
||||||
if err != nil {
|
|
||||||
return false, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return result, nil
|
|
||||||
}
|
|
||||||
@@ -78,35 +78,47 @@ func (s *StatusCode) UnmarshalJSON(b []byte) error {
|
|||||||
|
|
||||||
type BriefResources struct {
|
type BriefResources struct {
|
||||||
Accounts Accounts `json:"Accounts,omitempty"`
|
Accounts Accounts `json:"Accounts,omitempty"`
|
||||||
CSs CSs `json:"CSs,omitempty"`
|
|
||||||
Computes Computes `json:"Computes,omitempty"`
|
Computes Computes `json:"Computes,omitempty"`
|
||||||
RGs RGs `json:"RGs,omitempty"`
|
RGs RGs `json:"RGs,omitempty"`
|
||||||
VMs VMs `json:"VMs,omitempty"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type Accounts struct {
|
type Accounts struct {
|
||||||
Disabled uint64 `json:"DISABLED,omitempty"`
|
Destroying uint64 `json:"DESTROYING,omitempty"`
|
||||||
Enabled uint64 `json:"ENABLED,omitempty"`
|
Confirmed uint64 `json:"CONFIRMED,omitempty"`
|
||||||
}
|
Disabled uint64 `json:"DISABLED,omitempty"`
|
||||||
|
Deleted uint64 `json:"DELETED,omitempty"`
|
||||||
type CSs struct {
|
|
||||||
Disabled uint64 `json:"DISABLED,omitempty"`
|
|
||||||
Enabled uint64 `json:"ENABLED,omitempty"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type Computes struct {
|
type Computes struct {
|
||||||
Started uint64 `json:"Started,omitempty"`
|
Starting uint64 `json:"STARTING,omitempty"`
|
||||||
Stopped uint64 `json:"Stopped,omitempty"`
|
Started uint64 `json:"STARTED,omitempty"`
|
||||||
|
Stopping uint64 `json:"STOPPING,omitempty"`
|
||||||
|
Stopped uint64 `json:"STOPPED,omitempty"`
|
||||||
|
Paused uint64 `json:"PAUSED,omitempty"`
|
||||||
|
Pausing uint64 `json:"PAUSING,omitempty"`
|
||||||
|
Merge uint64 `json:"MERGE,omitempty"`
|
||||||
|
Migrating uint64 `json:"MIGRATING,omitempty"`
|
||||||
|
MigratingIn uint64 `json:"MIGRATING_IN,omitempty"`
|
||||||
|
MigratingOut uint64 `json:"MIGRATING_OUT,omitempty"`
|
||||||
|
Down uint64 `json:"DOWN,omitempty"`
|
||||||
|
Scheduled uint64 `json:"SCHEDULED,omitempty"`
|
||||||
|
BackupStopped uint64 `json:"BACKUP_STOPPED,omitempty"`
|
||||||
|
BackupRunning uint64 `json:"BACKUP_RUNNING,omitempty"`
|
||||||
|
SnapСreate uint64 `json:"SNAPCREATE,omitempty"`
|
||||||
|
Cloning uint64 `json:"CLONING,omitempty"`
|
||||||
|
Rollback uint64 `json:"ROLLBACK,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type RGs struct {
|
type RGs struct {
|
||||||
Disabled uint64 `json:"DISABLED,omitempty"`
|
Modeled uint64 `json:"MODELED,omitempty"`
|
||||||
Enabled uint64 `json:"ENABLED,omitempty"`
|
Created uint64 `json:"CREATED,omitempty"`
|
||||||
}
|
Deleted uint64 `json:"DELETED,omitempty"`
|
||||||
|
Deleting uint64 `json:"DELETING,omitempty"`
|
||||||
type VMs struct {
|
Destroying uint64 `json:"DESTROYING,omitempty"`
|
||||||
Halted uint64 `json:"Halted,omitempty"`
|
Disabled uint64 `json:"DISABLED,omitempty"`
|
||||||
Running uint64 `json:"Running,omitempty"`
|
Disabling uint64 `json:"DISABLING,omitempty"`
|
||||||
|
Enabling uint64 `json:"ENABLING,omitempty"`
|
||||||
|
Restoring uint64 `json:"RESTORING,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type APIsEndpoints struct {
|
type APIsEndpoints struct {
|
||||||
|
|||||||
@@ -18,33 +18,29 @@ type ListRequest struct {
|
|||||||
// Required: false
|
// Required: false
|
||||||
Status string `url:"status,omitempty" json:"status,omitempty"`
|
Status string `url:"status,omitempty" json:"status,omitempty"`
|
||||||
|
|
||||||
// Find by vgpu type
|
// Find by mode
|
||||||
// Required: false
|
// Required: false
|
||||||
Type string `url:"type,omitempty" json:"type,omitempty"`
|
SplitMode string `url:"split_mode,omitempty" json:"split_mode,omitempty"`
|
||||||
|
|
||||||
// Find by vgpu mode
|
// Find by id node
|
||||||
// Required: false
|
// Required: false
|
||||||
Mode string `url:"mode,omitempty" json:"mode,omitempty"`
|
NodeID uint64 `url:"node_id,omitempty" json:"node_id,omitempty"`
|
||||||
|
|
||||||
// Find by id resgroup
|
|
||||||
// Required: false
|
|
||||||
RGID uint64 `url:"rgId,omitempty" json:"rgId,omitempty"`
|
|
||||||
|
|
||||||
// Find by account id
|
// Find by account id
|
||||||
// Required: false
|
// Required: false
|
||||||
AccountID uint64 `url:"accountId,omitempty" json:"accountId,omitempty"`
|
AccountID uint64 `url:"account_id,omitempty" json:"account_id,omitempty"`
|
||||||
|
|
||||||
// Find by compute id
|
// Find by compute id
|
||||||
// Required: false
|
// Required: false
|
||||||
ComputeID uint64 `url:"computeId,omitempty" json:"computeId,omitempty"`
|
ComputeID uint64 `url:"compute_id,omitempty" json:"compute_id,omitempty"`
|
||||||
|
|
||||||
// Find by pgpu id
|
// Find by pgpu id
|
||||||
// Required: false
|
// Required: false
|
||||||
PGPUID uint64 `url:"pgpuId,omitempty" json:"pgpuId,omitempty"`
|
PGPUID uint64 `url:"pgpu_id,omitempty" json:"pgpu_id,omitempty"`
|
||||||
|
|
||||||
// Sort by one of supported fields, format +|-(field)
|
// Sort by one of supported fields, format +|-(field)
|
||||||
// Required: false
|
// Required: false
|
||||||
SortBy string `url:"sortBy,omitempty" json:"sortBy,omitempty" validate:"omitempty,sortBy"`
|
SortBy string `url:"sort_by,omitempty" json:"sort_by,omitempty" validate:"omitempty,sortBy"`
|
||||||
|
|
||||||
// Page number
|
// Page number
|
||||||
// Required: false
|
// Required: false
|
||||||
@@ -83,6 +79,6 @@ func (v VGPU) ListRaw(ctx context.Context, req ListRequest) ([]byte, error) {
|
|||||||
|
|
||||||
url := "/cloudapi/vgpu/list"
|
url := "/cloudapi/vgpu/list"
|
||||||
|
|
||||||
res, err := v.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
res, err := v.client.DecortApiCall(ctx, http.MethodGet, url, req)
|
||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,14 +1,23 @@
|
|||||||
package vgpu
|
package vgpu
|
||||||
|
|
||||||
type ItemVGPU struct {
|
type ItemVGPU struct {
|
||||||
// Account ID
|
// Account IDs
|
||||||
AccountID uint64 `json:"accountId"`
|
AccountIDs []uint64 `json:"account_ids"`
|
||||||
|
|
||||||
|
// Bus number
|
||||||
|
BusNumber int `json:"bus_number"`
|
||||||
|
|
||||||
|
// ComputeID
|
||||||
|
ComputeID uint64 `json:"compute_id"`
|
||||||
|
|
||||||
// Created time
|
// Created time
|
||||||
CreatedTime uint64 `json:"createdTime"`
|
CreatedTime uint64 `json:"created_time"`
|
||||||
|
|
||||||
// Deleted time
|
// Deleted time
|
||||||
DeletedTime uint64 `json:"deletedTime"`
|
DeletedTime uint64 `json:"deleted_time"`
|
||||||
|
|
||||||
|
// Device Reference
|
||||||
|
DeviceReference string `json:"device_reference"`
|
||||||
|
|
||||||
//Grid ID
|
//Grid ID
|
||||||
GID uint64 `json:"gid"`
|
GID uint64 `json:"gid"`
|
||||||
@@ -19,44 +28,32 @@ type ItemVGPU struct {
|
|||||||
// VGPU ID
|
// VGPU ID
|
||||||
ID uint64 `json:"id"`
|
ID uint64 `json:"id"`
|
||||||
|
|
||||||
// Last claimed by
|
// Last Update time
|
||||||
LastClaimedBy uint64 `json:"lastClaimedBy"`
|
LastUpdateTime uint64 `json:"last_update_time"`
|
||||||
|
|
||||||
// Last update time
|
// Mdev UUID
|
||||||
LastUpdateTime uint64 `json:"lastUpdateTime"`
|
MdevUUID string `json:"mdev_uuid"`
|
||||||
|
|
||||||
// Mode
|
// Parent PCI Address
|
||||||
Mode string `json:"mode"`
|
ParentPCIAddress string `json:"parent_pci_address"`
|
||||||
|
|
||||||
// Bus number
|
|
||||||
BusNumber int `json:"bus_number"`
|
|
||||||
|
|
||||||
// PCI Slot
|
// PCI Slot
|
||||||
PCISlot int `json:"pciSlot"`
|
PCISlot uint64 `json:"pci_slot"`
|
||||||
|
|
||||||
// PGPUID
|
// PGPU ID
|
||||||
PGPUID uint64 `json:"pgpuid"`
|
PGPUID uint64 `json:"pgpu_id"`
|
||||||
|
|
||||||
// Profile ID
|
// Profile Reference
|
||||||
ProfileID uint64 `json:"profileId"`
|
ProfileReference string `json:"profile_reference"`
|
||||||
|
|
||||||
// RAM
|
// Profile Name
|
||||||
RAM uint64 `json:"ram"`
|
ProfileName string `json:"profile_name"`
|
||||||
|
|
||||||
// Reference ID
|
// Split Mode
|
||||||
ReferenceID string `json:"referenceId"`
|
SplitMode string `json:"split_mode"`
|
||||||
|
|
||||||
// RGID
|
|
||||||
RGID uint64 `json:"rgId"`
|
|
||||||
|
|
||||||
// Status
|
// Status
|
||||||
Status string `json:"status"`
|
Status string `json:"status"`
|
||||||
|
|
||||||
// Type
|
|
||||||
Type string `json:"type"`
|
|
||||||
|
|
||||||
// VMID
|
|
||||||
VMID uint64 `json:"vmid"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// List of VGPU
|
// List of VGPU
|
||||||
|
|||||||
@@ -1,40 +0,0 @@
|
|||||||
package vins
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"encoding/json"
|
|
||||||
"net/http"
|
|
||||||
|
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
|
||||||
)
|
|
||||||
|
|
||||||
// AuditsRequest struct to get audits
|
|
||||||
type AuditsRequest struct {
|
|
||||||
// ID of the VINS
|
|
||||||
// Required: true
|
|
||||||
VINSID uint64 `url:"vinsId" json:"vinsId" validate:"required"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// Audits gets audit records for the specified VINS object
|
|
||||||
func (v VINS) Audits(ctx context.Context, req AuditsRequest) (ListAudits, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/vins/audits"
|
|
||||||
|
|
||||||
res, err := v.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
list := ListAudits{}
|
|
||||||
|
|
||||||
err = json.Unmarshal(res, &list)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return list, nil
|
|
||||||
}
|
|
||||||
@@ -2,10 +2,10 @@ package vins
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants"
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -62,11 +62,11 @@ type CreateInAccountRequest struct {
|
|||||||
// Required: false
|
// Required: false
|
||||||
// Default: false
|
// Default: false
|
||||||
EnableSecGroups interface{} `url:"enable_secgroups,omitempty" json:"enable_secgroups,omitempty" validate:"omitempty,isBool"`
|
EnableSecGroups interface{} `url:"enable_secgroups,omitempty" json:"enable_secgroups,omitempty" validate:"omitempty,isBool"`
|
||||||
}
|
|
||||||
|
|
||||||
type wrapperCreateRequestInAcc struct {
|
// Flag indicating whether default gateway is enabled for this VINS
|
||||||
CreateInAccountRequest
|
// Required: false
|
||||||
Routes []string `url:"routes,omitempty"`
|
// Default: true
|
||||||
|
EnableDefaultGateway interface{} `url:"enable_default_gateway,omitempty" json:"enable_default_gateway,omitempty" validate:"omitempty,isBool"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreateInAccount creates VINS in account level
|
// CreateInAccount creates VINS in account level
|
||||||
@@ -76,31 +76,9 @@ func (v VINS) CreateInAccount(ctx context.Context, req CreateInAccountRequest) (
|
|||||||
return 0, validators.ValidationErrors(validators.GetErrors(err))
|
return 0, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
var routes []string
|
|
||||||
|
|
||||||
if len(req.Routes) != 0 {
|
|
||||||
routes = make([]string, 0, len(req.Routes))
|
|
||||||
|
|
||||||
for r := range req.Routes {
|
|
||||||
b, err := json.Marshal(req.Routes[r])
|
|
||||||
if err != nil {
|
|
||||||
return 0, err
|
|
||||||
}
|
|
||||||
|
|
||||||
routes = append(routes, string(b))
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
routes = []string{}
|
|
||||||
}
|
|
||||||
|
|
||||||
reqWrapped := wrapperCreateRequestInAcc{
|
|
||||||
CreateInAccountRequest: req,
|
|
||||||
Routes: routes,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/vins/createInAccount"
|
url := "/cloudapi/vins/createInAccount"
|
||||||
|
|
||||||
res, err := v.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
res, err := v.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,10 +2,10 @@ package vins
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants"
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -56,11 +56,11 @@ type CreateInRGRequest struct {
|
|||||||
// Required: false
|
// Required: false
|
||||||
// Default: false
|
// Default: false
|
||||||
EnableSecGroups interface{} `url:"enable_secgroups,omitempty" json:"enable_secgroups,omitempty" validate:"omitempty,isBool"`
|
EnableSecGroups interface{} `url:"enable_secgroups,omitempty" json:"enable_secgroups,omitempty" validate:"omitempty,isBool"`
|
||||||
}
|
|
||||||
|
|
||||||
type wrapperCreateRequestInRG struct {
|
// Flag indicating whether default gateway is enabled for this VINS
|
||||||
CreateInRGRequest
|
// Required: false
|
||||||
Routes []string `url:"routes,omitempty"`
|
// Default: true
|
||||||
|
EnableDefaultGateway interface{} `url:"enable_default_gateway,omitempty" json:"enable_default_gateway,omitempty" validate:"omitempty,isBool"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreateInRG creates VINS in resource group level
|
// CreateInRG creates VINS in resource group level
|
||||||
@@ -70,31 +70,9 @@ func (v VINS) CreateInRG(ctx context.Context, req CreateInRGRequest) (uint64, er
|
|||||||
return 0, validators.ValidationErrors(validators.GetErrors(err))
|
return 0, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
var routes []string
|
|
||||||
|
|
||||||
if len(req.Routes) != 0 {
|
|
||||||
routes = make([]string, 0, len(req.Routes))
|
|
||||||
|
|
||||||
for r := range req.Routes {
|
|
||||||
b, err := json.Marshal(req.Routes[r])
|
|
||||||
if err != nil {
|
|
||||||
return 0, err
|
|
||||||
}
|
|
||||||
|
|
||||||
routes = append(routes, string(b))
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
routes = []string{}
|
|
||||||
}
|
|
||||||
|
|
||||||
reqWrapped := wrapperCreateRequestInRG{
|
|
||||||
CreateInRGRequest: req,
|
|
||||||
Routes: routes,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/vins/createInRG"
|
url := "/cloudapi/vins/createInRG"
|
||||||
|
|
||||||
res, err := v.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
res, err := v.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user