diff --git a/README.md b/README.md index 441bdca..01a8252 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,7 @@ Dynamix SDK - это библиотека, написанная на языке - Версия 9.0.х Dynamix-SDK соответствует 4.1.0 версии платформы - Версия 10.0.х Dynamix-SDK соответствует 4.2.0 версии платформы - Версия 11.0.х Dynamix-SDK соответствует 4.3.0 версии платформы + - Версия 12.0.х Dynamix-SDK соответствует 4.4.0 версии платформы ## Оглавление @@ -76,7 +77,7 @@ Dynamix SDK - это библиотека, написанная на языке Выполните команду в терминале: ```bash -go get -u repository.basistech.ru/BASIS/dynamix-golang-sdk/v11 +go get -u repository.basistech.ru/BASIS/dynamix-golang-sdk/v12 ``` ## Список API @@ -85,6 +86,7 @@ go get -u repository.basistech.ru/BASIS/dynamix-golang-sdk/v11 - `cloudapi` - пользовательская группа, которая позволяет воспользоваться всем стардартным функционалом платформы; - `cloudbroker` - административная группа, которая позволяет воспользоваться всем стандартным функционалом платформы и расширенными возможностями, включающими в себя управление пользователями, ресурсами, платформами размещения ресурсов и т.д. +- `sdn` - группа для работы с SDN; ### Cloudapi @@ -107,11 +109,15 @@ go get -u repository.basistech.ru/BASIS/dynamix-golang-sdk/v11 - `Locations` - получение информации о grid площадки; - `Prometheus` - получение статистики prometheus; - `RG` - управление ресурсными группами аккаунта; +- `Security group` – управление группами безопасности; - `SEP` - управление storage endpoint (sep); - `Stack` - получение информации о вычислительных узлах; +- `Storage policy` – получение информации о политиках хранения; - `Tasks` - получение информации о ходе выполнения асинхронных задач (например, создание кластера); +- `Trunk` - получение информации о транковых портах; - `VFPool` - управление пулом виртуальных сетевых функций; -- `VINS` - управление виртуальными изолированными сетями. +- `VINS` - управление виртуальными изолированными сетями; +- `Zone` - управление зонами. ### Cloudbroker @@ -122,6 +128,7 @@ go get -u repository.basistech.ru/BASIS/dynamix-golang-sdk/v11 - `Audit` - получение информации о событиях системы; - `APIAccess` - управление доступом к API и его объектам; - `Backup` - управление резервным копированием; +- `BService` - управление группами виртуальных машин (computes); - `Compute` - управление виртуальными машинами (индивидуально); - `Disks` - управление виртуальными дисками; - `DPDK` - управление виртуальными сетями DPDK; @@ -139,13 +146,24 @@ go get -u repository.basistech.ru/BASIS/dynamix-golang-sdk/v11 - `Prometheus` - получение статистики prometheus; - `Resmon` - получение статистики resource monitoring; - `RG` - управление ресурсными группами аккаунта; +- `Security group` – управление группами безопасности; - `SEP` - управление storage endpoint (sep); - `Stack` - получение информации о вычислительных узлах; +- `Storage policy` – управление политиками хранения; - `Tasks` - получение информации о ходе выполнения асинхронных задач (например, создание кластера); +- `Trunk` - управление транковыми портами; - `User` - управление пользователями (индивидуально); - `VGPU` - управление виртуальными графическими процессорами; - `VFPool` - управление пулом виртуальных сетевых функций; - `VINS` - управление виртуальными изолированными сетями. +- `Zone` - управление зонами. + +### SDN + +`SDN` позволяет выполнять запросы к группе пользовательских конечных точек +Данная группа ручек позволяет выполнять следующие операции в платформе: + +- `AccessGroup` - управление группами доступа ## Работа с библиотекой @@ -176,7 +194,7 @@ go get -u repository.basistech.ru/BASIS/dynamix-golang-sdk/v11 ```go import ( - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/config" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/config" ) func main(){ @@ -201,7 +219,7 @@ func main(){ ```go import ( - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/config" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/config" ) func main() { @@ -246,8 +264,8 @@ sslSkipVerify: false package main import ( - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/config" - decort "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/config" + decort "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12" ) func main() { @@ -273,6 +291,7 @@ func main() { - `pkg/cloudapi` - для `cloudapi` - `pkg/cloudbroker` - для `cloudbroker` +- `pkg/sdn` - для `sdn` В каждом пакете находятся пакеты групп API: @@ -293,16 +312,21 @@ func main() { - `pkg/cloudapi/locations` - для `Locations` - `pkg/cloudapi/prometheus` - для `Prometheus` - `pkg/cloudapi/rg` - для `RG` + - `pkg/cloudapi/secgroup` - для `Security group` - `pkg/cloudapi/sep` - для `SEP` - `pkg/cloudapi/stack` - для `Stack` + - `pkg/cloudapi/stpolicy` - для `Storage policy` - `pkg/cloudapi/tasks` - для `Tasks` + - `pkg/cloudapi/trunk` - для `Trunk` - `pkg/cloudapi/vfpool` - для `VFPool` - `pkg/cloudapi/vins` - для `VINS` + - `pkg/cloudapi/zone` - для `Zone` - **cloudbroker**: - `pkg/cloudbroker/account` - для `Account` - `pkg/cloudbroker/audit` - для `Audit` - `pkg/cloudbroker/apiaccess` - для `APIAccess` - `pkg/cloudbroker/backup` - для `Backup` + - `pkg/cloudbroker/bservice` - для `Basic Service` - `pkg/cloudbroker/compute` - для `Compute` - `pkg/cloudbroker/disks` - для `Disks` - `pkg/cloudbroker/dpdknet` - для `DPDK` @@ -320,13 +344,19 @@ func main() { - `pkg/cloudbroker/prometheus` - для `Prometheus` - `pkg/cloudbroker/resmon` - для `Resmon` - `pkg/cloudbroker/rg` - для `RG` + - `pkg/cloudbroker/secgroup` - для `Security group` - `pkg/cloudbroker/sep` - для `SEP` - `pkg/cloudbroker/stack` - для `Stack` + - `pkg/cloudbroker/stpolicy` - для `Storage policy` - `pkg/cloudbroker/tasks` - для `Tasks` + - `pkg/cloudbroker/trunk` - для `Trunk` - `pkg/cloudbroker/user` - для `User` - `pkg/cloudbroker/vgpu` - для `VGPU` - `pkg/cloudbroker/vfpool` - для `VFPool` - `pkg/cloudbroker/vins` - для `VINS` + - `pkg/cloudbroker/zone` - для `Zone` +- **sdn**: + - `pkg/sdn/access_groups` - для `AccessGroups` Все поля структуры имеют описание, в которых содержится: @@ -426,9 +456,9 @@ type CreateRequest struct { package main import ( - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/config" - decort "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/pkg/cloudapi/kvmx86" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/config" + decort "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/pkg/cloudapi/kvmx86" ) func main() { @@ -460,7 +490,7 @@ func main() { Чтобы выполнить запрос, необходимо: -1. Вызвать у клиента метод, отвечаеющий за определение группы API для взаимодействия, это может быть `.CloudAPI()`, либо `.CloudBroker()`. Данные методы возвращаеют соответствующие структуры, с помощью которых можно совершать запросы. +1. Вызвать у клиента метод, отвечающий за определение группы API для взаимодействия, это может быть `.CloudAPI()`, `.CloudBroker()` или `.SDN()`. Данные методы возвращают соответствующие структуры, с помощью которых можно совершать запросы. 2. Вызвать у возвращенной структуры метод, определяющий группу ручек для взаимодействия. Доступные методы для `.CloudAPI()`: @@ -481,11 +511,15 @@ func main() { - `.Locations()` - для работы с `Locations` - `.Prometheus()` - для работы с `Prometheus` - `.RG()` - для работы с `RG` + - `.SecurityGroup()` - для работы с `Security Group` - `.SEP()` - для работы с `SEP` - `.Stack()` - для работы с `Stack` + - `.StPolicy()` - для работы с `Storage Policy` - `.Tasks()` - для работы с `Tasks` + - `.Trunk()` - для работы с `Trunk` - `.VFPool()` - для работы с `VFPool` - `.VINS()` - для работы с `VINS` + - `.Zone()` - для работы с `Zone` Доступные методы для `.CloudBroker()`: @@ -493,6 +527,7 @@ func main() { - `.Audit()` - для работы с `Audit` - `.APIAccess()` - для работы с `APIAccess` - `.Backup()` - для работы с `Backup` + - `.BService()` - для работы с `BService` - `.Compute()` - для работы с `Compute` - `.Disks()` - для работы с `Disks` - `.DPDKNet()` - для работы с `DPDK` @@ -510,13 +545,21 @@ func main() { - `.Prometheus()` - для работы с `Prometheus` - `.Resmon()` - для работы с `Resmon` - `.RG()` - для работы с `RG` + - `.SecurityGroup()` - для работы с `Security Group` - `.SEP()` - для работы с `SEP` - `.Stack()` - для работы с `Stack` + - `.StPolicy()` - для работы с `Storage Policy` - `.Tasks()` - для работы с `Tasks` + - `.Trunk()` - для работы с `Trunk` - `.User()` - для работы с `User` - `.VGPU()` - для работы с `VGPU` - `.VFPool()` - для работы с `VFPool` - `.VINS()` - для работы с `VINS` + - `.Zone()` - для работы с `Zone` + + Доступные методы для `.SDN()`: + + - `.AccessGroup()` - для работы с `AccessGroup` 3. Вызвать метод, отвечающий за выполнение запроса и передать в него: @@ -542,9 +585,9 @@ import ( "log" "fmt" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/config" - decort "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/pkg/cloudapi/kvmx86" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/config" + decort "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/pkg/cloudapi/kvmx86" ) func main() { @@ -592,9 +635,9 @@ import ( "log" "fmt" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/config" - decort "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/pkg/cloudapi/account" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/config" + decort "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/pkg/cloudapi/account" ) func main() { @@ -772,9 +815,9 @@ import ( "context" "log" - decort "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/config" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/pkg/cloudbroker/compute" + decort "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/config" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/pkg/cloudbroker/compute" ) func main() { @@ -830,9 +873,9 @@ import ( "log" "fmt" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/config" - decort "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/pkg/cloudapi/bservice" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/config" + decort "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/pkg/cloudapi/bservice" ) func main() { @@ -885,10 +928,10 @@ import ( "log" "fmt" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/config" - decort "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/pkg/cloudapi/tasks" - tasks_cb "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/pkg/cloudbroker/tasks" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/config" + decort "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/pkg/cloudapi/tasks" + tasks_cb "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/pkg/cloudbroker/tasks" ) func main() { @@ -968,7 +1011,7 @@ func main() { ```go import ( - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/config" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/config" ) func main(){ @@ -992,7 +1035,7 @@ func main(){ ```go import ( - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/config" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/config" ) func main() { @@ -1033,8 +1076,8 @@ sslSkipVerify: true package main import ( - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/config" - decort "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/config" + decort "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12" ) func main() { @@ -1061,8 +1104,8 @@ package main import ( "fmt" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/config" - decort "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/config" + decort "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12" ) func main() { @@ -1144,7 +1187,7 @@ func main() { ```go import ( - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/config" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/config" ) func main(){ @@ -1172,7 +1215,7 @@ func main(){ ```go import ( - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/config" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/config" ) func main() { @@ -1189,7 +1232,7 @@ func main() { ```go import ( - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/config" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/config" ) func main() { @@ -1255,8 +1298,8 @@ func main() { package main import ( - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/config" - decort "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/config" + decort "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12" ) func main() { @@ -1289,8 +1332,8 @@ package main import ( "fmt" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/config" - decort "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/config" + decort "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12" ) func main() { @@ -1330,8 +1373,8 @@ package main import ( "fmt" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/config" - decort "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/config" + decort "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12" ) func main() { @@ -1369,8 +1412,8 @@ package main import ( "fmt" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/config" - decort "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/config" + decort "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12" ) func main() { @@ -1423,11 +1466,11 @@ import ( "log" "os" - decort "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/config" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/constants" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/pkg/cloudbroker/kvmx86" + decort "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/config" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/constants" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/pkg/cloudbroker/kvmx86" ) func main() { @@ -1489,7 +1532,7 @@ func main() { ```go import ( - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/config" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/config" ) func main(){ @@ -1522,8 +1565,8 @@ func main(){ package main import ( - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/config" - decort "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/config" + decort "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12" ) func main() { @@ -1554,46 +1597,46 @@ package main import ( "fmt" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/config" - decort "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/config" + decort "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12" ) func main() { - // Настройка конфигурации - legacyCfg := config.LegacyConfig{ - Username: "", - Password: "", - Domain: "dynamix", - DecortURL: "https://mr4.digitalenergy.online", - Retries: 5, - } + // Настройка конфигурации + legacyCfg := config.LegacyConfig{ + Username: "", + Password: "", + Domain: "dynamix", + DecortURL: "https://mr4.digitalenergy.online", + Retries: 5, + } - legacyCfg.SetTimeout(5 * time.Minute) + legacyCfg.SetTimeout(5 * time.Minute) - cfg := config.UniversalConfig{ - LegacyConfig: &legacyCfg, + cfg := config.UniversalConfig{ + LegacyConfig: &legacyCfg, } - // Создание клиента - universalClient := decort.NewUniversal(cfg) - - // Создание структуры запроса - // CreateRequest - реквест на создание виртуальной машины - req := kvmx86.CreateRequest{ - RGID: 123, - Name: "compute", - CPU: 4, - RAM: 4096, - ImageID: 321, - } + // Создание клиента + universalClient := decort.NewUniversal(cfg) - // Выполнение запроса - res, err := universalClient.CloudAPI().KVMX86().Create(context.Background(), req) - if err != nil { - log.Fatal(err) - } + // Создание структуры запроса + // CreateRequest - реквест на создание виртуальной машины + req := kvmx86.CreateRequest{ + RGID: 123, + Name: "compute", + CPU: 4, + RAM: 4096, + ImageID: 321, + } - fmt.Println(res) + // Выполнение запроса + res, err := universalClient.CloudAPI().KVMX86().Create(context.Background(), req) + if err != nil { + log.Fatal(err) + } + + fmt.Println(res) } ``` @@ -1607,7 +1650,7 @@ func main() { ```go import ( - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/config" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/config" ) func main(){ diff --git a/check.go b/check.go index 356038a..8831b65 100644 --- a/check.go +++ b/check.go @@ -8,7 +8,7 @@ import ( "net/http" "strings" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/constants" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/constants" ) type CheckInfo struct { diff --git a/client.go b/client.go index 2970c5b..5e0c054 100644 --- a/client.go +++ b/client.go @@ -4,6 +4,7 @@ import ( "bytes" "context" "crypto/tls" + "encoding/base64" "encoding/json" "fmt" "io" @@ -16,11 +17,12 @@ import ( "time" "github.com/google/go-querystring/query" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/config" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/constants" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/pkg/cloudapi" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/pkg/cloudbroker" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/config" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/constants" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/pkg/cloudapi" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/pkg/cloudbroker" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/pkg/sdn" ) // DecortClient is HTTP-client for platform @@ -38,12 +40,6 @@ func New(cfg config.Config) *DecortClient { cfg.Retries = 5 } - var expiryTime time.Time - - if cfg.Token != "" { - expiryTime = time.Now().AddDate(0, 0, 1) - } - return &DecortClient{ decortURL: cfg.DecortURL, client: &http.Client{ @@ -54,9 +50,8 @@ func New(cfg config.Config) *DecortClient { }, }, }, - cfg: trimConfig(&cfg), - expiryTime: expiryTime, - mutex: &sync.Mutex{}, + cfg: trimConfig(&cfg), + mutex: &sync.Mutex{}, } } @@ -70,6 +65,11 @@ func (dc *DecortClient) CloudBroker() *cloudbroker.CloudBroker { return cloudbroker.New(dc) } +// SDN builder +func (dc *DecortClient) SDN() *sdn.SDN { + return sdn.New(dc) +} + // DecortApiCall method for sending requests to the platform func (dc *DecortClient) DecortApiCall(ctx context.Context, method, url string, params interface{}) ([]byte, error) { @@ -107,6 +107,47 @@ func (dc *DecortClient) DecortApiCall(ctx context.Context, method, url string, p return respBytes, err } +// DecortApiCallCtype method for sending requests to the platform with content type +func (dc *DecortClient) DecortApiCallCtype(ctx context.Context, method, url, ctype string, params interface{}) ([]byte, error) { + + var body *bytes.Buffer + + switch ctype { + case constants.MIMESTREAM: + body = bytes.NewBuffer(params.([]byte)) + case constants.MIMEJSON: + jsonBody, err := json.Marshal(params) + if err != nil { + return nil, err + } + body = bytes.NewBuffer(jsonBody) + default: + ctype = constants.MIMEPOSTForm + values, err := query.Values(params) + if err != nil { + return nil, err + } + body = bytes.NewBufferString(values.Encode()) + } + + req, err := http.NewRequestWithContext(ctx, method, dc.decortURL+constants.RESTMACHINE+url, body) + if err != nil { + return nil, err + } + + // get token + if err = dc.getToken(ctx); err != nil { + return nil, err + } + // perform request + respBytes, err := dc.do(req, ctype) + if err != nil { + return nil, err + } + + return respBytes, err +} + // DecortApiCallMP method for sending requests to the platform func (dc *DecortClient) DecortApiCallMP(ctx context.Context, method, url string, params interface{}) ([]byte, error) { body, ctype, err := multiPartReq(params) @@ -170,8 +211,13 @@ func (dc *DecortClient) getToken(ctx context.Context) error { // save token in config token := string(tokenBytes) + expiryTime, err := getTokenExp(token) + if err != nil { + return fmt.Errorf("cannot get expiry time: %w", err) + } + dc.cfg.Token = token - dc.expiryTime = time.Now().AddDate(0, 0, 1) + dc.expiryTime = expiryTime return nil } @@ -375,3 +421,29 @@ func trimConfig(cfg *config.Config) config.Config { cfg.DecortURL = strings.TrimSuffix(cfg.DecortURL, "/") return *cfg } + +func getTokenExp(token string) (time.Time, error) { + parts := strings.Split(token, ".") + if len(parts) != 3 { + return time.Time{}, fmt.Errorf("invalid token format") + } + + payload, err := base64.RawURLEncoding.DecodeString(parts[1]) + if err != nil { + return time.Time{}, fmt.Errorf("error decode payload from token: %w", err) + } + + var claims map[string]interface{} + if err := json.Unmarshal(payload, &claims); err != nil { + return time.Time{}, err + } + + exp, ok := claims["exp"] + if !ok { + return time.Time{}, fmt.Errorf("exp time bot found") + } + + expTime := time.Unix(int64(exp.(float64)), 0) + + return expTime, nil +} diff --git a/client_bvs.go b/client_bvs.go index 9bf11f6..0e87e1a 100644 --- a/client_bvs.go +++ b/client_bvs.go @@ -14,10 +14,10 @@ import ( "time" "github.com/google/go-querystring/query" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/config" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/constants" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/pkg/cloudapi" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/pkg/cloudbroker" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/config" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/constants" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/pkg/cloudapi" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/pkg/cloudbroker" ) // BVSDecortClient is HTTP-client for platform @@ -131,6 +131,72 @@ func (bdc *BVSDecortClient) DecortApiCall(ctx context.Context, method, url strin return respBytes, err } +// DecortApiCallCtype method for sending requests to the platform with content type +func (bdc *BVSDecortClient) DecortApiCallCtype(ctx context.Context, method, url, ctype string, params interface{}) ([]byte, error) { + var body *bytes.Buffer + + switch ctype { + case constants.MIMESTREAM: + body = bytes.NewBuffer(params.([]byte)) + case constants.MIMEJSON: + jsonBody, err := json.Marshal(params) + if err != nil { + return nil, err + } + body = bytes.NewBuffer(jsonBody) + default: + ctype = constants.MIMEPOSTForm + values, err := query.Values(params) + if err != nil { + return nil, err + } + body = bytes.NewBufferString(values.Encode()) + } + + req, err := http.NewRequestWithContext(ctx, method, bdc.decortURL+constants.RESTMACHINE+url, body) + if err != nil { + return nil, err + } + + // get token + if bdc.cfg.Token.AccessToken == "" { + if _, err = bdc.GetToken(ctx); err != nil { + return nil, err + } + } + + // refresh token + if bdc.cfg.Token.RefreshToken != "" && bdc.cfg.Token.Expiry.Add(-time.Duration(bdc.cfg.TimeToRefresh)*time.Minute).Before(time.Now()) { + if _, err := bdc.RefreshToken(ctx); err != nil { + if _, err = bdc.GetToken(ctx); err != nil { + return nil, err + } + } + } + + // perform request + reqCopy := req.Clone(ctx) + respBytes, err := bdc.do(req, ctype) + if err == nil { + return respBytes, nil + } + + // get token and retry in case of access denied + if err.Error() == "access is denied" { + _, err = bdc.GetToken(ctx) + if err != nil { + return nil, err + } + + respBytes, err = bdc.do(reqCopy, "") + if err != nil { + return nil, err + } + } + + return respBytes, err +} + func (bdc *BVSDecortClient) DecortApiCallMP(ctx context.Context, method, url string, params interface{}) ([]byte, error) { body, ctype, err := multiPartReq(params) if err != nil { diff --git a/config/config.go b/config/config.go index a968e35..e35ac27 100644 --- a/config/config.go +++ b/config/config.go @@ -6,7 +6,7 @@ import ( "time" "gopkg.in/yaml.v3" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // Configuration for creating request to platform diff --git a/config/config_bvs.go b/config/config_bvs.go index 0a6891e..1a03a17 100644 --- a/config/config_bvs.go +++ b/config/config_bvs.go @@ -6,8 +6,8 @@ import ( "time" "gopkg.in/yaml.v3" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/serialization" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/serialization" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) type BVSConfig struct { diff --git a/config/legacy-config.go b/config/legacy-config.go index 32ec48a..d1915c6 100644 --- a/config/legacy-config.go +++ b/config/legacy-config.go @@ -6,7 +6,7 @@ import ( "time" "gopkg.in/yaml.v3" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // Legacy client configuration diff --git a/go.mod b/go.mod index eed5e22..1ab33c8 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module repository.basistech.ru/BASIS/dynamix-golang-sdk/v11 +module repository.basistech.ru/BASIS/dynamix-golang-sdk/v12 go 1.20 diff --git a/interfaces/caller.go b/interfaces/caller.go index c40b0ba..026ac22 100644 --- a/interfaces/caller.go +++ b/interfaces/caller.go @@ -7,6 +7,9 @@ type Caller interface { // DecortApiCall method for sending requests to the platform DecortApiCall(ctx context.Context, method, url string, params interface{}) ([]byte, error) + // DecortApiCallCtype method for sending requests to the platform + DecortApiCallCtype(ctx context.Context, method, url, ctype string, params interface{}) ([]byte, error) + // DecortApiCallMP method for sending requests to the platform DecortApiCallMP(ctx context.Context, method, url string, params interface{}) ([]byte, error) } diff --git a/internal/constants/constants.go b/internal/constants/constants.go index 4ebc2e3..0f96f45 100644 --- a/internal/constants/constants.go +++ b/internal/constants/constants.go @@ -2,9 +2,23 @@ package constants const ( RESTMACHINE = "/restmachine" +) - // RAM_DIVISIBILITY sets divisibility of RAM value - RAM_DIVISIBILITY uint64 = 128 +const ( + MIMEJSON = "application/json" + MIMEHTML = "text/html" + MIMEXML = "application/xml" + MIMEXML2 = "text/xml" + MIMEPlain = "text/plain" + MIMEPOSTForm = "application/x-www-form-urlencoded" + MIMEMultipartPOSTForm = "multipart/form-data" + MIMEPROTOBUF = "application/x-protobuf" + MIMEMSGPACK = "application/x-msgpack" + MIMEMSGPACK2 = "application/msgpack" + MIMEYAML = "application/x-yaml" + MIMEYAML2 = "application/yaml" + MIMETOML = "application/toml" + MIMESTREAM = "application/octet-stream" ) var FileName = map[string]string{ @@ -14,5 +28,6 @@ var FileName = map[string]string{ var K8sValues = []string{"labels", "taints", "annotations, additionalSANs"} var VersionMap = map[string]string{ - "4.3.0": "-", + "4.4.0": "-", + "4.3.0": "v11.0.0", } diff --git a/internal/validators/custom.go b/internal/validators/custom.go index 8c2c4a3..66e60cc 100644 --- a/internal/validators/custom.go +++ b/internal/validators/custom.go @@ -6,20 +6,14 @@ import ( "net/url" "reflect" "regexp" + "strconv" "strings" "github.com/go-playground/validator/v10" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/interfaces" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/multierror" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/interfaces" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/multierror" ) -// computeDriverValidator is used to validate Driver field in kvmx86 create. -func computeDriverValidator(fe validator.FieldLevel) bool { - fieldValue := fe.Field().String() - - return IsInSlice(fieldValue, computeDriverValues) -} - // protoValidator is used to validate Proto fields. func protoValidator(fe validator.FieldLevel) bool { fieldValue := fe.Field().String() @@ -57,13 +51,6 @@ func resTypesValidator(fe validator.FieldLevel) bool { return true } -// driverValidator is used to validate Driver fields. -func driverValidator(fe validator.FieldLevel) bool { - fieldValue := fe.Field().String() - - return IsInSlice(fieldValue, driverValues) -} - // accountCUTypeValidator is used to validate CUType field. func accountCUTypeValidator(fe validator.FieldLevel) bool { fieldValue := fe.Field().String() @@ -120,6 +107,27 @@ func computex86NetTypeValidator(fe validator.FieldLevel) bool { return IsInSlice(fieldValue, computex86NetTypeValues) } +// securityGroupDirectionValidator is used to validate Direction field +func securityGroupDirectionValidator(fe validator.FieldLevel) bool { + fieldValue := fe.Field().String() + + return IsInSlice(fieldValue, securityGroupDirectionValues) +} + +// securityGroupEthertypeValidator is used to validate Ethertype field +func securityGroupEthertypeValidator(fe validator.FieldLevel) bool { + fieldValue := fe.Field().String() + + return IsInSlice(fieldValue, securityGroupEthertypeValues) +} + +// securityGroupProtocolValidator is used to validate Protocol field +func securityGroupProtocolValidator(fe validator.FieldLevel) bool { + fieldValue := fe.Field().String() + + return IsInSlice(fieldValue, securityGroupProtocolValues) +} + // computeOrderValidator is used to validate Order field. func computeOrderValidator(fe validator.FieldLevel) bool { fieldSlice, ok := fe.Field().Interface().([]string) @@ -206,22 +214,6 @@ func imageTypeValidator(fe validator.FieldLevel) bool { return IsInSlice(fieldValue, imageTypeValues) } -// imageDriversValidator is used to validate Drivers field. -func imageDriversValidator(fe validator.FieldLevel) bool { - fieldSlice, ok := fe.Field().Interface().([]string) - if !ok { - return false - } - - for _, item := range fieldSlice { - if !IsInSlice(item, imageDriversValues) { - return false - } - } - - return true -} - // imageArchitectureValidator is used to validate Architecture field. func imageArchitectureValidator(fe validator.FieldLevel) bool { fieldValue := fe.Field().String() @@ -414,6 +406,12 @@ func languageValidator(fe validator.FieldLevel) bool { return IsInSlice(fieldValue, languageValues) } +func userProviderValidator(fe validator.FieldLevel) bool { + fieldValue := fe.Field().String() + + return IsInSlice(fieldValue, userProviders) +} + // sepTypeValidator is used to validate sepType fields func sepTypeValidator(fe validator.FieldLevel) bool { fieldValue := fe.Field().String() @@ -421,6 +419,13 @@ func sepTypeValidator(fe validator.FieldLevel) bool { return IsInSlice(fieldValue, sepTypeValues) } +// deviceValidator is used to validate extnet device fields +func deviceValidator(fe validator.FieldLevel) bool { + fieldValue := fe.Field().String() + + return IsInSlice(fieldValue, deviceValues) +} + // ValidateRAM checks if request contains RAM value that is positive integer divisible by divisibility passed. // It is recommended to pass constants.RAM_DIVISIBILITY as divisility arguement func ValidateRAM(r interfaces.RequestWithRAM, divisibility uint64) error { @@ -442,3 +447,13 @@ func ValidateRAM(r interfaces.RequestWithRAM, divisibility uint64) error { } return multierror.Join(errs...) } + +// trunkTagsValidator checks if trunk_tags is in range from 1 to 4095 +func trunkTagsValidator(fe validator.FieldLevel) bool { + fieldValue := fe.Field().String() + numFieldValue, err := strconv.ParseInt(fieldValue, 10, 64) + if err != nil { + return false + } + return uint64(numFieldValue) >= uint64(trunkTagsMin) && uint64(numFieldValue) <= uint64(trunkTagsMax) +} diff --git a/internal/validators/helper.go b/internal/validators/helper.go index 633b977..6f15e3f 100644 --- a/internal/validators/helper.go +++ b/internal/validators/helper.go @@ -3,7 +3,7 @@ package validators import ( "errors" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/multierror" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/multierror" "github.com/go-playground/validator/v10" ) diff --git a/internal/validators/messages.go b/internal/validators/messages.go index 9f558ef..09d1a77 100644 --- a/internal/validators/messages.go +++ b/internal/validators/messages.go @@ -28,12 +28,6 @@ func errorMessage(fe validator.FieldError) string { case "isBool": return fmt.Sprintf("%s %s: must be bool type", prefix, fe.Field()) - case "driver": - return fmt.Sprintf("%s %s must be one of the following: %s", - prefix, - fe.Field(), - joinValues(driverValues)) - case "accessType": return fmt.Sprintf("%s %s must be one of the following: %s", prefix, @@ -128,12 +122,6 @@ func errorMessage(fe validator.FieldError) string { fe.Field(), joinValues(computeDataDisksValues)) - case "computeDriver": - return fmt.Sprintf("%s %s must be one of the following: %s", - prefix, - fe.Field(), - joinValues(computeDriverValues)) - // Disk Validators case "diskType": return fmt.Sprintf("%s %s must be one of the following: %s", @@ -201,12 +189,6 @@ func errorMessage(fe validator.FieldError) string { fe.Field(), joinValues(imageTypeValues)) - case "imageDrivers": - return fmt.Sprintf("%s %s must contain only the following: %s", - prefix, - fe.Field(), - joinValues(imageDriversValues)) - case "imageArchitecture": return fmt.Sprintf("%s %s must be one of the following: %s", prefix, @@ -333,6 +315,44 @@ func errorMessage(fe validator.FieldError) string { prefix, fe.Field(), joinValues(sepTypeValues)) + + // user validators + case "userProvider": + return fmt.Sprintf("%s %s must be one of the following: %s", + prefix, + fe.Field(), + joinValues(userProviders)) + + // security group validators + case "securityGroupDirection": + return fmt.Sprintf("%s %s must be one of the following: %s", + prefix, + fe.Field(), + joinValues(securityGroupDirectionValues)) + + case "securityGroupEthertype": + return fmt.Sprintf("%s %s must be one of the following: %s", + prefix, + fe.Field(), + joinValues(securityGroupEthertypeValues)) + + case "securityGroupProtocol": + return fmt.Sprintf("%s %s must be one of the following: %s", + prefix, + fe.Field(), + joinValues(securityGroupProtocolValues)) + + // trunk tags validator + case "trunkTags": + return fmt.Sprintf("%s %s must be in range from 1 to 4095", + prefix, + fe.Field()) + + case "device": + return fmt.Sprintf("%s %s must be one of the following: %s", + prefix, + fe.Field(), + joinValues(deviceValues)) } return fe.Error() diff --git a/internal/validators/validator.go b/internal/validators/validator.go index 5e9cf29..9a21cc6 100644 --- a/internal/validators/validator.go +++ b/internal/validators/validator.go @@ -31,11 +31,6 @@ func registerAllValidators(validate *validator.Validate) error { return err } - err = validate.RegisterValidation("computeDriver", computeDriverValidator) - if err != nil { - return err - } - err = validate.RegisterValidation("apiGroup", apiGroupValidator) if err != nil { return err @@ -51,11 +46,6 @@ func registerAllValidators(validate *validator.Validate) error { return err } - err = validate.RegisterValidation("driver", driverValidator) - if err != nil { - return err - } - err = validate.RegisterValidation("imageBootType", imageBootTypeValidator) if err != nil { return err @@ -66,11 +56,6 @@ func registerAllValidators(validate *validator.Validate) error { return err } - err = validate.RegisterValidation("imageDrivers", imageDriversValidator) - if err != nil { - return err - } - err = validate.RegisterValidation("imageArchitecture", imageArchitectureValidator) if err != nil { return err @@ -281,10 +266,40 @@ func registerAllValidators(validate *validator.Validate) error { return err } + err = validate.RegisterValidation("userProvider", userProviderValidator) + if err != nil { + return err + } + err = validate.RegisterValidation("sepType", sepTypeValidator) if err != nil { return err } + err = validate.RegisterValidation("device", deviceValidator) + if err != nil { + return err + } + + err = validate.RegisterValidation("trunkTags", trunkTagsValidator) + if err != nil { + return err + } + + err = validate.RegisterValidation("securityGroupDirection", securityGroupDirectionValidator) + if err != nil { + return err + } + + err = validate.RegisterValidation("securityGroupEthertype", securityGroupEthertypeValidator) + if err != nil { + return err + } + + err = validate.RegisterValidation("securityGroupProtocol", securityGroupProtocolValidator) + if err != nil { + return err + } + return nil } diff --git a/internal/validators/values.go b/internal/validators/values.go index 1d30630..5e1802e 100644 --- a/internal/validators/values.go +++ b/internal/validators/values.go @@ -3,7 +3,6 @@ package validators var ( apiGroupValues = []string{"cloudapi", "cloudbroker", "system"} - driverValues = []string{"KVM_X86"} accessTypeValues = []string{"R", "RCX", "ARCXDU"} resTypesValues = []string{"compute", "vins", "k8s", "openshift", "lb", "flipgroup"} protoValues = []string{"tcp", "udp"} @@ -17,17 +16,16 @@ var ( computeModeValues = []string{"EQ", "EN", "ANY"} computeDiskTypeValues = []string{"D", "B"} computeNetTypeValues = []string{"EXTNET", "VINS"} - computex86NetTypeValues = []string{"EXTNET", "VINS", "VFNIC", "DPDK"} + computex86NetTypeValues = []string{"EXTNET", "VINS", "VFNIC", "DPDK", "SDN", "EMPTY", "TRUNK"} computeOrderValues = []string{"cdrom", "network", "hd"} computeDataDisksValues = []string{"KEEP", "DETACH", "DESTROY"} - computeDriverValues = []string{"KVM_X86", "SVA_KVM_X86"} diskTypeValues = []string{"B", "T", "D"} flipgroupClientTypeValues = []string{"compute", "vins"} kvmNetTypeValues = []string{"EXTNET", "VINS", "NONE"} - kvmx86NetTypeValues = []string{"EXTNET", "VINS", "NONE", "VFNIC", "DPDK"} + kvmx86NetTypeValues = []string{"EXTNET", "VINS", "EMPTY", "VFNIC", "DPDK", "SDN", "TRUNK"} lbAlgorithmValues = []string{"roundrobin", "static-rr", "leastconn"} @@ -38,7 +36,6 @@ var ( imageBootTypeValues = []string{"uefi", "bios"} imageTypeValues = []string{"windows", "linux", "unknown"} - imageDriversValues = []string{"KVM_X86"} imageArchitectureValues = []string{"X86_64"} sepFieldTypeValues = []string{"int", "str", "bool", "list", "dict"} @@ -49,11 +46,11 @@ var ( interfaceStateValues = []string{"on", "off"} - actionValues = []string{"power_on", "shutdown", "force_shutdown", "reboot"} + actionValues = []string{"is_powered", "power_on", "shutdown", "force_shutdown", "reboot"} vmActionValues = []string{"stop", "move"} - computeFeaturesValues = []string{"hugepages", "numa", "cpupin", "vfnic", "dpdk", "changemac"} + computeFeaturesValues = []string{"hugepages", "numa", "cpupin", "vfnic", "dpdk", "changemac", "trunk"} networkInterfaceNamingValues = []string{"eth", "ens"} @@ -72,10 +69,20 @@ var ( sepTypeValues = []string{"hitachi", "dorado", "tatlin", "shared", "local", "des"} languageValues = []string{"ru", "en"} + + userProviders = []string{"bvs", "decs3o"} + + deviceValues = []string{"primary", "secondary"} + + securityGroupDirectionValues = []string{"inbound", "outbound"} + securityGroupEthertypeValues = []string{"IPv4", "IPv6"} + securityGroupProtocolValues = []string{"icmp", "tcp", "udp"} ) const ( mtuMin = 1 - mtuMax = 9216 + + trunkTagsMin = 1 + trunkTagsMax = 4095 ) diff --git a/legacy-client.go b/legacy-client.go index 4a49447..b31db96 100644 --- a/legacy-client.go +++ b/legacy-client.go @@ -4,6 +4,7 @@ import ( "bytes" "context" "crypto/tls" + "encoding/json" "fmt" "io" "net/http" @@ -13,10 +14,10 @@ import ( "time" "github.com/google/go-querystring/query" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/config" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/constants" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/pkg/cloudapi" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/pkg/cloudbroker" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/config" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/constants" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/pkg/cloudapi" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/pkg/cloudbroker" ) // LegacyDecortClient is Legacy HTTP-client for platform @@ -102,6 +103,47 @@ func (ldc *LegacyDecortClient) DecortApiCall(ctx context.Context, method, url st return respBytes, err } +// DecortApiCallCtype method for sending requests to the platform with content type +func (ldc *LegacyDecortClient) DecortApiCallCtype(ctx context.Context, method, url, ctype string, params interface{}) ([]byte, error) { + // get token + if err := ldc.getToken(ctx); err != nil { + return nil, err + } + + var body *bytes.Buffer + + switch ctype { + case constants.MIMESTREAM: + body = bytes.NewBuffer(params.([]byte)) + case constants.MIMEJSON: + jsonBody, err := json.Marshal(params) + if err != nil { + return nil, err + } + body = bytes.NewBuffer(jsonBody) + default: + ctype = constants.MIMEPOSTForm + values, err := query.Values(params) + if err != nil { + return nil, err + } + body = bytes.NewBufferString(values.Encode() + fmt.Sprintf("&authkey=%s", ldc.cfg.Token)) + } + + req, err := http.NewRequestWithContext(ctx, method, ldc.decortURL+constants.RESTMACHINE+url, body) + if err != nil { + return nil, err + } + + // perform request + respBytes, err := ldc.do(req, ctype) + if err != nil { + return nil, err + } + + return respBytes, err +} + func (ldc *LegacyDecortClient) DecortApiCallMP(ctx context.Context, method, url string, params interface{}) ([]byte, error) { body, ctype, err := multiPartReq(params) if err != nil { diff --git a/pkg/cloudapi/account.go b/pkg/cloudapi/account.go index da15e3e..f6ebc70 100644 --- a/pkg/cloudapi/account.go +++ b/pkg/cloudapi/account.go @@ -1,7 +1,7 @@ package cloudapi import ( - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/pkg/cloudapi/account" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/pkg/cloudapi/account" ) // Accessing the Account method group diff --git a/pkg/cloudapi/account/account.go b/pkg/cloudapi/account/account.go index 6a21575..813ba29 100644 --- a/pkg/cloudapi/account/account.go +++ b/pkg/cloudapi/account/account.go @@ -2,7 +2,7 @@ package account import ( - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/interfaces" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/interfaces" ) // Structure for creating request to account diff --git a/pkg/cloudapi/account/add_user.go b/pkg/cloudapi/account/add_user.go index c90a19d..223d3f3 100644 --- a/pkg/cloudapi/account/add_user.go +++ b/pkg/cloudapi/account/add_user.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // AddUserRequest struct to add permission to access account for a user diff --git a/pkg/cloudapi/account/audits.go b/pkg/cloudapi/account/audits.go index 36a0510..152a8f6 100644 --- a/pkg/cloudapi/account/audits.go +++ b/pkg/cloudapi/account/audits.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // AuditsRequest struct to give list of account audits diff --git a/pkg/cloudapi/account/delete.go b/pkg/cloudapi/account/delete.go index ebcf121..84d3ca8 100644 --- a/pkg/cloudapi/account/delete.go +++ b/pkg/cloudapi/account/delete.go @@ -4,7 +4,7 @@ import ( "context" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // DeleteRequest struct to delete account @@ -19,18 +19,18 @@ type DeleteRequest struct { } // 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) (bool, error) { +func (a Account) Delete(ctx context.Context, req DeleteRequest) (string, error) { err := validators.ValidateRequest(req) if err != nil { - return false, validators.ValidationErrors(validators.GetErrors(err)) + return "", validators.ValidationErrors(validators.GetErrors(err)) } url := "/cloudapi/account/delete" - _, err = a.client.DecortApiCall(ctx, http.MethodPost, url, req) + result, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req) if err != nil { - return false, err + return "", err } - return true, nil + return string(result), nil } diff --git a/pkg/cloudapi/account/delete_user.go b/pkg/cloudapi/account/delete_user.go index 06e6794..b5f2ccb 100644 --- a/pkg/cloudapi/account/delete_user.go +++ b/pkg/cloudapi/account/delete_user.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // DeleteUserRequest struct to revoke access to account diff --git a/pkg/cloudapi/account/disable_enable.go b/pkg/cloudapi/account/disable_enable.go index 6d93f0f..eea6b06 100644 --- a/pkg/cloudapi/account/disable_enable.go +++ b/pkg/cloudapi/account/disable_enable.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // DisableEnableRequest struct to change status of account @@ -13,10 +13,6 @@ type DisableEnableRequest struct { // ID of account // Required: true AccountID uint64 `url:"accountId" json:"accountId" validate:"required"` - - // Reason of disabling - // Required: false - Reason string `url:"reason,omitempty" json:"reason,omitempty"` } // Disable disables an account diff --git a/pkg/cloudapi/account/filter_test.go b/pkg/cloudapi/account/filter_test.go index b1e7f9f..05da015 100644 --- a/pkg/cloudapi/account/filter_test.go +++ b/pkg/cloudapi/account/filter_test.go @@ -7,7 +7,7 @@ import ( var accounts = ListAccounts{ Data: []ItemAccount{ { - ACL: []RecordACL{ + ACL: []ListRecordACL{ { IsExplicit: true, GUID: "", @@ -25,7 +25,7 @@ var accounts = ListAccounts{ UpdatedTime: 1676645275, }, { - ACL: []RecordACL{ + ACL: []ListRecordACL{ { IsExplicit: true, GUID: "", @@ -43,7 +43,7 @@ var accounts = ListAccounts{ UpdatedTime: 1676645275, }, { - ACL: []RecordACL{ + ACL: []ListRecordACL{ { IsExplicit: true, GUID: "", diff --git a/pkg/cloudapi/account/get.go b/pkg/cloudapi/account/get.go index d7b5efc..07fbf29 100644 --- a/pkg/cloudapi/account/get.go +++ b/pkg/cloudapi/account/get.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // GetRequest struct to get information about account diff --git a/pkg/cloudapi/account/get_consumed_account_units.go b/pkg/cloudapi/account/get_consumed_account_units.go index 31b0c00..f0bf158 100644 --- a/pkg/cloudapi/account/get_consumed_account_units.go +++ b/pkg/cloudapi/account/get_consumed_account_units.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // GetConsumedAccountUnitsRequest struct to calculate the currently consumed units for all cloudspaces and resource groups in the account diff --git a/pkg/cloudapi/account/get_consumed_cloud_units_by_type.go b/pkg/cloudapi/account/get_consumed_cloud_units_by_type.go index 82d9ea0..47fc16b 100644 --- a/pkg/cloudapi/account/get_consumed_cloud_units_by_type.go +++ b/pkg/cloudapi/account/get_consumed_cloud_units_by_type.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // GetConsumedCloudUnitsByTypeRequest struct to calculate the currently consumed cloud units of the specified type for all cloudspaces and resource groups in the account diff --git a/pkg/cloudapi/account/get_reserved_account_units.go b/pkg/cloudapi/account/get_reserved_account_units.go index 1137feb..70111ee 100644 --- a/pkg/cloudapi/account/get_reserved_account_units.go +++ b/pkg/cloudapi/account/get_reserved_account_units.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // GetReservedAccountUnitsRequest struct to calculate the reserved units for all cloudspaces and resource groups in the account diff --git a/pkg/cloudapi/account/get_resource_consumption.go b/pkg/cloudapi/account/get_resource_consumption.go index 2f59fac..4572f8e 100644 --- a/pkg/cloudapi/account/get_resource_consumption.go +++ b/pkg/cloudapi/account/get_resource_consumption.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // GetResourceConsumptionRequest struct to get resource consumption diff --git a/pkg/cloudapi/account/list.go b/pkg/cloudapi/account/list.go index 2bbd105..fa19c9e 100644 --- a/pkg/cloudapi/account/list.go +++ b/pkg/cloudapi/account/list.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ListRequest struct to get list of accounts @@ -30,6 +30,11 @@ type ListRequest struct { // Required: false SortBy string `url:"sortBy,omitempty" json:"sortBy,omitempty" validate:"omitempty,sortBy"` + // Sort by zone id + // Default value: 0 + // Required: false + ZoneID uint64 `url:"zone_id,omitempty" json:"zone_id,omitempty"` + // Page number // Required: false Page uint64 `url:"page,omitempty" json:"page,omitempty"` diff --git a/pkg/cloudapi/account/list_computes.go b/pkg/cloudapi/account/list_computes.go index 2ca60e6..f99058e 100644 --- a/pkg/cloudapi/account/list_computes.go +++ b/pkg/cloudapi/account/list_computes.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ListComputesRequest struct to get a list of compute instances diff --git a/pkg/cloudapi/account/list_deleted.go b/pkg/cloudapi/account/list_deleted.go index 8d76a48..2c06d32 100644 --- a/pkg/cloudapi/account/list_deleted.go +++ b/pkg/cloudapi/account/list_deleted.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ListDeletedRequest struct to get a list of deleted accounts diff --git a/pkg/cloudapi/account/list_disks.go b/pkg/cloudapi/account/list_disks.go index 6ee8476..561eaac 100644 --- a/pkg/cloudapi/account/list_disks.go +++ b/pkg/cloudapi/account/list_disks.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ListDisksRequest struct to get a list of deleted disks diff --git a/pkg/cloudapi/account/list_flipgroups.go b/pkg/cloudapi/account/list_flipgroups.go index fb9dfd3..8e60ebc 100644 --- a/pkg/cloudapi/account/list_flipgroups.go +++ b/pkg/cloudapi/account/list_flipgroups.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ListFLIPGroupsRequest struct to get a list of FLIPGroups diff --git a/pkg/cloudapi/account/list_rg.go b/pkg/cloudapi/account/list_rg.go index f3b97a1..447c8af 100644 --- a/pkg/cloudapi/account/list_rg.go +++ b/pkg/cloudapi/account/list_rg.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ListRGRequest struct to get a list of resource groups diff --git a/pkg/cloudapi/account/list_templates.go b/pkg/cloudapi/account/list_templates.go index 2eadd95..2a19130 100644 --- a/pkg/cloudapi/account/list_templates.go +++ b/pkg/cloudapi/account/list_templates.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ListTemplatesRequest struct to get a list of templates diff --git a/pkg/cloudapi/account/list_vins.go b/pkg/cloudapi/account/list_vins.go index 8a7163b..5765ec9 100644 --- a/pkg/cloudapi/account/list_vins.go +++ b/pkg/cloudapi/account/list_vins.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ListVINSRequest struct to get a list of VINS diff --git a/pkg/cloudapi/account/models.go b/pkg/cloudapi/account/models.go index 019058e..f72e377 100644 --- a/pkg/cloudapi/account/models.go +++ b/pkg/cloudapi/account/models.go @@ -1,7 +1,34 @@ package account +// Access Control List +type ListRecordACL struct { + // Whether access is explicitly specified + IsExplicit bool `json:"explicit"` + + // GUID + GUID string `json:"guid"` + + // Access rights + Rights string `json:"right"` + + // Status + Status string `json:"status"` + + // Account Type + Type string `json:"type"` + + // Account owner ID + UgroupID string `json:"userGroupId"` + + // Is it possible to remove + CanBeDeleted bool `json:"canBeDeleted"` +} + // Access Control List type RecordACL struct { + // Emails + Emails []string `json:"emails"` + // Whether access is explicitly specified IsExplicit bool `json:"explicit"` @@ -46,12 +73,21 @@ type ResourceLimits struct { // Number of graphics cores GPUUnits float64 `json:"gpu_units"` + + // Storage policy + StoragePolicy []StoragePolicyItem `json:"storage_policy"` +} + +type StoragePolicyItem struct { + ID uint64 `json:"id"` + + Limit int `json:"limit"` } // Main information in one of if the list of accounts type ItemAccount struct { // Access Control List - ACL []RecordACL `json:"acl"` + ACL []ListRecordACL `json:"acl"` // Compute Features ComputeFeatures []string `json:"computeFeatures"` @@ -76,6 +112,9 @@ type ItemAccount struct { // Updated time UpdatedTime uint64 `json:"updatedTime"` + + // Zones + ZoneIDs []uint64 `json:"zoneIds"` } // List of accounts @@ -85,6 +124,18 @@ type ListAccounts struct { EntryCount uint64 `json:"entryCount"` } +// Policy +type Policy struct { + // Size of the disk + DiskSize float64 `json:"disksize"` + + // Max size of the disk + DiskSizeMax float64 `json:"disksizemax"` + + // SEPs used + SEPs map[string]map[string]DiskUsage `json:"seps"` +} + // Resources used type Resource struct { // Number of cores @@ -105,6 +156,9 @@ type Resource struct { // Number of grafic cores GPU int64 `json:"gpu"` + // Policies + Policies map[string]Policy `json:"policies"` + // Number of RAM RAM int64 `json:"ram"` @@ -165,14 +219,20 @@ type Machines struct { Halted uint64 `json:"halted"` } +// Detailed information about the account zone +type ZoneID struct { + // ID of zone + ID int64 `json:"id"` + + // Name of zone + Name string `json:"name"` +} + // Main information about account type RecordAccount struct { // DCLocation DCLocation string `json:"DCLocation"` - // CKey - CKey string `json:"_ckey"` - // Access control list ACL []RecordACL `json:"acl"` @@ -239,6 +299,9 @@ type RecordAccount struct { // Status Status string `json:"status"` + // Storage policy ids + StoragePolicyIDs []uint64 `json:"storage_policy_ids"` + // UniqPools UniqPools []interface{} `json:"uniqPools"` @@ -253,6 +316,12 @@ type RecordAccount struct { // VINSes VINSes uint64 `json:"vinses"` + + // Zone + ZoneIDs []ZoneID `json:"zoneIds"` + + // Zones + DefaultZoneID uint64 `json:"defaultZoneId"` } // Main information about compute diff --git a/pkg/cloudapi/account/restore.go b/pkg/cloudapi/account/restore.go index 1c08481..1df6dd7 100644 --- a/pkg/cloudapi/account/restore.go +++ b/pkg/cloudapi/account/restore.go @@ -4,7 +4,7 @@ import ( "context" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // RestoreRequest struct to restore a deleted account @@ -15,18 +15,18 @@ type RestoreRequest struct { } // Restore restores a deleted account -func (a Account) Restore(ctx context.Context, req RestoreRequest) (bool, error) { +func (a Account) Restore(ctx context.Context, req RestoreRequest) (string, error) { err := validators.ValidateRequest(req) if err != nil { - return false, validators.ValidationErrors(validators.GetErrors(err)) + return "", validators.ValidationErrors(validators.GetErrors(err)) } url := "/cloudapi/account/restore" - _, err = a.client.DecortApiCall(ctx, http.MethodPost, url, req) + result, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req) if err != nil { - return false, err + return "", err } - return true, nil + return string(result), nil } diff --git a/pkg/cloudapi/account/serialize.go b/pkg/cloudapi/account/serialize.go index 55d3141..ceffb4e 100644 --- a/pkg/cloudapi/account/serialize.go +++ b/pkg/cloudapi/account/serialize.go @@ -3,7 +3,7 @@ package account import ( "encoding/json" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/serialization" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/serialization" ) // Serialize returns JSON-serialized []byte. Used as a wrapper over json.Marshal and json.MarshalIndent functions. diff --git a/pkg/cloudapi/account/update.go b/pkg/cloudapi/account/update.go index 94d3691..284614d 100644 --- a/pkg/cloudapi/account/update.go +++ b/pkg/cloudapi/account/update.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // UpdateRequest struct to update account @@ -54,6 +54,10 @@ type UpdateRequest struct { // i.e.: ["sep1_poolName1", "sep2_poolName2", etc] // Required: false UniqPools []string `url:"uniqPools,omitempty" json:"uniqPools,omitempty"` + + // Default zone ID + // Required: false + DefaultZoneID uint64 `url:"defaultZoneId,omitempty" json:"defaultZoneId,omitempty"` } // Update updates an account name and resource types and limits diff --git a/pkg/cloudapi/account/update_user.go b/pkg/cloudapi/account/update_user.go index 35013c6..67d266e 100644 --- a/pkg/cloudapi/account/update_user.go +++ b/pkg/cloudapi/account/update_user.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // UpdateUserRequest struct to update user access rights diff --git a/pkg/cloudapi/audit.go b/pkg/cloudapi/audit.go index a101f58..386e38d 100644 --- a/pkg/cloudapi/audit.go +++ b/pkg/cloudapi/audit.go @@ -1,7 +1,7 @@ package cloudapi import ( - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/pkg/cloudapi/audit" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/pkg/cloudapi/audit" ) // Accessing the Stack method group diff --git a/pkg/cloudapi/audit/audit.go b/pkg/cloudapi/audit/audit.go index b2647e8..2ac3412 100644 --- a/pkg/cloudapi/audit/audit.go +++ b/pkg/cloudapi/audit/audit.go @@ -1,6 +1,6 @@ package audit -import "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/interfaces" +import "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/interfaces" // Structure for creating request to audit type Audit struct { diff --git a/pkg/cloudapi/audit/filter.go b/pkg/cloudapi/audit/filter.go new file mode 100644 index 0000000..82f80e6 --- /dev/null +++ b/pkg/cloudapi/audit/filter.go @@ -0,0 +1,81 @@ +package audit + +// FilterByID returns ListAudits with specified ID. +func (la ListAudits) FilterByID(guid string) ListAudits { + predicate := func(ia ItemAudit) bool { + return ia.GUID == guid + } + + return la.FilterFunc(predicate) +} + +// FilterByCall returns ListAudits with specified call. +func (la ListAudits) FilterByCall(call string) ListAudits { + predicate := func(ic ItemAudit) bool { + return ic.Call == call + } + + return la.FilterFunc(predicate) +} + +// FilterByCorrelationID returns ListAudits with specified correlation id. +func (la ListAudits) FilterByCorrelationID(correlationID string) ListAudits { + predicate := func(ic ItemAudit) bool { + return ic.CorrelationID == correlationID + } + + return la.FilterFunc(predicate) +} + +// FilterByRemoteAddr returns ListAudits with specified remote address. +func (la ListAudits) FilterByRemoteAddr(remoteAddr string) ListAudits { + predicate := func(ic ItemAudit) bool { + return ic.RemoteAddr == remoteAddr + } + + return la.FilterFunc(predicate) +} + +// FilterByUser returns ListAudits with specified user name. +func (la ListAudits) FilterByUser(user string) ListAudits { + predicate := func(ic ItemAudit) bool { + return ic.User == user + } + + return la.FilterFunc(predicate) +} + +// FilterByStatusCode return ListAudits with specified status code. +func (la ListAudits) FilterByStatusCode(statusCode uint64) ListAudits { + predicate := func(ic ItemAudit) bool { + return ic.StatusCode == statusCode + } + + return la.FilterFunc(predicate) + +} + +// FilterFunc allows filtering ListAudits based on a user-specified predicate. +func (la ListAudits) FilterFunc(predicate func(ItemAudit) bool) ListAudits { + var result ListAudits + + for _, item := range la.Data { + if predicate(item) { + result.Data = append(result.Data, item) + } + } + + result.EntryCount = uint64(len(result.Data)) + + return result +} + +// FindOne returns first found ItemAudit +// If none was found, returns an empty struct. +func (la ListAudits) FindOne() ItemAudit { + if len(la.Data) == 0 { + return ItemAudit{} + } + + return la.Data[0] +} diff --git a/pkg/cloudapi/audit/filter_test.go b/pkg/cloudapi/audit/filter_test.go new file mode 100644 index 0000000..8f09a1b --- /dev/null +++ b/pkg/cloudapi/audit/filter_test.go @@ -0,0 +1,115 @@ +package audit + +import ( + "testing" +) + +var audits = ListAudits{ + Data: []ItemAudit{ + { + Args: "[]", + Call: "/restmachine/cloudapi/audit/linkedJobs", + GUID: "550e8400-e29b-41d4-a716-446655440001", + CorrelationID: "550e8400-e29b-41d4-a716-446655440001", + Kwargs: `{\"audit_guid\":\"dd8623a1-a887-48c1-a500-c10210d404cf\"}`, + RemoteAddr: "192.168.1.100", + ResponseTime: 1, + Result: `[]`, + StatusCode: 200, + Timestamp: 1640995200, + TimestampEnd: 1640995201, + User: "test@example.com", + TTL: "2025-07-31T14:22:57.028000", + }, + { + Args: "[]", + Call: "/restmachine/cloudapi/audit/test", + GUID: "550e8400-e29b-41d4-a716-446655440002", + CorrelationID: "550e8400-e29b-41d4-a716-446655440002", + Kwargs: `{\"audit_guid\":\"dd8623a1-a887-48c1-a500-c10210d404cf\"}`, + RemoteAddr: "192.168.1.105", + ResponseTime: 5, + Result: `[]`, + StatusCode: 400, + Timestamp: 1640995200, + TimestampEnd: 1640995201, + User: "test2@example.com", + TTL: "2025-07-31T14:22:57.028000", + }, + }, + EntryCount: 2, +} + +func TestFilterByID(t *testing.T) { + actual := audits.FilterByID("550e8400-e29b-41d4-a716-446655440002").FindOne() + + if actual.GUID != "550e8400-e29b-41d4-a716-446655440002" { + t.Fatal("expected GUID 550e8400-e29b-41d4-a716-446655440002, found: ", actual.GUID) + } + + actualEmpty := audits.FilterByID("") + + if len(actualEmpty.Data) != 0 { + t.Fatal("expected empty, actual: ", len(actualEmpty.Data)) + } +} + +func TestFilterByCorrelationID(t *testing.T) { + actual := audits.FilterByCorrelationID("550e8400-e29b-41d4-a716-446655440002").FindOne() + + if actual.CorrelationID != "550e8400-e29b-41d4-a716-446655440002" { + t.Fatal("expected GUID 550e8400-e29b-41d4-a716-446655440002, found: ", actual.CorrelationID) + } + + actualEmpty := audits.FilterByCorrelationID("") + + if len(actualEmpty.Data) != 0 { + t.Fatal("expected empty, actual: ", len(actualEmpty.Data)) + } +} + +func TestFilterByRemoteAddr(t *testing.T) { + actual := audits.FilterByRemoteAddr("192.168.1.100").FindOne() + + if actual.RemoteAddr != "192.168.1.100" { + t.Fatal("expected remote address 192.168.1.100, found: ", actual.RemoteAddr) + } + + actualEmpty := audits.FilterByRemoteAddr("") + + if len(actualEmpty.Data) != 0 { + t.Fatal("expected empty, actual: ", len(actualEmpty.Data)) + } +} + +func TestFilterByUser(t *testing.T) { + actual := audits.FilterByUser("test@example.com").FindOne() + + if actual.User != "test@example.com" { + t.Fatal("expected user test@example.com, found: ", actual.RemoteAddr) + } + + actualEmpty := audits.FilterByUser("") + + if len(actualEmpty.Data) != 0 { + t.Fatal("expected empty, actual: ", len(actualEmpty.Data)) + } +} + +func TestFilterByCall(t *testing.T) { + actual := audits.FilterByCall("/restmachine/cloudapi/audit/test").FindOne() + + if actual.Call != "/restmachine/cloudapi/audit/test" { + t.Fatal("expected call /restmachine/cloudapi/audit/test, found: ", actual.Call) + } +} + +func TestFilterByStatusCode(t *testing.T) { + actual := audits.FilterByStatusCode(200) + + for _, item := range actual.Data { + if item.StatusCode != 200 { + t.Fatal("expected 200 status code, found: ", item.StatusCode) + } + } +} diff --git a/pkg/cloudapi/audit/get.go b/pkg/cloudapi/audit/get.go index 0b976b5..5670f5d 100644 --- a/pkg/cloudapi/audit/get.go +++ b/pkg/cloudapi/audit/get.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // GetRequest struct to get information about account diff --git a/pkg/cloudapi/audit/list.go b/pkg/cloudapi/audit/list.go new file mode 100644 index 0000000..26c68f6 --- /dev/null +++ b/pkg/cloudapi/audit/list.go @@ -0,0 +1,124 @@ +package audit + +import ( + "context" + "encoding/json" + "net/http" + + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" +) + +// ListRequest struct to give list of account audits +type ListRequest struct { + + // Find all audits after point in time (unixtime) + // Required: false + TimestampAt uint64 `url:"timestamp_at,omitempty" json:"timestamp_at,omitempty"` + + // Find all audits before point in time (unixtime) + // Required: false + TimestampTo uint64 `url:"timestamp_to,omitempty" json:"timestamp_to,omitempty"` + + // Find by user (Mongo RegExp supported) + // Required: false + User string `url:"user,omitempty" json:"user,omitempty"` + + // Find by api endpoint (Mongo RegExp supported) + // Required: false + Call string `url:"call,omitempty" json:"call,omitempty"` + + // Find by request id + // Required: false + RequestID string `url:"request_id,omitempty" json:"request_id,omitempty"` + + // Find by HTTP min status code + // Required: false + MinStatusCode uint64 `url:"min_status_code,omitempty" json:"min_status_code,omitempty"` + + // Find by HTTP max status code + // Required: false + MaxStatusCode uint64 `url:"max_status_code,omitempty" json:"max_status_code,omitempty"` + + // Sort by one of supported fields, format +|-(field) + // Required: false + SortBy string `url:"sort_by,omitempty" json:"sort_by,omitempty" validate:"omitempty,sortBy"` + + // Page number + // Required: false + Page uint64 `url:"page,omitempty" json:"page,omitempty"` + + // Page size + // Required: false + Size uint64 `url:"size,omitempty" json:"size,omitempty"` + + // Find by resource group id + // Required: false + RGID uint64 `url:"resgroup_id,omitempty" json:"resgroup_id,omitempty"` + + // Find by compute id + // Required: false + ComputeID uint64 `url:"compute_id,omitempty" json:"compute_id,omitempty"` + + // Find by account id + // Required: false + AccountID uint64 `url:"account_id,omitempty" json:"account_id,omitempty"` + + // Find by vins id + // Required: false + VINSID uint64 `url:"vins_id,omitempty" json:"vins_id,omitempty"` + + // Find by service id + // Required: false + ServiceID uint64 `url:"service_id,omitempty" json:"service_id,omitempty"` + + // Find by k8s id + // Required: false + K8SID uint64 `url:"k8s_id,omitempty" json:"k8s_id,omitempty"` + + // Find by flipgroup id + // Required: false + FLIPGroupID uint64 `url:"flipgroup_id,omitempty" json:"flipgroup_id,omitempty"` + + // Find by load balancer id + // Required: false + LBID uint64 `url:"lb_id,omitempty" json:"lb_id,omitempty"` + + // Find by sep id + // Required: false + SEPID uint64 `url:"sep_id,omitempty" json:"sep_id,omitempty"` + + // Exclude audit lines from response + // Required: false + ExcludeAuditLines bool `url:"exclude_audit_lines,omitempty" json:"exclude_audit_lines,omitempty"` +} + +// List gets audit records for the specified account object +func (a Audit) List(ctx context.Context, req ListRequest) (*ListAudits, error) { + + res, err := a.ListRaw(ctx, req) + if err != nil { + return nil, err + } + + list := ListAudits{} + + err = json.Unmarshal(res, &list) + if err != nil { + return nil, err + } + + return &list, nil +} + +// ListRaw gets list of audit records an array of bytes +func (a Audit) ListRaw(ctx context.Context, req ListRequest) ([]byte, error) { + + if err := validators.ValidateRequest(req); err != nil { + return nil, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudapi/audit/list" + + res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req) + return res, err +} diff --git a/pkg/cloudapi/audit/models.go b/pkg/cloudapi/audit/models.go index 8bb0ef0..98626cf 100644 --- a/pkg/cloudapi/audit/models.go +++ b/pkg/cloudapi/audit/models.go @@ -12,6 +12,9 @@ type RecordAudit struct { // GUID GUID string `json:"guid"` + // Correlation ID + CorrelationID string `json:"correlation_id"` + // Kwargs Kwargs string `json:"kwargs"` @@ -39,3 +42,54 @@ type RecordAudit struct { // User User string `json:"user"` } + +// Main info about audit +type ItemAudit struct { + // Args + Args string `json:"args"` + + // Call + Call string `json:"call"` + + // GUID + GUID string `json:"guid"` + + // Correlation ID + CorrelationID string `json:"correlation_id"` + + // Kwargs + Kwargs string `json:"kwargs"` + + // RemoteAddr + RemoteAddr string `json:"remote_addr"` + + // Response time + ResponseTime float64 `json:"responsetime"` + + // Result + Result string `json:"result"` + + // Status code + StatusCode uint64 `json:"statuscode"` + + // Timestamp + Timestamp float64 `json:"timestamp"` + + // Timestamp End + TimestampEnd float64 `json:"timestampEnd"` + + // User + User string `json:"user"` + + // TTL + TTL string `json:"_ttl"` +} + +// List of audits +type ListAudits struct { + // Data + Data []ItemAudit `json:"data"` + + // EntryCount + EntryCount uint64 `json:"entryCount"` +} diff --git a/pkg/cloudapi/bservice.go b/pkg/cloudapi/bservice.go index 815579e..bed0f0d 100644 --- a/pkg/cloudapi/bservice.go +++ b/pkg/cloudapi/bservice.go @@ -1,6 +1,6 @@ package cloudapi -import "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/pkg/cloudapi/bservice" +import "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/pkg/cloudapi/bservice" // Accessing the BService method group func (ca *CloudAPI) BService() *bservice.BService { diff --git a/pkg/cloudapi/bservice/bservice.go b/pkg/cloudapi/bservice/bservice.go index b2c91e4..58c76d6 100644 --- a/pkg/cloudapi/bservice/bservice.go +++ b/pkg/cloudapi/bservice/bservice.go @@ -1,7 +1,7 @@ // API Actor for managing Compute Group. This actor is a final API for endusers to manage Compute Group package bservice -import "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/interfaces" +import "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/interfaces" // Structure for creating request to bservice type BService struct { diff --git a/pkg/cloudapi/bservice/create.go b/pkg/cloudapi/bservice/create.go index 252cb8d..38e002f 100644 --- a/pkg/cloudapi/bservice/create.go +++ b/pkg/cloudapi/bservice/create.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // CreateRequest struct for BasicService @@ -25,6 +25,10 @@ type CreateRequest struct { // SSH key to deploy for the specified user. Same key will be deployed to all computes of the service // Required: false SSHKey string `url:"sshKey,omitempty" json:"sshKey,omitempty"` + + // Zone ID + // Required: false + ZoneID uint64 `url:"zoneId,omitempty" json:"zoneId,omitempty"` } // Create creates blank BasicService instance diff --git a/pkg/cloudapi/bservice/delete.go b/pkg/cloudapi/bservice/delete.go index b91cffc..c73f72e 100644 --- a/pkg/cloudapi/bservice/delete.go +++ b/pkg/cloudapi/bservice/delete.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // DeleteRequest struct to delete basic service @@ -16,6 +16,7 @@ type DeleteRequest struct { // If set to False, Basic service will be deleted to recycle bin. Otherwise destroyed immediately // Required: false + // Default: false Permanently bool `url:"permanently,omitempty" json:"permanently,omitempty"` } diff --git a/pkg/cloudapi/bservice/disable.go b/pkg/cloudapi/bservice/disable.go index e81dfb6..fe17625 100644 --- a/pkg/cloudapi/bservice/disable.go +++ b/pkg/cloudapi/bservice/disable.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // DisableRequest struct for disable service diff --git a/pkg/cloudapi/bservice/enable.go b/pkg/cloudapi/bservice/enable.go index 6b36878..fa88537 100644 --- a/pkg/cloudapi/bservice/enable.go +++ b/pkg/cloudapi/bservice/enable.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // EnableRequest struct to disable service diff --git a/pkg/cloudapi/bservice/get.go b/pkg/cloudapi/bservice/get.go index 27f23a5..4d6a8e1 100644 --- a/pkg/cloudapi/bservice/get.go +++ b/pkg/cloudapi/bservice/get.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // GetRequest struct to get detailed information about service diff --git a/pkg/cloudapi/bservice/group_add.go b/pkg/cloudapi/bservice/group_add.go index 2d3c516..29a94f9 100644 --- a/pkg/cloudapi/bservice/group_add.go +++ b/pkg/cloudapi/bservice/group_add.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // GroupAddRequest struct to create new compute group within BasicService @@ -38,11 +38,9 @@ type GroupAddRequest struct { // Required: true ImageID uint64 `url:"imageId" json:"imageId" validate:"required"` - // Compute driver - // should be one of: - // - KVM_X86 + // Compute driver like a KVM_X86, etc. // Required: true - Driver string `url:"driver" json:"driver" validate:"driver"` + Driver string `url:"driver" json:"driver" validate:"required"` // Storage endpoint provider ID // Required: false @@ -75,6 +73,10 @@ type GroupAddRequest struct { //Chipset "i440fx" or "Q35 //Required: false Chipset string `url:"chipset,omitempty" json:"chipset,omitempty" validate:"chipset,omitempty"` + + // ID of the chosen storage policy + // Required: false + StoragePolicyID uint64 `url:"storage_policy_id,omitempty" json:"storage_policy_id,omitempty"` } // GetRAM returns RAM field values diff --git a/pkg/cloudapi/bservice/group_compute_remove.go b/pkg/cloudapi/bservice/group_compute_remove.go index 76a7c66..f648795 100644 --- a/pkg/cloudapi/bservice/group_compute_remove.go +++ b/pkg/cloudapi/bservice/group_compute_remove.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // GroupComputeRemoveRequest struct to remove group compute diff --git a/pkg/cloudapi/bservice/group_get.go b/pkg/cloudapi/bservice/group_get.go index 405cd22..4dbf84b 100644 --- a/pkg/cloudapi/bservice/group_get.go +++ b/pkg/cloudapi/bservice/group_get.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // GroupGetRequest struct to get detailed information about Compute Group diff --git a/pkg/cloudapi/bservice/group_parent_add.go b/pkg/cloudapi/bservice/group_parent_add.go index 275e502..179a4f1 100644 --- a/pkg/cloudapi/bservice/group_parent_add.go +++ b/pkg/cloudapi/bservice/group_parent_add.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // GroupParentAddRequest struct to add parent Compute Group relation to the specified Compute Group diff --git a/pkg/cloudapi/bservice/group_parent_remove.go b/pkg/cloudapi/bservice/group_parent_remove.go index 131b9dd..b0d1808 100644 --- a/pkg/cloudapi/bservice/group_parent_remove.go +++ b/pkg/cloudapi/bservice/group_parent_remove.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // GroupParentRemoveRequest struct to remove parent Compute Group diff --git a/pkg/cloudapi/bservice/group_remove.go b/pkg/cloudapi/bservice/group_remove.go index 6525134..7d24c1c 100644 --- a/pkg/cloudapi/bservice/group_remove.go +++ b/pkg/cloudapi/bservice/group_remove.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // GroupRemoveRequest struct for destroy the specified Compute Group diff --git a/pkg/cloudapi/bservice/group_resize.go b/pkg/cloudapi/bservice/group_resize.go index 4eaf984..3fef36e 100644 --- a/pkg/cloudapi/bservice/group_resize.go +++ b/pkg/cloudapi/bservice/group_resize.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // GroupResizeRequest struct to resize the group diff --git a/pkg/cloudapi/bservice/group_start.go b/pkg/cloudapi/bservice/group_start.go index 4e612e8..9c5a2bc 100644 --- a/pkg/cloudapi/bservice/group_start.go +++ b/pkg/cloudapi/bservice/group_start.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // GroupStartRequest struct to start the specified Compute Group diff --git a/pkg/cloudapi/bservice/group_stop.go b/pkg/cloudapi/bservice/group_stop.go index bd11577..f01ad10 100644 --- a/pkg/cloudapi/bservice/group_stop.go +++ b/pkg/cloudapi/bservice/group_stop.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // GroupStopRequest struct to stop the specified Compute Group diff --git a/pkg/cloudapi/bservice/group_update.go b/pkg/cloudapi/bservice/group_update.go index 28c1e8c..4cb364b 100644 --- a/pkg/cloudapi/bservice/group_update.go +++ b/pkg/cloudapi/bservice/group_update.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // GroupUpdateRequest struct to update existing Compute group diff --git a/pkg/cloudapi/bservice/group_update_extnet.go b/pkg/cloudapi/bservice/group_update_extnet.go index 47f2961..7cd0973 100644 --- a/pkg/cloudapi/bservice/group_update_extnet.go +++ b/pkg/cloudapi/bservice/group_update_extnet.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // GroupUpdateExtNetRequest struct to update External Network settings diff --git a/pkg/cloudapi/bservice/group_update_vins.go b/pkg/cloudapi/bservice/group_update_vins.go index c918e9a..c012b0e 100644 --- a/pkg/cloudapi/bservice/group_update_vins.go +++ b/pkg/cloudapi/bservice/group_update_vins.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // GroupUpdateVINSRequest struct to update VINS settings diff --git a/pkg/cloudapi/bservice/list.go b/pkg/cloudapi/bservice/list.go index ec2899b..e5ac66c 100644 --- a/pkg/cloudapi/bservice/list.go +++ b/pkg/cloudapi/bservice/list.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ListRequest struct to get list of BasicService instances @@ -46,6 +46,11 @@ type ListRequest struct { // Required: false SortBy string `url:"sortBy,omitempty" json:"sortBy,omitempty" validate:"omitempty,sortBy"` + // Sort by zone id + // Default value: 0 + // Required: false + ZoneID uint64 `url:"zone_id,omitempty" json:"zone_id,omitempty"` + // Page number // Required: false Page uint64 `url:"page,omitempty" json:"page,omitempty"` diff --git a/pkg/cloudapi/bservice/list_deleted.go b/pkg/cloudapi/bservice/list_deleted.go index aeb73ce..ffd73d8 100644 --- a/pkg/cloudapi/bservice/list_deleted.go +++ b/pkg/cloudapi/bservice/list_deleted.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ListDeletedRequest struct to get list of deleted BasicService instances diff --git a/pkg/cloudapi/bservice/migrate_to_zone.go b/pkg/cloudapi/bservice/migrate_to_zone.go new file mode 100644 index 0000000..273ccae --- /dev/null +++ b/pkg/cloudapi/bservice/migrate_to_zone.go @@ -0,0 +1,42 @@ +package bservice + +import ( + "context" + "net/http" + "strconv" + + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" +) + +// MigrateToZone struct to move basic service to another zone +type MigrateToZoneRequest struct { + // ID of the BasicService to move + // Required: true + ServiceID uint64 `url:"serviceId" json:"serviceId" validate:"required"` + + // ID of the zone to move + // Required: true + ZoneID uint64 `url:"zoneId" json:"zoneId" validate:"required"` +} + +// MigrateToZone moves basic service instance to new zone +func (b BService) MigrateToZone(ctx context.Context, req MigrateToZoneRequest) (bool, error) { + err := validators.ValidateRequest(req) + if err != nil { + return false, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudapi/bservice/migrateToZone" + + res, err := b.client.DecortApiCall(ctx, http.MethodPost, url, req) + if err != nil { + return false, err + } + + result, err := strconv.ParseBool(string(res)) + if err != nil { + return false, err + } + + return result, nil +} diff --git a/pkg/cloudapi/bservice/models.go b/pkg/cloudapi/bservice/models.go index 86e6416..f6a1769 100644 --- a/pkg/cloudapi/bservice/models.go +++ b/pkg/cloudapi/bservice/models.go @@ -88,6 +88,9 @@ type RecordBasicService struct { // Whether user controlled UserManaged bool `json:"userManaged"` + + // Zone ID + ZoneID uint64 `json:"zoneId"` } // Main information about Compute @@ -382,6 +385,9 @@ type ItemBasicService struct { // User Managed or not UserManaged bool `json:"userManaged"` + + // Zone ID + ZoneID uint64 `json:"zoneId"` } // List of BasicServices diff --git a/pkg/cloudapi/bservice/restore.go b/pkg/cloudapi/bservice/restore.go index 3b51941..5f92c9a 100644 --- a/pkg/cloudapi/bservice/restore.go +++ b/pkg/cloudapi/bservice/restore.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // RestoreRequest struct to restore BasicService instance diff --git a/pkg/cloudapi/bservice/serialize.go b/pkg/cloudapi/bservice/serialize.go index 07c8130..0d1d348 100644 --- a/pkg/cloudapi/bservice/serialize.go +++ b/pkg/cloudapi/bservice/serialize.go @@ -3,7 +3,7 @@ package bservice import ( "encoding/json" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/serialization" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/serialization" ) // Serialize returns JSON-serialized []byte. Used as a wrapper over json.Marshal and json.MarshalIndent functions. diff --git a/pkg/cloudapi/bservice/snapshot_create.go b/pkg/cloudapi/bservice/snapshot_create.go index 64827ae..226aa01 100644 --- a/pkg/cloudapi/bservice/snapshot_create.go +++ b/pkg/cloudapi/bservice/snapshot_create.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // SnapshotCreateRequest struct to create snapshot diff --git a/pkg/cloudapi/bservice/snapshot_delete.go b/pkg/cloudapi/bservice/snapshot_delete.go index 22582df..2395399 100644 --- a/pkg/cloudapi/bservice/snapshot_delete.go +++ b/pkg/cloudapi/bservice/snapshot_delete.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // SnapshotDeleteRequest struct to delete snapshot diff --git a/pkg/cloudapi/bservice/snapshot_list.go b/pkg/cloudapi/bservice/snapshot_list.go index 4b51d21..f64d2d6 100644 --- a/pkg/cloudapi/bservice/snapshot_list.go +++ b/pkg/cloudapi/bservice/snapshot_list.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // SnapshotListRequest struct to get list of existing snapshots diff --git a/pkg/cloudapi/bservice/snapshot_rollback.go b/pkg/cloudapi/bservice/snapshot_rollback.go index 70378a0..9bc05db 100644 --- a/pkg/cloudapi/bservice/snapshot_rollback.go +++ b/pkg/cloudapi/bservice/snapshot_rollback.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // SnapshotRollbackRequest struct to rollback snapshot diff --git a/pkg/cloudapi/bservice/start.go b/pkg/cloudapi/bservice/start.go index 767a30a..f0989bd 100644 --- a/pkg/cloudapi/bservice/start.go +++ b/pkg/cloudapi/bservice/start.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // StartRequest struct to start service diff --git a/pkg/cloudapi/bservice/stop.go b/pkg/cloudapi/bservice/stop.go index bdc8bc2..bd70a24 100644 --- a/pkg/cloudapi/bservice/stop.go +++ b/pkg/cloudapi/bservice/stop.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // StopRequest struct to stop service diff --git a/pkg/cloudapi/cloudapi.go b/pkg/cloudapi/cloudapi.go index 86e1898..40da815 100644 --- a/pkg/cloudapi/cloudapi.go +++ b/pkg/cloudapi/cloudapi.go @@ -2,7 +2,7 @@ package cloudapi import ( - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/interfaces" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/interfaces" ) // Structure for creating request to CloudAPI groups diff --git a/pkg/cloudapi/compute.go b/pkg/cloudapi/compute.go index a8c2b4c..a94d6f7 100644 --- a/pkg/cloudapi/compute.go +++ b/pkg/cloudapi/compute.go @@ -1,7 +1,7 @@ package cloudapi import ( - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/pkg/cloudapi/compute" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/pkg/cloudapi/compute" ) // Accessing the Compute method group diff --git a/pkg/cloudapi/compute/abort_shared_snapshot_merge.go b/pkg/cloudapi/compute/abort_shared_snapshot_merge.go new file mode 100644 index 0000000..7fa4832 --- /dev/null +++ b/pkg/cloudapi/compute/abort_shared_snapshot_merge.go @@ -0,0 +1,42 @@ +package compute + +import ( + "context" + "net/http" + "strconv" + + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" +) + +// AbortSharedSnapshotMergeRequest struct to abort shared snapshots merge +type AbortSharedSnapshotMergeRequest struct { + // ID of the compute + // Required: true + ComputeID uint64 `url:"compute_id" json:"compute_id" validate:"required"` + + // Label of the snapshot + // Required: true + Label string `url:"label" json:"label" validate:"required"` +} + +// AbortSharedSnapshotMerge shared snapshots merge abort +func (c Compute) AbortSharedSnapshotMerge(ctx context.Context, req AbortSharedSnapshotMergeRequest) (bool, error) { + err := validators.ValidateRequest(req) + if err != nil { + return false, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudapi/compute/abort_shared_snapshot_merge" + + res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req) + if err != nil { + return false, err + } + + result, err := strconv.ParseBool(string(res)) + if err != nil { + return false, err + } + + return result, nil +} diff --git a/pkg/cloudapi/compute/affinity_group_check_start.go b/pkg/cloudapi/compute/affinity_group_check_start.go index 8df0f81..89db2c3 100644 --- a/pkg/cloudapi/compute/affinity_group_check_start.go +++ b/pkg/cloudapi/compute/affinity_group_check_start.go @@ -4,7 +4,7 @@ import ( "context" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // AffinityGroupCheckStartRequest struct to check all computes with current affinity label can start diff --git a/pkg/cloudapi/compute/affinity_label_remove.go b/pkg/cloudapi/compute/affinity_label_remove.go index 22f67e4..8b1193a 100644 --- a/pkg/cloudapi/compute/affinity_label_remove.go +++ b/pkg/cloudapi/compute/affinity_label_remove.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // AffinityLabelRemoveRequest struct to clear affinity label for compute diff --git a/pkg/cloudapi/compute/affinity_label_set.go b/pkg/cloudapi/compute/affinity_label_set.go index 6e058b2..07f5ad3 100644 --- a/pkg/cloudapi/compute/affinity_label_set.go +++ b/pkg/cloudapi/compute/affinity_label_set.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // AffinityLabelSetRequest struct to set affinity label for compute diff --git a/pkg/cloudapi/compute/affinity_relations.go b/pkg/cloudapi/compute/affinity_relations.go index 99b4a9b..4481937 100644 --- a/pkg/cloudapi/compute/affinity_relations.go +++ b/pkg/cloudapi/compute/affinity_relations.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // AffinityRelationsRequest struct to get dict of computes diff --git a/pkg/cloudapi/compute/affinity_rule_add.go b/pkg/cloudapi/compute/affinity_rule_add.go index 53aad32..5fda9f0 100644 --- a/pkg/cloudapi/compute/affinity_rule_add.go +++ b/pkg/cloudapi/compute/affinity_rule_add.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // AffinityRuleAddRequest struct to add affinity rule diff --git a/pkg/cloudapi/compute/affinity_rule_remove.go b/pkg/cloudapi/compute/affinity_rule_remove.go index 8be8c1c..6a50d6c 100644 --- a/pkg/cloudapi/compute/affinity_rule_remove.go +++ b/pkg/cloudapi/compute/affinity_rule_remove.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // AffinityRuleRemoveRequest struct to remove affinity rule diff --git a/pkg/cloudapi/compute/affinity_rules_clear.go b/pkg/cloudapi/compute/affinity_rules_clear.go index 6dcdd0e..ada8811 100644 --- a/pkg/cloudapi/compute/affinity_rules_clear.go +++ b/pkg/cloudapi/compute/affinity_rules_clear.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // AffinityRulesClearRequest struct to clear affinity rules diff --git a/pkg/cloudapi/compute/anti_affinity_rule_add.go b/pkg/cloudapi/compute/anti_affinity_rule_add.go index c27973b..9b4c7f2 100644 --- a/pkg/cloudapi/compute/anti_affinity_rule_add.go +++ b/pkg/cloudapi/compute/anti_affinity_rule_add.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // AntiAffinityRuleAddRequest struct to add anti affinity rule diff --git a/pkg/cloudapi/compute/anti_affinity_rule_remove.go b/pkg/cloudapi/compute/anti_affinity_rule_remove.go index b1bdc5d..c12d678 100644 --- a/pkg/cloudapi/compute/anti_affinity_rule_remove.go +++ b/pkg/cloudapi/compute/anti_affinity_rule_remove.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // AntiAffinityRuleRemoveRequest struct to remove anti affinity rule diff --git a/pkg/cloudapi/compute/anti_affinity_rules_clear.go b/pkg/cloudapi/compute/anti_affinity_rules_clear.go index 20d090e..2588735 100644 --- a/pkg/cloudapi/compute/anti_affinity_rules_clear.go +++ b/pkg/cloudapi/compute/anti_affinity_rules_clear.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // AntiAffinityRulesClearRequest struct to clear anti affinity rules diff --git a/pkg/cloudapi/compute/attach_gpu.go b/pkg/cloudapi/compute/attach_gpu.go index 9cfe17e..a78be12 100644 --- a/pkg/cloudapi/compute/attach_gpu.go +++ b/pkg/cloudapi/compute/attach_gpu.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // AttachGPURequest struct to attach GPU for compute diff --git a/pkg/cloudapi/compute/attach_pci_device.go b/pkg/cloudapi/compute/attach_pci_device.go index 8b17ca1..968e3ae 100644 --- a/pkg/cloudapi/compute/attach_pci_device.go +++ b/pkg/cloudapi/compute/attach_pci_device.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // AttachPCIDeviceRequest struct to attach PCI device diff --git a/pkg/cloudapi/compute/audits.go b/pkg/cloudapi/compute/audits.go index 2a8598e..af93157 100644 --- a/pkg/cloudapi/compute/audits.go +++ b/pkg/cloudapi/compute/audits.go @@ -5,18 +5,54 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // AuditsRequest struct to get audit records type AuditsRequest struct { // ID of the compute // Required: true - ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"` + ComputeID uint64 `url:"compute_id" json:"compute_id" validate:"required"` + + // Find all audits after point in time + // Required: false + TimestampAT uint64 `url:"timestamp_at,omitempty" json:"timestamp_at,omitempty"` + + // Find all audits before point in time + // Required: false + TimestampTO uint64 `url:"timestamp_to,omitempty" json:"timestamp_to,omitempty"` + + // Find by user + // Required: false + User string `url:"user,omitempty" json:"user,omitempty"` + + // Find by api endpoints + // Required: false + Call string `url:"call,omitempty" json:"call,omitempty"` + + // Sort by one of supported fields, format ± + // Required: false + SortBy string `url:"sort_by,omitempty" json:"sort_by,omitempty"` + + // Page number + // Required: false + Page uint64 `url:"page,omitempty" json:"page,omitempty"` + + // Page size + // Required: false + Size uint64 `url:"size,omitempty" json:"size,omitempty"` + + // Find by HTTP min status code + // Required: false + MinStatusCode uint64 `url:"min_status_code,omitempty" json:"min_status_code,omitempty"` + + // Find by HTTP max status code + // Required: false + MaxStatusCode uint64 `url:"max_status_code,omitempty" json:"max_status_code,omitempty"` } // Audits gets audit records for the specified compute object -func (c Compute) Audits(ctx context.Context, req AuditsRequest) (ListAudits, error) { +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)) @@ -24,7 +60,7 @@ func (c Compute) Audits(ctx context.Context, req AuditsRequest) (ListAudits, err url := "/cloudapi/compute/audits" - res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req) + res, err := c.client.DecortApiCall(ctx, http.MethodGet, url, req) if err != nil { return nil, err } @@ -36,5 +72,5 @@ func (c Compute) Audits(ctx context.Context, req AuditsRequest) (ListAudits, err return nil, err } - return list, nil + return &list, nil } diff --git a/pkg/cloudapi/compute/boot_disk_set.go b/pkg/cloudapi/compute/boot_disk_set.go index a28ae23..bc5dc24 100644 --- a/pkg/cloudapi/compute/boot_disk_set.go +++ b/pkg/cloudapi/compute/boot_disk_set.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // BootDiskSetRequest struct to set boot disk for compute diff --git a/pkg/cloudapi/compute/boot_order_get.go b/pkg/cloudapi/compute/boot_order_get.go index 771aa99..8d81fe9 100644 --- a/pkg/cloudapi/compute/boot_order_get.go +++ b/pkg/cloudapi/compute/boot_order_get.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // BootOrderGetRequest struct to get boot order diff --git a/pkg/cloudapi/compute/boot_order_set.go b/pkg/cloudapi/compute/boot_order_set.go index 0b130fd..7746a66 100644 --- a/pkg/cloudapi/compute/boot_order_set.go +++ b/pkg/cloudapi/compute/boot_order_set.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // BootOrderSetRequest struct to set boot order diff --git a/pkg/cloudapi/compute/cd_eject.go b/pkg/cloudapi/compute/cd_eject.go index 76d49bf..571d7eb 100644 --- a/pkg/cloudapi/compute/cd_eject.go +++ b/pkg/cloudapi/compute/cd_eject.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // CDEjectRequest struct to eject CD image diff --git a/pkg/cloudapi/compute/cd_insert.go b/pkg/cloudapi/compute/cd_insert.go index f15f3f8..5a1239d 100644 --- a/pkg/cloudapi/compute/cd_insert.go +++ b/pkg/cloudapi/compute/cd_insert.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // CDInsertRequest struct to insert new CD image diff --git a/pkg/cloudapi/compute/change_ip.go b/pkg/cloudapi/compute/change_ip.go index 64eba42..a25fc8a 100644 --- a/pkg/cloudapi/compute/change_ip.go +++ b/pkg/cloudapi/compute/change_ip.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ChangeIPRequest struct to change IP for network diff --git a/pkg/cloudapi/compute/change_link_state.go b/pkg/cloudapi/compute/change_link_state.go index 859bb16..7fe90c6 100644 --- a/pkg/cloudapi/compute/change_link_state.go +++ b/pkg/cloudapi/compute/change_link_state.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ChangeLinkStateRequest struct to change link state diff --git a/pkg/cloudapi/compute/change_mac.go b/pkg/cloudapi/compute/change_mac.go index ff1d05e..84ea593 100644 --- a/pkg/cloudapi/compute/change_mac.go +++ b/pkg/cloudapi/compute/change_mac.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ChangeMACRequest struct to change MAC for network diff --git a/pkg/cloudapi/compute/change_mtu.go b/pkg/cloudapi/compute/change_mtu.go new file mode 100644 index 0000000..0c69a3e --- /dev/null +++ b/pkg/cloudapi/compute/change_mtu.go @@ -0,0 +1,46 @@ +package compute + +import ( + "context" + "net/http" + "strconv" + + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" +) + +// ChangeMTURequest struct to change MTU for a compute +type ChangeMTURequest struct { + // ID of compute instance + // Required: true + ComputeID uint64 `url:"compute_id" json:"compute_id" validate:"required"` + + // Interface name or MAC address + // Required: true + Interface string `url:"interface" json:"interface" validate:"required"` + + // Maximum transmission unit + // Required: true + MTU uint64 `url:"mtu" json:"mtu" validate:"required" validate:"omitempty,mtu"` +} + +// ChangeMTU change MTU for compute instance +func (c Compute) ChangeMTU(ctx context.Context, req ChangeMTURequest) (bool, error) { + err := validators.ValidateRequest(req) + if err != nil { + return false, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudapi/compute/change_mtu" + + res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req) + if err != nil { + return false, err + } + + result, err := strconv.ParseBool(string(res)) + if err != nil { + return false, err + } + + return result, nil +} diff --git a/pkg/cloudapi/compute/change_secutity_group.go b/pkg/cloudapi/compute/change_secutity_group.go new file mode 100644 index 0000000..4b41efc --- /dev/null +++ b/pkg/cloudapi/compute/change_secutity_group.go @@ -0,0 +1,50 @@ +package compute + +import ( + "context" + "net/http" + "strconv" + + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" +) + +// ChangeSecGroupsRequest struct to change security groups for compute +type ChangeSecGroupsRequest struct { + // Identifier compute + // Required: true + ComputeID uint64 `url:"compute_id" json:"compute_id" validate:"required"` + + // Interface name or MAC address + // Required: true + Interface string `url:"interface" json:"interface" validate:"required"` + + // List of security group IDs to assign to this interface + // Required: false + SecGroups []uint64 `url:"security_groups,omitempty" json:"security_groups,omitempty"` + + // Flag indicating whether security groups are enabled for this interface + // Required: false + EnableSecGroups interface{} `url:"enable_secgroups,omitempty" json:"enable_secgroups,omitempty" validate:"omitempty,isBool"` +} + +// ChangeSecGroups changes security groups for compute +func (c Compute) ChangeSecGroups(ctx context.Context, req ChangeSecGroupsRequest) (bool, error) { + err := validators.ValidateRequest(req) + if err != nil { + return false, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudapi/compute/change_security_groups" + + res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req) + if err != nil { + return false, err + } + + result, err := strconv.ParseBool(string(res)) + if err != nil { + return false, err + } + + return result, nil +} diff --git a/pkg/cloudapi/compute/clone.go b/pkg/cloudapi/compute/clone.go index d8c12be..8f9dcdb 100644 --- a/pkg/cloudapi/compute/clone.go +++ b/pkg/cloudapi/compute/clone.go @@ -3,9 +3,9 @@ package compute import ( "context" "net/http" - "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/constants" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // CloneRequest struct to clone compute instance @@ -18,6 +18,10 @@ type CloneRequest struct { // Required: true Name string `url:"name" json:"name" validate:"required"` + // ID of the Storage Policy + // Required: true + StoragePolicyID uint64 `url:"storage_policy_id" json:"storage_policy_id" validate:"required"` + // Timestamp of the parent's snapshot to create clone from // Required: false SnapshotTimestamp uint64 `url:"snapshotTimestamp,omitempty" json:"snapshotTimestamp,omitempty"` @@ -30,26 +34,29 @@ type CloneRequest struct { // Default: false // Required: false Force bool `url:"force" json:"force"` + + // The name of the pool to migrate disks to + // Required: false + PoolName string `url:"pool_name" json:"pool_name"` + + // The ID of the SEP to migrate disks to + // Required: false + SEPID uint64 `url:"sep_id" json:"sep_id"` } // Clone clones compute instance -func (c Compute) Clone(ctx context.Context, req CloneRequest) (uint64, error) { +func (c Compute) Clone(ctx context.Context, req CloneRequest) (string, error) { err := validators.ValidateRequest(req) if err != nil { - return 0, validators.ValidationErrors(validators.GetErrors(err)) + return "", validators.ValidationErrors(validators.GetErrors(err)) } url := "/cloudapi/compute/clone" - res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req) - if err != nil { - return 0, err - } - - result, err := strconv.ParseUint(string(res), 10, 64) + res, err := c.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req) if err != nil { - return 0, err + return "", err } - return result, nil + return string(res), nil } diff --git a/pkg/cloudapi/compute/clone_abort.go b/pkg/cloudapi/compute/clone_abort.go new file mode 100644 index 0000000..41f0087 --- /dev/null +++ b/pkg/cloudapi/compute/clone_abort.go @@ -0,0 +1,39 @@ +package compute + +import ( + "context" + "net/http" + "strconv" + + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/constants" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" +) + +// CloneAbortRequest struct to abort a compute clone +type CloneAbortRequest struct { + // ID of compute instance + // Required: true + ComputeID uint64 `url:"compute_id" json:"compute_id" validate:"required"` +} + +// CloneAbort aborts a compute clone +func (c Compute) CloneAbort(ctx context.Context, req CloneAbortRequest) (bool, error) { + err := validators.ValidateRequest(req) + if err != nil { + return false, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudapi/compute/clone_abort" + + res, err := c.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req) + if err != nil { + return false, err + } + + result, err := strconv.ParseBool(string(res)) + if err != nil { + return false, err + } + + return result, nil +} diff --git a/pkg/cloudapi/compute/clone_status.go b/pkg/cloudapi/compute/clone_status.go new file mode 100644 index 0000000..3c31ec8 --- /dev/null +++ b/pkg/cloudapi/compute/clone_status.go @@ -0,0 +1,40 @@ +package compute + +import ( + "context" + "encoding/json" + "net/http" + + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" +) + +// GetCloneStatusRequest struct to get information about compute clone status +type GetCloneStatusRequest struct { + // ID of compute instance + // Required: true + ComputeID uint64 `url:"compute_id" json:"compute_id" validate:"required"` +} + +// GetCloneStatus gets information about compute clone status as a RecordCloneStatus struct +func (c Compute) GetCloneStatus(ctx context.Context, req GetCloneStatusRequest) ([]RecordCloneStatus, error) { + err := validators.ValidateRequest(req) + if err != nil { + return nil, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudapi/compute/clone_status" + + res, err := c.client.DecortApiCall(ctx, http.MethodGet, url, req) + if err != nil { + return nil, err + } + + cloneStatus := make([]RecordCloneStatus, 0) + + err = json.Unmarshal(res, &cloneStatus) + if err != nil { + return nil, err + } + + return cloneStatus, nil +} diff --git a/pkg/cloudapi/compute/compute.go b/pkg/cloudapi/compute/compute.go index 6624483..4917c5a 100644 --- a/pkg/cloudapi/compute/compute.go +++ b/pkg/cloudapi/compute/compute.go @@ -2,7 +2,7 @@ package compute import ( - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/interfaces" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/interfaces" ) // Structure for creating request to compute diff --git a/pkg/cloudapi/compute/create_template.go b/pkg/cloudapi/compute/create_template.go index db62b7d..fddbc3d 100644 --- a/pkg/cloudapi/compute/create_template.go +++ b/pkg/cloudapi/compute/create_template.go @@ -3,10 +3,9 @@ package compute import ( "context" "net/http" - "strconv" "strings" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // CreateTemplateRequest struct to create template @@ -27,47 +26,15 @@ type wrapperCreateTemplateRequest struct { } // CreateTemplate create template from compute instance -func (c Compute) CreateTemplate(ctx context.Context, req CreateTemplateRequest) (uint64, error) { - err := validators.ValidateRequest(req) - if err != nil { - return 0, validators.ValidationErrors(validators.GetErrors(err)) - } - - reqWrapped := wrapperCreateTemplateRequest{ - CreateTemplateRequest: req, - AsyncMode: false, - } - - url := "/cloudapi/compute/createTemplate" - - res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped) - if err != nil { - return 0, err - } - - result, err := strconv.ParseUint(string(res), 10, 64) - if err != nil { - return 0, err - } - - return result, nil -} - -// CreateTemplateAsync create template from compute instance -func (c Compute) CreateTemplateAsync(ctx context.Context, req CreateTemplateRequest) (string, error) { +func (c Compute) CreateTemplate(ctx context.Context, req CreateTemplateRequest) (string, error) { err := validators.ValidateRequest(req) if err != nil { return "", validators.ValidationErrors(validators.GetErrors(err)) } - reqWrapped := wrapperCreateTemplateRequest{ - CreateTemplateRequest: req, - AsyncMode: true, - } - url := "/cloudapi/compute/createTemplate" - res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped) + res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req) if err != nil { return "", err } diff --git a/pkg/cloudapi/compute/create_template_from_blank.go b/pkg/cloudapi/compute/create_template_from_blank.go index 27be19f..9ed3fe8 100644 --- a/pkg/cloudapi/compute/create_template_from_blank.go +++ b/pkg/cloudapi/compute/create_template_from_blank.go @@ -6,7 +6,7 @@ import ( "strconv" "strings" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // CreateTemplateFromBlankRequest struct to create template from boot disk of current compute @@ -27,6 +27,10 @@ type CreateTemplateFromBlankRequest struct { // Required: true ImageType string `url:"imagetype" json:"imagetype" validate:"imageType"` + // Storage policy id of disk. The rules of the specified storage policy will be used. + // Required: true + StoragePolicyID uint64 `url:"storage_policy_id" json:"storage_policy_id" validate:"required"` + // Username for the image // Required: false Username string `url:"username,omitempty" json:"username,omitempty"` diff --git a/pkg/cloudapi/compute/delete.go b/pkg/cloudapi/compute/delete.go index ab01636..de40363 100644 --- a/pkg/cloudapi/compute/delete.go +++ b/pkg/cloudapi/compute/delete.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // DeleteRequest struct to delete compute diff --git a/pkg/cloudapi/compute/delete_custom_fields.go b/pkg/cloudapi/compute/delete_custom_fields.go index 7a2a606..5bd4c08 100644 --- a/pkg/cloudapi/compute/delete_custom_fields.go +++ b/pkg/cloudapi/compute/delete_custom_fields.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // DeleteCustomFieldsRequest struct to delete compute's custom fields diff --git a/pkg/cloudapi/compute/detach_gpu.go b/pkg/cloudapi/compute/detach_gpu.go index 5228175..f2300d4 100644 --- a/pkg/cloudapi/compute/detach_gpu.go +++ b/pkg/cloudapi/compute/detach_gpu.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // DetachGPURequest struct to detach vgpu for compute diff --git a/pkg/cloudapi/compute/detach_pci_device.go b/pkg/cloudapi/compute/detach_pci_device.go index 6f15b01..54eb1f6 100644 --- a/pkg/cloudapi/compute/detach_pci_device.go +++ b/pkg/cloudapi/compute/detach_pci_device.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // DetachPCIDeviceRequest struct to detach PCI device diff --git a/pkg/cloudapi/compute/disable.go b/pkg/cloudapi/compute/disable.go index dd669cb..09cef9e 100644 --- a/pkg/cloudapi/compute/disable.go +++ b/pkg/cloudapi/compute/disable.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // DisableRequest struct to disable compute diff --git a/pkg/cloudapi/compute/disk_add.go b/pkg/cloudapi/compute/disk_add.go index 78e0040..9abf59c 100644 --- a/pkg/cloudapi/compute/disk_add.go +++ b/pkg/cloudapi/compute/disk_add.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // DiskAddRequest struct to create and attach disk to compute @@ -22,6 +22,10 @@ type DiskAddRequest struct { // Required: true Size uint64 `url:"size" json:"size" validate:"required"` + // Storage policy id of disk. The rules of the specified storage policy will be used. + // Required: true + StoragePolicyID uint64 `url:"storage_policy_id" json:"storage_policy_id" validate:"required"` + // Type of the disk // Should be one of: // - D @@ -46,6 +50,14 @@ type DiskAddRequest struct { // Specify image id for create disk from template // Required: false ImageID uint64 `url:"imageId,omitempty" json:"imageId,omitempty"` + + // Desired PCI slot (hex string, e.g. "0x1A") + // Required: false + PCISlot string `url:"pci_slot,omitempty" json:"pci_slot,omitempty"` + + // Desired bus number (hex string, e.g. "0x03") + // Required: false + BusNumber string `url:"bus_number,omitempty" json:"bus_number,omitempty"` } // DiskAdd creates new disk and attach to compute diff --git a/pkg/cloudapi/compute/disk_attach.go b/pkg/cloudapi/compute/disk_attach.go index 22f59fa..c507d68 100644 --- a/pkg/cloudapi/compute/disk_attach.go +++ b/pkg/cloudapi/compute/disk_attach.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // DiskAttachRequest struct to attach disk to compute @@ -21,6 +21,14 @@ type DiskAttachRequest struct { // Type of the disk B;D // Required: false DiskType string `url:"diskType,omitempty" json:"diskType,omitempty" validate:"omitempty,computeDiskType"` + + // Desired PCI slot (hex string, e.g. "0x1A") + // Required: false + PCISlot string `url:"pci_slot,omitempty" json:"pci_slot,omitempty"` + + // Desired bus number (hex string, e.g. "0x03") + // Required: false + BusNumber string `url:"bus_number,omitempty" json:"bus_number,omitempty"` } // DiskAttach attach disk to compute diff --git a/pkg/cloudapi/compute/disk_del.go b/pkg/cloudapi/compute/disk_del.go index d310c6e..d53d745 100644 --- a/pkg/cloudapi/compute/disk_del.go +++ b/pkg/cloudapi/compute/disk_del.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // DiskDelRequest struct to detach and delete disk from compute diff --git a/pkg/cloudapi/compute/disk_detach.go b/pkg/cloudapi/compute/disk_detach.go index 7fe0ac8..819512e 100644 --- a/pkg/cloudapi/compute/disk_detach.go +++ b/pkg/cloudapi/compute/disk_detach.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // DiskDetachRequest struct to detach disk from compute diff --git a/pkg/cloudapi/compute/disk_migrate.go b/pkg/cloudapi/compute/disk_migrate.go index 7ca9514..2fee09f 100644 --- a/pkg/cloudapi/compute/disk_migrate.go +++ b/pkg/cloudapi/compute/disk_migrate.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // DiskMigrateRequest struct to migrate compute's disk to target disk diff --git a/pkg/cloudapi/compute/disk_qos.go b/pkg/cloudapi/compute/disk_qos.go index 32178dd..cd238c8 100644 --- a/pkg/cloudapi/compute/disk_qos.go +++ b/pkg/cloudapi/compute/disk_qos.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // DiskQOSRequest struct to change QoS of the disk diff --git a/pkg/cloudapi/compute/disk_resize.go b/pkg/cloudapi/compute/disk_resize.go index d5d11d8..5cd780c 100644 --- a/pkg/cloudapi/compute/disk_resize.go +++ b/pkg/cloudapi/compute/disk_resize.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // DiskResizeRequest struct to change disk size diff --git a/pkg/cloudapi/compute/disk_switch_to_replication.go b/pkg/cloudapi/compute/disk_switch_to_replication.go index 666ac3a..a945422 100644 --- a/pkg/cloudapi/compute/disk_switch_to_replication.go +++ b/pkg/cloudapi/compute/disk_switch_to_replication.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // DiskSwitchToReplicationRequest struct to switch disk to it's replication diff --git a/pkg/cloudapi/compute/enable.go b/pkg/cloudapi/compute/enable.go index b8c7509..e30f726 100644 --- a/pkg/cloudapi/compute/enable.go +++ b/pkg/cloudapi/compute/enable.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // EnableRequest struct to enable compute diff --git a/pkg/cloudapi/compute/filter.go b/pkg/cloudapi/compute/filter.go index 7465439..25ef198 100644 --- a/pkg/cloudapi/compute/filter.go +++ b/pkg/cloudapi/compute/filter.go @@ -3,9 +3,9 @@ package compute import ( "context" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/interfaces" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/pkg/cloudapi/k8s" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/pkg/cloudapi/lb" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/interfaces" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/pkg/cloudapi/k8s" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/pkg/cloudapi/lb" ) // FilterByID returns ListComputes with specified ID. diff --git a/pkg/cloudapi/compute/filter_test.go b/pkg/cloudapi/compute/filter_test.go index 513d2a9..0afb05f 100644 --- a/pkg/cloudapi/compute/filter_test.go +++ b/pkg/cloudapi/compute/filter_test.go @@ -55,7 +55,6 @@ var computes = ListComputes{ GID: 212, GUID: 48500, ID: 48500, - ImageID: 9884, Interfaces: []ItemVNFInterface{}, LockStatus: "UNLOCKED", ManagerID: 0, @@ -82,7 +81,7 @@ var computes = ListComputes{ UserManaged: true, VGPUs: []uint64{}, VINSConnected: 0, - VirtualImageID: 0, + ZoneID: 1, }, { ACL: ListACL{}, @@ -117,7 +116,6 @@ var computes = ListComputes{ GID: 212, GUID: 48556, ID: 48556, - ImageID: 9884, Interfaces: []ItemVNFInterface{}, LockStatus: "UNLOCKED", ManagerID: 0, @@ -144,7 +142,7 @@ var computes = ListComputes{ UserManaged: true, VGPUs: []uint64{}, VINSConnected: 0, - VirtualImageID: 0, + ZoneID: 5, }, }, EntryCount: 2, diff --git a/pkg/cloudapi/compute/get.go b/pkg/cloudapi/compute/get.go index 8117404..6f44bac 100644 --- a/pkg/cloudapi/compute/get.go +++ b/pkg/cloudapi/compute/get.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // GetRequest struct to get information about compute diff --git a/pkg/cloudapi/compute/get_audits.go b/pkg/cloudapi/compute/get_audits.go index d9d52b4..1ecc153 100644 --- a/pkg/cloudapi/compute/get_audits.go +++ b/pkg/cloudapi/compute/get_audits.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // GetAuditsRequest struct to get compute audits diff --git a/pkg/cloudapi/compute/get_console_url.go b/pkg/cloudapi/compute/get_console_url.go index 5bc4c5f..e94c7d4 100644 --- a/pkg/cloudapi/compute/get_console_url.go +++ b/pkg/cloudapi/compute/get_console_url.go @@ -5,7 +5,7 @@ import ( "net/http" "strings" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // GetConsoleURLRequest struct to get console URL diff --git a/pkg/cloudapi/compute/get_custom_fields.go b/pkg/cloudapi/compute/get_custom_fields.go index 553e4fd..bc6c305 100644 --- a/pkg/cloudapi/compute/get_custom_fields.go +++ b/pkg/cloudapi/compute/get_custom_fields.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // GetCustomFieldsRequest struct to get Compute's customFields diff --git a/pkg/cloudapi/compute/get_log.go b/pkg/cloudapi/compute/get_log.go index a08fe32..ce3a3fc 100644 --- a/pkg/cloudapi/compute/get_log.go +++ b/pkg/cloudapi/compute/get_log.go @@ -4,7 +4,7 @@ import ( "context" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // GetLogRequest struct to get compute logs @@ -27,7 +27,7 @@ func (c Compute) GetLog(ctx context.Context, req GetLogRequest) (string, error) url := "/cloudapi/compute/getLog" - res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req) + res, err := c.client.DecortApiCall(ctx, http.MethodGet, url, req) if err != nil { return "", err } diff --git a/pkg/cloudapi/compute/guest_agent_disable.go b/pkg/cloudapi/compute/guest_agent_disable.go new file mode 100644 index 0000000..175981e --- /dev/null +++ b/pkg/cloudapi/compute/guest_agent_disable.go @@ -0,0 +1,38 @@ +package compute + +import ( + "context" + "net/http" + "strconv" + + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" +) + +// GuestAgentDisableRequest struct to disable guest agent +type GuestAgentDisableRequest struct { + // ID of compute instance + // Required: true + ComputeID uint64 `url:"compute_id" json:"compute_id" validate:"required"` +} + +// Disable guest agent at a specific compute +func (c Compute) GuestAgentDisable(ctx context.Context, req GuestAgentDisableRequest) (bool, error) { + err := validators.ValidateRequest(req) + if err != nil { + return false, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudapi/compute/guest_agent_disable" + + res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req) + if err != nil { + return false, err + } + + result, err := strconv.ParseBool(string(res)) + if err != nil { + return false, err + } + + return result, nil +} diff --git a/pkg/cloudapi/compute/guest_agent_enable.go b/pkg/cloudapi/compute/guest_agent_enable.go new file mode 100644 index 0000000..0c884dd --- /dev/null +++ b/pkg/cloudapi/compute/guest_agent_enable.go @@ -0,0 +1,38 @@ +package compute + +import ( + "context" + "net/http" + "strconv" + + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" +) + +// GuestAgentEnableRequest struct to enable guest agent +type GuestAgentEnableRequest struct { + // ID of compute instance + // Required: true + ComputeID uint64 `url:"compute_id" json:"compute_id" validate:"required"` +} + +// Enable guest agent at a specific compute +func (c Compute) GuestAgentEnable(ctx context.Context, req GuestAgentEnableRequest) (bool, error) { + err := validators.ValidateRequest(req) + if err != nil { + return false, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudapi/compute/guest_agent_enable" + + res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req) + if err != nil { + return false, err + } + + result, err := strconv.ParseBool(string(res)) + if err != nil { + return false, err + } + + return result, nil +} diff --git a/pkg/cloudapi/compute/guest_agent_execute.go b/pkg/cloudapi/compute/guest_agent_execute.go new file mode 100644 index 0000000..7c3b294 --- /dev/null +++ b/pkg/cloudapi/compute/guest_agent_execute.go @@ -0,0 +1,48 @@ +package compute + +import ( + "context" + "encoding/json" + "net/http" + + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" +) + +// GuestAgentExecuteRequest struct to execute command from user to agent +type GuestAgentExecuteRequest struct { + // ID of compute instance + // Required: true + ComputeID uint64 `url:"compute_id" json:"compute_id" validate:"required"` + + // Custom command from user to agent + // Required: true + Command string `url:"command" json:"command" validate:"required"` + + // Arguments to command + // Required: true + Arguments string `url:"arguments" json:"arguments" validate:"required"` +} + +// Execute guest agent command +func (c Compute) GuestAgentExecuteRequest(ctx context.Context, req GuestAgentExecuteRequest) (map[string]interface{}, error) { + err := validators.ValidateRequest(req) + if err != nil { + return nil, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudapi/compute/guest_agent_execute" + + res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req) + if err != nil { + return nil, err + } + + var result map[string]interface{} + + err = json.Unmarshal(res, &result) + if err != nil { + return nil, err + } + + return result, nil +} diff --git a/pkg/cloudapi/compute/guest_agent_feature_get.go b/pkg/cloudapi/compute/guest_agent_feature_get.go new file mode 100644 index 0000000..e57d434 --- /dev/null +++ b/pkg/cloudapi/compute/guest_agent_feature_get.go @@ -0,0 +1,40 @@ +package compute + +import ( + "context" + "encoding/json" + "net/http" + + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" +) + +// GuestAgentFeatureGetRequest struct to feature get guest agent +type GuestAgentFeatureGetRequest struct { + // ID of compute instance + // Required: true + ComputeID uint64 `url:"compute_id" json:"compute_id" validate:"required"` +} + +// List of features +func (c Compute) GuestAgentFeatureGet(ctx context.Context, req GuestAgentFeatureGetRequest) ([]string, error) { + err := validators.ValidateRequest(req) + if err != nil { + return nil, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudapi/compute/guest_agent_feature_get" + + res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req) + if err != nil { + return nil, err + } + + features := make([]string, 0) + + err = json.Unmarshal(res, &features) + if err != nil { + return nil, err + } + + return features, nil +} diff --git a/pkg/cloudapi/compute/guest_agent_feature_update.go b/pkg/cloudapi/compute/guest_agent_feature_update.go new file mode 100644 index 0000000..bd96e11 --- /dev/null +++ b/pkg/cloudapi/compute/guest_agent_feature_update.go @@ -0,0 +1,38 @@ +package compute + +import ( + "context" + "net/http" + "strconv" + + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" +) + +// GuestAgentFeatureUpdateRequest struct to feature update guest agent +type GuestAgentFeatureUpdateRequest struct { + // ID of compute instance + // Required: true + ComputeID uint64 `url:"compute_id" json:"compute_id" validate:"required"` +} + +// Feature update guest agent +func (c Compute) GuestAgentFeatureUpdate(ctx context.Context, req GuestAgentFeatureUpdateRequest) (bool, error) { + err := validators.ValidateRequest(req) + if err != nil { + return false, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudapi/compute/guest_agent_feature_update" + + res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req) + if err != nil { + return false, err + } + + result, err := strconv.ParseBool(string(res)) + if err != nil { + return false, err + } + + return result, nil +} diff --git a/pkg/cloudapi/compute/list.go b/pkg/cloudapi/compute/list.go index 1570f53..a7e1dff 100644 --- a/pkg/cloudapi/compute/list.go +++ b/pkg/cloudapi/compute/list.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ListRequest struct to get list of available computes @@ -58,6 +58,11 @@ type ListRequest struct { // Required: false SortBy string `url:"sortBy,omitempty" json:"sortBy,omitempty" validate:"omitempty,sortBy"` + // Sort by zone id + // Default value: 0 + // Required: false + ZoneID uint64 `url:"zone_id,omitempty" json:"zone_id,omitempty"` + // Page number // Required: false Page uint64 `url:"page,omitempty" json:"page,omitempty"` diff --git a/pkg/cloudapi/compute/list_deleted.go b/pkg/cloudapi/compute/list_deleted.go index f785f10..1303fec 100644 --- a/pkg/cloudapi/compute/list_deleted.go +++ b/pkg/cloudapi/compute/list_deleted.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ListDeletedRequest struct to get deleted computes list diff --git a/pkg/cloudapi/compute/list_pci_device.go b/pkg/cloudapi/compute/list_pci_device.go index 8c4cd30..60b70b5 100644 --- a/pkg/cloudapi/compute/list_pci_device.go +++ b/pkg/cloudapi/compute/list_pci_device.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ListPCIDeviceRequest struct to get list of PCI devices diff --git a/pkg/cloudapi/compute/list_vgpu.go b/pkg/cloudapi/compute/list_vgpu.go index 50002f5..9559825 100644 --- a/pkg/cloudapi/compute/list_vgpu.go +++ b/pkg/cloudapi/compute/list_vgpu.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ListVGPURequest struct to get vGPU list diff --git a/pkg/cloudapi/compute/migrate_to_zone.go b/pkg/cloudapi/compute/migrate_to_zone.go new file mode 100644 index 0000000..8dc3549 --- /dev/null +++ b/pkg/cloudapi/compute/migrate_to_zone.go @@ -0,0 +1,42 @@ +package compute + +import ( + "context" + "net/http" + "strconv" + + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" +) + +// MigrateToRGZone struct to move compute to another zone +type MigrateToZoneRequest struct { + // ID of the compute instance to move + // Required: true + ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"` + + // ID of the zone to move + // Required: true + ZoneID uint64 `url:"zoneId" json:"zoneId " validate:"required"` +} + +// MoveToRG moves compute instance to new resource group +func (c Compute) MigrateToZone(ctx context.Context, req MigrateToZoneRequest) (bool, error) { + err := validators.ValidateRequest(req) + if err != nil { + return false, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudapi/compute/migrateToZone" + + res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req) + if err != nil { + return false, err + } + + result, err := strconv.ParseBool(string(res)) + if err != nil { + return false, err + } + + return result, nil +} diff --git a/pkg/cloudapi/compute/models.go b/pkg/cloudapi/compute/models.go index 3aaf0f1..66f65a5 100644 --- a/pkg/cloudapi/compute/models.go +++ b/pkg/cloudapi/compute/models.go @@ -5,13 +5,13 @@ import "strconv" // Access Control List type RecordACL struct { // Account ACL list - AccountACL ListACL `json:"accountAcl"` + AccountACL ListACL `json:"accountACL"` // Compute ACL list - ComputeACL ListACL `json:"computeAcl"` + ComputeACL ListACL `json:"computeACL"` // Resource group ACL list - RGACL ListACL `json:"rgAcl"` + RGACL ListACL `json:"rgACL"` } type ListUsers struct { @@ -238,7 +238,13 @@ type ItemAudit struct { } // List Detailed audits -type ListAudits []ItemAudit +type ListAudits struct { + // Data + Data []ItemAudit `json:"data"` + + // Entry count + EntryCount uint64 `json:"entryCount"` +} // Short information about audit type ItemShortAudit struct { @@ -305,6 +311,9 @@ type RecordCompute struct { // Architecture Architecture string `json:"arch"` + // Boot image ID + BootImageID uint64 `json:"boot_image_id"` + // Boot order BootOrder []string `json:"bootOrder"` @@ -386,6 +395,12 @@ type RecordCompute struct { // List interfaces Interfaces ListInterfaces `json:"interfaces"` + // Loader meta iso information + LoaderMetaIso LoaderMetaIso `json:"loaderMetaIso"` + + // Live migration job ID + LiveMigrationJobID uint64 `json:"live_migration_job_id"` + // Loader type LoaderType string `json:"loaderType"` @@ -434,6 +449,9 @@ type RecordCompute struct { // Natable VINS network name NatableVINSNetworkName string `json:"natableVinsNetworkName"` + // Name of OS + OSVersion string `json:"os_version"` + // List OS Users OSUsers ListOSUser `json:"osUsers"` @@ -443,6 +461,9 @@ type RecordCompute struct { // PreferredCPU PreferredCPU []int64 `json:"preferredCpu"` + // Qemu_quest + QemuQuest QemuQuest `json:"qemu_guest"` + // Number of RAM RAM uint64 `json:"ram"` @@ -497,14 +518,27 @@ type RecordCompute struct { // vGPUs list VGPUs []VGPUItem `json:"vgpus"` - // Virtual image ID - VirtualImageID uint64 `json:"virtualImageId"` - - // Virtual image name - VirtualImageName string `json:"virtualImageName"` - // VNC password VNCPassword string `json:"vncPasswd"` + + // Zone ID + // Required: false + ZoneID uint64 `json:"zoneId"` +} +type LoaderMetaIso struct { + // Name + DeviceName string `json:"devicename"` + + // Path + Path string `json:"path"` +} + +type QemuQuest struct { + Enabled bool `json:"enabled"` + EnabledAgentFeatures []string `json:"enabled_agent_features"` + GUID string `json:"guid"` + LastUpdate uint64 `json:"last_update"` + User string `json:"user"` } type VGPUItem struct { @@ -643,6 +677,9 @@ type ItemVNFInterface struct { // Enabled Enabled bool `json:"enabled"` + // Enable security groups + EnableSecGroups bool `json:"enable_secgroups"` + // FLIPGroup ID FLIPGroupID uint64 `json:"flipgroupId"` @@ -685,9 +722,18 @@ type ItemVNFInterface struct { // QOS QOS QOS `json:"qos"` + // List of security groups + SecGroups []uint64 `json:"security_groups"` + + // SDN interface ID + SDNInterfaceID string `json:"sdn_interface_id"` + // Target Target string `json:"target"` + // Trunk tags + TrunkTags string `json:"trunk_tags"` + // Type Type string `json:"type"` @@ -725,9 +771,18 @@ type ItemComputeDisk struct { // Bus number BusNumber uint64 `json:"bus_number"` + // Created by + CreatedBy string `json:"createdBy"` + // Created time CreatedTime uint64 `json:"createdTime"` + // Device name + DeviceName string `json:"devicename"` + + // Deleted by + DeletedBy string `json:"deletedBy"` + // Deleted time DeletedTime uint64 `json:"deletedTime"` @@ -770,9 +825,6 @@ type ItemComputeDisk struct { // Name Name string `json:"name"` - // Order - Order uint64 `json:"order"` - // Params Params string `json:"params"` @@ -827,17 +879,23 @@ type ItemComputeDisk struct { // Status Status string `json:"status"` + // Storage policy id of compute. + StoragePolicyID uint64 `json:"storage_policy_id"` + // Tech status TechStatus string `json:"techStatus"` + // Need to clean before destroy + ToClean bool `json:"to_clean"` + // Type Type string `json:"type"` // Updated by UpdatedBy string `json:"updatedBy"` - // Virtual machine ID - VMID uint64 `json:"vmid"` + // UpdatedTime + UpdatedTime uint64 `json:"updatedTime"` } type ItemReplication struct { @@ -958,6 +1016,9 @@ type ItemCompute struct { // Architecture Architecture string `json:"arch"` + // Boot image ID + BootImageID uint64 `json:"boot_image_id"` + // Boot order BootOrder []string `json:"bootOrder"` @@ -1030,12 +1091,12 @@ type ItemCompute struct { // ID ID uint64 `json:"id"` - // Image ID - ImageID uint64 `json:"imageId"` - // List interfaces Interfaces ListInterfaces `json:"interfaces"` + // Live migration job ID + LiveMigrationJobID uint64 `json:"live_migration_job_id"` + // Loader type LoaderType string `json:"loaderType"` @@ -1078,6 +1139,12 @@ type ItemCompute struct { // Number of RAM RAM uint64 `json:"ram"` + // Name of OS + OSVersion string `json:"os_version"` + + // Qemu_quest + QemuQuest QemuQuest `json:"qemu_guest"` + // Reference ID ReferenceID string `json:"referenceId"` @@ -1132,8 +1199,8 @@ type ItemCompute struct { // VINS connected VINSConnected uint64 `json:"vinsConnected"` - // Virtual image ID - VirtualImageID uint64 `json:"virtualImageId"` + // Zone ID + ZoneID uint64 `json:"zoneId"` } // ListInfoDisks @@ -1261,3 +1328,31 @@ type ListPCIDevices struct { // Entry count EntryCount uint64 `json:"entryCount"` } + +type RecordCloneStatus struct { + // Disk ID + DiskID int `json:"disk_id"` + + // Clone Status + Status CloneStatus `json:"status"` +} + +type CloneStatus struct { + // Type + Type int `json:"type"` + + // Copy speed + Bandwidth int `json:"bandwidth"` + + // Current progress + Cur int `json:"cur"` + + // Total size + End int `json:"end"` + + // Operation status + Ready bool `json:"ready"` + + // Progress percent + ProgressPercent int `json:"progress_percent"` +} diff --git a/pkg/cloudapi/compute/move_to_rg.go b/pkg/cloudapi/compute/move_to_rg.go index 8f1798c..360de81 100644 --- a/pkg/cloudapi/compute/move_to_rg.go +++ b/pkg/cloudapi/compute/move_to_rg.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // MoveToRGRequest struct to move compute to new resource group diff --git a/pkg/cloudapi/compute/net_attach.go b/pkg/cloudapi/compute/net_attach.go index 9d35147..24c2d1b 100644 --- a/pkg/cloudapi/compute/net_attach.go +++ b/pkg/cloudapi/compute/net_attach.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // NetAttachRequest struct to attach network @@ -19,6 +19,9 @@ type NetAttachRequest struct { // 'VINS' for connect to ViNS // 'VFNIC' for connect to vfpool // 'DPDK' for connect to DPDK + // `EMPTY` for connect empty network + // `SDT` for connect to SDN + // `TRUNK` for connect to TRUNK // Required: true NetType string `url:"netType" json:"netType" validate:"computex86NetType"` @@ -36,9 +39,27 @@ type NetAttachRequest struct { // Required: false MACAddr string `url:"mac_addr,omitempty" json:"mac_addr,omitempty"` - // Used only for DPDK type, must be 1-9216 + // Used only for EXTNET and DPDK + // For DPDK must be 1-9216 + // For EXTNET must be 1500-9216 // Required: false MTU uint64 `url:"mtu,omitempty" json:"mtu,omitempty" validate:"omitempty,mtu"` + + // Unique identifier of logical port on SDN side + // Required: false + SDNInterfaceID string `url:"sdn_interface_id,omitempty" json:"sdn_interface_id,omitempty" validate:"omitempty"` + + // List of security group IDs to assign to this interface + // Required: false + SecGroups []uint64 `url:"security_groups,omitempty" json:"security_groups,omitempty"` + + // Flag indicating whether security groups are enabled for this interface + // Required: false + EnableSecGroups bool `url:"enable_secgroups,omitempty" json:"enable_secgroups,omitempty"` + + // Flag indicating whether this interface is enabled (only for VINS, EXTNET, DPDK, SDN, TRUNK) + // Required: false + Enabled interface{} `url:"enabled,omitempty" json:"enabled,omitempty" validate:"omitempty,isBool"` } // NetAttach attaches network to compute and gets info about network diff --git a/pkg/cloudapi/compute/net_detach.go b/pkg/cloudapi/compute/net_detach.go index 654f0fc..a7d8c34 100644 --- a/pkg/cloudapi/compute/net_detach.go +++ b/pkg/cloudapi/compute/net_detach.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // NetDetachRequest struct to detach network from compute diff --git a/pkg/cloudapi/compute/pause.go b/pkg/cloudapi/compute/pause.go index 53b77d1..40fd61d 100644 --- a/pkg/cloudapi/compute/pause.go +++ b/pkg/cloudapi/compute/pause.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // PauseRequest struct to pause compute diff --git a/pkg/cloudapi/compute/pfw_add.go b/pkg/cloudapi/compute/pfw_add.go index 65f3bea..77908fe 100644 --- a/pkg/cloudapi/compute/pfw_add.go +++ b/pkg/cloudapi/compute/pfw_add.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // PFWAddRequest struct to add port forward rule diff --git a/pkg/cloudapi/compute/pfw_del.go b/pkg/cloudapi/compute/pfw_del.go index 694f77f..dbfa160 100644 --- a/pkg/cloudapi/compute/pfw_del.go +++ b/pkg/cloudapi/compute/pfw_del.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // PFWDelRequest struct to delete port forward rule diff --git a/pkg/cloudapi/compute/pfw_list.go b/pkg/cloudapi/compute/pfw_list.go index 2360e85..5ce4b6f 100644 --- a/pkg/cloudapi/compute/pfw_list.go +++ b/pkg/cloudapi/compute/pfw_list.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // PFWListRequest struct to get list of port forwards diff --git a/pkg/cloudapi/compute/pin_to_stack.go b/pkg/cloudapi/compute/pin_to_stack.go index ffe5e2a..f2e8e80 100644 --- a/pkg/cloudapi/compute/pin_to_stack.go +++ b/pkg/cloudapi/compute/pin_to_stack.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // PinToStackRequest struct to pin compute to stack diff --git a/pkg/cloudapi/compute/power_cycle.go b/pkg/cloudapi/compute/power_cycle.go index 681f46e..a3d225a 100644 --- a/pkg/cloudapi/compute/power_cycle.go +++ b/pkg/cloudapi/compute/power_cycle.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // PowerCycleRequest struct to force stop and start compute diff --git a/pkg/cloudapi/compute/reboot.go b/pkg/cloudapi/compute/reboot.go index 20dc4b5..b5d942f 100644 --- a/pkg/cloudapi/compute/reboot.go +++ b/pkg/cloudapi/compute/reboot.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // RebootRequest struct to reboot compute diff --git a/pkg/cloudapi/compute/redeploy.go b/pkg/cloudapi/compute/redeploy.go index 8e45ae8..03ea4af 100644 --- a/pkg/cloudapi/compute/redeploy.go +++ b/pkg/cloudapi/compute/redeploy.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // RedeployRequest struct to redeploy @@ -14,10 +14,18 @@ type RedeployRequest struct { // Required: true ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"` + // Storage policy id of compute. The rules of the specified storage policy will be used. + // Required: true + StoragePolicyID uint64 `url:"storage_policy_id" json:"storage_policy_id" validate:"required"` + // ID of the new OS image, if image change is required // Required: false ImageID uint64 `url:"imageId,omitempty" json:"imageId,omitempty"` + // The OS version that will be installed on the virtual machine + // Required: false + OSVersion string `url:"os_version,omitempty" json:"os_version,omitempty"` + // new size for the boot disk in GB, if boot disk size change is required // Required: false DiskSize uint64 `url:"diskSize,omitempty" json:"diskSize,omitempty"` diff --git a/pkg/cloudapi/compute/reset.go b/pkg/cloudapi/compute/reset.go index 4c11ba1..35f1fab 100644 --- a/pkg/cloudapi/compute/reset.go +++ b/pkg/cloudapi/compute/reset.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ResetRequest struct to reset compute diff --git a/pkg/cloudapi/compute/resize.go b/pkg/cloudapi/compute/resize.go index a0e2081..9a3cc06 100644 --- a/pkg/cloudapi/compute/resize.go +++ b/pkg/cloudapi/compute/resize.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ResizeRequest struct to resize compute diff --git a/pkg/cloudapi/compute/restore.go b/pkg/cloudapi/compute/restore.go index f1dcc12..c1829d4 100644 --- a/pkg/cloudapi/compute/restore.go +++ b/pkg/cloudapi/compute/restore.go @@ -4,7 +4,7 @@ import ( "context" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // RestoreRequest struct to restore compute diff --git a/pkg/cloudapi/compute/resume.go b/pkg/cloudapi/compute/resume.go index 5ef8bcc..44f8bdb 100644 --- a/pkg/cloudapi/compute/resume.go +++ b/pkg/cloudapi/compute/resume.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ResumeRequest struct to resume compute diff --git a/pkg/cloudapi/compute/serialize.go b/pkg/cloudapi/compute/serialize.go index cf70777..2a34a28 100644 --- a/pkg/cloudapi/compute/serialize.go +++ b/pkg/cloudapi/compute/serialize.go @@ -3,7 +3,7 @@ package compute import ( "encoding/json" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/serialization" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/serialization" ) // Serialize returns JSON-serialized []byte. Used as a wrapper over json.Marshal and json.MarshalIndent functions. diff --git a/pkg/cloudapi/compute/set_custom_fields.go b/pkg/cloudapi/compute/set_custom_fields.go index e81177f..483cd47 100644 --- a/pkg/cloudapi/compute/set_custom_fields.go +++ b/pkg/cloudapi/compute/set_custom_fields.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // SetCustomFieldsRequest struct to set customFields values for the Compute diff --git a/pkg/cloudapi/compute/shared_snapshot_merge_status.go b/pkg/cloudapi/compute/shared_snapshot_merge_status.go new file mode 100644 index 0000000..7831f32 --- /dev/null +++ b/pkg/cloudapi/compute/shared_snapshot_merge_status.go @@ -0,0 +1,33 @@ +package compute + +import ( + "context" + "net/http" + + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" +) + +// SharedSnapshotMergeStatusRequest struct to get shared snapshot merge status +type SharedSnapshotMergeStatusRequest struct { + // ID of compute instance to get log for + // Required: true + ComputeID uint64 `url:"compute_id" json:"compute_id" validate:"required"` +} + +// SharedSnapshotMergeStatus shared snapshots merge status +// returns a string representing either the current status or the progress percentage +func (c Compute) SharedSnapshotMergeStatus(ctx context.Context, req SharedSnapshotMergeStatusRequest) (string, error) { + err := validators.ValidateRequest(req) + if err != nil { + return "", validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudapi/compute/shared_snapshot_merge_status" + + res, err := c.client.DecortApiCall(ctx, http.MethodGet, url, req) + if err != nil { + return "", err + } + + return string(res), nil +} diff --git a/pkg/cloudapi/compute/snapshot_create.go b/pkg/cloudapi/compute/snapshot_create.go index 51dcc47..dd37ffd 100644 --- a/pkg/cloudapi/compute/snapshot_create.go +++ b/pkg/cloudapi/compute/snapshot_create.go @@ -5,7 +5,7 @@ import ( "net/http" "strings" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // SnapshotCreateRequest struct to create snapshot diff --git a/pkg/cloudapi/compute/snapshot_delete.go b/pkg/cloudapi/compute/snapshot_delete.go index b8d5155..8ae10e1 100644 --- a/pkg/cloudapi/compute/snapshot_delete.go +++ b/pkg/cloudapi/compute/snapshot_delete.go @@ -4,7 +4,7 @@ import ( "context" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // SnapshotDeleteRequest struct to delete snapshot diff --git a/pkg/cloudapi/compute/snapshot_list.go b/pkg/cloudapi/compute/snapshot_list.go index d719cd8..439ac12 100644 --- a/pkg/cloudapi/compute/snapshot_list.go +++ b/pkg/cloudapi/compute/snapshot_list.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // SnapshotListRequest struct to get list snapshots diff --git a/pkg/cloudapi/compute/snapshot_rollback.go b/pkg/cloudapi/compute/snapshot_rollback.go index ca7e076..9206e4b 100644 --- a/pkg/cloudapi/compute/snapshot_rollback.go +++ b/pkg/cloudapi/compute/snapshot_rollback.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // SnapshotRollbackRequest struct for rollback diff --git a/pkg/cloudapi/compute/snapshot_usage.go b/pkg/cloudapi/compute/snapshot_usage.go index c30ab65..e54ea4e 100644 --- a/pkg/cloudapi/compute/snapshot_usage.go +++ b/pkg/cloudapi/compute/snapshot_usage.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // SnapshotUsageRequest struct to get compute snapshot real size on storage diff --git a/pkg/cloudapi/compute/start.go b/pkg/cloudapi/compute/start.go index 00fb2b4..685dfca 100644 --- a/pkg/cloudapi/compute/start.go +++ b/pkg/cloudapi/compute/start.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // StartRequest struct to start compute diff --git a/pkg/cloudapi/compute/stop.go b/pkg/cloudapi/compute/stop.go index b588f79..ccad959 100644 --- a/pkg/cloudapi/compute/stop.go +++ b/pkg/cloudapi/compute/stop.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // StopRequest struct to stop compute diff --git a/pkg/cloudapi/compute/tag_add.go b/pkg/cloudapi/compute/tag_add.go index 70b6c01..6e581a3 100644 --- a/pkg/cloudapi/compute/tag_add.go +++ b/pkg/cloudapi/compute/tag_add.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // TagAddRequest struct to add tag to compute diff --git a/pkg/cloudapi/compute/tag_remove.go b/pkg/cloudapi/compute/tag_remove.go index 5c44150..f0204e4 100644 --- a/pkg/cloudapi/compute/tag_remove.go +++ b/pkg/cloudapi/compute/tag_remove.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // TagRemoveRequest struct to remove tag from compute diff --git a/pkg/cloudapi/compute/unpin_from_stack.go b/pkg/cloudapi/compute/unpin_from_stack.go index 95a05a0..2bf3fec 100644 --- a/pkg/cloudapi/compute/unpin_from_stack.go +++ b/pkg/cloudapi/compute/unpin_from_stack.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // UnpinFromStackRequest struct for unpin from stack diff --git a/pkg/cloudapi/compute/update.go b/pkg/cloudapi/compute/update.go index 3145aed..da96fb3 100644 --- a/pkg/cloudapi/compute/update.go +++ b/pkg/cloudapi/compute/update.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // UpdateRequest struct to update compute @@ -65,6 +65,10 @@ type UpdateRequest struct { // Does this machine supports hot resize, true or false // Required: false HotResize interface{} `url:"hotResize,omitempty" json:"hotResize,omitempty" validate:"omitempty,isBool"` + + // The OS version that will be installed on the virtual machine + // Required: false + OSVersion string `url:"os_version,omitempty" json:"os_version,omitempty"` } // Update updates some properties of the compute diff --git a/pkg/cloudapi/compute/user_grant.go b/pkg/cloudapi/compute/user_grant.go index 92d206e..209ae3a 100644 --- a/pkg/cloudapi/compute/user_grant.go +++ b/pkg/cloudapi/compute/user_grant.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // UserGrantRequest struct to grant access to compute diff --git a/pkg/cloudapi/compute/user_list.go b/pkg/cloudapi/compute/user_list.go index 892276d..d144281 100644 --- a/pkg/cloudapi/compute/user_list.go +++ b/pkg/cloudapi/compute/user_list.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // UserListRequest struct to get list of users for compute diff --git a/pkg/cloudapi/compute/user_revoke.go b/pkg/cloudapi/compute/user_revoke.go index 8cf2dff..93a41bc 100644 --- a/pkg/cloudapi/compute/user_revoke.go +++ b/pkg/cloudapi/compute/user_revoke.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // UserRevokeRequest struct to revoke user access diff --git a/pkg/cloudapi/compute/user_update.go b/pkg/cloudapi/compute/user_update.go index f996430..5809a32 100644 --- a/pkg/cloudapi/compute/user_update.go +++ b/pkg/cloudapi/compute/user_update.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // UserUpdateRequest struct to update user access diff --git a/pkg/cloudapi/disks.go b/pkg/cloudapi/disks.go index 6cdf0a9..3da1bf6 100644 --- a/pkg/cloudapi/disks.go +++ b/pkg/cloudapi/disks.go @@ -1,7 +1,7 @@ package cloudapi import ( - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/pkg/cloudapi/disks" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/pkg/cloudapi/disks" ) // Accessing the Disks method group diff --git a/pkg/cloudapi/disks/change_disk_storage_policy.go b/pkg/cloudapi/disks/change_disk_storage_policy.go new file mode 100644 index 0000000..55a2b66 --- /dev/null +++ b/pkg/cloudapi/disks/change_disk_storage_policy.go @@ -0,0 +1,42 @@ +package disks + +import ( + "context" + "net/http" + "strconv" + + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" +) + +// ChangeDiskStoragePolicyRequest struct to change storage policy for disk +type ChangeDiskStoragePolicyRequest struct { + // ID of the disk + // Required: true + DiskID uint64 `url:"disk_id" json:"disk_id" validate:"required"` + + // ID of the storage policy to which to connect for disk + // Required: true + StoragePolicyID uint64 `url:"storage_policy_id" json:"storage_policy_id" validate:"required"` +} + +// ChangeDiskStoragePolicy changes storage policy for disk +func (d Disks) ChangeDiskStoragePolicy(ctx context.Context, req ChangeDiskStoragePolicyRequest) (bool, error) { + err := validators.ValidateRequest(req) + if err != nil { + return false, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudapi/disks/change_disk_storage_policy" + + res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, req) + if err != nil { + return false, err + } + + result, err := strconv.ParseBool(string(res)) + if err != nil { + return false, err + } + + return result, nil +} diff --git a/pkg/cloudapi/disks/create.go b/pkg/cloudapi/disks/create.go index 1286eee..623b07b 100644 --- a/pkg/cloudapi/disks/create.go +++ b/pkg/cloudapi/disks/create.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // CreateRequest struct to create disk @@ -18,6 +18,10 @@ type CreateRequest struct { // Required: true Name string `url:"name" json:"name" validate:"required"` + // ID of the storage policy under the disk will be created + // Required: true + StoragePolicyID uint64 `url:"storage_policy_id" json:"storage_policy_id" validate:"required"` + // Description of disk // Required: false Description string `url:"description,omitempty" json:"description,omitempty"` @@ -26,10 +30,6 @@ type CreateRequest struct { // Required: false Size uint64 `url:"size,omitempty" json:"size,omitempty"` - // Max IOPS disk can perform defaults to 2000 - // Required: false - IOPS uint64 `url:"iops,omitempty" json:"iops,omitempty"` - // Storage endpoint provider ID to create disk // Required: false SEPID uint64 `url:"sep_id,omitempty" json:"sep_id,omitempty"` diff --git a/pkg/cloudapi/disks/delete.go b/pkg/cloudapi/disks/delete.go index ed824dd..d541b9f 100644 --- a/pkg/cloudapi/disks/delete.go +++ b/pkg/cloudapi/disks/delete.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // DeleteRequest to delete disk diff --git a/pkg/cloudapi/disks/delete_disks.go b/pkg/cloudapi/disks/delete_disks.go index 2dea7c0..3f2e9cb 100644 --- a/pkg/cloudapi/disks/delete_disks.go +++ b/pkg/cloudapi/disks/delete_disks.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // DisksDeleteRequest struct for multiple disks diff --git a/pkg/cloudapi/disks/disks.go b/pkg/cloudapi/disks/disks.go index f792a77..cb05338 100644 --- a/pkg/cloudapi/disks/disks.go +++ b/pkg/cloudapi/disks/disks.go @@ -2,7 +2,7 @@ package disks import ( - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/interfaces" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/interfaces" ) // Structure for creating request to disks diff --git a/pkg/cloudapi/disks/filter.go b/pkg/cloudapi/disks/filter.go index 841e251..de926a1 100644 --- a/pkg/cloudapi/disks/filter.go +++ b/pkg/cloudapi/disks/filter.go @@ -4,9 +4,9 @@ import ( "context" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/interfaces" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/pkg/cloudapi/k8s" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/pkg/cloudapi/lb" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/interfaces" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/pkg/cloudapi/k8s" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/pkg/cloudapi/lb" ) // FilterByID returns ListDisks with specified ID. diff --git a/pkg/cloudapi/disks/from_platform_disk.go b/pkg/cloudapi/disks/from_platform_disk.go index 25c9271..aad986e 100644 --- a/pkg/cloudapi/disks/from_platform_disk.go +++ b/pkg/cloudapi/disks/from_platform_disk.go @@ -6,7 +6,7 @@ import ( "strconv" "strings" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // FromPlatformDiskRequest struct to create template from platform disk @@ -27,12 +27,6 @@ type FromPlatformDiskRequest struct { // Required: true ImageType string `url:"imagetype" json:"imagetype" validate:"imageType"` - // Binary architecture of this image - // Should be: - // - X86_64 - // Required: true - Architecture string `url:"architecture" json:"architecture" validate:"imageArchitecture"` - // Username for the image // Required: false Username string `url:"username,omitempty" json:"username,omitempty"` @@ -49,11 +43,6 @@ type FromPlatformDiskRequest struct { // Required: false PoolName string `url:"poolName,omitempty" json:"poolName,omitempty"` - // List of types of compute suitable for image - // Example: [ "KVM_X86" ] - // Required: true - Drivers []string `url:"drivers" json:"drivers" validate:"required"` - // Does this machine supports hot resize // Required: false HotResize bool `url:"hotresize" json:"hotresize"` diff --git a/pkg/cloudapi/disks/get.go b/pkg/cloudapi/disks/get.go index 68a8ae1..2a40f18 100644 --- a/pkg/cloudapi/disks/get.go +++ b/pkg/cloudapi/disks/get.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // GetRequest struct to get information about disk diff --git a/pkg/cloudapi/disks/limitio.go b/pkg/cloudapi/disks/limitio.go index 2177819..1848643 100644 --- a/pkg/cloudapi/disks/limitio.go +++ b/pkg/cloudapi/disks/limitio.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // LimitIORequest struct for limit IO diff --git a/pkg/cloudapi/disks/list.go b/pkg/cloudapi/disks/list.go index 9549fd7..ad63579 100644 --- a/pkg/cloudapi/disks/list.go +++ b/pkg/cloudapi/disks/list.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ListRequest struct to get list of disks @@ -46,6 +46,10 @@ type ListRequest struct { // Required: false SEPID uint64 `url:"sepId,omitempty" json:"sepId,omitempty"` + // Find by storage policy id + // Required: false + StoragePolicyID uint64 `url:"storage_policy_id,omitempty" json:"storage_policy_id,omitempty"` + // Find by pool name // Required: false Pool string `url:"pool,omitempty" json:"pool,omitempty"` diff --git a/pkg/cloudapi/disks/list_deleted.go b/pkg/cloudapi/disks/list_deleted.go index 0da1623..c7c591c 100644 --- a/pkg/cloudapi/disks/list_deleted.go +++ b/pkg/cloudapi/disks/list_deleted.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ListDeletedRequest struct to get list of deleted disks diff --git a/pkg/cloudapi/disks/list_types.go b/pkg/cloudapi/disks/list_types.go index 39f6e28..6a06ad0 100644 --- a/pkg/cloudapi/disks/list_types.go +++ b/pkg/cloudapi/disks/list_types.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ListTypesRequest struct to get list types of disks diff --git a/pkg/cloudapi/disks/list_unattached.go b/pkg/cloudapi/disks/list_unattached.go index 9a5de6f..9b100a3 100644 --- a/pkg/cloudapi/disks/list_unattached.go +++ b/pkg/cloudapi/disks/list_unattached.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ListUnattachedRequest struct to get list of unattached disk @@ -38,6 +38,10 @@ type ListUnattachedRequest struct { // Required: false SEPID uint64 `url:"sepId,omitempty" json:"sepId,omitempty"` + // Find by storage policy id + // Required: false + StoragePolicyID uint64 `url:"storage_policy_id,omitempty" json:"storage_policy_id,omitempty"` + // Find by pool name // Required: false Pool string `url:"pool,omitempty" json:"pool,omitempty"` diff --git a/pkg/cloudapi/disks/models.go b/pkg/cloudapi/disks/models.go index 026b78e..db67195 100644 --- a/pkg/cloudapi/disks/models.go +++ b/pkg/cloudapi/disks/models.go @@ -119,9 +119,15 @@ type ItemDisk struct { // Status Status string `json:"status"` + // Storage policy ID + StoragePolicyID uint64 `json:"storage_policy_id"` + // Tech status TechStatus string `json:"techStatus"` + // Need to clean before destroy + ToClean bool `json:"to_clean"` + // Type Type string `json:"type"` @@ -477,9 +483,15 @@ type RecordDisk struct { // Status Status string `json:"status"` + // Storage policy ID + StoragePolicyID uint64 `json:"storage_policy_id"` + // Tech status TechStatus string `json:"techStatus"` + // Need to clean before destroy + ToClean bool `json:"to_clean"` + // Type Type string `json:"type"` diff --git a/pkg/cloudapi/disks/rename.go b/pkg/cloudapi/disks/rename.go index 8956e8e..2d46251 100644 --- a/pkg/cloudapi/disks/rename.go +++ b/pkg/cloudapi/disks/rename.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // RenameRequest struct to rename disk diff --git a/pkg/cloudapi/disks/replicate.go b/pkg/cloudapi/disks/replicate.go index 557699e..fdd6022 100644 --- a/pkg/cloudapi/disks/replicate.go +++ b/pkg/cloudapi/disks/replicate.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ReplicateRequest struct to create an empty disk in chosen SEP and pool combination. @@ -25,9 +25,13 @@ type ReplicateRequest struct { // Pool name to create slave disk in // Required: true PoolName string `url:"poolName" json:"poolName" validate:"required"` + + // ID of the storage policy under the disk will be created + // Required: true + StoragePolicyID uint64 `url:"storage_policy_id" json:"storage_policy_id" validate:"required"` } -// 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 // Note: only TATLIN type SEP are supported for replications between func (d Disks) Replicate(ctx context.Context, req ReplicateRequest) (uint64, error) { diff --git a/pkg/cloudapi/disks/replication_resume.go b/pkg/cloudapi/disks/replication_resume.go index 19a8791..e75a0a9 100644 --- a/pkg/cloudapi/disks/replication_resume.go +++ b/pkg/cloudapi/disks/replication_resume.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ReplicationResume struct to resume suspended replication diff --git a/pkg/cloudapi/disks/replication_reverse.go b/pkg/cloudapi/disks/replication_reverse.go index 454513e..79af200 100644 --- a/pkg/cloudapi/disks/replication_reverse.go +++ b/pkg/cloudapi/disks/replication_reverse.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ReplicationReverseRequest struct to change role between disks replications diff --git a/pkg/cloudapi/disks/replication_start.go b/pkg/cloudapi/disks/replication_start.go index 1dd241d..7445729 100644 --- a/pkg/cloudapi/disks/replication_start.go +++ b/pkg/cloudapi/disks/replication_start.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ReplicationStartRequest struct to starts replication between two chosen disks diff --git a/pkg/cloudapi/disks/replication_status.go b/pkg/cloudapi/disks/replication_status.go index e0a42e3..bce2d1c 100644 --- a/pkg/cloudapi/disks/replication_status.go +++ b/pkg/cloudapi/disks/replication_status.go @@ -4,7 +4,7 @@ import ( "context" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ReplicationStatusRequest struct to get replication status diff --git a/pkg/cloudapi/disks/replication_stop.go b/pkg/cloudapi/disks/replication_stop.go index 693763e..f343852 100644 --- a/pkg/cloudapi/disks/replication_stop.go +++ b/pkg/cloudapi/disks/replication_stop.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ReplicationStopRequest struct to remove replication between disks completely diff --git a/pkg/cloudapi/disks/replication_suspend.go b/pkg/cloudapi/disks/replication_suspend.go index 1e705d7..64fbc0e 100644 --- a/pkg/cloudapi/disks/replication_suspend.go +++ b/pkg/cloudapi/disks/replication_suspend.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ReplicationSuspendRequest struct to pause replication with possibility to resume from pause moment diff --git a/pkg/cloudapi/disks/resize.go b/pkg/cloudapi/disks/resize.go index 13381d3..4fece51 100644 --- a/pkg/cloudapi/disks/resize.go +++ b/pkg/cloudapi/disks/resize.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ResizeRequest struct to resize disk diff --git a/pkg/cloudapi/disks/restore.go b/pkg/cloudapi/disks/restore.go index fcacebd..0c42eaf 100644 --- a/pkg/cloudapi/disks/restore.go +++ b/pkg/cloudapi/disks/restore.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // RestoreRequest struct to restore a deleted unattached disk diff --git a/pkg/cloudapi/disks/serialize.go b/pkg/cloudapi/disks/serialize.go index fb763e8..5dbc78e 100644 --- a/pkg/cloudapi/disks/serialize.go +++ b/pkg/cloudapi/disks/serialize.go @@ -3,7 +3,7 @@ package disks import ( "encoding/json" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/serialization" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/serialization" ) // Serialize returns JSON-serialized []byte. Used as a wrapper over json.Marshal and json.MarshalIndent functions. diff --git a/pkg/cloudapi/disks/share.go b/pkg/cloudapi/disks/share.go index 5bf0207..2456ca0 100644 --- a/pkg/cloudapi/disks/share.go +++ b/pkg/cloudapi/disks/share.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ShareRequest struct to share disk data diff --git a/pkg/cloudapi/disks/snapshot_delete.go b/pkg/cloudapi/disks/snapshot_delete.go index 81c6f9b..ba538f9 100644 --- a/pkg/cloudapi/disks/snapshot_delete.go +++ b/pkg/cloudapi/disks/snapshot_delete.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // SnapshotDeleteRequest struct to delete snapshot diff --git a/pkg/cloudapi/disks/snapshot_rollback.go b/pkg/cloudapi/disks/snapshot_rollback.go index 21de92b..702ea03 100644 --- a/pkg/cloudapi/disks/snapshot_rollback.go +++ b/pkg/cloudapi/disks/snapshot_rollback.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // SnapshotRollbackRequest struct to rollback snapshot diff --git a/pkg/cloudapi/disks/unshare.go b/pkg/cloudapi/disks/unshare.go index ca3f906..d244d43 100644 --- a/pkg/cloudapi/disks/unshare.go +++ b/pkg/cloudapi/disks/unshare.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // UnshareRequest struct to unshare data disk diff --git a/pkg/cloudapi/dpdknet.go b/pkg/cloudapi/dpdknet.go index 29d3194..02051df 100644 --- a/pkg/cloudapi/dpdknet.go +++ b/pkg/cloudapi/dpdknet.go @@ -1,6 +1,6 @@ package cloudapi -import "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/pkg/cloudapi/dpdknet" +import "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/pkg/cloudapi/dpdknet" // Accessing the DPDKNet method group func (ca *CloudAPI) DPDKNet() *dpdknet.DPDKNet { diff --git a/pkg/cloudapi/dpdknet/dpdknet.go b/pkg/cloudapi/dpdknet/dpdknet.go index 0d2500f..eb87237 100644 --- a/pkg/cloudapi/dpdknet/dpdknet.go +++ b/pkg/cloudapi/dpdknet/dpdknet.go @@ -1,6 +1,6 @@ package dpdknet -import "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/interfaces" +import "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/interfaces" // Structure for creating request to DPDK network type DPDKNet struct { diff --git a/pkg/cloudapi/dpdknet/get.go b/pkg/cloudapi/dpdknet/get.go index 9187e48..e206831 100644 --- a/pkg/cloudapi/dpdknet/get.go +++ b/pkg/cloudapi/dpdknet/get.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // GetRequest struct to get information about DPDK network diff --git a/pkg/cloudapi/dpdknet/list.go b/pkg/cloudapi/dpdknet/list.go index e7053dc..d26d13d 100644 --- a/pkg/cloudapi/dpdknet/list.go +++ b/pkg/cloudapi/dpdknet/list.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ListRequest struct to get list of DPDK networks diff --git a/pkg/cloudapi/dpdknet/models.go b/pkg/cloudapi/dpdknet/models.go index 7bcf84d..ebcca93 100644 --- a/pkg/cloudapi/dpdknet/models.go +++ b/pkg/cloudapi/dpdknet/models.go @@ -14,6 +14,9 @@ type RecordDPDKNet struct { // Description Description string `json:"description"` + // Enable Security Groups + EnableSecGroups bool `json:"enable_secgroups"` + // Grid ID GID uint64 `json:"gid"` @@ -63,6 +66,9 @@ type ItemDPDKNet struct { // Description Description string `json:"description"` + // Enable Security Groups + EnableSecGroups bool `json:"enable_secgroups"` + // Grid ID GID uint64 `json:"gid"` diff --git a/pkg/cloudapi/extnet.go b/pkg/cloudapi/extnet.go index 8dff27f..356effc 100644 --- a/pkg/cloudapi/extnet.go +++ b/pkg/cloudapi/extnet.go @@ -1,7 +1,7 @@ package cloudapi import ( - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/pkg/cloudapi/extnet" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/pkg/cloudapi/extnet" ) // Accessing the ExtNet method group diff --git a/pkg/cloudapi/extnet/extnet.go b/pkg/cloudapi/extnet/extnet.go index 6f972b8..dff778e 100644 --- a/pkg/cloudapi/extnet/extnet.go +++ b/pkg/cloudapi/extnet/extnet.go @@ -2,7 +2,7 @@ package extnet import ( - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/interfaces" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/interfaces" ) // Structure for creating request to extnet diff --git a/pkg/cloudapi/extnet/get.go b/pkg/cloudapi/extnet/get.go index 6bfd273..ff11202 100644 --- a/pkg/cloudapi/extnet/get.go +++ b/pkg/cloudapi/extnet/get.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // GetRequest struct to get detailed information about external network diff --git a/pkg/cloudapi/extnet/get_reserved_ip.go b/pkg/cloudapi/extnet/get_reserved_ip.go index 7485884..4b8cdd5 100644 --- a/pkg/cloudapi/extnet/get_reserved_ip.go +++ b/pkg/cloudapi/extnet/get_reserved_ip.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // GetRequest struct to get information about reserved address or address poll diff --git a/pkg/cloudapi/extnet/list.go b/pkg/cloudapi/extnet/list.go index f30aa9f..eee1163 100644 --- a/pkg/cloudapi/extnet/list.go +++ b/pkg/cloudapi/extnet/list.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ListRequest struct to get list of external network @@ -42,6 +42,11 @@ type ListRequest struct { // Required: false SortBy string `url:"sortBy,omitempty" json:"sortBy,omitempty" validate:"omitempty,sortBy"` + // Sort by zone id + // Default value: 0 + // Required: false + ZoneID uint64 `url:"zone_id,omitempty" json:"zone_id,omitempty"` + // Page number // Required: false Page uint64 `url:"page,omitempty" json:"page,omitempty"` diff --git a/pkg/cloudapi/extnet/list_computes.go b/pkg/cloudapi/extnet/list_computes.go index 4a2a8e1..42dff8d 100644 --- a/pkg/cloudapi/extnet/list_computes.go +++ b/pkg/cloudapi/extnet/list_computes.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ListComputesRequest struct to get list computes diff --git a/pkg/cloudapi/extnet/models.go b/pkg/cloudapi/extnet/models.go index 8911f61..b7a7e9d 100644 --- a/pkg/cloudapi/extnet/models.go +++ b/pkg/cloudapi/extnet/models.go @@ -172,6 +172,9 @@ type RecordExtNet struct { // Excluded Excluded []Excluded `json:"excluded"` + // Enable Security Groups + EnableSecGroups bool `json:"enable_secgroups"` + // Free IPs FreeIPs int64 `json:"free_ips"` @@ -193,14 +196,17 @@ type RecordExtNet struct { // Milestones Milestones uint64 `json:"milestones"` + // MTU + MTU uint64 `json:"mtu"` + // Name Name string `json:"name"` // Network Network string `json:"network"` - // Network ID - NetworkID uint64 `json:"networkId"` + // Network IDs + NetworkIDs NetworkIDs `json:"networkIds"` // NTP NTP []string `json:"ntp"` @@ -217,9 +223,18 @@ type RecordExtNet struct { // PriVNFDevID PriVNFDevID uint64 `json:"priVnfDevId"` + // Redundant + Redundant bool `json:"redundant"` + + // SecVnfDevId + SecVNFDevID uint64 `json:"secVnfDevId"` + // List reservations Reservations ListReservations `json:"reservations"` + // List pre-reservations + PreReservations ListReservations `json:"pre-reservations"` + // Shared with SharedWith []uint64 `json:"sharedWith"` @@ -231,6 +246,17 @@ type RecordExtNet struct { // VNFs VNFs VNFs `json:"vnfs"` + + // Zone ID + ZoneID uint64 `json:"zoneId"` +} + +type NetworkIDs struct { + // Primary + Primary uint64 `json:"primary"` + + // Secondary + Secondary uint64 `json:"secondary"` } // Detailed information about reserved address or address pool diff --git a/pkg/cloudapi/extnet/serialize.go b/pkg/cloudapi/extnet/serialize.go index d140922..e2132ac 100644 --- a/pkg/cloudapi/extnet/serialize.go +++ b/pkg/cloudapi/extnet/serialize.go @@ -3,7 +3,7 @@ package extnet import ( "encoding/json" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/serialization" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/serialization" ) // Serialize returns JSON-serialized []byte. Used as a wrapper over json.Marshal and json.MarshalIndent functions. diff --git a/pkg/cloudapi/flipgroup.go b/pkg/cloudapi/flipgroup.go index 9f4be79..1c836c3 100644 --- a/pkg/cloudapi/flipgroup.go +++ b/pkg/cloudapi/flipgroup.go @@ -1,7 +1,7 @@ package cloudapi import ( - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/pkg/cloudapi/flipgroup" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/pkg/cloudapi/flipgroup" ) // Accessing the FLIPGroup method group diff --git a/pkg/cloudapi/flipgroup/compute_add.go b/pkg/cloudapi/flipgroup/compute_add.go index 7f87623..6aa0334 100644 --- a/pkg/cloudapi/flipgroup/compute_add.go +++ b/pkg/cloudapi/flipgroup/compute_add.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ComputeAddRequest struct to add compute instance diff --git a/pkg/cloudapi/flipgroup/compute_remove.go b/pkg/cloudapi/flipgroup/compute_remove.go index f7f821a..9e5613e 100644 --- a/pkg/cloudapi/flipgroup/compute_remove.go +++ b/pkg/cloudapi/flipgroup/compute_remove.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ComputeRemoveRequest struct to remove compute instance diff --git a/pkg/cloudapi/flipgroup/create.go b/pkg/cloudapi/flipgroup/create.go index 3b8f6dc..b478c26 100644 --- a/pkg/cloudapi/flipgroup/create.go +++ b/pkg/cloudapi/flipgroup/create.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // CreateRequest struct to create FLIPGroup @@ -32,8 +32,9 @@ type CreateRequest struct { // Type of client // - 'compute' // - 'vins' (will be later) - // Required: true - ClientType string `url:"clientType" json:"clientType" validate:"flipgroupClientType"` + // Required: false + // Default: "compute" + ClientType string `url:"clientType,omitempty" json:"clientType,omitempty"` // IP address to associate with this group. If empty, the platform will autoselect IP address // Required: false diff --git a/pkg/cloudapi/flipgroup/delete.go b/pkg/cloudapi/flipgroup/delete.go index 367691e..fcf4718 100644 --- a/pkg/cloudapi/flipgroup/delete.go +++ b/pkg/cloudapi/flipgroup/delete.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // DeleteRequest struct to delete FLIPGroup diff --git a/pkg/cloudapi/flipgroup/edit.go b/pkg/cloudapi/flipgroup/edit.go index 77b8ad2..50fe0c0 100644 --- a/pkg/cloudapi/flipgroup/edit.go +++ b/pkg/cloudapi/flipgroup/edit.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // EditRequest struct to edit FLIPGroup diff --git a/pkg/cloudapi/flipgroup/flipgroup.go b/pkg/cloudapi/flipgroup/flipgroup.go index d532897..220dd30 100644 --- a/pkg/cloudapi/flipgroup/flipgroup.go +++ b/pkg/cloudapi/flipgroup/flipgroup.go @@ -2,7 +2,7 @@ package flipgroup import ( - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/interfaces" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/interfaces" ) // Structure for creating request to FLIPGroup diff --git a/pkg/cloudapi/flipgroup/get.go b/pkg/cloudapi/flipgroup/get.go index 6693f1e..f4ad35f 100644 --- a/pkg/cloudapi/flipgroup/get.go +++ b/pkg/cloudapi/flipgroup/get.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // GetRequest struct to get information about FLIPGroup diff --git a/pkg/cloudapi/flipgroup/list.go b/pkg/cloudapi/flipgroup/list.go index e7b014a..79503eb 100644 --- a/pkg/cloudapi/flipgroup/list.go +++ b/pkg/cloudapi/flipgroup/list.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ListRequest struct to get list of FLIPGroup available to the current user diff --git a/pkg/cloudapi/flipgroup/serialize.go b/pkg/cloudapi/flipgroup/serialize.go index a53fca9..49cb39b 100644 --- a/pkg/cloudapi/flipgroup/serialize.go +++ b/pkg/cloudapi/flipgroup/serialize.go @@ -3,7 +3,7 @@ package flipgroup import ( "encoding/json" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/serialization" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/serialization" ) // Serialize returns JSON-serialized []byte. Used as a wrapper over json.Marshal and json.MarshalIndent functions. diff --git a/pkg/cloudapi/image.go b/pkg/cloudapi/image.go index 5676bb9..4ecbb21 100644 --- a/pkg/cloudapi/image.go +++ b/pkg/cloudapi/image.go @@ -1,7 +1,7 @@ package cloudapi import ( - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/pkg/cloudapi/image" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/pkg/cloudapi/image" ) // Accessing the Image method group diff --git a/pkg/cloudapi/image/change_storage_policy.go b/pkg/cloudapi/image/change_storage_policy.go new file mode 100644 index 0000000..b1b3cd4 --- /dev/null +++ b/pkg/cloudapi/image/change_storage_policy.go @@ -0,0 +1,41 @@ +package image + +import ( + "context" + "net/http" + "strconv" + + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" +) + +type ChangeStoragePolicyRequest struct { + // ID of the image to change the storage policy + // Required: true + ImageID uint64 `url:"image_id" json:"image_id" validate:"required"` + + // ID of the storage policy to move the image to + // Required: true + StoragePolicyID uint64 `url:"storage_policy_id" json:"storage_policy_id" validate:"required"` +} + +// ChangeStoragePolicy changes the storage policy of the image chosen +func (i Image) ChangeStoragePolicy(ctx context.Context, req ChangeStoragePolicyRequest) (bool, error) { + err := validators.ValidateRequest(req) + if err != nil { + return false, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudapi/image/change_storage_policy" + + res, err := i.client.DecortApiCall(ctx, http.MethodPost, url, req) + if err != nil { + return false, err + } + + result, err := strconv.ParseBool(string(res)) + if err != nil { + return false, err + } + + return result, nil +} diff --git a/pkg/cloudapi/image/create.go b/pkg/cloudapi/image/create.go index b8d2cee..819f1d5 100644 --- a/pkg/cloudapi/image/create.go +++ b/pkg/cloudapi/image/create.go @@ -2,10 +2,11 @@ package image import ( "context" + "encoding/json" "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // CreateRequest struct to create image @@ -34,6 +35,10 @@ type CreateRequest struct { // Required: true AccountID uint64 `url:"accountId" json:"accountId" validate:"required"` + // ID of the chosen storage policy + // Required: true + StoragePolicyID uint64 `url:"storage_policy_id" json:"storage_policy_id" validate:"required"` + // Select a network interface naming pattern for your Linux machine. eth - onboard, ens - pci slot naming // Should be: // - eth @@ -68,17 +73,11 @@ type CreateRequest struct { // Pool for image create // Required: false Pool string `url:"poolName,omitempty" json:"poolName,omitempty"` +} - // Binary architecture of this image - // Should be: - // - X86_64 - // Required: false - Architecture string `url:"architecture,omitempty" json:"architecture,omitempty" validate:"omitempty,imageArchitecture"` - - // List of types of compute suitable for image - // Example: [ "KVM_X86" ] - // Required: true - Drivers []string `url:"drivers" json:"drivers" validate:"min=1,max=2,imageDrivers"` +type asyncWrapperCreateRequest struct { + CreateRequest + AsyncMode bool `url:"asyncMode"` } // Create creates image from a media identified by URL @@ -102,3 +101,29 @@ func (i Image) Create(ctx context.Context, req CreateRequest) (uint64, error) { return result, nil } + +// AsyncCreate creates image from a media identified by URL in async mode +func (i Image) AsyncCreate(ctx context.Context, req CreateRequest) (string, error) { + err := validators.ValidateRequest(req) + if err != nil { + return "", validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudapi/image/create" + + asyncReq := asyncWrapperCreateRequest{CreateRequest: req, AsyncMode: true} + + res, err := i.client.DecortApiCall(ctx, http.MethodPost, url, asyncReq) + if err != nil { + return " ", err + } + + var taskID string + + err = json.Unmarshal(res, &taskID) + if err != nil { + return "", err + } + + return taskID, nil +} diff --git a/pkg/cloudapi/image/create_virtual.go b/pkg/cloudapi/image/create_virtual.go index 296b1dc..8e25d99 100644 --- a/pkg/cloudapi/image/create_virtual.go +++ b/pkg/cloudapi/image/create_virtual.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // CreateVirtualRequest struct to create virtual image @@ -17,6 +17,11 @@ type CreateVirtualRequest struct { // ID of real image to link this virtual image to upon creation // Required: true TargetID uint64 `url:"targetId" json:"targetId" validate:"required"` + + // AccountID to make the virtual image exclusive + // Required: false + // Default: 0 + AccountID uint64 `url:"accountId,omitempty" json:"accountId,omitempty"` } // CreateVirtual creates virtual image diff --git a/pkg/cloudapi/image/delete.go b/pkg/cloudapi/image/delete.go index 46ef137..1981364 100644 --- a/pkg/cloudapi/image/delete.go +++ b/pkg/cloudapi/image/delete.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // DeleteRequest struct to delete image diff --git a/pkg/cloudapi/image/get.go b/pkg/cloudapi/image/get.go index 5dd9943..8404553 100644 --- a/pkg/cloudapi/image/get.go +++ b/pkg/cloudapi/image/get.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // GetRequest struct to get detailed information about image diff --git a/pkg/cloudapi/image/image.go b/pkg/cloudapi/image/image.go index 3834a40..6dfe263 100644 --- a/pkg/cloudapi/image/image.go +++ b/pkg/cloudapi/image/image.go @@ -2,7 +2,7 @@ package image import ( - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/interfaces" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/interfaces" ) // Structure for creating request to image diff --git a/pkg/cloudapi/image/link.go b/pkg/cloudapi/image/link.go index afdee33..0b03857 100644 --- a/pkg/cloudapi/image/link.go +++ b/pkg/cloudapi/image/link.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // LinkRequest struct to link virtual image to another image diff --git a/pkg/cloudapi/image/list.go b/pkg/cloudapi/image/list.go index 90d2576..8779a9a 100644 --- a/pkg/cloudapi/image/list.go +++ b/pkg/cloudapi/image/list.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ListRequest struct to get list of available images @@ -26,10 +26,6 @@ type ListRequest struct { // Required: false Status string `url:"status,omitempty" json:"status,omitempty"` - // Find by architecture - // Required: false - Architecture string `url:"architecture,omitempty" json:"architecture,omitempty"` - // Find by type // Required: false TypeImage string `url:"typeImage,omitempty" json:"typeImage,omitempty"` @@ -73,6 +69,10 @@ type ListRequest struct { // Find by enabled True or False // Required: false Enabled interface{} `url:"enabled,omitempty" json:"enabled,omitempty" validate:"omitempty,isBool"` + + // Find by storage policy id + // Required: false + StoragePolicyID uint64 `url:"storage_policy_id,omitempty" json:"storage_policy_id,omitempty"` } // List gets list of available images as a ListImages struct, optionally filtering by account ID diff --git a/pkg/cloudapi/image/models.go b/pkg/cloudapi/image/models.go index fe455e2..d71f0df 100644 --- a/pkg/cloudapi/image/models.go +++ b/pkg/cloudapi/image/models.go @@ -50,6 +50,9 @@ type ItemImage struct { // Status Status string `json:"status"` + // Storage policy ID + StoragePolicyID uint64 `json:"storage_policy_id"` + // Type Type string `json:"type"` @@ -191,6 +194,9 @@ type RecordImage struct { // Status Status string `json:"status"` + // Storage policy ID + StoragePolicyID uint64 `json:"storage_policy_id"` + // Tech status TechStatus string `json:"techStatus"` diff --git a/pkg/cloudapi/image/rename.go b/pkg/cloudapi/image/rename.go index adbbab6..fecda9c 100644 --- a/pkg/cloudapi/image/rename.go +++ b/pkg/cloudapi/image/rename.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // RenameRequest struct to rename image diff --git a/pkg/cloudapi/image/serialize.go b/pkg/cloudapi/image/serialize.go index eee9cb7..b6c8596 100644 --- a/pkg/cloudapi/image/serialize.go +++ b/pkg/cloudapi/image/serialize.go @@ -3,7 +3,7 @@ package image import ( "encoding/json" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/serialization" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/serialization" ) // Serialize returns JSON-serialized []byte. Used as a wrapper over json.Marshal and json.MarshalIndent functions. diff --git a/pkg/cloudapi/k8ci.go b/pkg/cloudapi/k8ci.go index a76fd72..18f39a4 100644 --- a/pkg/cloudapi/k8ci.go +++ b/pkg/cloudapi/k8ci.go @@ -1,7 +1,7 @@ package cloudapi import ( - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/pkg/cloudapi/k8ci" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/pkg/cloudapi/k8ci" ) // Accessing the K8CI method group diff --git a/pkg/cloudapi/k8ci/get.go b/pkg/cloudapi/k8ci/get.go index ddd289e..8db5283 100644 --- a/pkg/cloudapi/k8ci/get.go +++ b/pkg/cloudapi/k8ci/get.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // GetRequest struct to get information about K8CI diff --git a/pkg/cloudapi/k8ci/k8ci.go b/pkg/cloudapi/k8ci/k8ci.go index bc7542d..0a37268 100644 --- a/pkg/cloudapi/k8ci/k8ci.go +++ b/pkg/cloudapi/k8ci/k8ci.go @@ -2,7 +2,7 @@ package k8ci import ( - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/interfaces" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/interfaces" ) // Structure for creating request to K8CI diff --git a/pkg/cloudapi/k8ci/list.go b/pkg/cloudapi/k8ci/list.go index 720e64f..c1bd796 100644 --- a/pkg/cloudapi/k8ci/list.go +++ b/pkg/cloudapi/k8ci/list.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ListRequest struct to get list of information about images @@ -22,14 +22,6 @@ type ListRequest struct { // Required: false Status string `url:"status,omitempty" json:"status,omitempty"` - // Find by worker driver - // Required: false - WorkerDriver string `url:"workerDriver,omitempty" json:"workerDriver,omitempty"` - - // Find by master driver - // Required: false - MasterDriver string `url:"masterDriver,omitempty" json:"masterDriver,omitempty"` - // Find by network plugin // Required: false NetworkPlugins string `url:"netPlugins,omitempty" json:"netPlugins,omitempty"` diff --git a/pkg/cloudapi/k8ci/list_deleted.go b/pkg/cloudapi/k8ci/list_deleted.go index 47e2fe9..d4efbf7 100644 --- a/pkg/cloudapi/k8ci/list_deleted.go +++ b/pkg/cloudapi/k8ci/list_deleted.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ListDeletedRequest struct to get list information about deleted k8ci items @@ -18,14 +18,6 @@ type ListDeletedRequest struct { // Required: false Name string `url:"name,omitempty" json:"name,omitempty"` - // Find by worker driver - // Required: false - WorkerDriver string `url:"workerDriver,omitempty" json:"workerDriver,omitempty"` - - // Find by master driver - // Required: false - MasterDriver string `url:"masterDriver,omitempty" json:"masterDriver,omitempty"` - // Find by network plugin // Required: false NetworkPlugins string `url:"netPlugins,omitempty" json:"netPlugins,omitempty"` diff --git a/pkg/cloudapi/k8ci/serialize.go b/pkg/cloudapi/k8ci/serialize.go index f5d61be..b33c48a 100644 --- a/pkg/cloudapi/k8ci/serialize.go +++ b/pkg/cloudapi/k8ci/serialize.go @@ -3,7 +3,7 @@ package k8ci import ( "encoding/json" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/serialization" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/serialization" ) // Serialize returns JSON-serialized []byte. Used as a wrapper over json.Marshal and json.MarshalIndent functions. diff --git a/pkg/cloudapi/k8s.go b/pkg/cloudapi/k8s.go index f848841..6751745 100644 --- a/pkg/cloudapi/k8s.go +++ b/pkg/cloudapi/k8s.go @@ -1,7 +1,7 @@ package cloudapi import ( - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/pkg/cloudapi/k8s" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/pkg/cloudapi/k8s" ) // Accessing the K8S method group diff --git a/pkg/cloudapi/k8s/create.go b/pkg/cloudapi/k8s/create.go index d6f3480..55a1859 100644 --- a/pkg/cloudapi/k8s/create.go +++ b/pkg/cloudapi/k8s/create.go @@ -5,7 +5,7 @@ import ( "net/http" "strings" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // CreateRequest struct to create kubernetes cluster @@ -31,6 +31,10 @@ type CreateRequest struct { // Required: true NetworkPlugin string `url:"networkPlugin" json:"networkPlugin" validate:"required,networkPlugin"` + // ID of the chosen storage policy + // Required: true + StoragePolicyID uint64 `url:"storage_policy_id" json:"storage_policy_id" validate:"required"` + // ID of SEP to create boot disks for master nodes. Uses images SEP ID if not set // Required: false MasterSEPID uint64 `url:"masterSepId,omitempty" json:"masterSepId,omitempty"` @@ -166,6 +170,10 @@ type CreateRequest struct { // Type of the emulated system, Q35 or i440fx // Required: false Chipset string `url:"chipset,omitempty" json:"chipset,omitempty" validate:"omitempty,chipset"` + + // Zone ID + // Required: false + ZoneID uint64 `url:"zoneId,omitempty" json:"zoneId,omitempty"` } // GetRAM returns RAM field values diff --git a/pkg/cloudapi/k8s/delete.go b/pkg/cloudapi/k8s/delete.go index 151efad..4a510ff 100644 --- a/pkg/cloudapi/k8s/delete.go +++ b/pkg/cloudapi/k8s/delete.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // DeleteRequest struct to delete kubernetes cluster diff --git a/pkg/cloudapi/k8s/delete_master_from_group.go b/pkg/cloudapi/k8s/delete_master_from_group.go index d9378c6..c2463b6 100644 --- a/pkg/cloudapi/k8s/delete_master_from_group.go +++ b/pkg/cloudapi/k8s/delete_master_from_group.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // DeleteMasterFromGroupRequest struct to delete master from group diff --git a/pkg/cloudapi/k8s/delete_worker_from_group.go b/pkg/cloudapi/k8s/delete_worker_from_group.go index ffb6b2d..f619b5c 100644 --- a/pkg/cloudapi/k8s/delete_worker_from_group.go +++ b/pkg/cloudapi/k8s/delete_worker_from_group.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // DeleteWorkerFromGroupRequest struct to delete worker from group diff --git a/pkg/cloudapi/k8s/disable_enable.go b/pkg/cloudapi/k8s/disable_enable.go index 0105049..991e23e 100644 --- a/pkg/cloudapi/k8s/disable_enable.go +++ b/pkg/cloudapi/k8s/disable_enable.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // DisableEnableRequest struct to disable/enable kubernetes cluster diff --git a/pkg/cloudapi/k8s/find_group_by_label.go b/pkg/cloudapi/k8s/find_group_by_label.go index c47ad9a..0c5d6f6 100644 --- a/pkg/cloudapi/k8s/find_group_by_label.go +++ b/pkg/cloudapi/k8s/find_group_by_label.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // FindGroupByLabelRequest struct to get information about group of kubernetes cluster diff --git a/pkg/cloudapi/k8s/get.go b/pkg/cloudapi/k8s/get.go index 0e7a767..8c7dd94 100644 --- a/pkg/cloudapi/k8s/get.go +++ b/pkg/cloudapi/k8s/get.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // GetRequest struct to get detailed information about kubernetes cluster diff --git a/pkg/cloudapi/k8s/get_config.go b/pkg/cloudapi/k8s/get_config.go index b71848e..fca3737 100644 --- a/pkg/cloudapi/k8s/get_config.go +++ b/pkg/cloudapi/k8s/get_config.go @@ -4,7 +4,7 @@ import ( "context" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // GetConfigRequest struct to get configuration of kubernetes cluster diff --git a/pkg/cloudapi/k8s/get_node_annotations.go b/pkg/cloudapi/k8s/get_node_annotations.go index f7034cf..a8ea9eb 100644 --- a/pkg/cloudapi/k8s/get_node_annotations.go +++ b/pkg/cloudapi/k8s/get_node_annotations.go @@ -4,7 +4,7 @@ import ( "context" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // GetNodeAnnotationsRequest struct to get node annotations diff --git a/pkg/cloudapi/k8s/get_node_labels.go b/pkg/cloudapi/k8s/get_node_labels.go index 01e317e..30465b6 100644 --- a/pkg/cloudapi/k8s/get_node_labels.go +++ b/pkg/cloudapi/k8s/get_node_labels.go @@ -4,7 +4,7 @@ import ( "context" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // GetNodeLabelsRequest struct to get node labels diff --git a/pkg/cloudapi/k8s/get_node_taints.go b/pkg/cloudapi/k8s/get_node_taints.go index 3f3041a..278719b 100644 --- a/pkg/cloudapi/k8s/get_node_taints.go +++ b/pkg/cloudapi/k8s/get_node_taints.go @@ -4,7 +4,7 @@ import ( "context" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // GetNodeTaintsRequest struct to get node taints diff --git a/pkg/cloudapi/k8s/get_worker_nodes_meta_data.go b/pkg/cloudapi/k8s/get_worker_nodes_meta_data.go index c4c9a01..9c86e5d 100644 --- a/pkg/cloudapi/k8s/get_worker_nodes_meta_data.go +++ b/pkg/cloudapi/k8s/get_worker_nodes_meta_data.go @@ -4,7 +4,7 @@ import ( "context" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // GetWorkerNodesMetaDataRequest struct to get worker group metadata by ID diff --git a/pkg/cloudapi/k8s/k8s.go b/pkg/cloudapi/k8s/k8s.go index 99f53b2..7e24ca9 100644 --- a/pkg/cloudapi/k8s/k8s.go +++ b/pkg/cloudapi/k8s/k8s.go @@ -2,7 +2,7 @@ package k8s import ( - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/interfaces" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/interfaces" ) // Structure for creating request to K8S diff --git a/pkg/cloudapi/k8s/list.go b/pkg/cloudapi/k8s/list.go index 7cba8e4..0e20543 100644 --- a/pkg/cloudapi/k8s/list.go +++ b/pkg/cloudapi/k8s/list.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ListRequest struct to get list information K8S @@ -46,6 +46,11 @@ type ListRequest struct { // Required: false IncludeDeleted bool `url:"includedeleted,omitempty" json:"includedeleted,omitempty"` + // Sort by zone id + // Default value: 0 + // Required: false + ZoneID uint64 `url:"zone_id,omitempty" json:"zone_id,omitempty"` + // Sort by one of supported fields, format +|-(field) // Required: false SortBy string `url:"sortBy,omitempty" json:"sortBy,omitempty" validate:"omitempty,sortBy"` diff --git a/pkg/cloudapi/k8s/list_deleted.go b/pkg/cloudapi/k8s/list_deleted.go index 166a1da..8851c89 100644 --- a/pkg/cloudapi/k8s/list_deleted.go +++ b/pkg/cloudapi/k8s/list_deleted.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ListDeletedRequest struct to get list of deleted kubernetes cluster diff --git a/pkg/cloudapi/k8s/migrate_to_zone.go b/pkg/cloudapi/k8s/migrate_to_zone.go new file mode 100644 index 0000000..c217b68 --- /dev/null +++ b/pkg/cloudapi/k8s/migrate_to_zone.go @@ -0,0 +1,42 @@ +package k8s + +import ( + "context" + "net/http" + "strconv" + + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" +) + +// MigrateToZone struct to move k8s cluster to another zone +type MigrateToZoneRequest struct { + // Kubernetes cluster ID to move + // Required: true + K8SID uint64 `url:"k8sId" json:"k8sId" validate:"required"` + + // ID of the zone to move + // Required: true + ZoneID uint64 `url:"zoneId" json:"zoneId" validate:"required"` +} + +// MigrateToZone moves k8s cluster instance to new zone +func (k8s K8S) MigrateToZone(ctx context.Context, req MigrateToZoneRequest) (bool, error) { + err := validators.ValidateRequest(req) + if err != nil { + return false, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudapi/k8s/migrateToZone" + + res, err := k8s.client.DecortApiCall(ctx, http.MethodPost, url, req) + if err != nil { + return false, err + } + + result, err := strconv.ParseBool(string(res)) + if err != nil { + return false, err + } + + return result, nil +} diff --git a/pkg/cloudapi/k8s/models.go b/pkg/cloudapi/k8s/models.go index d5eb418..8d49c13 100644 --- a/pkg/cloudapi/k8s/models.go +++ b/pkg/cloudapi/k8s/models.go @@ -139,6 +139,9 @@ type RecordK8S struct { // With LB WithLB bool `json:"withLB"` + + // Zone ID + ZoneID uint64 `json:"zoneId"` } // Detailed information about address of the Virtual Internet Protocol @@ -305,6 +308,9 @@ type ItemK8SCluster struct { // List workers group WorkersGroup ListK8SGroups `json:"workersGroups"` + + // Zone ID + ZoneID uint64 `json:"zoneId"` } // Information about service account diff --git a/pkg/cloudapi/k8s/restore.go b/pkg/cloudapi/k8s/restore.go index 3e5ebd7..39e635c 100644 --- a/pkg/cloudapi/k8s/restore.go +++ b/pkg/cloudapi/k8s/restore.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // RestoreRequest struct to restore kubernetes cluster diff --git a/pkg/cloudapi/k8s/serialize.go b/pkg/cloudapi/k8s/serialize.go index def5e2e..18fb4e1 100644 --- a/pkg/cloudapi/k8s/serialize.go +++ b/pkg/cloudapi/k8s/serialize.go @@ -3,7 +3,7 @@ package k8s import ( "encoding/json" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/serialization" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/serialization" ) // Serialize returns JSON-serialized []byte. Used as a wrapper over json.Marshal and json.MarshalIndent functions. diff --git a/pkg/cloudapi/k8s/start.go b/pkg/cloudapi/k8s/start.go index 010c326..743fa79 100644 --- a/pkg/cloudapi/k8s/start.go +++ b/pkg/cloudapi/k8s/start.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // StartRequest struct to start kubernetes cluster diff --git a/pkg/cloudapi/k8s/stop.go b/pkg/cloudapi/k8s/stop.go index 69f0c22..eb988c8 100644 --- a/pkg/cloudapi/k8s/stop.go +++ b/pkg/cloudapi/k8s/stop.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // StopRequest struct to stop kubernetes cluster diff --git a/pkg/cloudapi/k8s/update.go b/pkg/cloudapi/k8s/update.go index 16a5115..7a3d176 100644 --- a/pkg/cloudapi/k8s/update.go +++ b/pkg/cloudapi/k8s/update.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // UpdateRequest struct to update kubernetes cluster diff --git a/pkg/cloudapi/k8s/update_worker_nodes_meta_data.go b/pkg/cloudapi/k8s/update_worker_nodes_meta_data.go index d84e7c7..d3a2623 100644 --- a/pkg/cloudapi/k8s/update_worker_nodes_meta_data.go +++ b/pkg/cloudapi/k8s/update_worker_nodes_meta_data.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // UpdateWorkerNodesMetaDataRequest struct to add worker to a kubernetes cluster diff --git a/pkg/cloudapi/k8s/worker_add.go b/pkg/cloudapi/k8s/worker_add.go index 72abd27..381feba 100644 --- a/pkg/cloudapi/k8s/worker_add.go +++ b/pkg/cloudapi/k8s/worker_add.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // WorkerAddRequest struct to add worker to a kubernetes cluster diff --git a/pkg/cloudapi/k8s/worker_reset.go b/pkg/cloudapi/k8s/worker_reset.go index 5c277f3..222bbe2 100644 --- a/pkg/cloudapi/k8s/worker_reset.go +++ b/pkg/cloudapi/k8s/worker_reset.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // WorkerResetRequest struct for hard reset kubernetes cluster diff --git a/pkg/cloudapi/k8s/worker_restart.go b/pkg/cloudapi/k8s/worker_restart.go index 17caacb..375a784 100644 --- a/pkg/cloudapi/k8s/worker_restart.go +++ b/pkg/cloudapi/k8s/worker_restart.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // WorkerRestartRequest struct to restart worker node diff --git a/pkg/cloudapi/k8s/workers_group_add.go b/pkg/cloudapi/k8s/workers_group_add.go index 0fa9459..df13e35 100644 --- a/pkg/cloudapi/k8s/workers_group_add.go +++ b/pkg/cloudapi/k8s/workers_group_add.go @@ -4,7 +4,7 @@ import ( "context" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // WorkersGroupAddRequest struct to add workers group @@ -17,6 +17,10 @@ type WorkersGroupAddRequest struct { // Required: true Name string `url:"name" json:"name" validate:"required"` + // ID of the chosen storage policy + // Required: true + StoragePolicyID uint64 `url:"storage_policy_id" json:"storage_policy_id" validate:"required"` + // ID of SEP to create boot disks for default worker nodes group. Uses images SEP ID if not set // Required: false WorkerSEPID uint64 `url:"workerSepId,omitempty" json:"workerSepId,omitempty"` diff --git a/pkg/cloudapi/k8s/workers_group_delete.go b/pkg/cloudapi/k8s/workers_group_delete.go index 649538f..f04fa38 100644 --- a/pkg/cloudapi/k8s/workers_group_delete.go +++ b/pkg/cloudapi/k8s/workers_group_delete.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // WorkersGroupDeleteRequest struct to delete workers group diff --git a/pkg/cloudapi/k8s/workers_group_get_by_name.go b/pkg/cloudapi/k8s/workers_group_get_by_name.go index 296f2bd..631f4ed 100644 --- a/pkg/cloudapi/k8s/workers_group_get_by_name.go +++ b/pkg/cloudapi/k8s/workers_group_get_by_name.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // WorkersGroupGetByNameRequest struct to get information about worker group diff --git a/pkg/cloudapi/kvmx86.go b/pkg/cloudapi/kvmx86.go index 2ac802e..3138a8b 100644 --- a/pkg/cloudapi/kvmx86.go +++ b/pkg/cloudapi/kvmx86.go @@ -1,7 +1,7 @@ package cloudapi import ( - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/pkg/cloudapi/kvmx86" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/pkg/cloudapi/kvmx86" ) // Accessing the KVMX86 method group diff --git a/pkg/cloudapi/kvmx86/create.go b/pkg/cloudapi/kvmx86/create.go index 17e1e52..c3a3d4f 100644 --- a/pkg/cloudapi/kvmx86/create.go +++ b/pkg/cloudapi/kvmx86/create.go @@ -6,7 +6,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) type Interface struct { @@ -16,6 +16,9 @@ type Interface struct { // - EXTNET // - VFNIC // - DPDK + // - EMPTY + // - SDN + // - TRUNK NetType string `url:"netType" json:"netType" validate:"required,kvmx86NetType"` // Network ID for connect to, @@ -35,6 +38,22 @@ type Interface struct { // MAC address to assign to this VM when connecting to the specified network // Required: false MAC string `url:"mac,omitempty" json:"mac,omitempty" validate:"omitempty"` + + // SDN interface id + // Required: false + SDNInterfaceID string `url:"sdn_interface_id,omitempty" json:"sdn_interface_id,omitempty"` + + // List of security group IDs to assign to this interface + // Required: false + SecGroups []uint64 `url:"security_groups,omitempty" json:"security_groups,omitempty"` + + // Flag indicating whether security groups are enabled for this interface + // Required: false + EnableSecGroups bool `url:"enable_secgroups,omitempty" json:"enable_secgroups,omitempty"` + + // Flag indicating whether this interface is enabled (only for VINS, EXTNET, DPDK, SDN, TRUNK) + // Required: false + Enabled interface{} `url:"enabled,omitempty" json:"enabled,omitempty" validate:"omitempty,isBool"` } // DataDisk detailed struct for DataDisks field in CreateRequest and CreateBlankRequest @@ -47,6 +66,10 @@ type DataDisk struct { // Required: true Size uint64 `url:"size" json:"size" validate:"required"` + // Storage policy id of disk. The rules of the specified storage policy will be used. + // Required: true + StoragePolicyID uint64 `url:"storage_policy_id" json:"storage_policy_id" validate:"required"` + // Storage endpoint provider ID // By default the same with boot disk // Required: false @@ -85,6 +108,10 @@ type CreateRequest struct { // Required: true RAM uint64 `url:"ram" json:"ram" validate:"required"` + // Storage policy id of сompute. The rules of the specified storage policy will be used. + // Required: true + StoragePolicyID uint64 `url:"storage_policy_id" json:"storage_policy_id" validate:"required"` + // If True, the imageId, bootDisk, sepId, pool parameters are ignored and the compute is created without a boot disk in the stopped state // Required: false WithoutBootDisk bool `url:"withoutBootDisk" json:"withoutBootDisk"` @@ -94,6 +121,10 @@ type CreateRequest struct { // Required: false ImageID uint64 `url:"imageId,omitempty" json:"imageId,omitempty"` + // The OS version that will be installed on the virtual machine + // Required: false + OSVersion string `url:"os_version,omitempty" json:"os_version,omitempty"` + // Size of the boot disk in GB // Required: false BootDisk uint64 `url:"bootDisk,omitempty" json:"bootDisk,omitempty"` @@ -143,10 +174,6 @@ type CreateRequest struct { // Required: false CustomFields string `url:"customFields,omitempty" json:"customFields,omitempty"` - // Type of compute Stateful (KVM_X86) or Stateless (SVA_KVM_X86) - // Required: false - Driver string `url:"driver,omitempty" json:"driver,omitempty" validate:"omitempty,computeDriver"` - // Rule for VM placement with NUMA affinity. // Possible values - none (placement without NUMA affinity), // strict (strictly with NUMA affinity, if not possible - do not start VM), @@ -172,6 +199,10 @@ type CreateRequest struct { // Recommended isolated CPUs. Field is ignored if compute.cpupin=False or compute.pinned=False // Required: false PreferredCPU []int64 `url:"preferredCpu,omitempty" json:"preferredCpu,omitempty" validate:"omitempty,preferredCPU"` + + // Zone ID + // Required: false + ZoneID uint64 `url:"zoneId,omitempty" json:"zoneId,omitempty"` } // GetRAM returns RAM field values diff --git a/pkg/cloudapi/kvmx86/create_blank.go b/pkg/cloudapi/kvmx86/create_blank.go index 9490e45..2775e3c 100644 --- a/pkg/cloudapi/kvmx86/create_blank.go +++ b/pkg/cloudapi/kvmx86/create_blank.go @@ -6,7 +6,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // CreateBlankRequest struct to create KVM x86 VM from scratch @@ -28,6 +28,10 @@ type CreateBlankRequest struct { // Required: true RAM uint64 `url:"ram" json:"ram" validate:"required"` + // Storage policy id of compute. The rules of the specified storage policy will be used. + // Required: true + StoragePolicyID uint64 `url:"storage_policy_id" json:"storage_policy_id" validate:"required"` + // If True, the imageId, bootDisk, sepId, pool parameters are ignored and the compute is created without a boot disk in the stopped state // Required: false WithoutBootDisk bool `url:"withoutBootDisk" json:"withoutBootDisk"` @@ -57,10 +61,6 @@ type CreateBlankRequest struct { // Required: false Interfaces []Interface `url:"-" json:"interfaces,omitempty" validate:"omitempty,dive"` - // Type of compute Stateful (KVM_X86) or Stateless (SVA_KVM_X86) - // Required: false - Driver string `url:"driver,omitempty" json:"driver,omitempty" validate:"omitempty,computeDriver"` - // Type of the emulated system, Q35 or i440fx // Required: false Chipset string `url:"chipset,omitempty" json:"chipset,omitempty" validate:"omitempty,chipset"` @@ -88,6 +88,14 @@ type CreateBlankRequest struct { // Does this machine supports hot resize // Required: false HotResize bool `url:"hotResize,omitempty" json:"hotResize,omitempty"` + + // Zone ID + // Required: false + ZoneID uint64 `url:"zoneId,omitempty" json:"zoneId,omitempty"` + + // The OS version that will be installed on the virtual machine + // Required: false + OSVersion string `url:"os_version,omitempty" json:"os_version,omitempty"` } // GetRAM returns RAM field values diff --git a/pkg/cloudapi/kvmx86/kvmx86.go b/pkg/cloudapi/kvmx86/kvmx86.go index 1ac8498..43cbd24 100644 --- a/pkg/cloudapi/kvmx86/kvmx86.go +++ b/pkg/cloudapi/kvmx86/kvmx86.go @@ -2,7 +2,7 @@ package kvmx86 import ( - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/interfaces" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/interfaces" ) // Structure for creating request to KVMX86 diff --git a/pkg/cloudapi/lb.go b/pkg/cloudapi/lb.go index b7c950d..8f91b50 100644 --- a/pkg/cloudapi/lb.go +++ b/pkg/cloudapi/lb.go @@ -1,6 +1,6 @@ package cloudapi -import "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/pkg/cloudapi/lb" +import "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/pkg/cloudapi/lb" // Accessing the LB method group func (ca *CloudAPI) LB() *lb.LB { diff --git a/pkg/cloudapi/lb/backend_create.go b/pkg/cloudapi/lb/backend_create.go index d051dc8..0316758 100644 --- a/pkg/cloudapi/lb/backend_create.go +++ b/pkg/cloudapi/lb/backend_create.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // BackendCreateRequest struct to create backend diff --git a/pkg/cloudapi/lb/backend_delete.go b/pkg/cloudapi/lb/backend_delete.go index 14ce439..1f30f69 100644 --- a/pkg/cloudapi/lb/backend_delete.go +++ b/pkg/cloudapi/lb/backend_delete.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // BackendDeleteRequest struct to delete backend diff --git a/pkg/cloudapi/lb/backend_server_add.go b/pkg/cloudapi/lb/backend_server_add.go index 6e2c321..ebf0212 100644 --- a/pkg/cloudapi/lb/backend_server_add.go +++ b/pkg/cloudapi/lb/backend_server_add.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // BackendServerAddRequest struct to add server definition to the backend diff --git a/pkg/cloudapi/lb/backend_server_delete.go b/pkg/cloudapi/lb/backend_server_delete.go index 839b590..760f338 100644 --- a/pkg/cloudapi/lb/backend_server_delete.go +++ b/pkg/cloudapi/lb/backend_server_delete.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // BackendServerDeleteRequest struct to delete server definition diff --git a/pkg/cloudapi/lb/backend_server_update.go b/pkg/cloudapi/lb/backend_server_update.go index f10b122..5700312 100644 --- a/pkg/cloudapi/lb/backend_server_update.go +++ b/pkg/cloudapi/lb/backend_server_update.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // BackendServerUpdateRequest struct to update server diff --git a/pkg/cloudapi/lb/backend_update.go b/pkg/cloudapi/lb/backend_update.go index 7c0bd3b..596e89a 100644 --- a/pkg/cloudapi/lb/backend_update.go +++ b/pkg/cloudapi/lb/backend_update.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // BackendUpdateRequest struct to update backend diff --git a/pkg/cloudapi/lb/config_reset.go b/pkg/cloudapi/lb/config_reset.go index cb38e0c..f59fbd1 100644 --- a/pkg/cloudapi/lb/config_reset.go +++ b/pkg/cloudapi/lb/config_reset.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ConfigResetRequest struct for reset config diff --git a/pkg/cloudapi/lb/create.go b/pkg/cloudapi/lb/create.go index 53a17f1..41587c2 100644 --- a/pkg/cloudapi/lb/create.go +++ b/pkg/cloudapi/lb/create.go @@ -7,7 +7,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // CreateRequest struct to create load balancer @@ -38,12 +38,16 @@ type CreateRequest struct { HighlyAvailable bool `url:"highlyAvailable,omitempty" json:"highlyAvailable,omitempty"` // Start now Load balancer - // Required: false - Start bool `url:"start" json:"start"` + // Required: true + Start bool `url:"start" json:"start" validate:"required"` // Text description of this load balancer // Required: false Description string `url:"desc,omitempty" json:"desc,omitempty"` + + // Zone ID + // Required: false + ZoneID uint64 `url:"zoneId,omitempty" json:"zoneId,omitempty"` } type wrapperCreateRequest struct { diff --git a/pkg/cloudapi/lb/delete.go b/pkg/cloudapi/lb/delete.go index 3abfaaa..e45acb7 100644 --- a/pkg/cloudapi/lb/delete.go +++ b/pkg/cloudapi/lb/delete.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // DeleteRequest struct to delete load balancer diff --git a/pkg/cloudapi/lb/disable_enable.go b/pkg/cloudapi/lb/disable_enable.go index 9fb9547..1ba01e7 100644 --- a/pkg/cloudapi/lb/disable_enable.go +++ b/pkg/cloudapi/lb/disable_enable.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // DisableEnableRequest struct for disable/enable load balancer diff --git a/pkg/cloudapi/lb/filter.go b/pkg/cloudapi/lb/filter.go index 65fd906..0a27bdd 100644 --- a/pkg/cloudapi/lb/filter.go +++ b/pkg/cloudapi/lb/filter.go @@ -3,8 +3,8 @@ package lb import ( "context" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/interfaces" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/pkg/cloudapi/k8s" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/interfaces" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/pkg/cloudapi/k8s" ) // FilterByID returns ListLB with specified ID. diff --git a/pkg/cloudapi/lb/frontend_bind.go b/pkg/cloudapi/lb/frontend_bind.go index 039d4e9..36dedde 100644 --- a/pkg/cloudapi/lb/frontend_bind.go +++ b/pkg/cloudapi/lb/frontend_bind.go @@ -5,7 +5,7 @@ import ( "net/http" "strings" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // FrontendBindRequest struct for frontend bind diff --git a/pkg/cloudapi/lb/frontend_bind_delete.go b/pkg/cloudapi/lb/frontend_bind_delete.go index b4eea54..5fe5286 100644 --- a/pkg/cloudapi/lb/frontend_bind_delete.go +++ b/pkg/cloudapi/lb/frontend_bind_delete.go @@ -5,7 +5,7 @@ import ( "net/http" "strings" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // FrontendBindDeleteRequest struct to delete bind diff --git a/pkg/cloudapi/lb/frontend_bind_update.go b/pkg/cloudapi/lb/frontend_bind_update.go index cd1ddd2..fa99ec5 100644 --- a/pkg/cloudapi/lb/frontend_bind_update.go +++ b/pkg/cloudapi/lb/frontend_bind_update.go @@ -5,7 +5,7 @@ import ( "net/http" "strings" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // FrontendBindUpdateRequest struct to update binding diff --git a/pkg/cloudapi/lb/frontend_create.go b/pkg/cloudapi/lb/frontend_create.go index 618865a..92ae464 100644 --- a/pkg/cloudapi/lb/frontend_create.go +++ b/pkg/cloudapi/lb/frontend_create.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // FrontendCreateRequest struct to create frontend diff --git a/pkg/cloudapi/lb/frontend_delete.go b/pkg/cloudapi/lb/frontend_delete.go index a507f87..79d3b37 100644 --- a/pkg/cloudapi/lb/frontend_delete.go +++ b/pkg/cloudapi/lb/frontend_delete.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // FrontendDeleteRequest struct to delete frontend diff --git a/pkg/cloudapi/lb/get.go b/pkg/cloudapi/lb/get.go index d1d6b35..340519c 100644 --- a/pkg/cloudapi/lb/get.go +++ b/pkg/cloudapi/lb/get.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // GetRequest struct to get detailed information about load balancer diff --git a/pkg/cloudapi/lb/lb.go b/pkg/cloudapi/lb/lb.go index 2897643..0e613a4 100644 --- a/pkg/cloudapi/lb/lb.go +++ b/pkg/cloudapi/lb/lb.go @@ -2,7 +2,7 @@ package lb import ( - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/interfaces" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/interfaces" ) // Structure for creating request to load balancer diff --git a/pkg/cloudapi/lb/list.go b/pkg/cloudapi/lb/list.go index 755d089..f890386 100644 --- a/pkg/cloudapi/lb/list.go +++ b/pkg/cloudapi/lb/list.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ListRequest struct to get list of load balancers @@ -50,6 +50,11 @@ type ListRequest struct { // Required: false SortBy string `url:"sortBy,omitempty" json:"sortBy,omitempty" validate:"omitempty,sortBy"` + // Sort by zone id + // Default value: 0 + // Required: false + ZoneID uint64 `url:"zone_id,omitempty" json:"zone_id,omitempty"` + // Page number // Required: false Page uint64 `url:"page,omitempty" json:"page,omitempty"` diff --git a/pkg/cloudapi/lb/list_deleted.go b/pkg/cloudapi/lb/list_deleted.go index 70977d4..becf7a1 100644 --- a/pkg/cloudapi/lb/list_deleted.go +++ b/pkg/cloudapi/lb/list_deleted.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ListDeletedRequest struct to get list of deleted load balancers diff --git a/pkg/cloudapi/lb/make_highly_available.go b/pkg/cloudapi/lb/make_highly_available.go index 8103907..00a0711 100644 --- a/pkg/cloudapi/lb/make_highly_available.go +++ b/pkg/cloudapi/lb/make_highly_available.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // HighlyAvailableRequest struct to make Load Balancer Highly available diff --git a/pkg/cloudapi/lb/migrate_to_zone.go b/pkg/cloudapi/lb/migrate_to_zone.go new file mode 100644 index 0000000..0e53abf --- /dev/null +++ b/pkg/cloudapi/lb/migrate_to_zone.go @@ -0,0 +1,42 @@ +package lb + +import ( + "context" + "net/http" + "strconv" + + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" +) + +// MigrateToZone struct to move lb to another zone +type MigrateToZoneRequest struct { + // ID of the load balancer instance to move + // Required: true + LBID uint64 `url:"lbId" json:"lbId" validate:"required"` + + // ID of the zone to move + // Required: true + ZoneID uint64 `url:"zoneId" json:"zoneId" validate:"required"` +} + +// MigrateToZone moves lb instance to new zone +func (l LB) MigrateToZone(ctx context.Context, req MigrateToZoneRequest) (bool, error) { + err := validators.ValidateRequest(req) + if err != nil { + return false, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudapi/lb/migrateToZone" + + res, err := l.client.DecortApiCall(ctx, http.MethodPost, url, req) + if err != nil { + return false, err + } + + result, err := strconv.ParseBool(string(res)) + if err != nil { + return false, err + } + + return result, nil +} diff --git a/pkg/cloudapi/lb/models.go b/pkg/cloudapi/lb/models.go index 519348e..60471b7 100644 --- a/pkg/cloudapi/lb/models.go +++ b/pkg/cloudapi/lb/models.go @@ -8,6 +8,9 @@ type RecordLB struct { // Access Control List ACL interface{} `json:"acl"` + //Account ID + AccountID uint64 `json:"accountId"` + // BackendHAIP BackendHAIP string `json:"backendHAIP"` @@ -84,7 +87,7 @@ type RecordLB struct { Status string `json:"status"` // Sysctl Params - SysctlParams interface{} `json:"sysctlParams"` + SysctlParams map[string]string `json:"sysctlParams"` // Tech status TechStatus string `json:"techStatus"` @@ -100,6 +103,9 @@ type RecordLB struct { // VINS ID VINSID uint64 `json:"vinsId"` + + // Zone ID + ZoneID uint64 `json:"zoneId"` } // Main information about load balancer diff --git a/pkg/cloudapi/lb/restart.go b/pkg/cloudapi/lb/restart.go index ef33722..3e9272d 100644 --- a/pkg/cloudapi/lb/restart.go +++ b/pkg/cloudapi/lb/restart.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // RestartRequest struct to restart load balancer diff --git a/pkg/cloudapi/lb/restore.go b/pkg/cloudapi/lb/restore.go index 7dccbce..30155d0 100644 --- a/pkg/cloudapi/lb/restore.go +++ b/pkg/cloudapi/lb/restore.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // RestoreRequest struct to restore load balancer diff --git a/pkg/cloudapi/lb/serialize.go b/pkg/cloudapi/lb/serialize.go index 6e7031a..80755e1 100644 --- a/pkg/cloudapi/lb/serialize.go +++ b/pkg/cloudapi/lb/serialize.go @@ -3,7 +3,7 @@ package lb import ( "encoding/json" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/serialization" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/serialization" ) // Serialize returns JSON-serialized []byte. Used as a wrapper over json.Marshal and json.MarshalIndent functions. diff --git a/pkg/cloudapi/lb/start.go b/pkg/cloudapi/lb/start.go index 7706844..f23a2fb 100644 --- a/pkg/cloudapi/lb/start.go +++ b/pkg/cloudapi/lb/start.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // StartRequest struct to start load balancer diff --git a/pkg/cloudapi/lb/stop.go b/pkg/cloudapi/lb/stop.go index 4940b43..c6ae43b 100644 --- a/pkg/cloudapi/lb/stop.go +++ b/pkg/cloudapi/lb/stop.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // StopRequest struct to stop load balancer diff --git a/pkg/cloudapi/lb/update.go b/pkg/cloudapi/lb/update.go index 38306c8..6797a2c 100644 --- a/pkg/cloudapi/lb/update.go +++ b/pkg/cloudapi/lb/update.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // UpdateRequest struct to update load balancer diff --git a/pkg/cloudapi/lb/update_sysctl_params.go b/pkg/cloudapi/lb/update_sysctl_params.go index 0d8858a..b30272c 100644 --- a/pkg/cloudapi/lb/update_sysctl_params.go +++ b/pkg/cloudapi/lb/update_sysctl_params.go @@ -6,7 +6,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // UpdateSysctParamsRequest struct to update sysct params for lb diff --git a/pkg/cloudapi/locations/get_list.go b/pkg/cloudapi/locations/get_list.go new file mode 100644 index 0000000..da6d6d6 --- /dev/null +++ b/pkg/cloudapi/locations/get_list.go @@ -0,0 +1,71 @@ +package locations + +import ( + "context" + "encoding/json" + "net/http" + + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" +) + +// ListGetRequest struct to get list of locations +type ListGetRequest 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 by flag + // Required: false + Flag string `url:"flag,omitempty" json:"flag,omitempty"` + + // Find by name + // Required: false + Name string `url:"name,omitempty" json:"name,omitempty"` + + // Find by ID + // Required: false + ByID uint64 `url:"by_id,omitempty" json:"by_id,omitempty"` + + // Find by code location + // Required: false + LocationCode string `url:"locationCode,omitempty" json:"locationCode,omitempty"` + + // Sort by one of supported fields, format +|-(field) + // Required: false + SortBy string `url:"sortBy,omitempty" json:"sortBy,omitempty" validate:"omitempty,sortBy"` +} + +// ListGet gets list of all locations as a ListLocations struct +func (l Locations) ListGet(ctx context.Context, req ListGetRequest) (*ListLocations, error) { + + res, err := l.ListGetRaw(ctx, req) + if err != nil { + return nil, err + } + + list := ListLocations{} + + err = json.Unmarshal(res, &list) + if err != nil { + return nil, err + } + + return &list, nil +} + +// ListGetRaw gets list of all locations as an array of bytes +func (l Locations) ListGetRaw(ctx context.Context, req ListGetRequest) ([]byte, error) { + + if err := validators.ValidateRequest(req); err != nil { + return nil, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudapi/locations/list" + + res, err := l.client.DecortApiCall(ctx, http.MethodGet, url, req) + return res, err +} diff --git a/pkg/cloudapi/locations/list.go b/pkg/cloudapi/locations/list.go index 22f2b95..ec13308 100644 --- a/pkg/cloudapi/locations/list.go +++ b/pkg/cloudapi/locations/list.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ListRequest struct to get list of locations diff --git a/pkg/cloudapi/locations/locations.go b/pkg/cloudapi/locations/locations.go index 8da5328..bd06660 100644 --- a/pkg/cloudapi/locations/locations.go +++ b/pkg/cloudapi/locations/locations.go @@ -2,7 +2,7 @@ package locations import ( - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/interfaces" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/interfaces" ) // Structure for creating request to locations diff --git a/pkg/cloudapi/locations/models.go b/pkg/cloudapi/locations/models.go index fd0526e..adc5ea6 100644 --- a/pkg/cloudapi/locations/models.go +++ b/pkg/cloudapi/locations/models.go @@ -20,6 +20,9 @@ type ItemLocation struct { // Name Name string `json:"name"` + // Network Modes + NetworkModes []string `json:"network_modes"` + // Flag Flag string `json:"flag"` diff --git a/pkg/cloudapi/locations/serialize.go b/pkg/cloudapi/locations/serialize.go index fd79e9a..29378a5 100644 --- a/pkg/cloudapi/locations/serialize.go +++ b/pkg/cloudapi/locations/serialize.go @@ -3,7 +3,7 @@ package locations import ( "encoding/json" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/serialization" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/serialization" ) // Serialize returns JSON-serialized []byte. Used as a wrapper over json.Marshal and json.MarshalIndent functions. diff --git a/pkg/cloudapi/locatons.go b/pkg/cloudapi/locatons.go index 5213ab3..0f384cb 100644 --- a/pkg/cloudapi/locatons.go +++ b/pkg/cloudapi/locatons.go @@ -1,6 +1,6 @@ package cloudapi -import "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/pkg/cloudapi/locations" +import "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/pkg/cloudapi/locations" // Accessing the Locations method group func (ca *CloudAPI) Locations() *locations.Locations { diff --git a/pkg/cloudapi/pcidevice.go b/pkg/cloudapi/pcidevice.go index 37aa8ea..0a94741 100644 --- a/pkg/cloudapi/pcidevice.go +++ b/pkg/cloudapi/pcidevice.go @@ -1,6 +1,6 @@ package cloudapi -import "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/pkg/cloudapi/pcidevice" +import "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/pkg/cloudapi/pcidevice" // Accessing the PCI Device method group func (ca *CloudAPI) PCIDevice() *pcidevice.PCIDevice { diff --git a/pkg/cloudapi/pcidevice/list.go b/pkg/cloudapi/pcidevice/list.go index f58562d..b768115 100644 --- a/pkg/cloudapi/pcidevice/list.go +++ b/pkg/cloudapi/pcidevice/list.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ListRequest struct to get list of pci devices diff --git a/pkg/cloudapi/pcidevice/pcidevice.go b/pkg/cloudapi/pcidevice/pcidevice.go index 7a42767..d575df7 100644 --- a/pkg/cloudapi/pcidevice/pcidevice.go +++ b/pkg/cloudapi/pcidevice/pcidevice.go @@ -1,6 +1,6 @@ package pcidevice -import "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/interfaces" +import "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/interfaces" // Structure for creating request to PCI device type PCIDevice struct { diff --git a/pkg/cloudapi/pcidevice/serialize.go b/pkg/cloudapi/pcidevice/serialize.go index 56be05c..1c6da92 100644 --- a/pkg/cloudapi/pcidevice/serialize.go +++ b/pkg/cloudapi/pcidevice/serialize.go @@ -3,7 +3,7 @@ package pcidevice import ( "encoding/json" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/serialization" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/serialization" ) // Serialize returns JSON-serialized []byte. Used as a wrapper over json.Marshal and json.MarshalIndent functions. diff --git a/pkg/cloudapi/prometheus.go b/pkg/cloudapi/prometheus.go index 588c9e4..9fc7516 100644 --- a/pkg/cloudapi/prometheus.go +++ b/pkg/cloudapi/prometheus.go @@ -1,6 +1,6 @@ package cloudapi -import "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/pkg/cloudapi/prometheus" +import "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/pkg/cloudapi/prometheus" // Accessing the Resmon method group func (ca *CloudAPI) Prometheus() *prometheus.Prometheus { diff --git a/pkg/cloudapi/prometheus/compute_cpu_load.go b/pkg/cloudapi/prometheus/compute_cpu_load.go index 2c044dc..12acd2a 100644 --- a/pkg/cloudapi/prometheus/compute_cpu_load.go +++ b/pkg/cloudapi/prometheus/compute_cpu_load.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) type ComputeCPULoadRequest struct { diff --git a/pkg/cloudapi/prometheus/compute_memory_available.go b/pkg/cloudapi/prometheus/compute_memory_available.go index 168802c..b7f6150 100644 --- a/pkg/cloudapi/prometheus/compute_memory_available.go +++ b/pkg/cloudapi/prometheus/compute_memory_available.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) type ComputeMemoryAvailableRequest struct { diff --git a/pkg/cloudapi/prometheus/compute_memory_unused.go b/pkg/cloudapi/prometheus/compute_memory_unused.go index 99a2c2e..84626d1 100644 --- a/pkg/cloudapi/prometheus/compute_memory_unused.go +++ b/pkg/cloudapi/prometheus/compute_memory_unused.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) type ComputeMemoryUnusedRequest struct { diff --git a/pkg/cloudapi/prometheus/compute_memory_usable.go b/pkg/cloudapi/prometheus/compute_memory_usable.go index 1912855..00dc738 100644 --- a/pkg/cloudapi/prometheus/compute_memory_usable.go +++ b/pkg/cloudapi/prometheus/compute_memory_usable.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) type ComputeMemoryUsableRequest struct { diff --git a/pkg/cloudapi/prometheus/compute_memory_usage.go b/pkg/cloudapi/prometheus/compute_memory_usage.go index 3b06ea4..c1d357f 100644 --- a/pkg/cloudapi/prometheus/compute_memory_usage.go +++ b/pkg/cloudapi/prometheus/compute_memory_usage.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) type ComputeMemoryUsageRequest struct { diff --git a/pkg/cloudapi/prometheus/compute_memory_used.go b/pkg/cloudapi/prometheus/compute_memory_used.go index 780b9b9..b2d8c7e 100644 --- a/pkg/cloudapi/prometheus/compute_memory_used.go +++ b/pkg/cloudapi/prometheus/compute_memory_used.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) type ComputeMemoryUsedRequest struct { diff --git a/pkg/cloudapi/prometheus/compute_read_bytes.go b/pkg/cloudapi/prometheus/compute_read_bytes.go index 6be4397..c6810b6 100644 --- a/pkg/cloudapi/prometheus/compute_read_bytes.go +++ b/pkg/cloudapi/prometheus/compute_read_bytes.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) type ComputeReadBytesRequest struct { diff --git a/pkg/cloudapi/prometheus/compute_read_requests.go b/pkg/cloudapi/prometheus/compute_read_requests.go index 752fdc9..0c6b6e4 100644 --- a/pkg/cloudapi/prometheus/compute_read_requests.go +++ b/pkg/cloudapi/prometheus/compute_read_requests.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) type ComputeReadRequestsRequest struct { diff --git a/pkg/cloudapi/prometheus/compute_receive_bytes.go b/pkg/cloudapi/prometheus/compute_receive_bytes.go index 370be24..b77d976 100644 --- a/pkg/cloudapi/prometheus/compute_receive_bytes.go +++ b/pkg/cloudapi/prometheus/compute_receive_bytes.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) type ComputeReceiveBytesRequest struct { diff --git a/pkg/cloudapi/prometheus/compute_receive_packets.go b/pkg/cloudapi/prometheus/compute_receive_packets.go index ecc6cca..b164820 100644 --- a/pkg/cloudapi/prometheus/compute_receive_packets.go +++ b/pkg/cloudapi/prometheus/compute_receive_packets.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) type ComputeReceivePacketsRequest struct { diff --git a/pkg/cloudapi/prometheus/compute_transmit_bytes.go b/pkg/cloudapi/prometheus/compute_transmit_bytes.go index e41b221..c8a8da2 100644 --- a/pkg/cloudapi/prometheus/compute_transmit_bytes.go +++ b/pkg/cloudapi/prometheus/compute_transmit_bytes.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) type ComputeTransmitBytesRequest struct { diff --git a/pkg/cloudapi/prometheus/compute_transmit_packets.go b/pkg/cloudapi/prometheus/compute_transmit_packets.go index 3a9f374..92c4506 100644 --- a/pkg/cloudapi/prometheus/compute_transmit_packets.go +++ b/pkg/cloudapi/prometheus/compute_transmit_packets.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) type ComputeTransmitPacketsRequest struct { diff --git a/pkg/cloudapi/prometheus/compute_write_bytes.go b/pkg/cloudapi/prometheus/compute_write_bytes.go index bab82c8..84487dc 100644 --- a/pkg/cloudapi/prometheus/compute_write_bytes.go +++ b/pkg/cloudapi/prometheus/compute_write_bytes.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) type ComputeWriteBytesRequest struct { diff --git a/pkg/cloudapi/prometheus/compute_write_requests.go b/pkg/cloudapi/prometheus/compute_write_requests.go index 414b016..dae4a0f 100644 --- a/pkg/cloudapi/prometheus/compute_write_requests.go +++ b/pkg/cloudapi/prometheus/compute_write_requests.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) type ComputeWriteRequestsRequest struct { diff --git a/pkg/cloudapi/prometheus/computes.go b/pkg/cloudapi/prometheus/computes.go index 2795dc6..062f1df 100644 --- a/pkg/cloudapi/prometheus/computes.go +++ b/pkg/cloudapi/prometheus/computes.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) const ( diff --git a/pkg/cloudapi/prometheus/prometheus.go b/pkg/cloudapi/prometheus/prometheus.go index a3012ca..92049fa 100644 --- a/pkg/cloudapi/prometheus/prometheus.go +++ b/pkg/cloudapi/prometheus/prometheus.go @@ -1,7 +1,7 @@ package prometheus import ( - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/interfaces" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/interfaces" ) type Prometheus struct { diff --git a/pkg/cloudapi/rg.go b/pkg/cloudapi/rg.go index 24959cd..b608db1 100644 --- a/pkg/cloudapi/rg.go +++ b/pkg/cloudapi/rg.go @@ -1,6 +1,6 @@ package cloudapi -import "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/pkg/cloudapi/rg" +import "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/pkg/cloudapi/rg" // Accessing the RG method group func (ca *CloudAPI) RG() *rg.RG { diff --git a/pkg/cloudapi/rg/access_grant.go b/pkg/cloudapi/rg/access_grant.go index f9e7176..328cec3 100644 --- a/pkg/cloudapi/rg/access_grant.go +++ b/pkg/cloudapi/rg/access_grant.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // AccessGrantRequest struct to grant access to resource group diff --git a/pkg/cloudapi/rg/access_revoke.go b/pkg/cloudapi/rg/access_revoke.go index e3c324c..16ea913 100644 --- a/pkg/cloudapi/rg/access_revoke.go +++ b/pkg/cloudapi/rg/access_revoke.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // AccessRevokeRequest struct to revoke access diff --git a/pkg/cloudapi/rg/affinity_group_computes.go b/pkg/cloudapi/rg/affinity_group_computes.go index c1ce1fc..c43b9ab 100644 --- a/pkg/cloudapi/rg/affinity_group_computes.go +++ b/pkg/cloudapi/rg/affinity_group_computes.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // AffinityGroupComputesRequest struct to get list of all computes with their relationships diff --git a/pkg/cloudapi/rg/affinity_groups_get.go b/pkg/cloudapi/rg/affinity_groups_get.go index 3a84879..0274542 100644 --- a/pkg/cloudapi/rg/affinity_groups_get.go +++ b/pkg/cloudapi/rg/affinity_groups_get.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // AffinityGroupsGetRequest struct to get list computes from affinity group diff --git a/pkg/cloudapi/rg/affinity_groups_list.go b/pkg/cloudapi/rg/affinity_groups_list.go index 29d8ddc..8d60f51 100644 --- a/pkg/cloudapi/rg/affinity_groups_list.go +++ b/pkg/cloudapi/rg/affinity_groups_list.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // AffinityGroupsListRequest struct to get list of affinity groups from resource group diff --git a/pkg/cloudapi/rg/audits.go b/pkg/cloudapi/rg/audits.go index 8018a5d..6a3c5ad 100644 --- a/pkg/cloudapi/rg/audits.go +++ b/pkg/cloudapi/rg/audits.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // AuditsRequest struct to get audit diff --git a/pkg/cloudapi/rg/create.go b/pkg/cloudapi/rg/create.go index 9cb4dbd..70409bd 100644 --- a/pkg/cloudapi/rg/create.go +++ b/pkg/cloudapi/rg/create.go @@ -5,7 +5,8 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/constants" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // CreateRequest struct to create resource group @@ -22,6 +23,10 @@ type CreateRequest struct { // Required: true Name string `url:"name" json:"name" validate:"required,min=2"` + // Storage policies + // Required: false + StoragePolicies []StoragePolicy `url:"storage_policies" json:"storage_policies"` + // Max size of memory in MB // Required: false MaxMemoryCapacity int64 `url:"maxMemoryCapacity,omitempty" json:"maxMemoryCapacity,omitempty"` @@ -71,6 +76,15 @@ type CreateRequest struct { // External IP address // Required: false ExtIP string `url:"extIp,omitempty" json:"extIp,omitempty"` + + // SDN access group id + // Required: false + SDNAccessGroupID string `url:"sdn_access_group_id,omitempty" json:"sdn_access_group_id,omitempty"` +} + +type StoragePolicy struct { + ID uint64 `url:"id" json:"id"` + Limit int `url:"limit" json:"limit"` } // Create creates resource group @@ -82,7 +96,7 @@ func (r RG) Create(ctx context.Context, req CreateRequest) (uint64, error) { url := "/cloudapi/rg/create" - res, err := r.client.DecortApiCall(ctx, http.MethodPost, url, req) + res, err := r.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req) if err != nil { return 0, err } diff --git a/pkg/cloudapi/rg/delete.go b/pkg/cloudapi/rg/delete.go index 703a358..7b495c2 100644 --- a/pkg/cloudapi/rg/delete.go +++ b/pkg/cloudapi/rg/delete.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // DeleteRequest struct to delete resource group diff --git a/pkg/cloudapi/rg/disable.go b/pkg/cloudapi/rg/disable.go index 23b12f8..d406b9d 100644 --- a/pkg/cloudapi/rg/disable.go +++ b/pkg/cloudapi/rg/disable.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // DisableRequest struct to disable resource group diff --git a/pkg/cloudapi/rg/enable.go b/pkg/cloudapi/rg/enable.go index f1be19e..96325aa 100644 --- a/pkg/cloudapi/rg/enable.go +++ b/pkg/cloudapi/rg/enable.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // EnableRequest struct to enable resource group diff --git a/pkg/cloudapi/rg/get.go b/pkg/cloudapi/rg/get.go index 4d41714..2e445c2 100644 --- a/pkg/cloudapi/rg/get.go +++ b/pkg/cloudapi/rg/get.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // GetRequest struct to get detailed information about resource group diff --git a/pkg/cloudapi/rg/get_resource_consumption.go b/pkg/cloudapi/rg/get_resource_consumption.go index 10ec9e1..bec5eca 100644 --- a/pkg/cloudapi/rg/get_resource_consumption.go +++ b/pkg/cloudapi/rg/get_resource_consumption.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // GetResourceConsumptionRequest struct to get detailed information about resource consumption for ResGroup diff --git a/pkg/cloudapi/rg/list.go b/pkg/cloudapi/rg/list.go index 34f0efc..344f312 100644 --- a/pkg/cloudapi/rg/list.go +++ b/pkg/cloudapi/rg/list.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ListRequest struct to get list of resource groups diff --git a/pkg/cloudapi/rg/list_computes.go b/pkg/cloudapi/rg/list_computes.go index 0b52b47..08aa672 100644 --- a/pkg/cloudapi/rg/list_computes.go +++ b/pkg/cloudapi/rg/list_computes.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ListComputesRequest struct to get list of computes diff --git a/pkg/cloudapi/rg/list_deleted.go b/pkg/cloudapi/rg/list_deleted.go index 842fbca..f87edd4 100644 --- a/pkg/cloudapi/rg/list_deleted.go +++ b/pkg/cloudapi/rg/list_deleted.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ListDeletedRequest struct to get list deleted resource groups diff --git a/pkg/cloudapi/rg/list_lb.go b/pkg/cloudapi/rg/list_lb.go index 2ee776a..32ce327 100644 --- a/pkg/cloudapi/rg/list_lb.go +++ b/pkg/cloudapi/rg/list_lb.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ListLBRequest struct to get list of load balancers diff --git a/pkg/cloudapi/rg/list_pfw.go b/pkg/cloudapi/rg/list_pfw.go index cc3f2dc..61570b8 100644 --- a/pkg/cloudapi/rg/list_pfw.go +++ b/pkg/cloudapi/rg/list_pfw.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ListPFWRequest struct to get list of port forward rules diff --git a/pkg/cloudapi/rg/list_vins.go b/pkg/cloudapi/rg/list_vins.go index 045b2b2..573d4a4 100644 --- a/pkg/cloudapi/rg/list_vins.go +++ b/pkg/cloudapi/rg/list_vins.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ListVINSRequest struct to get list of VINSes diff --git a/pkg/cloudapi/rg/models.go b/pkg/cloudapi/rg/models.go index 6232570..ce81b38 100644 --- a/pkg/cloudapi/rg/models.go +++ b/pkg/cloudapi/rg/models.go @@ -134,6 +134,12 @@ type RecordResourceGroup struct { // List of resource types ResTypes []string `json:"resourceTypes"` + // Storage policy ids + StoragePolicyIDs []uint64 `json:"storage_policy_ids"` + + // SDN access group id + SDNAccessGroupID string `json:"sdn_access_group_id"` + // Secret Secret string `json:"secret"` @@ -227,6 +233,12 @@ type ItemResourceGroup struct { // List of resource types ResTypes []string `json:"resourceTypes"` + // SDN access group id + SDNAccessGroupID string `json:"sdn_access_group_id"` + + // Storage policy ids + StoragePolicyIDs []uint64 `json:"storage_policy_ids"` + // Secret Secret string `json:"secret"` @@ -302,6 +314,9 @@ type ResourceLimits struct { // GPU units GPUUnits float64 `json:"gpu_units"` + + // Storage policies + StoragePolicies []StoragePolicy `json:"storage_policy"` } // Main information about affinity group diff --git a/pkg/cloudapi/rg/remove_def_net.go b/pkg/cloudapi/rg/remove_def_net.go index 47fbf2b..dc99303 100644 --- a/pkg/cloudapi/rg/remove_def_net.go +++ b/pkg/cloudapi/rg/remove_def_net.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // RemoveDefNetRequest struct to remove default network diff --git a/pkg/cloudapi/rg/restore.go b/pkg/cloudapi/rg/restore.go index ab16d70..03f15f6 100644 --- a/pkg/cloudapi/rg/restore.go +++ b/pkg/cloudapi/rg/restore.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // RestoreRequest struct to restore resource group diff --git a/pkg/cloudapi/rg/rg.go b/pkg/cloudapi/rg/rg.go index eb10e33..00c1428 100644 --- a/pkg/cloudapi/rg/rg.go +++ b/pkg/cloudapi/rg/rg.go @@ -2,7 +2,7 @@ package rg import ( - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/interfaces" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/interfaces" ) // Structure for creating request to resource group diff --git a/pkg/cloudapi/rg/serialize.go b/pkg/cloudapi/rg/serialize.go index 9becc06..bc27504 100644 --- a/pkg/cloudapi/rg/serialize.go +++ b/pkg/cloudapi/rg/serialize.go @@ -3,7 +3,7 @@ package rg import ( "encoding/json" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/serialization" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/serialization" ) // Serialize returns JSON-serialized []byte. Used as a wrapper over json.Marshal and json.MarshalIndent functions. diff --git a/pkg/cloudapi/rg/set_def_net.go b/pkg/cloudapi/rg/set_def_net.go index ca60c56..55f0838 100644 --- a/pkg/cloudapi/rg/set_def_net.go +++ b/pkg/cloudapi/rg/set_def_net.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // SetDefNetRequest struct to set default network diff --git a/pkg/cloudapi/rg/update.go b/pkg/cloudapi/rg/update.go index 1153653..4ef7f07 100644 --- a/pkg/cloudapi/rg/update.go +++ b/pkg/cloudapi/rg/update.go @@ -5,7 +5,8 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/constants" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // UpdateRequest struct to update resource group @@ -50,6 +51,10 @@ type UpdateRequest struct { // Default: false // Required: false ClearUniqPools bool `url:"clearUniqPools" json:"clearUniqPools"` + + // Storage policies + // Required: false + StoragePolicies []StoragePolicy `url:"-" json:"storage_policies,omitempty"` } // Update updates resource group @@ -61,7 +66,7 @@ func (r RG) Update(ctx context.Context, req UpdateRequest) (bool, error) { url := "/cloudapi/rg/update" - res, err := r.client.DecortApiCall(ctx, http.MethodPost, url, req) + res, err := r.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req) if err != nil { return false, err } diff --git a/pkg/cloudapi/rg/usage.go b/pkg/cloudapi/rg/usage.go index 01b06b9..be76330 100644 --- a/pkg/cloudapi/rg/usage.go +++ b/pkg/cloudapi/rg/usage.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // UsageRequest struct to get report of resource usage diff --git a/pkg/cloudapi/secgroup/create.go b/pkg/cloudapi/secgroup/create.go new file mode 100644 index 0000000..da8c5e1 --- /dev/null +++ b/pkg/cloudapi/secgroup/create.go @@ -0,0 +1,46 @@ +package secgroup + +import ( + "context" + "net/http" + "strconv" + + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/constants" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" +) + +type CreateRequest struct { + // Account ID that owns security group + // Required: true + AccountID uint64 `url:"account_id" json:"account_id" validate:"required"` + + // Security group name + // Required: true + Name string `url:"name" json:"name" validate:"required"` + + // Security group description + // Required: false + Description string `url:"description,omitempty" json:"description,omitempty"` +} + +func (sg SecurityGroup) Create(ctx context.Context, req CreateRequest) (uint64, error) { + err := validators.ValidateRequest(req) + if err != nil { + return 0, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudapi/security_group/create" + + res, err := sg.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req) + if err != nil { + return 0, err + } + + result, err := strconv.ParseUint(string(res), 10, 64) + if err != nil { + return 0, err + } + + return result, nil + +} diff --git a/pkg/cloudapi/secgroup/create_rule.go b/pkg/cloudapi/secgroup/create_rule.go new file mode 100644 index 0000000..da21550 --- /dev/null +++ b/pkg/cloudapi/secgroup/create_rule.go @@ -0,0 +1,63 @@ +package secgroup + +import ( + "context" + "net/http" + "strconv" + + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/constants" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" +) + +type CreateRuleRequest struct { + // Security group ID + // Required: true + SecurityGroupID uint64 `url:"security_group_id" json:"security_group_id" validate:"required"` + + // Traffic direction (inbound/outbound) + // Required: true + Direction string `url:"direction" json:"direction" validate:"required,securityGroupDirection"` + + // IP protocol version + // Default: IPv4 + // Required: false + Ethertype string `url:"ethertype,omitempty" json:"ethertype,omitempty" validate:"omitempty,securityGroupEthertype"` + + // Network protocol, available values : icmp, tcp, udp + // Required: false + Protocol string `url:"protocol,omitempty" json:"protocol,omitempty" validate:"omitempty,securityGroupProtocol"` + + // Start port number (for TCP/UDP) + // Required: false + PortRangeMin uint64 `url:"port_range_min,omitempty" json:"port_range_min,omitempty"` + + // End port number (for TCP/UDP) + // Required: false + PortRangeMax uint64 `url:"port_range_max,omitempty" json:"port_range_max,omitempty"` + + // Remote IP prefix in CIDR notation + // Required: false + RemoteIPPrefix string `url:"remote_ip_prefix,omitempty" json:"remote_ip_prefix,omitempty"` +} + +func (sg SecurityGroup) CreateRule(ctx context.Context, req CreateRuleRequest) (uint64, error) { + err := validators.ValidateRequest(req) + if err != nil { + return 0, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudapi/security_group/create_rule" + + res, err := sg.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req) + if err != nil { + return 0, err + } + + result, err := strconv.ParseUint(string(res), 10, 64) + if err != nil { + return 0, err + } + + return result, nil + +} diff --git a/pkg/cloudapi/secgroup/delete.go b/pkg/cloudapi/secgroup/delete.go new file mode 100644 index 0000000..fb0aae9 --- /dev/null +++ b/pkg/cloudapi/secgroup/delete.go @@ -0,0 +1,36 @@ +package secgroup + +import ( + "context" + "net/http" + "strconv" + + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" +) + +type DeleteRequest struct { + // Security group ID + // Required: true + SecurityGroupID uint64 `url:"security_group_id" json:"security_group_id" validate:"required"` +} + +func (sg SecurityGroup) Delete(ctx context.Context, req DeleteRequest) (bool, error) { + err := validators.ValidateRequest(req) + if err != nil { + return false, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudapi/security_group/delete" + + res, err := sg.client.DecortApiCall(ctx, http.MethodPost, url, req) + if err != nil { + return false, err + } + + result, err := strconv.ParseBool(string(res)) + if err != nil { + return false, err + } + + return result, nil +} diff --git a/pkg/cloudapi/secgroup/delete_rule.go b/pkg/cloudapi/secgroup/delete_rule.go new file mode 100644 index 0000000..5752968 --- /dev/null +++ b/pkg/cloudapi/secgroup/delete_rule.go @@ -0,0 +1,40 @@ +package secgroup + +import ( + "context" + "net/http" + "strconv" + + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" +) + +type DeleteRuleRequest struct { + // Security group ID + // Required: true + SecurityGroupID uint64 `url:"security_group_id" json:"security_group_id" validate:"required"` + + // Rule ID + // Required: true + RuleID uint64 `url:"rule_id" json:"rule_id" validate:"required"` +} + +func (sg SecurityGroup) DeleteRule(ctx context.Context, req DeleteRuleRequest) (bool, error) { + err := validators.ValidateRequest(req) + if err != nil { + return false, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudapi/security_group/delete_rule" + + res, err := sg.client.DecortApiCall(ctx, http.MethodPost, url, req) + if err != nil { + return false, err + } + + result, err := strconv.ParseBool(string(res)) + if err != nil { + return false, err + } + + return result, nil +} diff --git a/pkg/cloudapi/secgroup/filter.go b/pkg/cloudapi/secgroup/filter.go new file mode 100644 index 0000000..6a03da3 --- /dev/null +++ b/pkg/cloudapi/secgroup/filter.go @@ -0,0 +1,80 @@ +package secgroup + +// FilterByID returns ListSecurityGroups with specified ID. +func (lsg ListSecurityGroups) FilterByID(id uint64) ListSecurityGroups { + predicate := func(isg ItemSecurityGroup) bool { + return isg.ID == id + } + + return lsg.FilterFunc(predicate) +} + +// FilterByID returns ListSecurityGroups with specified Name. +func (lsg ListSecurityGroups) FilterByName(name string) ListSecurityGroups { + predicate := func(isg ItemSecurityGroup) bool { + return isg.Name == name + } + + return lsg.FilterFunc(predicate) +} + +// FilterByCreatedBy returns ListSecurityGroups with specified CreatedBy. +func (lsg ListSecurityGroups) FilterByCreatedBy(createdBy string) ListSecurityGroups { + predicate := func(isg ItemSecurityGroup) bool { + return isg.CreatedBy == createdBy + } + + return lsg.FilterFunc(predicate) +} + +// FilterByDescription returns ListSecurityGroups with specified Description. +func (lsg ListSecurityGroups) FilterByDescription(description string) ListSecurityGroups { + predicate := func(isg ItemSecurityGroup) bool { + return isg.Description == description + } + + return lsg.FilterFunc(predicate) +} + +// FilterByUpdatedBy returns ListSecurityGroups with specified UpdatedBy. +func (lsg ListSecurityGroups) FilterByUpdatedBy(updatedBy string) ListSecurityGroups { + predicate := func(isg ItemSecurityGroup) bool { + return isg.UpdatedBy == updatedBy + } + + return lsg.FilterFunc(predicate) +} + +// FilterByAccountID returns ListSecurityGroups with specified AccountID. +func (lsg ListSecurityGroups) FilterByAccountID(accountID uint64) ListSecurityGroups { + predicate := func(isg ItemSecurityGroup) bool { + return isg.AccountID == accountID + } + + return lsg.FilterFunc(predicate) +} + +// FilterFunc allows filtering ListSecurityGroups based on a user-specified predicate. +func (lsg ListSecurityGroups) FilterFunc(predicate func(ItemSecurityGroup) bool) ListSecurityGroups { + var result ListSecurityGroups + + for _, item := range lsg.Data { + if predicate(item) { + result.Data = append(result.Data, item) + } + } + + result.EntryCount = uint64(len(result.Data)) + + return result +} + +// FindOne returns first found ItemSecurityGroup +// If none was found, returns an empty struct. +func (lsg ListSecurityGroups) FindOne() ItemSecurityGroup { + if len(lsg.Data) == 0 { + return ItemSecurityGroup{} + } + + return lsg.Data[0] +} diff --git a/pkg/cloudapi/secgroup/filter_test.go b/pkg/cloudapi/secgroup/filter_test.go new file mode 100644 index 0000000..2231f60 --- /dev/null +++ b/pkg/cloudapi/secgroup/filter_test.go @@ -0,0 +1,87 @@ +package secgroup + +import "testing" + +var securityGroups = ListSecurityGroups{ + Data: []ItemSecurityGroup{ + { + ID: 1, + AccountID: 1, + Name: "sg1", + Description: "some desc", + CreatedBy: "user", + }, + { + ID: 3, + AccountID: 3, + Name: "sg3", + Description: "some desc", + CreatedBy: "anotheruser", + }, + { + ID: 5, + AccountID: 3, + Name: "sg5", + Description: "some other desc", + CreatedBy: "anotheruser", + UpdatedBy: "user", + }, + }, + EntryCount: 3, +} + +func TestFilterByID(t *testing.T) { + actual := securityGroups.FilterByID(1).FindOne() + if actual.ID != 1 { + t.Fatal("expected ID 1, found: ", actual.ID) + } +} + +func TestFilterByName(t *testing.T) { + actual := securityGroups.FilterByName("sg3").FindOne() + if actual.Name != "sg3" { + t.Fatal("expected Name sg3, found: ", actual.Name) + } +} + +func TestFilterByDescription(t *testing.T) { + actual := securityGroups.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 := securityGroups.FilterByAccountID(1).FindOne() + if actual.AccountID != 1 { + t.Fatal("expected AccountID 1, found: ", actual.AccountID) + } +} + +func TestFilterByCreatedBy(t *testing.T) { + actual := securityGroups.FilterByCreatedBy("anotheruser") + + if len(actual.Data) != 2 { + t.Fatal("expected 2 found, actual: ", len(actual.Data)) + } + + for _, item := range actual.Data { + if item.CreatedBy != "anotheruser" { + t.Fatal("expected CreatedBy 'anotheruser', found: ", item.CreatedBy) + } + } +} + +func TestFilterByUpdatedBy(t *testing.T) { + actual := securityGroups.FilterByUpdatedBy("user").FindOne() + if actual.UpdatedBy != "user" { + t.Fatal("expected UpdatedBy 'user', found: ", actual.UpdatedBy) + } +} diff --git a/pkg/cloudapi/secgroup/get.go b/pkg/cloudapi/secgroup/get.go new file mode 100644 index 0000000..330a691 --- /dev/null +++ b/pkg/cloudapi/secgroup/get.go @@ -0,0 +1,43 @@ +package secgroup + +import ( + "context" + "encoding/json" + "net/http" + + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" +) + +type GetRequest struct { + // ID of security group + // Required: true + SecurityGroupID uint64 `url:"security_group_id" json:"security_group_id" validate:"required"` +} + +func (sg SecurityGroup) Get(ctx context.Context, req GetRequest) (*RecordSecurityGroup, error) { + res, err := sg.GetRaw(ctx, req) + if err != nil { + return nil, err + } + + info := RecordSecurityGroup{} + + err = json.Unmarshal(res, &info) + if err != nil { + return nil, err + } + + return &info, nil +} + +func (sg SecurityGroup) GetRaw(ctx context.Context, req GetRequest) ([]byte, error) { + err := validators.ValidateRequest(req) + if err != nil { + return nil, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudapi/security_group/get" + + res, err := sg.client.DecortApiCall(ctx, http.MethodGet, url, req) + return res, err +} diff --git a/pkg/cloudapi/secgroup/list.go b/pkg/cloudapi/secgroup/list.go new file mode 100644 index 0000000..fe82041 --- /dev/null +++ b/pkg/cloudapi/secgroup/list.go @@ -0,0 +1,86 @@ +package secgroup + +import ( + "context" + "encoding/json" + "net/http" + + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" +) + +type ListRequest struct { + // Search by security group id + // Required: false + ByID uint64 `url:"by_id,omitempty" json:"by_id,omitempty"` + + // Search by account id + // Required: false + AccountID uint64 `url:"account_id,omitempty" json:"account_id,omitempty"` + + // Search by security group name + // Required: false + Name string `url:"name,omitempty" json:"name,omitempty"` + + // Search by security group description + // Required: false + Description string `url:"description,omitempty" json:"description,omitempty"` + + // Search by created after time (unix timestamp) + // Required: false + CreatedMin uint64 `url:"created_min,omitempty" json:"created_min,omitempty"` + + // Search by created before time (unix timestamp) + // Required: false + CreatedMax uint64 `url:"created_max,omitempty" json:"created_max,omitempty"` + + // Search by updated after time (unix timestamp) + // Required: false + UpdatedMin uint64 `url:"updated_min,omitempty" json:"updated_min,omitempty"` + + // Search by updated before time (unix timestamp) + // Required: false + UpdatedMax uint64 `url:"updated_max,omitempty" json:"updated_max,omitempty"` + + // Sort by one of supported fields, format ± + // Required: false + SortBy string `url:"sort_by,omitempty" json:"sort_by,omitempty"` + + // Page number + // Required: false + Page uint64 `url:"page,omitempty" json:"page,omitempty"` + + // Page size + // Required: false + Size uint64 `url:"size,omitempty" json:"size,omitempty"` +} + +// List gets list of security groups as a ListSecurityGroups struct +func (sg SecurityGroup) List(ctx context.Context, req ListRequest) (*ListSecurityGroups, error) { + + res, err := sg.ListRaw(ctx, req) + if err != nil { + return nil, err + } + + list := ListSecurityGroups{} + + err = json.Unmarshal(res, &list) + if err != nil { + return nil, err + } + + return &list, nil +} + +// ListRaw gets list of security groups as an array of bytes +func (sg SecurityGroup) ListRaw(ctx context.Context, req ListRequest) ([]byte, error) { + + if err := validators.ValidateRequest(req); err != nil { + return nil, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudapi/security_group/list" + + res, err := sg.client.DecortApiCall(ctx, http.MethodGet, url, req) + return res, err +} diff --git a/pkg/cloudapi/secgroup/models.go b/pkg/cloudapi/secgroup/models.go new file mode 100644 index 0000000..766d731 --- /dev/null +++ b/pkg/cloudapi/secgroup/models.go @@ -0,0 +1,94 @@ +package secgroup + +type ListSecurityGroups struct { + // List + Data []ItemSecurityGroup `json:"data"` + + // Entry count + EntryCount uint64 `json:"entryCount"` +} + +type ItemSecurityGroup struct { + // ID of the security group + ID uint64 `json:"id"` + + // Account ID that owns the security group + AccountID uint64 `json:"account_id"` + + // Name of the security group + Name string `json:"name"` + + // Description of the security group + Description string `json:"description"` + + // List of rules + Rules Rules `json:"rules"` + + // Created at + CreatedAt uint64 `json:"created_at"` + + // Updated at + UpdatedAt uint64 `json:"updated_at"` + + // Created by + CreatedBy string `json:"created_by"` + + // Updated by + UpdatedBy string `json:"updated_by"` +} + +type RecordSecurityGroup struct { + // ID of the security group + ID uint64 `json:"id"` + + // Account ID that owns the security group + AccountID uint64 `json:"account_id"` + + // Name of the security group + Name string `json:"name"` + + // Description of the security group + Description string `json:"description"` + + // List of rules + Rules Rules `json:"rules"` + + // Created at + CreatedAt uint64 `json:"created_at"` + + // Updated at + UpdatedAt uint64 `json:"updated_at"` + + // Created by + CreatedBy string `json:"created_by"` + + // Updated by + UpdatedBy string `json:"updated_by"` +} + +type Rules []Rule + +type Rule struct { + // ID of the rule + ID uint64 `json:"id"` + + // Traffic direction (inbound/outbound) + Direction string `json:"direction"` + + // IP protocol version + Ethertype string `json:"ethertype"` + + // Network protocol + Protocol string `json:"protocol"` + + // Start port number (for TCP/UDP) + PortRangeMin uint64 `json:"port_range_min"` + + // End port number (for TCP/UDP) + PortRangeMax uint64 `json:"port_range_max"` + + // Remote IP prefix in CIDR notation + RemoteIPPrefix string `json:"remote_ip_prefix"` + + RemoteGroupID uint64 `json:"remote_group_id"` +} diff --git a/pkg/cloudapi/secgroup/security_group.go b/pkg/cloudapi/secgroup/security_group.go new file mode 100644 index 0000000..5563b4c --- /dev/null +++ b/pkg/cloudapi/secgroup/security_group.go @@ -0,0 +1,15 @@ +package secgroup + +import "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/interfaces" + +// Structure for creating request to storage policy +type SecurityGroup struct { + client interfaces.Caller +} + +// Builder for stack endpoint +func New(client interfaces.Caller) *SecurityGroup { + return &SecurityGroup{ + client: client, + } +} diff --git a/pkg/cloudapi/secgroup/sorting.go b/pkg/cloudapi/secgroup/sorting.go new file mode 100644 index 0000000..57df52b --- /dev/null +++ b/pkg/cloudapi/secgroup/sorting.go @@ -0,0 +1,41 @@ +package secgroup + +import "sort" + +// SortByCreatedAt sorts ListSecurityGroups by the CreatedAt field in ascending order. +// +// If inverse param is set to true, the order is reversed. +func (lsg ListSecurityGroups) SortByCreatedAt(inverse bool) ListSecurityGroups { + if len(lsg.Data) < 2 { + return lsg + } + + sort.Slice(lsg.Data, func(i, j int) bool { + if inverse { + return lsg.Data[i].CreatedAt > lsg.Data[j].CreatedAt + } + + return lsg.Data[i].CreatedAt < lsg.Data[j].CreatedAt + }) + + return lsg +} + +// SortByUpdatedAt sorts ListSecurityGroups by the UpdatedAt field in ascending order. +// +// If inverse param is set to true, the order is reversed. +func (lsg ListSecurityGroups) SortByUpdatedAt(inverse bool) ListSecurityGroups { + if len(lsg.Data) < 2 { + return lsg + } + + sort.Slice(lsg.Data, func(i, j int) bool { + if inverse { + return lsg.Data[i].UpdatedAt > lsg.Data[j].UpdatedAt + } + + return lsg.Data[i].UpdatedAt < lsg.Data[j].UpdatedAt + }) + + return lsg +} diff --git a/pkg/cloudapi/secgroup/update.go b/pkg/cloudapi/secgroup/update.go new file mode 100644 index 0000000..5cb37bb --- /dev/null +++ b/pkg/cloudapi/secgroup/update.go @@ -0,0 +1,51 @@ +package secgroup + +import ( + "context" + "encoding/json" + "net/http" + + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" +) + +type UpdateRequest struct { + // Security group ID + // Required: true + SecurityGroupID uint64 `url:"security_group_id" json:"security_group_id" validate:"required"` + + // New security group name + // Required: false + Name string `url:"name,omitempty" json:"name,omitempty"` + + // New security group description + // Required: false + Description string `url:"description,omitempty" json:"description,omitempty"` +} + +func (sg SecurityGroup) Update(ctx context.Context, req UpdateRequest) (*RecordSecurityGroup, error) { + res, err := sg.UpdateRaw(ctx, req) + if err != nil { + return nil, err + } + + info := RecordSecurityGroup{} + + err = json.Unmarshal(res, &info) + if err != nil { + return nil, err + } + + return &info, nil +} + +func (sg SecurityGroup) UpdateRaw(ctx context.Context, req UpdateRequest) ([]byte, error) { + err := validators.ValidateRequest(req) + if err != nil { + return nil, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudapi/security_group/update" + + res, err := sg.client.DecortApiCall(ctx, http.MethodPost, url, req) + return res, err +} diff --git a/pkg/cloudapi/securitygroup.go b/pkg/cloudapi/securitygroup.go new file mode 100644 index 0000000..c023a9d --- /dev/null +++ b/pkg/cloudapi/securitygroup.go @@ -0,0 +1,10 @@ +package cloudapi + +import ( + secgroup "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/pkg/cloudapi/secgroup" +) + +// Accessing the Security Group method group +func (ca *CloudAPI) SecurityGroup() *secgroup.SecurityGroup { + return secgroup.New(ca.client) +} diff --git a/pkg/cloudapi/sep.go b/pkg/cloudapi/sep.go index 7a6bb90..aef09c1 100644 --- a/pkg/cloudapi/sep.go +++ b/pkg/cloudapi/sep.go @@ -1,6 +1,6 @@ package cloudapi -import "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/pkg/cloudapi/sep" +import "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/pkg/cloudapi/sep" // Accessing the SEP method group func (cb *CloudAPI) SEP() *sep.SEP { diff --git a/pkg/cloudapi/sep/list_available_sep_and_pools.go b/pkg/cloudapi/sep/list_available_sep_and_pools.go index b701244..2425449 100644 --- a/pkg/cloudapi/sep/list_available_sep_and_pools.go +++ b/pkg/cloudapi/sep/list_available_sep_and_pools.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ListAvailableSEPAndPoolsRequest struct to get dict with entry count and list of dict with SEPs and pools details accessible by the Account and RG diff --git a/pkg/cloudapi/sep/sep.go b/pkg/cloudapi/sep/sep.go index 26fb750..bc306b7 100644 --- a/pkg/cloudapi/sep/sep.go +++ b/pkg/cloudapi/sep/sep.go @@ -2,7 +2,7 @@ package sep import ( - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/interfaces" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/interfaces" ) // Structure for creating request to storage endpoint provider diff --git a/pkg/cloudapi/sep/serialize.go b/pkg/cloudapi/sep/serialize.go index 6a9b89f..36098a0 100644 --- a/pkg/cloudapi/sep/serialize.go +++ b/pkg/cloudapi/sep/serialize.go @@ -3,7 +3,7 @@ package sep import ( "encoding/json" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/serialization" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/serialization" ) // Serialize returns JSON-serialized []byte. Used as a wrapper over json.Marshal and json.MarshalIndent functions. diff --git a/pkg/cloudapi/stack.go b/pkg/cloudapi/stack.go index dd5b7f8..d129360 100644 --- a/pkg/cloudapi/stack.go +++ b/pkg/cloudapi/stack.go @@ -1,7 +1,7 @@ package cloudapi import ( - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/pkg/cloudapi/stack" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/pkg/cloudapi/stack" ) // Accessing the Stack method group diff --git a/pkg/cloudapi/stack/get.go b/pkg/cloudapi/stack/get.go index 57e7154..ebafea6 100644 --- a/pkg/cloudapi/stack/get.go +++ b/pkg/cloudapi/stack/get.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // GetRequest struct to get info of stack diff --git a/pkg/cloudapi/stack/list.go b/pkg/cloudapi/stack/list.go index 95d1ee9..2f9c578 100644 --- a/pkg/cloudapi/stack/list.go +++ b/pkg/cloudapi/stack/list.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ListRequest struct to get list of stacks diff --git a/pkg/cloudapi/stack/stack.go b/pkg/cloudapi/stack/stack.go index 1882be2..605a835 100644 --- a/pkg/cloudapi/stack/stack.go +++ b/pkg/cloudapi/stack/stack.go @@ -1,7 +1,7 @@ // Lists all the stack. package stack -import "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/interfaces" +import "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/interfaces" // Structure for creating request to stack type Stack struct { diff --git a/pkg/cloudapi/storage_policy.go b/pkg/cloudapi/storage_policy.go new file mode 100644 index 0000000..4241d1a --- /dev/null +++ b/pkg/cloudapi/storage_policy.go @@ -0,0 +1,10 @@ +package cloudapi + +import ( + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/pkg/cloudapi/stpolicy" +) + +// Accessing the Storage Policy method group +func (ca *CloudAPI) StPolicy() *stpolicy.StPolicy { + return stpolicy.New(ca.client) +} diff --git a/pkg/cloudapi/stpolicy/get.go b/pkg/cloudapi/stpolicy/get.go new file mode 100644 index 0000000..0104990 --- /dev/null +++ b/pkg/cloudapi/stpolicy/get.go @@ -0,0 +1,43 @@ +package stpolicy + +import ( + "context" + "encoding/json" + "net/http" + + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" +) + +type GetRequest struct { + // ID of storage policy + // Required: true + StoragePolicyID uint64 `url:"storage_policy_id" json:"storage_policy_id" validate:"required"` +} + +func (sp StPolicy) Get(ctx context.Context, req GetRequest) (*InfoStoragePolicy, error) { + res, err := sp.GetRaw(ctx, req) + if err != nil { + return nil, err + } + + info := InfoStoragePolicy{} + + err = json.Unmarshal(res, &info) + if err != nil { + return nil, err + } + + return &info, nil +} + +func (sp StPolicy) GetRaw(ctx context.Context, req GetRequest) ([]byte, error) { + err := validators.ValidateRequest(req) + if err != nil { + return nil, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudapi/storage_policy/get" + + res, err := sp.client.DecortApiCall(ctx, http.MethodGet, url, req) + return res, err +} diff --git a/pkg/cloudapi/stpolicy/list.go b/pkg/cloudapi/stpolicy/list.go new file mode 100644 index 0000000..136bc37 --- /dev/null +++ b/pkg/cloudapi/stpolicy/list.go @@ -0,0 +1,90 @@ +package stpolicy + +import ( + "context" + "encoding/json" + "net/http" + + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/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"` + + // Search by storage policy ID + // Required: false + ByID uint64 `url:"by_id,omitempty" json:"by_id,omitempty"` + + // Search by storage policy name + // Required: false + Name string `url:"name,omitempty" json:"name,omitempty"` + + // Search by storage policy status + // Required: false + Status string `url:"status,omitempty" json:"status,omitempty"` + + // Search by storage policy desc + // Required: false + Desc string `url:"desc,omitempty" json:"desc,omitempty"` + + // Search by storage policy iops limit + // Required: false + LimitIOPS uint64 `url:"limit_iops,omitempty" json:"limit_iops,omitempty"` + + // Sort by one of supported fields, format ± + // Required: false + SortBy string `url:"sort_by,omitempty" json:"sort_by,omitempty"` + + // ID of account ID + // Required: false + AccountID uint64 `url:"account_id,omitempty" json:"account_id,omitempty"` + + // Search by resgroup id + // Required: false + ResgroupID uint64 `url:"resgroup_id,omitempty" json:"resgroup_id,omitempty"` + + // Search by sep id + // Required: false + SepID uint64 `url:"sep_id,omitempty" json:"sep_id,omitempty"` + + // Search by pool name + // Required: false + PoolName string `url:"pool_name,omitempty" json:"pool_name,omitempty"` +} + +// List gets list of storage policies as a ListStoragePolicies struct +func (sp StPolicy) List(ctx context.Context, req ListRequest) (*ListStoragePolicies, error) { + + res, err := sp.ListRaw(ctx, req) + if err != nil { + return nil, err + } + + list := ListStoragePolicies{} + + err = json.Unmarshal(res, &list) + if err != nil { + return nil, err + } + + return &list, nil +} + +// ListRaw gets list of storage policies as an array of bytes +func (sp StPolicy) ListRaw(ctx context.Context, req ListRequest) ([]byte, error) { + + if err := validators.ValidateRequest(req); err != nil { + return nil, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudapi/storage_policy/list" + + res, err := sp.client.DecortApiCall(ctx, http.MethodGet, url, req) + return res, err +} diff --git a/pkg/cloudapi/stpolicy/models.go b/pkg/cloudapi/stpolicy/models.go new file mode 100644 index 0000000..954a6eb --- /dev/null +++ b/pkg/cloudapi/stpolicy/models.go @@ -0,0 +1,82 @@ +package stpolicy + +type ListStoragePolicies struct { + // List + Data []ItemStoragePolicy `json:"data"` + + // Entry Count + EntryCount uint64 `json:"entryCount"` +} + +type ItemStoragePolicy struct { + // ID of the storage policy + ID uint64 `json:"id"` + + // GUID + GUID uint64 `json:"guid"` + + // Name of the storage policy + Name string `json:"name"` + + // Description of the storage policy + Description string `json:"description"` + + // List of pools in SEP for storage policy + AccessSEPPools ListAccessSEPPools `json:"access_seps_pools"` + + // Status of the storage policy + Status string `json:"status"` + + // Max IOPS for the sotrage policy + LimitIOPS uint64 `json:"limit_iops"` + + // Which accounts and resource groups use the storage policy + Usage Usage `json:"usage"` +} + +type InfoStoragePolicy struct { + // ID of the storage policy + ID uint64 `json:"id"` + + // GUID + GUID uint64 `json:"guid"` + + // Name of the storage policy + Name string `json:"name"` + + // Description of the storage policy + Description string `json:"description"` + + // List of pools in SEP for storage policy + AccessSEPPools ListAccessSEPPools `json:"access_seps_pools"` + + // Status of the storage policy + Status string `json:"status"` + + // Max IOPS for the sotrage policy + LimitIOPS uint64 `json:"limit_iops"` + + // Which accounts and resource groups use the storage policy + Usage Usage `json:"usage"` +} + +type ListAccessSEPPools []AccessSEPPool + +type AccessSEPPool struct { + // SEP ID + SEPID uint64 `json:"sep_id"` + + // SEP name + Name string `json:"sep_name"` + + // Pool names + PoolNames []string `json:"pool_names"` +} + +type Usage struct { + // List of accounts + Accounts []uint64 `json:"accounts"` + + // List of resource groups + Resgroups []uint64 `json:"resgroups"` +} diff --git a/pkg/cloudapi/stpolicy/storage_policy.go b/pkg/cloudapi/stpolicy/storage_policy.go new file mode 100644 index 0000000..061f7c4 --- /dev/null +++ b/pkg/cloudapi/stpolicy/storage_policy.go @@ -0,0 +1,15 @@ +package stpolicy + +import "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/interfaces" + +// Structure for creating request to storage policy +type StPolicy struct { + client interfaces.Caller +} + +// Builder for stack endpoint +func New(client interfaces.Caller) *StPolicy { + return &StPolicy{ + client: client, + } +} diff --git a/pkg/cloudapi/tasks.go b/pkg/cloudapi/tasks.go index 3cafe78..8629299 100644 --- a/pkg/cloudapi/tasks.go +++ b/pkg/cloudapi/tasks.go @@ -1,7 +1,7 @@ package cloudapi import ( - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/pkg/cloudapi/tasks" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/pkg/cloudapi/tasks" ) // Accessing the Tasks method group diff --git a/pkg/cloudapi/tasks/get.go b/pkg/cloudapi/tasks/get.go index 94c2e4b..340df2b 100644 --- a/pkg/cloudapi/tasks/get.go +++ b/pkg/cloudapi/tasks/get.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // GetRequest struct to get information about task diff --git a/pkg/cloudapi/tasks/list.go b/pkg/cloudapi/tasks/list.go index 9fa6898..7c24d27 100644 --- a/pkg/cloudapi/tasks/list.go +++ b/pkg/cloudapi/tasks/list.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ListRequest struct to get list of tasks diff --git a/pkg/cloudapi/tasks/models.go b/pkg/cloudapi/tasks/models.go index c9133ab..0680d41 100644 --- a/pkg/cloudapi/tasks/models.go +++ b/pkg/cloudapi/tasks/models.go @@ -46,9 +46,6 @@ type RecordAsyncTask struct { // Detailed information about task type ItemAsyncTask struct { RecordAsyncTask - - // GUID - GUID string `json:"guid"` } // List of tasks diff --git a/pkg/cloudapi/tasks/tasks.go b/pkg/cloudapi/tasks/tasks.go index cb90367..ea5c6ab 100644 --- a/pkg/cloudapi/tasks/tasks.go +++ b/pkg/cloudapi/tasks/tasks.go @@ -2,7 +2,7 @@ package tasks import ( - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/interfaces" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/interfaces" ) // Structure for creating request to tasks diff --git a/pkg/cloudapi/trunk.go b/pkg/cloudapi/trunk.go new file mode 100644 index 0000000..3ebd7f7 --- /dev/null +++ b/pkg/cloudapi/trunk.go @@ -0,0 +1,10 @@ +package cloudapi + +import ( + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/pkg/cloudapi/trunk" +) + +// Accessing the Trunk method group +func (ca *CloudAPI) Trunk() *trunk.Trunk { + return trunk.New(ca.client) +} diff --git a/pkg/cloudapi/trunk/get.go b/pkg/cloudapi/trunk/get.go new file mode 100644 index 0000000..b24e03c --- /dev/null +++ b/pkg/cloudapi/trunk/get.go @@ -0,0 +1,46 @@ +package trunk + +import ( + "context" + "encoding/json" + "net/http" + + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" +) + +// GetRequest struct to get information about a trunk +type GetRequest struct { + // ID of trunk + // Required: true + TrunkID uint64 `url:"id" json:"id" validate:"required"` +} + +// Get gets detailed information about a trunk as a ItemTrunk struct +func (t Trunk) Get(ctx context.Context, req GetRequest) (*ItemTrunk, error) { + res, err := t.GetRaw(ctx, req) + if err != nil { + return nil, err + } + + info := ItemTrunk{} + + err = json.Unmarshal(res, &info) + if err != nil { + return nil, err + } + + return &info, nil +} + +// GetRaw gets detailed information about a trunk as an array of bytes +func (t Trunk) GetRaw(ctx context.Context, req GetRequest) ([]byte, error) { + err := validators.ValidateRequest(req) + if err != nil { + return nil, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudapi/trunk/get" + + res, err := t.client.DecortApiCall(ctx, http.MethodGet, url, req) + return res, err +} diff --git a/pkg/cloudapi/trunk/list.go b/pkg/cloudapi/trunk/list.go new file mode 100644 index 0000000..7c04710 --- /dev/null +++ b/pkg/cloudapi/trunk/list.go @@ -0,0 +1,64 @@ +package trunk + +import ( + "context" + "encoding/json" + "net/http" + + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" +) + +// ListRequest struct to get list of trunks +type ListRequest struct { + // Account access ID to filter by + AccountIDs []uint64 `url:"account_ids,omitempty" json:"account_ids,omitempty"` + + // ID of the trunk to filter by + IDs []uint64 `url:"ids,omitempty" json:"ids,omitempty"` + + // Sort by one of supported fields, format ± + SortBy string `url:"sort_by,omitempty" json:"sort_by,omitempty"` + + // Trunk tags to filter by + TrunkTags string `url:"trunk_tags,omitempty" json:"trunk_tags,omitempty" validate:"omitempty,trunkTags"` + + // Page number + Page uint64 `url:"page,omitempty" json:"page,omitempty"` + + // Page size + Size uint64 `url:"size,omitempty" json:"size,omitempty"` + + // Status + Status string `url:"status,omitempty" json:"status,omitempty"` +} + +// List gets list of all trunks as a ListTrunks struct +func (t Trunk) List(ctx context.Context, req ListRequest) (*ListTrunks, error) { + + res, err := t.ListRaw(ctx, req) + if err != nil { + return nil, err + } + + list := ListTrunks{} + + err = json.Unmarshal(res, &list) + if err != nil { + return nil, err + } + + return &list, nil +} + +// ListRaw gets list of all trunks as an array of bytes +func (t Trunk) ListRaw(ctx context.Context, req ListRequest) ([]byte, error) { + + if err := validators.ValidateRequest(req); err != nil { + return nil, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudapi/trunk/list" + + res, err := t.client.DecortApiCall(ctx, http.MethodGet, url, req) + return res, err +} diff --git a/pkg/cloudapi/trunk/models.go b/pkg/cloudapi/trunk/models.go new file mode 100644 index 0000000..de7742a --- /dev/null +++ b/pkg/cloudapi/trunk/models.go @@ -0,0 +1,59 @@ +package trunk + +type ItemTrunk struct { + + // List of account IDs with access to this trunk + AccountIDs []uint64 `json:"accountIds"` + + // Created at + CreatedAt uint64 `json:"created_at"` + + // Created by + CreatedBy string `json:"created_by"` + + // Deleted at + DeletedAt uint64 `json:"deleted_at"` + + // Deleted by + DeletedBy string `json:"deleted_by"` + + // Description of a trunk + Description string `json:"description"` + + // GUID + GUID uint64 `json:"guid"` + + // ID of a trunk + ID uint64 `json:"id"` + + // MAC + MAC string `json:"mac"` + + // Name of a trunk + Name string `json:"name"` + + // Native VLAN ID + NativeVLANID uint64 `json:"nativeVlanId"` + + // OVS bridge name + OVSBridge string `json:"ovsBridge"` + + // If the trunk is enabled + Status string `json:"status"` + + // List of trunk tags (values between 1-4095) + TrunkTags string `json:"trunkTags"` + + // Updated at + UpdatedAt uint64 `json:"updated_at"` + + // Updated by + UpdatedBy string `json:"updated_by"` +} + +// List of trunks +type ListTrunks struct { + Data []ItemTrunk `json:"data"` + + EntryCount uint64 `json:"entryCount"` +} diff --git a/pkg/cloudapi/trunk/trunk.go b/pkg/cloudapi/trunk/trunk.go new file mode 100644 index 0000000..aa0c9e8 --- /dev/null +++ b/pkg/cloudapi/trunk/trunk.go @@ -0,0 +1,18 @@ +// API Actor API for trunk nerworks +package trunk + +import ( + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/interfaces" +) + +// Structure for creating request to trunk +type Trunk struct { + client interfaces.Caller +} + +// Builder for trunk endpoints +func New(client interfaces.Caller) *Trunk { + return &Trunk{ + client, + } +} diff --git a/pkg/cloudapi/user.go b/pkg/cloudapi/user.go index fedff59..94761d0 100644 --- a/pkg/cloudapi/user.go +++ b/pkg/cloudapi/user.go @@ -1,6 +1,6 @@ package cloudapi -import "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/pkg/cloudapi/user" +import "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/pkg/cloudapi/user" func (ca *CloudAPI) User() *user.User { return user.New(ca.client) diff --git a/pkg/cloudapi/user/api_list.go b/pkg/cloudapi/user/api_list.go index 4f93a18..c276d44 100644 --- a/pkg/cloudapi/user/api_list.go +++ b/pkg/cloudapi/user/api_list.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // APIListRequest struct for getting API list. diff --git a/pkg/cloudapi/user/authenticate.go b/pkg/cloudapi/user/authenticate.go index e6ee50f..098060d 100644 --- a/pkg/cloudapi/user/authenticate.go +++ b/pkg/cloudapi/user/authenticate.go @@ -4,7 +4,7 @@ import ( "context" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // AuthenticateRequest struct to authenticate user. diff --git a/pkg/cloudapi/user/get.go b/pkg/cloudapi/user/get.go index 5b93a43..3ecceea 100644 --- a/pkg/cloudapi/user/get.go +++ b/pkg/cloudapi/user/get.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // GetRequest struct to get user details. diff --git a/pkg/cloudapi/user/is_valid_invite_user_token.go b/pkg/cloudapi/user/is_valid_invite_user_token.go index d8cfd56..5358723 100644 --- a/pkg/cloudapi/user/is_valid_invite_user_token.go +++ b/pkg/cloudapi/user/is_valid_invite_user_token.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // GetRequest struct to check if the inviteusertoken and emailaddress pair are valid and matching. diff --git a/pkg/cloudapi/user/set_data.go b/pkg/cloudapi/user/set_data.go index 30a2eec..d8e1803 100644 --- a/pkg/cloudapi/user/set_data.go +++ b/pkg/cloudapi/user/set_data.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // SetDataRequest struct for setting extra user information. diff --git a/pkg/cloudapi/user/user.go b/pkg/cloudapi/user/user.go index cd5cfb7..8b6fa37 100644 --- a/pkg/cloudapi/user/user.go +++ b/pkg/cloudapi/user/user.go @@ -1,6 +1,6 @@ package user -import "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/interfaces" +import "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/interfaces" // Structure for creating request to User type User struct { diff --git a/pkg/cloudapi/vfpool.go b/pkg/cloudapi/vfpool.go index 0a7c8e7..e995c68 100644 --- a/pkg/cloudapi/vfpool.go +++ b/pkg/cloudapi/vfpool.go @@ -1,6 +1,6 @@ package cloudapi -import "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/pkg/cloudapi/vfpool" +import "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/pkg/cloudapi/vfpool" // Accessing the VFPool method group func (ca *CloudAPI) VFPool() *vfpool.VFPool { diff --git a/pkg/cloudapi/vfpool/get.go b/pkg/cloudapi/vfpool/get.go index 35d97d4..e0846f6 100644 --- a/pkg/cloudapi/vfpool/get.go +++ b/pkg/cloudapi/vfpool/get.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // GetRequest struct to get detailed information about vfpool device diff --git a/pkg/cloudapi/vfpool/list.go b/pkg/cloudapi/vfpool/list.go index af586d4..ea36470 100644 --- a/pkg/cloudapi/vfpool/list.go +++ b/pkg/cloudapi/vfpool/list.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ListRequest struct to get list of vfpool devices diff --git a/pkg/cloudapi/vfpool/serialize.go b/pkg/cloudapi/vfpool/serialize.go index a0347d1..207948c 100644 --- a/pkg/cloudapi/vfpool/serialize.go +++ b/pkg/cloudapi/vfpool/serialize.go @@ -3,7 +3,7 @@ package vfpool import ( "encoding/json" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/serialization" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/serialization" ) // Serialize returns JSON-serialized []byte. Used as a wrapper over json.Marshal and json.MarshalIndent functions. diff --git a/pkg/cloudapi/vfpool/vfpool.go b/pkg/cloudapi/vfpool/vfpool.go index d8ca096..5dcc98e 100644 --- a/pkg/cloudapi/vfpool/vfpool.go +++ b/pkg/cloudapi/vfpool/vfpool.go @@ -2,7 +2,7 @@ package vfpool import ( - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/interfaces" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/interfaces" ) // Structure for creating request to vfpool diff --git a/pkg/cloudapi/vins.go b/pkg/cloudapi/vins.go index 78b3651..812a5e4 100644 --- a/pkg/cloudapi/vins.go +++ b/pkg/cloudapi/vins.go @@ -1,7 +1,7 @@ package cloudapi import ( - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/pkg/cloudapi/vins" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/pkg/cloudapi/vins" ) // Accessing the VINS method group diff --git a/pkg/cloudapi/vins/audits.go b/pkg/cloudapi/vins/audits.go index b6bba8a..120cf0a 100644 --- a/pkg/cloudapi/vins/audits.go +++ b/pkg/cloudapi/vins/audits.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // AuditsRequest struct to get audits diff --git a/pkg/cloudapi/vins/create_in_account.go b/pkg/cloudapi/vins/create_in_account.go index fa64fbb..1b4f041 100644 --- a/pkg/cloudapi/vins/create_in_account.go +++ b/pkg/cloudapi/vins/create_in_account.go @@ -6,7 +6,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) type Route struct { @@ -53,6 +53,10 @@ type CreateInAccountRequest struct { // List of static routes, each item must have destination, netmask, and gateway fields // Required: false Routes []Route `url:"-" json:"routes,omitempty" validate:"omitempty,dive"` + + // Zone ID + // Required: false + ZoneID uint64 `url:"zoneId,omitempty" json:"zoneId,omitempty"` } type wrapperCreateRequestInAcc struct { diff --git a/pkg/cloudapi/vins/create_in_rg.go b/pkg/cloudapi/vins/create_in_rg.go index 24f00d4..bd7049b 100644 --- a/pkg/cloudapi/vins/create_in_rg.go +++ b/pkg/cloudapi/vins/create_in_rg.go @@ -6,7 +6,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // CreateInRGRequest struct to create VINS in resource group @@ -47,6 +47,10 @@ type CreateInRGRequest struct { // List of static routes, each item must have destination, netmask, and gateway fields // Required: false Routes []Route `url:"-" json:"routes,omitempty" validate:"omitempty,dive"` + + // Zone ID + // Required: false + ZoneID uint64 `url:"zoneId,omitempty" json:"zoneId,omitempty"` } type wrapperCreateRequestInRG struct { diff --git a/pkg/cloudapi/vins/delete.go b/pkg/cloudapi/vins/delete.go index 20b26f2..71bbc67 100644 --- a/pkg/cloudapi/vins/delete.go +++ b/pkg/cloudapi/vins/delete.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // DeleteRequest struct to delete VINS diff --git a/pkg/cloudapi/vins/disable_enable.go b/pkg/cloudapi/vins/disable_enable.go index 5fc0502..578492d 100644 --- a/pkg/cloudapi/vins/disable_enable.go +++ b/pkg/cloudapi/vins/disable_enable.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // DisableEnableRequest struct to disable/enable VINS diff --git a/pkg/cloudapi/vins/dns_apply.go b/pkg/cloudapi/vins/dns_apply.go index 0629838..d9746f1 100644 --- a/pkg/cloudapi/vins/dns_apply.go +++ b/pkg/cloudapi/vins/dns_apply.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // DNSApplyRequest struct to apply new DNS list in VINS diff --git a/pkg/cloudapi/vins/extnet_connect.go b/pkg/cloudapi/vins/extnet_connect.go index 854ed58..cdf54b8 100644 --- a/pkg/cloudapi/vins/extnet_connect.go +++ b/pkg/cloudapi/vins/extnet_connect.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ExtNetConnectRequest struct to connect to external network diff --git a/pkg/cloudapi/vins/extnet_disconnect.go b/pkg/cloudapi/vins/extnet_disconnect.go index 34d60ba..7fe6291 100644 --- a/pkg/cloudapi/vins/extnet_disconnect.go +++ b/pkg/cloudapi/vins/extnet_disconnect.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ExtNetDisconnectRequest struct to disconnect VINS from external network diff --git a/pkg/cloudapi/vins/extnet_list.go b/pkg/cloudapi/vins/extnet_list.go index 411ca52..9ac5c00 100644 --- a/pkg/cloudapi/vins/extnet_list.go +++ b/pkg/cloudapi/vins/extnet_list.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ExtNetListRequest struct to get list of VINS external network connections diff --git a/pkg/cloudapi/vins/get.go b/pkg/cloudapi/vins/get.go index 419e248..1f2cf5d 100644 --- a/pkg/cloudapi/vins/get.go +++ b/pkg/cloudapi/vins/get.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // GetRequest struct to get information about VINS diff --git a/pkg/cloudapi/vins/ip_list.go b/pkg/cloudapi/vins/ip_list.go index eb0b243..2fb198c 100644 --- a/pkg/cloudapi/vins/ip_list.go +++ b/pkg/cloudapi/vins/ip_list.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // IPListRequest struct for DHCP IP diff --git a/pkg/cloudapi/vins/ip_release.go b/pkg/cloudapi/vins/ip_release.go index 27b78e0..9f1aee1 100644 --- a/pkg/cloudapi/vins/ip_release.go +++ b/pkg/cloudapi/vins/ip_release.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // IPReleaseRequest struct for IP release diff --git a/pkg/cloudapi/vins/ip_reserve.go b/pkg/cloudapi/vins/ip_reserve.go index c96681e..31adcdd 100644 --- a/pkg/cloudapi/vins/ip_reserve.go +++ b/pkg/cloudapi/vins/ip_reserve.go @@ -4,7 +4,7 @@ import ( "context" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // IPReserveRequest struct for IP reserve diff --git a/pkg/cloudapi/vins/list.go b/pkg/cloudapi/vins/list.go index 0c4e48e..6f8567b 100644 --- a/pkg/cloudapi/vins/list.go +++ b/pkg/cloudapi/vins/list.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ListRequest struct to get list of VINSes @@ -46,6 +46,11 @@ type ListRequest struct { // Required: false SortBy string `url:"sortBy,omitempty" json:"sortBy,omitempty" validate:"omitempty,sortBy"` + // Sort by zone id + // Default value: 0 + // Required: false + ZoneID uint64 `url:"zone_id,omitempty" json:"zone_id,omitempty"` + // Page number // Required: false Page uint64 `url:"page,omitempty" json:"page,omitempty"` diff --git a/pkg/cloudapi/vins/list_deleted.go b/pkg/cloudapi/vins/list_deleted.go index 8cabd62..aa2efc5 100644 --- a/pkg/cloudapi/vins/list_deleted.go +++ b/pkg/cloudapi/vins/list_deleted.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ListDeletedRequest struct to get list of deleted VINSes diff --git a/pkg/cloudapi/vins/migrate_to_zone.go b/pkg/cloudapi/vins/migrate_to_zone.go new file mode 100644 index 0000000..69bd0c4 --- /dev/null +++ b/pkg/cloudapi/vins/migrate_to_zone.go @@ -0,0 +1,42 @@ +package vins + +import ( + "context" + "net/http" + "strconv" + + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" +) + +// MigrateToZone struct to move VINS to another zone +type MigrateToZoneRequest struct { + // VINSID to move + // Required: true + VINSID uint64 `url:"net_id" json:"net_id" validate:"required"` + + // ID of the zone to move + // Required: true + ZoneID uint64 `url:"zone_id" json:"zone_id" validate:"required"` +} + +// MigrateToZone moves VINS instance to new zone +func (v VINS) MigrateToZone(ctx context.Context, req MigrateToZoneRequest) (bool, error) { + err := validators.ValidateRequest(req) + if err != nil { + return false, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudapi/vins/migrateToZone" + + res, err := v.client.DecortApiCall(ctx, http.MethodPost, url, req) + if err != nil { + return false, err + } + + result, err := strconv.ParseBool(string(res)) + if err != nil { + return false, err + } + + return result, nil +} diff --git a/pkg/cloudapi/vins/models.go b/pkg/cloudapi/vins/models.go index 1f54c3a..2134e14 100644 --- a/pkg/cloudapi/vins/models.go +++ b/pkg/cloudapi/vins/models.go @@ -211,6 +211,9 @@ type RecordVNFDev struct { // VNC password VNCPassword string `json:"vncPasswd"` + + // Zone ID + ZoneID uint64 `json:"zoneId"` } // VNF config @@ -269,6 +272,9 @@ type ItemVNFInterface struct { // Enabled Enabled bool `json:"enabled"` + // Enable security groups + EnableSecGroups bool `json:"enable_secgroups"` + // FLIPGroup ID FLIPGroupID uint64 `json:"flipgroupId"` @@ -305,6 +311,12 @@ type ItemVNFInterface struct { // NodeID NodeID int64 `json:"nodeId"` + // List of security groups + SecGroups []uint64 `json:"security_groups"` + + // SDNInterfaceID + SDNInterfaceID string `json:"sdn_interface_id"` + // PCI slot PCISlot int64 `json:"pciSlot"` @@ -415,6 +427,9 @@ type RecordNAT struct { // Type Type string `json:"type"` + + // Zone ID + ZoneID uint64 `json:"zoneId"` } // NAT configuration @@ -483,6 +498,9 @@ type RecordGW struct { // Type Type string `json:"type"` + + // Zone ID + ZoneID uint64 `json:"zoneId"` } // GW configuration @@ -573,6 +591,9 @@ type RecordDHCP struct { // Type Type string `json:"type"` + + // Zone ID + ZoneID uint64 `json:"zoneId"` } // DHCP configuration @@ -670,6 +691,9 @@ type RecordVINS struct { // Description Description string `json:"desc"` + // Enable Security Groups + EnableSecGroups bool `json:"enable_secgroups"` + // Grid ID GID uint64 `json:"gid"` @@ -732,6 +756,9 @@ type RecordVINS struct { // VXLAN ID VXLANID uint64 `json:"vxlanId"` + + // Zone ID + ZoneID uint64 `json:"zoneId"` } // Information about libvirt settings diff --git a/pkg/cloudapi/vins/nat_rule_add.go b/pkg/cloudapi/vins/nat_rule_add.go index 4ff8db4..bbc565b 100644 --- a/pkg/cloudapi/vins/nat_rule_add.go +++ b/pkg/cloudapi/vins/nat_rule_add.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // NATRuleAddRequest struct to create NAT rules diff --git a/pkg/cloudapi/vins/nat_rule_del.go b/pkg/cloudapi/vins/nat_rule_del.go index 75b9829..42c9c70 100644 --- a/pkg/cloudapi/vins/nat_rule_del.go +++ b/pkg/cloudapi/vins/nat_rule_del.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // NATRuleDelRequest struct to delete NAT rule diff --git a/pkg/cloudapi/vins/nat_rule_list.go b/pkg/cloudapi/vins/nat_rule_list.go index 0593cac..b55b30d 100644 --- a/pkg/cloudapi/vins/nat_rule_list.go +++ b/pkg/cloudapi/vins/nat_rule_list.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // NATRuleListRequest struct to get list of NAT rules diff --git a/pkg/cloudapi/vins/restore.go b/pkg/cloudapi/vins/restore.go index f4ad926..c304e39 100644 --- a/pkg/cloudapi/vins/restore.go +++ b/pkg/cloudapi/vins/restore.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // RestoreRequest struct for restore diff --git a/pkg/cloudapi/vins/serialize.go b/pkg/cloudapi/vins/serialize.go index 472cd51..9f20463 100644 --- a/pkg/cloudapi/vins/serialize.go +++ b/pkg/cloudapi/vins/serialize.go @@ -3,7 +3,7 @@ package vins import ( "encoding/json" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/serialization" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/serialization" ) // Serialize returns JSON-serialized []byte. Used as a wrapper over json.Marshal and json.MarshalIndent functions. diff --git a/pkg/cloudapi/vins/static_route_access_grant.go b/pkg/cloudapi/vins/static_route_access_grant.go index 2ec4c26..fbb4805 100644 --- a/pkg/cloudapi/vins/static_route_access_grant.go +++ b/pkg/cloudapi/vins/static_route_access_grant.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // StaticRouteAccessGrantRequest struct to grant access to static route to Compute/ViNS diff --git a/pkg/cloudapi/vins/static_route_access_revoke.go b/pkg/cloudapi/vins/static_route_access_revoke.go index 80028bd..7a3bb1d 100644 --- a/pkg/cloudapi/vins/static_route_access_revoke.go +++ b/pkg/cloudapi/vins/static_route_access_revoke.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // StaticRouteAccessRevokeRequest struct to revoke access to static route to Compute/ViNS diff --git a/pkg/cloudapi/vins/static_route_add.go b/pkg/cloudapi/vins/static_route_add.go index ae21ce9..d9ed59b 100644 --- a/pkg/cloudapi/vins/static_route_add.go +++ b/pkg/cloudapi/vins/static_route_add.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // StaticRouteAddRequest struct to add static route diff --git a/pkg/cloudapi/vins/static_route_del.go b/pkg/cloudapi/vins/static_route_del.go index 235835c..283ab65 100644 --- a/pkg/cloudapi/vins/static_route_del.go +++ b/pkg/cloudapi/vins/static_route_del.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // StaticRouteDelRequest struct to remove static route from ViNS diff --git a/pkg/cloudapi/vins/static_route_list.go b/pkg/cloudapi/vins/static_route_list.go index 95054ae..5c9bc9b 100644 --- a/pkg/cloudapi/vins/static_route_list.go +++ b/pkg/cloudapi/vins/static_route_list.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // StaticRouteListRequest struct for static route list diff --git a/pkg/cloudapi/vins/vins.go b/pkg/cloudapi/vins/vins.go index a60daa0..a16f190 100644 --- a/pkg/cloudapi/vins/vins.go +++ b/pkg/cloudapi/vins/vins.go @@ -2,7 +2,7 @@ package vins import ( - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/interfaces" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/interfaces" ) // Structure for creating request to VINS diff --git a/pkg/cloudapi/vins/vnfdev_redeploy.go b/pkg/cloudapi/vins/vnfdev_redeploy.go index 6d3aa64..df09287 100644 --- a/pkg/cloudapi/vins/vnfdev_redeploy.go +++ b/pkg/cloudapi/vins/vnfdev_redeploy.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // VNFDevRedeployRequest struct for redeploy VNFDevs diff --git a/pkg/cloudapi/vins/vnfdev_restart.go b/pkg/cloudapi/vins/vnfdev_restart.go index d47f295..abd5a22 100644 --- a/pkg/cloudapi/vins/vnfdev_restart.go +++ b/pkg/cloudapi/vins/vnfdev_restart.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // VNFDevRestartRequest struct for reboot VINSes primary VNF device diff --git a/pkg/cloudapi/zone.go b/pkg/cloudapi/zone.go new file mode 100644 index 0000000..e7eb6d1 --- /dev/null +++ b/pkg/cloudapi/zone.go @@ -0,0 +1,10 @@ +package cloudapi + +import ( + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/pkg/cloudapi/zone" +) + +// Accessing the Zone method group +func (ca *CloudAPI) Zone() *zone.Zone { + return zone.New(ca.client) +} diff --git a/pkg/cloudapi/zone/filter.go b/pkg/cloudapi/zone/filter.go new file mode 100644 index 0000000..ec55a7a --- /dev/null +++ b/pkg/cloudapi/zone/filter.go @@ -0,0 +1,53 @@ +package zone + +// FilterByID returns ListZones with specified ID. +func (list ListZones) FilterByID(id uint64) ListZones { + predicate := func(izone RecordZone) bool { + return izone.ID == id + } + + return list.FilterFunc(predicate) +} + +// FilterByName returns ListZones with specified Name. +func (list ListZones) FilterByName(name string) ListZones { + predicate := func(izone RecordZone) bool { + return izone.Name == name + } + + return list.FilterFunc(predicate) +} + +// FilterByStatus returns ListZones with specified Status. +func (list ListZones) FilterByStatus(status string) ListZones { + predicate := func(izone RecordZone) bool { + return izone.Status == status + } + + return list.FilterFunc(predicate) +} + +// FilterFunc allows filtering ListZones based on a user-specified predicate. +func (list ListZones) FilterFunc(predicate func(RecordZone) bool) ListZones { + var result ListZones + + for _, item := range list.Data { + if predicate(item) { + result.Data = append(result.Data, item) + } + } + + result.EntryCount = uint64(len(result.Data)) + + return result +} + +// FindOne returns first found RecordZone +// If none was found, returns an empty struct. +func (list ListZones) FindOne() RecordZone { + if list.EntryCount == 0 { + return RecordZone{} + } + + return list.Data[0] +} diff --git a/pkg/cloudapi/zone/filter_test.go b/pkg/cloudapi/zone/filter_test.go new file mode 100644 index 0000000..5966796 --- /dev/null +++ b/pkg/cloudapi/zone/filter_test.go @@ -0,0 +1,86 @@ +package zone + +import "testing" + +var zones = ListZones{ + Data: []RecordZone{ + + { + ID: 2, + GUID: 0, + GID: 0, + Name: "System Config", + Description: "", + Deletable: true, + Status: "LOCKED", + CreatedTime: 1640995200, // 2022-01-01 + UpdatedTime: 1640995200, + NodeIDs: nil, + }, + { + ID: 5, + GUID: 5500, + GID: 6600, + Name: "ssss Nodes", + Description: " infrastructure", + Deletable: true, + Status: "DISABLED", + CreatedTime: 1577836800, // 2020-01-01 + UpdatedTime: 1580515200, // 2020-02-01 + NodeIDs: []uint64{777, 888, 999}, + }, + { + ID: 10, + GUID: 5500, + GID: 6600, + Name: "node", + Description: "infrastructure", + Deletable: true, + Status: "DISABLED", + CreatedTime: 1577836800, + UpdatedTime: 1580515200, + NodeIDs: []uint64{777, 888, 999}, + }, + }, +} + +func TestFilterByID(t *testing.T) { + actual := zones.FilterByID(10).FindOne() + + if actual.ID != 10 { + t.Fatal("expected ID 10, found: ", actual.ID) + } +} + +func TestFilterByName(t *testing.T) { + name := "node" + actual := zones.FilterByName(name).FindOne() + + if actual.Name != name { + t.Fatal("expected ", name, " found: ", actual.Name) + } +} + +func TestFilterByStatus(t *testing.T) { + actual := zones.FilterByStatus("DISABLED") + + if len(actual.Data) != 2 { + t.Fatal("expected 2 found, actual: ", len(actual.Data)) + } + + for _, item := range actual.Data { + if item.Status != "DISABLED" { + t.Fatal("expected Status 'DISABLED', found: ", item.Status) + } + } +} + +func TestFilterFunc(t *testing.T) { + actual := zones.FilterFunc(func(ien RecordZone) bool { + return ien.Deletable == true + }) + + if len(actual.Data) != 3 { + t.Fatal("expected 3 elements, found: ", len(actual.Data)) + } +} diff --git a/pkg/cloudapi/zone/get.go b/pkg/cloudapi/zone/get.go new file mode 100644 index 0000000..8f0dbd7 --- /dev/null +++ b/pkg/cloudapi/zone/get.go @@ -0,0 +1,46 @@ +package zone + +import ( + "context" + "encoding/json" + "net/http" + + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" +) + +// GetRequest struct to get detailed information about zone +type GetRequest struct { + // ID of zone + // Required: true + ID uint64 `url:"id" json:"id" validate:"required"` +} + +// Get gets detailed information about zone struct +func (e Zone) Get(ctx context.Context, req GetRequest) (*RecordZone, error) { + res, err := e.GetRaw(ctx, req) + if err != nil { + return nil, err + } + + info := RecordZone{} + + err = json.Unmarshal(res, &info) + if err != nil { + return nil, err + } + + return &info, nil +} + +// GetRaw gets detailed information about zone as an array of bytes +func (e Zone) GetRaw(ctx context.Context, req GetRequest) ([]byte, error) { + err := validators.ValidateRequest(req) + if err != nil { + return nil, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudapi/zone/get" + + res, err := e.client.DecortApiCall(ctx, http.MethodPost, url, req) + return res, err +} diff --git a/pkg/cloudapi/zone/ids.go b/pkg/cloudapi/zone/ids.go new file mode 100644 index 0000000..33f6193 --- /dev/null +++ b/pkg/cloudapi/zone/ids.go @@ -0,0 +1,10 @@ +package zone + +// IDs gets array of IDs from ListZones struct +func (le ListZones) IDs() []uint64 { + res := make([]uint64, 0, len(le.Data)) + for _, e := range le.Data { + res = append(res, e.ID) + } + return res +} diff --git a/pkg/cloudapi/zone/list.go b/pkg/cloudapi/zone/list.go new file mode 100644 index 0000000..92b96cb --- /dev/null +++ b/pkg/cloudapi/zone/list.go @@ -0,0 +1,84 @@ +package zone + +import ( + "context" + "encoding/json" + "net/http" + + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" +) + +// ListRequest struct to get list of zones +type ListRequest struct { + + // Find by ID + // Required: false + ByID uint64 `url:"by_id,omitempty" json:"by_id,omitempty"` + + // Find by Grid ID + // Required: false + GID uint64 `url:"gid,omitempty" json:"gid,omitempty"` + + // Find by name + // Required: false + Name string `url:"name,omitempty" json:"name,omitempty"` + + // Find by description + // Required: false + Description string `url:"description,omitempty" json:"description,omitempty"` + + // Find by status + // Required: false + Status string `url:"status,omitempty" json:"status,omitempty"` + + // Find by deletable + // Required: false + Deletable bool `url:"deletable,omitempty" json:"deletable,omitempty"` + + // Find by node ID + // Required: false + NodeID uint64 `url:"nodeId,omitempty" json:"nodeId,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 + // Required: false + Size uint64 `url:"size,omitempty" json:"size,omitempty"` +} + +// List gets list of all zones as a ListZones struct +func (e Zone) List(ctx context.Context, req ListRequest) (*ListZones, error) { + + res, err := e.ListRaw(ctx, req) + if err != nil { + return nil, err + } + + list := ListZones{} + + err = json.Unmarshal(res, &list) + if err != nil { + return nil, err + } + + return &list, nil +} + +// ListRaw gets list of all available zones as an array of bytes +func (e Zone) ListRaw(ctx context.Context, req ListRequest) ([]byte, error) { + + if err := validators.ValidateRequest(req); err != nil { + return nil, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudapi/zone/list" + + res, err := e.client.DecortApiCall(ctx, http.MethodPost, url, req) + return res, err +} diff --git a/pkg/cloudapi/zone/migrate_to_zone.go b/pkg/cloudapi/zone/migrate_to_zone.go new file mode 100644 index 0000000..6be865f --- /dev/null +++ b/pkg/cloudapi/zone/migrate_to_zone.go @@ -0,0 +1 @@ +package zone diff --git a/pkg/cloudapi/zone/models.go b/pkg/cloudapi/zone/models.go new file mode 100644 index 0000000..110f9f9 --- /dev/null +++ b/pkg/cloudapi/zone/models.go @@ -0,0 +1,63 @@ +package zone + +type ListZones struct { + // Entry count + EntryCount uint64 `json:"entryCount"` + + // Data + Data []RecordZone `json:"data"` +} + +// Detailed information about the zone record +type RecordZone struct { + // ID + ID uint64 `json:"id"` + + // GUID + GUID uint64 `json:"guid"` + + // GID + GID uint64 `json:"gid"` + + // Name + Name string `json:"name"` + + // List of associated account IDs + AccountIDs []uint64 `json:"accountIds"` + + // List of associated bservice IDs + BserviceIDs []uint64 `json:"bserviceIds"` + + // List of associated compute IDs + ComputeIDs []uint64 `json:"computeIds"` + + // Description + Description string `json:"description"` + + // Deletable flag + Deletable bool `json:"deletable"` + + // List of associated ExtNet IDs + ExtnetIDs []uint64 `json:"extnetIds"` + + // List of associated K8s IDs + K8SIDs []uint64 `json:"k8sIds"` + + // List of associated LB IDs + LBIDs []uint64 `json:"lbIds"` + + // Status + Status string `json:"status"` + + // Created timestamp + CreatedTime uint64 `json:"createdTime"` + + // Updated timestamp + UpdatedTime uint64 `json:"updatedTime"` + + // List of associated Node IDs + NodeIDs []uint64 `json:"nodeIds"` + + // List of associated VINS IDs + VinsIDs []uint64 `json:"vinsIds"` +} diff --git a/pkg/cloudapi/zone/serialize.go b/pkg/cloudapi/zone/serialize.go new file mode 100644 index 0000000..4ecb2a6 --- /dev/null +++ b/pkg/cloudapi/zone/serialize.go @@ -0,0 +1,43 @@ +package zone + +import ( + "encoding/json" + + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/serialization" +) + +// Serialize returns JSON-serialized []byte. Used as a wrapper over json.Marshal and json.MarshalIndent functions. +// +// In order to serialize with indent make sure to follow these guidelines: +// - First argument -> prefix +// - Second argument -> indent +func (list ListZones) Serialize(params ...string) (serialization.Serialized, error) { + if list.EntryCount == 0 { + return []byte{}, nil + } + + if len(params) > 1 { + prefix := params[0] + indent := params[1] + + return json.MarshalIndent(list, prefix, indent) + } + + return json.Marshal(list) +} + +// Serialize returns JSON-serialized []byte. Used as a wrapper over json.Marshal and json.MarshalIndent functions. +// +// In order to serialize with indent make sure to follow these guidelines: +// - First argument -> prefix +// - Second argument -> indent +func (item RecordZone) Serialize(params ...string) (serialization.Serialized, error) { + if len(params) > 1 { + prefix := params[0] + indent := params[1] + + return json.MarshalIndent(item, prefix, indent) + } + + return json.Marshal(item) +} diff --git a/pkg/cloudapi/zone/zone.go b/pkg/cloudapi/zone/zone.go new file mode 100644 index 0000000..cd157db --- /dev/null +++ b/pkg/cloudapi/zone/zone.go @@ -0,0 +1,18 @@ +// API Actor for use zones +package zone + +import ( + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/interfaces" +) + +// Structure for creating request to zone +type Zone struct { + client interfaces.Caller +} + +// Builder for zone endpoints +func New(client interfaces.Caller) *Zone { + return &Zone{ + client, + } +} diff --git a/pkg/cloudbroker/account.go b/pkg/cloudbroker/account.go index 2aab78f..cb40471 100644 --- a/pkg/cloudbroker/account.go +++ b/pkg/cloudbroker/account.go @@ -1,7 +1,7 @@ package cloudbroker import ( - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/pkg/cloudbroker/account" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/pkg/cloudbroker/account" ) // Accessing the Account method group diff --git a/pkg/cloudbroker/account/account.go b/pkg/cloudbroker/account/account.go index 17c2304..5731ca4 100644 --- a/pkg/cloudbroker/account/account.go +++ b/pkg/cloudbroker/account/account.go @@ -1,7 +1,7 @@ // API Actor API for managing account package account -import "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/interfaces" +import "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/interfaces" // Structure for creating request to account type Account struct { diff --git a/pkg/cloudbroker/account/add_storage_policy.go b/pkg/cloudbroker/account/add_storage_policy.go new file mode 100644 index 0000000..5651c47 --- /dev/null +++ b/pkg/cloudbroker/account/add_storage_policy.go @@ -0,0 +1,46 @@ +package account + +import ( + "context" + "net/http" + "strconv" + + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" +) + +// AddStoragePolicyRequest struct for adding storage policy to the account +type AddStoragePolicyRequest struct { + // ID of account to add to + // Required: true + AccountID uint64 `url:"account_id" json:"account_id" validate:"required"` + + // ID of the storage policy to which to connect account + // Required: true + StoragePolicyID uint64 `url:"storage_policy_id" json:"storage_policy_id" validate:"required"` + + // Limit storage resources GB. Or -1 unlimit + // Required: false + Limit int `url:"limit,omitempty" json:"limit,omitempty"` +} + +// AddStoragePolicy add storage policy to the account. +func (a Account) AddStoragePolicy(ctx context.Context, req AddStoragePolicyRequest) (bool, error) { + err := validators.ValidateRequest(req) + if err != nil { + return false, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/account/add_storage_policy" + + res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req) + if err != nil { + return false, err + } + + result, err := strconv.ParseBool(string(res)) + if err != nil { + return false, err + } + + return result, nil +} diff --git a/pkg/cloudbroker/account/add_user.go b/pkg/cloudbroker/account/add_user.go index 1f04dca..7475225 100644 --- a/pkg/cloudbroker/account/add_user.go +++ b/pkg/cloudbroker/account/add_user.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // AddUserRequest struct for adding permission to access to account for a user diff --git a/pkg/cloudbroker/account/add_zone.go b/pkg/cloudbroker/account/add_zone.go new file mode 100644 index 0000000..7426cb8 --- /dev/null +++ b/pkg/cloudbroker/account/add_zone.go @@ -0,0 +1,42 @@ +package account + +import ( + "context" + "net/http" + "strconv" + + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" +) + +// AddZoneRequest struct for adding zone to account for a user +type AddZoneRequest struct { + // ID of account to add to + // Required: true + AccountID uint64 `url:"accountId" json:"accountId" validate:"required"` + + // IDs of zones + // Required: true + ZoneIDs []uint64 `url:"zoneIds" json:"zoneIds" validate:"required"` +} + +// AddUser gives a user access rights. +func (a Account) AddZone(ctx context.Context, req AddZoneRequest) (bool, error) { + err := validators.ValidateRequest(req) + if err != nil { + return false, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/account/addZone" + + res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req) + if err != nil { + return false, err + } + + result, err := strconv.ParseBool(string(res)) + if err != nil { + return false, err + } + + return result, nil +} diff --git a/pkg/cloudbroker/account/audits.go b/pkg/cloudbroker/account/audits.go index a38b35b..99213bd 100644 --- a/pkg/cloudbroker/account/audits.go +++ b/pkg/cloudbroker/account/audits.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // AuditsRequest struct to give list of account audits diff --git a/pkg/cloudbroker/account/create.go b/pkg/cloudbroker/account/create.go index 47a8573..2c32f55 100644 --- a/pkg/cloudbroker/account/create.go +++ b/pkg/cloudbroker/account/create.go @@ -5,7 +5,8 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/constants" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // CreateRequest struct for creating account @@ -26,6 +27,10 @@ type CreateRequest struct { // Required: false EmailAddress string `url:"emailaddress,omitempty" json:"emailaddress,omitempty" validate:"omitempty,email"` + // Storage policies + // Required: false + StoragePolicies []StoragePolicy `url:"-" json:"storage_policies,omitempty"` + // Max size of memory in MB // Required: false MaxMemoryCapacity int64 `url:"maxMemoryCapacity,omitempty" json:"maxMemoryCapacity,omitempty"` @@ -60,9 +65,22 @@ type CreateRequest struct { UniqPools []string `url:"uniqPools,omitempty" json:"uniqPools,omitempty"` // Advanced compute features, - // one of: hugepages, numa, cpupin, vfnic, dpdk, changemac + // one of: hugepages, numa, cpupin, vfnic, dpdk, changemac, trunk // Required: false ComputeFeatures []string `url:"computeFeatures,omitempty" json:"computeFeatures,omitempty" validate:"omitempty,computeFeatures"` + + // Default zone ID + // Required: false + DefaultZoneID uint64 `url:"defaultZoneId,omitempty" json:"defaultZoneId,omitempty"` + + // Zones + // Required: false + ZoneIDs []uint64 `url:"zoneIds,omitempty" json:"zoneIds,omitempty"` +} + +type StoragePolicy struct { + ID uint64 `url:"id" json:"id"` + Limit int `url:"limit" json:"limit"` } // Create creates account @@ -75,7 +93,7 @@ func (a Account) Create(ctx context.Context, req CreateRequest) (uint64, error) url := "/cloudbroker/account/create" - res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req) + res, err := a.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req) if err != nil { return 0, err } diff --git a/pkg/cloudbroker/account/del_storage_policy.go b/pkg/cloudbroker/account/del_storage_policy.go new file mode 100644 index 0000000..4601319 --- /dev/null +++ b/pkg/cloudbroker/account/del_storage_policy.go @@ -0,0 +1,42 @@ +package account + +import ( + "context" + "net/http" + "strconv" + + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" +) + +// DelStoragePolicyRequest struct for deleting storage policy to the account +type DelStoragePolicyRequest struct { + // ID of account + // Required: true + AccountID uint64 `url:"account_id" json:"account_id" validate:"required"` + + // ID of the storage policy to which to disconnect account + // Required: true + StoragePolicyID uint64 `url:"storage_policy_id" json:"storage_policy_id" validate:"required"` +} + +// DelStoragePolicy delete storage policy to the account. +func (a Account) DelStoragePolicy(ctx context.Context, req DelStoragePolicyRequest) (bool, error) { + err := validators.ValidateRequest(req) + if err != nil { + return false, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/account/del_storage_policy" + + res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req) + if err != nil { + return false, err + } + + result, err := strconv.ParseBool(string(res)) + if err != nil { + return false, err + } + + return result, nil +} diff --git a/pkg/cloudbroker/account/delete.go b/pkg/cloudbroker/account/delete.go index 9305667..5b3460b 100644 --- a/pkg/cloudbroker/account/delete.go +++ b/pkg/cloudbroker/account/delete.go @@ -4,7 +4,7 @@ import ( "context" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // DeleteRequest struct to delete account @@ -20,25 +20,21 @@ type DeleteRequest struct { // Name of account // Required: false Name string `url:"name,omitempty" json:"name,omitempty"` - - // Reason of deleting - // Required: false - Reason string `url:"reason,omitempty" json:"reason,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) (bool, error) { +func (a Account) Delete(ctx context.Context, req DeleteRequest) (string, error) { err := validators.ValidateRequest(req) if err != nil { - return false, validators.ValidationErrors(validators.GetErrors(err)) + return "", validators.ValidationErrors(validators.GetErrors(err)) } url := "/cloudbroker/account/delete" - _, err = a.client.DecortApiCall(ctx, http.MethodPost, url, req) + result, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req) if err != nil { - return false, err + return "", err } - return true, nil + return string(result), nil } diff --git a/pkg/cloudbroker/account/delete_accounts.go b/pkg/cloudbroker/account/delete_accounts.go index 9ea0703..1c4f960 100644 --- a/pkg/cloudbroker/account/delete_accounts.go +++ b/pkg/cloudbroker/account/delete_accounts.go @@ -4,7 +4,7 @@ import ( "context" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // DeleteAccountsRequest struct to delete group of accounts @@ -19,18 +19,18 @@ type DeleteAccountsRequest struct { } // DeleteAccounts destroys a group of accounts -func (a Account) DeleteAccounts(ctx context.Context, req DeleteAccountsRequest) (bool, error) { +func (a Account) DeleteAccounts(ctx context.Context, req DeleteAccountsRequest) (string, error) { err := validators.ValidateRequest(req) if err != nil { - return false, validators.ValidationErrors(validators.GetErrors(err)) + return "", validators.ValidationErrors(validators.GetErrors(err)) } url := "/cloudbroker/account/deleteAccounts" - _, err = a.client.DecortApiCall(ctx, http.MethodPost, url, req) + res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req) if err != nil { - return false, err + return "", err } - return true, nil + return string(res), nil } diff --git a/pkg/cloudbroker/account/delete_user.go b/pkg/cloudbroker/account/delete_user.go index 170477a..333319c 100644 --- a/pkg/cloudbroker/account/delete_user.go +++ b/pkg/cloudbroker/account/delete_user.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // DeleteUserRequest struct to revoke access to account diff --git a/pkg/cloudbroker/account/disable.go b/pkg/cloudbroker/account/disable.go index 81365d7..4c09bd2 100644 --- a/pkg/cloudbroker/account/disable.go +++ b/pkg/cloudbroker/account/disable.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // DisableRequest struct to disable account @@ -13,10 +13,6 @@ type DisableRequest struct { // ID of account // Required: true AccountID uint64 `url:"accountId" json:"accountId" validate:"required"` - - // Reason of disabling - // Required: false - Reason string `url:"reason,omitempty" json:"reason,omitempty"` } // Disable disables an account diff --git a/pkg/cloudbroker/account/disable_accounts.go b/pkg/cloudbroker/account/disable_accounts.go index aec3e00..3527b6e 100644 --- a/pkg/cloudbroker/account/disable_accounts.go +++ b/pkg/cloudbroker/account/disable_accounts.go @@ -4,7 +4,7 @@ import ( "context" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // DisableAccountsRequest struct to disable group of accounts @@ -12,25 +12,21 @@ type DisableAccountsRequest struct { // IDs of accounts // Required: true AccountIDs []uint64 `url:"accountIds" json:"accountIds" validate:"min=1"` - - // Reason of disabling - // Required: false - Reason string `url:"reason,omitempty" json:"reason,omitempty"` } // DisableAccounts disables accounts -func (a Account) DisableAccounts(ctx context.Context, req DisableAccountsRequest) (bool, error) { +func (a Account) DisableAccounts(ctx context.Context, req DisableAccountsRequest) (string, error) { err := validators.ValidateRequest(req) if err != nil { - return false, validators.ValidationErrors(validators.GetErrors(err)) + return "", validators.ValidationErrors(validators.GetErrors(err)) } url := "/cloudbroker/account/disableAccounts" - _, err = a.client.DecortApiCall(ctx, http.MethodPost, url, req) + res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req) if err != nil { - return false, err + return "", err } - return true, nil + return string(res), nil } diff --git a/pkg/cloudbroker/account/enable.go b/pkg/cloudbroker/account/enable.go index 5d79149..8c16973 100644 --- a/pkg/cloudbroker/account/enable.go +++ b/pkg/cloudbroker/account/enable.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // EnableRequest struct to enable account diff --git a/pkg/cloudbroker/account/enable_accounts.go b/pkg/cloudbroker/account/enable_accounts.go index eec7aef..50fa4cc 100644 --- a/pkg/cloudbroker/account/enable_accounts.go +++ b/pkg/cloudbroker/account/enable_accounts.go @@ -4,7 +4,7 @@ import ( "context" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // EnableAccountsRequest to enable group of accounts @@ -15,18 +15,18 @@ type EnableAccountsRequest struct { } // EnableAccounts enables accounts -func (a Account) EnableAccounts(ctx context.Context, req EnableAccountsRequest) (bool, error) { +func (a Account) EnableAccounts(ctx context.Context, req EnableAccountsRequest) (string, error) { err := validators.ValidateRequest(req) if err != nil { - return false, validators.ValidationErrors(validators.GetErrors(err)) + return "", validators.ValidationErrors(validators.GetErrors(err)) } url := "/cloudbroker/account/enableAccounts" - _, err = a.client.DecortApiCall(ctx, http.MethodPost, url, req) + res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req) if err != nil { - return false, err + return "", err } - return true, nil + return string(res), nil } diff --git a/pkg/cloudbroker/account/filter_test.go b/pkg/cloudbroker/account/filter_test.go index 3b2458a..c8ccae9 100644 --- a/pkg/cloudbroker/account/filter_test.go +++ b/pkg/cloudbroker/account/filter_test.go @@ -7,18 +7,7 @@ import ( var accounts = ListAccounts{ Data: []ItemAccount{ { - Meta: []interface{}{}, InfoAccount: InfoAccount{ - ACL: []ACL{ - { - Explicit: true, - GUID: "", - Right: "CXDRAU", - Status: "CONFIRMED", - Type: "U", - UserGroupID: "not_really_timofey_tkachev_1@decs3o", - }, - }, CreatedTime: 1676878820, DeletedTime: 0, ID: 132847, @@ -26,20 +15,19 @@ var accounts = ListAccounts{ Status: "CONFIRMED", UpdatedTime: 1676645275, }, + ACL: []ACL{ + { + Explicit: true, + GUID: "", + Right: "CXDRAU", + Status: "CONFIRMED", + Type: "U", + UserGroupID: "not_really_timofey_tkachev_1@decs3o", + }, + }, }, { - Meta: []interface{}{}, InfoAccount: InfoAccount{ - ACL: []ACL{ - { - Explicit: true, - GUID: "", - Right: "CXDRAU", - Status: "CONFIRMED", - Type: "U", - UserGroupID: "timofey_tkachev_1@decs3o", - }, - }, CreatedTime: 1676645275, DeletedTime: 1677723401, ID: 132846, @@ -47,28 +35,19 @@ var accounts = ListAccounts{ Status: "DELETED", UpdatedTime: 1676645275, }, + ACL: []ACL{ + { + Explicit: true, + GUID: "", + Right: "CXDRAU", + Status: "CONFIRMED", + Type: "U", + UserGroupID: "timofey_tkachev_1@decs3o", + }, + }, }, { - Meta: []interface{}{}, InfoAccount: InfoAccount{ - ACL: []ACL{ - { - Explicit: true, - GUID: "", - Right: "CXDRAU", - Status: "CONFIRMED", - Type: "U", - UserGroupID: "timofey_tkachev_1@decs3o", - }, - { - Explicit: true, - GUID: "", - Right: "CXDRAU", - Status: "CONFIRMED", - Type: "U", - UserGroupID: "second_account@decs3o", - }, - }, CreatedTime: 1676883850, DeletedTime: 1676883899, ID: 132848, @@ -76,6 +55,24 @@ var accounts = ListAccounts{ Status: "DELETED", UpdatedTime: 1676878820, }, + ACL: []ACL{ + { + Explicit: true, + GUID: "", + Right: "CXDRAU", + Status: "CONFIRMED", + Type: "U", + UserGroupID: "timofey_tkachev_1@decs3o", + }, + { + Explicit: true, + GUID: "", + Right: "CXDRAU", + Status: "CONFIRMED", + Type: "U", + UserGroupID: "second_account@decs3o", + }, + }, }, }, EntryCount: 3, diff --git a/pkg/cloudbroker/account/get.go b/pkg/cloudbroker/account/get.go index 9f78251..479635e 100644 --- a/pkg/cloudbroker/account/get.go +++ b/pkg/cloudbroker/account/get.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // GetRequest struct to get information about account diff --git a/pkg/cloudbroker/account/get_resource_consumption.go b/pkg/cloudbroker/account/get_resource_consumption.go index 8367f1f..356a757 100644 --- a/pkg/cloudbroker/account/get_resource_consumption.go +++ b/pkg/cloudbroker/account/get_resource_consumption.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // GetResourceConsumptionRequest struct for getting resource consumption diff --git a/pkg/cloudbroker/account/grant_access_templates.go b/pkg/cloudbroker/account/grant_access_templates.go index 231f71d..0af76ea 100644 --- a/pkg/cloudbroker/account/grant_access_templates.go +++ b/pkg/cloudbroker/account/grant_access_templates.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // GrantAccessTemplatesRequest struct to share images with account diff --git a/pkg/cloudbroker/account/list.go b/pkg/cloudbroker/account/list.go index b347673..1fff9e8 100644 --- a/pkg/cloudbroker/account/list.go +++ b/pkg/cloudbroker/account/list.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ListRequest struct to get list of accounts @@ -30,6 +30,11 @@ type ListRequest struct { // Required: false SortBy string `url:"sortBy,omitempty" json:"sortBy,omitempty" validate:"omitempty,sortBy"` + // Sort by zone id + // Default value: 0 + // Required: false + ZoneID uint64 `url:"zone_id,omitempty" json:"zone_id,omitempty"` + // Page number // Required: false Page uint64 `url:"page,omitempty" json:"page,omitempty"` diff --git a/pkg/cloudbroker/account/list_available_templates.go b/pkg/cloudbroker/account/list_available_templates.go index 1b50f07..437ee38 100644 --- a/pkg/cloudbroker/account/list_available_templates.go +++ b/pkg/cloudbroker/account/list_available_templates.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ListAvailableTemplatesRequest struct to list templates who sharedWith include accountId diff --git a/pkg/cloudbroker/account/list_computes.go b/pkg/cloudbroker/account/list_computes.go index e2c28c9..bfb1286 100644 --- a/pkg/cloudbroker/account/list_computes.go +++ b/pkg/cloudbroker/account/list_computes.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ListComputesRequest struct to a get list of compute instances diff --git a/pkg/cloudbroker/account/list_deleted.go b/pkg/cloudbroker/account/list_deleted.go index 0729004..d277031 100644 --- a/pkg/cloudbroker/account/list_deleted.go +++ b/pkg/cloudbroker/account/list_deleted.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ListDeletedRequest struct to get list of deleted accounts diff --git a/pkg/cloudbroker/account/list_disks.go b/pkg/cloudbroker/account/list_disks.go index 6b19e19..d47a81a 100644 --- a/pkg/cloudbroker/account/list_disks.go +++ b/pkg/cloudbroker/account/list_disks.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ListDisksRequest struct to get list of deleted disks diff --git a/pkg/cloudbroker/account/list_flip_groups.go b/pkg/cloudbroker/account/list_flip_groups.go index d29281b..7332ab3 100644 --- a/pkg/cloudbroker/account/list_flip_groups.go +++ b/pkg/cloudbroker/account/list_flip_groups.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ListFLIPGroupsRequest struct to get list of FLIPGroups diff --git a/pkg/cloudbroker/account/list_rg.go b/pkg/cloudbroker/account/list_rg.go index 210a06e..75b388b 100644 --- a/pkg/cloudbroker/account/list_rg.go +++ b/pkg/cloudbroker/account/list_rg.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ListRGRequest struct to get list of resource groups diff --git a/pkg/cloudbroker/account/list_vins.go b/pkg/cloudbroker/account/list_vins.go index 48543ac..36f30cb 100644 --- a/pkg/cloudbroker/account/list_vins.go +++ b/pkg/cloudbroker/account/list_vins.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ListVINSRequest struct to get list of VINS diff --git a/pkg/cloudbroker/account/models.go b/pkg/cloudbroker/account/models.go index e506d2f..0e4c507 100644 --- a/pkg/cloudbroker/account/models.go +++ b/pkg/cloudbroker/account/models.go @@ -46,6 +46,18 @@ type ListResources struct { EntryCount uint64 `json:"entryCount"` } +// Policy +type Policy struct { + // Size of the disk + DiskSize float64 `json:"disksize"` + + // Max size of the disk + DiskSizeMax float64 `json:"disksizemax"` + + // SEPs used + SEPs map[string]map[string]DiskUsage `json:"seps"` +} + type Resource struct { // Number of cores CPU int64 `json:"cpu"` @@ -70,6 +82,9 @@ type Resource struct { // SEPs SEPs map[string]map[string]DiskUsage `json:"seps"` + + // Policies + Policies map[string]Policy `json:"policies"` } // Disk usage @@ -102,6 +117,15 @@ type ACL struct { UserGroupID string `json:"userGroupId"` } +// Access Control List with emails field +type ACLWithEmails struct { + // ACL + ACL + + // Emails + Emails []string `json:"emails"` +} + // Resource limits type ResourceLimits struct { // CuC @@ -124,6 +148,9 @@ type ResourceLimits struct { // GPUUnits GPUUnits float64 `json:"gpu_units"` + + // Storage policies + StoragePolicies []StoragePolicy `json:"storage_policy"` } // Main information about account @@ -131,12 +158,6 @@ type InfoAccount struct { // DCLocation DCLocation string `json:"DCLocation"` - // CKey - CKey string `json:"_ckey"` - - // Access Control List - ACL []ACL `json:"acl"` - // Company Company string `json:"company"` @@ -194,6 +215,9 @@ type InfoAccount struct { // Status Status string `json:"status"` + // Storage policy ids + StoragePolicyIDs []uint64 `json:"storage_policy_ids"` + // UniqPools UniqPools []string `json:"uniqPools"` @@ -205,21 +229,43 @@ type InfoAccount struct { // List of VINS IDs VINS []uint64 `json:"vins"` + + // Default zone ID + DefaultZoneID uint64 `json:"defaultZoneId"` +} + +// Deatailed information about the account zone +type ZoneID struct { + // ID of zone + ID int64 `json:"id"` + + // Name of zone + Name string `json:"name"` } // Deatailed information about account type RecordAccount struct { // Main information about account InfoAccount + + // Access Control List + ACL []ACLWithEmails `json:"acl"` + + // Zones IDs + ZoneIDs []ZoneID `json:"zoneIds"` } // More information about account type ItemAccount struct { - // Meta - Meta []interface{} `json:"_meta"` + + // Access Control List + ACL []ACL `json:"acl"` // Main information about account InfoAccount + + // Zones + ZoneIDs []uint64 `json:"zoneIds"` } // List of accounts diff --git a/pkg/cloudbroker/account/remove_zone.go b/pkg/cloudbroker/account/remove_zone.go new file mode 100644 index 0000000..c7ab065 --- /dev/null +++ b/pkg/cloudbroker/account/remove_zone.go @@ -0,0 +1,42 @@ +package account + +import ( + "context" + "net/http" + "strconv" + + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" +) + +// RemoveZoneRequest struct for removing zone from account for a user +type RemoveZoneRequest struct { + // ID of account to add to + // Required: true + AccountID uint64 `url:"accountId" json:"accountId" validate:"required"` + + // IDs of zones + // Required: true + ZoneIDs []uint64 `url:"zoneIds" json:"zoneIds" validate:"required"` +} + +// RemoveZone removes zones with ids provided from a user. +func (a Account) RemoveZone(ctx context.Context, req RemoveZoneRequest) (bool, error) { + err := validators.ValidateRequest(req) + if err != nil { + return false, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/account/removeZone" + + res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req) + if err != nil { + return false, err + } + + result, err := strconv.ParseBool(string(res)) + if err != nil { + return false, err + } + + return result, nil +} diff --git a/pkg/cloudbroker/account/restore.go b/pkg/cloudbroker/account/restore.go index 7ff8c25..9a3953a 100644 --- a/pkg/cloudbroker/account/restore.go +++ b/pkg/cloudbroker/account/restore.go @@ -4,7 +4,7 @@ import ( "context" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // RestoreRequest struct to restore a deleted account @@ -12,25 +12,21 @@ type RestoreRequest struct { // ID an account // Required: true AccountID uint64 `url:"accountId" json:"accountId" validate:"required"` - - // Reason of disabling - // Required: false - Reason string `url:"reason,omitempty" json:"reason,omitempty"` } // Restore restores a deleted account -func (a Account) Restore(ctx context.Context, req RestoreRequest) (bool, error) { +func (a Account) Restore(ctx context.Context, req RestoreRequest) (string, error) { err := validators.ValidateRequest(req) if err != nil { - return false, validators.ValidationErrors(validators.GetErrors(err)) + return "", validators.ValidationErrors(validators.GetErrors(err)) } url := "/cloudbroker/account/restore" - _, err = a.client.DecortApiCall(ctx, http.MethodPost, url, req) + result, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req) if err != nil { - return false, err + return "", err } - return true, nil + return string(result), nil } diff --git a/pkg/cloudbroker/account/revoke_access_templates.go b/pkg/cloudbroker/account/revoke_access_templates.go index dfaa227..e223d1b 100644 --- a/pkg/cloudbroker/account/revoke_access_templates.go +++ b/pkg/cloudbroker/account/revoke_access_templates.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // RevokeAccessTemplatesRequest struct to unshare images with account diff --git a/pkg/cloudbroker/account/serialize.go b/pkg/cloudbroker/account/serialize.go index 0c179d2..e1faf64 100644 --- a/pkg/cloudbroker/account/serialize.go +++ b/pkg/cloudbroker/account/serialize.go @@ -3,7 +3,7 @@ package account import ( "encoding/json" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/serialization" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/serialization" ) // Serialize returns JSON-serialized []byte. Used as a wrapper over json.Marshal and json.MarshalIndent functions. diff --git a/pkg/cloudbroker/account/set_cpu_allocation_parameter.go b/pkg/cloudbroker/account/set_cpu_allocation_parameter.go index d6b56f3..e3a5dcf 100644 --- a/pkg/cloudbroker/account/set_cpu_allocation_parameter.go +++ b/pkg/cloudbroker/account/set_cpu_allocation_parameter.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // SetCPUAllocationParameterRequest struct for setting CPU allocation parameter diff --git a/pkg/cloudbroker/account/set_cpu_allocation_ratio.go b/pkg/cloudbroker/account/set_cpu_allocation_ratio.go index 41c7815..acc2122 100644 --- a/pkg/cloudbroker/account/set_cpu_allocation_ratio.go +++ b/pkg/cloudbroker/account/set_cpu_allocation_ratio.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // SetCPUAllocationRatioRequest struct for setting CPU allocation ratio diff --git a/pkg/cloudbroker/account/update.go b/pkg/cloudbroker/account/update.go index cacc490..e866000 100644 --- a/pkg/cloudbroker/account/update.go +++ b/pkg/cloudbroker/account/update.go @@ -5,7 +5,8 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/constants" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // UpdateRequest struct to update account @@ -46,6 +47,10 @@ type UpdateRequest struct { // Required: false SendAccessEmails bool `url:"sendAccessEmails" json:"sendAccessEmails"` + // Storage policies + // Required: false + StoragePolicies []StoragePolicy `url:"-" json:"storage_policies,omitempty"` + // Limit (positive) or disable (0) GPU resources // Required: false GPUUnits int64 `url:"gpu_units,omitempty" json:"gpu_units,omitempty"` @@ -59,6 +64,10 @@ type UpdateRequest struct { // Default: false // Required: false ClearUniqPools bool `url:"clearUniqPools" json:"clearUniqPools"` + + // Default zone ID + // Required: false + DefaultZoneID uint64 `url:"defaultZoneId,omitempty" json:"defaultZoneId,omitempty"` } // Update updates an account name and resource types and limits @@ -70,7 +79,7 @@ func (a Account) Update(ctx context.Context, req UpdateRequest) (bool, error) { url := "/cloudbroker/account/update" - res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req) + res, err := a.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req) if err != nil { return false, err } diff --git a/pkg/cloudbroker/account/update_compute_features.go b/pkg/cloudbroker/account/update_compute_features.go index 76078b4..a838e80 100644 --- a/pkg/cloudbroker/account/update_compute_features.go +++ b/pkg/cloudbroker/account/update_compute_features.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // UpdateComputeFeaturesRequest struct to update advanced compute features @@ -15,7 +15,7 @@ type UpdateComputeFeaturesRequest struct { AccountID uint64 `url:"accountId" json:"accountId" validate:"required"` // Advanced compute features, - // one of: hugepages, numa, cpupin, vfnic, dpdk, changemac + // one of: hugepages, numa, cpupin, vfnic, dpdk, changemac, trunk // Required: false ComputeFeatures []string `url:"computeFeatures,omitempty" json:"computeFeatures,omitempty" validate:"omitempty,computeFeatures"` } diff --git a/pkg/cloudbroker/account/update_resource_types.go b/pkg/cloudbroker/account/update_resource_types.go index 611c737..cea14d2 100644 --- a/pkg/cloudbroker/account/update_resource_types.go +++ b/pkg/cloudbroker/account/update_resource_types.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // UpdateResourceTypesRequest struct to update resource types in account diff --git a/pkg/cloudbroker/account/update_user.go b/pkg/cloudbroker/account/update_user.go index 3240e1f..349b62d 100644 --- a/pkg/cloudbroker/account/update_user.go +++ b/pkg/cloudbroker/account/update_user.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // UpdateUserRequest struct to update user access rights diff --git a/pkg/cloudbroker/apiaccess.go b/pkg/cloudbroker/apiaccess.go index d40c83b..5898f36 100644 --- a/pkg/cloudbroker/apiaccess.go +++ b/pkg/cloudbroker/apiaccess.go @@ -1,6 +1,6 @@ package cloudbroker -import "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/pkg/cloudbroker/apiaccess" +import "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/pkg/cloudbroker/apiaccess" // Accessing the APIAccess method group func (cb *CloudBroker) APIAccess() *apiaccess.APIAccess { diff --git a/pkg/cloudbroker/apiaccess/api_find.go b/pkg/cloudbroker/apiaccess/api_find.go index 6c52c21..4db7d3f 100644 --- a/pkg/cloudbroker/apiaccess/api_find.go +++ b/pkg/cloudbroker/apiaccess/api_find.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // APIFindRequest struct for finding apiaccess groups. diff --git a/pkg/cloudbroker/apiaccess/apiaccess.go b/pkg/cloudbroker/apiaccess/apiaccess.go index 3aff618..d0c6d20 100644 --- a/pkg/cloudbroker/apiaccess/apiaccess.go +++ b/pkg/cloudbroker/apiaccess/apiaccess.go @@ -1,6 +1,6 @@ package apiaccess -import "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/interfaces" +import "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/interfaces" // Structure for creating request to APIAccess type APIAccess struct { diff --git a/pkg/cloudbroker/apiaccess/apis_exclude.go b/pkg/cloudbroker/apiaccess/apis_exclude.go index d976e12..8d8159b 100644 --- a/pkg/cloudbroker/apiaccess/apis_exclude.go +++ b/pkg/cloudbroker/apiaccess/apis_exclude.go @@ -6,7 +6,7 @@ import ( "fmt" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) type APIString string diff --git a/pkg/cloudbroker/apiaccess/apis_include.go b/pkg/cloudbroker/apiaccess/apis_include.go index e804ff3..645dc9e 100644 --- a/pkg/cloudbroker/apiaccess/apis_include.go +++ b/pkg/cloudbroker/apiaccess/apis_include.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // APIsIncludeRequest struct for adding api to access group. diff --git a/pkg/cloudbroker/apiaccess/copy.go b/pkg/cloudbroker/apiaccess/copy.go index 2eb8375..39d6298 100644 --- a/pkg/cloudbroker/apiaccess/copy.go +++ b/pkg/cloudbroker/apiaccess/copy.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // CopyRequest Request for copying apiaccess group. diff --git a/pkg/cloudbroker/apiaccess/create.go b/pkg/cloudbroker/apiaccess/create.go index dd8c8f3..4759ef0 100644 --- a/pkg/cloudbroker/apiaccess/create.go +++ b/pkg/cloudbroker/apiaccess/create.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // CreateRequest struct for creating apiaccess group. diff --git a/pkg/cloudbroker/apiaccess/delete.go b/pkg/cloudbroker/apiaccess/delete.go index e5c3d6a..f200d05 100644 --- a/pkg/cloudbroker/apiaccess/delete.go +++ b/pkg/cloudbroker/apiaccess/delete.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // DeleteRequest struct for deleting apiaccess group. diff --git a/pkg/cloudbroker/apiaccess/desc_update.go b/pkg/cloudbroker/apiaccess/desc_update.go index 2988704..36dee4f 100644 --- a/pkg/cloudbroker/apiaccess/desc_update.go +++ b/pkg/cloudbroker/apiaccess/desc_update.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // DescUpdateRequest struct for updating apiaccess group description. diff --git a/pkg/cloudbroker/apiaccess/get.go b/pkg/cloudbroker/apiaccess/get.go index 4cec279..01b7a33 100644 --- a/pkg/cloudbroker/apiaccess/get.go +++ b/pkg/cloudbroker/apiaccess/get.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // GetRequest struct to get apiaccess group. diff --git a/pkg/cloudbroker/apiaccess/list.go b/pkg/cloudbroker/apiaccess/list.go index 54d96bf..49c4808 100644 --- a/pkg/cloudbroker/apiaccess/list.go +++ b/pkg/cloudbroker/apiaccess/list.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ListRequest struct to get list of all non deleted apiaccess instances. diff --git a/pkg/cloudbroker/apiaccess/set_default.go b/pkg/cloudbroker/apiaccess/set_default.go index 2034432..85a728a 100644 --- a/pkg/cloudbroker/apiaccess/set_default.go +++ b/pkg/cloudbroker/apiaccess/set_default.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // SetDefaultRequest struct for setting default apiaccess group. diff --git a/pkg/cloudbroker/apiaccess/subtract.go b/pkg/cloudbroker/apiaccess/subtract.go index 9c8c68b..e1987f1 100644 --- a/pkg/cloudbroker/apiaccess/subtract.go +++ b/pkg/cloudbroker/apiaccess/subtract.go @@ -6,7 +6,7 @@ import ( "context" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // SubtractRequest struct for subtracting. diff --git a/pkg/cloudbroker/apiaccess/union.go b/pkg/cloudbroker/apiaccess/union.go index e03b1df..c5eafbf 100644 --- a/pkg/cloudbroker/apiaccess/union.go +++ b/pkg/cloudbroker/apiaccess/union.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // UnionRequest struct for union. diff --git a/pkg/cloudbroker/apiaccess/update.go b/pkg/cloudbroker/apiaccess/update.go index 7a1388d..96881c1 100644 --- a/pkg/cloudbroker/apiaccess/update.go +++ b/pkg/cloudbroker/apiaccess/update.go @@ -6,7 +6,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // UpdateRequest struct for updating apis of apiaccess group. diff --git a/pkg/cloudbroker/apiaccess/user_list.go b/pkg/cloudbroker/apiaccess/user_list.go index c90c326..9ade936 100644 --- a/pkg/cloudbroker/apiaccess/user_list.go +++ b/pkg/cloudbroker/apiaccess/user_list.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // UserListRequest struct for getting a list of users currently included in the specified group. diff --git a/pkg/cloudbroker/audit.go b/pkg/cloudbroker/audit.go index 4f208a2..ae7eb8f 100644 --- a/pkg/cloudbroker/audit.go +++ b/pkg/cloudbroker/audit.go @@ -1,7 +1,7 @@ package cloudbroker import ( - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/pkg/cloudbroker/audit" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/pkg/cloudbroker/audit" ) // Accessing the Stack method group diff --git a/pkg/cloudbroker/audit/audit.go b/pkg/cloudbroker/audit/audit.go index b2647e8..2ac3412 100644 --- a/pkg/cloudbroker/audit/audit.go +++ b/pkg/cloudbroker/audit/audit.go @@ -1,6 +1,6 @@ package audit -import "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/interfaces" +import "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/interfaces" // Structure for creating request to audit type Audit struct { diff --git a/pkg/cloudbroker/audit/filter.go b/pkg/cloudbroker/audit/filter.go new file mode 100644 index 0000000..82f80e6 --- /dev/null +++ b/pkg/cloudbroker/audit/filter.go @@ -0,0 +1,81 @@ +package audit + +// FilterByID returns ListAudits with specified ID. +func (la ListAudits) FilterByID(guid string) ListAudits { + predicate := func(ia ItemAudit) bool { + return ia.GUID == guid + } + + return la.FilterFunc(predicate) +} + +// FilterByCall returns ListAudits with specified call. +func (la ListAudits) FilterByCall(call string) ListAudits { + predicate := func(ic ItemAudit) bool { + return ic.Call == call + } + + return la.FilterFunc(predicate) +} + +// FilterByCorrelationID returns ListAudits with specified correlation id. +func (la ListAudits) FilterByCorrelationID(correlationID string) ListAudits { + predicate := func(ic ItemAudit) bool { + return ic.CorrelationID == correlationID + } + + return la.FilterFunc(predicate) +} + +// FilterByRemoteAddr returns ListAudits with specified remote address. +func (la ListAudits) FilterByRemoteAddr(remoteAddr string) ListAudits { + predicate := func(ic ItemAudit) bool { + return ic.RemoteAddr == remoteAddr + } + + return la.FilterFunc(predicate) +} + +// FilterByUser returns ListAudits with specified user name. +func (la ListAudits) FilterByUser(user string) ListAudits { + predicate := func(ic ItemAudit) bool { + return ic.User == user + } + + return la.FilterFunc(predicate) +} + +// FilterByStatusCode return ListAudits with specified status code. +func (la ListAudits) FilterByStatusCode(statusCode uint64) ListAudits { + predicate := func(ic ItemAudit) bool { + return ic.StatusCode == statusCode + } + + return la.FilterFunc(predicate) + +} + +// FilterFunc allows filtering ListAudits based on a user-specified predicate. +func (la ListAudits) FilterFunc(predicate func(ItemAudit) bool) ListAudits { + var result ListAudits + + for _, item := range la.Data { + if predicate(item) { + result.Data = append(result.Data, item) + } + } + + result.EntryCount = uint64(len(result.Data)) + + return result +} + +// FindOne returns first found ItemAudit +// If none was found, returns an empty struct. +func (la ListAudits) FindOne() ItemAudit { + if len(la.Data) == 0 { + return ItemAudit{} + } + + return la.Data[0] +} diff --git a/pkg/cloudbroker/audit/filter_test.go b/pkg/cloudbroker/audit/filter_test.go new file mode 100644 index 0000000..8f09a1b --- /dev/null +++ b/pkg/cloudbroker/audit/filter_test.go @@ -0,0 +1,115 @@ +package audit + +import ( + "testing" +) + +var audits = ListAudits{ + Data: []ItemAudit{ + { + Args: "[]", + Call: "/restmachine/cloudapi/audit/linkedJobs", + GUID: "550e8400-e29b-41d4-a716-446655440001", + CorrelationID: "550e8400-e29b-41d4-a716-446655440001", + Kwargs: `{\"audit_guid\":\"dd8623a1-a887-48c1-a500-c10210d404cf\"}`, + RemoteAddr: "192.168.1.100", + ResponseTime: 1, + Result: `[]`, + StatusCode: 200, + Timestamp: 1640995200, + TimestampEnd: 1640995201, + User: "test@example.com", + TTL: "2025-07-31T14:22:57.028000", + }, + { + Args: "[]", + Call: "/restmachine/cloudapi/audit/test", + GUID: "550e8400-e29b-41d4-a716-446655440002", + CorrelationID: "550e8400-e29b-41d4-a716-446655440002", + Kwargs: `{\"audit_guid\":\"dd8623a1-a887-48c1-a500-c10210d404cf\"}`, + RemoteAddr: "192.168.1.105", + ResponseTime: 5, + Result: `[]`, + StatusCode: 400, + Timestamp: 1640995200, + TimestampEnd: 1640995201, + User: "test2@example.com", + TTL: "2025-07-31T14:22:57.028000", + }, + }, + EntryCount: 2, +} + +func TestFilterByID(t *testing.T) { + actual := audits.FilterByID("550e8400-e29b-41d4-a716-446655440002").FindOne() + + if actual.GUID != "550e8400-e29b-41d4-a716-446655440002" { + t.Fatal("expected GUID 550e8400-e29b-41d4-a716-446655440002, found: ", actual.GUID) + } + + actualEmpty := audits.FilterByID("") + + if len(actualEmpty.Data) != 0 { + t.Fatal("expected empty, actual: ", len(actualEmpty.Data)) + } +} + +func TestFilterByCorrelationID(t *testing.T) { + actual := audits.FilterByCorrelationID("550e8400-e29b-41d4-a716-446655440002").FindOne() + + if actual.CorrelationID != "550e8400-e29b-41d4-a716-446655440002" { + t.Fatal("expected GUID 550e8400-e29b-41d4-a716-446655440002, found: ", actual.CorrelationID) + } + + actualEmpty := audits.FilterByCorrelationID("") + + if len(actualEmpty.Data) != 0 { + t.Fatal("expected empty, actual: ", len(actualEmpty.Data)) + } +} + +func TestFilterByRemoteAddr(t *testing.T) { + actual := audits.FilterByRemoteAddr("192.168.1.100").FindOne() + + if actual.RemoteAddr != "192.168.1.100" { + t.Fatal("expected remote address 192.168.1.100, found: ", actual.RemoteAddr) + } + + actualEmpty := audits.FilterByRemoteAddr("") + + if len(actualEmpty.Data) != 0 { + t.Fatal("expected empty, actual: ", len(actualEmpty.Data)) + } +} + +func TestFilterByUser(t *testing.T) { + actual := audits.FilterByUser("test@example.com").FindOne() + + if actual.User != "test@example.com" { + t.Fatal("expected user test@example.com, found: ", actual.RemoteAddr) + } + + actualEmpty := audits.FilterByUser("") + + if len(actualEmpty.Data) != 0 { + t.Fatal("expected empty, actual: ", len(actualEmpty.Data)) + } +} + +func TestFilterByCall(t *testing.T) { + actual := audits.FilterByCall("/restmachine/cloudapi/audit/test").FindOne() + + if actual.Call != "/restmachine/cloudapi/audit/test" { + t.Fatal("expected call /restmachine/cloudapi/audit/test, found: ", actual.Call) + } +} + +func TestFilterByStatusCode(t *testing.T) { + actual := audits.FilterByStatusCode(200) + + for _, item := range actual.Data { + if item.StatusCode != 200 { + t.Fatal("expected 200 status code, found: ", item.StatusCode) + } + } +} diff --git a/pkg/cloudbroker/audit/get.go b/pkg/cloudbroker/audit/get.go index 19c2850..45cb7fd 100644 --- a/pkg/cloudbroker/audit/get.go +++ b/pkg/cloudbroker/audit/get.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // GetRequest struct to get information about account diff --git a/pkg/cloudbroker/audit/linked_jobs.go b/pkg/cloudbroker/audit/linked_jobs.go index 174cfc4..5fbda40 100644 --- a/pkg/cloudbroker/audit/linked_jobs.go +++ b/pkg/cloudbroker/audit/linked_jobs.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // LinkedJobsRequest struct to get information about jobs linked with Audit diff --git a/pkg/cloudbroker/audit/list.go b/pkg/cloudbroker/audit/list.go index 2b23c69..70b2cf2 100644 --- a/pkg/cloudbroker/audit/list.go +++ b/pkg/cloudbroker/audit/list.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ListRequest struct to give list of account audits @@ -50,6 +50,50 @@ type ListRequest struct { // Page size // Required: false Size uint64 `url:"size,omitempty" json:"size,omitempty"` + + // Find by resource group id + // Required: false + RGID uint64 `url:"resgroup_id,omitempty" json:"resgroup_id,omitempty"` + + // Find by compute id + // Required: false + ComputeID uint64 `url:"compute_id,omitempty" json:"compute_id,omitempty"` + + // Find by account id + // Required: false + AccountID uint64 `url:"account_id,omitempty" json:"account_id,omitempty"` + + // Find by vins id + // Required: false + VINSID uint64 `url:"vins_id,omitempty" json:"vins_id,omitempty"` + + // Find by service id + // Required: false + ServiceID uint64 `url:"service_id,omitempty" json:"service_id,omitempty"` + + // Find by k8s id + // Required: false + K8SID uint64 `url:"k8s_id,omitempty" json:"k8s_id,omitempty"` + + // Find by flipgroup id + // Required: false + FLIPGroupID uint64 `url:"flipgroup_id,omitempty" json:"flipgroup_id,omitempty"` + + // Find by load balancer id + // Required: false + LBID uint64 `url:"lb_id,omitempty" json:"lb_id,omitempty"` + + // Find by sep id + // Required: false + SEPID uint64 `url:"sep_id,omitempty" json:"sep_id,omitempty"` + + // Find by node id + // Required: false + NodeID uint64 `url:"node_id,omitempty" json:"node_id,omitempty"` + + // Exclude audit lines from response + // Required: false + ExcludeAuditLines bool `url:"exclude_audit_lines,omitempty" json:"exclude_audit_lines,omitempty"` } // List gets audit records for the specified account object diff --git a/pkg/cloudbroker/audit/models.go b/pkg/cloudbroker/audit/models.go index ef9599b..a8bffe2 100644 --- a/pkg/cloudbroker/audit/models.go +++ b/pkg/cloudbroker/audit/models.go @@ -11,6 +11,9 @@ type ItemAudit struct { // GUID GUID string `json:"guid"` + // Correlation ID + CorrelationID string `json:"correlation_id"` + // Kwargs Kwargs string `json:"kwargs"` @@ -37,9 +40,6 @@ type ItemAudit struct { // TTL TTL string `json:"_ttl"` - - // Tags - Tags string `json:"tags"` } // List of audits @@ -60,6 +60,9 @@ type RecordAudit struct { // Call Call string `json:"call"` + // Correlation ID + CorrelationID string `json:"correlation_id"` + // GUID GUID string `json:"guid"` diff --git a/pkg/cloudbroker/backup.go b/pkg/cloudbroker/backup.go index 7300f68..34c98ab 100644 --- a/pkg/cloudbroker/backup.go +++ b/pkg/cloudbroker/backup.go @@ -1,6 +1,6 @@ package cloudbroker -import "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/pkg/cloudbroker/backup" +import "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/pkg/cloudbroker/backup" // Accessing the Backup method group func (cb *CloudBroker) Backup() *backup.Backup { diff --git a/pkg/cloudbroker/backup/backup.go b/pkg/cloudbroker/backup/backup.go index 6bc7339..d6548ff 100644 --- a/pkg/cloudbroker/backup/backup.go +++ b/pkg/cloudbroker/backup/backup.go @@ -1,7 +1,7 @@ package backup import ( - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/interfaces" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/interfaces" ) // Structure for creating request to backup diff --git a/pkg/cloudbroker/backup/create_disk_backup.go b/pkg/cloudbroker/backup/create_disk_backup.go index cc429b0..ca704ce 100644 --- a/pkg/cloudbroker/backup/create_disk_backup.go +++ b/pkg/cloudbroker/backup/create_disk_backup.go @@ -6,7 +6,7 @@ import ( "net/http" "strings" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // CreateDiskBackupRequest struct for creating disk backup diff --git a/pkg/cloudbroker/backup/create_disks_backup.go b/pkg/cloudbroker/backup/create_disks_backup.go index c2ec398..fe8e102 100644 --- a/pkg/cloudbroker/backup/create_disks_backup.go +++ b/pkg/cloudbroker/backup/create_disks_backup.go @@ -6,7 +6,7 @@ import ( "net/http" "strings" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) type Disk struct { diff --git a/pkg/cloudbroker/backup/delete_disk_backup.go b/pkg/cloudbroker/backup/delete_disk_backup.go index a3d34a7..e2da0b5 100644 --- a/pkg/cloudbroker/backup/delete_disk_backup.go +++ b/pkg/cloudbroker/backup/delete_disk_backup.go @@ -6,7 +6,7 @@ import ( "strconv" "strings" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // DeleteDiskBackupRequest struct for deleting disk backup diff --git a/pkg/cloudbroker/backup/list_backup_paths.go b/pkg/cloudbroker/backup/list_backup_paths.go index 3d04ac7..89479f6 100644 --- a/pkg/cloudbroker/backup/list_backup_paths.go +++ b/pkg/cloudbroker/backup/list_backup_paths.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ListBackupPathsRequest struct for getting list of backup paths diff --git a/pkg/cloudbroker/backup/restore_disk_from_backup.go b/pkg/cloudbroker/backup/restore_disk_from_backup.go index ba6cca2..62cc0fe 100644 --- a/pkg/cloudbroker/backup/restore_disk_from_backup.go +++ b/pkg/cloudbroker/backup/restore_disk_from_backup.go @@ -6,7 +6,7 @@ import ( "net/http" "strings" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // RestoreDiskFromBackupRequest struct for restoring disk from backup diff --git a/pkg/cloudbroker/backup/restore_disks_from_backup.go b/pkg/cloudbroker/backup/restore_disks_from_backup.go index d8ecfc6..6297cfc 100644 --- a/pkg/cloudbroker/backup/restore_disks_from_backup.go +++ b/pkg/cloudbroker/backup/restore_disks_from_backup.go @@ -6,7 +6,7 @@ import ( "net/http" "strings" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) type BackupFile struct { diff --git a/pkg/cloudbroker/bservice.go b/pkg/cloudbroker/bservice.go index 64f1592..eaa78ed 100644 --- a/pkg/cloudbroker/bservice.go +++ b/pkg/cloudbroker/bservice.go @@ -1,6 +1,6 @@ package cloudbroker -import "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/pkg/cloudbroker/bservice" +import "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/pkg/cloudbroker/bservice" // Accessing the BService method group func (ca *CloudBroker) BService() *bservice.BService { diff --git a/pkg/cloudbroker/bservice/bservice.go b/pkg/cloudbroker/bservice/bservice.go index c66b3a4..fefe960 100644 --- a/pkg/cloudbroker/bservice/bservice.go +++ b/pkg/cloudbroker/bservice/bservice.go @@ -1,6 +1,6 @@ package bservice -import "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/interfaces" +import "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/interfaces" // Structure for creating request to bservice type BService struct { diff --git a/pkg/cloudbroker/bservice/create.go b/pkg/cloudbroker/bservice/create.go index 65b797a..2dfa6bb 100644 --- a/pkg/cloudbroker/bservice/create.go +++ b/pkg/cloudbroker/bservice/create.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // CreateRequest struct for BasicService @@ -25,6 +25,10 @@ type CreateRequest struct { // SSH key to deploy for the specified user. Same key will be deployed to all computes of the service // Required: false SSHKey string `url:"sshKey,omitempty" json:"sshKey,omitempty"` + + // Zone ID + // Required: false + ZoneID uint64 `url:"zoneId,omitempty" json:"zoneId,omitempty"` } // Create creates blank BasicService instance diff --git a/pkg/cloudbroker/bservice/delete.go b/pkg/cloudbroker/bservice/delete.go index 3c8267f..a8020e9 100644 --- a/pkg/cloudbroker/bservice/delete.go +++ b/pkg/cloudbroker/bservice/delete.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // DeleteRequest struct to delete basic service @@ -15,8 +15,9 @@ type DeleteRequest struct { ServiceID uint64 `url:"serviceId" json:"serviceId" validate:"required"` // If set to False, Basic service will be deleted to recycle bin. Otherwise destroyed immediately - // Required: true - Permanently bool `url:"permanently" json:"permanently"` + // Required: false + // Default: false + Permanently bool `url:"permanently,omitempty" json:"permanently,omitempty"` } // Delete deletes BasicService instance diff --git a/pkg/cloudbroker/bservice/disable.go b/pkg/cloudbroker/bservice/disable.go index 1816793..6face5f 100644 --- a/pkg/cloudbroker/bservice/disable.go +++ b/pkg/cloudbroker/bservice/disable.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // DisableRequest struct for disable service diff --git a/pkg/cloudbroker/bservice/enable.go b/pkg/cloudbroker/bservice/enable.go index a297993..599ee3a 100644 --- a/pkg/cloudbroker/bservice/enable.go +++ b/pkg/cloudbroker/bservice/enable.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // EnableRequest struct to disable service diff --git a/pkg/cloudbroker/bservice/get.go b/pkg/cloudbroker/bservice/get.go index 186184f..b0ab349 100644 --- a/pkg/cloudbroker/bservice/get.go +++ b/pkg/cloudbroker/bservice/get.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // GetRequest struct to get detailed information about service diff --git a/pkg/cloudbroker/bservice/group_add.go b/pkg/cloudbroker/bservice/group_add.go index 10de6df..d9cbd6a 100644 --- a/pkg/cloudbroker/bservice/group_add.go +++ b/pkg/cloudbroker/bservice/group_add.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // GroupAddRequest struct to create new compute group within BasicService @@ -38,11 +38,9 @@ type GroupAddRequest struct { // Required: true ImageID uint64 `url:"imageId" json:"imageId" validate:"required"` - // Compute driver - // should be one of: - // - KVM_X86 + // Compute driver like a KVM_X86, etc. // Required: true - Driver string `url:"driver" json:"driver" validate:"driver"` + Driver string `url:"driver" json:"driver" validate:"required"` // Storage endpoint provider ID // Required: false @@ -75,6 +73,10 @@ type GroupAddRequest struct { //Chipset "i440fx" or "Q35 //Required: false Chipset string `url:"chipset,omitempty" json:"chipset,omitempty" validate:"chipset"` + + // ID of the chosen storage policy + // Required: false + StoragePolicyID uint64 `url:"storage_policy_id,omitempty" json:"storage_policy_id,omitempty"` } // GetRAM returns RAM field values diff --git a/pkg/cloudbroker/bservice/group_compute_remove.go b/pkg/cloudbroker/bservice/group_compute_remove.go index 65d7fd8..6b66da9 100644 --- a/pkg/cloudbroker/bservice/group_compute_remove.go +++ b/pkg/cloudbroker/bservice/group_compute_remove.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // GroupComputeRemoveRequest struct to remove group compute diff --git a/pkg/cloudbroker/bservice/group_get.go b/pkg/cloudbroker/bservice/group_get.go index f24b311..5c6adf4 100644 --- a/pkg/cloudbroker/bservice/group_get.go +++ b/pkg/cloudbroker/bservice/group_get.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // GroupGetRequest struct to get detailed information about Compute Group diff --git a/pkg/cloudbroker/bservice/group_parent_remove.go b/pkg/cloudbroker/bservice/group_parent_remove.go index 2ca1a2a..d18eb61 100644 --- a/pkg/cloudbroker/bservice/group_parent_remove.go +++ b/pkg/cloudbroker/bservice/group_parent_remove.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // GroupParentRemoveRequest struct to remove parent Compute Group diff --git a/pkg/cloudbroker/bservice/group_parrent_add.go b/pkg/cloudbroker/bservice/group_parrent_add.go index 38a4d00..cdd6cc0 100644 --- a/pkg/cloudbroker/bservice/group_parrent_add.go +++ b/pkg/cloudbroker/bservice/group_parrent_add.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // GroupParentAddRequest struct to add parent Compute Group relation to the specified Compute Group diff --git a/pkg/cloudbroker/bservice/group_remove.go b/pkg/cloudbroker/bservice/group_remove.go index 5456980..c8c887b 100644 --- a/pkg/cloudbroker/bservice/group_remove.go +++ b/pkg/cloudbroker/bservice/group_remove.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // GroupRemoveRequest struct for destroy the specified Compute Group diff --git a/pkg/cloudbroker/bservice/group_resize.go b/pkg/cloudbroker/bservice/group_resize.go index a94d028..83e1433 100644 --- a/pkg/cloudbroker/bservice/group_resize.go +++ b/pkg/cloudbroker/bservice/group_resize.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // GroupResizeRequest struct to resize the group diff --git a/pkg/cloudbroker/bservice/group_start.go b/pkg/cloudbroker/bservice/group_start.go index 9ac7aae..32918f8 100644 --- a/pkg/cloudbroker/bservice/group_start.go +++ b/pkg/cloudbroker/bservice/group_start.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // GroupStartRequest struct to start the specified Compute Group diff --git a/pkg/cloudbroker/bservice/group_stop.go b/pkg/cloudbroker/bservice/group_stop.go index 02ba1e5..7750077 100644 --- a/pkg/cloudbroker/bservice/group_stop.go +++ b/pkg/cloudbroker/bservice/group_stop.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // GroupStopRequest struct to stop the specified Compute Group diff --git a/pkg/cloudbroker/bservice/group_update.go b/pkg/cloudbroker/bservice/group_update.go index 31402fb..b35787e 100644 --- a/pkg/cloudbroker/bservice/group_update.go +++ b/pkg/cloudbroker/bservice/group_update.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // GroupUpdateRequest struct to update existing Compute group diff --git a/pkg/cloudbroker/bservice/group_update_extnet.go b/pkg/cloudbroker/bservice/group_update_extnet.go index 73a6859..50e7fb5 100644 --- a/pkg/cloudbroker/bservice/group_update_extnet.go +++ b/pkg/cloudbroker/bservice/group_update_extnet.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // GroupUpdateExtNetRequest struct to update External Network settings diff --git a/pkg/cloudbroker/bservice/group_update_vins.go b/pkg/cloudbroker/bservice/group_update_vins.go index 185a515..e3fb0a8 100644 --- a/pkg/cloudbroker/bservice/group_update_vins.go +++ b/pkg/cloudbroker/bservice/group_update_vins.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // GroupUpdateVINSRequest struct to update VINS settings diff --git a/pkg/cloudbroker/bservice/list.go b/pkg/cloudbroker/bservice/list.go index 7f04adb..7c1ad31 100644 --- a/pkg/cloudbroker/bservice/list.go +++ b/pkg/cloudbroker/bservice/list.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ListRequest struct to get list of BasicService instances @@ -42,6 +42,11 @@ type ListRequest struct { // Required: false AccountName string `url:"accountName,omitempty" json:"accountName,omitempty"` + // Sort by zone id + // Default value: 0 + // Required: false + ZoneID uint64 `url:"zone_id,omitempty" json:"zone_id,omitempty"` + // Sort by one of supported fields, format +|-(field) // Required: false SortBy string `url:"sortBy,omitempty" json:"sortBy,omitempty" validate:"omitempty,sortBy"` diff --git a/pkg/cloudbroker/bservice/list_deleted.go b/pkg/cloudbroker/bservice/list_deleted.go index c5f93a8..65cbaae 100644 --- a/pkg/cloudbroker/bservice/list_deleted.go +++ b/pkg/cloudbroker/bservice/list_deleted.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ListDeletedRequest struct to get list of deleted BasicService instances diff --git a/pkg/cloudbroker/bservice/migrate_to_zone.go b/pkg/cloudbroker/bservice/migrate_to_zone.go new file mode 100644 index 0000000..3fbf9f0 --- /dev/null +++ b/pkg/cloudbroker/bservice/migrate_to_zone.go @@ -0,0 +1,42 @@ +package bservice + +import ( + "context" + "net/http" + "strconv" + + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" +) + +// MigrateToZone struct to move basic service to another zone +type MigrateToZoneRequest struct { + // ID of the BasicService to move + // Required: true + ServiceID uint64 `url:"serviceId" json:"serviceId" validate:"required"` + + // ID of the zone to move + // Required: true + ZoneID uint64 `url:"zoneId" json:"zoneId" validate:"required"` +} + +// MigrateToZone moves Basic Service instance to new zone +func (b BService) MigrateToZone(ctx context.Context, req MigrateToZoneRequest) (bool, error) { + err := validators.ValidateRequest(req) + if err != nil { + return false, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/bservice/migrateToZone" + + res, err := b.client.DecortApiCall(ctx, http.MethodPost, url, req) + if err != nil { + return false, err + } + + result, err := strconv.ParseBool(string(res)) + if err != nil { + return false, err + } + + return result, nil +} diff --git a/pkg/cloudbroker/bservice/models.go b/pkg/cloudbroker/bservice/models.go index 08a0521..3790f99 100644 --- a/pkg/cloudbroker/bservice/models.go +++ b/pkg/cloudbroker/bservice/models.go @@ -88,6 +88,9 @@ type RecordBasicService struct { // Whether user controlled UserManaged bool `json:"userManaged"` + + // Zone ID + ZoneID uint64 `json:"zoneId"` } // List of Groups @@ -254,6 +257,9 @@ type ItemBasicService struct { // User Managed or not UserManaged bool `json:"userManaged"` + + // Zone ID + ZoneID uint64 `json:"zoneId"` } // List of Snapshots diff --git a/pkg/cloudbroker/bservice/restore.go b/pkg/cloudbroker/bservice/restore.go index eefefa5..0b867ae 100644 --- a/pkg/cloudbroker/bservice/restore.go +++ b/pkg/cloudbroker/bservice/restore.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // RestoreRequest struct to restore BasicService instance diff --git a/pkg/cloudbroker/bservice/snapshot_create.go b/pkg/cloudbroker/bservice/snapshot_create.go index 613fdb3..11a4463 100644 --- a/pkg/cloudbroker/bservice/snapshot_create.go +++ b/pkg/cloudbroker/bservice/snapshot_create.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // SnapshotCreateRequest struct to create snapshot diff --git a/pkg/cloudbroker/bservice/snapshot_delete.go b/pkg/cloudbroker/bservice/snapshot_delete.go index f18ab30..dd6086d 100644 --- a/pkg/cloudbroker/bservice/snapshot_delete.go +++ b/pkg/cloudbroker/bservice/snapshot_delete.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // SnapshotDeleteRequest struct to delete snapshot diff --git a/pkg/cloudbroker/bservice/snapshot_list.go b/pkg/cloudbroker/bservice/snapshot_list.go index 14aa5f7..df2a988 100644 --- a/pkg/cloudbroker/bservice/snapshot_list.go +++ b/pkg/cloudbroker/bservice/snapshot_list.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // SnapshotListRequest struct to get list of existing snapshots diff --git a/pkg/cloudbroker/bservice/snapshot_rollback.go b/pkg/cloudbroker/bservice/snapshot_rollback.go index 446f7ba..8b9ec6e 100644 --- a/pkg/cloudbroker/bservice/snapshot_rollback.go +++ b/pkg/cloudbroker/bservice/snapshot_rollback.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // SnapshotRollbackRequest struct to rollback snapshot diff --git a/pkg/cloudbroker/bservice/start.go b/pkg/cloudbroker/bservice/start.go index f00dd79..74605ca 100644 --- a/pkg/cloudbroker/bservice/start.go +++ b/pkg/cloudbroker/bservice/start.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // StartRequest struct to start service diff --git a/pkg/cloudbroker/bservice/stop.go b/pkg/cloudbroker/bservice/stop.go index b60ece6..f551016 100644 --- a/pkg/cloudbroker/bservice/stop.go +++ b/pkg/cloudbroker/bservice/stop.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // StopRequest struct to stop service diff --git a/pkg/cloudbroker/cloudbroker.go b/pkg/cloudbroker/cloudbroker.go index 8a86865..bfda106 100644 --- a/pkg/cloudbroker/cloudbroker.go +++ b/pkg/cloudbroker/cloudbroker.go @@ -1,7 +1,7 @@ // List of method groups for the admin package cloudbroker -import "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/interfaces" +import "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/interfaces" // Structure for creating request to CloudBroker groups type CloudBroker struct { diff --git a/pkg/cloudbroker/compute.go b/pkg/cloudbroker/compute.go index 5bcc59d..c46a11f 100644 --- a/pkg/cloudbroker/compute.go +++ b/pkg/cloudbroker/compute.go @@ -1,7 +1,7 @@ package cloudbroker import ( - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/pkg/cloudbroker/compute" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/pkg/cloudbroker/compute" ) // Accessing the Compute method group diff --git a/pkg/cloudbroker/compute/abort_shared_snapshot_merge.go b/pkg/cloudbroker/compute/abort_shared_snapshot_merge.go new file mode 100644 index 0000000..72c4074 --- /dev/null +++ b/pkg/cloudbroker/compute/abort_shared_snapshot_merge.go @@ -0,0 +1,42 @@ +package compute + +import ( + "context" + "net/http" + "strconv" + + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" +) + +// AbortSharedSnapshotMergeRequest struct to abort shared snapshots merge +type AbortSharedSnapshotMergeRequest struct { + // ID of the compute + // Required: true + ComputeID uint64 `url:"compute_id" json:"compute_id" validate:"required"` + + // Label of the snapshot + // Required: true + Label string `url:"label" json:"label" validate:"required"` +} + +// AbortSharedSnapshotMerge shared snapshots merge abort +func (c Compute) AbortSharedSnapshotMerge(ctx context.Context, req AbortSharedSnapshotMergeRequest) (bool, error) { + err := validators.ValidateRequest(req) + if err != nil { + return false, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/compute/abort_shared_snapshot_merge" + + res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req) + if err != nil { + return false, err + } + + result, err := strconv.ParseBool(string(res)) + if err != nil { + return false, err + } + + return result, nil +} diff --git a/pkg/cloudbroker/compute/affinity_group_check_start.go b/pkg/cloudbroker/compute/affinity_group_check_start.go index bcb94bf..03a17a9 100644 --- a/pkg/cloudbroker/compute/affinity_group_check_start.go +++ b/pkg/cloudbroker/compute/affinity_group_check_start.go @@ -4,7 +4,7 @@ import ( "context" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // AffinityGroupCheckStartRequest struct to check all computes with current affinity label can start diff --git a/pkg/cloudbroker/compute/affinity_label_remove.go b/pkg/cloudbroker/compute/affinity_label_remove.go index 9e68e33..1338c18 100644 --- a/pkg/cloudbroker/compute/affinity_label_remove.go +++ b/pkg/cloudbroker/compute/affinity_label_remove.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // AffinityLabelRemoveRequest struct for clear affinity label for compute diff --git a/pkg/cloudbroker/compute/affinity_label_set.go b/pkg/cloudbroker/compute/affinity_label_set.go index 9abd49e..c214ace 100644 --- a/pkg/cloudbroker/compute/affinity_label_set.go +++ b/pkg/cloudbroker/compute/affinity_label_set.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // AffinityLabelSetRequest struct to set affinity label for compute diff --git a/pkg/cloudbroker/compute/affinity_relations.go b/pkg/cloudbroker/compute/affinity_relations.go index c35b97d..04e6b72 100644 --- a/pkg/cloudbroker/compute/affinity_relations.go +++ b/pkg/cloudbroker/compute/affinity_relations.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // AffinityRelationsRequest struct to get dict of computes diff --git a/pkg/cloudbroker/compute/affinity_rule_add.go b/pkg/cloudbroker/compute/affinity_rule_add.go index c238043..224f739 100644 --- a/pkg/cloudbroker/compute/affinity_rule_add.go +++ b/pkg/cloudbroker/compute/affinity_rule_add.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // AffinityRuleAddRequest struct to add affinity rule diff --git a/pkg/cloudbroker/compute/affinity_rule_remove.go b/pkg/cloudbroker/compute/affinity_rule_remove.go index c46cc40..4031b75 100644 --- a/pkg/cloudbroker/compute/affinity_rule_remove.go +++ b/pkg/cloudbroker/compute/affinity_rule_remove.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // AffinityRuleRemoveRequest struct to remove affinity rule diff --git a/pkg/cloudbroker/compute/affinity_rules_clear.go b/pkg/cloudbroker/compute/affinity_rules_clear.go index f46bf1c..4ec49ec 100644 --- a/pkg/cloudbroker/compute/affinity_rules_clear.go +++ b/pkg/cloudbroker/compute/affinity_rules_clear.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // AffinityRulesClearRequest struct to clear affinity rules diff --git a/pkg/cloudbroker/compute/anti_affinity_rule_add.go b/pkg/cloudbroker/compute/anti_affinity_rule_add.go index aa9d5f7..85e3b0b 100644 --- a/pkg/cloudbroker/compute/anti_affinity_rule_add.go +++ b/pkg/cloudbroker/compute/anti_affinity_rule_add.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // AntiAffinityRuleAddRequest struct to add anti affinity rule diff --git a/pkg/cloudbroker/compute/anti_affinity_rule_clear.go b/pkg/cloudbroker/compute/anti_affinity_rule_clear.go index 06e9b9b..21ae1fe 100644 --- a/pkg/cloudbroker/compute/anti_affinity_rule_clear.go +++ b/pkg/cloudbroker/compute/anti_affinity_rule_clear.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // AntiAffinityRulesClearRequest struct to clear anti affinity rules diff --git a/pkg/cloudbroker/compute/anti_affinity_rule_remove.go b/pkg/cloudbroker/compute/anti_affinity_rule_remove.go index 58078a1..3d79125 100644 --- a/pkg/cloudbroker/compute/anti_affinity_rule_remove.go +++ b/pkg/cloudbroker/compute/anti_affinity_rule_remove.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // AntiAffinityRuleRemoveRequest struct to remove anti affinity rule diff --git a/pkg/cloudbroker/compute/attach_gpu.go b/pkg/cloudbroker/compute/attach_gpu.go index 0b492bf..5ccba0f 100644 --- a/pkg/cloudbroker/compute/attach_gpu.go +++ b/pkg/cloudbroker/compute/attach_gpu.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // AttachGPURequest struct to attach GPU for compute diff --git a/pkg/cloudbroker/compute/attach_pci_device.go b/pkg/cloudbroker/compute/attach_pci_device.go index 6c09e45..d392fe6 100644 --- a/pkg/cloudbroker/compute/attach_pci_device.go +++ b/pkg/cloudbroker/compute/attach_pci_device.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // AttachPCIDeviceRequest struct to attach PCI device diff --git a/pkg/cloudbroker/compute/audits.go b/pkg/cloudbroker/compute/audits.go index a1187d9..03c1e73 100644 --- a/pkg/cloudbroker/compute/audits.go +++ b/pkg/cloudbroker/compute/audits.go @@ -5,18 +5,54 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // AuditsRequest struct to get audit records type AuditsRequest struct { // ID of the compute // Required: true - ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"` + ComputeID uint64 `url:"compute_id" json:"compute_id" validate:"required"` + + // Find all audits after point in time + // Required: false + TimestampAT uint64 `url:"timestamp_at,omitempty" json:"timestamp_at,omitempty"` + + // Find all audits before point in time + // Required: false + TimestampTO uint64 `url:"timestamp_to,omitempty" json:"timestamp_to,omitempty"` + + // Find by user + // Required: false + User string `url:"user,omitempty" json:"user,omitempty"` + + // Find by api endpoints + // Required: false + Call string `url:"call,omitempty" json:"call,omitempty"` + + // Sort by one of supported fields, format ± + // Required: false + SortBy string `url:"sort_by,omitempty" json:"sort_by,omitempty"` + + // Page number + // Required: false + Page uint64 `url:"page,omitempty" json:"page,omitempty"` + + // Page size + // Required: false + Size uint64 `url:"size,omitempty" json:"size,omitempty"` + + // Find by HTTP min status code + // Required: false + MinStatusCode uint64 `url:"min_status_code,omitempty" json:"min_status_code,omitempty"` + + // Find by HTTP max status code + // Required: false + MaxStatusCode uint64 `url:"max_status_code,omitempty" json:"max_status_code,omitempty"` } // Audits gets audit records for the specified compute object -func (c Compute) Audits(ctx context.Context, req AuditsRequest) (ListDetailedAudits, error) { +func (c Compute) Audits(ctx context.Context, req AuditsRequest) (*ListDetailedAudits, error) { err := validators.ValidateRequest(req) if err != nil { return nil, validators.ValidationErrors(validators.GetErrors(err)) @@ -24,7 +60,7 @@ func (c Compute) Audits(ctx context.Context, req AuditsRequest) (ListDetailedAud url := "/cloudbroker/compute/audits" - res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req) + res, err := c.client.DecortApiCall(ctx, http.MethodGet, url, req) if err != nil { return nil, err } @@ -36,5 +72,5 @@ func (c Compute) Audits(ctx context.Context, req AuditsRequest) (ListDetailedAud return nil, err } - return list, nil + return &list, nil } diff --git a/pkg/cloudbroker/compute/boot_disk_set.go b/pkg/cloudbroker/compute/boot_disk_set.go index 8b97736..0366cdc 100644 --- a/pkg/cloudbroker/compute/boot_disk_set.go +++ b/pkg/cloudbroker/compute/boot_disk_set.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // BootDiskSetRequest struct to set boot disk for compute diff --git a/pkg/cloudbroker/compute/boot_order_get.go b/pkg/cloudbroker/compute/boot_order_get.go index 9b16968..f8b23bb 100644 --- a/pkg/cloudbroker/compute/boot_order_get.go +++ b/pkg/cloudbroker/compute/boot_order_get.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // BootOrderGetRequest struct to get boot order diff --git a/pkg/cloudbroker/compute/boot_order_set.go b/pkg/cloudbroker/compute/boot_order_set.go index b865aca..5117637 100644 --- a/pkg/cloudbroker/compute/boot_order_set.go +++ b/pkg/cloudbroker/compute/boot_order_set.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // BootOrderSetRequest struct to set boot order diff --git a/pkg/cloudbroker/compute/cd_eject.go b/pkg/cloudbroker/compute/cd_eject.go index ba72de0..298fc40 100644 --- a/pkg/cloudbroker/compute/cd_eject.go +++ b/pkg/cloudbroker/compute/cd_eject.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // CDEjectRequest struct to eject CD image diff --git a/pkg/cloudbroker/compute/cd_insert.go b/pkg/cloudbroker/compute/cd_insert.go index 1025bb3..c176a8b 100644 --- a/pkg/cloudbroker/compute/cd_insert.go +++ b/pkg/cloudbroker/compute/cd_insert.go @@ -4,7 +4,7 @@ import ( "context" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // CDInsertRequest struct to insert new CD image diff --git a/pkg/cloudbroker/compute/change_ip.go b/pkg/cloudbroker/compute/change_ip.go index 92e3af6..441b845 100644 --- a/pkg/cloudbroker/compute/change_ip.go +++ b/pkg/cloudbroker/compute/change_ip.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ChangeIPRequest struct to change IP for network diff --git a/pkg/cloudbroker/compute/change_link_state.go b/pkg/cloudbroker/compute/change_link_state.go index e47aad3..261b45a 100644 --- a/pkg/cloudbroker/compute/change_link_state.go +++ b/pkg/cloudbroker/compute/change_link_state.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ChangeLinkStateRequest struct for changing link state diff --git a/pkg/cloudbroker/compute/change_mac.go b/pkg/cloudbroker/compute/change_mac.go index 6c64e5f..3044d9e 100644 --- a/pkg/cloudbroker/compute/change_mac.go +++ b/pkg/cloudbroker/compute/change_mac.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ChangeMACRequest struct to change MAC for network diff --git a/pkg/cloudbroker/compute/change_mtu.go b/pkg/cloudbroker/compute/change_mtu.go new file mode 100644 index 0000000..4d0fd22 --- /dev/null +++ b/pkg/cloudbroker/compute/change_mtu.go @@ -0,0 +1,46 @@ +package compute + +import ( + "context" + "net/http" + "strconv" + + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" +) + +// ChangeMTURequest struct to change MTU for a compute +type ChangeMTURequest struct { + // ID of compute instance + // Required: true + ComputeID uint64 `url:"compute_id" json:"compute_id" validate:"required"` + + // Interface name or MAC address + // Required: true + Interface string `url:"interface" json:"interface" validate:"required"` + + // Maximum transmission unit + // Required: true + MTU uint64 `url:"mtu" json:"mtu" validate:"required" validate:"omitempty,mtu"` +} + +// ChangeMTU change MTU for compute instance +func (c Compute) ChangeMTU(ctx context.Context, req ChangeMTURequest) (bool, error) { + err := validators.ValidateRequest(req) + if err != nil { + return false, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/compute/change_mtu" + + res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req) + if err != nil { + return false, err + } + + result, err := strconv.ParseBool(string(res)) + if err != nil { + return false, err + } + + return result, nil +} diff --git a/pkg/cloudbroker/compute/change_secutity_group.go b/pkg/cloudbroker/compute/change_secutity_group.go new file mode 100644 index 0000000..04bd3ed --- /dev/null +++ b/pkg/cloudbroker/compute/change_secutity_group.go @@ -0,0 +1,50 @@ +package compute + +import ( + "context" + "net/http" + "strconv" + + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" +) + +// ChangeSecGroupsRequest struct to change security groups for compute +type ChangeSecGroupsRequest struct { + // Identifier compute + // Required: true + ComputeID uint64 `url:"compute_id" json:"compute_id" validate:"required"` + + // Interface name or MAC address + // Required: true + Interface string `url:"interface" json:"interface" validate:"required"` + + // List of security group IDs to assign to this interface + // Required: false + SecGroups []uint64 `url:"security_groups,omitempty" json:"security_groups,omitempty"` + + // Flag indicating whether security groups are enabled for this interface + // Required: false + EnableSecGroups interface{} `url:"enable_secgroups,omitempty" json:"enable_secgroups,omitempty" validate:"omitempty,isBool"` +} + +// ChangeSecGroups changes security groups for compute +func (c Compute) ChangeSecGroups(ctx context.Context, req ChangeSecGroupsRequest) (bool, error) { + err := validators.ValidateRequest(req) + if err != nil { + return false, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/compute/change_security_groups" + + res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req) + if err != nil { + return false, err + } + + result, err := strconv.ParseBool(string(res)) + if err != nil { + return false, err + } + + return result, nil +} diff --git a/pkg/cloudbroker/compute/clone.go b/pkg/cloudbroker/compute/clone.go index daf0a75..25242fc 100644 --- a/pkg/cloudbroker/compute/clone.go +++ b/pkg/cloudbroker/compute/clone.go @@ -3,9 +3,9 @@ package compute import ( "context" "net/http" - "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/constants" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // CloneRequest struct to clone compute instance @@ -18,6 +18,10 @@ type CloneRequest struct { // Required: true Name string `url:"name" json:"name" validate:"required"` + // ID of the Storage Policy + // Required: true + StoragePolicyID uint64 `url:"storage_policy_id" json:"storage_policy_id" validate:"required"` + // Timestamp of the parent's snapshot to create clone from // Required: false SnapshotTimestamp uint64 `url:"snapshotTimestamp" json:"snapshotTimestamp"` @@ -30,26 +34,29 @@ type CloneRequest struct { // Default: false // Required: false Force bool `url:"force" json:"force"` + + // The name of the pool to migrate disks to + // Required: false + PoolName string `url:"pool_name" json:"pool_name"` + + // The ID of the SEP to migrate disks to + // Required: false + SEPID uint64 `url:"sep_id" json:"sep_id"` } // Clone clones compute instance -func (c Compute) Clone(ctx context.Context, req CloneRequest) (uint64, error) { +func (c Compute) Clone(ctx context.Context, req CloneRequest) (string, error) { err := validators.ValidateRequest(req) if err != nil { - return 0, validators.ValidationErrors(validators.GetErrors(err)) + return "", validators.ValidationErrors(validators.GetErrors(err)) } url := "/cloudbroker/compute/clone" - res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req) - if err != nil { - return 0, err - } - - result, err := strconv.ParseUint(string(res), 10, 64) + res, err := c.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req) if err != nil { - return 0, err + return "", err } - return result, nil + return string(res), nil } diff --git a/pkg/cloudbroker/compute/clone_abort.go b/pkg/cloudbroker/compute/clone_abort.go new file mode 100644 index 0000000..d37f4be --- /dev/null +++ b/pkg/cloudbroker/compute/clone_abort.go @@ -0,0 +1,39 @@ +package compute + +import ( + "context" + "net/http" + "strconv" + + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/constants" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" +) + +// CloneAbortRequest struct to abort a compute clone +type CloneAbortRequest struct { + // ID of compute instance + // Required: true + ComputeID uint64 `url:"compute_id" json:"compute_id" validate:"required"` +} + +// CloneAbort aborts a compute clone +func (c Compute) CloneAbort(ctx context.Context, req CloneAbortRequest) (bool, error) { + err := validators.ValidateRequest(req) + if err != nil { + return false, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/compute/clone_abort" + + res, err := c.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req) + if err != nil { + return false, err + } + + result, err := strconv.ParseBool(string(res)) + if err != nil { + return false, err + } + + return result, nil +} diff --git a/pkg/cloudbroker/compute/clone_status.go b/pkg/cloudbroker/compute/clone_status.go new file mode 100644 index 0000000..d0f52e2 --- /dev/null +++ b/pkg/cloudbroker/compute/clone_status.go @@ -0,0 +1,40 @@ +package compute + +import ( + "context" + "encoding/json" + "net/http" + + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" +) + +// GetCloneStatusRequest struct to get information about compute clone status +type GetCloneStatusRequest struct { + // ID of compute instance + // Required: true + ComputeID uint64 `url:"compute_id" json:"compute_id" validate:"required"` +} + +// GetCloneStatus gets information about compute clone status as a RecordCloneStatus struct +func (c Compute) GetCloneStatus(ctx context.Context, req GetCloneStatusRequest) ([]RecordCloneStatus, error) { + err := validators.ValidateRequest(req) + if err != nil { + return nil, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/compute/clone_status" + + res, err := c.client.DecortApiCall(ctx, http.MethodGet, url, req) + if err != nil { + return nil, err + } + + cloneStatus := make([]RecordCloneStatus, 0) + + err = json.Unmarshal(res, &cloneStatus) + if err != nil { + return nil, err + } + + return cloneStatus, nil +} diff --git a/pkg/cloudbroker/compute/compute.go b/pkg/cloudbroker/compute/compute.go index 922dbba..9eb4de0 100644 --- a/pkg/cloudbroker/compute/compute.go +++ b/pkg/cloudbroker/compute/compute.go @@ -1,7 +1,7 @@ // API Actor for managing Compute. This actor is a final API for admin to manage Compute package compute -import "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/interfaces" +import "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/interfaces" // Structure for creating request to compute type Compute struct { diff --git a/pkg/cloudbroker/compute/computeci_set.go b/pkg/cloudbroker/compute/computeci_set.go index ce3cb4b..6edd979 100644 --- a/pkg/cloudbroker/compute/computeci_set.go +++ b/pkg/cloudbroker/compute/computeci_set.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ComputeCISetRequest struct to set compute CI diff --git a/pkg/cloudbroker/compute/computeci_unset.go b/pkg/cloudbroker/compute/computeci_unset.go index 37188a4..21ddd61 100644 --- a/pkg/cloudbroker/compute/computeci_unset.go +++ b/pkg/cloudbroker/compute/computeci_unset.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ComputeCIUnsetRequest struct to unset compute CI diff --git a/pkg/cloudbroker/compute/create_template.go b/pkg/cloudbroker/compute/create_template.go index 0552764..2157479 100644 --- a/pkg/cloudbroker/compute/create_template.go +++ b/pkg/cloudbroker/compute/create_template.go @@ -3,10 +3,9 @@ package compute import ( "context" "net/http" - "strconv" "strings" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // CreateTemplateRequest struct to create template @@ -20,27 +19,16 @@ type CreateTemplateRequest struct { Name string `url:"name" json:"name" validate:"required"` } -type wrapperCreateTemplateRequest struct { - CreateTemplateRequest - - AsyncMode bool `url:"asyncMode"` -} - -// CreateTemplateAsync create template from compute instance -func (c Compute) CreateTemplateAsync(ctx context.Context, req CreateTemplateRequest) (string, error) { +// CreateTemplate create template from compute instance +func (c Compute) CreateTemplate(ctx context.Context, req CreateTemplateRequest) (string, error) { err := validators.ValidateRequest(req) if err != nil { return "", validators.ValidationErrors(validators.GetErrors(err)) } - reqWrapped := wrapperCreateTemplateRequest{ - CreateTemplateRequest: req, - AsyncMode: true, - } - url := "/cloudbroker/compute/createTemplate" - res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped) + res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req) if err != nil { return "", err } @@ -49,30 +37,3 @@ func (c Compute) CreateTemplateAsync(ctx context.Context, req CreateTemplateRequ return result, nil } - -// CreateTemplate create template from compute instance -func (c Compute) CreateTemplate(ctx context.Context, req CreateTemplateRequest) (uint64, error) { - err := validators.ValidateRequest(req) - if err != nil { - return 0, validators.ValidationErrors(validators.GetErrors(err)) - } - - reqWrapped := wrapperCreateTemplateRequest{ - CreateTemplateRequest: req, - AsyncMode: false, - } - - url := "/cloudbroker/compute/createTemplate" - - res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped) - if err != nil { - return 0, err - } - - result, err := strconv.ParseUint(string(res), 10, 64) - if err != nil { - return 0, err - } - - return result, nil -} diff --git a/pkg/cloudbroker/compute/create_template_from_blank.go b/pkg/cloudbroker/compute/create_template_from_blank.go index aa92a7e..321651a 100644 --- a/pkg/cloudbroker/compute/create_template_from_blank.go +++ b/pkg/cloudbroker/compute/create_template_from_blank.go @@ -6,7 +6,7 @@ import ( "strconv" "strings" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // CreateTemplateFromBlankRequest struct to create template from boot disk of current compute @@ -27,6 +27,10 @@ type CreateTemplateFromBlankRequest struct { // Required: true ImageType string `url:"imagetype" json:"imagetype" validate:"imageType"` + // Storage policy id of compute. The rules of the specified storage policy will be used. + // Required: true + StoragePolicyID uint64 `url:"storage_policy_id" json:"storage_policy_id" validate:"required"` + // Username for the image // Required: false Username string `url:"username,omitempty" json:"username,omitempty"` diff --git a/pkg/cloudbroker/compute/delete.go b/pkg/cloudbroker/compute/delete.go index 63421f5..594e4d4 100644 --- a/pkg/cloudbroker/compute/delete.go +++ b/pkg/cloudbroker/compute/delete.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // DeleteRequest struct to delete compute diff --git a/pkg/cloudbroker/compute/delete_custom_fields.go b/pkg/cloudbroker/compute/delete_custom_fields.go index 9a969a1..5208d87 100644 --- a/pkg/cloudbroker/compute/delete_custom_fields.go +++ b/pkg/cloudbroker/compute/delete_custom_fields.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // DeleteCustomFieldsRequest struct to delete compute's custom fields diff --git a/pkg/cloudbroker/compute/detach_gpu.go b/pkg/cloudbroker/compute/detach_gpu.go index 915c32b..5df8d00 100644 --- a/pkg/cloudbroker/compute/detach_gpu.go +++ b/pkg/cloudbroker/compute/detach_gpu.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // DetachGPURequest struct to detach VGPU for compute diff --git a/pkg/cloudbroker/compute/detach_pci_device.go b/pkg/cloudbroker/compute/detach_pci_device.go index 3853972..f1e06f2 100644 --- a/pkg/cloudbroker/compute/detach_pci_device.go +++ b/pkg/cloudbroker/compute/detach_pci_device.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // DetachPCIDeviceRequest struct to detach PCI device diff --git a/pkg/cloudbroker/compute/disable.go b/pkg/cloudbroker/compute/disable.go index 5a20d60..a198615 100644 --- a/pkg/cloudbroker/compute/disable.go +++ b/pkg/cloudbroker/compute/disable.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // DisableRequest struct to disable compute diff --git a/pkg/cloudbroker/compute/disk_add.go b/pkg/cloudbroker/compute/disk_add.go index 3f07ff6..a543e90 100644 --- a/pkg/cloudbroker/compute/disk_add.go +++ b/pkg/cloudbroker/compute/disk_add.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // DiskAddRequest struct to create and attach disk to compute @@ -27,6 +27,10 @@ type DiskAddRequest struct { // Required: false SepID uint64 `url:"sepId,omitempty" json:"sepId,omitempty"` + // Storage policy id of compute. The rules of the specified storage policy will be used. + // Required: true + StoragePolicyID uint64 `url:"storage_policy_id" json:"storage_policy_id" validate:"required"` + // Type of the disk // Should be one of: // - D @@ -46,6 +50,14 @@ type DiskAddRequest struct { // Specify image id for create disk from template // Required: false ImageID uint64 `url:"imageId,omitempty" json:"imageId,omitempty"` + + // Desired PCI slot (hex string, e.g. "0x1A") + // Required: false + PCISlot string `url:"pci_slot,omitempty" json:"pci_slot,omitempty"` + + // Desired bus number (hex string, e.g. "0x03") + // Required: false + BusNumber string `url:"bus_number,omitempty" json:"bus_number,omitempty"` } // DiskAdd creates new disk and attach to compute diff --git a/pkg/cloudbroker/compute/disk_attach.go b/pkg/cloudbroker/compute/disk_attach.go index db72d4c..ff988ef 100644 --- a/pkg/cloudbroker/compute/disk_attach.go +++ b/pkg/cloudbroker/compute/disk_attach.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // DiskAttachRequest struct to attach disk to compute @@ -21,6 +21,14 @@ type DiskAttachRequest struct { // Type of the disk B;D // Required: false DiskType string `url:"diskType,omitempty" json:"diskType,omitempty"` + + // Desired PCI slot (hex string, e.g. "0x1A") + // Required: false + PCISlot string `url:"pci_slot,omitempty" json:"pci_slot,omitempty"` + + // Desired bus number (hex string, e.g. "0x03") + // Required: false + BusNumber string `url:"bus_number,omitempty" json:"bus_number,omitempty"` } // DiskAttach attach disk to compute diff --git a/pkg/cloudbroker/compute/disk_del.go b/pkg/cloudbroker/compute/disk_del.go index 2f496fa..905f6ee 100644 --- a/pkg/cloudbroker/compute/disk_del.go +++ b/pkg/cloudbroker/compute/disk_del.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // DiskDelRequest struct to detach and delete disk from compute diff --git a/pkg/cloudbroker/compute/disk_detach.go b/pkg/cloudbroker/compute/disk_detach.go index 3925051..3ff1427 100644 --- a/pkg/cloudbroker/compute/disk_detach.go +++ b/pkg/cloudbroker/compute/disk_detach.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // DiskDetachRequest struct to detach disk from compute diff --git a/pkg/cloudbroker/compute/disk_migrate.go b/pkg/cloudbroker/compute/disk_migrate.go index 6a8aa7e..0126e42 100644 --- a/pkg/cloudbroker/compute/disk_migrate.go +++ b/pkg/cloudbroker/compute/disk_migrate.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // DiskMigrateRequest struct to migrate compute's disk to target disk diff --git a/pkg/cloudbroker/compute/disk_qos.go b/pkg/cloudbroker/compute/disk_qos.go index 4c84c77..feddaab 100644 --- a/pkg/cloudbroker/compute/disk_qos.go +++ b/pkg/cloudbroker/compute/disk_qos.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // DiskQOSRequest struct to change QOS of the disk diff --git a/pkg/cloudbroker/compute/disk_resize.go b/pkg/cloudbroker/compute/disk_resize.go index 2c97690..50a46d3 100644 --- a/pkg/cloudbroker/compute/disk_resize.go +++ b/pkg/cloudbroker/compute/disk_resize.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // DiskResizeRequest struct to change disk size diff --git a/pkg/cloudbroker/compute/disk_switch_to_replication.go b/pkg/cloudbroker/compute/disk_switch_to_replication.go index 3087e2b..d173027 100644 --- a/pkg/cloudbroker/compute/disk_switch_to_replication.go +++ b/pkg/cloudbroker/compute/disk_switch_to_replication.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // DiskSwitchToReplicationRequest struct to switch disk to it's replication diff --git a/pkg/cloudbroker/compute/enable.go b/pkg/cloudbroker/compute/enable.go index 40d2b11..9d63388 100644 --- a/pkg/cloudbroker/compute/enable.go +++ b/pkg/cloudbroker/compute/enable.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // EnableRequest struct to enable compute diff --git a/pkg/cloudbroker/compute/filter.go b/pkg/cloudbroker/compute/filter.go index 85e88fb..f769ca9 100644 --- a/pkg/cloudbroker/compute/filter.go +++ b/pkg/cloudbroker/compute/filter.go @@ -3,9 +3,9 @@ package compute import ( "context" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/interfaces" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/pkg/cloudbroker/k8s" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/pkg/cloudbroker/lb" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/interfaces" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/pkg/cloudbroker/k8s" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/pkg/cloudbroker/lb" ) // FilterByID returns ListComputes with specified ID. diff --git a/pkg/cloudbroker/compute/filter_test.go b/pkg/cloudbroker/compute/filter_test.go index cca037f..10a9a4f 100644 --- a/pkg/cloudbroker/compute/filter_test.go +++ b/pkg/cloudbroker/compute/filter_test.go @@ -58,7 +58,6 @@ var computes = ListComputes{ GID: 212, GUID: 48500, ID: 48500, - ImageID: 9884, Interfaces: ListInterfaces{}, LockStatus: "UNLOCKED", ManagerID: 0, @@ -85,7 +84,6 @@ var computes = ListComputes{ UserManaged: true, VGPUs: []uint64{}, VINSConnected: 0, - VirtualImageID: 0, }, }, { @@ -122,7 +120,6 @@ var computes = ListComputes{ GID: 212, GUID: 48556, ID: 48556, - ImageID: 9884, Interfaces: ListInterfaces{}, LockStatus: "UNLOCKED", ManagerID: 0, @@ -149,7 +146,6 @@ var computes = ListComputes{ UserManaged: true, VGPUs: []uint64{}, VINSConnected: 0, - VirtualImageID: 0, }, }, }, @@ -301,7 +297,6 @@ var deleteComputes = ListDeletedComputes{ GID: 212, GUID: 48500, ID: 48500, - ImageID: 9884, Interfaces: ListInterfaces{}, LockStatus: "UNLOCKED", ManagerID: 0, @@ -327,7 +322,6 @@ var deleteComputes = ListDeletedComputes{ UserManaged: true, VGPUs: []uint64{}, VINSConnected: 0, - VirtualImageID: 0, }, }, { @@ -364,7 +358,6 @@ var deleteComputes = ListDeletedComputes{ GID: 212, GUID: 48556, ID: 48556, - ImageID: 9884, Interfaces: ListInterfaces{}, LockStatus: "UNLOCKED", ManagerID: 0, @@ -390,7 +383,6 @@ var deleteComputes = ListDeletedComputes{ UserManaged: true, VGPUs: []uint64{}, VINSConnected: 0, - VirtualImageID: 0, }, }, }, diff --git a/pkg/cloudbroker/compute/get.go b/pkg/cloudbroker/compute/get.go index 321a24d..3ebb31a 100644 --- a/pkg/cloudbroker/compute/get.go +++ b/pkg/cloudbroker/compute/get.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // GetRequest to get information about compute diff --git a/pkg/cloudbroker/compute/get_audits.go b/pkg/cloudbroker/compute/get_audits.go index 6fb7074..07ea7cf 100644 --- a/pkg/cloudbroker/compute/get_audits.go +++ b/pkg/cloudbroker/compute/get_audits.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // GetAuditsRequest struct to get compute audits diff --git a/pkg/cloudbroker/compute/get_console_url.go b/pkg/cloudbroker/compute/get_console_url.go index 29d11a5..dfa3a28 100644 --- a/pkg/cloudbroker/compute/get_console_url.go +++ b/pkg/cloudbroker/compute/get_console_url.go @@ -5,7 +5,7 @@ import ( "net/http" "strings" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // GetConsoleURLRequest struct to get console URL diff --git a/pkg/cloudbroker/compute/get_custom_fields.go b/pkg/cloudbroker/compute/get_custom_fields.go index de0c2b4..76e7523 100644 --- a/pkg/cloudbroker/compute/get_custom_fields.go +++ b/pkg/cloudbroker/compute/get_custom_fields.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // GetCustomFieldsRequest struct to get Compute's customFields diff --git a/pkg/cloudbroker/compute/get_log.go b/pkg/cloudbroker/compute/get_log.go index 5ac874e..8ca8d07 100644 --- a/pkg/cloudbroker/compute/get_log.go +++ b/pkg/cloudbroker/compute/get_log.go @@ -4,7 +4,7 @@ import ( "context" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // GetLogRequest struct to get compute logs @@ -27,7 +27,7 @@ func (c Compute) GetLog(ctx context.Context, req GetLogRequest) (string, error) url := "/cloudbroker/compute/getLog" - res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req) + res, err := c.client.DecortApiCall(ctx, http.MethodGet, url, req) if err != nil { return "", err } diff --git a/pkg/cloudbroker/compute/guest_agent_disable.go b/pkg/cloudbroker/compute/guest_agent_disable.go new file mode 100644 index 0000000..1b8876b --- /dev/null +++ b/pkg/cloudbroker/compute/guest_agent_disable.go @@ -0,0 +1,38 @@ +package compute + +import ( + "context" + "net/http" + "strconv" + + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" +) + +// GuestAgentDisableRequest struct to disable guest agent +type GuestAgentDisableRequest struct { + // ID of compute instance + // Required: true + ComputeID uint64 `url:"compute_id" json:"compute_id" validate:"required"` +} + +// Disable guest agent at a specific compute +func (c Compute) GuestAgentDisable(ctx context.Context, req GuestAgentDisableRequest) (bool, error) { + err := validators.ValidateRequest(req) + if err != nil { + return false, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/compute/guest_agent_disable" + + res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req) + if err != nil { + return false, err + } + + result, err := strconv.ParseBool(string(res)) + if err != nil { + return false, err + } + + return result, nil +} diff --git a/pkg/cloudbroker/compute/guest_agent_enable.go b/pkg/cloudbroker/compute/guest_agent_enable.go new file mode 100644 index 0000000..93436eb --- /dev/null +++ b/pkg/cloudbroker/compute/guest_agent_enable.go @@ -0,0 +1,38 @@ +package compute + +import ( + "context" + "net/http" + "strconv" + + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" +) + +// GuestAgentEnableRequest struct to enable guest agent +type GuestAgentEnableRequest struct { + // ID of compute instance + // Required: true + ComputeID uint64 `url:"compute_id" json:"compute_id" validate:"required"` +} + +// Enable guest agent at a specific compute +func (c Compute) GuestAgentEnable(ctx context.Context, req GuestAgentEnableRequest) (bool, error) { + err := validators.ValidateRequest(req) + if err != nil { + return false, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/compute/guest_agent_enable" + + res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req) + if err != nil { + return false, err + } + + result, err := strconv.ParseBool(string(res)) + if err != nil { + return false, err + } + + return result, nil +} diff --git a/pkg/cloudbroker/compute/guest_agent_execute.go b/pkg/cloudbroker/compute/guest_agent_execute.go new file mode 100644 index 0000000..e671cbb --- /dev/null +++ b/pkg/cloudbroker/compute/guest_agent_execute.go @@ -0,0 +1,48 @@ +package compute + +import ( + "context" + "encoding/json" + "net/http" + + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" +) + +// GuestAgentExecuteRequest struct to execute command from user to agent +type GuestAgentExecuteRequest struct { + // ID of compute instance + // Required: true + ComputeID uint64 `url:"compute_id" json:"compute_id" validate:"required"` + + // Custom command from user to agent + // Required: true + Command string `url:"command" json:"command" validate:"required"` + + // Arguments to command + // Required: true + Arguments string `url:"arguments" json:"arguments" validate:"required"` +} + +// Execute guest agent command +func (c Compute) GuestAgentExecuteRequest(ctx context.Context, req GuestAgentExecuteRequest) (map[string]interface{}, error) { + err := validators.ValidateRequest(req) + if err != nil { + return nil, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/compute/guest_agent_execute" + + res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req) + if err != nil { + return nil, err + } + + var result map[string]interface{} + + err = json.Unmarshal(res, &result) + if err != nil { + return nil, err + } + + return result, nil +} diff --git a/pkg/cloudbroker/compute/guest_agent_feature_get.go b/pkg/cloudbroker/compute/guest_agent_feature_get.go new file mode 100644 index 0000000..14ede57 --- /dev/null +++ b/pkg/cloudbroker/compute/guest_agent_feature_get.go @@ -0,0 +1,40 @@ +package compute + +import ( + "context" + "encoding/json" + "net/http" + + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" +) + +// GuestAgentFeatureGetRequest struct to feature get guest agent +type GuestAgentFeatureGetRequest struct { + // ID of compute instance + // Required: true + ComputeID uint64 `url:"compute_id" json:"compute_id" validate:"required"` +} + +// List of features +func (c Compute) GuestAgentFeatureGet(ctx context.Context, req GuestAgentFeatureGetRequest) ([]string, error) { + err := validators.ValidateRequest(req) + if err != nil { + return nil, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/compute/guest_agent_feature_get" + + res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req) + if err != nil { + return nil, err + } + + features := make([]string, 0) + + err = json.Unmarshal(res, &features) + if err != nil { + return nil, err + } + + return features, nil +} diff --git a/pkg/cloudbroker/compute/guest_agent_feature_update.go b/pkg/cloudbroker/compute/guest_agent_feature_update.go new file mode 100644 index 0000000..105e071 --- /dev/null +++ b/pkg/cloudbroker/compute/guest_agent_feature_update.go @@ -0,0 +1,38 @@ +package compute + +import ( + "context" + "net/http" + "strconv" + + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" +) + +// GuestAgentFeatureUpdateRequest struct to feature update guest agent +type GuestAgentFeatureUpdateRequest struct { + // ID of compute instance + // Required: true + ComputeID uint64 `url:"compute_id" json:"compute_id" validate:"required"` +} + +// Feature update guest agent +func (c Compute) GuestAgentFeatureUpdate(ctx context.Context, req GuestAgentFeatureUpdateRequest) (bool, error) { + err := validators.ValidateRequest(req) + if err != nil { + return false, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/compute/guest_agent_feature_update" + + res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req) + if err != nil { + return false, err + } + + result, err := strconv.ParseBool(string(res)) + if err != nil { + return false, err + } + + return result, nil +} diff --git a/pkg/cloudbroker/compute/list.go b/pkg/cloudbroker/compute/list.go index 074f99f..b88fa82 100644 --- a/pkg/cloudbroker/compute/list.go +++ b/pkg/cloudbroker/compute/list.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ListRequest struct to get list of available computes @@ -46,10 +46,6 @@ type ListRequest struct { // Required: false StackID uint64 `url:"stackId,omitempty" json:"stackId,omitempty"` - // Find by image ID - // Required: false - ImageID uint64 `url:"imageId,omitempty" json:"imageId,omitempty"` - // Find by CD image ID // Required: false CDImageID uint64 `url:"cdImageId,omitempty" json:"cdImageId,omitempty"` @@ -74,6 +70,11 @@ type ListRequest struct { // Required: false SortBy string `url:"sortBy,omitempty" json:"sortBy,omitempty" validate:"omitempty,sortBy"` + // Sort by zone id + // Default value: 0 + // Required: false + ZoneID uint64 `url:"zone_id,omitempty" json:"zone_id,omitempty"` + // Page number // Required: false Page uint64 `url:"page,omitempty" json:"page,omitempty"` diff --git a/pkg/cloudbroker/compute/list_deleted.go b/pkg/cloudbroker/compute/list_deleted.go index 240f373..f04c9b9 100644 --- a/pkg/cloudbroker/compute/list_deleted.go +++ b/pkg/cloudbroker/compute/list_deleted.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ListDeletedRequest struct to get deleted computes list diff --git a/pkg/cloudbroker/compute/list_pci_device.go b/pkg/cloudbroker/compute/list_pci_device.go index b27c63d..e5502b3 100644 --- a/pkg/cloudbroker/compute/list_pci_device.go +++ b/pkg/cloudbroker/compute/list_pci_device.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ListPCIDeviceRequest struct to get list of PCI devices diff --git a/pkg/cloudbroker/compute/list_vgpu.go b/pkg/cloudbroker/compute/list_vgpu.go index 9c760b8..8ef6b98 100644 --- a/pkg/cloudbroker/compute/list_vgpu.go +++ b/pkg/cloudbroker/compute/list_vgpu.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ListVGPURequest struct to get list of GPU for compute diff --git a/pkg/cloudbroker/compute/mass_delete.go b/pkg/cloudbroker/compute/mass_delete.go index 68f1db3..814e439 100644 --- a/pkg/cloudbroker/compute/mass_delete.go +++ b/pkg/cloudbroker/compute/mass_delete.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // MassDeleteRequest struct to delete several computes diff --git a/pkg/cloudbroker/compute/mass_reboot.go b/pkg/cloudbroker/compute/mass_reboot.go index 7405397..d2aeebb 100644 --- a/pkg/cloudbroker/compute/mass_reboot.go +++ b/pkg/cloudbroker/compute/mass_reboot.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // MassRebootRequest struct to reboot several computes diff --git a/pkg/cloudbroker/compute/mass_start.go b/pkg/cloudbroker/compute/mass_start.go index 173242b..bd2673b 100644 --- a/pkg/cloudbroker/compute/mass_start.go +++ b/pkg/cloudbroker/compute/mass_start.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // MassStartRequest struct to start several computes diff --git a/pkg/cloudbroker/compute/mass_stop.go b/pkg/cloudbroker/compute/mass_stop.go index b76bf24..2ac3b79 100644 --- a/pkg/cloudbroker/compute/mass_stop.go +++ b/pkg/cloudbroker/compute/mass_stop.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // MassStopRequest struct to stop several computes diff --git a/pkg/cloudbroker/compute/migrate.go b/pkg/cloudbroker/compute/migrate.go index 48d46a1..30e57fc 100644 --- a/pkg/cloudbroker/compute/migrate.go +++ b/pkg/cloudbroker/compute/migrate.go @@ -2,10 +2,11 @@ package compute import ( "context" + "encoding/json" "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // MigrateRequest struct to migrate compute @@ -24,6 +25,11 @@ type MigrateRequest struct { Force bool `url:"force,omitempty" json:"force,omitempty"` } +type AsyncWrapperMigrateRequest struct { + MigrateRequest + SyncMode bool `url:"sync"` +} + // Migrate migrates compute to another stack func (c Compute) Migrate(ctx context.Context, req MigrateRequest) (bool, error) { err := validators.ValidateRequest(req) @@ -33,7 +39,9 @@ func (c Compute) Migrate(ctx context.Context, req MigrateRequest) (bool, error) url := "/cloudbroker/compute/migrate" - res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req) + syncReq := AsyncWrapperMigrateRequest{MigrateRequest: req, SyncMode: true} + + res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, syncReq) if err != nil { return false, err } @@ -45,3 +53,29 @@ func (c Compute) Migrate(ctx context.Context, req MigrateRequest) (bool, error) return result, nil } + +// AsyncMigrate migrates compute to another stack in async mode +func (c Compute) AsyncMigrate(ctx context.Context, req MigrateRequest) (string, error) { + err := validators.ValidateRequest(req) + if err != nil { + return "", validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/compute/migrate" + + asyncReq := AsyncWrapperMigrateRequest{MigrateRequest: req, SyncMode: false} + + res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, asyncReq) + if err != nil { + return " ", err + } + + var taskID string + + err = json.Unmarshal(res, &taskID) + if err != nil { + return "", err + } + + return taskID, nil +} diff --git a/pkg/cloudbroker/compute/migrate_abort.go b/pkg/cloudbroker/compute/migrate_abort.go new file mode 100644 index 0000000..3551c94 --- /dev/null +++ b/pkg/cloudbroker/compute/migrate_abort.go @@ -0,0 +1,35 @@ +package compute + +import ( + "context" + "net/http" + "strings" + + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" +) + +// MigrateAbortRequest struct to abort migration +type MigrateAbortRequest struct { + // ID of the compute instance + // Required: true + ComputeID uint64 `url:"compute_id" json:"compute_id" validate:"required"` +} + +// MigrateAbort aborts compute migration +func (c Compute) MigrateAbort(ctx context.Context, req MigrateAbortRequest) (string, error) { + err := validators.ValidateRequest(req) + if err != nil { + return "", validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/compute/migrate_abort" + + res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req) + if err != nil { + return "", err + } + + result := strings.ReplaceAll(string(res), "\"", "") + + return result, nil +} diff --git a/pkg/cloudbroker/compute/migrate_storage.go b/pkg/cloudbroker/compute/migrate_storage.go index cc23c97..aafe02d 100644 --- a/pkg/cloudbroker/compute/migrate_storage.go +++ b/pkg/cloudbroker/compute/migrate_storage.go @@ -5,7 +5,7 @@ import ( "net/http" "strings" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // MigrateStorageRequest struct for migration diff --git a/pkg/cloudbroker/compute/migrate_storage_abort.go b/pkg/cloudbroker/compute/migrate_storage_abort.go index 4dc2ad5..bdf5873 100644 --- a/pkg/cloudbroker/compute/migrate_storage_abort.go +++ b/pkg/cloudbroker/compute/migrate_storage_abort.go @@ -5,7 +5,7 @@ import ( "net/http" "strings" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // MigrateStorageAbortRequest struct to abort migration diff --git a/pkg/cloudbroker/compute/migrate_storage_clean_up.go b/pkg/cloudbroker/compute/migrate_storage_clean_up.go index 22cde3f..71d9926 100644 --- a/pkg/cloudbroker/compute/migrate_storage_clean_up.go +++ b/pkg/cloudbroker/compute/migrate_storage_clean_up.go @@ -5,7 +5,7 @@ import ( "net/http" "strings" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // MigrateStorageCleanUpRequest struct to cleanup resources after finished migration diff --git a/pkg/cloudbroker/compute/migrate_storage_info.go b/pkg/cloudbroker/compute/migrate_storage_info.go index db3239a..6abdf21 100644 --- a/pkg/cloudbroker/compute/migrate_storage_info.go +++ b/pkg/cloudbroker/compute/migrate_storage_info.go @@ -5,7 +5,7 @@ import ( "net/http" "strings" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // MigrateStorageInfoRequest struct to get info about migration diff --git a/pkg/cloudbroker/compute/migrate_storage_list.go b/pkg/cloudbroker/compute/migrate_storage_list.go new file mode 100644 index 0000000..6f2af9e --- /dev/null +++ b/pkg/cloudbroker/compute/migrate_storage_list.go @@ -0,0 +1,55 @@ +package compute + +import ( + "context" + "encoding/json" + "net/http" + + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" +) + +// MigrateStorageListRequest struct to get list of jobs +type MigrateStorageListRequest struct { + // Find by job ID + // Required: false + MigrationJobID uint64 `url:"migration_job_id,omitempty" json:"migration_job_id,omitempty"` + + // If True then return completed jobs + // Required: false + Completed interface{} `url:"completed,omitempty" json:"completed,omitempty" validate:"omitempty,isBool"` + + // Sort by one of supported fields, format +|-(field) + // Required: false + SortBy string `url:"sort_by,omitempty" json:"sort_by,omitempty" validate:"omitempty,sortBy"` + + // Page number + // Required: false + Page uint64 `url:"page,omitempty" json:"page,omitempty"` + + // Page size + // Required: false + Size uint64 `url:"size,omitempty" json:"size,omitempty"` +} + +// MigrateStorageList gets list of the jobs. +func (c Compute) MigrateStorageList(ctx context.Context, req MigrateStorageListRequest) (*ListMigrateStorage, error) { + if err := validators.ValidateRequest(req); err != nil { + return nil, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/compute/migrate_storage_list" + + res, err := c.client.DecortApiCall(ctx, http.MethodGet, url, req) + if err != nil { + return nil, err + } + + list := ListMigrateStorage{} + + err = json.Unmarshal(res, &list) + if err != nil { + return nil, err + } + + return &list, nil +} diff --git a/pkg/cloudbroker/compute/migrate_to_zone.go b/pkg/cloudbroker/compute/migrate_to_zone.go new file mode 100644 index 0000000..f6d663d --- /dev/null +++ b/pkg/cloudbroker/compute/migrate_to_zone.go @@ -0,0 +1,42 @@ +package compute + +import ( + "context" + "net/http" + "strconv" + + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" +) + +// MigrateToZone struct to move compute to another zone +type MigrateToZoneRequest struct { + // ID of the compute instance to move + // Required: true + ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"` + + // ID of the zone to move + // Required: true + ZoneID uint64 `url:"zoneId" json:"zoneId" validate:"required"` +} + +// MoveToZone moves compute to new zone +func (c Compute) MigrateToZone(ctx context.Context, req MigrateToZoneRequest) (bool, error) { + err := validators.ValidateRequest(req) + if err != nil { + return false, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/compute/migrateToZone" + + res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req) + if err != nil { + return false, err + } + + result, err := strconv.ParseBool(string(res)) + if err != nil { + return false, err + } + + return result, nil +} diff --git a/pkg/cloudbroker/compute/models.go b/pkg/cloudbroker/compute/models.go index 24572fa..6fdf3b4 100644 --- a/pkg/cloudbroker/compute/models.go +++ b/pkg/cloudbroker/compute/models.go @@ -44,7 +44,7 @@ type ItemACL struct { // ACL compute information type ItemComputeACL struct { // Explicit - Explicit string `json:"explicit"` + Explicit bool `json:"explicit"` // GUID GUID string `json:"guid"` @@ -221,8 +221,14 @@ type ItemDetailedAudit struct { User string `json:"user"` } -// List of detailed audit -type ListDetailedAudits []ItemDetailedAudit +// List Detailed audits +type ListDetailedAudits struct { + // Data + Data []ItemDetailedAudit `json:"data"` + + // Entry count + EntryCount uint64 `json:"entryCount"` +} // Main information about port forward type ItemPFW struct { @@ -367,9 +373,18 @@ type ItemDisk struct { // Bus number BusNumber uint64 `json:"bus_number"` + // Created by + CreatedBy string `json:"createdBy"` + // Created time CreatedTime uint64 `json:"createdTime"` + // Device name + DeviceName string `json:"devicename"` + + // Deleted by + DeletedBy string `json:"deletedBy"` + // Deleted time DeletedTime uint64 `json:"deletedTime"` @@ -412,9 +427,6 @@ type ItemDisk struct { // Name Name string `json:"name"` - // Order - Order uint64 `json:"order"` - // Params Params string `json:"params"` @@ -478,17 +490,23 @@ type ItemDisk struct { // Status Status string `json:"status"` + // Storage policy id of disk. + StoragePolicyID uint64 `json:"storage_policy_id"` + // Tech status TechStatus string `json:"techStatus"` + // Need to clean before destroy + ToClean bool `json:"to_clean"` + // Type Type string `json:"type"` // Updated by UpdatedBy string `json:"updatedBy"` - // Virtual machine ID - VMID uint64 `json:"vmid"` + // UpdatedTime + UpdatedTime uint64 `json:"updatedTime"` } type ItemReplication struct { @@ -531,6 +549,9 @@ type ItemInterface struct { // Enabled Enabled bool `json:"enabled"` + // Enable security groups + EnableSecGroups bool `json:"enable_secgroups"` + // FLIPGroup ID FLIPGroupID uint64 `json:"flipgroupId"` @@ -573,9 +594,18 @@ type ItemInterface struct { // QOS QOS QOS `json:"qos"` + // List of security groups + SecGroups []uint64 `json:"security_groups"` + + // SDN interface ID + SDNInterfaceID string `json:"sdn_interface_id"` + // Target Target string `json:"target"` + // Trunk tags + TrunkTags string `json:"trunk_tags"` + // Type Type string `json:"type"` @@ -633,6 +663,9 @@ type InfoCompute struct { // Architecture Arch string `json:"arch"` + // Boot image ID + BootImageID uint64 `json:"boot_image_id"` + // Boot order BootOrder []string `json:"bootOrder"` @@ -702,12 +735,12 @@ type InfoCompute struct { // ID ID uint64 `json:"id"` - // Image ID - ImageID uint64 `json:"imageId"` - // List interfaces Interfaces ListInterfaces `json:"interfaces"` + // Live migration job ID + LiveMigrationJobID uint64 `json:"live_migration_job_id"` + // Loader type LoaderType string `json:"loaderType"` @@ -744,12 +777,18 @@ type InfoCompute struct { // List OS users OSUsers ListOSUsers `json:"osUsers"` + // Name of OS + OSVersion string `json:"os_version"` + // Pinned to stack PinnedToStack int64 `json:"pinnedToStack"` // PreferredCPU PreferredCPU []int64 `json:"preferredCpu"` + // Qemu_quest + QemuQuest QemuQuest `json:"qemu_guest"` + // Number of RAM RAM uint64 `json:"ram"` @@ -816,8 +855,16 @@ type InfoCompute struct { // VINS connected VINSConnected uint64 `json:"vinsConnected"` - // Virtual image ID - VirtualImageID uint64 `json:"virtualImageId"` + // Zone ID + ZoneID uint64 `json:"zoneId"` +} + +type QemuQuest struct { + Enabled bool `json:"enabled"` + EnabledAgentFeatures []string `json:"enabled_agent_features"` + GUID string `json:"guid"` + LastUpdate uint64 `json:"last_update"` + User string `json:"user"` } // Information about libvirt settings @@ -873,6 +920,9 @@ type RecordCompute struct { // Architecture Arch string `json:"arch"` + // Boot image ID + BootImageID uint64 `json:"boot_image_id"` + // Boot order BootOrder []string `json:"bootOrder"` @@ -948,12 +998,18 @@ type RecordCompute struct { // Image ID ImageID uint64 `json:"imageId"` - // ImageName + // 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"` @@ -1008,12 +1064,18 @@ type RecordCompute struct { // List OS users OSUsers ListOSUsers `json:"osUsers"` + // Name of OS + OSVersion string `json:"os_version"` + // Pinned to stack PinnedToStack int64 `json:"pinnedToStack"` // PreferredCPU PreferredCPU []int64 `json:"preferredCpu"` + // Qemu_quest + QemuQuest QemuQuest `json:"qemu_guest"` + // Number of RAM RAM uint64 `json:"ram"` @@ -1077,14 +1139,19 @@ type RecordCompute struct { // List VGPU VGPUs []VGPUItem `json:"vgpus"` - // Virtual image ID - VirtualImageID uint64 `json:"virtualImageId"` - - // VirtualImageName - VirtualImageName string `json:"virtualImageName"` - // VNC password VNCPassword string `json:"vncPasswd"` + + // Zone ID + ZoneID uint64 `json:"zoneId"` +} + +type LoaderMetaIso struct { + // Name + DeviceName string `json:"devicename"` + + // Path + Path string `json:"path"` } type VGPUItem struct { @@ -1331,3 +1398,59 @@ type ItemVGPU struct { // VM ID VMID uint64 `json:"vmid"` } + +type ListMigrateStorage struct { + EntryCount uint64 `json:"entryCount"` + Data []MigrateStorageItem `json:"data"` +} + +type MigrateStorageItem struct { + // Migration completion status + Completed bool `json:"completed"` + + // Domain name + DomainName string `json:"domainName"` + + // Migration job ID + ID uint64 `json:"id"` + + // Migration process log + Log []string `json:"log"` + + // Source stack ID + SourceStackID uint64 `json:"sourceStackId"` + + // Migration status + Status string `json:"status"` + + // Target stack ID + TargetStackID uint64 `json:"targetStackId"` +} + +type RecordCloneStatus struct { + // Disk ID + DiskID int `json:"disk_id"` + + // Clone Status + Status CloneStatus `json:"status"` +} + +type CloneStatus struct { + // Type + Type int `json:"type"` + + // Copy speed + Bandwidth int `json:"bandwidth"` + + // Current progress + Cur int `json:"cur"` + + // Total size + End int `json:"end"` + + // Operation status + Ready bool `json:"ready"` + + // Progress percent + ProgressPercent int `json:"progress_percent"` +} diff --git a/pkg/cloudbroker/compute/move_to_rg.go b/pkg/cloudbroker/compute/move_to_rg.go index 1747af0..561df83 100644 --- a/pkg/cloudbroker/compute/move_to_rg.go +++ b/pkg/cloudbroker/compute/move_to_rg.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // MoveToRGRequest struct to move compute to new resource group diff --git a/pkg/cloudbroker/compute/net_attach.go b/pkg/cloudbroker/compute/net_attach.go index 0747a94..8333edc 100644 --- a/pkg/cloudbroker/compute/net_attach.go +++ b/pkg/cloudbroker/compute/net_attach.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // NetAttachRequest struct to attach network @@ -19,6 +19,9 @@ type NetAttachRequest struct { // 'VINS' for connect to ViNS // 'VFNIC' for connect to vfpool // 'DPDK' for connect to DPDK + // `EMPTY` for connect empty network + // `SDT` for connect to SDN + // `TRUNK` for connect to TRUNK // Required: true NetType string `url:"netType" json:"netType" validate:"computex86NetType"` @@ -36,9 +39,27 @@ type NetAttachRequest struct { // Required: false MACAddr string `url:"mac_addr,omitempty" json:"mac_addr,omitempty"` - // Used only for DPDK type, must be 1-9216 + // Used only for EXTNET and DPDK + // For DPDK must be 1-9216 + // For EXTNET must be 1500-9216 // Required: false MTU uint64 `url:"mtu,omitempty" json:"mtu,omitempty" validate:"omitempty,mtu"` + + // Unique identifier of logical port on SDN side + // Required: false + SDNInterfaceID string `url:"sdn_interface_id,omitempty" json:"sdn_interface_id,omitempty" validate:"omitempty"` + + // List of security group IDs to assign to this interface + // Required: false + SecGroups []uint64 `url:"security_groups,omitempty" json:"security_groups,omitempty"` + + // Flag indicating whether security groups are enabled for this interface + // Required: false + EnableSecGroups bool `url:"enable_secgroups,omitempty" json:"enable_secgroups,omitempty"` + + // Flag indicating whether this interface is enabled (only for VINS, EXTNET, DPDK, SDN, TRUNK) + // Required: false + Enabled interface{} `url:"enabled,omitempty" json:"enabled,omitempty" validate:"omitempty,isBool"` } // NetAttach attaches network to compute and gets info about network diff --git a/pkg/cloudbroker/compute/net_detach.go b/pkg/cloudbroker/compute/net_detach.go index bbc0956..190773b 100644 --- a/pkg/cloudbroker/compute/net_detach.go +++ b/pkg/cloudbroker/compute/net_detach.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // NetDetachRequest struct to detach network from compute diff --git a/pkg/cloudbroker/compute/net_qos.go b/pkg/cloudbroker/compute/net_qos.go index dca6a4a..ff9db02 100644 --- a/pkg/cloudbroker/compute/net_qos.go +++ b/pkg/cloudbroker/compute/net_qos.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // NetQOSRequest struct for update QOS diff --git a/pkg/cloudbroker/compute/pause.go b/pkg/cloudbroker/compute/pause.go index ef0b55d..e8c7ec0 100644 --- a/pkg/cloudbroker/compute/pause.go +++ b/pkg/cloudbroker/compute/pause.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // PauseRequest struct to pause compute diff --git a/pkg/cloudbroker/compute/pfw_add.go b/pkg/cloudbroker/compute/pfw_add.go index 43d8b20..8d39013 100644 --- a/pkg/cloudbroker/compute/pfw_add.go +++ b/pkg/cloudbroker/compute/pfw_add.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // PFWAddRequest struct to add port forward rule diff --git a/pkg/cloudbroker/compute/pfw_del.go b/pkg/cloudbroker/compute/pfw_del.go index f619316..6b43715 100644 --- a/pkg/cloudbroker/compute/pfw_del.go +++ b/pkg/cloudbroker/compute/pfw_del.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // PFWDelRequest struct to delete port forward rule diff --git a/pkg/cloudbroker/compute/pfw_list.go b/pkg/cloudbroker/compute/pfw_list.go index 0cd9631..9b2a2c0 100644 --- a/pkg/cloudbroker/compute/pfw_list.go +++ b/pkg/cloudbroker/compute/pfw_list.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // PFWListRequest struct to get list of port forwards diff --git a/pkg/cloudbroker/compute/pin_to_stack.go b/pkg/cloudbroker/compute/pin_to_stack.go index f34c589..014a10a 100644 --- a/pkg/cloudbroker/compute/pin_to_stack.go +++ b/pkg/cloudbroker/compute/pin_to_stack.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // PinToStackRequest struct to pin compute to stack diff --git a/pkg/cloudbroker/compute/power_cycle.go b/pkg/cloudbroker/compute/power_cycle.go index ada8474..4c4d60e 100644 --- a/pkg/cloudbroker/compute/power_cycle.go +++ b/pkg/cloudbroker/compute/power_cycle.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // PowerCycleRequest struct to force stop and start compute diff --git a/pkg/cloudbroker/compute/reboot.go b/pkg/cloudbroker/compute/reboot.go index 474565c..100b5ee 100644 --- a/pkg/cloudbroker/compute/reboot.go +++ b/pkg/cloudbroker/compute/reboot.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // RebootRequest struct to reboot compute diff --git a/pkg/cloudbroker/compute/redeploy.go b/pkg/cloudbroker/compute/redeploy.go index ec262a8..fd1667e 100644 --- a/pkg/cloudbroker/compute/redeploy.go +++ b/pkg/cloudbroker/compute/redeploy.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // RedeployRequest struct for redeploy @@ -18,6 +18,14 @@ type RedeployRequest struct { // Required: false ImageID uint64 `url:"imageId,omitempty" json:"imageId,omitempty"` + // The OS version that will be installed on the virtual machine + // Required: false + OSVersion string `url:"os_version,omitempty" json:"os_version,omitempty"` + + // Storage policy id of compute. The rules of the specified storage policy will be used. + // Required: true + StoragePolicyID uint64 `url:"storage_policy_id" json:"storage_policy_id" validate:"required"` + // New size for the boot disk in GB, if boot disk size change is required // Required: false DiskSize uint64 `url:"diskSize,omitempty" json:"diskSize,omitempty"` diff --git a/pkg/cloudbroker/compute/reset.go b/pkg/cloudbroker/compute/reset.go index e42ac45..330cd54 100644 --- a/pkg/cloudbroker/compute/reset.go +++ b/pkg/cloudbroker/compute/reset.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ResetRequest struct to reset compute diff --git a/pkg/cloudbroker/compute/resize.go b/pkg/cloudbroker/compute/resize.go index 6fe4f4f..1e96138 100644 --- a/pkg/cloudbroker/compute/resize.go +++ b/pkg/cloudbroker/compute/resize.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ResizeRequest struct to resize compute diff --git a/pkg/cloudbroker/compute/restore.go b/pkg/cloudbroker/compute/restore.go index 85d4d4f..a947a07 100644 --- a/pkg/cloudbroker/compute/restore.go +++ b/pkg/cloudbroker/compute/restore.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // RestoreRequest struct to restore compute diff --git a/pkg/cloudbroker/compute/resume.go b/pkg/cloudbroker/compute/resume.go index 3516076..27e5bc8 100644 --- a/pkg/cloudbroker/compute/resume.go +++ b/pkg/cloudbroker/compute/resume.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ResumeRequest struct to resume compute diff --git a/pkg/cloudbroker/compute/serialize.go b/pkg/cloudbroker/compute/serialize.go index 6b3cd3b..7a48c7d 100644 --- a/pkg/cloudbroker/compute/serialize.go +++ b/pkg/cloudbroker/compute/serialize.go @@ -3,7 +3,7 @@ package compute import ( "encoding/json" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/serialization" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/serialization" ) // Serialize returns JSON-serialized []byte. Used as a wrapper over json.Marshal and json.MarshalIndent functions. diff --git a/pkg/cloudbroker/compute/set_custom_fields.go b/pkg/cloudbroker/compute/set_custom_fields.go index 26c189d..6ad3776 100644 --- a/pkg/cloudbroker/compute/set_custom_fields.go +++ b/pkg/cloudbroker/compute/set_custom_fields.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // SetCustomFieldsRequest struct for setting customFields values for the Compute diff --git a/pkg/cloudbroker/compute/set_net_config.go b/pkg/cloudbroker/compute/set_net_config.go index dd398ae..a1252f1 100644 --- a/pkg/cloudbroker/compute/set_net_config.go +++ b/pkg/cloudbroker/compute/set_net_config.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // SetNetConfigRequest struct to Configure libvirt virtio interface parameters diff --git a/pkg/cloudbroker/compute/shared_snapshot_merge_status.go b/pkg/cloudbroker/compute/shared_snapshot_merge_status.go new file mode 100644 index 0000000..364c9a1 --- /dev/null +++ b/pkg/cloudbroker/compute/shared_snapshot_merge_status.go @@ -0,0 +1,33 @@ +package compute + +import ( + "context" + "net/http" + + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" +) + +// SharedSnapshotMergeStatusRequest struct to get shared snapshot merge status +type SharedSnapshotMergeStatusRequest struct { + // ID of compute instance to get log for + // Required: true + ComputeID uint64 `url:"compute_id" json:"compute_id" validate:"required"` +} + +// SharedSnapshotMergeStatus shared snapshots merge status +// returns a string representing either the current status or the progress percentage +func (c Compute) SharedSnapshotMergeStatus(ctx context.Context, req SharedSnapshotMergeStatusRequest) (string, error) { + err := validators.ValidateRequest(req) + if err != nil { + return "", validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/compute/shared_snapshot_merge_status" + + res, err := c.client.DecortApiCall(ctx, http.MethodGet, url, req) + if err != nil { + return "", err + } + + return string(res), nil +} diff --git a/pkg/cloudbroker/compute/snapshot_create.go b/pkg/cloudbroker/compute/snapshot_create.go index 69d1afb..675e26b 100644 --- a/pkg/cloudbroker/compute/snapshot_create.go +++ b/pkg/cloudbroker/compute/snapshot_create.go @@ -5,7 +5,7 @@ import ( "net/http" "strings" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // SnapshotCreateRequest struct to create snapshot diff --git a/pkg/cloudbroker/compute/snapshot_delete.go b/pkg/cloudbroker/compute/snapshot_delete.go index d98c9e0..b0df3c4 100644 --- a/pkg/cloudbroker/compute/snapshot_delete.go +++ b/pkg/cloudbroker/compute/snapshot_delete.go @@ -4,7 +4,7 @@ import ( "context" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // SnapshotDeleteRequest struct to delete snapshot diff --git a/pkg/cloudbroker/compute/snapshot_evict_disk.go b/pkg/cloudbroker/compute/snapshot_evict_disk.go index 031a817..3cbdc73 100644 --- a/pkg/cloudbroker/compute/snapshot_evict_disk.go +++ b/pkg/cloudbroker/compute/snapshot_evict_disk.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // SnapshotEvictDiskRequest struct to evict specified disk diff --git a/pkg/cloudbroker/compute/snapshot_list.go b/pkg/cloudbroker/compute/snapshot_list.go index a8d4756..de7fec6 100644 --- a/pkg/cloudbroker/compute/snapshot_list.go +++ b/pkg/cloudbroker/compute/snapshot_list.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // SnapshotListRequest struct to get list of snapshots diff --git a/pkg/cloudbroker/compute/snapshot_rollback.go b/pkg/cloudbroker/compute/snapshot_rollback.go index 81d3749..3675840 100644 --- a/pkg/cloudbroker/compute/snapshot_rollback.go +++ b/pkg/cloudbroker/compute/snapshot_rollback.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // SnapshotRollbackRequest struct for rollback diff --git a/pkg/cloudbroker/compute/snapshot_usage.go b/pkg/cloudbroker/compute/snapshot_usage.go index ab6ec73..ea2767e 100644 --- a/pkg/cloudbroker/compute/snapshot_usage.go +++ b/pkg/cloudbroker/compute/snapshot_usage.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // SnapshotUsageRequest struct tto get compute snapshot real size on storage diff --git a/pkg/cloudbroker/compute/start.go b/pkg/cloudbroker/compute/start.go index 4d2e922..d0f5556 100644 --- a/pkg/cloudbroker/compute/start.go +++ b/pkg/cloudbroker/compute/start.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // StartRequest struct to start compute diff --git a/pkg/cloudbroker/compute/start_migration_in.go b/pkg/cloudbroker/compute/start_migration_in.go new file mode 100644 index 0000000..4faab96 --- /dev/null +++ b/pkg/cloudbroker/compute/start_migration_in.go @@ -0,0 +1,36 @@ +package compute + +import ( + "context" + "net/http" + + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" +) + +// StartMigrationINRequest struct to start compute for external migration in +type StartMigrationINRequest struct { + // ID of compute instance + // Required: true + ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"` + + // ID of the stack where the compute will be staged for migration-in + // Required: false + StackID uint64 `url:"stackId,omitempty" json:"stackId,omitempty"` +} + +// StartMigrationIN starts compute for external migration in +func (c Compute) StartMigrationIN(ctx context.Context, req StartRequest) (string, error) { + err := validators.ValidateRequest(req) + if err != nil { + return "", validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/compute/start_migration_in" + + res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req) + if err != nil { + return "", err + } + + return string(res), nil +} diff --git a/pkg/cloudbroker/compute/start_migration_out.go b/pkg/cloudbroker/compute/start_migration_out.go new file mode 100644 index 0000000..44618f6 --- /dev/null +++ b/pkg/cloudbroker/compute/start_migration_out.go @@ -0,0 +1,58 @@ +package compute + +import ( + "context" + "net/http" + + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/constants" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" +) + +// StartMigrationOutRequest struct to start compute for external migration out +type StartMigrationOutRequest struct { + // ID of compute instance + // Required: true + ComputeID uint64 `url:"compute_id" json:"compute_id" validate:"required"` + + // Remote libvirt host to connect to + // Required: true + Target string `url:"target" json:"target" validate:"required"` + + // Graphics handling on the destination + // Required: true + Graphics string `url:"graphics" json:"graphics" validate:"required"` + + // Optional new domain name on the destination + // Required: false + NewName string `url:"new_name,omitempty" json:"new_name,omitempty"` + + // When true, adds libvirt's UNSAFE flag to force migration even if libvirt marks it unsafe. + // Default: false + // Required: false + UseUnsafe bool `url:"use_unsafe,omitempty" json:"use_unsafe,omitempty"` + + // Mapping of guest disk target names to absolute paths on the destination host. + // Required: false + Diskmap map[string]string `url:"diskmap,omitempty" json:"diskmap,omitempty"` + + // Mapping for CD/DVD devices or their source paths to new ISO/device paths on the destination + // Required: false + CDROMMap map[string]string `url:"cdrommap,omitempty" json:"cdrommap,omitempty"` +} + +// StartMigrationOut starts compute for external migration out +func (c Compute) StartMigrationOut(ctx context.Context, req StartMigrationOutRequest) (string, error) { + err := validators.ValidateRequest(req) + if err != nil { + return "", validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/compute/start_migration_out" + + res, err := c.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req) + if err != nil { + return "", err + } + + return string(res), nil +} diff --git a/pkg/cloudbroker/compute/stop.go b/pkg/cloudbroker/compute/stop.go index 352850f..4db0c2d 100644 --- a/pkg/cloudbroker/compute/stop.go +++ b/pkg/cloudbroker/compute/stop.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // StopRequest struct to stop compute diff --git a/pkg/cloudbroker/compute/stop_migration_in.go b/pkg/cloudbroker/compute/stop_migration_in.go new file mode 100644 index 0000000..022e72d --- /dev/null +++ b/pkg/cloudbroker/compute/stop_migration_in.go @@ -0,0 +1,57 @@ +package compute + +import ( + "context" + "net/http" + + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/constants" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" +) + +// OSUsers struct contains OS user data for Guest OS. +// Must be provided if NewVMUUID is provided. +type OSUser struct { + // Login of a user + Login string `url:"login,omitempty" json:"login,omitempty"` + + // Password of a user + Password string `url:"password,omitempty" json:"password,omitempty"` + + // GUID + GUID string `url:"guid,omitempty" json:"guid,omitempty"` + + // Pubkey + Pubkey string `url:"pubkey,omitempty" json:"pubkey,omitempty"` +} + +// StopMigrationINRequest struct to stop compute for external migration in +type StopMigrationINRequest struct { + // ID of compute instance + // Required: true + ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"` + + // If provided, indicates the UUID of the VM on the target host and that migration completed. + // Required: false + NewVMUUID string `url:"new_vm_uuid,omitempty" json:"new_vm_uuid,omitempty"` + + // OS user data for Guest OS + // Required: false + OSUsers []OSUser `url:"os_users,omitempty" json:"os_users,omitempty"` +} + +// StopMigrationIN stops compute for external migration in +func (c Compute) StopMigrationIN(ctx context.Context, req StopMigrationINRequest) (string, error) { + err := validators.ValidateRequest(req) + if err != nil { + return "", validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/compute/stop_migration_in" + + res, err := c.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req) + if err != nil { + return "", err + } + + return string(res), nil +} diff --git a/pkg/cloudbroker/compute/stop_migration_out.go b/pkg/cloudbroker/compute/stop_migration_out.go new file mode 100644 index 0000000..1d6aa7b --- /dev/null +++ b/pkg/cloudbroker/compute/stop_migration_out.go @@ -0,0 +1,37 @@ +package compute + +import ( + "context" + "net/http" + + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/constants" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" +) + +// StopMigrationOutRequest struct to stop compute for external migration out +type StopMigrationOutRequest struct { + // ID of compute instance + // Required: true + ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"` + + // Identifier of the agent-side external migration (LibvirtMigrateToURI3Request) job + // Required: false + MigrateToURI3JobID string `url:"migrate_to_uri3_job_id,omitempty" json:"migrate_to_uri3_job_id,omitempty"` +} + +// StopMigrationOut stops compute for external migration out +func (c Compute) StopMigrationOut(ctx context.Context, req StopMigrationOutRequest) (string, error) { + err := validators.ValidateRequest(req) + if err != nil { + return "", validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/compute/stop_migration_out" + + res, err := c.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req) + if err != nil { + return "", err + } + + return string(res), nil +} diff --git a/pkg/cloudbroker/compute/tag_add.go b/pkg/cloudbroker/compute/tag_add.go index cb670f5..f5b9cb7 100644 --- a/pkg/cloudbroker/compute/tag_add.go +++ b/pkg/cloudbroker/compute/tag_add.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // TagAddRequest struct to add tag to compute diff --git a/pkg/cloudbroker/compute/tag_remove.go b/pkg/cloudbroker/compute/tag_remove.go index 38c9953..64d011c 100644 --- a/pkg/cloudbroker/compute/tag_remove.go +++ b/pkg/cloudbroker/compute/tag_remove.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // TagRemoveRequest struct to remove tag from compute diff --git a/pkg/cloudbroker/compute/unpin_from_stack.go b/pkg/cloudbroker/compute/unpin_from_stack.go index ef96cd9..ad2f9af 100644 --- a/pkg/cloudbroker/compute/unpin_from_stack.go +++ b/pkg/cloudbroker/compute/unpin_from_stack.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // UnpinFromStackRequest struct to unpin from stack diff --git a/pkg/cloudbroker/compute/update.go b/pkg/cloudbroker/compute/update.go index 635bc04..54401f6 100644 --- a/pkg/cloudbroker/compute/update.go +++ b/pkg/cloudbroker/compute/update.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // UpdateRequest struct to update compute @@ -65,6 +65,10 @@ type UpdateRequest struct { // Does this machine supports hot resize, true or false // Required: false HotResize interface{} `url:"hotResize,omitempty" json:"hotResize,omitempty" validate:"omitempty,isBool"` + + // The OS version that will be installed on the virtual machine + // Required: false + OSVersion string `url:"os_version,omitempty" json:"os_version,omitempty"` } // Update updates some properties of the compute diff --git a/pkg/cloudbroker/compute/user_grant.go b/pkg/cloudbroker/compute/user_grant.go index b908f15..c73a4a1 100644 --- a/pkg/cloudbroker/compute/user_grant.go +++ b/pkg/cloudbroker/compute/user_grant.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // UserGrantRequest struct to grant access to compute diff --git a/pkg/cloudbroker/compute/user_list.go b/pkg/cloudbroker/compute/user_list.go index 49ea874..cce96f7 100644 --- a/pkg/cloudbroker/compute/user_list.go +++ b/pkg/cloudbroker/compute/user_list.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // UserListRequest struct to get list of users for compute diff --git a/pkg/cloudbroker/compute/user_revoke.go b/pkg/cloudbroker/compute/user_revoke.go index b2a593f..014db92 100644 --- a/pkg/cloudbroker/compute/user_revoke.go +++ b/pkg/cloudbroker/compute/user_revoke.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // UserRevokeRequest struct to revoke user access diff --git a/pkg/cloudbroker/compute/user_update.go b/pkg/cloudbroker/compute/user_update.go index 41c5e7d..8dc8cc2 100644 --- a/pkg/cloudbroker/compute/user_update.go +++ b/pkg/cloudbroker/compute/user_update.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // UserUpdateRequest struct to update user access diff --git a/pkg/cloudbroker/disks.go b/pkg/cloudbroker/disks.go index a27e3ab..d00c710 100644 --- a/pkg/cloudbroker/disks.go +++ b/pkg/cloudbroker/disks.go @@ -1,7 +1,7 @@ package cloudbroker import ( - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/pkg/cloudbroker/disks" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/pkg/cloudbroker/disks" ) // Accessing the Disks method group diff --git a/pkg/cloudbroker/disks/change_disk_storage_policy.go b/pkg/cloudbroker/disks/change_disk_storage_policy.go new file mode 100644 index 0000000..59f64ec --- /dev/null +++ b/pkg/cloudbroker/disks/change_disk_storage_policy.go @@ -0,0 +1,42 @@ +package disks + +import ( + "context" + "net/http" + "strconv" + + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" +) + +// ChangeDiskStoragePolicyRequest struct to change storage policy for disk +type ChangeDiskStoragePolicyRequest struct { + // ID of the disk + // Required: true + DiskID uint64 `url:"disk_id" json:"disk_id" validate:"required"` + + // ID of the storage policy to which to connect account + // Required: true + StoragePolicyID uint64 `url:"storage_policy_id" json:"storage_policy_id" validate:"required"` +} + +// ChangeDiskStoragePolicy changes storage policy for disk +func (d Disks) ChangeDiskStoragePolicy(ctx context.Context, req ChangeDiskStoragePolicyRequest) (bool, error) { + err := validators.ValidateRequest(req) + if err != nil { + return false, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/disks/change_disk_storage_policy" + + res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, req) + if err != nil { + return false, err + } + + result, err := strconv.ParseBool(string(res)) + if err != nil { + return false, err + } + + return result, nil +} diff --git a/pkg/cloudbroker/disks/create.go b/pkg/cloudbroker/disks/create.go index 37e74c3..f2b9fce 100644 --- a/pkg/cloudbroker/disks/create.go +++ b/pkg/cloudbroker/disks/create.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // CreateRequest struct to create disk @@ -18,6 +18,10 @@ type CreateRequest struct { // Required: true Name string `url:"name" json:"name" validate:"required"` + // ID of the storage policy under the disk will be created + // Required: true + StoragePolicyID uint64 `url:"storage_policy_id" json:"storage_policy_id" validate:"required"` + // Description of disk // Required: false Description string `url:"description,omitempty" json:"description,omitempty"` @@ -26,10 +30,6 @@ type CreateRequest struct { // Required: false Size uint64 `url:"size,omitempty" json:"size,omitempty"` - // Max IOPS disk can perform defaults to 2000 - // Required: false - IOPS uint64 `url:"iops,omitempty" json:"iops,omitempty"` - // Storage endpoint provider ID to create disk // Required: false SEPID uint64 `url:"sep_id,omitempty" json:"sep_id,omitempty"` diff --git a/pkg/cloudbroker/disks/delete.go b/pkg/cloudbroker/disks/delete.go index 9859c2c..52a7680 100644 --- a/pkg/cloudbroker/disks/delete.go +++ b/pkg/cloudbroker/disks/delete.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // DeleteRequest struct to delete disk diff --git a/pkg/cloudbroker/disks/delete_disks.go b/pkg/cloudbroker/disks/delete_disks.go index 9316995..7b383eb 100644 --- a/pkg/cloudbroker/disks/delete_disks.go +++ b/pkg/cloudbroker/disks/delete_disks.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // DeleteDisksRequest struct for multiple disks diff --git a/pkg/cloudbroker/disks/depresent.go b/pkg/cloudbroker/disks/depresent.go index 9099e2f..f54241f 100644 --- a/pkg/cloudbroker/disks/depresent.go +++ b/pkg/cloudbroker/disks/depresent.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // DepresentRequest struct to depresent disk from node diff --git a/pkg/cloudbroker/disks/disks.go b/pkg/cloudbroker/disks/disks.go index 4612836..48a9d2e 100644 --- a/pkg/cloudbroker/disks/disks.go +++ b/pkg/cloudbroker/disks/disks.go @@ -1,7 +1,7 @@ // API Actor for managing Disk. This actor is a final API for admin to manage Disk package disks -import "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/interfaces" +import "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/interfaces" // Structure for creating request to disks type Disks struct { diff --git a/pkg/cloudbroker/disks/filter.go b/pkg/cloudbroker/disks/filter.go index 7e742ce..aaca0f9 100644 --- a/pkg/cloudbroker/disks/filter.go +++ b/pkg/cloudbroker/disks/filter.go @@ -4,9 +4,9 @@ import ( "context" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/interfaces" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/pkg/cloudbroker/k8s" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/pkg/cloudbroker/lb" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/interfaces" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/pkg/cloudbroker/k8s" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/pkg/cloudbroker/lb" ) // FilterByID returns ListDisks with specified ID. diff --git a/pkg/cloudbroker/disks/from_platform_disk.go b/pkg/cloudbroker/disks/from_platform_disk.go index c889f0e..1ce255b 100644 --- a/pkg/cloudbroker/disks/from_platform_disk.go +++ b/pkg/cloudbroker/disks/from_platform_disk.go @@ -6,7 +6,7 @@ import ( "strconv" "strings" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // FromPlatformDiskRequest struct to create template from platform disk @@ -27,12 +27,6 @@ type FromPlatformDiskRequest struct { // Required: true ImageType string `url:"imagetype" json:"imagetype" validate:"imageType"` - // Binary architecture of this image - // Should be: - // - X86_64 - // Required: true - Architecture string `url:"architecture" json:"architecture" validate:"imageArchitecture"` - // Username for the image // Required: false Username string `url:"username,omitempty" json:"username,omitempty"` @@ -49,11 +43,6 @@ type FromPlatformDiskRequest struct { // Required: false PoolName string `url:"poolName,omitempty" json:"poolName,omitempty"` - // List of types of compute suitable for image - // Example: [ "KVM_X86" ] - // Required: true - Drivers []string `url:"drivers" json:"drivers" validate:"required"` - // Does this machine supports hot resize // Required: false HotResize bool `url:"hotresize" json:"hotresize"` diff --git a/pkg/cloudbroker/disks/get.go b/pkg/cloudbroker/disks/get.go index cb54fb5..e934b8e 100644 --- a/pkg/cloudbroker/disks/get.go +++ b/pkg/cloudbroker/disks/get.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // GetRequest struct to get information about disk diff --git a/pkg/cloudbroker/disks/limit_io.go b/pkg/cloudbroker/disks/limit_io.go index c35ca19..543fa85 100644 --- a/pkg/cloudbroker/disks/limit_io.go +++ b/pkg/cloudbroker/disks/limit_io.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // LimitIORequest struct for limit IO diff --git a/pkg/cloudbroker/disks/list.go b/pkg/cloudbroker/disks/list.go index 9898a16..f02e0c0 100644 --- a/pkg/cloudbroker/disks/list.go +++ b/pkg/cloudbroker/disks/list.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ListRequest struct to get list/list_deleted of disks @@ -46,6 +46,10 @@ type ListRequest struct { // Required: false SEPID uint64 `url:"sepId,omitempty" json:"sepId,omitempty"` + // Find by storage policy id + // Required: false + StoragePolicyID uint64 `url:"storage_policy_id,omitempty" json:"storage_policy_id,omitempty"` + // Find by pool name // Required: false Pool string `url:"pool,omitempty" json:"pool,omitempty"` diff --git a/pkg/cloudbroker/disks/list_deleted.go b/pkg/cloudbroker/disks/list_deleted.go index 75d13c9..813d379 100644 --- a/pkg/cloudbroker/disks/list_deleted.go +++ b/pkg/cloudbroker/disks/list_deleted.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ListDeletedRequest struct to get list of deleted disks diff --git a/pkg/cloudbroker/disks/list_types.go b/pkg/cloudbroker/disks/list_types.go index 93652e2..e62357b 100644 --- a/pkg/cloudbroker/disks/list_types.go +++ b/pkg/cloudbroker/disks/list_types.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ListTypesRequest struct to get list of types of disks diff --git a/pkg/cloudbroker/disks/list_unattached.go b/pkg/cloudbroker/disks/list_unattached.go index b555813..ee5ec96 100644 --- a/pkg/cloudbroker/disks/list_unattached.go +++ b/pkg/cloudbroker/disks/list_unattached.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ListUnattachedRequest struct to get list of unattached disk @@ -38,6 +38,10 @@ type ListUnattachedRequest struct { // Required: false SEPID uint64 `url:"sepId,omitempty" json:"sepId,omitempty"` + // Find by storage policy id + // Required: false + StoragePolicyID uint64 `url:"storage_policy_id,omitempty" json:"storage_policy_id,omitempty"` + // Find by pool name // Required: false Pool string `url:"pool,omitempty" json:"pool,omitempty"` diff --git a/pkg/cloudbroker/disks/migrate.go b/pkg/cloudbroker/disks/migrate.go new file mode 100644 index 0000000..521014b --- /dev/null +++ b/pkg/cloudbroker/disks/migrate.go @@ -0,0 +1,46 @@ +package disks + +import ( + "context" + "net/http" + + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" +) + +// Migrate struct to move disk to another sep, pool and storage policy +type MigrateRequest struct { + // ID of the disk + // Required: true + DiskID uint64 `url:"disk_id" json:"disk_id" validate:"required"` + + // ID of the new SEP + // Required: true + SEPID uint64 `url:"sep_id" json:"sep_id" validate:"required"` + + // New pool name + // Required: true + PoolName string `url:"pool_name" json:"pool_name" validate:"required"` + + // ID if the storage policy + // Required: false + StoragePolicyID uint64 `url:"storage_policy_id,omitempty" json:"storage_policy_id,omitempty"` +} + +// Move moves disk to another sep, pool and storage policy +func (c Disks) Migrate(ctx context.Context, req MigrateRequest) (string, error) { + err := validators.ValidateRequest(req) + if err != nil { + return "", validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/disks/migrate" + + res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req) + if err != nil { + return "", err + } + + result := string(res) + + return result, nil +} diff --git a/pkg/cloudbroker/disks/migrate_abort.go b/pkg/cloudbroker/disks/migrate_abort.go new file mode 100644 index 0000000..6fe15d3 --- /dev/null +++ b/pkg/cloudbroker/disks/migrate_abort.go @@ -0,0 +1,38 @@ +package disks + +import ( + "context" + "net/http" + "strconv" + + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" +) + +// MigrateAbortRequest struct to abort migration +type MigrateAbortRequest struct { + // ID of the disk + // Required: true + DiskID uint64 `url:"disk_id" json:"disk_id" validate:"required"` +} + +// MigrateAbort aborts disk migration +func (c Disks) MigrateAbort(ctx context.Context, req MigrateAbortRequest) (bool, error) { + err := validators.ValidateRequest(req) + if err != nil { + return false, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/disks/migrate_abort" + + res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req) + if err != nil { + return false, err + } + + result, err := strconv.ParseBool(string(res)) + if err != nil { + return false, err + } + + return result, nil +} diff --git a/pkg/cloudbroker/disks/migrate_status.go b/pkg/cloudbroker/disks/migrate_status.go new file mode 100644 index 0000000..e4f13b9 --- /dev/null +++ b/pkg/cloudbroker/disks/migrate_status.go @@ -0,0 +1,40 @@ +package disks + +import ( + "context" + "encoding/json" + "net/http" + + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" +) + +// GetMigrateStatusRequest struct to get information about disk migrate status +type GetMigrateStatusRequest struct { + // ID of disk + // Required: true + DiskID uint64 `url:"disk_id" json:"disk_id" validate:"required"` +} + +// GetMigrateStatus gets information about disk migrate status +func (c Disks) GetMigrateStatus(ctx context.Context, req GetMigrateStatusRequest) (*MigrateStatus, error) { + err := validators.ValidateRequest(req) + if err != nil { + return nil, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/disks/migrate_status" + + res, err := c.client.DecortApiCall(ctx, http.MethodGet, url, req) + if err != nil { + return nil, err + } + + status := MigrateStatus{} + + err = json.Unmarshal(res, &status) + if err != nil { + return nil, err + } + + return &status, nil +} diff --git a/pkg/cloudbroker/disks/models.go b/pkg/cloudbroker/disks/models.go index d3791d6..1ff9471 100644 --- a/pkg/cloudbroker/disks/models.go +++ b/pkg/cloudbroker/disks/models.go @@ -170,9 +170,15 @@ type InfoDisk struct { // Status Status string `json:"status"` + // Storage policy ID + StoragePolicyID uint64 `json:"storage_policy_id"` + // Tech status TechStatus string `json:"techStatus"` + // Need to clean before destroy + ToClean bool `json:"to_clean"` + // Type Type string `json:"type"` @@ -314,3 +320,20 @@ type ListTypes struct { // Entry count EntryCount uint64 `json:"entryCount"` } + +type MigrateStatus struct { + // Type + Type int `json:"type"` + + // Copy speed + Bandwidth int `json:"bandwidth"` + + // Current progress + Cur interface{} `json:"cur"` + + // Total size + End interface{} `json:"end"` + + // Progress percent + ProgressPercent int `json:"progress_percent"` +} diff --git a/pkg/cloudbroker/disks/present.go b/pkg/cloudbroker/disks/present.go index 18db0fb..24fc9f6 100644 --- a/pkg/cloudbroker/disks/present.go +++ b/pkg/cloudbroker/disks/present.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // PresentRequest struct to present disk to node diff --git a/pkg/cloudbroker/disks/rename.go b/pkg/cloudbroker/disks/rename.go index 24b9509..295a227 100644 --- a/pkg/cloudbroker/disks/rename.go +++ b/pkg/cloudbroker/disks/rename.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // RenameRequest struct to rename disk diff --git a/pkg/cloudbroker/disks/replicate.go b/pkg/cloudbroker/disks/replicate.go index a170a1c..e74bba4 100644 --- a/pkg/cloudbroker/disks/replicate.go +++ b/pkg/cloudbroker/disks/replicate.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ReplicateRequest struct to create an empty disk in chosen SEP and pool combination. @@ -25,9 +25,13 @@ type ReplicateRequest struct { // Pool name to create slave disk in // Required: true PoolName string `url:"poolName" json:"poolName" validate:"required"` + + // ID of the storage policy under the disk will be created + // Required: true + StoragePolicyID uint64 `url:"storage_policy_id" json:"storage_policy_id" validate:"required"` } -// 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 // Note: only TATLIN type SEP are supported for replications between func (d Disks) Replicate(ctx context.Context, req ReplicateRequest) (uint64, error) { diff --git a/pkg/cloudbroker/disks/replication_resume.go b/pkg/cloudbroker/disks/replication_resume.go index cbf605f..bfeda57 100644 --- a/pkg/cloudbroker/disks/replication_resume.go +++ b/pkg/cloudbroker/disks/replication_resume.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ReplicationResume struct to resume suspended replication diff --git a/pkg/cloudbroker/disks/replication_reverse.go b/pkg/cloudbroker/disks/replication_reverse.go index 554ac9a..377fc71 100644 --- a/pkg/cloudbroker/disks/replication_reverse.go +++ b/pkg/cloudbroker/disks/replication_reverse.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ReplicationReverseRequest struct to change role between disks replications diff --git a/pkg/cloudbroker/disks/replication_start.go b/pkg/cloudbroker/disks/replication_start.go index fd7acbc..0504028 100644 --- a/pkg/cloudbroker/disks/replication_start.go +++ b/pkg/cloudbroker/disks/replication_start.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ReplicationStartRequest struct to starts replication between two chosen disks diff --git a/pkg/cloudbroker/disks/replication_status.go b/pkg/cloudbroker/disks/replication_status.go index d51a932..02e30b5 100644 --- a/pkg/cloudbroker/disks/replication_status.go +++ b/pkg/cloudbroker/disks/replication_status.go @@ -4,7 +4,7 @@ import ( "context" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ReplicationStatusRequest struct to get replication status diff --git a/pkg/cloudbroker/disks/replication_stop.go b/pkg/cloudbroker/disks/replication_stop.go index 02dab1a..13a5622 100644 --- a/pkg/cloudbroker/disks/replication_stop.go +++ b/pkg/cloudbroker/disks/replication_stop.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ReplicationStopRequest struct to remove replication between disks completely diff --git a/pkg/cloudbroker/disks/replication_suspend.go b/pkg/cloudbroker/disks/replication_suspend.go index 4242c9d..913ef25 100644 --- a/pkg/cloudbroker/disks/replication_suspend.go +++ b/pkg/cloudbroker/disks/replication_suspend.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ReplicationSuspendRequest struct to pause replication with possibility to resume from pause moment diff --git a/pkg/cloudbroker/disks/resize.go b/pkg/cloudbroker/disks/resize.go index 0614ac1..0a7cc6f 100644 --- a/pkg/cloudbroker/disks/resize.go +++ b/pkg/cloudbroker/disks/resize.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ResizeRequest struct to resize disk diff --git a/pkg/cloudbroker/disks/restore.go b/pkg/cloudbroker/disks/restore.go index 3bc2cd4..ab23cee 100644 --- a/pkg/cloudbroker/disks/restore.go +++ b/pkg/cloudbroker/disks/restore.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // RestoreRequest struct to restore a deleted unattached disk diff --git a/pkg/cloudbroker/disks/serialize.go b/pkg/cloudbroker/disks/serialize.go index 8b015ea..e0a0a56 100644 --- a/pkg/cloudbroker/disks/serialize.go +++ b/pkg/cloudbroker/disks/serialize.go @@ -3,7 +3,7 @@ package disks import ( "encoding/json" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/serialization" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/serialization" ) // Serialize returns JSON-serialized []byte. Used as a wrapper over json.Marshal and json.MarshalIndent functions. diff --git a/pkg/cloudbroker/disks/share.go b/pkg/cloudbroker/disks/share.go index 3609c4c..6ceb664 100644 --- a/pkg/cloudbroker/disks/share.go +++ b/pkg/cloudbroker/disks/share.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ShareRequest struct to share data disk diff --git a/pkg/cloudbroker/disks/snapshot_delete.go b/pkg/cloudbroker/disks/snapshot_delete.go index 3cc5118..0b0acfb 100644 --- a/pkg/cloudbroker/disks/snapshot_delete.go +++ b/pkg/cloudbroker/disks/snapshot_delete.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // SnapshotDeleteRequest struct to delete snapshot diff --git a/pkg/cloudbroker/disks/snapshot_rollback.go b/pkg/cloudbroker/disks/snapshot_rollback.go index db6bfdb..0afa8e1 100644 --- a/pkg/cloudbroker/disks/snapshot_rollback.go +++ b/pkg/cloudbroker/disks/snapshot_rollback.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // SnapshotRollbackRequest struct to rollback snapshot diff --git a/pkg/cloudbroker/disks/unshare.go b/pkg/cloudbroker/disks/unshare.go index 93e3f9b..a67a8a3 100644 --- a/pkg/cloudbroker/disks/unshare.go +++ b/pkg/cloudbroker/disks/unshare.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // UnshareRequest struct to unshare data disk diff --git a/pkg/cloudbroker/dpdk.go b/pkg/cloudbroker/dpdk.go index 4c0a6a9..bab6042 100644 --- a/pkg/cloudbroker/dpdk.go +++ b/pkg/cloudbroker/dpdk.go @@ -1,6 +1,6 @@ package cloudbroker -import "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/pkg/cloudbroker/dpdknet" +import "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/pkg/cloudbroker/dpdknet" // Accessing the DPDK method group func (ca *CloudBroker) DPDKNet() *dpdknet.DPDKNet { diff --git a/pkg/cloudbroker/dpdknet/create.go b/pkg/cloudbroker/dpdknet/create.go index db4bd4e..03182ed 100644 --- a/pkg/cloudbroker/dpdknet/create.go +++ b/pkg/cloudbroker/dpdknet/create.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // CreateRequest struct to create DPDK network diff --git a/pkg/cloudbroker/dpdknet/delete.go b/pkg/cloudbroker/dpdknet/delete.go index 64cab18..c9d491b 100644 --- a/pkg/cloudbroker/dpdknet/delete.go +++ b/pkg/cloudbroker/dpdknet/delete.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // DeleteRequest struct to delete DPDK network diff --git a/pkg/cloudbroker/dpdknet/disable.go b/pkg/cloudbroker/dpdknet/disable.go index 9e546b9..c029e1d 100644 --- a/pkg/cloudbroker/dpdknet/disable.go +++ b/pkg/cloudbroker/dpdknet/disable.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // DisableRequest struct to disable DPDK network diff --git a/pkg/cloudbroker/dpdknet/dpdk.go b/pkg/cloudbroker/dpdknet/dpdk.go index 0d2500f..eb87237 100644 --- a/pkg/cloudbroker/dpdknet/dpdk.go +++ b/pkg/cloudbroker/dpdknet/dpdk.go @@ -1,6 +1,6 @@ package dpdknet -import "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/interfaces" +import "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/interfaces" // Structure for creating request to DPDK network type DPDKNet struct { diff --git a/pkg/cloudbroker/dpdknet/enable.go b/pkg/cloudbroker/dpdknet/enable.go index a658815..08be284 100644 --- a/pkg/cloudbroker/dpdknet/enable.go +++ b/pkg/cloudbroker/dpdknet/enable.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // EnableRequest struct to enable DPDK network diff --git a/pkg/cloudbroker/dpdknet/get.go b/pkg/cloudbroker/dpdknet/get.go index 1d7d329..c9db8ba 100644 --- a/pkg/cloudbroker/dpdknet/get.go +++ b/pkg/cloudbroker/dpdknet/get.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // GetRequest struct to get information about DPDK network diff --git a/pkg/cloudbroker/dpdknet/list.go b/pkg/cloudbroker/dpdknet/list.go index 7d4be00..7f67dd5 100644 --- a/pkg/cloudbroker/dpdknet/list.go +++ b/pkg/cloudbroker/dpdknet/list.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ListRequest struct to get list of DPDK networks diff --git a/pkg/cloudbroker/dpdknet/models.go b/pkg/cloudbroker/dpdknet/models.go index 7bcf84d..ebcca93 100644 --- a/pkg/cloudbroker/dpdknet/models.go +++ b/pkg/cloudbroker/dpdknet/models.go @@ -14,6 +14,9 @@ type RecordDPDKNet struct { // Description Description string `json:"description"` + // Enable Security Groups + EnableSecGroups bool `json:"enable_secgroups"` + // Grid ID GID uint64 `json:"gid"` @@ -63,6 +66,9 @@ type ItemDPDKNet struct { // Description Description string `json:"description"` + // Enable Security Groups + EnableSecGroups bool `json:"enable_secgroups"` + // Grid ID GID uint64 `json:"gid"` diff --git a/pkg/cloudbroker/dpdknet/update.go b/pkg/cloudbroker/dpdknet/update.go index 1e7d75a..c44182e 100644 --- a/pkg/cloudbroker/dpdknet/update.go +++ b/pkg/cloudbroker/dpdknet/update.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // UpdateRequest struct to update DPDK network @@ -37,6 +37,10 @@ type UpdateRequest struct { // Name of OVS Bridge to use for DPDK network // Required: true OVSBridge string `url:"ovsBridge,omitempty" json:"ovsBridge,omitempty"` + + // Flag indicating whether security groups are enabled for this network + // Required: false + EnableSecGroups interface{} `url:"enable_secgroups,omitempty" json:"enable_secgroups,omitempty" validate:"omitempty,isBool"` } // Update updates a DPDK networks diff --git a/pkg/cloudbroker/extnet.go b/pkg/cloudbroker/extnet.go index 3b59a96..e79677b 100644 --- a/pkg/cloudbroker/extnet.go +++ b/pkg/cloudbroker/extnet.go @@ -1,7 +1,7 @@ package cloudbroker import ( - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/pkg/cloudbroker/extnet" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/pkg/cloudbroker/extnet" ) // Accessing the ExtNet method group diff --git a/pkg/cloudbroker/extnet/access_add.go b/pkg/cloudbroker/extnet/access_add.go index 2a179ba..3ebce73 100644 --- a/pkg/cloudbroker/extnet/access_add.go +++ b/pkg/cloudbroker/extnet/access_add.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // AccessAddRequest struct to grant access diff --git a/pkg/cloudbroker/extnet/access_remove.go b/pkg/cloudbroker/extnet/access_remove.go index 4c73d2b..36a4f6a 100644 --- a/pkg/cloudbroker/extnet/access_remove.go +++ b/pkg/cloudbroker/extnet/access_remove.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // AccessRemoveRequest struct to remove access diff --git a/pkg/cloudbroker/extnet/add_reserved_ip.go b/pkg/cloudbroker/extnet/add_reserved_ip.go index c549216..3b941b0 100644 --- a/pkg/cloudbroker/extnet/add_reserved_ip.go +++ b/pkg/cloudbroker/extnet/add_reserved_ip.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // AddReserveIPRequest struct to reserved address or address poll diff --git a/pkg/cloudbroker/extnet/create.go b/pkg/cloudbroker/extnet/create.go index b30bba4..82ad4fa 100644 --- a/pkg/cloudbroker/extnet/create.go +++ b/pkg/cloudbroker/extnet/create.go @@ -6,7 +6,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) type Route struct { @@ -47,6 +47,11 @@ type CreateRequest struct { // Required: false DNS []string `url:"dns,omitempty" json:"dns,omitempty"` + // Maximum transmission unit + // Default: 1500 + // Required: false + MTU uint `url:"mtu,omitempty" json:"mtu,omitempty"` + // List of NTP addresses // Required: false NTP []string `url:"ntp,omitempty" json:"ntp,omitempty"` @@ -71,9 +76,13 @@ type CreateRequest struct { // Required: false EndIP string `url:"endIP,omitempty" json:"endIP,omitempty"` - // IP to create VNFDev with + // IP to create primary vnfdev with + // Required: false + PriVNFDevIP string `url:"priVnfdevIP,omitempty" json:"priVnfdevIP,omitempty"` + + // IP to create secondary vnfdev with // Required: false - VNFDevIP string `url:"vnfdevIP,omitempty" json:"vnfdevIP,omitempty"` + SecVNFDevIP string `url:"secVnfdevIP,omitempty" json:"secVnfdevIP,omitempty"` // Number of pre created reservations // Required: false @@ -86,6 +95,15 @@ type CreateRequest struct { // List of static routes, each item must have destination, netmask, and gateway fields // Required: false Routes []Route `url:"-" json:"routes,omitempty" validate:"omitempty,dive"` + + // Zone ID + // Required: false + ZoneID uint64 `url:"zoneId,omitempty" json:"zoneId,omitempty"` + + // High Availability mode is enabled, default False + // Required: false + // Default: false + HAMode bool `url:"highlyAvailable,omitempty" json:"highlyAvailable,omitempty"` } type wrapperCreateRequest struct { diff --git a/pkg/cloudbroker/extnet/default_qos_update.go b/pkg/cloudbroker/extnet/default_qos_update.go index a570d26..a1edba4 100644 --- a/pkg/cloudbroker/extnet/default_qos_update.go +++ b/pkg/cloudbroker/extnet/default_qos_update.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // DefaultQOSUpdateRequest struct for update QOS diff --git a/pkg/cloudbroker/extnet/del_reserved_ip.go b/pkg/cloudbroker/extnet/del_reserved_ip.go index 7db9b18..cbf5c05 100644 --- a/pkg/cloudbroker/extnet/del_reserved_ip.go +++ b/pkg/cloudbroker/extnet/del_reserved_ip.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // DelReserveIPRequest struct to delete reserved address or address poll diff --git a/pkg/cloudbroker/extnet/destroy.go b/pkg/cloudbroker/extnet/destroy.go index d9396fc..4b84860 100644 --- a/pkg/cloudbroker/extnet/destroy.go +++ b/pkg/cloudbroker/extnet/destroy.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // DestroyRequest struct for destroy diff --git a/pkg/cloudbroker/extnet/device_deploy.go b/pkg/cloudbroker/extnet/device_deploy.go index 55116e0..75ae289 100644 --- a/pkg/cloudbroker/extnet/device_deploy.go +++ b/pkg/cloudbroker/extnet/device_deploy.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // DeviceDeployRequest struct to deploy network device diff --git a/pkg/cloudbroker/extnet/device_migrate.go b/pkg/cloudbroker/extnet/device_migrate.go index 8ee4dbc..144fb57 100644 --- a/pkg/cloudbroker/extnet/device_migrate.go +++ b/pkg/cloudbroker/extnet/device_migrate.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // DeviceMigrateRequest struct for migrate VNF @@ -17,6 +17,11 @@ type DeviceMigrateRequest struct { // Target stack ID to migrate to // Required: false StackID uint64 `url:"stackId,omitempty" json:"stackId,omitempty"` + + // Target device to migrate + // Required: false + // Default: primary + Device string `url:"device,omitempty" json:"device,omitempty" validate:"omitempty,device"` } // DeviceMigrate migrates external network VNF device diff --git a/pkg/cloudbroker/extnet/device_remove.go b/pkg/cloudbroker/extnet/device_remove.go index b8bdb7f..f94a8fc 100644 --- a/pkg/cloudbroker/extnet/device_remove.go +++ b/pkg/cloudbroker/extnet/device_remove.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // DeviceRemoveRequest struct to remove network device diff --git a/pkg/cloudbroker/extnet/device_restart.go b/pkg/cloudbroker/extnet/device_restart.go index 4d161bf..8895ff9 100644 --- a/pkg/cloudbroker/extnet/device_restart.go +++ b/pkg/cloudbroker/extnet/device_restart.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // DeviceRestartRequest struct for restart VNF device diff --git a/pkg/cloudbroker/extnet/disable.go b/pkg/cloudbroker/extnet/disable.go index c7ab6f6..fbaf157 100644 --- a/pkg/cloudbroker/extnet/disable.go +++ b/pkg/cloudbroker/extnet/disable.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // DisableRequest struct to disable external network diff --git a/pkg/cloudbroker/extnet/dns_apply.go b/pkg/cloudbroker/extnet/dns_apply.go index da14f96..6d1a2ae 100644 --- a/pkg/cloudbroker/extnet/dns_apply.go +++ b/pkg/cloudbroker/extnet/dns_apply.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // DNSApplyRequest struct to set new DNS diff --git a/pkg/cloudbroker/extnet/enable.go b/pkg/cloudbroker/extnet/enable.go index a95aafc..ebd6599 100644 --- a/pkg/cloudbroker/extnet/enable.go +++ b/pkg/cloudbroker/extnet/enable.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // EnableRequest struct to enable external network diff --git a/pkg/cloudbroker/extnet/extnet.go b/pkg/cloudbroker/extnet/extnet.go index 9db89c4..9b7ef10 100644 --- a/pkg/cloudbroker/extnet/extnet.go +++ b/pkg/cloudbroker/extnet/extnet.go @@ -1,7 +1,7 @@ // API Actor for configure and use external networks package extnet -import "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/interfaces" +import "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/interfaces" // Structure for creating request to extnet type ExtNet struct { diff --git a/pkg/cloudbroker/extnet/filter_test.go b/pkg/cloudbroker/extnet/filter_test.go index e92a0b3..4dcb212 100644 --- a/pkg/cloudbroker/extnet/filter_test.go +++ b/pkg/cloudbroker/extnet/filter_test.go @@ -18,7 +18,7 @@ var extnets = ListExtNet{ IPCIDR: "176.118.164.0/24", Milestones: 1355466, Name: "176.118.164.0/24", - NetworkID: 0, + NetworkIDs: NetworkIDs{Primary: 10, Secondary: 0}, OVSBridge: "", PreReservationsNum: 0, PriVNFDevID: 0, @@ -41,7 +41,7 @@ var extnets = ListExtNet{ IPCIDR: "45.134.255.0/24", Milestones: 2135543, Name: "45.134.255.0/24", - NetworkID: 0, + NetworkIDs: NetworkIDs{Primary: 10, Secondary: 0}, OVSBridge: "", PreReservationsNum: 0, PriVNFDevID: 0, @@ -64,7 +64,7 @@ var extnets = ListExtNet{ IPCIDR: "88.218.249.0/24", Milestones: 1232134, Name: "88.218.249.0/24", - NetworkID: 0, + NetworkIDs: NetworkIDs{Primary: 10, Secondary: 0}, OVSBridge: "", PreReservationsNum: 0, PriVNFDevID: 0, diff --git a/pkg/cloudbroker/extnet/get.go b/pkg/cloudbroker/extnet/get.go index 4427513..f57fe1d 100644 --- a/pkg/cloudbroker/extnet/get.go +++ b/pkg/cloudbroker/extnet/get.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // GetRequest struct to get information about external network diff --git a/pkg/cloudbroker/extnet/get_reserved_ip.go b/pkg/cloudbroker/extnet/get_reserved_ip.go index 8b6445b..d6c9669 100644 --- a/pkg/cloudbroker/extnet/get_reserved_ip.go +++ b/pkg/cloudbroker/extnet/get_reserved_ip.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // GetRequest struct to get information about reserved address or address poll diff --git a/pkg/cloudbroker/extnet/ips_exclude.go b/pkg/cloudbroker/extnet/ips_exclude.go index 8a218cf..d03d777 100644 --- a/pkg/cloudbroker/extnet/ips_exclude.go +++ b/pkg/cloudbroker/extnet/ips_exclude.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // IPsExcludeRequest struct to exclude list of IPs diff --git a/pkg/cloudbroker/extnet/ips_exclude_range.go b/pkg/cloudbroker/extnet/ips_exclude_range.go index f77ae25..608defa 100644 --- a/pkg/cloudbroker/extnet/ips_exclude_range.go +++ b/pkg/cloudbroker/extnet/ips_exclude_range.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // IPsExcludeRangeRequest struct to exclude range of IPs diff --git a/pkg/cloudbroker/extnet/ips_include.go b/pkg/cloudbroker/extnet/ips_include.go index 5acc80f..90e020c 100644 --- a/pkg/cloudbroker/extnet/ips_include.go +++ b/pkg/cloudbroker/extnet/ips_include.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // IPsIncludeRequest struct to include list of IPs diff --git a/pkg/cloudbroker/extnet/ips_include_range.go b/pkg/cloudbroker/extnet/ips_include_range.go index a6bc01b..8680568 100644 --- a/pkg/cloudbroker/extnet/ips_include_range.go +++ b/pkg/cloudbroker/extnet/ips_include_range.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // IPsIncludeRangeRequest struct to include range of IPs diff --git a/pkg/cloudbroker/extnet/list.go b/pkg/cloudbroker/extnet/list.go index 1a180dc..a1eb067 100644 --- a/pkg/cloudbroker/extnet/list.go +++ b/pkg/cloudbroker/extnet/list.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ListRequest struct to get list of external network @@ -42,6 +42,11 @@ type ListRequest struct { // Required: false SortBy string `url:"sortBy,omitempty" json:"sortBy,omitempty" validate:"omitempty,sortBy"` + // Sort by zone id + // Default value: 0 + // Required: false + ZoneID uint64 `url:"zone_id,omitempty" json:"zone_id,omitempty"` + // Page number // Required: false Page uint64 `url:"page,omitempty" json:"page,omitempty"` diff --git a/pkg/cloudbroker/extnet/migrate_to_zone.go b/pkg/cloudbroker/extnet/migrate_to_zone.go new file mode 100644 index 0000000..1b64c75 --- /dev/null +++ b/pkg/cloudbroker/extnet/migrate_to_zone.go @@ -0,0 +1,42 @@ +package extnet + +import ( + "context" + "net/http" + "strconv" + + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" +) + +// MigrateToZone struct to move extnet to another zone +type MigrateToZoneRequest struct { + // ID of external network + // Required: true + NetID uint64 `url:"net_id" json:"net_id" validate:"required"` + + // ID of the zone to move + // Required: true + ZoneID uint64 `url:"zone_id" json:"zone_id" validate:"required"` +} + +// MoveToZone moves extnet to new zone +func (e ExtNet) MigrateToZone(ctx context.Context, req MigrateToZoneRequest) (bool, error) { + err := validators.ValidateRequest(req) + if err != nil { + return false, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/extnet/migrateToZone" + + res, err := e.client.DecortApiCall(ctx, http.MethodPost, url, req) + if err != nil { + return false, err + } + + result, err := strconv.ParseBool(string(res)) + if err != nil { + return false, err + } + + return result, nil +} diff --git a/pkg/cloudbroker/extnet/models.go b/pkg/cloudbroker/extnet/models.go index 645b5d4..a84c7f6 100644 --- a/pkg/cloudbroker/extnet/models.go +++ b/pkg/cloudbroker/extnet/models.go @@ -58,6 +58,9 @@ type ItemExtNet struct { // CKey CKey string `json:"_ckey"` + // Enable Security Groups + EnableSecGroups bool `json:"enable_secgroups"` + // Meta Meta []interface{} `json:"_meta"` @@ -91,11 +94,14 @@ type ItemExtNet struct { // Milestones Milestones uint64 `json:"milestones"` + // MTU + MTU uint64 `json:"mtu"` + // Name Name string `json:"name"` - // Network ID - NetworkID uint64 `json:"networkId"` + // Network IDs + NetworkIDs NetworkIDs `json:"networkIds"` // OVSBridge OVSBridge string `json:"ovsBridge"` @@ -106,6 +112,12 @@ type ItemExtNet struct { // PriVNFDevID PriVNFDevID uint64 `json:"priVnfDevId"` + // Redundant + Redundant bool `json:"redundant"` + + // SecVnfDevId + SecVNFDevID uint64 `json:"secVnfDevId"` + // List of shared with SharedWith []interface{} `json:"sharedWith"` @@ -117,6 +129,9 @@ type ItemExtNet struct { // VNFs VNFs VNFs `json:"vnfs"` + + // Zone ID + ZoneID uint64 `json:"zoneId"` } // List external networks @@ -154,6 +169,9 @@ type RecordExtNet struct { // List excludes Excluded ListReservations `json:"excluded"` + // Enable Security Groups + EnableSecGroups bool `json:"enable_secgroups"` + // Free IPs number FreeIPs int64 `json:"free_ips"` @@ -175,14 +193,17 @@ type RecordExtNet struct { // Milestones Milestones uint64 `json:"milestones"` + // MTU + MTU uint64 `json:"mtu"` + // Name Name string `json:"name"` // Network Network string `json:"network"` - // Network ID - NetworkID uint64 `json:"networkId"` + // Network IDs + NetworkIDs NetworkIDs `json:"networkIds"` // NTP NTP []string `json:"ntp"` @@ -199,9 +220,18 @@ type RecordExtNet struct { // PriVNFDevID PriVNFDevID uint64 `json:"priVnfDevId"` + // Redundant + Redundant bool `json:"redundant"` + + // SecVnfDevId + SecVNFDevID uint64 `json:"secVnfDevId"` + // List reservations Reservations ListReservations `json:"reservations"` + // List pre-reservations + PreReservations ListReservations `json:"pre-reservations"` + // List of shared with SharedWith []interface{} `json:"sharedWith"` @@ -213,6 +243,17 @@ type RecordExtNet struct { // VNFs VNFs VNFs `json:"vnfs"` + + // Zone ID + ZoneID uint64 `json:"zoneId"` +} + +type NetworkIDs struct { + // Primary + Primary uint64 `json:"primary"` + + // Secondary + Secondary uint64 `json:"secondary"` } // List of static routes diff --git a/pkg/cloudbroker/extnet/ntp_apply.go b/pkg/cloudbroker/extnet/ntp_apply.go index b993e88..f79d169 100644 --- a/pkg/cloudbroker/extnet/ntp_apply.go +++ b/pkg/cloudbroker/extnet/ntp_apply.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // NTPApplyRequest struct for set new NTP diff --git a/pkg/cloudbroker/extnet/serialize.go b/pkg/cloudbroker/extnet/serialize.go index 7f9e486..0954488 100644 --- a/pkg/cloudbroker/extnet/serialize.go +++ b/pkg/cloudbroker/extnet/serialize.go @@ -3,7 +3,7 @@ package extnet import ( "encoding/json" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/serialization" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/serialization" ) // Serialize returns JSON-serialized []byte. Used as a wrapper over json.Marshal and json.MarshalIndent functions. diff --git a/pkg/cloudbroker/extnet/set_default.go b/pkg/cloudbroker/extnet/set_default.go index 5c435ca..448d195 100644 --- a/pkg/cloudbroker/extnet/set_default.go +++ b/pkg/cloudbroker/extnet/set_default.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // SetDefaultRequest struct to set external network as default diff --git a/pkg/cloudbroker/extnet/set_highly_available.go b/pkg/cloudbroker/extnet/set_highly_available.go new file mode 100644 index 0000000..8726599 --- /dev/null +++ b/pkg/cloudbroker/extnet/set_highly_available.go @@ -0,0 +1,42 @@ +package extnet + +import ( + "context" + "net/http" + "strconv" + + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" +) + +// SetHAModeRequest struct to set HA mode for external network +type SetHAModeRequest struct { + // ID of external network + // Required: true + NetID uint64 `url:"net_id" json:"net_id" validate:"required"` + + // HA Mode + // Required: true + HAMode bool `url:"highly_available" json:"highly_available" validate:"required"` +} + +// SetHAMode set HA mode for external network +func (e ExtNet) SetHAMode(ctx context.Context, req SetHAModeRequest) (bool, error) { + err := validators.ValidateRequest(req) + if err != nil { + return false, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/extnet/set_highly_available" + + res, err := e.client.DecortApiCall(ctx, http.MethodPost, url, req) + if err != nil { + return false, err + } + + result, err := strconv.ParseBool(string(res)) + if err != nil { + return false, err + } + + return result, nil +} diff --git a/pkg/cloudbroker/extnet/static_route_access_grant.go b/pkg/cloudbroker/extnet/static_route_access_grant.go index c9d43b5..c78b3b5 100644 --- a/pkg/cloudbroker/extnet/static_route_access_grant.go +++ b/pkg/cloudbroker/extnet/static_route_access_grant.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // StaticRouteAccessGrantRequest struct to grant access to static route to Compute/ViNS diff --git a/pkg/cloudbroker/extnet/static_route_access_revoke.go b/pkg/cloudbroker/extnet/static_route_access_revoke.go index c0e68fd..01fd808 100644 --- a/pkg/cloudbroker/extnet/static_route_access_revoke.go +++ b/pkg/cloudbroker/extnet/static_route_access_revoke.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // StaticRouteAccessRevokeRequest struct to revoke access to static route to Compute/ViNS diff --git a/pkg/cloudbroker/extnet/static_route_add.go b/pkg/cloudbroker/extnet/static_route_add.go index ab4cdcc..a3ba6c6 100644 --- a/pkg/cloudbroker/extnet/static_route_add.go +++ b/pkg/cloudbroker/extnet/static_route_add.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // StaticRouteAddRequest struct to add static route diff --git a/pkg/cloudbroker/extnet/static_route_del.go b/pkg/cloudbroker/extnet/static_route_del.go index 3833321..b344954 100644 --- a/pkg/cloudbroker/extnet/static_route_del.go +++ b/pkg/cloudbroker/extnet/static_route_del.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // StaticRouteDelRequest struct to remove static route from ViNS diff --git a/pkg/cloudbroker/extnet/static_route_list.go b/pkg/cloudbroker/extnet/static_route_list.go index ddc0912..254f46c 100644 --- a/pkg/cloudbroker/extnet/static_route_list.go +++ b/pkg/cloudbroker/extnet/static_route_list.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // StaticRouteListRequest struct for static route list diff --git a/pkg/cloudbroker/extnet/update.go b/pkg/cloudbroker/extnet/update.go index 3667af5..a276281 100644 --- a/pkg/cloudbroker/extnet/update.go +++ b/pkg/cloudbroker/extnet/update.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // UpdateRequest struct to update external network @@ -21,6 +21,15 @@ type UpdateRequest struct { // New external network description // Required: false Description string `url:"desc,omitempty" json:"desc,omitempty"` + + // Maximum transmission unit + // Default: 1500 + // Required: false + MTU uint64 `url:"mtu,omitempty" json:"mtu,omitempty"` + + // Flag indicating whether security groups are enabled for this network + // Required: false + EnableSecGroups interface{} `url:"enable_secgroups,omitempty" json:"enable_secgroups,omitempty" validate:"omitempty,isBool"` } // Update updates external network parameters diff --git a/pkg/cloudbroker/flipgoup.go b/pkg/cloudbroker/flipgoup.go index c786cc0..f81572c 100644 --- a/pkg/cloudbroker/flipgoup.go +++ b/pkg/cloudbroker/flipgoup.go @@ -1,7 +1,7 @@ package cloudbroker import ( - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/pkg/cloudbroker/flipgroup" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/pkg/cloudbroker/flipgroup" ) // Accessing the FLIPGroup method group diff --git a/pkg/cloudbroker/flipgroup/compute_add.go b/pkg/cloudbroker/flipgroup/compute_add.go index f400ee5..aa0c889 100644 --- a/pkg/cloudbroker/flipgroup/compute_add.go +++ b/pkg/cloudbroker/flipgroup/compute_add.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ComputeAddRequest struct to add compute instance diff --git a/pkg/cloudbroker/flipgroup/compute_remove.go b/pkg/cloudbroker/flipgroup/compute_remove.go index ad84e0c..5ae1963 100644 --- a/pkg/cloudbroker/flipgroup/compute_remove.go +++ b/pkg/cloudbroker/flipgroup/compute_remove.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ComputeRemoveRequest struct to remove compute instance diff --git a/pkg/cloudbroker/flipgroup/create.go b/pkg/cloudbroker/flipgroup/create.go index b287f9d..421ea39 100644 --- a/pkg/cloudbroker/flipgroup/create.go +++ b/pkg/cloudbroker/flipgroup/create.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // CreateRequest struct to create FLIPGroup @@ -32,8 +32,9 @@ type CreateRequest struct { // Type of client // - 'compute' // - 'vins' (will be later) - // Required: true - ClientType string `url:"clientType" json:"clientType" validate:"flipgroupClientType"` + // Required: false + // Default: "compute" + ClientType string `url:"clientType,omitempty" json:"clientType,omitempty"` // IP address to associate with this group. If empty, the platform will autoselect IP address // Required: false diff --git a/pkg/cloudbroker/flipgroup/delete.go b/pkg/cloudbroker/flipgroup/delete.go index 901dfb8..03cd190 100644 --- a/pkg/cloudbroker/flipgroup/delete.go +++ b/pkg/cloudbroker/flipgroup/delete.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // DeleteRequest struct to delete FLIPGroup diff --git a/pkg/cloudbroker/flipgroup/edit.go b/pkg/cloudbroker/flipgroup/edit.go index 5d67abd..027239a 100644 --- a/pkg/cloudbroker/flipgroup/edit.go +++ b/pkg/cloudbroker/flipgroup/edit.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // EditRequest struct to edit FLIPGroup diff --git a/pkg/cloudbroker/flipgroup/flipgroup.go b/pkg/cloudbroker/flipgroup/flipgroup.go index 3836927..7697d99 100644 --- a/pkg/cloudbroker/flipgroup/flipgroup.go +++ b/pkg/cloudbroker/flipgroup/flipgroup.go @@ -2,7 +2,7 @@ package flipgroup import ( - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/interfaces" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/interfaces" ) // Structure for creating request to FLIPGroup diff --git a/pkg/cloudbroker/flipgroup/get.go b/pkg/cloudbroker/flipgroup/get.go index 57e5c95..01821c5 100644 --- a/pkg/cloudbroker/flipgroup/get.go +++ b/pkg/cloudbroker/flipgroup/get.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // GetRequest struct to get information about FLIPGroup diff --git a/pkg/cloudbroker/flipgroup/list.go b/pkg/cloudbroker/flipgroup/list.go index 78046bd..8dd910e 100644 --- a/pkg/cloudbroker/flipgroup/list.go +++ b/pkg/cloudbroker/flipgroup/list.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ListRequest struct to get list of FLIPGroup available to the current user diff --git a/pkg/cloudbroker/flipgroup/serialize.go b/pkg/cloudbroker/flipgroup/serialize.go index a53fca9..49cb39b 100644 --- a/pkg/cloudbroker/flipgroup/serialize.go +++ b/pkg/cloudbroker/flipgroup/serialize.go @@ -3,7 +3,7 @@ package flipgroup import ( "encoding/json" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/serialization" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/serialization" ) // Serialize returns JSON-serialized []byte. Used as a wrapper over json.Marshal and json.MarshalIndent functions. diff --git a/pkg/cloudbroker/grid.go b/pkg/cloudbroker/grid.go index 06ea277..c62b9bb 100644 --- a/pkg/cloudbroker/grid.go +++ b/pkg/cloudbroker/grid.go @@ -1,6 +1,6 @@ package cloudbroker -import "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/pkg/cloudbroker/grid" +import "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/pkg/cloudbroker/grid" // Accessing the Grid method group func (cb *CloudBroker) Grid() *grid.Grid { diff --git a/pkg/cloudbroker/grid/add.go b/pkg/cloudbroker/grid/add.go index fa0b375..8995421 100644 --- a/pkg/cloudbroker/grid/add.go +++ b/pkg/cloudbroker/grid/add.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // AddRequest struct for location code diff --git a/pkg/cloudbroker/grid/add_custom_backup_path.go b/pkg/cloudbroker/grid/add_custom_backup_path.go index 3ed980a..30222a6 100644 --- a/pkg/cloudbroker/grid/add_custom_backup_path.go +++ b/pkg/cloudbroker/grid/add_custom_backup_path.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // AddCustomBackupPathRequest struct to add new path to the list of custom backup paths diff --git a/pkg/cloudbroker/grid/change_settings.go b/pkg/cloudbroker/grid/change_settings.go index f4a44ce..b60180c 100644 --- a/pkg/cloudbroker/grid/change_settings.go +++ b/pkg/cloudbroker/grid/change_settings.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ChangeSettingsRequest struct to change grid settings diff --git a/pkg/cloudbroker/grid/execute_maintenance_script.go b/pkg/cloudbroker/grid/execute_maintenance_script.go index 8c86fc8..175c655 100644 --- a/pkg/cloudbroker/grid/execute_maintenance_script.go +++ b/pkg/cloudbroker/grid/execute_maintenance_script.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ExecuteMaintenanceScriptRequest struct to execute script diff --git a/pkg/cloudbroker/grid/get.go b/pkg/cloudbroker/grid/get.go index 0c55ecf..24fac95 100644 --- a/pkg/cloudbroker/grid/get.go +++ b/pkg/cloudbroker/grid/get.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // GetRequest struct to get grid details diff --git a/pkg/cloudbroker/grid/get_backup.go b/pkg/cloudbroker/grid/get_backup.go index 99526c3..6b72f57 100644 --- a/pkg/cloudbroker/grid/get_backup.go +++ b/pkg/cloudbroker/grid/get_backup.go @@ -4,7 +4,7 @@ import ( "context" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // GetBackupRequest struct to get backup diff --git a/pkg/cloudbroker/grid/get_diagnosis.go b/pkg/cloudbroker/grid/get_diagnosis.go index 1ebd350..153433a 100644 --- a/pkg/cloudbroker/grid/get_diagnosis.go +++ b/pkg/cloudbroker/grid/get_diagnosis.go @@ -4,7 +4,7 @@ import ( "context" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // GetDiagnosisRequest struct to get platform snapshot with additional diagnosis diff --git a/pkg/cloudbroker/grid/get_resource_consumption.go b/pkg/cloudbroker/grid/get_resource_consumption.go index 7b81e9b..4c35a00 100644 --- a/pkg/cloudbroker/grid/get_resource_consumption.go +++ b/pkg/cloudbroker/grid/get_resource_consumption.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // GetResourceConsumptionRequest struct to get resource consumption diff --git a/pkg/cloudbroker/grid/get_settings.go b/pkg/cloudbroker/grid/get_settings.go index f08ba1b..fcd4c3d 100644 --- a/pkg/cloudbroker/grid/get_settings.go +++ b/pkg/cloudbroker/grid/get_settings.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // GetSettingsRequest struct to get grid settings diff --git a/pkg/cloudbroker/grid/grid.go b/pkg/cloudbroker/grid/grid.go index fb1e5ac..d11c417 100644 --- a/pkg/cloudbroker/grid/grid.go +++ b/pkg/cloudbroker/grid/grid.go @@ -2,7 +2,7 @@ package grid import ( - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/interfaces" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/interfaces" ) // Structure for creating request to grid diff --git a/pkg/cloudbroker/grid/list.go b/pkg/cloudbroker/grid/list.go index 7f29f95..587b8c5 100644 --- a/pkg/cloudbroker/grid/list.go +++ b/pkg/cloudbroker/grid/list.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ListRequest struct to get list of locations diff --git a/pkg/cloudbroker/grid/models.go b/pkg/cloudbroker/grid/models.go index 1e78e81..9f5a6ed 100644 --- a/pkg/cloudbroker/grid/models.go +++ b/pkg/cloudbroker/grid/models.go @@ -93,6 +93,12 @@ type RecordGrid struct { // Name Name string `json:"name"` + + // Network modes + NetworkModes []string `json:"network_modes"` + + // SDN support + SDNSupport bool `json:"sdn_support"` } // Information about grid @@ -120,6 +126,12 @@ type ItemGridList struct { // Name Name string `json:"name"` + + // Network modes + NetworkModes []string `json:"network_modes"` + + // SDN support + SDNSupport bool `json:"sdn_support"` } // List Grids diff --git a/pkg/cloudbroker/grid/purge_logs.go b/pkg/cloudbroker/grid/purge_logs.go index b25c921..722f0b6 100644 --- a/pkg/cloudbroker/grid/purge_logs.go +++ b/pkg/cloudbroker/grid/purge_logs.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // PurgeLogsRequest struct to purge logs diff --git a/pkg/cloudbroker/grid/remove_custom_backup_path.go b/pkg/cloudbroker/grid/remove_custom_backup_path.go index fd0f757..7a06b53 100644 --- a/pkg/cloudbroker/grid/remove_custom_backup_path.go +++ b/pkg/cloudbroker/grid/remove_custom_backup_path.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // RemoveCustomBackupPathRequest struct to remove path from the list of custom backup paths diff --git a/pkg/cloudbroker/grid/rename.go b/pkg/cloudbroker/grid/rename.go index 7579b5f..40e73d2 100644 --- a/pkg/cloudbroker/grid/rename.go +++ b/pkg/cloudbroker/grid/rename.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // RenameRequest struct to rename grid diff --git a/pkg/cloudbroker/grid/serialize.go b/pkg/cloudbroker/grid/serialize.go index e9bf05e..c869fd7 100644 --- a/pkg/cloudbroker/grid/serialize.go +++ b/pkg/cloudbroker/grid/serialize.go @@ -3,7 +3,7 @@ package grid import ( "encoding/json" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/serialization" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/serialization" ) // Serialize returns JSON-serialized []byte. Used as a wrapper over json.Marshal and json.MarshalIndent functions. diff --git a/pkg/cloudbroker/grid/services_restart.go b/pkg/cloudbroker/grid/services_restart.go index 5ab86f3..bc205cd 100644 --- a/pkg/cloudbroker/grid/services_restart.go +++ b/pkg/cloudbroker/grid/services_restart.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ServicesRestartRequest struct to restart services diff --git a/pkg/cloudbroker/grid/set_cpu_allocation_parameter.go b/pkg/cloudbroker/grid/set_cpu_allocation_parameter.go index 243b2f3..1d63930 100644 --- a/pkg/cloudbroker/grid/set_cpu_allocation_parameter.go +++ b/pkg/cloudbroker/grid/set_cpu_allocation_parameter.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // SetCPUAllocationParameterRequest for setting CPU allocation parameter diff --git a/pkg/cloudbroker/grid/set_cpu_allocation_ratio.go b/pkg/cloudbroker/grid/set_cpu_allocation_ratio.go index 33ec70c..8b09a5c 100644 --- a/pkg/cloudbroker/grid/set_cpu_allocation_ratio.go +++ b/pkg/cloudbroker/grid/set_cpu_allocation_ratio.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // SetCPUAllocationRatioRequest struct to set allocation diff --git a/pkg/cloudbroker/grid/set_cpu_allocation_ratio_for_vm.go b/pkg/cloudbroker/grid/set_cpu_allocation_ratio_for_vm.go index 6b698d8..9cf1012 100644 --- a/pkg/cloudbroker/grid/set_cpu_allocation_ratio_for_vm.go +++ b/pkg/cloudbroker/grid/set_cpu_allocation_ratio_for_vm.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // SetCPUAllocationRatioForVMRequest for setting CPU allocation ratio for computes diff --git a/pkg/cloudbroker/grid/set_mem_allocation_ratio.go b/pkg/cloudbroker/grid/set_mem_allocation_ratio.go index 9b7fcca..696e2cc 100644 --- a/pkg/cloudbroker/grid/set_mem_allocation_ratio.go +++ b/pkg/cloudbroker/grid/set_mem_allocation_ratio.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // SetMemAllocationRatioRequest struct to set memory allocation diff --git a/pkg/cloudbroker/grid/set_password_policy.go b/pkg/cloudbroker/grid/set_password_policy.go index a7ae125..e1473ae 100644 --- a/pkg/cloudbroker/grid/set_password_policy.go +++ b/pkg/cloudbroker/grid/set_password_policy.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // SetPasswordPolicyRequest struct to set password policy for a grid diff --git a/pkg/cloudbroker/group.go b/pkg/cloudbroker/group.go index 8585b7e..c54565a 100644 --- a/pkg/cloudbroker/group.go +++ b/pkg/cloudbroker/group.go @@ -1,6 +1,6 @@ package cloudbroker -import "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/pkg/cloudbroker/group" +import "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/pkg/cloudbroker/group" // Accessing the Group method group func (cb *CloudBroker) Group() *group.Group { diff --git a/pkg/cloudbroker/group/get.go b/pkg/cloudbroker/group/get.go index 8acd081..98578f6 100644 --- a/pkg/cloudbroker/group/get.go +++ b/pkg/cloudbroker/group/get.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // GetRequest struct to get details of the specified group. diff --git a/pkg/cloudbroker/group/group.go b/pkg/cloudbroker/group/group.go index 5069ef4..2f848b6 100644 --- a/pkg/cloudbroker/group/group.go +++ b/pkg/cloudbroker/group/group.go @@ -1,6 +1,6 @@ package group -import "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/interfaces" +import "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/interfaces" // Structure for creating request to group type Group struct { diff --git a/pkg/cloudbroker/group/list.go b/pkg/cloudbroker/group/list.go index be6cf2d..37f84bb 100644 --- a/pkg/cloudbroker/group/list.go +++ b/pkg/cloudbroker/group/list.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ListRequest struct to get list of group instances. diff --git a/pkg/cloudbroker/image.go b/pkg/cloudbroker/image.go index f12fff2..84c7638 100644 --- a/pkg/cloudbroker/image.go +++ b/pkg/cloudbroker/image.go @@ -1,7 +1,7 @@ package cloudbroker import ( - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/pkg/cloudbroker/image" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/pkg/cloudbroker/image" ) // Accessing the Image method group diff --git a/pkg/cloudbroker/image/change_storage_policy.go b/pkg/cloudbroker/image/change_storage_policy.go new file mode 100644 index 0000000..7e9130c --- /dev/null +++ b/pkg/cloudbroker/image/change_storage_policy.go @@ -0,0 +1,41 @@ +package image + +import ( + "context" + "net/http" + "strconv" + + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" +) + +type ChangeStoragePolicyRequest struct { + // ID of the image to change the storage policy + // Required: true + ImageID uint64 `url:"image_id" json:"image_id" validate:"required"` + + // ID of the storage policy to move the image to + // Required: true + StoragePolicyID uint64 `url:"storage_policy_id" json:"storage_policy_id" validate:"required"` +} + +// ChangeStoragePolicy changes the storage policy of the image chosen +func (i Image) ChangeStoragePolicy(ctx context.Context, req ChangeStoragePolicyRequest) (bool, error) { + err := validators.ValidateRequest(req) + if err != nil { + return false, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/image/change_storage_policy" + + res, err := i.client.DecortApiCall(ctx, http.MethodPost, url, req) + if err != nil { + return false, err + } + + result, err := strconv.ParseBool(string(res)) + if err != nil { + return false, err + } + + return result, nil +} diff --git a/pkg/cloudbroker/image/computeci_set.go b/pkg/cloudbroker/image/computeci_set.go index 944b365..d17fb7b 100644 --- a/pkg/cloudbroker/image/computeci_set.go +++ b/pkg/cloudbroker/image/computeci_set.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ComputeCISetRequest struct to set compute CI diff --git a/pkg/cloudbroker/image/computeci_unset.go b/pkg/cloudbroker/image/computeci_unset.go index 62ef781..0ea3508 100644 --- a/pkg/cloudbroker/image/computeci_unset.go +++ b/pkg/cloudbroker/image/computeci_unset.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ComputeCIUnsetRequest struct to unset compute CI diff --git a/pkg/cloudbroker/image/create_cdrom_image.go b/pkg/cloudbroker/image/create_cdrom_image.go index ae230d2..a7955af 100644 --- a/pkg/cloudbroker/image/create_cdrom_image.go +++ b/pkg/cloudbroker/image/create_cdrom_image.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // CreateCDROMImageRequest struct to create CD-ROM image @@ -18,6 +18,10 @@ type CreateCDROMImageRequest struct { // Required: true URL string `url:"url" json:"url" validate:"required,url"` + // ID of the chosen storage policy + // Required: true + StoragePolicyID uint64 `url:"storage_policy_id" json:"storage_policy_id" validate:"required"` + // Account ID to make the image exclusive // Required: false AccountID uint64 `url:"accountId,omitempty" json:"accountId,omitempty"` @@ -37,17 +41,6 @@ type CreateCDROMImageRequest struct { // Password for remote media download // Required: false PasswordDl string `url:"passwordDL,omitempty" json:"passwordDL,omitempty"` - - // Binary architecture of this image - // Should be one of: - // - X86_64 - // Required: false - Architecture string `url:"architecture,omitempty" json:"architecture,omitempty"` - - // List of types of compute suitable for image. - // Example: [ "KVM_X86" ] - // Required: false - Drivers []string `url:"drivers,omitempty" json:"drivers,omitempty" validate:"max=2,imageDrivers"` } // CreateCDROMImage creates CD-ROM image from an ISO identified by URL diff --git a/pkg/cloudbroker/image/create_image.go b/pkg/cloudbroker/image/create_image.go index afe0f28..4c42b17 100644 --- a/pkg/cloudbroker/image/create_image.go +++ b/pkg/cloudbroker/image/create_image.go @@ -2,15 +2,16 @@ package image import ( "context" + "encoding/json" "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // CreateRequest struct to create image type CreateRequest struct { - // Name of the rescue disk + // Name of the image // Required: true Name string `url:"name" json:"name" validate:"required"` @@ -33,6 +34,10 @@ type CreateRequest struct { // Required: true ImageType string `url:"imagetype" json:"imagetype" validate:"required,imageType"` + // ID of the chosen storage policy + // Required: true + StoragePolicyID uint64 `url:"storage_policy_id" json:"storage_policy_id" validate:"required"` + // Select a network interface naming pattern for your Linux machine. eth - onboard, ens - pci slot naming // Should be: // - eth @@ -72,22 +77,16 @@ type CreateRequest struct { // Required: false PoolName string `url:"poolName,omitempty" json:"poolName,omitempty"` - // Binary architecture of this image - // Should be one of: - // - X86_64 - // Required: false - Architecture string `url:"architecture,omitempty" json:"architecture,omitempty"` - - // List of types of compute suitable for image - // Example: [ "KVM_X86" ] - // Required: required - Drivers []string `url:"drivers" json:"drivers" validate:"min=1,max=2,imageDrivers"` - // Bootable image or not // Required: false Bootable bool `url:"bootable,omitempty" json:"bootable,omitempty"` } +type asyncWrapperCreateRequest struct { + CreateRequest + AsyncMode bool `url:"asyncMode"` +} + // CreateImage creates image from a media identified by URL func (i Image) CreateImage(ctx context.Context, req CreateRequest) (uint64, error) { err := validators.ValidateRequest(req) @@ -97,7 +96,9 @@ func (i Image) CreateImage(ctx context.Context, req CreateRequest) (uint64, erro url := "/cloudbroker/image/createImage" - res, err := i.client.DecortApiCall(ctx, http.MethodPost, url, req) + syncReq := asyncWrapperCreateRequest{CreateRequest: req, AsyncMode: false} + + res, err := i.client.DecortApiCall(ctx, http.MethodPost, url, syncReq) if err != nil { return 0, err } @@ -109,3 +110,29 @@ func (i Image) CreateImage(ctx context.Context, req CreateRequest) (uint64, erro return result, nil } + +// AsyncCreate creates image from a media identified by URL in async mode +func (i Image) AsyncCreateImage(ctx context.Context, req CreateRequest) (string, error) { + err := validators.ValidateRequest(req) + if err != nil { + return "", validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/image/createImage" + + asyncReq := asyncWrapperCreateRequest{CreateRequest: req, AsyncMode: true} + + res, err := i.client.DecortApiCall(ctx, http.MethodPost, url, asyncReq) + if err != nil { + return " ", err + } + + var taskID string + + err = json.Unmarshal(res, &taskID) + if err != nil { + return "", err + } + + return taskID, nil +} diff --git a/pkg/cloudbroker/image/create_virtual.go b/pkg/cloudbroker/image/create_virtual.go index da8d11b..08da322 100644 --- a/pkg/cloudbroker/image/create_virtual.go +++ b/pkg/cloudbroker/image/create_virtual.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // CreateVirtualRequest struct to create virtual image @@ -17,6 +17,11 @@ type CreateVirtualRequest struct { // ID of real image to link this virtual image to upon creation // Required: true TargetID uint64 `url:"targetId" json:"targetId" validate:"required"` + + // AccountID to make the virtual image exclusive + // Required: false + // Default: 0 + AccountID uint64 `url:"accountId,omitempty" json:"accountId,omitempty"` } // CreateVirtual creates virtual image diff --git a/pkg/cloudbroker/image/delete.go b/pkg/cloudbroker/image/delete.go index a69bd2b..b767973 100644 --- a/pkg/cloudbroker/image/delete.go +++ b/pkg/cloudbroker/image/delete.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // DeleteRequest struct to delete image diff --git a/pkg/cloudbroker/image/delete_cdrom_image.go b/pkg/cloudbroker/image/delete_cdrom_image.go index 9ea2254..ea36ac7 100644 --- a/pkg/cloudbroker/image/delete_cdrom_image.go +++ b/pkg/cloudbroker/image/delete_cdrom_image.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // DeleteCDROMImageRequest struct to delete CD-ROM image diff --git a/pkg/cloudbroker/image/delete_images.go b/pkg/cloudbroker/image/delete_images.go index 9f9a723..a0fce32 100644 --- a/pkg/cloudbroker/image/delete_images.go +++ b/pkg/cloudbroker/image/delete_images.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // DeleteImagesRequest struct to delete images diff --git a/pkg/cloudbroker/image/disable.go b/pkg/cloudbroker/image/disable.go index 8fd7859..5e1b15d 100644 --- a/pkg/cloudbroker/image/disable.go +++ b/pkg/cloudbroker/image/disable.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // DisableRequest struct to disable image diff --git a/pkg/cloudbroker/image/edit.go b/pkg/cloudbroker/image/edit.go index 6106802..92c49f0 100644 --- a/pkg/cloudbroker/image/edit.go +++ b/pkg/cloudbroker/image/edit.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // EditRequest struct to edit image diff --git a/pkg/cloudbroker/image/enable.go b/pkg/cloudbroker/image/enable.go index aa86fd1..8b326b0 100644 --- a/pkg/cloudbroker/image/enable.go +++ b/pkg/cloudbroker/image/enable.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // EnableRequest struct to enable image diff --git a/pkg/cloudbroker/image/get.go b/pkg/cloudbroker/image/get.go index 95ee7c0..89c1788 100644 --- a/pkg/cloudbroker/image/get.go +++ b/pkg/cloudbroker/image/get.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // GetRequest struct to get image details diff --git a/pkg/cloudbroker/image/grant_access.go b/pkg/cloudbroker/image/grant_access.go index ddca871..e6263e1 100644 --- a/pkg/cloudbroker/image/grant_access.go +++ b/pkg/cloudbroker/image/grant_access.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // GrantAccessRequest struct to share image with accounts diff --git a/pkg/cloudbroker/image/image.go b/pkg/cloudbroker/image/image.go index 2795463..ee898ea 100644 --- a/pkg/cloudbroker/image/image.go +++ b/pkg/cloudbroker/image/image.go @@ -1,7 +1,7 @@ // Lists all the images. A image is a template which can be used to deploy machines package image -import "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/interfaces" +import "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/interfaces" // Structure for creating request to image type Image struct { diff --git a/pkg/cloudbroker/image/link.go b/pkg/cloudbroker/image/link.go index 471c117..e3e2433 100644 --- a/pkg/cloudbroker/image/link.go +++ b/pkg/cloudbroker/image/link.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // LinkRequest struct to link virtual image to another image diff --git a/pkg/cloudbroker/image/list.go b/pkg/cloudbroker/image/list.go index f38f14b..4001a4d 100644 --- a/pkg/cloudbroker/image/list.go +++ b/pkg/cloudbroker/image/list.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ListRequest struct to get list of available images @@ -26,10 +26,6 @@ type ListRequest struct { // Required: false Status string `url:"status,omitempty" json:"status,omitempty"` - // Find by architecture - // Required: false - Architecture string `url:"architecture,omitempty" json:"architecture,omitempty"` - // Find by type // Required: false TypeImage string `url:"typeImage,omitempty" json:"typeImage,omitempty"` @@ -73,6 +69,10 @@ type ListRequest struct { // Find by enabled True or False // Required: false Enabled interface{} `url:"enabled,omitempty" json:"enabled,omitempty" validate:"omitempty,isBool"` + + // Find by storage policy id + // Required: false + StoragePolicyID uint64 `url:"storage_policy_id,omitempty" json:"storage_policy_id,omitempty"` } // List gets list of information about images as a ListImages struct diff --git a/pkg/cloudbroker/image/list_stacks.go b/pkg/cloudbroker/image/list_stacks.go index c51e40c..28989aa 100644 --- a/pkg/cloudbroker/image/list_stacks.go +++ b/pkg/cloudbroker/image/list_stacks.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ListStacksRequest struct to get list of stack diff --git a/pkg/cloudbroker/image/models.go b/pkg/cloudbroker/image/models.go index 6ace868..c094a9d 100644 --- a/pkg/cloudbroker/image/models.go +++ b/pkg/cloudbroker/image/models.go @@ -110,6 +110,9 @@ type RecordImage struct { // Status Status string `json:"status"` + // Storage policy ID + StoragePolicyID uint64 `json:"storage_policy_id"` + // Tech status TechStatus string `json:"techStatus"` @@ -236,6 +239,9 @@ type ItemImage struct { // Status Status string `json:"status"` + // Storage policy ID + StoragePolicyID uint64 `json:"storage_policy_id"` + // Tech status TechStatus string `json:"techStatus"` @@ -331,9 +337,6 @@ type ItemListStacks struct { // CKey CKey string `json:"_ckey"` - // Meta - Meta []interface{} `json:"_meta"` - // API URL APIURL string `json:"apiUrl"` diff --git a/pkg/cloudbroker/image/rename.go b/pkg/cloudbroker/image/rename.go index de50a5e..93ddc0d 100644 --- a/pkg/cloudbroker/image/rename.go +++ b/pkg/cloudbroker/image/rename.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // RenameRequest struct to rename image diff --git a/pkg/cloudbroker/image/revoke_access.go b/pkg/cloudbroker/image/revoke_access.go index 3b8df29..43a3622 100644 --- a/pkg/cloudbroker/image/revoke_access.go +++ b/pkg/cloudbroker/image/revoke_access.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // RevokeAccessRequest struct to unshare image with accounts diff --git a/pkg/cloudbroker/image/serialize.go b/pkg/cloudbroker/image/serialize.go index f1b482a..04ac4fb 100644 --- a/pkg/cloudbroker/image/serialize.go +++ b/pkg/cloudbroker/image/serialize.go @@ -3,7 +3,7 @@ package image import ( "encoding/json" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/serialization" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/serialization" ) // Serialize returns JSON-serialized []byte. Used as a wrapper over json.Marshal and json.MarshalIndent functions. diff --git a/pkg/cloudbroker/image/share.go b/pkg/cloudbroker/image/share.go index 208d3a3..f8acef1 100644 --- a/pkg/cloudbroker/image/share.go +++ b/pkg/cloudbroker/image/share.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ShareRequest struct to share image diff --git a/pkg/cloudbroker/image/sync_create_image.go b/pkg/cloudbroker/image/sync_create_image.go deleted file mode 100644 index c2939fd..0000000 --- a/pkg/cloudbroker/image/sync_create_image.go +++ /dev/null @@ -1,111 +0,0 @@ -package image - -import ( - "context" - "net/http" - "strconv" - - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" -) - -// SyncCreateRequest struct to sync create image -type SyncCreateRequest struct { - // Name of the rescue disk - // Required: true - Name string `url:"name" json:"name" validate:"required"` - - // URL where to download media from - // Required: true - URL string `url:"url" json:"url" validate:"required"` - - // Boot type of image - // Should be one of: - // - bios - // - UEFI - // Required: true - BootType string `url:"boottype" json:"boottype" validate:"required,imageBootType"` - - // Image type - // Should be one of: - // - linux - // - windows - // - or other - // Required: true - ImageType string `url:"imagetype" json:"imagetype" validate:"required,imageType"` - - // Select a network interface naming pattern for your Linux machine. eth - onboard, ens - pci slot naming - // Should be: - // - eth - // - ens (default value) - // Required: false - NetworkInterfaceNaming string `url:"networkInterfaceNaming,omitempty" json:"networkInterfaceNaming,omitempty" validate:"omitempty,networkInterfaceNaming"` - - // Does this machine supports hot resize - // Required: false - HotResize bool `url:"hotresize,omitempty" json:"hotresize,omitempty"` - - // Optional username for the image - // Required: false - Username string `url:"username,omitempty" json:"username,omitempty"` - - // Optional password for the image - // Required: false - Password string `url:"password,omitempty" json:"password,omitempty"` - - // Account ID to make the image exclusive - // Required: false - AccountID uint64 `url:"accountId,omitempty" json:"accountId,omitempty"` - - // Username for upload binary media - // Required: false - UsernameDL string `url:"usernameDL,omitempty" json:"usernameDL,omitempty"` - - // Password for upload binary media - // Required: false - PasswordDL string `url:"passwordDL,omitempty" json:"passwordDL,omitempty"` - - // Storage endpoint provider ID - // Required: false - SEPID uint64 `url:"sepId,omitempty" json:"sepId,omitempty"` - - // Pool for image create - // Required: false - PoolName string `url:"poolName,omitempty" json:"poolName,omitempty"` - - // Binary architecture of this image - // Should be one of: - // - X86_64 - // Required: false - Architecture string `url:"architecture,omitempty" json:"architecture,omitempty"` - - // List of types of compute suitable for image - // Example: [ "KVM_X86" ] - // Required: true - Drivers []string `url:"drivers" json:"drivers" validate:"min=1,max=2,imageDrivers"` - - // Bootable image or not - // Required: false - Bootable bool `url:"bootable,omitempty" json:"bootable,omitempty"` -} - -// SyncCreate creates image from a media identified by URL (in synchronous mode) -func (i Image) SyncCreate(ctx context.Context, req SyncCreateRequest) (uint64, error) { - err := validators.ValidateRequest(req) - if err != nil { - return 0, validators.ValidationErrors(validators.GetErrors(err)) - } - - url := "/cloudbroker/image/syncCreateImage" - - res, err := i.client.DecortApiCall(ctx, http.MethodPost, url, req) - if err != nil { - return 0, err - } - - result, err := strconv.ParseUint(string(res), 10, 64) - if err != nil { - return 0, err - } - - return result, nil -} diff --git a/pkg/cloudbroker/image/update_nodes.go b/pkg/cloudbroker/image/update_nodes.go deleted file mode 100644 index c89b157..0000000 --- a/pkg/cloudbroker/image/update_nodes.go +++ /dev/null @@ -1,42 +0,0 @@ -package image - -import ( - "context" - "net/http" - "strconv" - - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" -) - -// UpdateNodesRequest struct to update nodes -type UpdateNodesRequest struct { - // Image ID - // Required: true - ImageID uint64 `url:"imageId" json:"imageId" validate:"required"` - - // List of stacks - // Required: false - EnabledStacks []uint64 `url:"enabledStacks,omitempty" json:"enabledStacks,omitempty"` -} - -// UpdateNodes updates image availability on nodes -func (i Image) UpdateNodes(ctx context.Context, req UpdateNodesRequest) (bool, error) { - err := validators.ValidateRequest(req) - if err != nil { - return false, validators.ValidationErrors(validators.GetErrors(err)) - } - - url := "/cloudbroker/image/updateNodes" - - res, err := i.client.DecortApiCall(ctx, http.MethodPost, url, req) - if err != nil { - return false, err - } - - result, err := strconv.ParseBool(string(res)) - if err != nil { - return false, err - } - - return result, nil -} diff --git a/pkg/cloudbroker/k8ci.go b/pkg/cloudbroker/k8ci.go index 14f09ad..265f6dc 100644 --- a/pkg/cloudbroker/k8ci.go +++ b/pkg/cloudbroker/k8ci.go @@ -1,7 +1,7 @@ package cloudbroker import ( - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/pkg/cloudbroker/k8ci" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/pkg/cloudbroker/k8ci" ) // Accessing the K8CI method group diff --git a/pkg/cloudbroker/k8ci/access_add.go b/pkg/cloudbroker/k8ci/access_add.go index 0773813..87233d8 100644 --- a/pkg/cloudbroker/k8ci/access_add.go +++ b/pkg/cloudbroker/k8ci/access_add.go @@ -4,7 +4,7 @@ import ( "context" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // AccessAddRequest struct for adding permission to access to account for a k8ci diff --git a/pkg/cloudbroker/k8ci/access_remove.go b/pkg/cloudbroker/k8ci/access_remove.go index c2efa2d..6b42c1a 100644 --- a/pkg/cloudbroker/k8ci/access_remove.go +++ b/pkg/cloudbroker/k8ci/access_remove.go @@ -4,7 +4,7 @@ import ( "context" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // AccessRemoveRequest struct for removing permission to access to account for a k8ci diff --git a/pkg/cloudbroker/k8ci/create.go b/pkg/cloudbroker/k8ci/create.go index 8d7663a..e8b1cc7 100644 --- a/pkg/cloudbroker/k8ci/create.go +++ b/pkg/cloudbroker/k8ci/create.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // CreateRequest struct to create K8CI instance @@ -26,24 +26,10 @@ type CreateRequest struct { // Required: true MasterImageID uint64 `url:"masterImageId" json:"masterImageId" validate:"required"` - // Compute driver - // Should be one of: - // - KVM_X86 - // - etc - // Required: true - MasterDriver string `url:"masterDriver" json:"masterDriver" validate:"driver"` - // Image ID for worker K8S node // Required: true WorkerImageID uint64 `url:"workerImageId" json:"workerImageId" validate:"required"` - // Compute driver - // Should be one of - // - KVM_X86 - // - etc - // Required: true - WorkerDriver string `url:"workerDriver" json:"workerDriver" validate:"driver"` - // List of account IDs, which have access to this item. // If empty, any account has access // Required: false diff --git a/pkg/cloudbroker/k8ci/delete.go b/pkg/cloudbroker/k8ci/delete.go index 62b6927..70bc363 100644 --- a/pkg/cloudbroker/k8ci/delete.go +++ b/pkg/cloudbroker/k8ci/delete.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // DeleteRequest struct to delete K8CI diff --git a/pkg/cloudbroker/k8ci/disable.go b/pkg/cloudbroker/k8ci/disable.go index f0724bf..f7744eb 100644 --- a/pkg/cloudbroker/k8ci/disable.go +++ b/pkg/cloudbroker/k8ci/disable.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // DisableRequest struct to disable K8CI diff --git a/pkg/cloudbroker/k8ci/enable.go b/pkg/cloudbroker/k8ci/enable.go index 149f76c..460555a 100644 --- a/pkg/cloudbroker/k8ci/enable.go +++ b/pkg/cloudbroker/k8ci/enable.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // EnableRequest struct to enable K8CI diff --git a/pkg/cloudbroker/k8ci/filter_test.go b/pkg/cloudbroker/k8ci/filter_test.go index fbaa6d4..5df0376 100644 --- a/pkg/cloudbroker/k8ci/filter_test.go +++ b/pkg/cloudbroker/k8ci/filter_test.go @@ -12,7 +12,6 @@ var k8ciItems = ListK8CI{ GUID: 1, ID: 1, LBImageID: 5, - MasterDriver: "KVM_X86", MasterImageID: 120, MaxMasterCount: 2, MaxWorkerCount: 3, @@ -20,7 +19,6 @@ var k8ciItems = ListK8CI{ SharedWith: []uint64{}, Status: "ENABLED", Version: "1", - WorkerDriver: "KVM_X86", WorkerImageID: 120, }, }, @@ -32,7 +30,6 @@ var k8ciItems = ListK8CI{ GUID: 2, ID: 2, LBImageID: 10, - MasterDriver: "KVM_X86", MasterImageID: 121, MaxMasterCount: 3, MaxWorkerCount: 5, @@ -40,7 +37,6 @@ var k8ciItems = ListK8CI{ SharedWith: []uint64{}, Status: "DISABLED", Version: "2", - WorkerDriver: "KVM_X86", WorkerImageID: 121, }, }, @@ -52,7 +48,6 @@ var k8ciItems = ListK8CI{ GUID: 3, ID: 3, LBImageID: 12, - MasterDriver: "KVM_X86", MasterImageID: 98, MaxMasterCount: 5, MaxWorkerCount: 9, @@ -60,7 +55,6 @@ var k8ciItems = ListK8CI{ SharedWith: []uint64{}, Status: "ENABLED", Version: "3", - WorkerDriver: "KVM_X86", WorkerImageID: 98, }, }, diff --git a/pkg/cloudbroker/k8ci/get.go b/pkg/cloudbroker/k8ci/get.go index dacbe00..cf1d7cb 100644 --- a/pkg/cloudbroker/k8ci/get.go +++ b/pkg/cloudbroker/k8ci/get.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // GetRequest struct to get information about K8CI diff --git a/pkg/cloudbroker/k8ci/k8ci.go b/pkg/cloudbroker/k8ci/k8ci.go index f181192..5424488 100644 --- a/pkg/cloudbroker/k8ci/k8ci.go +++ b/pkg/cloudbroker/k8ci/k8ci.go @@ -2,7 +2,7 @@ package k8ci import ( - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/interfaces" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/interfaces" ) // Structure for creating request to K8CI diff --git a/pkg/cloudbroker/k8ci/list.go b/pkg/cloudbroker/k8ci/list.go index 99f9177..5da8ad3 100644 --- a/pkg/cloudbroker/k8ci/list.go +++ b/pkg/cloudbroker/k8ci/list.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ListRequest struct to get list information about images @@ -22,14 +22,6 @@ type ListRequest struct { // Required: false Status string `url:"status,omitempty" json:"status,omitempty"` - // Find by worker driver - // Required: false - WorkerDriver string `url:"workerDriver,omitempty" json:"workerDriver,omitempty"` - - // Find by master driver - // Required: false - MasterDriver string `url:"masterDriver,omitempty" json:"masterDriver,omitempty"` - // Find by network plugin // Required: false NetworkPlugins string `url:"netPlugins,omitempty" json:"masterDrnetPluginsiver,omitempty"` diff --git a/pkg/cloudbroker/k8ci/list_deleted.go b/pkg/cloudbroker/k8ci/list_deleted.go index 6ca5e1f..91761b1 100644 --- a/pkg/cloudbroker/k8ci/list_deleted.go +++ b/pkg/cloudbroker/k8ci/list_deleted.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ListDeletedRequest struct to get list information about deleted k8ci items @@ -18,14 +18,6 @@ type ListDeletedRequest struct { // Required: false Name string `url:"name,omitempty" json:"name,omitempty"` - // Find by worker driver - // Required: false - WorkerDriver string `url:"workerDriver,omitempty" json:"workerDriver,omitempty"` - - // Find by master driver - // Required: false - MasterDriver string `url:"masterDriver,omitempty" json:"masterDriver,omitempty"` - // Find by network plugin // Required: false NetworkPlugins string `url:"netPlugins,omitempty" json:"netPlugins,omitempty"` diff --git a/pkg/cloudbroker/k8ci/models.go b/pkg/cloudbroker/k8ci/models.go index 647956b..cdeb03b 100644 --- a/pkg/cloudbroker/k8ci/models.go +++ b/pkg/cloudbroker/k8ci/models.go @@ -34,9 +34,6 @@ type RecordK8CIList struct { // Load balancer image ID LBImageID uint64 `json:"lbImageId"` - // Master driver - MasterDriver string `json:"masterDriver"` - // Master image ID MasterImageID uint64 `json:"masterImageId"` @@ -58,14 +55,11 @@ type RecordK8CIList struct { // Version Version string `json:"version"` - // Worker driver - WorkerDriver string `json:"workerDriver"` - // Worker image ID WorkerImageID uint64 `json:"workerImageId"` } -// Detailed information about K8CI +// Detailed information about K8CI type RecordK8CI struct { // Description Description string `json:"desc"` @@ -82,12 +76,12 @@ type RecordK8CI struct { // Load balancer image ID LBImageID uint64 `json:"lbImageId"` - // Master driver - MasterDriver string `json:"masterDriver"` - // Master image ID MasterImageID uint64 `json:"masterImageId"` + // Master driver + MasterDriver string `json:"masterDriver"` + // Max master count MaxMasterCount uint64 `json:"maxMasterCount"` @@ -112,9 +106,9 @@ type RecordK8CI struct { // Version Version string `json:"version"` - // Worker driver - WorkerDriver string `json:"workerDriver"` - // Worker image ID WorkerImageID uint64 `json:"workerImageId"` + + // Worker driver + WorkerDriver string `json:"workerDriver"` } diff --git a/pkg/cloudbroker/k8ci/restore.go b/pkg/cloudbroker/k8ci/restore.go index 64b82d6..ce11e40 100644 --- a/pkg/cloudbroker/k8ci/restore.go +++ b/pkg/cloudbroker/k8ci/restore.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // RestoreRequest struct to restore K8CI diff --git a/pkg/cloudbroker/k8ci/serialize.go b/pkg/cloudbroker/k8ci/serialize.go index f5d61be..b33c48a 100644 --- a/pkg/cloudbroker/k8ci/serialize.go +++ b/pkg/cloudbroker/k8ci/serialize.go @@ -3,7 +3,7 @@ package k8ci import ( "encoding/json" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/serialization" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/serialization" ) // Serialize returns JSON-serialized []byte. Used as a wrapper over json.Marshal and json.MarshalIndent functions. diff --git a/pkg/cloudbroker/k8s.go b/pkg/cloudbroker/k8s.go index 251f2e5..c21ccde 100644 --- a/pkg/cloudbroker/k8s.go +++ b/pkg/cloudbroker/k8s.go @@ -1,7 +1,7 @@ package cloudbroker import ( - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/pkg/cloudbroker/k8s" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/pkg/cloudbroker/k8s" ) // Accessing the K8S method group diff --git a/pkg/cloudbroker/k8s/create.go b/pkg/cloudbroker/k8s/create.go index e291f19..7f75df3 100644 --- a/pkg/cloudbroker/k8s/create.go +++ b/pkg/cloudbroker/k8s/create.go @@ -5,7 +5,7 @@ import ( "net/http" "strings" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // CreateRequest struct to create K8S @@ -31,6 +31,10 @@ type CreateRequest struct { // Required: true NetworkPlugin string `url:"networkPlugin" json:"networkPlugin" validate:"required,networkPlugin"` + // ID of the chosen storage policy + // Required: true + StoragePolicyID uint64 `url:"storage_policy_id" json:"storage_policy_id" validate:"required"` + // ID of SEP to create boot disks for master nodes. // Uses images SEP ID if not set // Required: false @@ -168,6 +172,10 @@ type CreateRequest struct { // Type of the emulated system, Q35 or i440fx // Required: false Chipset string `url:"chipset,omitempty" json:"chipset,omitempty" validate:"omitempty,chipset"` + + // Zone ID + // Required: false + ZoneID uint64 `url:"zoneId,omitempty" json:"zoneId,omitempty"` } // GetRAM returns RAM values diff --git a/pkg/cloudbroker/k8s/delete.go b/pkg/cloudbroker/k8s/delete.go index 38a4a77..8b7856d 100644 --- a/pkg/cloudbroker/k8s/delete.go +++ b/pkg/cloudbroker/k8s/delete.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // DeleteRequest struct to delete kubernetes cluster diff --git a/pkg/cloudbroker/k8s/delete_master_from_group.go b/pkg/cloudbroker/k8s/delete_master_from_group.go index 655c99a..8eea25f 100644 --- a/pkg/cloudbroker/k8s/delete_master_from_group.go +++ b/pkg/cloudbroker/k8s/delete_master_from_group.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // DeleteMasterFromGroupRequest struct to delete master from group diff --git a/pkg/cloudbroker/k8s/delete_worker_from_group.go b/pkg/cloudbroker/k8s/delete_worker_from_group.go index a07c059..8505b0f 100644 --- a/pkg/cloudbroker/k8s/delete_worker_from_group.go +++ b/pkg/cloudbroker/k8s/delete_worker_from_group.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // DeleteWorkerFromGroupRequest struct to delete worker from group diff --git a/pkg/cloudbroker/k8s/disable.go b/pkg/cloudbroker/k8s/disable.go index 2eb9e88..cc5c610 100644 --- a/pkg/cloudbroker/k8s/disable.go +++ b/pkg/cloudbroker/k8s/disable.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // DisableRequest struct to disable kubernetes cluster diff --git a/pkg/cloudbroker/k8s/enable.go b/pkg/cloudbroker/k8s/enable.go index baef340..416ec70 100644 --- a/pkg/cloudbroker/k8s/enable.go +++ b/pkg/cloudbroker/k8s/enable.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // EnableRequest struct to enable kubernetes cluster diff --git a/pkg/cloudbroker/k8s/find_group_by_label.go b/pkg/cloudbroker/k8s/find_group_by_label.go index 0e974f3..c2aa160 100644 --- a/pkg/cloudbroker/k8s/find_group_by_label.go +++ b/pkg/cloudbroker/k8s/find_group_by_label.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // FindGroupByLabelRequest struct for get information about group of kubernetes cluster diff --git a/pkg/cloudbroker/k8s/get.go b/pkg/cloudbroker/k8s/get.go index a66a0a6..f9860f0 100644 --- a/pkg/cloudbroker/k8s/get.go +++ b/pkg/cloudbroker/k8s/get.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // GetRequest struct to get detailed information about kubernetes cluster diff --git a/pkg/cloudbroker/k8s/get_config.go b/pkg/cloudbroker/k8s/get_config.go index e1087a7..e50e333 100644 --- a/pkg/cloudbroker/k8s/get_config.go +++ b/pkg/cloudbroker/k8s/get_config.go @@ -5,7 +5,7 @@ import ( "net/http" "strings" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // GetConfigRequest struct to get configuration of kubernetes cluster diff --git a/pkg/cloudbroker/k8s/get_node_annotations.go b/pkg/cloudbroker/k8s/get_node_annotations.go index 2cd018b..7790db1 100644 --- a/pkg/cloudbroker/k8s/get_node_annotations.go +++ b/pkg/cloudbroker/k8s/get_node_annotations.go @@ -5,7 +5,7 @@ import ( "net/http" "strings" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // GetNodeAnnotationsRequest struct to get node annotations diff --git a/pkg/cloudbroker/k8s/get_node_labels.go b/pkg/cloudbroker/k8s/get_node_labels.go index 033bc18..01c0fbb 100644 --- a/pkg/cloudbroker/k8s/get_node_labels.go +++ b/pkg/cloudbroker/k8s/get_node_labels.go @@ -5,7 +5,7 @@ import ( "net/http" "strings" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // GetNodeLabelsRequest struct to get worker node labels diff --git a/pkg/cloudbroker/k8s/get_node_taints.go b/pkg/cloudbroker/k8s/get_node_taints.go index 9cec4bc..d64e8c2 100644 --- a/pkg/cloudbroker/k8s/get_node_taints.go +++ b/pkg/cloudbroker/k8s/get_node_taints.go @@ -5,7 +5,7 @@ import ( "net/http" "strings" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // GetNodeTaintsRequest struct to get node taints diff --git a/pkg/cloudbroker/k8s/get_worker_nodes_meta_data.go b/pkg/cloudbroker/k8s/get_worker_nodes_meta_data.go index e7d955e..a9c5dc9 100644 --- a/pkg/cloudbroker/k8s/get_worker_nodes_meta_data.go +++ b/pkg/cloudbroker/k8s/get_worker_nodes_meta_data.go @@ -4,7 +4,7 @@ import ( "context" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // GetWorkerNodesMetaDataRequest struct to get worker group metadata by ID diff --git a/pkg/cloudbroker/k8s/k8s.go b/pkg/cloudbroker/k8s/k8s.go index ed55b4c..d5526cb 100644 --- a/pkg/cloudbroker/k8s/k8s.go +++ b/pkg/cloudbroker/k8s/k8s.go @@ -2,7 +2,7 @@ package k8s import ( - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/interfaces" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/interfaces" ) // Structure for creating request to K8S diff --git a/pkg/cloudbroker/k8s/list.go b/pkg/cloudbroker/k8s/list.go index cf782f1..ba8f3b6 100644 --- a/pkg/cloudbroker/k8s/list.go +++ b/pkg/cloudbroker/k8s/list.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ListRequest struct to get list information K8S @@ -50,6 +50,11 @@ type ListRequest struct { // Required: false SortBy string `url:"sortBy,omitempty" json:"sortBy,omitempty" validate:"omitempty,sortBy"` + // Sort by zone id + // Default value: 0 + // Required: false + ZoneID uint64 `url:"zone_id,omitempty" json:"zone_id,omitempty"` + // Page number // Required: false Page uint64 `url:"page,omitempty" json:"page,omitempty"` diff --git a/pkg/cloudbroker/k8s/list_deleted.go b/pkg/cloudbroker/k8s/list_deleted.go index ac9651a..9ba639f 100644 --- a/pkg/cloudbroker/k8s/list_deleted.go +++ b/pkg/cloudbroker/k8s/list_deleted.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ListDeletedRequest struct to get list of deleted kubernetes cluster diff --git a/pkg/cloudbroker/k8s/migrate_to_zone.go b/pkg/cloudbroker/k8s/migrate_to_zone.go new file mode 100644 index 0000000..dc82a46 --- /dev/null +++ b/pkg/cloudbroker/k8s/migrate_to_zone.go @@ -0,0 +1,42 @@ +package k8s + +import ( + "context" + "net/http" + "strconv" + + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" +) + +// MigrateToZone struct to move k8s cluster to another zone +type MigrateToZoneRequest struct { + // Kubernetes cluster ID to move + // Required: true + K8SID uint64 `url:"k8sId" json:"k8sId" validate:"required"` + + // ID of the zone to move + // Required: true + ZoneID uint64 `url:"zoneId" json:"zoneId" validate:"required"` +} + +// MigrateToZone moves k8s cluster instance to new zone +func (k8s K8S) MigrateToZone(ctx context.Context, req MigrateToZoneRequest) (bool, error) { + err := validators.ValidateRequest(req) + if err != nil { + return false, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/k8s/migrateToZone" + + res, err := k8s.client.DecortApiCall(ctx, http.MethodPost, url, req) + if err != nil { + return false, err + } + + result, err := strconv.ParseBool(string(res)) + if err != nil { + return false, err + } + + return result, nil +} diff --git a/pkg/cloudbroker/k8s/models.go b/pkg/cloudbroker/k8s/models.go index ec180c1..f3d5fbe 100644 --- a/pkg/cloudbroker/k8s/models.go +++ b/pkg/cloudbroker/k8s/models.go @@ -139,6 +139,9 @@ type RecordK8S struct { // With LB WithLB bool `json:"withLB"` + + // Zone ID + ZoneID uint64 `json:"zoneId"` } // Detailed info about address of the Virtual Internet Protocol @@ -307,6 +310,9 @@ type ItemK8S struct { // List workers WorkersGroup ListK8SGroup `json:"workersGroups"` + + // Zone ID + ZoneID uint64 `json:"zoneId"` } // Service account diff --git a/pkg/cloudbroker/k8s/restore.go b/pkg/cloudbroker/k8s/restore.go index c9daf1b..0331cd0 100644 --- a/pkg/cloudbroker/k8s/restore.go +++ b/pkg/cloudbroker/k8s/restore.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // RestoreRequest struct to restore kubernetes cluster diff --git a/pkg/cloudbroker/k8s/serialize.go b/pkg/cloudbroker/k8s/serialize.go index 3aa4334..e6ee662 100644 --- a/pkg/cloudbroker/k8s/serialize.go +++ b/pkg/cloudbroker/k8s/serialize.go @@ -3,7 +3,7 @@ package k8s import ( "encoding/json" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/serialization" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/serialization" ) // Serialize returns JSON-serialized []byte. Used as a wrapper over json.Marshal and json.MarshalIndent functions. diff --git a/pkg/cloudbroker/k8s/start.go b/pkg/cloudbroker/k8s/start.go index eb80d45..509cc49 100644 --- a/pkg/cloudbroker/k8s/start.go +++ b/pkg/cloudbroker/k8s/start.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // StartRequest struct to start kubernetes cluster diff --git a/pkg/cloudbroker/k8s/stop.go b/pkg/cloudbroker/k8s/stop.go index ceddf49..bb54469 100644 --- a/pkg/cloudbroker/k8s/stop.go +++ b/pkg/cloudbroker/k8s/stop.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // StopRequest struct to stop kubernetes cluster diff --git a/pkg/cloudbroker/k8s/update.go b/pkg/cloudbroker/k8s/update.go index baa05a1..7d7a201 100644 --- a/pkg/cloudbroker/k8s/update.go +++ b/pkg/cloudbroker/k8s/update.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // UpdateRequest struct to update kubernetes cluster diff --git a/pkg/cloudbroker/k8s/update_worker_nodes_meta_data.go b/pkg/cloudbroker/k8s/update_worker_nodes_meta_data.go index 0df5451..815ff97 100644 --- a/pkg/cloudbroker/k8s/update_worker_nodes_meta_data.go +++ b/pkg/cloudbroker/k8s/update_worker_nodes_meta_data.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // UpdateWorkerNodesMetaDataRequest struct to add worker to a kubernetes cluster diff --git a/pkg/cloudbroker/k8s/worker_add.go b/pkg/cloudbroker/k8s/worker_add.go index 8ab7d41..942c5b4 100644 --- a/pkg/cloudbroker/k8s/worker_add.go +++ b/pkg/cloudbroker/k8s/worker_add.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // WorkerAddRequest struct to add worker to a kubernetes cluster diff --git a/pkg/cloudbroker/k8s/worker_reset.go b/pkg/cloudbroker/k8s/worker_reset.go index e6efe64..50687b4 100644 --- a/pkg/cloudbroker/k8s/worker_reset.go +++ b/pkg/cloudbroker/k8s/worker_reset.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // WorkerResetRequest struct for hard reset kubernetes cluster diff --git a/pkg/cloudbroker/k8s/worker_restart.go b/pkg/cloudbroker/k8s/worker_restart.go index 4e1a52e..f9b63a2 100644 --- a/pkg/cloudbroker/k8s/worker_restart.go +++ b/pkg/cloudbroker/k8s/worker_restart.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // WorkerRestartRequest struct to restart worker node diff --git a/pkg/cloudbroker/k8s/workers_group_add.go b/pkg/cloudbroker/k8s/workers_group_add.go index 4103071..8752fe9 100644 --- a/pkg/cloudbroker/k8s/workers_group_add.go +++ b/pkg/cloudbroker/k8s/workers_group_add.go @@ -5,7 +5,7 @@ import ( "net/http" "strings" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // WorkersGroupAddRequest struct to add workers group @@ -18,6 +18,10 @@ type WorkersGroupAddRequest struct { // Required: true Name string `url:"name" json:"name" validate:"required"` + // ID of the chosen storage policy + // Required: true + StoragePolicyID uint64 `url:"storage_policy_id" json:"storage_policy_id" validate:"required"` + // ID of SEP to create boot disks for default worker nodes group. // Uses images SEP ID if not set // Required: false diff --git a/pkg/cloudbroker/k8s/workers_group_delete.go b/pkg/cloudbroker/k8s/workers_group_delete.go index 84750b9..45c6a67 100644 --- a/pkg/cloudbroker/k8s/workers_group_delete.go +++ b/pkg/cloudbroker/k8s/workers_group_delete.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // WorkersGroupDeleteRequest struct to delete workers group diff --git a/pkg/cloudbroker/k8s/workers_group_get_by_name.go b/pkg/cloudbroker/k8s/workers_group_get_by_name.go index 6e94b0b..1c37a70 100644 --- a/pkg/cloudbroker/k8s/workers_group_get_by_name.go +++ b/pkg/cloudbroker/k8s/workers_group_get_by_name.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // WorkersGroupGetByNameRequest struct to get information about worker group diff --git a/pkg/cloudbroker/kvmx86.go b/pkg/cloudbroker/kvmx86.go index a98583a..93198a0 100644 --- a/pkg/cloudbroker/kvmx86.go +++ b/pkg/cloudbroker/kvmx86.go @@ -1,7 +1,7 @@ package cloudbroker import ( - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/pkg/cloudbroker/kvmx86" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/pkg/cloudbroker/kvmx86" ) // Accessing the KVMX86 method group diff --git a/pkg/cloudbroker/kvmx86/create.go b/pkg/cloudbroker/kvmx86/create.go index bd20689..c03cd0a 100644 --- a/pkg/cloudbroker/kvmx86/create.go +++ b/pkg/cloudbroker/kvmx86/create.go @@ -6,7 +6,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) type Interface struct { @@ -16,6 +16,9 @@ type Interface struct { // - EXTNET // - VFNIC // - DPDK + // - EMPTY + // - SDN + // - TRUNK NetType string `url:"netType" json:"netType" validate:"required,kvmx86NetType"` // Network ID for connect to, @@ -35,6 +38,22 @@ type Interface struct { // MAC address to assign to this VM when connecting to the specified network // Required: false MAC string `url:"mac,omitempty" json:"mac,omitempty" validate:"omitempty"` + + // SDN interface id + // Required: false + SDNInterfaceID string `url:"sdn_interface_id,omitempty" json:"sdn_interface_id,omitempty"` + + // List of security group IDs to assign to this interface + // Required: false + SecGroups []uint64 `url:"security_groups,omitempty" json:"security_groups,omitempty"` + + // Flag indicating whether security groups are enabled for this interface + // Required: false + EnableSecGroups bool `url:"enable_secgroups,omitempty" json:"enable_secgroups,omitempty"` + + // Flag indicating whether this interface is enabled (only for VINS, EXTNET, DPDK, SDN, TRUNK) + // Required: false + Enabled interface{} `url:"enabled,omitempty" json:"enabled,omitempty" validate:"omitempty,isBool"` } // DataDisk detailed struct for DataDisks field in CreateRequest, CreateBlankRequest and MassCreateRequest @@ -47,6 +66,10 @@ type DataDisk struct { // Required: true Size uint64 `url:"size" json:"size" validate:"required"` + // Storage policy id of disk. The rules of the specified storage policy will be used. + // Required: true + StoragePolicyID uint64 `url:"storage_policy_id" json:"storage_policy_id" validate:"required"` + // Storage endpoint provider ID // By default the same with boot disk // Required: false @@ -85,6 +108,10 @@ type CreateRequest struct { // Required: true RAM uint64 `url:"ram" json:"ram" validate:"required"` + // Storage policy id of сompute. The rules of the specified storage policy will be used. + // Required: true + StoragePolicyID uint64 `url:"storage_policy_id" json:"storage_policy_id" validate:"required"` + // If True, the imageId, bootDisk, sepId, pool parameters are ignored and the compute is created without a boot disk in the stopped state // Required: false WithoutBootDisk bool `url:"withoutBootDisk" json:"withoutBootDisk"` @@ -94,6 +121,10 @@ type CreateRequest struct { // Required: false ImageID uint64 `url:"imageId,omitempty" json:"imageId,omitempty"` + // The OS version that will be installed on the virtual machine + // Required: false + OSVersion string `url:"os_version,omitempty" json:"os_version,omitempty"` + // Size of the boot disk in GB // Required: false BootDisk uint64 `url:"bootDisk,omitempty" json:"bootDisk,omitempty"` @@ -147,10 +178,6 @@ type CreateRequest struct { // Required: false CustomField string `url:"customFields,omitempty" json:"customFields,omitempty"` - //Type of compute Stateful (KVM_X86) or Stateless (SVA_KVM_X86) - // Required: false - Driver string `url:"driver,omitempty" json:"driver,omitempty"` - // Rule for VM placement with NUMA affinity. // Possible values - none (placement without NUMA affinity), // strict (strictly with NUMA affinity, if not possible - do not start VM), @@ -176,6 +203,10 @@ type CreateRequest struct { // Recommended isolated CPUs. Field is ignored if compute.cpupin=False or compute.pinned=False // Required: false PreferredCPU []int64 `url:"preferredCpu,omitempty" json:"preferredCpu,omitempty" validate:"omitempty,preferredCPU"` + + // Zone ID + // Required: false + ZoneID uint64 `url:"zoneId,omitempty" json:"zoneId,omitempty"` } // GetRAM returns RAM field values diff --git a/pkg/cloudbroker/kvmx86/create_blank.go b/pkg/cloudbroker/kvmx86/create_blank.go index a487c98..cf525dd 100644 --- a/pkg/cloudbroker/kvmx86/create_blank.go +++ b/pkg/cloudbroker/kvmx86/create_blank.go @@ -6,7 +6,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // CreateBlankRequest struct to create KVM x86 VM from scratch @@ -28,6 +28,10 @@ type CreateBlankRequest struct { // Required: true RAM uint64 `url:"ram" json:"ram" validate:"required"` + // Storage policy id of сompute. The rules of the specified storage policy will be used. + // Required: true + StoragePolicyID uint64 `url:"storage_policy_id" json:"storage_policy_id" validate:"required"` + // If True, the imageId, bootDisk, sepId, pool parameters are ignored and the compute is created without a boot disk in the stopped state // Required: false WithoutBootDisk bool `url:"withoutBootDisk" json:"withoutBootDisk"` @@ -61,10 +65,6 @@ type CreateBlankRequest struct { // Required: false Description string `url:"desc,omitempty" json:"desc,omitempty"` - //Type of compute Stateful (KVM_X86) or Stateless (SVA_KVM_X86) - // Required: false - Driver string `url:"driver,omitempty" json:"driver,omitempty"` - // Type of the emulated system, Q35 or i440fx // Required: false Chipset string `url:"chipset,omitempty" json:"chipset,omitempty" validate:"omitempty,chipset"` @@ -88,6 +88,14 @@ type CreateBlankRequest struct { // Does this machine supports hot resize // Required: false HotResize bool `url:"hotResize,omitempty" json:"hotResize,omitempty"` + + // Zone ID + // Required: false + ZoneID uint64 `url:"zoneId,omitempty" json:"zoneId,omitempty"` + + // The OS version that will be installed on the virtual machine + // Required: false + OSVersion string `url:"os_version,omitempty" json:"os_version,omitempty"` } // GetRAM returns RAM field values diff --git a/pkg/cloudbroker/kvmx86/kvmx86.go b/pkg/cloudbroker/kvmx86/kvmx86.go index 05011a0..df090ac 100644 --- a/pkg/cloudbroker/kvmx86/kvmx86.go +++ b/pkg/cloudbroker/kvmx86/kvmx86.go @@ -1,7 +1,7 @@ // API to manage KVM x86 compute instances (x86 VMs) package kvmx86 -import "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/interfaces" +import "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/interfaces" // Structure for creating request to KVMX86 type KVMX86 struct { diff --git a/pkg/cloudbroker/kvmx86/mass_create.go b/pkg/cloudbroker/kvmx86/mass_create.go index f6bf3a9..0c5e36c 100644 --- a/pkg/cloudbroker/kvmx86/mass_create.go +++ b/pkg/cloudbroker/kvmx86/mass_create.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // MassCreateRequest struct to mass create KVM x86 @@ -31,6 +31,10 @@ type MassCreateRequest struct { // Required: true RAM uint64 `url:"ram" json:"ram" validate:"required"` + // Storage policy id of сompute. The rules of the specified storage policy will be used. + // Required: true + StoragePolicyID uint64 `url:"storage_policy_id" json:"storage_policy_id" validate:"required"` + // If True, the imageId, bootDisk, sepId, pool parameters are ignored and the compute is created without a boot disk in the stopped state // Required: false WithoutBootDisk bool `url:"withoutBootDisk" json:"withoutBootDisk"` @@ -79,6 +83,14 @@ type MassCreateRequest struct { // Type of the emulated system, Q35 or i440fx // Required: false Chipset string `url:"chipset,omitempty" json:"chipset,omitempty" validate:"omitempty,chipset"` + + // Zone ID + // Required: false + ZoneID uint64 `url:"zoneId,omitempty" json:"zoneId,omitempty"` + + // The OS version that will be installed on the virtual machine + // Required: false + OSVersion string `url:"os_version,omitempty" json:"os_version,omitempty"` } type asyncWrapperMassCreateRequest struct { diff --git a/pkg/cloudbroker/lb.go b/pkg/cloudbroker/lb.go index e1b5e0d..b80cae8 100644 --- a/pkg/cloudbroker/lb.go +++ b/pkg/cloudbroker/lb.go @@ -1,6 +1,6 @@ package cloudbroker -import "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/pkg/cloudbroker/lb" +import "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/pkg/cloudbroker/lb" // Accessing the LB method group func (cb *CloudBroker) LB() *lb.LB { diff --git a/pkg/cloudbroker/lb/backend_create.go b/pkg/cloudbroker/lb/backend_create.go index 6c1ba70..038566d 100644 --- a/pkg/cloudbroker/lb/backend_create.go +++ b/pkg/cloudbroker/lb/backend_create.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // BackendCreateRequest struct to create backend diff --git a/pkg/cloudbroker/lb/backend_delete.go b/pkg/cloudbroker/lb/backend_delete.go index 02d2a95..9486a37 100644 --- a/pkg/cloudbroker/lb/backend_delete.go +++ b/pkg/cloudbroker/lb/backend_delete.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // BackendDeleteRequest struct to delete backend diff --git a/pkg/cloudbroker/lb/backend_server_add.go b/pkg/cloudbroker/lb/backend_server_add.go index 19c6691..8a210df 100644 --- a/pkg/cloudbroker/lb/backend_server_add.go +++ b/pkg/cloudbroker/lb/backend_server_add.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // BackendServerAddRequest struct to add server definition to the backend diff --git a/pkg/cloudbroker/lb/backend_server_delete.go b/pkg/cloudbroker/lb/backend_server_delete.go index 474655c..d376aa1 100644 --- a/pkg/cloudbroker/lb/backend_server_delete.go +++ b/pkg/cloudbroker/lb/backend_server_delete.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // BackendServerDeleteRequest struct to delete server definition diff --git a/pkg/cloudbroker/lb/backend_server_update.go b/pkg/cloudbroker/lb/backend_server_update.go index 5e60050..8742305 100644 --- a/pkg/cloudbroker/lb/backend_server_update.go +++ b/pkg/cloudbroker/lb/backend_server_update.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // BackendServerUpdateRequest struct to update server diff --git a/pkg/cloudbroker/lb/backend_update.go b/pkg/cloudbroker/lb/backend_update.go index b1af616..3fca6f1 100644 --- a/pkg/cloudbroker/lb/backend_update.go +++ b/pkg/cloudbroker/lb/backend_update.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // BackendUpdateRequest struct to update backend diff --git a/pkg/cloudbroker/lb/config_reset.go b/pkg/cloudbroker/lb/config_reset.go index bee1e37..943c91b 100644 --- a/pkg/cloudbroker/lb/config_reset.go +++ b/pkg/cloudbroker/lb/config_reset.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ConfigResetRequest struct to reset config diff --git a/pkg/cloudbroker/lb/create.go b/pkg/cloudbroker/lb/create.go index faae764..c13345d 100644 --- a/pkg/cloudbroker/lb/create.go +++ b/pkg/cloudbroker/lb/create.go @@ -7,7 +7,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // CreateRequest struct to create load balancer @@ -44,6 +44,10 @@ type CreateRequest struct { // Text description of this load balancer // Required: false Description string `url:"desc,omitempty" json:"desc,omitempty"` + + // Zone ID + // Required: false + ZoneID uint64 `url:"zoneId,omitempty" json:"zoneId,omitempty"` } type wrapperCreateRequest struct { diff --git a/pkg/cloudbroker/lb/delete.go b/pkg/cloudbroker/lb/delete.go index 832c101..20a26bf 100644 --- a/pkg/cloudbroker/lb/delete.go +++ b/pkg/cloudbroker/lb/delete.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // DeleteRequest struct to delete load balancer diff --git a/pkg/cloudbroker/lb/disable.go b/pkg/cloudbroker/lb/disable.go index 74256a7..9fd1df8 100644 --- a/pkg/cloudbroker/lb/disable.go +++ b/pkg/cloudbroker/lb/disable.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // DisableRequest struct to disable load balancer diff --git a/pkg/cloudbroker/lb/enable.go b/pkg/cloudbroker/lb/enable.go index 8b79c47..32dd8c2 100644 --- a/pkg/cloudbroker/lb/enable.go +++ b/pkg/cloudbroker/lb/enable.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // EnableRequest struct to enable load balancer diff --git a/pkg/cloudbroker/lb/filter.go b/pkg/cloudbroker/lb/filter.go index 92e0a0e..14c1b07 100644 --- a/pkg/cloudbroker/lb/filter.go +++ b/pkg/cloudbroker/lb/filter.go @@ -3,8 +3,8 @@ package lb import ( "context" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/interfaces" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/pkg/cloudbroker/k8s" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/interfaces" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/pkg/cloudbroker/k8s" ) // FilterByID returns ListLB with specified ID. diff --git a/pkg/cloudbroker/lb/frontend_bind.go b/pkg/cloudbroker/lb/frontend_bind.go index 3965499..fdba972 100644 --- a/pkg/cloudbroker/lb/frontend_bind.go +++ b/pkg/cloudbroker/lb/frontend_bind.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // FrontendBindRequest struct for frontend bind diff --git a/pkg/cloudbroker/lb/frontend_bind_delete.go b/pkg/cloudbroker/lb/frontend_bind_delete.go index 61f78ca..f0e8592 100644 --- a/pkg/cloudbroker/lb/frontend_bind_delete.go +++ b/pkg/cloudbroker/lb/frontend_bind_delete.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // FrontendBindDeleteRequest struct to delete bind diff --git a/pkg/cloudbroker/lb/frontend_binding_update.go b/pkg/cloudbroker/lb/frontend_binding_update.go index 976e004..a2e5714 100644 --- a/pkg/cloudbroker/lb/frontend_binding_update.go +++ b/pkg/cloudbroker/lb/frontend_binding_update.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // FrontendBindUpdateRequest struct for update binding diff --git a/pkg/cloudbroker/lb/frontend_create.go b/pkg/cloudbroker/lb/frontend_create.go index 56fdf91..e0a0b50 100644 --- a/pkg/cloudbroker/lb/frontend_create.go +++ b/pkg/cloudbroker/lb/frontend_create.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // FrontendCreateRequest struct for create frontend diff --git a/pkg/cloudbroker/lb/frontend_delete.go b/pkg/cloudbroker/lb/frontend_delete.go index de1a09e..8fed174 100644 --- a/pkg/cloudbroker/lb/frontend_delete.go +++ b/pkg/cloudbroker/lb/frontend_delete.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // FrontendDeleteRequest struct for delete frontend diff --git a/pkg/cloudbroker/lb/get.go b/pkg/cloudbroker/lb/get.go index 798d236..ef1bc46 100644 --- a/pkg/cloudbroker/lb/get.go +++ b/pkg/cloudbroker/lb/get.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // GetRequest struct to get detailed information about load balancer diff --git a/pkg/cloudbroker/lb/lb.go b/pkg/cloudbroker/lb/lb.go index b3a45c1..1e3a0e2 100644 --- a/pkg/cloudbroker/lb/lb.go +++ b/pkg/cloudbroker/lb/lb.go @@ -1,7 +1,7 @@ // API to manage load balancer instance package lb -import "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/interfaces" +import "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/interfaces" // Structure for creating request to load balancer type LB struct { diff --git a/pkg/cloudbroker/lb/list.go b/pkg/cloudbroker/lb/list.go index f3b8519..c7c3885 100644 --- a/pkg/cloudbroker/lb/list.go +++ b/pkg/cloudbroker/lb/list.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ListRequest struct to get list of load balancers @@ -50,6 +50,11 @@ type ListRequest struct { // Required: false SortBy string `url:"sortBy,omitempty" json:"sortBy,omitempty" validate:"omitempty,sortBy"` + // Sort by zone id + // Default value: 0 + // Required: false + ZoneID uint64 `url:"zone_id,omitempty" json:"zone_id,omitempty"` + // Page number // Required: false Page uint64 `url:"page,omitempty" json:"page,omitempty"` diff --git a/pkg/cloudbroker/lb/list_deleted.go b/pkg/cloudbroker/lb/list_deleted.go index 32e29d1..6f3af30 100644 --- a/pkg/cloudbroker/lb/list_deleted.go +++ b/pkg/cloudbroker/lb/list_deleted.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ListDeletedRequest struct to get list of deleted load balancers diff --git a/pkg/cloudbroker/lb/make_highly_available.go b/pkg/cloudbroker/lb/make_highly_available.go index 1b45a2e..999029d 100644 --- a/pkg/cloudbroker/lb/make_highly_available.go +++ b/pkg/cloudbroker/lb/make_highly_available.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // HighlyAvailableRequest struct to make Load Balancer Highly available diff --git a/pkg/cloudbroker/lb/migrate_to_zone.go b/pkg/cloudbroker/lb/migrate_to_zone.go new file mode 100644 index 0000000..39b0423 --- /dev/null +++ b/pkg/cloudbroker/lb/migrate_to_zone.go @@ -0,0 +1,42 @@ +package lb + +import ( + "context" + "net/http" + "strconv" + + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" +) + +// MigrateToZone struct to move lb to another zone +type MigrateToZoneRequest struct { + // ID of the load balancer instance to move + // Required: true + LBID uint64 `url:"lbId" json:"lbId" validate:"required"` + + // ID of the zone to move + // Required: true + ZoneID uint64 `url:"zoneId" json:"zoneId" validate:"required"` +} + +// MigrateToZone moves lb instance to new zone +func (l LB) MigrateToZone(ctx context.Context, req MigrateToZoneRequest) (bool, error) { + err := validators.ValidateRequest(req) + if err != nil { + return false, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/lb/migrateToZone" + + res, err := l.client.DecortApiCall(ctx, http.MethodPost, url, req) + if err != nil { + return false, err + } + + result, err := strconv.ParseBool(string(res)) + if err != nil { + return false, err + } + + return result, nil +} diff --git a/pkg/cloudbroker/lb/models.go b/pkg/cloudbroker/lb/models.go index 11382cd..c4d41f1 100644 --- a/pkg/cloudbroker/lb/models.go +++ b/pkg/cloudbroker/lb/models.go @@ -153,6 +153,9 @@ type RecordLB struct { // Meta Meta []interface{} `json:"_meta"` + //Account ID + AccountID uint64 `json:"accountId"` + // Access Control List ACL interface{} `json:"acl"` @@ -220,7 +223,7 @@ type RecordLB struct { Status string `json:"status"` // Sysctl Params - SysctlParams interface{} `json:"sysctlParams"` + SysctlParams map[string]string `json:"sysctlParams"` // Tech status TechStatus string `json:"techStatus"` @@ -230,6 +233,9 @@ type RecordLB struct { // VINS ID VINSID uint64 `json:"vinsId"` + + // Zone ID + ZoneID uint64 `json:"zoneId"` } // Detailed information about load balancer in List @@ -316,7 +322,7 @@ type ItemLBList struct { Status string `json:"status"` // Sysctl Params - SysctlParams interface{} `json:"sysctlParams"` + SysctlParams map[string]string `json:"sysctlParams"` // Tech status TechStatus string `json:"techStatus"` @@ -332,4 +338,7 @@ type ItemLBList struct { // VINS ID VINSID uint64 `json:"vinsId"` + + // Zone ID + ZoneID uint64 `json:"zoneId"` } diff --git a/pkg/cloudbroker/lb/restart.go b/pkg/cloudbroker/lb/restart.go index a3ba0e0..da2dc29 100644 --- a/pkg/cloudbroker/lb/restart.go +++ b/pkg/cloudbroker/lb/restart.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // RestartRequest struct to restart load balancer diff --git a/pkg/cloudbroker/lb/restore.go b/pkg/cloudbroker/lb/restore.go index 28ac598..2891864 100644 --- a/pkg/cloudbroker/lb/restore.go +++ b/pkg/cloudbroker/lb/restore.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // RestoreRequest struct to restore load balancer diff --git a/pkg/cloudbroker/lb/serialize.go b/pkg/cloudbroker/lb/serialize.go index 9a5ba91..e92dca7 100644 --- a/pkg/cloudbroker/lb/serialize.go +++ b/pkg/cloudbroker/lb/serialize.go @@ -3,7 +3,7 @@ package lb import ( "encoding/json" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/serialization" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/serialization" ) // Serialize returns JSON-serialized []byte. Used as a wrapper over json.Marshal and json.MarshalIndent functions. diff --git a/pkg/cloudbroker/lb/start.go b/pkg/cloudbroker/lb/start.go index 8340c0a..5e5e5e6 100644 --- a/pkg/cloudbroker/lb/start.go +++ b/pkg/cloudbroker/lb/start.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // StartRequest struct to start load balancer diff --git a/pkg/cloudbroker/lb/stop.go b/pkg/cloudbroker/lb/stop.go index c1f4978..b1eeed0 100644 --- a/pkg/cloudbroker/lb/stop.go +++ b/pkg/cloudbroker/lb/stop.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // StopRequest struct to stop load balancer diff --git a/pkg/cloudbroker/lb/update.go b/pkg/cloudbroker/lb/update.go index f40e5fc..c5c8bff 100644 --- a/pkg/cloudbroker/lb/update.go +++ b/pkg/cloudbroker/lb/update.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // UpdateRequest struct to update load balancer diff --git a/pkg/cloudbroker/lb/update_sysctl_params.go b/pkg/cloudbroker/lb/update_sysctl_params.go index f03ac06..577695a 100644 --- a/pkg/cloudbroker/lb/update_sysctl_params.go +++ b/pkg/cloudbroker/lb/update_sysctl_params.go @@ -6,7 +6,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // UpdateSysctParamsRequest struct to update sysct params for lb diff --git a/pkg/cloudbroker/node.go b/pkg/cloudbroker/node.go index 2e48527..0736b16 100644 --- a/pkg/cloudbroker/node.go +++ b/pkg/cloudbroker/node.go @@ -1,6 +1,6 @@ package cloudbroker -import "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/pkg/cloudbroker/node" +import "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/pkg/cloudbroker/node" // Accessing the Node method group func (cb *CloudBroker) Node() *node.Node { diff --git a/pkg/cloudbroker/node/add_ssh_identity.go b/pkg/cloudbroker/node/add_ssh_identity.go new file mode 100644 index 0000000..191d03b --- /dev/null +++ b/pkg/cloudbroker/node/add_ssh_identity.go @@ -0,0 +1,54 @@ +package node + +import ( + "context" + "net/http" + "strconv" + + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" +) + +// AddSSHIdentityRequest struct to add node ssh information +type AddSSHIdentityRequest struct { + // Node ID + // Required: true + NID uint64 `url:"node_id" json:"node_id" validate:"required"` + + // Host name of the client + // Required: true + ClientHostName string `url:"client_host_name" json:"client_host_name" validate:"required"` + + // SSH host key of the client + // Required: true + ClientHostKey string `url:"client_host_key" json:"client_host_key" validate:"required" ` + + // SSH public key of the client + // Required: true + ClientPublicKey string `url:"client_public_key" json:"client_public_key" validate:"required"` + + // IPv4 address + // Required: true + ClientIPAddress string `url:"client_ip_address" json:"client_ip_address" validate:"required" ` +} + +// AddSSHIdentity adds node ssh information +func (n Node) AddSSHIdentity(ctx context.Context, req AddSSHIdentityRequest) (bool, error) { + err := validators.ValidateRequest(req) + if err != nil { + return false, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/node/add_ssh_identity" + + res, err := n.client.DecortApiCall(ctx, http.MethodPost, url, req) + if err != nil { + return false, err + } + + result, err := strconv.ParseBool(string(res)) + if err != nil { + return false, err + } + + return result, nil +} diff --git a/pkg/cloudbroker/node/apply_ipmi_action.go b/pkg/cloudbroker/node/apply_ipmi_action.go index 2b00677..81c7a63 100644 --- a/pkg/cloudbroker/node/apply_ipmi_action.go +++ b/pkg/cloudbroker/node/apply_ipmi_action.go @@ -4,7 +4,7 @@ import ( "context" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ApplyIpmiActionRequest struct to apply ipmi action on node @@ -14,7 +14,7 @@ type ApplyIpmiActionRequest struct { NID uint64 `url:"nid" json:"nid" validate:"required"` // Action - // on of actions power_on shutdown force_shutdown reboot + // Available values : is_powered, power_on, shutdown, force_shutdown, reboot. // Required: true Action string `url:"action" json:"action" validate:"required,action"` } diff --git a/pkg/cloudbroker/node/consumption.go b/pkg/cloudbroker/node/consumption.go index a9346cf..bc14d4d 100644 --- a/pkg/cloudbroker/node/consumption.go +++ b/pkg/cloudbroker/node/consumption.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ConsumptionRequest struct to get node summary by resources and consumption diff --git a/pkg/cloudbroker/node/decommission.go b/pkg/cloudbroker/node/decommission.go index 26b69b0..ce94548 100644 --- a/pkg/cloudbroker/node/decommission.go +++ b/pkg/cloudbroker/node/decommission.go @@ -4,7 +4,7 @@ import ( "context" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // DecommissionRequest struct to set node status to DECOMMISSIONED diff --git a/pkg/cloudbroker/node/enable.go b/pkg/cloudbroker/node/enable.go index a3eb131..d848b9c 100644 --- a/pkg/cloudbroker/node/enable.go +++ b/pkg/cloudbroker/node/enable.go @@ -4,7 +4,7 @@ import ( "context" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // EnableRequest struct to enable node from maintenance status to enabled diff --git a/pkg/cloudbroker/node/enable_nodes.go b/pkg/cloudbroker/node/enable_nodes.go index 27ab78b..11844ea 100644 --- a/pkg/cloudbroker/node/enable_nodes.go +++ b/pkg/cloudbroker/node/enable_nodes.go @@ -4,7 +4,7 @@ import ( "context" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // EnableNodesRequest struct to enable nodes from maintenance status to enabled diff --git a/pkg/cloudbroker/node/get.go b/pkg/cloudbroker/node/get.go index 8900446..930ee3d 100644 --- a/pkg/cloudbroker/node/get.go +++ b/pkg/cloudbroker/node/get.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // GetRequest struct to get detailed information about node diff --git a/pkg/cloudbroker/node/get_ssh_identity.go b/pkg/cloudbroker/node/get_ssh_identity.go new file mode 100644 index 0000000..f5fdd6e --- /dev/null +++ b/pkg/cloudbroker/node/get_ssh_identity.go @@ -0,0 +1,39 @@ +package node + +import ( + "context" + "encoding/json" + "net/http" + + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" +) + +// GetSSHIdentityRequest struct to get node ssh information +type GetSSHIdentityRequest struct { + // Node ID + // Required: true + NID uint64 `url:"node_id" json:"node_id" validate:"required"` +} + +// GetSSHIdentity gets node ssh information +func (n Node) GetSSHIdentity(ctx context.Context, req GetSSHIdentityRequest) (*SSHIdentity, error) { + if err := validators.ValidateRequest(req); err != nil { + return nil, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/node/get_ssh_identity" + + res, err := n.client.DecortApiCall(ctx, http.MethodGet, url, req) + if err != nil { + return nil, err + } + + info := SSHIdentity{} + + err = json.Unmarshal(res, &info) + if err != nil { + return nil, err + } + + return &info, nil +} diff --git a/pkg/cloudbroker/node/list.go b/pkg/cloudbroker/node/list.go index 5db883d..92c7c4d 100644 --- a/pkg/cloudbroker/node/list.go +++ b/pkg/cloudbroker/node/list.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ListRequest struct to get list of nodes diff --git a/pkg/cloudbroker/node/maintenance.go b/pkg/cloudbroker/node/maintenance.go index 7aca872..720822a 100644 --- a/pkg/cloudbroker/node/maintenance.go +++ b/pkg/cloudbroker/node/maintenance.go @@ -4,7 +4,7 @@ import ( "context" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // MaintenanceRequest struct to place node in maintenance state diff --git a/pkg/cloudbroker/node/models.go b/pkg/cloudbroker/node/models.go index 6f4c5cf..d3761af 100644 --- a/pkg/cloudbroker/node/models.go +++ b/pkg/cloudbroker/node/models.go @@ -73,6 +73,9 @@ type RecordNode struct { // Version Version string `json:"version"` + + // Zone ID + ZoneID uint64 `json:"zoneId"` } // Resource consumption of the node @@ -97,6 +100,9 @@ type ConsumptionInfo struct { type FreeResourcesInfo struct { // RAM RAM float64 `json:"RAM"` + + // VCPU + VCPU uint64 `json:"vCPU"` } // Resources Info @@ -227,6 +233,9 @@ type ItemNode struct { // Roles Roles []string `json:"roles"` + // SDN Hypervisor Name + SDNHypervisorName string `json:"sdn_hypervisor_name"` + // Seps Seps []uint64 `json:"seps"` @@ -253,6 +262,9 @@ type ItemNode struct { // Version Version string `json:"version"` + + // Zone ID + ZoneID uint64 `json:"zoneId"` } // Numa Topology Info @@ -380,3 +392,15 @@ type Role struct { Reason string `json:"reason"` Time uint64 `json:"time"` } + +// Information about SSH Identity +type SSHIdentity struct { + //Host name of the client + HostName string `json:"host_name"` + + //SSH host key of the client + HostKey string `json:"host_key"` + + //Array of SSH public keys of the client + PublicKeys []string `json:"public_keys"` +} diff --git a/pkg/cloudbroker/node/node.go b/pkg/cloudbroker/node/node.go index 744c481..fe886f3 100644 --- a/pkg/cloudbroker/node/node.go +++ b/pkg/cloudbroker/node/node.go @@ -2,7 +2,7 @@ package node import ( - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/interfaces" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/interfaces" ) // Structure for creating request to node diff --git a/pkg/cloudbroker/node/restrict.go b/pkg/cloudbroker/node/restrict.go index 74e5edd..99bf3be 100644 --- a/pkg/cloudbroker/node/restrict.go +++ b/pkg/cloudbroker/node/restrict.go @@ -4,7 +4,7 @@ import ( "context" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // RestrictRequest struct to set node status to 'RESTRICTED' diff --git a/pkg/cloudbroker/node/serialize.go b/pkg/cloudbroker/node/serialize.go index 292f3bb..e2eac23 100644 --- a/pkg/cloudbroker/node/serialize.go +++ b/pkg/cloudbroker/node/serialize.go @@ -3,7 +3,7 @@ package node import ( "encoding/json" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/serialization" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/serialization" ) // Serialize returns JSON-serialized []byte. Used as a wrapper over json.Marshal and json.MarshalIndent functions. diff --git a/pkg/cloudbroker/node/set_core_isolation.go b/pkg/cloudbroker/node/set_core_isolation.go index 209fd35..b631703 100644 --- a/pkg/cloudbroker/node/set_core_isolation.go +++ b/pkg/cloudbroker/node/set_core_isolation.go @@ -4,7 +4,7 @@ import ( "context" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // SetCoreIsolationRequest struct to isolate selected cores on node boot diff --git a/pkg/cloudbroker/node/set_huge_pages.go b/pkg/cloudbroker/node/set_huge_pages.go index 904f1f4..e67bb45 100644 --- a/pkg/cloudbroker/node/set_huge_pages.go +++ b/pkg/cloudbroker/node/set_huge_pages.go @@ -4,7 +4,7 @@ import ( "context" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // SetHugePagesRequest struct to set on-boot Huge Pages configuration diff --git a/pkg/cloudbroker/node/set_sriov_status.go b/pkg/cloudbroker/node/set_sriov_status.go index 97da27f..3c6d46b 100644 --- a/pkg/cloudbroker/node/set_sriov_status.go +++ b/pkg/cloudbroker/node/set_sriov_status.go @@ -4,7 +4,7 @@ import ( "context" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // SetSRIOVStatusRequest struct to set Single-root input/output virtualization kernel config on node diff --git a/pkg/cloudbroker/node/set_vfs_number.go b/pkg/cloudbroker/node/set_vfs_number.go index d99bc3d..c383365 100644 --- a/pkg/cloudbroker/node/set_vfs_number.go +++ b/pkg/cloudbroker/node/set_vfs_number.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // SetVFsNumberRequest struct to set number of VFs for individual NIC on node diff --git a/pkg/cloudbroker/node/set_vfs_params.go b/pkg/cloudbroker/node/set_vfs_params.go index 4a449c0..1c282a4 100644 --- a/pkg/cloudbroker/node/set_vfs_params.go +++ b/pkg/cloudbroker/node/set_vfs_params.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) type VFParam struct { diff --git a/pkg/cloudbroker/node/update.go b/pkg/cloudbroker/node/update.go index 51e55c8..4a9a925 100644 --- a/pkg/cloudbroker/node/update.go +++ b/pkg/cloudbroker/node/update.go @@ -4,7 +4,7 @@ import ( "context" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // UpdateRequest struct to update node for actual version diff --git a/pkg/cloudbroker/pcidevice.go b/pkg/cloudbroker/pcidevice.go index 2b38c08..3ff0078 100644 --- a/pkg/cloudbroker/pcidevice.go +++ b/pkg/cloudbroker/pcidevice.go @@ -1,6 +1,6 @@ package cloudbroker -import "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/pkg/cloudbroker/pcidevice" +import "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/pkg/cloudbroker/pcidevice" // Accessing the PCI Device method group func (cb *CloudBroker) PCIDevice() *pcidevice.PCIDevice { diff --git a/pkg/cloudbroker/pcidevice/create.go b/pkg/cloudbroker/pcidevice/create.go index d8d3c32..4570ff7 100644 --- a/pkg/cloudbroker/pcidevice/create.go +++ b/pkg/cloudbroker/pcidevice/create.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // CreateRequest struct to creating PCI device diff --git a/pkg/cloudbroker/pcidevice/delete.go b/pkg/cloudbroker/pcidevice/delete.go index 04131a5..1c07b42 100644 --- a/pkg/cloudbroker/pcidevice/delete.go +++ b/pkg/cloudbroker/pcidevice/delete.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // DeleteRequest struct to deleting PCI device diff --git a/pkg/cloudbroker/pcidevice/disable.go b/pkg/cloudbroker/pcidevice/disable.go index df8609f..596143f 100644 --- a/pkg/cloudbroker/pcidevice/disable.go +++ b/pkg/cloudbroker/pcidevice/disable.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // DisableRequest struct for disabling PCI device diff --git a/pkg/cloudbroker/pcidevice/enable.go b/pkg/cloudbroker/pcidevice/enable.go index e30ca5b..f0df2ad 100644 --- a/pkg/cloudbroker/pcidevice/enable.go +++ b/pkg/cloudbroker/pcidevice/enable.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // EnableRequest struct for enabling PCI device diff --git a/pkg/cloudbroker/pcidevice/list.go b/pkg/cloudbroker/pcidevice/list.go index 041c3eb..8a404e9 100644 --- a/pkg/cloudbroker/pcidevice/list.go +++ b/pkg/cloudbroker/pcidevice/list.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ListRequest struct to get list of pci devices diff --git a/pkg/cloudbroker/pcidevice/pcidevice.go b/pkg/cloudbroker/pcidevice/pcidevice.go index 7a42767..d575df7 100644 --- a/pkg/cloudbroker/pcidevice/pcidevice.go +++ b/pkg/cloudbroker/pcidevice/pcidevice.go @@ -1,6 +1,6 @@ package pcidevice -import "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/interfaces" +import "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/interfaces" // Structure for creating request to PCI device type PCIDevice struct { diff --git a/pkg/cloudbroker/pcidevice/serialize.go b/pkg/cloudbroker/pcidevice/serialize.go index 56be05c..1c6da92 100644 --- a/pkg/cloudbroker/pcidevice/serialize.go +++ b/pkg/cloudbroker/pcidevice/serialize.go @@ -3,7 +3,7 @@ package pcidevice import ( "encoding/json" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/serialization" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/serialization" ) // Serialize returns JSON-serialized []byte. Used as a wrapper over json.Marshal and json.MarshalIndent functions. diff --git a/pkg/cloudbroker/prometheus.go b/pkg/cloudbroker/prometheus.go index d5f21af..de0387f 100644 --- a/pkg/cloudbroker/prometheus.go +++ b/pkg/cloudbroker/prometheus.go @@ -1,6 +1,6 @@ package cloudbroker -import "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/pkg/cloudbroker/prometheus" +import "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/pkg/cloudbroker/prometheus" // Accessing the Prometheus method group func (cb *CloudBroker) Prometheus() *prometheus.Prometheus { diff --git a/pkg/cloudbroker/prometheus/compute_cpu_load.go b/pkg/cloudbroker/prometheus/compute_cpu_load.go index d70070a..4caeb2d 100644 --- a/pkg/cloudbroker/prometheus/compute_cpu_load.go +++ b/pkg/cloudbroker/prometheus/compute_cpu_load.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) type ComputeCPULoadRequest struct { diff --git a/pkg/cloudbroker/prometheus/compute_memory_available.go b/pkg/cloudbroker/prometheus/compute_memory_available.go index 3c4bc67..92ab021 100644 --- a/pkg/cloudbroker/prometheus/compute_memory_available.go +++ b/pkg/cloudbroker/prometheus/compute_memory_available.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) type ComputeMemoryAvailableRequest struct { diff --git a/pkg/cloudbroker/prometheus/compute_memory_unused.go b/pkg/cloudbroker/prometheus/compute_memory_unused.go index d2e20e7..98f4d0a 100644 --- a/pkg/cloudbroker/prometheus/compute_memory_unused.go +++ b/pkg/cloudbroker/prometheus/compute_memory_unused.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) type ComputeMemoryUnusedRequest struct { diff --git a/pkg/cloudbroker/prometheus/compute_memory_usable.go b/pkg/cloudbroker/prometheus/compute_memory_usable.go index 8d2a9ca..74054ad 100644 --- a/pkg/cloudbroker/prometheus/compute_memory_usable.go +++ b/pkg/cloudbroker/prometheus/compute_memory_usable.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) type ComputeMemoryUsableRequest struct { diff --git a/pkg/cloudbroker/prometheus/compute_memory_usage.go b/pkg/cloudbroker/prometheus/compute_memory_usage.go index 048d10c..724b862 100644 --- a/pkg/cloudbroker/prometheus/compute_memory_usage.go +++ b/pkg/cloudbroker/prometheus/compute_memory_usage.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) type ComputeMemoryUsageRequest struct { diff --git a/pkg/cloudbroker/prometheus/compute_memory_used.go b/pkg/cloudbroker/prometheus/compute_memory_used.go index a0bed83..6211eef 100644 --- a/pkg/cloudbroker/prometheus/compute_memory_used.go +++ b/pkg/cloudbroker/prometheus/compute_memory_used.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) type ComputeMemoryUsedRequest struct { diff --git a/pkg/cloudbroker/prometheus/compute_read_bytes.go b/pkg/cloudbroker/prometheus/compute_read_bytes.go index 1d5b4be..093a20f 100644 --- a/pkg/cloudbroker/prometheus/compute_read_bytes.go +++ b/pkg/cloudbroker/prometheus/compute_read_bytes.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) type ComputeReadBytesRequest struct { diff --git a/pkg/cloudbroker/prometheus/compute_read_requests.go b/pkg/cloudbroker/prometheus/compute_read_requests.go index 06b500e..e28ee18 100644 --- a/pkg/cloudbroker/prometheus/compute_read_requests.go +++ b/pkg/cloudbroker/prometheus/compute_read_requests.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) type ComputeReadRequestsRequest struct { diff --git a/pkg/cloudbroker/prometheus/compute_receive_bytes.go b/pkg/cloudbroker/prometheus/compute_receive_bytes.go index 6de2e5e..54f72f3 100644 --- a/pkg/cloudbroker/prometheus/compute_receive_bytes.go +++ b/pkg/cloudbroker/prometheus/compute_receive_bytes.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) type ComputeReceiveBytesRequest struct { diff --git a/pkg/cloudbroker/prometheus/compute_receive_packets.go b/pkg/cloudbroker/prometheus/compute_receive_packets.go index 9f2095f..8d99202 100644 --- a/pkg/cloudbroker/prometheus/compute_receive_packets.go +++ b/pkg/cloudbroker/prometheus/compute_receive_packets.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) type ComputeReceivePacketsRequest struct { diff --git a/pkg/cloudbroker/prometheus/compute_transmit_bytes.go b/pkg/cloudbroker/prometheus/compute_transmit_bytes.go index b868ad0..7d31d68 100644 --- a/pkg/cloudbroker/prometheus/compute_transmit_bytes.go +++ b/pkg/cloudbroker/prometheus/compute_transmit_bytes.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) type ComputeTransmitBytesRequest struct { diff --git a/pkg/cloudbroker/prometheus/compute_transmit_packets.go b/pkg/cloudbroker/prometheus/compute_transmit_packets.go index c6e7914..8024248 100644 --- a/pkg/cloudbroker/prometheus/compute_transmit_packets.go +++ b/pkg/cloudbroker/prometheus/compute_transmit_packets.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) type ComputeTransmitPacketsRequest struct { diff --git a/pkg/cloudbroker/prometheus/compute_write_bytes.go b/pkg/cloudbroker/prometheus/compute_write_bytes.go index a0b9712..8530cae 100644 --- a/pkg/cloudbroker/prometheus/compute_write_bytes.go +++ b/pkg/cloudbroker/prometheus/compute_write_bytes.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) type ComputeWriteBytesRequest struct { diff --git a/pkg/cloudbroker/prometheus/compute_write_requests.go b/pkg/cloudbroker/prometheus/compute_write_requests.go index abfadb3..5c79eb4 100644 --- a/pkg/cloudbroker/prometheus/compute_write_requests.go +++ b/pkg/cloudbroker/prometheus/compute_write_requests.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) type ComputeWriteRequestsRequest struct { diff --git a/pkg/cloudbroker/prometheus/computes.go b/pkg/cloudbroker/prometheus/computes.go index 9056cb8..bafcda0 100644 --- a/pkg/cloudbroker/prometheus/computes.go +++ b/pkg/cloudbroker/prometheus/computes.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) const ( diff --git a/pkg/cloudbroker/prometheus/prometheus.go b/pkg/cloudbroker/prometheus/prometheus.go index bffc0c2..90ac120 100644 --- a/pkg/cloudbroker/prometheus/prometheus.go +++ b/pkg/cloudbroker/prometheus/prometheus.go @@ -1,7 +1,7 @@ package prometheus import ( - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/interfaces" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/interfaces" ) // Structure for creating request to prometheus diff --git a/pkg/cloudbroker/resmon.go b/pkg/cloudbroker/resmon.go index 5d59144..9c8f6bf 100644 --- a/pkg/cloudbroker/resmon.go +++ b/pkg/cloudbroker/resmon.go @@ -1,7 +1,7 @@ package cloudbroker import ( - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/pkg/cloudbroker/resmon" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/pkg/cloudbroker/resmon" ) // Accessing the Resmon method group diff --git a/pkg/cloudbroker/resmon/get_by_compute.go b/pkg/cloudbroker/resmon/get_by_compute.go index 567a588..0c274d4 100644 --- a/pkg/cloudbroker/resmon/get_by_compute.go +++ b/pkg/cloudbroker/resmon/get_by_compute.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) type GetByComputeRequest struct { diff --git a/pkg/cloudbroker/resmon/get_by_computes.go b/pkg/cloudbroker/resmon/get_by_computes.go index 11024e5..1018a22 100644 --- a/pkg/cloudbroker/resmon/get_by_computes.go +++ b/pkg/cloudbroker/resmon/get_by_computes.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) type GetByComputesRequest struct { diff --git a/pkg/cloudbroker/resmon/get_by_grid.go b/pkg/cloudbroker/resmon/get_by_grid.go index 6ae3e07..aa7dba2 100644 --- a/pkg/cloudbroker/resmon/get_by_grid.go +++ b/pkg/cloudbroker/resmon/get_by_grid.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) type GetByGRIDRequest struct { diff --git a/pkg/cloudbroker/resmon/get_by_stack.go b/pkg/cloudbroker/resmon/get_by_stack.go index 9aac831..ccd80e5 100644 --- a/pkg/cloudbroker/resmon/get_by_stack.go +++ b/pkg/cloudbroker/resmon/get_by_stack.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) type GetByStackRequest struct { diff --git a/pkg/cloudbroker/resmon/get_by_stacks.go b/pkg/cloudbroker/resmon/get_by_stacks.go index 4bbc9ea..e15ce35 100644 --- a/pkg/cloudbroker/resmon/get_by_stacks.go +++ b/pkg/cloudbroker/resmon/get_by_stacks.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) type GetByStacksRequest struct { diff --git a/pkg/cloudbroker/resmon/resmon.go b/pkg/cloudbroker/resmon/resmon.go index b46ff74..75f20e0 100644 --- a/pkg/cloudbroker/resmon/resmon.go +++ b/pkg/cloudbroker/resmon/resmon.go @@ -1,6 +1,6 @@ package resmon -import "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/interfaces" +import "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/interfaces" // Structure for creating request to resource monitoring type Resmon struct { diff --git a/pkg/cloudbroker/rg.go b/pkg/cloudbroker/rg.go index 7b92a05..c6c62aa 100644 --- a/pkg/cloudbroker/rg.go +++ b/pkg/cloudbroker/rg.go @@ -1,6 +1,6 @@ package cloudbroker -import "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/pkg/cloudbroker/rg" +import "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/pkg/cloudbroker/rg" // Accessing the RG method group func (cb *CloudBroker) RG() *rg.RG { diff --git a/pkg/cloudbroker/rg/access_grant.go b/pkg/cloudbroker/rg/access_grant.go index 9c8a6de..68c4c63 100644 --- a/pkg/cloudbroker/rg/access_grant.go +++ b/pkg/cloudbroker/rg/access_grant.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // AccessGrantRequest struct to grant access to resource group diff --git a/pkg/cloudbroker/rg/access_revoke.go b/pkg/cloudbroker/rg/access_revoke.go index 41fbde4..6925770 100644 --- a/pkg/cloudbroker/rg/access_revoke.go +++ b/pkg/cloudbroker/rg/access_revoke.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // AccessRevokeRequest struct to revoke access diff --git a/pkg/cloudbroker/rg/add_storage_policy.go b/pkg/cloudbroker/rg/add_storage_policy.go new file mode 100644 index 0000000..44030c3 --- /dev/null +++ b/pkg/cloudbroker/rg/add_storage_policy.go @@ -0,0 +1,46 @@ +package rg + +import ( + "context" + "net/http" + "strconv" + + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" +) + +// AddStoragePolicyRequest struct for adding storage policy to the resource group +type AddStoragePolicyRequest struct { + // ID of resource group to add to + // Required: true + RGID uint64 `url:"resgroup_id" json:"resgroup_id" validate:"required"` + + // ID of the storage policy to which to connect resource group + // Required: true + StoragePolicyID uint64 `url:"storage_policy_id" json:"storage_policy_id" validate:"required"` + + // Limit storage resources GB. Or -1 unlimit + // Required: false + Limit int `url:"limit,omitempty" json:"limit,omitempty"` +} + +// AddStoragePolicy add storage policy to the account. +func (r RG) AddStoragePolicy(ctx context.Context, req AddStoragePolicyRequest) (bool, error) { + err := validators.ValidateRequest(req) + if err != nil { + return false, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/rg/add_storage_policy" + + res, err := r.client.DecortApiCall(ctx, http.MethodPost, url, req) + if err != nil { + return false, err + } + + result, err := strconv.ParseBool(string(res)) + if err != nil { + return false, err + } + + return result, nil +} diff --git a/pkg/cloudbroker/rg/affinity_group_computes.go b/pkg/cloudbroker/rg/affinity_group_computes.go index ae98a3f..b684e24 100644 --- a/pkg/cloudbroker/rg/affinity_group_computes.go +++ b/pkg/cloudbroker/rg/affinity_group_computes.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // AffinityGroupComputesRequest struct to get list of all computes with their relationships diff --git a/pkg/cloudbroker/rg/affinity_groups_get.go b/pkg/cloudbroker/rg/affinity_groups_get.go index c7b120c..d4f5a9d 100644 --- a/pkg/cloudbroker/rg/affinity_groups_get.go +++ b/pkg/cloudbroker/rg/affinity_groups_get.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // AffinityGroupsGetRequest struct to get list of computes from affinity group diff --git a/pkg/cloudbroker/rg/affinity_groups_list.go b/pkg/cloudbroker/rg/affinity_groups_list.go index cffc95d..6505b2f 100644 --- a/pkg/cloudbroker/rg/affinity_groups_list.go +++ b/pkg/cloudbroker/rg/affinity_groups_list.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // AffinityGroupsListRequest struct to get list of affinity groups from resource group diff --git a/pkg/cloudbroker/rg/audits.go b/pkg/cloudbroker/rg/audits.go index f419793..d467ec3 100644 --- a/pkg/cloudbroker/rg/audits.go +++ b/pkg/cloudbroker/rg/audits.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // AuditsRequest struct to get audit diff --git a/pkg/cloudbroker/rg/create.go b/pkg/cloudbroker/rg/create.go index 173d039..65008e5 100644 --- a/pkg/cloudbroker/rg/create.go +++ b/pkg/cloudbroker/rg/create.go @@ -5,7 +5,8 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/constants" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // CreateRequest struct to create resource group @@ -26,6 +27,10 @@ type CreateRequest struct { // Required: false MaxMemoryCapacity int64 `url:"maxMemoryCapacity,omitempty" json:"maxMemoryCapacity,omitempty"` + // Storage policies + // Required: false + StoragePolicies []StoragePolicy `url:"-" json:"storage_policies,omitempty"` + // Max size of aggregated virtual disks in GB // Required: false MaxVDiskCapacity int64 `url:"maxVDiskCapacity,omitempty" json:"maxVDiskCapacity,omitempty"` @@ -73,9 +78,18 @@ type CreateRequest struct { UniqPools []string `url:"uniqPools,omitempty" json:"uniqPools,omitempty"` // Advanced compute features, - // one of: hugepages, numa, cpupin, vfnic, dpdk, changemac + // one of: hugepages, numa, cpupin, vfnic, dpdk, changemac, trunk // Required: false ComputeFeatures []string `url:"computeFeatures,omitempty" json:"computeFeatures,omitempty" validate:"omitempty,computeFeatures"` + + // SDN access group id + // Required: false + SDNAccessGroupID string `url:"sdn_access_group_id,omitempty" json:"sdn_access_group_id,omitempty"` +} + +type StoragePolicy struct { + ID uint64 `url:"id" json:"id"` + Limit int `url:"limit" json:"limit"` } // Create creates resource group @@ -87,7 +101,7 @@ func (r RG) Create(ctx context.Context, req CreateRequest) (uint64, error) { url := "/cloudbroker/rg/create" - res, err := r.client.DecortApiCall(ctx, http.MethodPost, url, req) + res, err := r.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req) if err != nil { return 0, err } diff --git a/pkg/cloudbroker/rg/del_storage_policy.go b/pkg/cloudbroker/rg/del_storage_policy.go new file mode 100644 index 0000000..a6d71c7 --- /dev/null +++ b/pkg/cloudbroker/rg/del_storage_policy.go @@ -0,0 +1,42 @@ +package rg + +import ( + "context" + "net/http" + "strconv" + + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" +) + +// DelStoragePolicyRequest struct for deleting storage policy to the resource group +type DelStoragePolicyRequest struct { + // ID of resource group + // Required: true + RGID uint64 `url:"resgroup_id" json:"resgroup_id" validate:"required"` + + // ID of the storage policy to which to disconnect account + // Required: true + StoragePolicyID uint64 `url:"storage_policy_id" json:"storage_policy_id" validate:"required"` +} + +// DelStoragePolicy delete storage policy to the account. +func (r RG) DelStoragePolicy(ctx context.Context, req DelStoragePolicyRequest) (bool, error) { + err := validators.ValidateRequest(req) + if err != nil { + return false, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/rg/del_storage_policy" + + res, err := r.client.DecortApiCall(ctx, http.MethodPost, url, req) + if err != nil { + return false, err + } + + result, err := strconv.ParseBool(string(res)) + if err != nil { + return false, err + } + + return result, nil +} diff --git a/pkg/cloudbroker/rg/delete.go b/pkg/cloudbroker/rg/delete.go index c0cd6a7..3ad9ca0 100644 --- a/pkg/cloudbroker/rg/delete.go +++ b/pkg/cloudbroker/rg/delete.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // DeleteRequest struct to delete resource group diff --git a/pkg/cloudbroker/rg/disable.go b/pkg/cloudbroker/rg/disable.go index 172fbb2..7f701ed 100644 --- a/pkg/cloudbroker/rg/disable.go +++ b/pkg/cloudbroker/rg/disable.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // DisableRequest struct to disable resource group diff --git a/pkg/cloudbroker/rg/enable.go b/pkg/cloudbroker/rg/enable.go index 579ff0a..11c6c64 100644 --- a/pkg/cloudbroker/rg/enable.go +++ b/pkg/cloudbroker/rg/enable.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // EnableRequest struct to enable resource group diff --git a/pkg/cloudbroker/rg/get.go b/pkg/cloudbroker/rg/get.go index 68f706b..17ea22c 100644 --- a/pkg/cloudbroker/rg/get.go +++ b/pkg/cloudbroker/rg/get.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // GetRequest struct to get detailed information about resource group diff --git a/pkg/cloudbroker/rg/get_resource_consumption.go b/pkg/cloudbroker/rg/get_resource_consumption.go index c556419..4b75cf4 100644 --- a/pkg/cloudbroker/rg/get_resource_consumption.go +++ b/pkg/cloudbroker/rg/get_resource_consumption.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // GetResourceConsumptionRequest struct to get detailed information about resource consumption for ResGroup diff --git a/pkg/cloudbroker/rg/list.go b/pkg/cloudbroker/rg/list.go index dd6c9dd..7f8c1d6 100644 --- a/pkg/cloudbroker/rg/list.go +++ b/pkg/cloudbroker/rg/list.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ListRequest struct to get list of resource groups diff --git a/pkg/cloudbroker/rg/list_computes.go b/pkg/cloudbroker/rg/list_computes.go index 82d807c..b5eaa9c 100644 --- a/pkg/cloudbroker/rg/list_computes.go +++ b/pkg/cloudbroker/rg/list_computes.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ListComputesRequest struct to get list of computes diff --git a/pkg/cloudbroker/rg/list_deleted.go b/pkg/cloudbroker/rg/list_deleted.go index d12818a..400bef3 100644 --- a/pkg/cloudbroker/rg/list_deleted.go +++ b/pkg/cloudbroker/rg/list_deleted.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ListDeletedRequest struct to get list of deleted resource groups diff --git a/pkg/cloudbroker/rg/list_lb.go b/pkg/cloudbroker/rg/list_lb.go index 2ab3e6a..f6dfa9b 100644 --- a/pkg/cloudbroker/rg/list_lb.go +++ b/pkg/cloudbroker/rg/list_lb.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ListLBRequest struct to get list of load balancers diff --git a/pkg/cloudbroker/rg/list_pfw.go b/pkg/cloudbroker/rg/list_pfw.go index 97da9cb..e7231fb 100644 --- a/pkg/cloudbroker/rg/list_pfw.go +++ b/pkg/cloudbroker/rg/list_pfw.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ListPFWRequest struct to get list of port forward rules diff --git a/pkg/cloudbroker/rg/list_vins.go b/pkg/cloudbroker/rg/list_vins.go index 4cfa256..9df83b0 100644 --- a/pkg/cloudbroker/rg/list_vins.go +++ b/pkg/cloudbroker/rg/list_vins.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ListVINSRequest struct to get list of VINSes diff --git a/pkg/cloudbroker/rg/mass_delete.go b/pkg/cloudbroker/rg/mass_delete.go index 5672124..1ced46d 100644 --- a/pkg/cloudbroker/rg/mass_delete.go +++ b/pkg/cloudbroker/rg/mass_delete.go @@ -4,7 +4,7 @@ import ( "context" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // MassDeleteRequest struct to delete several resource groups @@ -26,18 +26,18 @@ type MassDeleteRequest struct { } // MassDelete starts jobs to delete several resource groups -func (r RG) MassDelete(ctx context.Context, req MassDeleteRequest) (bool, error) { +func (r RG) MassDelete(ctx context.Context, req MassDeleteRequest) (string, error) { err := validators.ValidateRequest(req) if err != nil { - return false, validators.ValidationErrors(validators.GetErrors(err)) + return "", validators.ValidationErrors(validators.GetErrors(err)) } url := "/cloudbroker/rg/massDelete" - _, err = r.client.DecortApiCall(ctx, http.MethodPost, url, req) + res, err := r.client.DecortApiCall(ctx, http.MethodPost, url, req) if err != nil { - return false, err + return "", err } - return true, nil + return string(res), nil } diff --git a/pkg/cloudbroker/rg/mass_disable.go b/pkg/cloudbroker/rg/mass_disable.go index 1f7cdcc..72bb2a6 100644 --- a/pkg/cloudbroker/rg/mass_disable.go +++ b/pkg/cloudbroker/rg/mass_disable.go @@ -4,7 +4,7 @@ import ( "context" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // MassDisableRequest struct to disable several resource groups @@ -15,18 +15,18 @@ type MassDisableRequest struct { } // MassDisable start jobs to disable several resource groups -func (r RG) MassDisable(ctx context.Context, req MassDisableRequest) (bool, error) { +func (r RG) MassDisable(ctx context.Context, req MassDisableRequest) (string, error) { err := validators.ValidateRequest(req) if err != nil { - return false, validators.ValidationErrors(validators.GetErrors(err)) + return "", validators.ValidationErrors(validators.GetErrors(err)) } url := "/cloudbroker/rg/massDisable" - _, err = r.client.DecortApiCall(ctx, http.MethodPost, url, req) + res, err := r.client.DecortApiCall(ctx, http.MethodPost, url, req) if err != nil { - return false, err + return "", err } - return true, nil + return string(res), nil } diff --git a/pkg/cloudbroker/rg/mass_enable.go b/pkg/cloudbroker/rg/mass_enable.go index 5950e8d..3fd810b 100644 --- a/pkg/cloudbroker/rg/mass_enable.go +++ b/pkg/cloudbroker/rg/mass_enable.go @@ -4,7 +4,7 @@ import ( "context" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // MassEnableRequest struct to enable several resource groups @@ -15,18 +15,18 @@ type MassEnableRequest struct { } // MassEnable start jobs to enable several resource groups -func (r RG) MassEnable(ctx context.Context, req MassEnableRequest) (bool, error) { +func (r RG) MassEnable(ctx context.Context, req MassEnableRequest) (string, error) { err := validators.ValidateRequest(req) if err != nil { - return false, validators.ValidationErrors(validators.GetErrors(err)) + return "", validators.ValidationErrors(validators.GetErrors(err)) } url := "/cloudbroker/rg/massEnable" - _, err = r.client.DecortApiCall(ctx, http.MethodPost, url, req) + res, err := r.client.DecortApiCall(ctx, http.MethodPost, url, req) if err != nil { - return false, err + return "", err } - return true, nil + return string(res), nil } diff --git a/pkg/cloudbroker/rg/models.go b/pkg/cloudbroker/rg/models.go index c09ea4e..3fbe1e7 100644 --- a/pkg/cloudbroker/rg/models.go +++ b/pkg/cloudbroker/rg/models.go @@ -126,6 +126,9 @@ type ResourceLimits struct { // GPU units GPUUnits float64 `json:"gpu_units"` + + // Storage policies + StoragePolicies []StoragePolicy `json:"storage_policy"` } // Detailed information about resource group @@ -202,9 +205,15 @@ type ItemRG struct { // Resource types list ResTypes []string `json:"resourceTypes"` + // SDN access group id + SDNAccessGroupID string `json:"sdn_access_group_id"` + // Secret Secret string `json:"secret"` + // Storage policy ids + StoragePolicyIDs []uint64 `json:"storage_policy_ids"` + // Status Status string `json:"status"` diff --git a/pkg/cloudbroker/rg/remove_def_net.go b/pkg/cloudbroker/rg/remove_def_net.go index 4ab2313..bac97b0 100644 --- a/pkg/cloudbroker/rg/remove_def_net.go +++ b/pkg/cloudbroker/rg/remove_def_net.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // RemoveDefNetRequest struct to remove default network diff --git a/pkg/cloudbroker/rg/restore.go b/pkg/cloudbroker/rg/restore.go index 805bfa5..d548fb7 100644 --- a/pkg/cloudbroker/rg/restore.go +++ b/pkg/cloudbroker/rg/restore.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // RestoreRequest struct to restore resource group diff --git a/pkg/cloudbroker/rg/rg.go b/pkg/cloudbroker/rg/rg.go index c83074f..40c76e2 100644 --- a/pkg/cloudbroker/rg/rg.go +++ b/pkg/cloudbroker/rg/rg.go @@ -2,7 +2,7 @@ package rg import ( - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/interfaces" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/interfaces" ) // Structure for creating request to resource group diff --git a/pkg/cloudbroker/rg/serialize.go b/pkg/cloudbroker/rg/serialize.go index 74b70de..31e5fa3 100644 --- a/pkg/cloudbroker/rg/serialize.go +++ b/pkg/cloudbroker/rg/serialize.go @@ -3,7 +3,7 @@ package rg import ( "encoding/json" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/serialization" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/serialization" ) // Serialize returns JSON-serialized []byte. Used as a wrapper over json.Marshal and json.MarshalIndent functions. diff --git a/pkg/cloudbroker/rg/set_cpu_allocation_parameter.go b/pkg/cloudbroker/rg/set_cpu_allocation_parameter.go index c0b0410..bcf31a4 100644 --- a/pkg/cloudbroker/rg/set_cpu_allocation_parameter.go +++ b/pkg/cloudbroker/rg/set_cpu_allocation_parameter.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // SetCPUAllocationParameterRequest struct for setting CPU allocation parameter diff --git a/pkg/cloudbroker/rg/set_cpu_allocation_ratio.go b/pkg/cloudbroker/rg/set_cpu_allocation_ratio.go index 40820b6..e22959e 100644 --- a/pkg/cloudbroker/rg/set_cpu_allocation_ratio.go +++ b/pkg/cloudbroker/rg/set_cpu_allocation_ratio.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // SetCPUAllocationRatioRequest struct for setting CPU allocation ratio diff --git a/pkg/cloudbroker/rg/set_def_net.go b/pkg/cloudbroker/rg/set_def_net.go index 3de86f5..9ecd9ba 100644 --- a/pkg/cloudbroker/rg/set_def_net.go +++ b/pkg/cloudbroker/rg/set_def_net.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // SetDefNetRequest struct to set default network diff --git a/pkg/cloudbroker/rg/update.go b/pkg/cloudbroker/rg/update.go index d843699..347b885 100644 --- a/pkg/cloudbroker/rg/update.go +++ b/pkg/cloudbroker/rg/update.go @@ -5,7 +5,8 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/constants" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // UpdateRequest struct to update resource group @@ -50,6 +51,10 @@ type UpdateRequest struct { // Default: false // Required: false ClearUniqPools bool `url:"clearUniqPools" json:"clearUniqPools"` + + // Storage policies + // Required: false + StoragePolicies []StoragePolicy `url:"-" json:"storage_policies,omitempty"` } // Update updates resource group @@ -61,7 +66,7 @@ func (r RG) Update(ctx context.Context, req UpdateRequest) (bool, error) { url := "/cloudbroker/rg/update" - res, err := r.client.DecortApiCall(ctx, http.MethodPost, url, req) + res, err := r.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req) if err != nil { return false, err } diff --git a/pkg/cloudbroker/rg/update_compute_features.go b/pkg/cloudbroker/rg/update_compute_features.go index 5afef70..dac8701 100644 --- a/pkg/cloudbroker/rg/update_compute_features.go +++ b/pkg/cloudbroker/rg/update_compute_features.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // UpdateComputeFeaturesRequest struct to update advanced compute features diff --git a/pkg/cloudbroker/rg/update_resource_types.go b/pkg/cloudbroker/rg/update_resource_types.go index 66ea0a0..de916f5 100644 --- a/pkg/cloudbroker/rg/update_resource_types.go +++ b/pkg/cloudbroker/rg/update_resource_types.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // UpdateResourceTypesRequest struct to update resource types in account diff --git a/pkg/cloudbroker/rg/usage.go b/pkg/cloudbroker/rg/usage.go index 8320d35..83dcdaf 100644 --- a/pkg/cloudbroker/rg/usage.go +++ b/pkg/cloudbroker/rg/usage.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // UsageRequest struct to get report of resource usage diff --git a/pkg/cloudbroker/secgroup/create.go b/pkg/cloudbroker/secgroup/create.go new file mode 100644 index 0000000..f9f46a8 --- /dev/null +++ b/pkg/cloudbroker/secgroup/create.go @@ -0,0 +1,46 @@ +package secgroup + +import ( + "context" + "net/http" + "strconv" + + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/constants" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" +) + +type CreateRequest struct { + // Account ID that owns security group + // Required: true + AccountID uint64 `url:"account_id" json:"account_id" validate:"required"` + + // Security group name + // Required: true + Name string `url:"name" json:"name" validate:"required"` + + // Security group description + // Required: false + Description string `url:"description,omitempty" json:"description,omitempty"` +} + +func (sg SecurityGroup) Create(ctx context.Context, req CreateRequest) (uint64, error) { + err := validators.ValidateRequest(req) + if err != nil { + return 0, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/security_group/create" + + res, err := sg.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req) + if err != nil { + return 0, err + } + + result, err := strconv.ParseUint(string(res), 10, 64) + if err != nil { + return 0, err + } + + return result, nil + +} diff --git a/pkg/cloudbroker/secgroup/create_rule.go b/pkg/cloudbroker/secgroup/create_rule.go new file mode 100644 index 0000000..7ce6ae5 --- /dev/null +++ b/pkg/cloudbroker/secgroup/create_rule.go @@ -0,0 +1,63 @@ +package secgroup + +import ( + "context" + "net/http" + "strconv" + + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/constants" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" +) + +type CreateRuleRequest struct { + // Security group ID + // Required: true + SecurityGroupID uint64 `url:"security_group_id" json:"security_group_id" validate:"required"` + + // Traffic direction (inbound/outbound) + // Required: true + Direction string `url:"direction" json:"direction" validate:"required,securityGroupDirection"` + + // IP protocol version + // Default: IPv4 + // Required: false + Ethertype string `url:"ethertype,omitempty" json:"ethertype,omitempty" validate:"omitempty,securityGroupEthertype"` + + // Network protocol, available values : icmp, tcp, udp + // Required: false + Protocol string `url:"protocol,omitempty" json:"protocol,omitempty" validate:"omitempty,securityGroupProtocol"` + + // Start port number (for TCP/UDP) + // Required: false + PortRangeMin uint64 `url:"port_range_min,omitempty" json:"port_range_min,omitempty"` + + // End port number (for TCP/UDP) + // Required: false + PortRangeMax uint64 `url:"port_range_max,omitempty" json:"port_range_max,omitempty"` + + // Remote IP prefix in CIDR notation + // Required: false + RemoteIPPrefix string `url:"remote_ip_prefix,omitempty" json:"remote_ip_prefix,omitempty"` +} + +func (sg SecurityGroup) CreateRule(ctx context.Context, req CreateRuleRequest) (uint64, error) { + err := validators.ValidateRequest(req) + if err != nil { + return 0, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/security_group/create_rule" + + res, err := sg.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req) + if err != nil { + return 0, err + } + + result, err := strconv.ParseUint(string(res), 10, 64) + if err != nil { + return 0, err + } + + return result, nil + +} diff --git a/pkg/cloudbroker/secgroup/delete.go b/pkg/cloudbroker/secgroup/delete.go new file mode 100644 index 0000000..8d416f2 --- /dev/null +++ b/pkg/cloudbroker/secgroup/delete.go @@ -0,0 +1,36 @@ +package secgroup + +import ( + "context" + "net/http" + "strconv" + + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" +) + +type DeleteRequest struct { + // Security group ID + // Required: true + SecurityGroupID uint64 `url:"security_group_id" json:"security_group_id" validate:"required"` +} + +func (sg SecurityGroup) Delete(ctx context.Context, req DeleteRequest) (bool, error) { + err := validators.ValidateRequest(req) + if err != nil { + return false, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/security_group/delete" + + res, err := sg.client.DecortApiCall(ctx, http.MethodPost, url, req) + if err != nil { + return false, err + } + + result, err := strconv.ParseBool(string(res)) + if err != nil { + return false, err + } + + return result, nil +} diff --git a/pkg/cloudbroker/secgroup/delete_rule.go b/pkg/cloudbroker/secgroup/delete_rule.go new file mode 100644 index 0000000..8e7304e --- /dev/null +++ b/pkg/cloudbroker/secgroup/delete_rule.go @@ -0,0 +1,40 @@ +package secgroup + +import ( + "context" + "net/http" + "strconv" + + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" +) + +type DeleteRuleRequest struct { + // Security group ID + // Required: true + SecurityGroupID uint64 `url:"security_group_id" json:"security_group_id" validate:"required"` + + // Rule ID + // Required: true + RuleID uint64 `url:"rule_id" json:"rule_id" validate:"required"` +} + +func (sg SecurityGroup) DeleteRule(ctx context.Context, req DeleteRuleRequest) (bool, error) { + err := validators.ValidateRequest(req) + if err != nil { + return false, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/security_group/delete_rule" + + res, err := sg.client.DecortApiCall(ctx, http.MethodPost, url, req) + if err != nil { + return false, err + } + + result, err := strconv.ParseBool(string(res)) + if err != nil { + return false, err + } + + return result, nil +} diff --git a/pkg/cloudbroker/secgroup/filter.go b/pkg/cloudbroker/secgroup/filter.go new file mode 100644 index 0000000..6a03da3 --- /dev/null +++ b/pkg/cloudbroker/secgroup/filter.go @@ -0,0 +1,80 @@ +package secgroup + +// FilterByID returns ListSecurityGroups with specified ID. +func (lsg ListSecurityGroups) FilterByID(id uint64) ListSecurityGroups { + predicate := func(isg ItemSecurityGroup) bool { + return isg.ID == id + } + + return lsg.FilterFunc(predicate) +} + +// FilterByID returns ListSecurityGroups with specified Name. +func (lsg ListSecurityGroups) FilterByName(name string) ListSecurityGroups { + predicate := func(isg ItemSecurityGroup) bool { + return isg.Name == name + } + + return lsg.FilterFunc(predicate) +} + +// FilterByCreatedBy returns ListSecurityGroups with specified CreatedBy. +func (lsg ListSecurityGroups) FilterByCreatedBy(createdBy string) ListSecurityGroups { + predicate := func(isg ItemSecurityGroup) bool { + return isg.CreatedBy == createdBy + } + + return lsg.FilterFunc(predicate) +} + +// FilterByDescription returns ListSecurityGroups with specified Description. +func (lsg ListSecurityGroups) FilterByDescription(description string) ListSecurityGroups { + predicate := func(isg ItemSecurityGroup) bool { + return isg.Description == description + } + + return lsg.FilterFunc(predicate) +} + +// FilterByUpdatedBy returns ListSecurityGroups with specified UpdatedBy. +func (lsg ListSecurityGroups) FilterByUpdatedBy(updatedBy string) ListSecurityGroups { + predicate := func(isg ItemSecurityGroup) bool { + return isg.UpdatedBy == updatedBy + } + + return lsg.FilterFunc(predicate) +} + +// FilterByAccountID returns ListSecurityGroups with specified AccountID. +func (lsg ListSecurityGroups) FilterByAccountID(accountID uint64) ListSecurityGroups { + predicate := func(isg ItemSecurityGroup) bool { + return isg.AccountID == accountID + } + + return lsg.FilterFunc(predicate) +} + +// FilterFunc allows filtering ListSecurityGroups based on a user-specified predicate. +func (lsg ListSecurityGroups) FilterFunc(predicate func(ItemSecurityGroup) bool) ListSecurityGroups { + var result ListSecurityGroups + + for _, item := range lsg.Data { + if predicate(item) { + result.Data = append(result.Data, item) + } + } + + result.EntryCount = uint64(len(result.Data)) + + return result +} + +// FindOne returns first found ItemSecurityGroup +// If none was found, returns an empty struct. +func (lsg ListSecurityGroups) FindOne() ItemSecurityGroup { + if len(lsg.Data) == 0 { + return ItemSecurityGroup{} + } + + return lsg.Data[0] +} diff --git a/pkg/cloudbroker/secgroup/filter_test.go b/pkg/cloudbroker/secgroup/filter_test.go new file mode 100644 index 0000000..2231f60 --- /dev/null +++ b/pkg/cloudbroker/secgroup/filter_test.go @@ -0,0 +1,87 @@ +package secgroup + +import "testing" + +var securityGroups = ListSecurityGroups{ + Data: []ItemSecurityGroup{ + { + ID: 1, + AccountID: 1, + Name: "sg1", + Description: "some desc", + CreatedBy: "user", + }, + { + ID: 3, + AccountID: 3, + Name: "sg3", + Description: "some desc", + CreatedBy: "anotheruser", + }, + { + ID: 5, + AccountID: 3, + Name: "sg5", + Description: "some other desc", + CreatedBy: "anotheruser", + UpdatedBy: "user", + }, + }, + EntryCount: 3, +} + +func TestFilterByID(t *testing.T) { + actual := securityGroups.FilterByID(1).FindOne() + if actual.ID != 1 { + t.Fatal("expected ID 1, found: ", actual.ID) + } +} + +func TestFilterByName(t *testing.T) { + actual := securityGroups.FilterByName("sg3").FindOne() + if actual.Name != "sg3" { + t.Fatal("expected Name sg3, found: ", actual.Name) + } +} + +func TestFilterByDescription(t *testing.T) { + actual := securityGroups.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 := securityGroups.FilterByAccountID(1).FindOne() + if actual.AccountID != 1 { + t.Fatal("expected AccountID 1, found: ", actual.AccountID) + } +} + +func TestFilterByCreatedBy(t *testing.T) { + actual := securityGroups.FilterByCreatedBy("anotheruser") + + if len(actual.Data) != 2 { + t.Fatal("expected 2 found, actual: ", len(actual.Data)) + } + + for _, item := range actual.Data { + if item.CreatedBy != "anotheruser" { + t.Fatal("expected CreatedBy 'anotheruser', found: ", item.CreatedBy) + } + } +} + +func TestFilterByUpdatedBy(t *testing.T) { + actual := securityGroups.FilterByUpdatedBy("user").FindOne() + if actual.UpdatedBy != "user" { + t.Fatal("expected UpdatedBy 'user', found: ", actual.UpdatedBy) + } +} diff --git a/pkg/cloudbroker/secgroup/get.go b/pkg/cloudbroker/secgroup/get.go new file mode 100644 index 0000000..43c6bc7 --- /dev/null +++ b/pkg/cloudbroker/secgroup/get.go @@ -0,0 +1,43 @@ +package secgroup + +import ( + "context" + "encoding/json" + "net/http" + + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" +) + +type GetRequest struct { + // ID of security group + // Required: true + SecurityGroupID uint64 `url:"security_group_id" json:"security_group_id" validate:"required"` +} + +func (sg SecurityGroup) Get(ctx context.Context, req GetRequest) (*RecordSecurityGroup, error) { + res, err := sg.GetRaw(ctx, req) + if err != nil { + return nil, err + } + + info := RecordSecurityGroup{} + + err = json.Unmarshal(res, &info) + if err != nil { + return nil, err + } + + return &info, nil +} + +func (sg SecurityGroup) GetRaw(ctx context.Context, req GetRequest) ([]byte, error) { + err := validators.ValidateRequest(req) + if err != nil { + return nil, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/security_group/get" + + res, err := sg.client.DecortApiCall(ctx, http.MethodGet, url, req) + return res, err +} diff --git a/pkg/cloudbroker/secgroup/list.go b/pkg/cloudbroker/secgroup/list.go new file mode 100644 index 0000000..c0e245d --- /dev/null +++ b/pkg/cloudbroker/secgroup/list.go @@ -0,0 +1,86 @@ +package secgroup + +import ( + "context" + "encoding/json" + "net/http" + + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" +) + +type ListRequest struct { + // Search by security group id + // Required: false + ByID uint64 `url:"by_id,omitempty" json:"by_id,omitempty"` + + // Search by account id + // Required: false + AccountID uint64 `url:"account_id,omitempty" json:"account_id,omitempty"` + + // Search by security group name + // Required: false + Name string `url:"name,omitempty" json:"name,omitempty"` + + // Search by security group description + // Required: false + Description string `url:"description,omitempty" json:"description,omitempty"` + + // Search by created after time (unix timestamp) + // Required: false + CreatedMin uint64 `url:"created_min,omitempty" json:"created_min,omitempty"` + + // Search by created before time (unix timestamp) + // Required: false + CreatedMax uint64 `url:"created_max,omitempty" json:"created_max,omitempty"` + + // Search by updated after time (unix timestamp) + // Required: false + UpdatedMin uint64 `url:"updated_min,omitempty" json:"updated_min,omitempty"` + + // Search by updated before time (unix timestamp) + // Required: false + UpdatedMax uint64 `url:"updated_max,omitempty" json:"updated_max,omitempty"` + + // Sort by one of supported fields, format ± + // Required: false + SortBy string `url:"sort_by,omitempty" json:"sort_by,omitempty"` + + // Page number + // Required: false + Page uint64 `url:"page,omitempty" json:"page,omitempty"` + + // Page size + // Required: false + Size uint64 `url:"size,omitempty" json:"size,omitempty"` +} + +// List gets list of security groups as a ListSecurityGroups struct +func (sg SecurityGroup) List(ctx context.Context, req ListRequest) (*ListSecurityGroups, error) { + + res, err := sg.ListRaw(ctx, req) + if err != nil { + return nil, err + } + + list := ListSecurityGroups{} + + err = json.Unmarshal(res, &list) + if err != nil { + return nil, err + } + + return &list, nil +} + +// ListRaw gets list of security groups as an array of bytes +func (sg SecurityGroup) ListRaw(ctx context.Context, req ListRequest) ([]byte, error) { + + if err := validators.ValidateRequest(req); err != nil { + return nil, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/security_group/list" + + res, err := sg.client.DecortApiCall(ctx, http.MethodGet, url, req) + return res, err +} diff --git a/pkg/cloudbroker/secgroup/models.go b/pkg/cloudbroker/secgroup/models.go new file mode 100644 index 0000000..766d731 --- /dev/null +++ b/pkg/cloudbroker/secgroup/models.go @@ -0,0 +1,94 @@ +package secgroup + +type ListSecurityGroups struct { + // List + Data []ItemSecurityGroup `json:"data"` + + // Entry count + EntryCount uint64 `json:"entryCount"` +} + +type ItemSecurityGroup struct { + // ID of the security group + ID uint64 `json:"id"` + + // Account ID that owns the security group + AccountID uint64 `json:"account_id"` + + // Name of the security group + Name string `json:"name"` + + // Description of the security group + Description string `json:"description"` + + // List of rules + Rules Rules `json:"rules"` + + // Created at + CreatedAt uint64 `json:"created_at"` + + // Updated at + UpdatedAt uint64 `json:"updated_at"` + + // Created by + CreatedBy string `json:"created_by"` + + // Updated by + UpdatedBy string `json:"updated_by"` +} + +type RecordSecurityGroup struct { + // ID of the security group + ID uint64 `json:"id"` + + // Account ID that owns the security group + AccountID uint64 `json:"account_id"` + + // Name of the security group + Name string `json:"name"` + + // Description of the security group + Description string `json:"description"` + + // List of rules + Rules Rules `json:"rules"` + + // Created at + CreatedAt uint64 `json:"created_at"` + + // Updated at + UpdatedAt uint64 `json:"updated_at"` + + // Created by + CreatedBy string `json:"created_by"` + + // Updated by + UpdatedBy string `json:"updated_by"` +} + +type Rules []Rule + +type Rule struct { + // ID of the rule + ID uint64 `json:"id"` + + // Traffic direction (inbound/outbound) + Direction string `json:"direction"` + + // IP protocol version + Ethertype string `json:"ethertype"` + + // Network protocol + Protocol string `json:"protocol"` + + // Start port number (for TCP/UDP) + PortRangeMin uint64 `json:"port_range_min"` + + // End port number (for TCP/UDP) + PortRangeMax uint64 `json:"port_range_max"` + + // Remote IP prefix in CIDR notation + RemoteIPPrefix string `json:"remote_ip_prefix"` + + RemoteGroupID uint64 `json:"remote_group_id"` +} diff --git a/pkg/cloudbroker/secgroup/security_group.go b/pkg/cloudbroker/secgroup/security_group.go new file mode 100644 index 0000000..5563b4c --- /dev/null +++ b/pkg/cloudbroker/secgroup/security_group.go @@ -0,0 +1,15 @@ +package secgroup + +import "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/interfaces" + +// Structure for creating request to storage policy +type SecurityGroup struct { + client interfaces.Caller +} + +// Builder for stack endpoint +func New(client interfaces.Caller) *SecurityGroup { + return &SecurityGroup{ + client: client, + } +} diff --git a/pkg/cloudbroker/secgroup/sorting.go b/pkg/cloudbroker/secgroup/sorting.go new file mode 100644 index 0000000..57df52b --- /dev/null +++ b/pkg/cloudbroker/secgroup/sorting.go @@ -0,0 +1,41 @@ +package secgroup + +import "sort" + +// SortByCreatedAt sorts ListSecurityGroups by the CreatedAt field in ascending order. +// +// If inverse param is set to true, the order is reversed. +func (lsg ListSecurityGroups) SortByCreatedAt(inverse bool) ListSecurityGroups { + if len(lsg.Data) < 2 { + return lsg + } + + sort.Slice(lsg.Data, func(i, j int) bool { + if inverse { + return lsg.Data[i].CreatedAt > lsg.Data[j].CreatedAt + } + + return lsg.Data[i].CreatedAt < lsg.Data[j].CreatedAt + }) + + return lsg +} + +// SortByUpdatedAt sorts ListSecurityGroups by the UpdatedAt field in ascending order. +// +// If inverse param is set to true, the order is reversed. +func (lsg ListSecurityGroups) SortByUpdatedAt(inverse bool) ListSecurityGroups { + if len(lsg.Data) < 2 { + return lsg + } + + sort.Slice(lsg.Data, func(i, j int) bool { + if inverse { + return lsg.Data[i].UpdatedAt > lsg.Data[j].UpdatedAt + } + + return lsg.Data[i].UpdatedAt < lsg.Data[j].UpdatedAt + }) + + return lsg +} diff --git a/pkg/cloudbroker/secgroup/update.go b/pkg/cloudbroker/secgroup/update.go new file mode 100644 index 0000000..3d63d4a --- /dev/null +++ b/pkg/cloudbroker/secgroup/update.go @@ -0,0 +1,51 @@ +package secgroup + +import ( + "context" + "encoding/json" + "net/http" + + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" +) + +type UpdateRequest struct { + // Security group ID + // Required: true + SecurityGroupID uint64 `url:"security_group_id" json:"security_group_id" validate:"required"` + + // New security group name + // Required: false + Name string `url:"name,omitempty" json:"name,omitempty"` + + // New security group description + // Required: false + Description string `url:"description,omitempty" json:"description,omitempty"` +} + +func (sg SecurityGroup) Update(ctx context.Context, req UpdateRequest) (*RecordSecurityGroup, error) { + res, err := sg.UpdateRaw(ctx, req) + if err != nil { + return nil, err + } + + info := RecordSecurityGroup{} + + err = json.Unmarshal(res, &info) + if err != nil { + return nil, err + } + + return &info, nil +} + +func (sg SecurityGroup) UpdateRaw(ctx context.Context, req UpdateRequest) ([]byte, error) { + err := validators.ValidateRequest(req) + if err != nil { + return nil, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/security_group/update" + + res, err := sg.client.DecortApiCall(ctx, http.MethodPost, url, req) + return res, err +} diff --git a/pkg/cloudbroker/securitygroup.go b/pkg/cloudbroker/securitygroup.go new file mode 100644 index 0000000..9b92b88 --- /dev/null +++ b/pkg/cloudbroker/securitygroup.go @@ -0,0 +1,10 @@ +package cloudbroker + +import ( + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/pkg/cloudbroker/secgroup" +) + +// Accessing the Security Group method group +func (cb *CloudBroker) SecurityGroup() *secgroup.SecurityGroup { + return secgroup.New(cb.client) +} diff --git a/pkg/cloudbroker/sep.go b/pkg/cloudbroker/sep.go index 2d5c513..b49bf45 100644 --- a/pkg/cloudbroker/sep.go +++ b/pkg/cloudbroker/sep.go @@ -1,6 +1,6 @@ package cloudbroker -import "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/pkg/cloudbroker/sep" +import "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/pkg/cloudbroker/sep" // Accessing the SEP method group func (cb *CloudBroker) SEP() *sep.SEP { diff --git a/pkg/cloudbroker/sep/access_grant.go b/pkg/cloudbroker/sep/access_grant.go index 14d5af4..4ba5945 100644 --- a/pkg/cloudbroker/sep/access_grant.go +++ b/pkg/cloudbroker/sep/access_grant.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // AccessGrantRequest struct to grant access to SEP diff --git a/pkg/cloudbroker/sep/access_grant_to_pool.go b/pkg/cloudbroker/sep/access_grant_to_pool.go index ee33450..0e25466 100644 --- a/pkg/cloudbroker/sep/access_grant_to_pool.go +++ b/pkg/cloudbroker/sep/access_grant_to_pool.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // AccessGrantToPoolRequest struct to grant access to pool SEP diff --git a/pkg/cloudbroker/sep/access_revoke.go b/pkg/cloudbroker/sep/access_revoke.go index 94e96c1..2be8c6c 100644 --- a/pkg/cloudbroker/sep/access_revoke.go +++ b/pkg/cloudbroker/sep/access_revoke.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // AccessRevokeRequest struct to revoke access to SEP diff --git a/pkg/cloudbroker/sep/access_revoke_to_pool.go b/pkg/cloudbroker/sep/access_revoke_to_pool.go index 64d701b..0e70bb4 100644 --- a/pkg/cloudbroker/sep/access_revoke_to_pool.go +++ b/pkg/cloudbroker/sep/access_revoke_to_pool.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // AccessRevokeToPoolRequest struct to revoke access to pool SEP diff --git a/pkg/cloudbroker/sep/add_consumer_nodes.go b/pkg/cloudbroker/sep/add_consumer_nodes.go index 047518b..41c1d3e 100644 --- a/pkg/cloudbroker/sep/add_consumer_nodes.go +++ b/pkg/cloudbroker/sep/add_consumer_nodes.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // AddConsumerNodesRequest struct to add consumer nodes diff --git a/pkg/cloudbroker/sep/add_pool.go b/pkg/cloudbroker/sep/add_pool.go index 4b239d0..f0a6599 100644 --- a/pkg/cloudbroker/sep/add_pool.go +++ b/pkg/cloudbroker/sep/add_pool.go @@ -4,7 +4,7 @@ import ( "context" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // AddPoolRequest struct to add pool to storage endpoint (SEP) diff --git a/pkg/cloudbroker/sep/add_provider_nodes.go b/pkg/cloudbroker/sep/add_provider_nodes.go index b43668a..40cca59 100644 --- a/pkg/cloudbroker/sep/add_provider_nodes.go +++ b/pkg/cloudbroker/sep/add_provider_nodes.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // AddProviderNodesRequest struct to add provider nodes diff --git a/pkg/cloudbroker/sep/config_field_edit.go b/pkg/cloudbroker/sep/config_field_edit.go index 28fadc4..c82aecd 100644 --- a/pkg/cloudbroker/sep/config_field_edit.go +++ b/pkg/cloudbroker/sep/config_field_edit.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ConfigFieldEditRequest struct to edit config fields diff --git a/pkg/cloudbroker/sep/config_insert.go b/pkg/cloudbroker/sep/config_insert.go index 4419aa8..6b5e355 100644 --- a/pkg/cloudbroker/sep/config_insert.go +++ b/pkg/cloudbroker/sep/config_insert.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ConfigInsertRequest struct to insert config diff --git a/pkg/cloudbroker/sep/config_validate.go b/pkg/cloudbroker/sep/config_validate.go index 60ab364..0f442e6 100644 --- a/pkg/cloudbroker/sep/config_validate.go +++ b/pkg/cloudbroker/sep/config_validate.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ConfigValidateRequest struct to validate config diff --git a/pkg/cloudbroker/sep/consumption.go b/pkg/cloudbroker/sep/consumption.go index 6a6fb64..e2fc788 100644 --- a/pkg/cloudbroker/sep/consumption.go +++ b/pkg/cloudbroker/sep/consumption.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ConsumptionRequest struct to get consumption info diff --git a/pkg/cloudbroker/sep/create.go b/pkg/cloudbroker/sep/create.go index 8d46dd2..b39f802 100644 --- a/pkg/cloudbroker/sep/create.go +++ b/pkg/cloudbroker/sep/create.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // CreateRequest struct to create SEP object diff --git a/pkg/cloudbroker/sep/decommission.go b/pkg/cloudbroker/sep/decommission.go index 86db6a8..6167d55 100644 --- a/pkg/cloudbroker/sep/decommission.go +++ b/pkg/cloudbroker/sep/decommission.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // DecommissionRequest struct for decommission diff --git a/pkg/cloudbroker/sep/del_consumer_nodes.go b/pkg/cloudbroker/sep/del_consumer_nodes.go index 08e20ab..80a29a8 100644 --- a/pkg/cloudbroker/sep/del_consumer_nodes.go +++ b/pkg/cloudbroker/sep/del_consumer_nodes.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // DelConsumerNodesRequest struct to exclude consumer nodes diff --git a/pkg/cloudbroker/sep/del_pool.go b/pkg/cloudbroker/sep/del_pool.go index 4c5b6c8..d034688 100644 --- a/pkg/cloudbroker/sep/del_pool.go +++ b/pkg/cloudbroker/sep/del_pool.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // DelPoolRequest struct to delete pool from storage endpoint (SEP) diff --git a/pkg/cloudbroker/sep/delete.go b/pkg/cloudbroker/sep/delete.go index 0aa7c6b..698dd05 100644 --- a/pkg/cloudbroker/sep/delete.go +++ b/pkg/cloudbroker/sep/delete.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // DeleteRequest struct to delete SEP diff --git a/pkg/cloudbroker/sep/disable.go b/pkg/cloudbroker/sep/disable.go index 5d97987..d233fec 100644 --- a/pkg/cloudbroker/sep/disable.go +++ b/pkg/cloudbroker/sep/disable.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // DisableRequest struct to disable SEP diff --git a/pkg/cloudbroker/sep/disk_list.go b/pkg/cloudbroker/sep/disk_list.go index 150cb2c..5eb88aa 100644 --- a/pkg/cloudbroker/sep/disk_list.go +++ b/pkg/cloudbroker/sep/disk_list.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // DiskListRequest struct to get list of disk IDs diff --git a/pkg/cloudbroker/sep/enable.go b/pkg/cloudbroker/sep/enable.go index f363b6b..dda46f9 100644 --- a/pkg/cloudbroker/sep/enable.go +++ b/pkg/cloudbroker/sep/enable.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // EnableRequest struct to enable SEP diff --git a/pkg/cloudbroker/sep/get.go b/pkg/cloudbroker/sep/get.go index 1dd0cc7..7b13a3f 100644 --- a/pkg/cloudbroker/sep/get.go +++ b/pkg/cloudbroker/sep/get.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // GetRequest struct to get SEP parameters diff --git a/pkg/cloudbroker/sep/get_config.go b/pkg/cloudbroker/sep/get_config.go index 60a0500..90362cd 100644 --- a/pkg/cloudbroker/sep/get_config.go +++ b/pkg/cloudbroker/sep/get_config.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // GetConfigRequest struct to get SEP config diff --git a/pkg/cloudbroker/sep/get_pool.go b/pkg/cloudbroker/sep/get_pool.go index 6dd0b8d..952b00f 100644 --- a/pkg/cloudbroker/sep/get_pool.go +++ b/pkg/cloudbroker/sep/get_pool.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // GetPoolRequest struct to get SEP pool config by name diff --git a/pkg/cloudbroker/sep/get_template.go b/pkg/cloudbroker/sep/get_template.go index 0571df9..df383b9 100644 --- a/pkg/cloudbroker/sep/get_template.go +++ b/pkg/cloudbroker/sep/get_template.go @@ -4,7 +4,7 @@ import ( "context" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // GetTemplateRequest struct to get template of SEP diff --git a/pkg/cloudbroker/sep/list.go b/pkg/cloudbroker/sep/list.go index ad0da82..8890103 100644 --- a/pkg/cloudbroker/sep/list.go +++ b/pkg/cloudbroker/sep/list.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ListRequest struct to get list of SEPs diff --git a/pkg/cloudbroker/sep/list_available_sep_and_pools.go b/pkg/cloudbroker/sep/list_available_sep_and_pools.go index 68b6823..9e911f9 100644 --- a/pkg/cloudbroker/sep/list_available_sep_and_pools.go +++ b/pkg/cloudbroker/sep/list_available_sep_and_pools.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ListAvailableSEPAndPoolsRequest struct to get dict with entry count and list of dict with SEPs and pools details accessible by the Account and RG diff --git a/pkg/cloudbroker/sep/sep.go b/pkg/cloudbroker/sep/sep.go index 26fb750..bc306b7 100644 --- a/pkg/cloudbroker/sep/sep.go +++ b/pkg/cloudbroker/sep/sep.go @@ -2,7 +2,7 @@ package sep import ( - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/interfaces" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/interfaces" ) // Structure for creating request to storage endpoint provider diff --git a/pkg/cloudbroker/sep/serialize.go b/pkg/cloudbroker/sep/serialize.go index 306ccb6..d78c17a 100644 --- a/pkg/cloudbroker/sep/serialize.go +++ b/pkg/cloudbroker/sep/serialize.go @@ -3,7 +3,7 @@ package sep import ( "encoding/json" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/serialization" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/serialization" ) // Serialize returns JSON-serialized []byte. Used as a wrapper over json.Marshal and json.MarshalIndent functions. diff --git a/pkg/cloudbroker/sep/shared_lock_start.go b/pkg/cloudbroker/sep/shared_lock_start.go index ae8b11f..5875110 100644 --- a/pkg/cloudbroker/sep/shared_lock_start.go +++ b/pkg/cloudbroker/sep/shared_lock_start.go @@ -6,7 +6,7 @@ import ( "strconv" "strings" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // SharedLockStartRequest struct to start shared locks diff --git a/pkg/cloudbroker/sep/shared_lock_stop.go b/pkg/cloudbroker/sep/shared_lock_stop.go index a7ef01e..db1dd86 100644 --- a/pkg/cloudbroker/sep/shared_lock_stop.go +++ b/pkg/cloudbroker/sep/shared_lock_stop.go @@ -6,7 +6,7 @@ import ( "strconv" "strings" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // SharedLockStopRequest struct to stop shared locks diff --git a/pkg/cloudbroker/stack.go b/pkg/cloudbroker/stack.go index a48ccea..fd5f817 100644 --- a/pkg/cloudbroker/stack.go +++ b/pkg/cloudbroker/stack.go @@ -1,7 +1,7 @@ package cloudbroker import ( - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/pkg/cloudbroker/stack" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/pkg/cloudbroker/stack" ) // Accessing the Stack method group diff --git a/pkg/cloudbroker/stack/get.go b/pkg/cloudbroker/stack/get.go index 2d16232..50061fc 100644 --- a/pkg/cloudbroker/stack/get.go +++ b/pkg/cloudbroker/stack/get.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // GetRequest struct to get list of stacks diff --git a/pkg/cloudbroker/stack/get_logical_cores_count.go b/pkg/cloudbroker/stack/get_logical_cores_count.go index 12efdbd..93403be 100644 --- a/pkg/cloudbroker/stack/get_logical_cores_count.go +++ b/pkg/cloudbroker/stack/get_logical_cores_count.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // GetLogicalCoresCountRequest struct to get logical cores count by stack diff --git a/pkg/cloudbroker/stack/list.go b/pkg/cloudbroker/stack/list.go index 932f2a6..efb4050 100644 --- a/pkg/cloudbroker/stack/list.go +++ b/pkg/cloudbroker/stack/list.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ListRequest struct to get list of stacks diff --git a/pkg/cloudbroker/stack/set_cpu_allocation_ratio.go b/pkg/cloudbroker/stack/set_cpu_allocation_ratio.go index 337bc7f..b4eeb38 100644 --- a/pkg/cloudbroker/stack/set_cpu_allocation_ratio.go +++ b/pkg/cloudbroker/stack/set_cpu_allocation_ratio.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // SetCpuAllocationRatioRequest struct to set CPU allocation ratio diff --git a/pkg/cloudbroker/stack/set_mem_allocation_ratio.go b/pkg/cloudbroker/stack/set_mem_allocation_ratio.go index cec3605..376a93a 100644 --- a/pkg/cloudbroker/stack/set_mem_allocation_ratio.go +++ b/pkg/cloudbroker/stack/set_mem_allocation_ratio.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // SetMemAllocationRatioRequest struct to set memory allocation ratio diff --git a/pkg/cloudbroker/stack/stack.go b/pkg/cloudbroker/stack/stack.go index bae6f29..2297168 100644 --- a/pkg/cloudbroker/stack/stack.go +++ b/pkg/cloudbroker/stack/stack.go @@ -1,6 +1,6 @@ package stack -import "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/interfaces" +import "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/interfaces" // Structure for creating request to stack type Stack struct { diff --git a/pkg/cloudbroker/storage_policy.go b/pkg/cloudbroker/storage_policy.go new file mode 100644 index 0000000..7ac05ab --- /dev/null +++ b/pkg/cloudbroker/storage_policy.go @@ -0,0 +1,10 @@ +package cloudbroker + +import ( + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/pkg/cloudbroker/stpolicy" +) + +// Accessing the Storage Policy method group +func (cb *CloudBroker) StPolicy() *stpolicy.StPolicy { + return stpolicy.New(cb.client) +} diff --git a/pkg/cloudbroker/stpolicy/add_pool.go b/pkg/cloudbroker/stpolicy/add_pool.go new file mode 100644 index 0000000..3099c81 --- /dev/null +++ b/pkg/cloudbroker/stpolicy/add_pool.go @@ -0,0 +1,51 @@ +package stpolicy + +import ( + "context" + "encoding/json" + "net/http" + + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" +) + +type AddPoolRequest struct { + // ID of storage policy + // Required: true + StoragePolicyID uint64 `url:"storage_policy_id" json:"storage_policy_id" validate:"required"` + + // Storage endpoint provider ID to add + // Required: true + SEPID uint64 `url:"sep_id" json:"sep_id" validate:"required"` + + // Pool to add + // Required: true + PoolName string `url:"pool_name" json:"pool_name" validate:"required"` +} + +func (sp StPolicy) AddPool(ctx context.Context, req AddPoolRequest) (*InfoStoragePolicyWithID, error) { + res, err := sp.AddPoolRaw(ctx, req) + if err != nil { + return nil, err + } + + info := InfoStoragePolicyWithID{} + + err = json.Unmarshal(res, &info) + if err != nil { + return nil, err + } + + return &info, nil +} + +func (sp StPolicy) AddPoolRaw(ctx context.Context, req AddPoolRequest) ([]byte, error) { + err := validators.ValidateRequest(req) + if err != nil { + return nil, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/storage_policy/add_pool" + + res, err := sp.client.DecortApiCall(ctx, http.MethodPost, url, req) + return res, err +} diff --git a/pkg/cloudbroker/stpolicy/create.go b/pkg/cloudbroker/stpolicy/create.go new file mode 100644 index 0000000..d0d49ae --- /dev/null +++ b/pkg/cloudbroker/stpolicy/create.go @@ -0,0 +1,63 @@ +package stpolicy + +import ( + "context" + "net/http" + "strconv" + + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/constants" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" +) + +type AccessSEPsPool struct { + + // Storage endpoint provider ID + // Required: true + SEPID uint64 `url:"sep_id" json:"sep_id" validate:"required"` + + // Names of pools + // Required: true + PoolNames []string `url:"pool_names" json:"pool_names" validate:"required"` +} + +type CreateRequest struct { + // Name of the storage policy + // Required: true + Name string `url:"name" json:"name" validate:"required"` + + // List of storage endpoint access objects + // Required: true + AccessSEPsPools []AccessSEPsPool `url:"access_seps_pools" json:"access_seps_pools" validate:"required"` + + // Description of the storage policy + // Required: false + Description string `url:"description,omitempty" json:"description,omitempty"` + + // Maximum IOPS limit + // Default: 2000 + // Required: false + LimitIOPS uint64 `url:"limit_iops,omitempty" json:"limit_iops,omitempty"` +} + +// Create creates a new storage policy +func (sp StPolicy) Create(ctx context.Context, req CreateRequest) (uint64, error) { + err := validators.ValidateRequest(req) + if err != nil { + return 0, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/storage_policy/create" + + res, err := sp.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req) + if err != nil { + return 0, err + } + + result, err := strconv.ParseUint(string(res), 10, 64) + if err != nil { + return 0, err + } + + return result, nil + +} diff --git a/pkg/cloudbroker/stpolicy/delete.go b/pkg/cloudbroker/stpolicy/delete.go new file mode 100644 index 0000000..6b0ffa6 --- /dev/null +++ b/pkg/cloudbroker/stpolicy/delete.go @@ -0,0 +1,36 @@ +package stpolicy + +import ( + "context" + "net/http" + "strconv" + + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" +) + +type DeleteRequest struct { + // ID of storage policy to delete + // Required: true + StoragePolicyID uint64 `url:"storage_policy_id" json:"storage_policy_id" validate:"required"` +} + +func (sp StPolicy) Delete(ctx context.Context, req DeleteRequest) (bool, error) { + err := validators.ValidateRequest(req) + if err != nil { + return false, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/storage_policy/delete" + + res, err := sp.client.DecortApiCall(ctx, http.MethodPost, url, req) + if err != nil { + return false, err + } + + result, err := strconv.ParseBool(string(res)) + if err != nil { + return false, err + } + + return result, nil +} diff --git a/pkg/cloudbroker/stpolicy/delete_pool.go b/pkg/cloudbroker/stpolicy/delete_pool.go new file mode 100644 index 0000000..d4b8629 --- /dev/null +++ b/pkg/cloudbroker/stpolicy/delete_pool.go @@ -0,0 +1,51 @@ +package stpolicy + +import ( + "context" + "encoding/json" + "net/http" + + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" +) + +type DeletePoolRequest struct { + // ID of storage policy + // Required: true + StoragePolicyID uint64 `url:"storage_policy_id" json:"storage_policy_id" validate:"required"` + + // Storage endpoint provider ID to delete + // Required: true + SEPID uint64 `url:"sep_id" json:"sep_id" validate:"required"` + + // Pool to delete + // Required: true + PoolName string `url:"pool_name" json:"pool_name" validate:"required"` +} + +func (sp StPolicy) DeletePool(ctx context.Context, req DeletePoolRequest) (*InfoStoragePolicyWithID, error) { + res, err := sp.DeletePoolRaw(ctx, req) + if err != nil { + return nil, err + } + + info := InfoStoragePolicyWithID{} + + err = json.Unmarshal(res, &info) + if err != nil { + return nil, err + } + + return &info, nil +} + +func (sp StPolicy) DeletePoolRaw(ctx context.Context, req DeletePoolRequest) ([]byte, error) { + err := validators.ValidateRequest(req) + if err != nil { + return nil, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/storage_policy/delete_pool" + + res, err := sp.client.DecortApiCall(ctx, http.MethodPost, url, req) + return res, err +} diff --git a/pkg/cloudbroker/stpolicy/disable.go b/pkg/cloudbroker/stpolicy/disable.go new file mode 100644 index 0000000..df5e46b --- /dev/null +++ b/pkg/cloudbroker/stpolicy/disable.go @@ -0,0 +1,36 @@ +package stpolicy + +import ( + "context" + "net/http" + "strconv" + + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" +) + +type DisableRequest struct { + // ID of storage policy to disable + // Required: true + StoragePolicyID uint64 `url:"storage_policy_id" json:"storage_policy_id" validate:"required"` +} + +func (sp StPolicy) Disable(ctx context.Context, req DisableRequest) (bool, error) { + err := validators.ValidateRequest(req) + if err != nil { + return false, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/storage_policy/disable" + + res, err := sp.client.DecortApiCall(ctx, http.MethodPost, url, req) + if err != nil { + return false, err + } + + result, err := strconv.ParseBool(string(res)) + if err != nil { + return false, err + } + + return result, nil +} diff --git a/pkg/cloudbroker/stpolicy/enable.go b/pkg/cloudbroker/stpolicy/enable.go new file mode 100644 index 0000000..1026f26 --- /dev/null +++ b/pkg/cloudbroker/stpolicy/enable.go @@ -0,0 +1,36 @@ +package stpolicy + +import ( + "context" + "net/http" + "strconv" + + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" +) + +type EnableRequest struct { + // ID of storage policy to enable + // Required: true + StoragePolicyID uint64 `url:"storage_policy_id" json:"storage_policy_id" validate:"required"` +} + +func (sp StPolicy) Enable(ctx context.Context, req EnableRequest) (bool, error) { + err := validators.ValidateRequest(req) + if err != nil { + return false, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/storage_policy/enable" + + res, err := sp.client.DecortApiCall(ctx, http.MethodPost, url, req) + if err != nil { + return false, err + } + + result, err := strconv.ParseBool(string(res)) + if err != nil { + return false, err + } + + return result, nil +} diff --git a/pkg/cloudbroker/stpolicy/filter.go b/pkg/cloudbroker/stpolicy/filter.go new file mode 100644 index 0000000..25599e2 --- /dev/null +++ b/pkg/cloudbroker/stpolicy/filter.go @@ -0,0 +1,71 @@ +package stpolicy + +// FilterByID returns ListStoragePolicies with specified ID. +func (lsp ListStoragePolicies) FilterByID(id uint64) ListStoragePolicies { + predicate := func(isp ItemStoragePolicy) bool { + return isp.ID == id + } + + return lsp.FilterFunc(predicate) +} + +// FilterByName returns ListStoragePolicies with specified Name. +func (lsp ListStoragePolicies) FilterByName(name string) ListStoragePolicies { + predicate := func(isp ItemStoragePolicy) bool { + return isp.Name == name + } + + return lsp.FilterFunc(predicate) +} + +// FilterByStatus returns ListStoragePolicies with specified Status. +func (lsp ListStoragePolicies) FilterByStatus(status string) ListStoragePolicies { + predicate := func(isp ItemStoragePolicy) bool { + return isp.Status == status + } + + return lsp.FilterFunc(predicate) +} + +// FilterByStatus returns ListStoragePolicies with specified Desc. +func (lsp ListStoragePolicies) FilterByDesc(desc string) ListStoragePolicies { + predicate := func(isp ItemStoragePolicy) bool { + return isp.Description == desc + } + + return lsp.FilterFunc(predicate) +} + +// FilterByLimitIOPS returns ListStoragePolicies with specified IOPS. +func (lsp ListStoragePolicies) FilterByLimitIOPS(limitIOPS uint64) ListStoragePolicies { + predicate := func(isp ItemStoragePolicy) bool { + return isp.LimitIOPS == limitIOPS + } + + return lsp.FilterFunc(predicate) +} + +// FilterFunc allows filtering ListStoragePolicies based on a user-specified predicate. +func (lsp ListStoragePolicies) FilterFunc(predicate func(ItemStoragePolicy) bool) ListStoragePolicies { + var result ListStoragePolicies + + for _, item := range lsp.Data { + if predicate(item) { + result.Data = append(result.Data, item) + } + } + + result.EntryCount = uint64(len(result.Data)) + + return result +} + +// FindOne returns first found ItemStoragePolicy +// If none was found, returns an empty struct. +func (lsp ListStoragePolicies) FindOne() ItemStoragePolicy { + if len(lsp.Data) == 0 { + return ItemStoragePolicy{} + } + + return lsp.Data[0] +} diff --git a/pkg/cloudbroker/stpolicy/filter_test.go b/pkg/cloudbroker/stpolicy/filter_test.go new file mode 100644 index 0000000..4eacea4 --- /dev/null +++ b/pkg/cloudbroker/stpolicy/filter_test.go @@ -0,0 +1,110 @@ +package stpolicy + +import "testing" + +var asp9 = AccessSEPPool{ + SEPID: 9, + PoolNames: []string{"data03"}, +} + +var asp7 = AccessSEPPool{ + SEPID: 7, + PoolNames: []string{"pool_QA"}, +} + +var asp8 = AccessSEPPool{ + SEPID: 8, + PoolNames: []string{ + "alpha_pool_block", + "alpha_pool_stripe", + "alpha_pool_file", + }, +} + +var storagePolicyItems = ListStoragePolicies{ + Data: []ItemStoragePolicy{ + { + ID: 1, + GUID: 1, + Name: "storagePolicy01", + Description: "desc", + AccessSEPPools: ListAccessSEPPools{asp7}, + Status: "ENABLED", + LimitIOPS: 2000, + Usage: Usage{}, + }, + { + ID: 3, + GUID: 3, + Name: "storagePolicy03", + Description: "desc", + AccessSEPPools: ListAccessSEPPools{asp7, asp8, asp9}, + Status: "ENABLED", + LimitIOPS: 2500, + Usage: Usage{}, + }, + { + ID: 5, + GUID: 5, + Name: "storagePolicy05", + Description: "another desc", + AccessSEPPools: ListAccessSEPPools{asp8, asp9}, + Status: "DISABLED", + LimitIOPS: 2000, + Usage: Usage{}, + }, + }, + EntryCount: 3, +} + +func TestFilterByID(t *testing.T) { + actual := storagePolicyItems.FilterByID(1).FindOne() + + if actual.ID != 1 { + t.Fatal("expected 1 ID, found: ", actual.ID) + } +} + +func TestFilterByName(t *testing.T) { + actual := storagePolicyItems.FilterByName("storagePolicy01").FindOne() + + if actual.Name != "storagePolicy01" { + t.Fatal("expected Name 'storagePolicy01', found: ", actual.Name) + } +} + +func TestFilterByStatus(t *testing.T) { + actual := storagePolicyItems.FilterByStatus("ENABLED") + + if len(actual.Data) != 2 { + t.Fatal("expected 2 found, actual: ", len(actual.Data)) + } + + for _, item := range actual.Data { + if item.Status != "ENABLED" { + t.Fatal("expected Status 'ENABLED', found: ", item.Status) + } + } +} + +func TestFilterByDesc(t *testing.T) { + actual := storagePolicyItems.FilterByDesc("desc") + + if len(actual.Data) != 2 { + t.Fatal("expected 2 found, actual: ", len(actual.Data)) + } + + for _, item := range actual.Data { + if item.Description != "desc" { + t.Fatal("expected Description 'desc', found: ", item.Status) + } + } +} + +func TestFilterByLimitIOPS(t *testing.T) { + actual := storagePolicyItems.FilterByLimitIOPS(2500).FindOne() + + if actual.LimitIOPS != 2500 { + t.Fatal("expected LimitIOPS '2500', found: ", actual.LimitIOPS) + } +} diff --git a/pkg/cloudbroker/stpolicy/get.go b/pkg/cloudbroker/stpolicy/get.go new file mode 100644 index 0000000..306a5f5 --- /dev/null +++ b/pkg/cloudbroker/stpolicy/get.go @@ -0,0 +1,43 @@ +package stpolicy + +import ( + "context" + "encoding/json" + "net/http" + + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" +) + +type GetRequest struct { + // ID of storage policy + // Required: true + StoragePolicyID uint64 `url:"storage_policy_id" json:"storage_policy_id" validate:"required"` +} + +func (sp StPolicy) Get(ctx context.Context, req GetRequest) (*InfoStoragePolicy, error) { + res, err := sp.GetRaw(ctx, req) + if err != nil { + return nil, err + } + + info := InfoStoragePolicy{} + + err = json.Unmarshal(res, &info) + if err != nil { + return nil, err + } + + return &info, nil +} + +func (sp StPolicy) GetRaw(ctx context.Context, req GetRequest) ([]byte, error) { + err := validators.ValidateRequest(req) + if err != nil { + return nil, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/storage_policy/get" + + res, err := sp.client.DecortApiCall(ctx, http.MethodGet, url, req) + return res, err +} diff --git a/pkg/cloudbroker/stpolicy/list.go b/pkg/cloudbroker/stpolicy/list.go new file mode 100644 index 0000000..eca605c --- /dev/null +++ b/pkg/cloudbroker/stpolicy/list.go @@ -0,0 +1,90 @@ +package stpolicy + +import ( + "context" + "encoding/json" + "net/http" + + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/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"` + + // Search by storage policy ID + // Required: false + ByID uint64 `url:"by_id,omitempty" json:"by_id,omitempty"` + + // Search by storage policy name + // Required: false + Name string `url:"name,omitempty" json:"name,omitempty"` + + // Search by storage policy status + // Required: false + Status string `url:"status,omitempty" json:"status,omitempty"` + + // Search by storage policy desc + // Required: false + Desc string `url:"desc,omitempty" json:"desc,omitempty"` + + // Search by storage policy iops limit + // Required: false + LimitIOPS uint64 `url:"limit_iops,omitempty" json:"limit_iops,omitempty"` + + // Sort by one of supported fields, format ± + // Required: false + SortBy string `url:"sort_by,omitempty" json:"sort_by,omitempty"` + + // ID of account ID + // Required: false + AccountID uint64 `url:"account_id,omitempty" json:"account_id,omitempty"` + + // Search by resgroup id + // Required: false + ResgroupID uint64 `url:"resgroup_id,omitempty" json:"resgroup_id,omitempty"` + + // Search by sep id + // Required: false + SepID uint64 `url:"sep_id,omitempty" json:"sep_id,omitempty"` + + // Search by pool name + // Required: false + PoolName string `url:"pool_name,omitempty" json:"pool_name,omitempty"` +} + +// List gets list of storage policies as a ListStoragePolicies struct +func (sp StPolicy) List(ctx context.Context, req ListRequest) (*ListStoragePolicies, error) { + + res, err := sp.ListRaw(ctx, req) + if err != nil { + return nil, err + } + + list := ListStoragePolicies{} + + err = json.Unmarshal(res, &list) + if err != nil { + return nil, err + } + + return &list, nil +} + +// ListRaw gets list of storage policies as an array of bytes +func (sp StPolicy) ListRaw(ctx context.Context, req ListRequest) ([]byte, error) { + + if err := validators.ValidateRequest(req); err != nil { + return nil, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/storage_policy/list" + + res, err := sp.client.DecortApiCall(ctx, http.MethodGet, url, req) + return res, err +} diff --git a/pkg/cloudbroker/stpolicy/models.go b/pkg/cloudbroker/stpolicy/models.go new file mode 100644 index 0000000..e298fc6 --- /dev/null +++ b/pkg/cloudbroker/stpolicy/models.go @@ -0,0 +1,108 @@ +package stpolicy + +type InfoStoragePolicyWithID struct { + // ID of the storage policy + ID uint64 `json:"id"` + + // GUID + GUID uint64 `json:"guid"` + + // Name of the storage policy + Name string `json:"name"` + + // Description of the storage policy + Description string `json:"description"` + + // List of pools in SEP for storage policy + AccessSEPPools ListAccessSEPPools `json:"access_seps_pools"` + + // Status of the storage policy + Status string `json:"status"` + + // Max IOPS for the sotrage policy + LimitIOPS uint64 `json:"limit_iops"` + + // ID of the storage policy + StoragePolicyID uint64 `json:"storage_policy_id"` +} + +type ListStoragePolicies struct { + // List + Data []ItemStoragePolicy `json:"data"` + + // Entry Count + EntryCount uint64 `json:"entryCount"` +} + +type ItemStoragePolicy struct { + // ID of the storage policy + ID uint64 `json:"id"` + + // GUID + GUID uint64 `json:"guid"` + + // Name of the storage policy + Name string `json:"name"` + + // Description of the storage policy + Description string `json:"description"` + + // List of pools in SEP for storage policy + AccessSEPPools ListAccessSEPPools `json:"access_seps_pools"` + + // Status of the storage policy + Status string `json:"status"` + + // Max IOPS for the sotrage policy + LimitIOPS uint64 `json:"limit_iops"` + + // Which accounts and resource groups use the storage policy + Usage Usage `json:"usage"` +} + +type InfoStoragePolicy struct { + // ID of the storage policy + ID uint64 `json:"id"` + + // GUID + GUID uint64 `json:"guid"` + + // Name of the storage policy + Name string `json:"name"` + + // Description of the storage policy + Description string `json:"description"` + + // List of pools in SEP for storage policy + AccessSEPPools ListAccessSEPPools `json:"access_seps_pools"` + + // Status of the storage policy + Status string `json:"status"` + + // Max IOPS for the storage policy + LimitIOPS uint64 `json:"limit_iops"` + + // Which accounts and resource groups use the storage policy + Usage Usage `json:"usage"` +} + +type ListAccessSEPPools []AccessSEPPool + +type AccessSEPPool struct { + // SEP ID + SEPID uint64 `json:"sep_id"` + + // SEP name + Name string `json:"sep_name"` + + // Pool names + PoolNames []string `json:"pool_names"` +} + +type Usage struct { + // List of accounts + Accounts []uint64 `json:"accounts"` + + // List of resource groups + Resgroups []uint64 `json:"resgroups"` +} diff --git a/pkg/cloudbroker/stpolicy/storage_policy.go b/pkg/cloudbroker/stpolicy/storage_policy.go new file mode 100644 index 0000000..061f7c4 --- /dev/null +++ b/pkg/cloudbroker/stpolicy/storage_policy.go @@ -0,0 +1,15 @@ +package stpolicy + +import "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/interfaces" + +// Structure for creating request to storage policy +type StPolicy struct { + client interfaces.Caller +} + +// Builder for stack endpoint +func New(client interfaces.Caller) *StPolicy { + return &StPolicy{ + client: client, + } +} diff --git a/pkg/cloudbroker/stpolicy/update.go b/pkg/cloudbroker/stpolicy/update.go new file mode 100644 index 0000000..e473506 --- /dev/null +++ b/pkg/cloudbroker/stpolicy/update.go @@ -0,0 +1,56 @@ +package stpolicy + +import ( + "context" + "encoding/json" + "net/http" + + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" +) + +type UpdateRequest struct { + // ID of storage policy + // Required: true + StoragePolicyID uint64 `url:"storage_policy_id" json:"storage_policy_id" validate:"required"` + + // New name for the storage policy + // Required: false + Name string `url:"name,omitempty" json:"name,omitempty"` + + // New value for limit IOPS + // Required: false + LimitIOPS uint64 `url:"limit_iops,omitempty" json:"limit_iops,omitempty"` + + // New description of the storage policy + // Required: false + Description string `url:"description,omitempty" json:"description,omitempty"` +} + +// Update updates storage policy +func (sp StPolicy) Update(ctx context.Context, req UpdateRequest) (*InfoStoragePolicyWithID, error) { + res, err := sp.UpdateRaw(ctx, req) + if err != nil { + return nil, err + } + + info := InfoStoragePolicyWithID{} + + err = json.Unmarshal(res, &info) + if err != nil { + return nil, err + } + + return &info, nil +} + +func (sp StPolicy) UpdateRaw(ctx context.Context, req UpdateRequest) ([]byte, error) { + err := validators.ValidateRequest(req) + if err != nil { + return nil, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/storage_policy/update" + + res, err := sp.client.DecortApiCall(ctx, http.MethodPost, url, req) + return res, err +} diff --git a/pkg/cloudbroker/tasks.go b/pkg/cloudbroker/tasks.go index 09f5bfc..4f887b3 100644 --- a/pkg/cloudbroker/tasks.go +++ b/pkg/cloudbroker/tasks.go @@ -1,7 +1,7 @@ package cloudbroker import ( - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/pkg/cloudbroker/tasks" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/pkg/cloudbroker/tasks" ) // Accessing the tasks method group diff --git a/pkg/cloudbroker/tasks/get.go b/pkg/cloudbroker/tasks/get.go index b026188..667c792 100644 --- a/pkg/cloudbroker/tasks/get.go +++ b/pkg/cloudbroker/tasks/get.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // GetRequest struct to get background API task status and result diff --git a/pkg/cloudbroker/tasks/list.go b/pkg/cloudbroker/tasks/list.go index 6a805f1..2d9b382 100644 --- a/pkg/cloudbroker/tasks/list.go +++ b/pkg/cloudbroker/tasks/list.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ListRequest struct to get list of audits diff --git a/pkg/cloudbroker/tasks/models.go b/pkg/cloudbroker/tasks/models.go index f2cbd13..43b7c17 100644 --- a/pkg/cloudbroker/tasks/models.go +++ b/pkg/cloudbroker/tasks/models.go @@ -28,9 +28,6 @@ type ItemTask struct { // Error Error string `json:"error"` - // GUID - GUID string `json:"guid"` - // List of logs Log []string `json:"log"` diff --git a/pkg/cloudbroker/tasks/tasks.go b/pkg/cloudbroker/tasks/tasks.go index 6fffad2..c4e822e 100644 --- a/pkg/cloudbroker/tasks/tasks.go +++ b/pkg/cloudbroker/tasks/tasks.go @@ -1,7 +1,7 @@ // User API tasks interface package tasks -import "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/interfaces" +import "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/interfaces" // Structure for creating request to tasks type Tasks struct { diff --git a/pkg/cloudbroker/trunk.go b/pkg/cloudbroker/trunk.go new file mode 100644 index 0000000..7754497 --- /dev/null +++ b/pkg/cloudbroker/trunk.go @@ -0,0 +1,10 @@ +package cloudbroker + +import ( + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/pkg/cloudbroker/trunk" +) + +// Accessing the Trunk method group +func (cb *CloudBroker) Trunk() *trunk.Trunk { + return trunk.New(cb.client) +} diff --git a/pkg/cloudbroker/trunk/access_grant.go b/pkg/cloudbroker/trunk/access_grant.go new file mode 100644 index 0000000..d7f0137 --- /dev/null +++ b/pkg/cloudbroker/trunk/access_grant.go @@ -0,0 +1,42 @@ +package trunk + +import ( + "context" + "net/http" + "strconv" + + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" +) + +// AccessGrant struct to grant access to a trunk to some accounts +type AccessGrantRequest struct { + // ID of the trunk to disable + // Required: true + TrunkID uint64 `url:"id" json:"id" validate:"required"` + + // IDs of the accounts to grant access to + // Required: true + AccountIDs []uint64 `url:"account_ids" json:"account_ids" validate:"required"` +} + +// AccessGrant grants access to a trunk +func (t Trunk) AccessGrant(ctx context.Context, req AccessGrantRequest) (bool, error) { + err := validators.ValidateRequest(req) + if err != nil { + return false, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/trunk/access_grant" + + res, err := t.client.DecortApiCall(ctx, http.MethodPost, url, req) + if err != nil { + return false, err + } + + result, err := strconv.ParseBool(string(res)) + if err != nil { + return false, err + } + + return result, nil +} diff --git a/pkg/cloudbroker/trunk/access_revoke.go b/pkg/cloudbroker/trunk/access_revoke.go new file mode 100644 index 0000000..9f3c075 --- /dev/null +++ b/pkg/cloudbroker/trunk/access_revoke.go @@ -0,0 +1,42 @@ +package trunk + +import ( + "context" + "net/http" + "strconv" + + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" +) + +// AccessRevoke struct to grant access to a trunk to some accounts +type AccessRevokeRequest struct { + // ID of the trunk to disable + // Required: true + TrunkID uint64 `url:"id" json:"id" validate:"required"` + + // IDs of the accounts to revoke access from + // Required: true + AccountIDs []uint64 `url:"account_ids" json:"account_ids" validate:"required"` +} + +// AccessRevoke revokes access to a trunk from accounts +func (t Trunk) AccessRevoke(ctx context.Context, req AccessRevokeRequest) (bool, error) { + err := validators.ValidateRequest(req) + if err != nil { + return false, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/trunk/access_revoke" + + res, err := t.client.DecortApiCall(ctx, http.MethodPost, url, req) + if err != nil { + return false, err + } + + result, err := strconv.ParseBool(string(res)) + if err != nil { + return false, err + } + + return result, nil +} diff --git a/pkg/cloudbroker/trunk/create.go b/pkg/cloudbroker/trunk/create.go new file mode 100644 index 0000000..44550c6 --- /dev/null +++ b/pkg/cloudbroker/trunk/create.go @@ -0,0 +1,58 @@ +package trunk + +import ( + "context" + "net/http" + "strconv" + + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" +) + +// CreateRequest struct to create a trunk +type CreateRequest struct { + // Name of the trunk + // Required: true + Name string `url:"name" json:"name" validate:"required"` + + // List of trunk tags (values between 1-4095) + // Required: true + TrunkTags string `url:"trunk_tags" json:"trunk_tags" validate:"required,trunkTags"` + + // OVS bridge name + // Required: true + OVSBridge string `url:"ovs_bridge" json:"ovs_bridge" validate:"required"` + + // Description of the trunk + // Required: false + Description string `url:"description,omitempty" json:"description,omitempty"` + + // List of account IDs with access to this trunk + // Required: false + AccountIDs []uint64 `url:"account_ids,omitempty" json:"account_ids,omitempty"` + + // Native VLAN ID + // Required: false + NativeVLANID uint64 `url:"native_vlan_id,omitempty" json:"native_vlan_id,omitempty"` +} + +// Create creates a user. +func (t Trunk) Create(ctx context.Context, req CreateRequest) (uint64, error) { + err := validators.ValidateRequest(req) + if err != nil { + return 0, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/trunk/create" + + res, err := t.client.DecortApiCall(ctx, http.MethodPost, url, req) + if err != nil { + return 0, err + } + + result, err := strconv.ParseUint(string(res), 10, 64) + if err != nil { + return 0, err + } + + return result, nil +} diff --git a/pkg/cloudbroker/trunk/destroy.go b/pkg/cloudbroker/trunk/destroy.go new file mode 100644 index 0000000..af475dc --- /dev/null +++ b/pkg/cloudbroker/trunk/destroy.go @@ -0,0 +1,38 @@ +package trunk + +import ( + "context" + "net/http" + "strconv" + + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" +) + +// DestroyRequest struct to destroy a trunk +type DestroyRequest struct { + // ID of the trunk to destroy + // Required: true + TrunkID uint64 `url:"id" json:"id" validate:"required"` +} + +// Destroy destroys a trunk +func (t Trunk) Destroy(ctx context.Context, req DestroyRequest) (bool, error) { + err := validators.ValidateRequest(req) + if err != nil { + return false, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/trunk/destroy" + + res, err := t.client.DecortApiCall(ctx, http.MethodPost, url, req) + if err != nil { + return false, err + } + + result, err := strconv.ParseBool(string(res)) + if err != nil { + return false, err + } + + return result, nil +} diff --git a/pkg/cloudbroker/trunk/disable.go b/pkg/cloudbroker/trunk/disable.go new file mode 100644 index 0000000..24d16a9 --- /dev/null +++ b/pkg/cloudbroker/trunk/disable.go @@ -0,0 +1,38 @@ +package trunk + +import ( + "context" + "net/http" + "strconv" + + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" +) + +// DisableRequest struct to disable a trunk +type DisableRequest struct { + // ID of the trunk to disable + // Required: true + TrunkID uint64 `url:"id" json:"id" validate:"required"` +} + +// Disable disables a trunk by ID +func (t Trunk) Disable(ctx context.Context, req DisableRequest) (bool, error) { + err := validators.ValidateRequest(req) + if err != nil { + return false, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/trunk/disable" + + res, err := t.client.DecortApiCall(ctx, http.MethodPost, url, req) + if err != nil { + return false, err + } + + result, err := strconv.ParseBool(string(res)) + if err != nil { + return false, err + } + + return result, nil +} diff --git a/pkg/cloudbroker/trunk/enable.go b/pkg/cloudbroker/trunk/enable.go new file mode 100644 index 0000000..7899485 --- /dev/null +++ b/pkg/cloudbroker/trunk/enable.go @@ -0,0 +1,38 @@ +package trunk + +import ( + "context" + "net/http" + "strconv" + + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" +) + +// EnableRequest struct to enable a trunk +type EnableRequest struct { + // ID of the trunk to enable + // Required: true + TrunkID uint64 `url:"id" json:"id" validate:"required"` +} + +// Enable enables a trunk +func (t Trunk) Enable(ctx context.Context, req EnableRequest) (bool, error) { + err := validators.ValidateRequest(req) + if err != nil { + return false, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/trunk/enable" + + res, err := t.client.DecortApiCall(ctx, http.MethodPost, url, req) + if err != nil { + return false, err + } + + result, err := strconv.ParseBool(string(res)) + if err != nil { + return false, err + } + + return result, nil +} diff --git a/pkg/cloudbroker/trunk/get.go b/pkg/cloudbroker/trunk/get.go new file mode 100644 index 0000000..f87038c --- /dev/null +++ b/pkg/cloudbroker/trunk/get.go @@ -0,0 +1,46 @@ +package trunk + +import ( + "context" + "encoding/json" + "net/http" + + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" +) + +// GetRequest struct to get information about a trunk +type GetRequest struct { + // ID of trunk + // Required: true + TrunkID uint64 `url:"id" json:"id" validate:"required"` +} + +// Get gets detailed information about a trunk as a ItemTrunk struct +func (t Trunk) Get(ctx context.Context, req GetRequest) (*ItemTrunk, error) { + res, err := t.GetRaw(ctx, req) + if err != nil { + return nil, err + } + + info := ItemTrunk{} + + err = json.Unmarshal(res, &info) + if err != nil { + return nil, err + } + + return &info, nil +} + +// GetRaw gets detailed information about a trunk as an array of bytes +func (t Trunk) GetRaw(ctx context.Context, req GetRequest) ([]byte, error) { + err := validators.ValidateRequest(req) + if err != nil { + return nil, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/trunk/get" + + res, err := t.client.DecortApiCall(ctx, http.MethodGet, url, req) + return res, err +} diff --git a/pkg/cloudbroker/trunk/list.go b/pkg/cloudbroker/trunk/list.go new file mode 100644 index 0000000..c67904b --- /dev/null +++ b/pkg/cloudbroker/trunk/list.go @@ -0,0 +1,64 @@ +package trunk + +import ( + "context" + "encoding/json" + "net/http" + + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" +) + +// ListRequest struct to get list of trunks +type ListRequest struct { + // Account access ID to filter by + AccountIDs []uint64 `url:"account_ids,omitempty" json:"account_ids,omitempty"` + + // ID of the trunk to filter by + IDs []uint64 `url:"ids,omitempty" json:"ids,omitempty"` + + // Sort by one of supported fields, format ± + SortBy string `url:"sort_by,omitempty" json:"sort_by,omitempty"` + + // Trunk tags to filter by + TrunkTags string `url:"trunk_tags,omitempty" json:"trunk_tags,omitempty" validate:"omitempty,trunkTags"` + + // Page number + Page uint64 `url:"page,omitempty" json:"page,omitempty"` + + // Page size + Size uint64 `url:"size,omitempty" json:"size,omitempty"` + + // Status + Status string `url:"status,omitempty" json:"status,omitempty"` +} + +// List gets list of all trunks as a ListTrunks struct +func (t Trunk) List(ctx context.Context, req ListRequest) (*ListTrunks, error) { + + res, err := t.ListRaw(ctx, req) + if err != nil { + return nil, err + } + + list := ListTrunks{} + + err = json.Unmarshal(res, &list) + if err != nil { + return nil, err + } + + return &list, nil +} + +// ListRaw gets list of all trunks as an array of bytes +func (t Trunk) ListRaw(ctx context.Context, req ListRequest) ([]byte, error) { + + if err := validators.ValidateRequest(req); err != nil { + return nil, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/trunk/list" + + res, err := t.client.DecortApiCall(ctx, http.MethodGet, url, req) + return res, err +} diff --git a/pkg/cloudbroker/trunk/models.go b/pkg/cloudbroker/trunk/models.go new file mode 100644 index 0000000..de7742a --- /dev/null +++ b/pkg/cloudbroker/trunk/models.go @@ -0,0 +1,59 @@ +package trunk + +type ItemTrunk struct { + + // List of account IDs with access to this trunk + AccountIDs []uint64 `json:"accountIds"` + + // Created at + CreatedAt uint64 `json:"created_at"` + + // Created by + CreatedBy string `json:"created_by"` + + // Deleted at + DeletedAt uint64 `json:"deleted_at"` + + // Deleted by + DeletedBy string `json:"deleted_by"` + + // Description of a trunk + Description string `json:"description"` + + // GUID + GUID uint64 `json:"guid"` + + // ID of a trunk + ID uint64 `json:"id"` + + // MAC + MAC string `json:"mac"` + + // Name of a trunk + Name string `json:"name"` + + // Native VLAN ID + NativeVLANID uint64 `json:"nativeVlanId"` + + // OVS bridge name + OVSBridge string `json:"ovsBridge"` + + // If the trunk is enabled + Status string `json:"status"` + + // List of trunk tags (values between 1-4095) + TrunkTags string `json:"trunkTags"` + + // Updated at + UpdatedAt uint64 `json:"updated_at"` + + // Updated by + UpdatedBy string `json:"updated_by"` +} + +// List of trunks +type ListTrunks struct { + Data []ItemTrunk `json:"data"` + + EntryCount uint64 `json:"entryCount"` +} diff --git a/pkg/cloudbroker/trunk/trunk.go b/pkg/cloudbroker/trunk/trunk.go new file mode 100644 index 0000000..aaa87cf --- /dev/null +++ b/pkg/cloudbroker/trunk/trunk.go @@ -0,0 +1,17 @@ +package trunk + +import ( + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/interfaces" +) + +// Structure for creating request to trunk +type Trunk struct { + client interfaces.Caller +} + +// Builder for trunk endpoints +func New(client interfaces.Caller) *Trunk { + return &Trunk{ + client, + } +} diff --git a/pkg/cloudbroker/trunk/update.go b/pkg/cloudbroker/trunk/update.go new file mode 100644 index 0000000..3c48dbf --- /dev/null +++ b/pkg/cloudbroker/trunk/update.go @@ -0,0 +1,54 @@ +package trunk + +import ( + "context" + "net/http" + "strconv" + + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" +) + +// UpdateRequest struct to update a trunk +type UpdateRequest struct { + // ID of the trunk to update + // Required: true + TrunkID uint64 `url:"id" json:"id" validate:"required"` + + // New name of the trunk + // Required: true + Name string `url:"name" json:"name" validate:"required"` + + // List of trunk tags (values between 1-4095) + // Required: true + TrunkTags string `url:"trunk_tags" json:"trunk_tags" validate:"required,trunkTags"` + + // New description of the trunk + // Required: false + Description string `url:"description,omitempty" json:"description,omitempty"` + + // New native VLAN ID + // Required: false + NativeVLANID uint64 `url:"native_vlan_id,omitempty" json:"native_vlan_id,omitempty"` +} + +// Update updates a trunk +func (t Trunk) Update(ctx context.Context, req UpdateRequest) (bool, error) { + err := validators.ValidateRequest(req) + if err != nil { + return false, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/trunk/update" + + res, err := t.client.DecortApiCall(ctx, http.MethodPost, url, req) + if err != nil { + return false, err + } + + result, err := strconv.ParseBool(string(res)) + if err != nil { + return false, err + } + + return result, nil +} diff --git a/pkg/cloudbroker/user.go b/pkg/cloudbroker/user.go index d27cf3b..4661044 100644 --- a/pkg/cloudbroker/user.go +++ b/pkg/cloudbroker/user.go @@ -1,6 +1,6 @@ package cloudbroker -import "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/pkg/cloudbroker/user" +import "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/pkg/cloudbroker/user" func (cb *CloudBroker) User() *user.User { return user.New(cb.client) diff --git a/pkg/cloudbroker/user/api_list.go b/pkg/cloudbroker/user/api_list.go index ebdc062..e9682a5 100644 --- a/pkg/cloudbroker/user/api_list.go +++ b/pkg/cloudbroker/user/api_list.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // APIListRequest struct for getting API list. diff --git a/pkg/cloudbroker/user/apiaccess_join.go b/pkg/cloudbroker/user/apiaccess_join.go index 4895ef6..9cec3be 100644 --- a/pkg/cloudbroker/user/apiaccess_join.go +++ b/pkg/cloudbroker/user/apiaccess_join.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // APIAccessJoinRequest struct for joining user into apiaccess group. diff --git a/pkg/cloudbroker/user/apiaccess_leave.go b/pkg/cloudbroker/user/apiaccess_leave.go index 2943f7c..f0a106d 100644 --- a/pkg/cloudbroker/user/apiaccess_leave.go +++ b/pkg/cloudbroker/user/apiaccess_leave.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // APIAccessLeaveRequest struct for leaving user from apiaccess group. diff --git a/pkg/cloudbroker/user/apiaccess_list.go b/pkg/cloudbroker/user/apiaccess_list.go index 74a7f0d..f6e01fd 100644 --- a/pkg/cloudbroker/user/apiaccess_list.go +++ b/pkg/cloudbroker/user/apiaccess_list.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // APIAccessListRequest struct for showing list of dicts with information about diff --git a/pkg/cloudbroker/user/block.go b/pkg/cloudbroker/user/block.go new file mode 100644 index 0000000..190ac31 --- /dev/null +++ b/pkg/cloudbroker/user/block.go @@ -0,0 +1,38 @@ +package user + +import ( + "context" + "net/http" + "strconv" + + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" +) + +// BlockRequest struct to block a user. +type BlockRequest struct { + // ID of the user to block. + // Required: true + UserID string `url:"user_id" json:"user_id" validate:"required"` +} + +// Block blocks a user +func (u User) Block(ctx context.Context, req BlockRequest) (bool, error) { + err := validators.ValidateRequest(req) + if err != nil { + return false, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/user/block" + + res, err := u.client.DecortApiCall(ctx, http.MethodPost, url, req) + if err != nil { + return false, err + } + + result, err := strconv.ParseBool(string(res)) + if err != nil { + return false, err + } + + return result, nil +} diff --git a/pkg/cloudbroker/user/create.go b/pkg/cloudbroker/user/create.go index 9df3789..642509c 100644 --- a/pkg/cloudbroker/user/create.go +++ b/pkg/cloudbroker/user/create.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // CreateRequest struct for creating a user. @@ -20,15 +20,17 @@ type CreateRequest struct { // Password of user // Required: false + // Default: strongpassword Password string `url:"password,omitempty" json:"password,omitempty"` - // List of groups this user belongs to. - // Required: false - Groups []string `url:"groups,omitempty" json:"groups,omitempty"` - // List of apiaccess groups this user belongs to. // Required: false APIAccess []uint64 `url:"apiaccess,omitempty" json:"apiaccess,omitempty"` + + // Provider of user + // one of: bvs, decs3o + // Required: false + Provider string `url:"provider,omitempty" json:"provider,omitempty" validate:"omitempty,userProvider"` } // Create creates a user. diff --git a/pkg/cloudbroker/user/delete.go b/pkg/cloudbroker/user/delete.go index f9901be..7d180a7 100644 --- a/pkg/cloudbroker/user/delete.go +++ b/pkg/cloudbroker/user/delete.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // DeleteRequest struct for deleting a user. diff --git a/pkg/cloudbroker/user/delete_by_guid.go b/pkg/cloudbroker/user/delete_by_guid.go index b2aa3d8..12ef3b7 100644 --- a/pkg/cloudbroker/user/delete_by_guid.go +++ b/pkg/cloudbroker/user/delete_by_guid.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // DeleteByGUIDRequest struct for deleting a user using user's GUID. diff --git a/pkg/cloudbroker/user/delete_users.go b/pkg/cloudbroker/user/delete_users.go index eb48a96..0c43af5 100644 --- a/pkg/cloudbroker/user/delete_users.go +++ b/pkg/cloudbroker/user/delete_users.go @@ -5,14 +5,14 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // DeleteUsersRequest struct for bulk delete a list of users. type DeleteUsersRequest struct { // List of user ids // Required: true - UserIDs string `url:"userIds" json:"userIds" validate:"required"` + UserIDs []string `url:"userIds" json:"userIds" validate:"required"` } // DeleteUsers bulk delete a list of users. diff --git a/pkg/cloudbroker/user/get.go b/pkg/cloudbroker/user/get.go index c650a4c..553e1d4 100644 --- a/pkg/cloudbroker/user/get.go +++ b/pkg/cloudbroker/user/get.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // GetRequest struct to get user details. diff --git a/pkg/cloudbroker/user/get_matching_usernames.go b/pkg/cloudbroker/user/get_matching_usernames.go index b73f8a6..881045e 100644 --- a/pkg/cloudbroker/user/get_matching_usernames.go +++ b/pkg/cloudbroker/user/get_matching_usernames.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // GetMatchingUsernamesRequest struct for getting a list of the matching usernames for a given string. diff --git a/pkg/cloudbroker/user/list.go b/pkg/cloudbroker/user/list.go index d5a80e2..10cb317 100644 --- a/pkg/cloudbroker/user/list.go +++ b/pkg/cloudbroker/user/list.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ListRequest struct to get all non deleted user instances. @@ -18,6 +18,10 @@ type ListRequest struct { // Required: false Active interface{} `url:"active,omitempty" json:"active,omitempty" validate:"omitempty,isBool"` + // Find by email. + // Required: false + Email string `url:"email,omitempty" json:"email,omitempty"` + // Find by serviceaccount. True or False. // Required: false ServiceAccount interface{} `url:"serviceaccount,omitempty" json:"serviceaccount,omitempty" validate:"omitempty,isBool"` diff --git a/pkg/cloudbroker/user/models.go b/pkg/cloudbroker/user/models.go index a928088..1c2cb47 100644 --- a/pkg/cloudbroker/user/models.go +++ b/pkg/cloudbroker/user/models.go @@ -21,6 +21,9 @@ type ItemUser struct { // AuthKeys AuthKeys []interface{} + // Blocked + Blocked bool `json:"blocked"` + // Data Data string `json:"data"` diff --git a/pkg/cloudbroker/user/unblock.go b/pkg/cloudbroker/user/unblock.go new file mode 100644 index 0000000..5833c20 --- /dev/null +++ b/pkg/cloudbroker/user/unblock.go @@ -0,0 +1,38 @@ +package user + +import ( + "context" + "net/http" + "strconv" + + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" +) + +// UnblockRequest struct to block a user. +type UnblockRequest struct { + // ID of the user to block. + // Required: true + UserID string `url:"user_id" json:"user_id" validate:"required"` +} + +// Unblock unblocks a user +func (u User) Unblock(ctx context.Context, req UnblockRequest) (bool, error) { + err := validators.ValidateRequest(req) + if err != nil { + return false, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/user/unblock" + + res, err := u.client.DecortApiCall(ctx, http.MethodPost, url, req) + if err != nil { + return false, err + } + + result, err := strconv.ParseBool(string(res)) + if err != nil { + return false, err + } + + return result, nil +} diff --git a/pkg/cloudbroker/user/user.go b/pkg/cloudbroker/user/user.go index cd5cfb7..8b6fa37 100644 --- a/pkg/cloudbroker/user/user.go +++ b/pkg/cloudbroker/user/user.go @@ -1,6 +1,6 @@ package user -import "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/interfaces" +import "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/interfaces" // Structure for creating request to User type User struct { diff --git a/pkg/cloudbroker/vfpool.go b/pkg/cloudbroker/vfpool.go index e17f286..81e2ae4 100644 --- a/pkg/cloudbroker/vfpool.go +++ b/pkg/cloudbroker/vfpool.go @@ -1,6 +1,6 @@ package cloudbroker -import "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/pkg/cloudbroker/vfpool" +import "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/pkg/cloudbroker/vfpool" // Accessing the VFPool method group func (cb *CloudBroker) VFPool() *vfpool.VFPool { diff --git a/pkg/cloudbroker/vfpool/create.go b/pkg/cloudbroker/vfpool/create.go index a603145..b694878 100644 --- a/pkg/cloudbroker/vfpool/create.go +++ b/pkg/cloudbroker/vfpool/create.go @@ -6,7 +6,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // CreateRequest struct to create vfpool device diff --git a/pkg/cloudbroker/vfpool/delete.go b/pkg/cloudbroker/vfpool/delete.go index 5b7232f..3729a1e 100644 --- a/pkg/cloudbroker/vfpool/delete.go +++ b/pkg/cloudbroker/vfpool/delete.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // DeleteRequest struct to delete vfpool device diff --git a/pkg/cloudbroker/vfpool/disable.go b/pkg/cloudbroker/vfpool/disable.go index 096b00c..0ce37a6 100644 --- a/pkg/cloudbroker/vfpool/disable.go +++ b/pkg/cloudbroker/vfpool/disable.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // DisableRequest struct to disable vfpool device diff --git a/pkg/cloudbroker/vfpool/enable.go b/pkg/cloudbroker/vfpool/enable.go index 0358359..e6aa1f6 100644 --- a/pkg/cloudbroker/vfpool/enable.go +++ b/pkg/cloudbroker/vfpool/enable.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // EnableRequest struct to enable vfpool device diff --git a/pkg/cloudbroker/vfpool/get.go b/pkg/cloudbroker/vfpool/get.go index 1719db6..7f7643f 100644 --- a/pkg/cloudbroker/vfpool/get.go +++ b/pkg/cloudbroker/vfpool/get.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // GetRequest struct to get detailed information about vfpool device diff --git a/pkg/cloudbroker/vfpool/list.go b/pkg/cloudbroker/vfpool/list.go index f4a9e39..db9141d 100644 --- a/pkg/cloudbroker/vfpool/list.go +++ b/pkg/cloudbroker/vfpool/list.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ListRequest struct to get list of vfpool devices diff --git a/pkg/cloudbroker/vfpool/serialize.go b/pkg/cloudbroker/vfpool/serialize.go index a0347d1..207948c 100644 --- a/pkg/cloudbroker/vfpool/serialize.go +++ b/pkg/cloudbroker/vfpool/serialize.go @@ -3,7 +3,7 @@ package vfpool import ( "encoding/json" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/serialization" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/serialization" ) // Serialize returns JSON-serialized []byte. Used as a wrapper over json.Marshal and json.MarshalIndent functions. diff --git a/pkg/cloudbroker/vfpool/update.go b/pkg/cloudbroker/vfpool/update.go index ce5aa68..c7fb2b7 100644 --- a/pkg/cloudbroker/vfpool/update.go +++ b/pkg/cloudbroker/vfpool/update.go @@ -6,7 +6,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // UpdateRequest struct to update vfpool device diff --git a/pkg/cloudbroker/vfpool/vfpool.go b/pkg/cloudbroker/vfpool/vfpool.go index d8ca096..5dcc98e 100644 --- a/pkg/cloudbroker/vfpool/vfpool.go +++ b/pkg/cloudbroker/vfpool/vfpool.go @@ -2,7 +2,7 @@ package vfpool import ( - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/interfaces" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/interfaces" ) // Structure for creating request to vfpool diff --git a/pkg/cloudbroker/vgpu.go b/pkg/cloudbroker/vgpu.go index cf4e720..6acd377 100644 --- a/pkg/cloudbroker/vgpu.go +++ b/pkg/cloudbroker/vgpu.go @@ -1,6 +1,6 @@ package cloudbroker -import "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/pkg/cloudbroker/vgpu" +import "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/pkg/cloudbroker/vgpu" // Accessing the VGPU method group func (cb *CloudBroker) VGPU() *vgpu.VGPU { diff --git a/pkg/cloudbroker/vgpu/allocate.go b/pkg/cloudbroker/vgpu/allocate.go index 253128f..8a9c799 100644 --- a/pkg/cloudbroker/vgpu/allocate.go +++ b/pkg/cloudbroker/vgpu/allocate.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // AllocateRequest struct for allocating VGPU diff --git a/pkg/cloudbroker/vgpu/create.go b/pkg/cloudbroker/vgpu/create.go index de426d7..49db295 100644 --- a/pkg/cloudbroker/vgpu/create.go +++ b/pkg/cloudbroker/vgpu/create.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // CreateRequest struct for creating VGPU diff --git a/pkg/cloudbroker/vgpu/deallocate.go b/pkg/cloudbroker/vgpu/deallocate.go index 72eb392..50e90d3 100644 --- a/pkg/cloudbroker/vgpu/deallocate.go +++ b/pkg/cloudbroker/vgpu/deallocate.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // DeallocateRequest struct for deallocating VGPU diff --git a/pkg/cloudbroker/vgpu/destroy.go b/pkg/cloudbroker/vgpu/destroy.go index 1d90a5d..c77adb1 100644 --- a/pkg/cloudbroker/vgpu/destroy.go +++ b/pkg/cloudbroker/vgpu/destroy.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // DestroyRequest struct for destroying VGPU diff --git a/pkg/cloudbroker/vgpu/list.go b/pkg/cloudbroker/vgpu/list.go index 9711654..b620287 100644 --- a/pkg/cloudbroker/vgpu/list.go +++ b/pkg/cloudbroker/vgpu/list.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ListRequest struct to get list of VGPU diff --git a/pkg/cloudbroker/vgpu/serialize.go b/pkg/cloudbroker/vgpu/serialize.go index 548a3be..17bf664 100644 --- a/pkg/cloudbroker/vgpu/serialize.go +++ b/pkg/cloudbroker/vgpu/serialize.go @@ -3,7 +3,7 @@ package vgpu import ( "encoding/json" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/serialization" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/serialization" ) // Serialize returns JSON-serialized []byte. Used as a wrapper over json.Marshal and json.MarshalIndent functions. diff --git a/pkg/cloudbroker/vgpu/vgpu.go b/pkg/cloudbroker/vgpu/vgpu.go index 3b0b22b..e181355 100644 --- a/pkg/cloudbroker/vgpu/vgpu.go +++ b/pkg/cloudbroker/vgpu/vgpu.go @@ -1,6 +1,6 @@ package vgpu -import "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/interfaces" +import "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/interfaces" // Structure for creating request to VGPU type VGPU struct { diff --git a/pkg/cloudbroker/vins.go b/pkg/cloudbroker/vins.go index aace822..aed73d6 100644 --- a/pkg/cloudbroker/vins.go +++ b/pkg/cloudbroker/vins.go @@ -1,7 +1,7 @@ package cloudbroker import ( - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/pkg/cloudbroker/vins" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/pkg/cloudbroker/vins" ) // Accessing the VINS method group diff --git a/pkg/cloudbroker/vins/audits.go b/pkg/cloudbroker/vins/audits.go index 0407b94..9be3e45 100644 --- a/pkg/cloudbroker/vins/audits.go +++ b/pkg/cloudbroker/vins/audits.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // AuditsRequest struct to get audits diff --git a/pkg/cloudbroker/vins/create_in_account.go b/pkg/cloudbroker/vins/create_in_account.go index 1da56b4..37058c3 100644 --- a/pkg/cloudbroker/vins/create_in_account.go +++ b/pkg/cloudbroker/vins/create_in_account.go @@ -6,7 +6,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) type Route struct { @@ -53,6 +53,10 @@ type CreateInAccountRequest struct { // List of static routes, each item must have destination, netmask, and gateway fields // Required: false Routes []Route `url:"-" json:"routes,omitempty" validate:"omitempty,dive"` + + // Zone ID + // Required: false + ZoneID uint64 `url:"zoneId,omitempty" json:"zoneId,omitempty"` } type wrapperCreateRequestInAcc struct { diff --git a/pkg/cloudbroker/vins/create_in_rg.go b/pkg/cloudbroker/vins/create_in_rg.go index 0d40020..dc57315 100644 --- a/pkg/cloudbroker/vins/create_in_rg.go +++ b/pkg/cloudbroker/vins/create_in_rg.go @@ -6,7 +6,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // CreateInRGRequest struct to create VINS in resource group @@ -47,6 +47,10 @@ type CreateInRGRequest struct { // List of static routes, each item must have destination, netmask, and gateway fields // Required: false Routes []Route `url:"-" json:"routes,omitempty" validate:"omitempty,dive"` + + // Zone ID + // Required: false + ZoneID uint64 `url:"zoneId,omitempty" json:"zoneId,omitempty"` } type wrapperCreateRequestInRG struct { diff --git a/pkg/cloudbroker/vins/default_qos_update.go b/pkg/cloudbroker/vins/default_qos_update.go index 62fff22..f8b4da4 100644 --- a/pkg/cloudbroker/vins/default_qos_update.go +++ b/pkg/cloudbroker/vins/default_qos_update.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // DefaultQOSUpdateRequest struct to update QOS diff --git a/pkg/cloudbroker/vins/delete.go b/pkg/cloudbroker/vins/delete.go index 5c6bc40..d77251d 100644 --- a/pkg/cloudbroker/vins/delete.go +++ b/pkg/cloudbroker/vins/delete.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // DeleteRequest struct to delete VINS diff --git a/pkg/cloudbroker/vins/disable.go b/pkg/cloudbroker/vins/disable.go index f07a740..4acb971 100644 --- a/pkg/cloudbroker/vins/disable.go +++ b/pkg/cloudbroker/vins/disable.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // DisableRequest struct to disable VINS diff --git a/pkg/cloudbroker/vins/dns_apply.go b/pkg/cloudbroker/vins/dns_apply.go index f9dbceb..47644f4 100644 --- a/pkg/cloudbroker/vins/dns_apply.go +++ b/pkg/cloudbroker/vins/dns_apply.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // DNSApplyRequest struct to apply new DNS list in VINS diff --git a/pkg/cloudbroker/vins/enable.go b/pkg/cloudbroker/vins/enable.go index 55e9495..d46d2a6 100644 --- a/pkg/cloudbroker/vins/enable.go +++ b/pkg/cloudbroker/vins/enable.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // EnableRequest struct to enable VINS diff --git a/pkg/cloudbroker/vins/extnet_connect.go b/pkg/cloudbroker/vins/extnet_connect.go index 52ec98f..8e9e318 100644 --- a/pkg/cloudbroker/vins/extnet_connect.go +++ b/pkg/cloudbroker/vins/extnet_connect.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ExtNetConnectRequest struct to connect external network diff --git a/pkg/cloudbroker/vins/extnet_disconnect.go b/pkg/cloudbroker/vins/extnet_disconnect.go index 1fe1989..503c4be 100644 --- a/pkg/cloudbroker/vins/extnet_disconnect.go +++ b/pkg/cloudbroker/vins/extnet_disconnect.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ExtNetDisconnectRequest struct to disconnect VINS from external network diff --git a/pkg/cloudbroker/vins/extnet_list.go b/pkg/cloudbroker/vins/extnet_list.go index 57d81a0..ebab6d9 100644 --- a/pkg/cloudbroker/vins/extnet_list.go +++ b/pkg/cloudbroker/vins/extnet_list.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ExtNetListRequest struct to get list of VINS external network connections diff --git a/pkg/cloudbroker/vins/get.go b/pkg/cloudbroker/vins/get.go index 5182cd5..e886b33 100644 --- a/pkg/cloudbroker/vins/get.go +++ b/pkg/cloudbroker/vins/get.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // GetRequest struct to get information about VINS diff --git a/pkg/cloudbroker/vins/ip_list.go b/pkg/cloudbroker/vins/ip_list.go index 1bcbe4b..0dfddc1 100644 --- a/pkg/cloudbroker/vins/ip_list.go +++ b/pkg/cloudbroker/vins/ip_list.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // IPListRequest struct for DHCP IP diff --git a/pkg/cloudbroker/vins/ip_release.go b/pkg/cloudbroker/vins/ip_release.go index 2b76b4d..210d182 100644 --- a/pkg/cloudbroker/vins/ip_release.go +++ b/pkg/cloudbroker/vins/ip_release.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // IPReleaseRequest struct for IP release diff --git a/pkg/cloudbroker/vins/ip_reserve.go b/pkg/cloudbroker/vins/ip_reserve.go index ac23277..a285f66 100644 --- a/pkg/cloudbroker/vins/ip_reserve.go +++ b/pkg/cloudbroker/vins/ip_reserve.go @@ -5,7 +5,7 @@ import ( "net/http" "strings" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // IPReserveRequest struct for IP reserve diff --git a/pkg/cloudbroker/vins/list.go b/pkg/cloudbroker/vins/list.go index 42497af..9410859 100644 --- a/pkg/cloudbroker/vins/list.go +++ b/pkg/cloudbroker/vins/list.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ListRequest struct to get list of VINSes @@ -46,6 +46,11 @@ type ListRequest struct { // Required: false SortBy string `url:"sortBy,omitempty" json:"sortBy,omitempty" validate:"omitempty,sortBy"` + // Sort by zone id + // Default value: 0 + // Required: false + ZoneID uint64 `url:"zone_id,omitempty" json:"zone_id,omitempty"` + // Page number // Required: false Page uint64 `url:"page,omitempty" json:"page,omitempty"` diff --git a/pkg/cloudbroker/vins/list_deleted.go b/pkg/cloudbroker/vins/list_deleted.go index 6e50d1b..2343072 100644 --- a/pkg/cloudbroker/vins/list_deleted.go +++ b/pkg/cloudbroker/vins/list_deleted.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // ListDeletedRequest struct to get list of deleted VINSes diff --git a/pkg/cloudbroker/vins/mass_delete.go b/pkg/cloudbroker/vins/mass_delete.go index ccc60b4..a4e3af4 100644 --- a/pkg/cloudbroker/vins/mass_delete.go +++ b/pkg/cloudbroker/vins/mass_delete.go @@ -4,7 +4,7 @@ import ( "context" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // MassDeleteRequest struct to delete several VINSes @@ -28,18 +28,18 @@ type MassDeleteRequest struct { } // MassDelete start jobs to delete several VINSes -func (v VINS) MassDelete(ctx context.Context, req MassDeleteRequest) (bool, error) { +func (v VINS) MassDelete(ctx context.Context, req MassDeleteRequest) (string, error) { err := validators.ValidateRequest(req) if err != nil { - return false, validators.ValidationErrors(validators.GetErrors(err)) + return "", validators.ValidationErrors(validators.GetErrors(err)) } url := "/cloudbroker/vins/massDelete" - _, err = v.client.DecortApiCall(ctx, http.MethodPost, url, req) + res, err := v.client.DecortApiCall(ctx, http.MethodPost, url, req) if err != nil { - return false, err + return "", err } - return true, nil + return string(res), nil } diff --git a/pkg/cloudbroker/vins/mass_disable.go b/pkg/cloudbroker/vins/mass_disable.go index 846c00f..39d6530 100644 --- a/pkg/cloudbroker/vins/mass_disable.go +++ b/pkg/cloudbroker/vins/mass_disable.go @@ -4,7 +4,7 @@ import ( "context" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // MassDisableRequest struct to disable several VINSes @@ -15,18 +15,18 @@ type MassDisableRequest struct { } // MassDisable start jobs to disable several VINSes -func (v VINS) MassDisable(ctx context.Context, req MassDisableRequest) (bool, error) { +func (v VINS) MassDisable(ctx context.Context, req MassDisableRequest) (string, error) { err := validators.ValidateRequest(req) if err != nil { - return false, validators.ValidationErrors(validators.GetErrors(err)) + return "", validators.ValidationErrors(validators.GetErrors(err)) } url := "/cloudbroker/vins/massDisable" - _, err = v.client.DecortApiCall(ctx, http.MethodPost, url, req) + res, err := v.client.DecortApiCall(ctx, http.MethodPost, url, req) if err != nil { - return false, err + return "", err } - return true, nil + return string(res), nil } diff --git a/pkg/cloudbroker/vins/mass_enable.go b/pkg/cloudbroker/vins/mass_enable.go index e71c208..ab80f42 100644 --- a/pkg/cloudbroker/vins/mass_enable.go +++ b/pkg/cloudbroker/vins/mass_enable.go @@ -4,7 +4,7 @@ import ( "context" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // MassEnableRequest struct to enable several VINSes @@ -15,18 +15,18 @@ type MassEnableRequest struct { } // MassEnable start jobs to enable several VINSes -func (v VINS) MassEnable(ctx context.Context, req MassEnableRequest) (bool, error) { +func (v VINS) MassEnable(ctx context.Context, req MassEnableRequest) (string, error) { err := validators.ValidateRequest(req) if err != nil { - return false, validators.ValidationErrors(validators.GetErrors(err)) + return "", validators.ValidationErrors(validators.GetErrors(err)) } url := "/cloudbroker/vins/massEnable" - _, err = v.client.DecortApiCall(ctx, http.MethodPost, url, req) + res, err := v.client.DecortApiCall(ctx, http.MethodPost, url, req) if err != nil { - return false, err + return "", err } - return true, nil + return string(res), nil } diff --git a/pkg/cloudbroker/vins/migrate_to_zone.go b/pkg/cloudbroker/vins/migrate_to_zone.go new file mode 100644 index 0000000..1f13306 --- /dev/null +++ b/pkg/cloudbroker/vins/migrate_to_zone.go @@ -0,0 +1,42 @@ +package vins + +import ( + "context" + "net/http" + "strconv" + + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" +) + +// MigrateToZone struct to move VINS to another zone +type MigrateToZoneRequest struct { + // VINSID to move + // Required: true + VINSID uint64 `url:"net_id" json:"net_id" validate:"required"` + + // ID of the zone to move + // Required: true + ZoneID uint64 `url:"zone_id" json:"zone_id" validate:"required"` +} + +// MigrateToZone moves VINS instance to new zone +func (v VINS) MigrateToZone(ctx context.Context, req MigrateToZoneRequest) (bool, error) { + err := validators.ValidateRequest(req) + if err != nil { + return false, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/vins/migrateToZone" + + res, err := v.client.DecortApiCall(ctx, http.MethodPost, url, req) + if err != nil { + return false, err + } + + result, err := strconv.ParseBool(string(res)) + if err != nil { + return false, err + } + + return result, nil +} diff --git a/pkg/cloudbroker/vins/models.go b/pkg/cloudbroker/vins/models.go index 3e3a2be..574772e 100644 --- a/pkg/cloudbroker/vins/models.go +++ b/pkg/cloudbroker/vins/models.go @@ -122,6 +122,9 @@ type ItemInterface struct { // Enabled Enabled bool `json:"enabled"` + // Enable security groups + EnableSecGroups bool `json:"enable_secgroups"` + // FLIPGroup ID FLIPGroupID uint64 `json:"flipgroupId"` @@ -158,6 +161,12 @@ type ItemInterface struct { // NodeID NodeID int64 `json:"nodeId"` + // List of security groups + SecGroups []uint64 `json:"security_groups"` + + // SDNInterfaceID + SDNInterfaceID string `json:"sdn_interface_id"` + // PCI slot PCISlot int64 `json:"pciSlot"` @@ -238,6 +247,9 @@ type VNFDev struct { // VNC password VNCPassword string `json:"vncPasswd"` + + // Zone ID + ZoneID uint64 `json:"zoneId"` } // Main information about reservation @@ -418,6 +430,9 @@ type InfoVNF struct { // Type Type string `json:"type"` + + // Zone ID + ZoneID uint64 `json:"zoneId"` } // List of static routes @@ -505,6 +520,9 @@ type RecordVINS struct { // Description Description string `json:"desc"` + // Enable Security Groups + EnableSecGroups bool `json:"enable_secgroups"` + // Grid ID GID uint64 `json:"gid"` @@ -567,6 +585,9 @@ type RecordVINS struct { // VXLAN ID VXLANID uint64 `json:"vxlanId"` + + // Zone ID + ZoneID uint64 `json:"zoneId"` } // Information about libvirt settings @@ -712,6 +733,9 @@ type ItemVINS struct { // Description Description string `json:"desc"` + // Enable Security Groups + EnableSecGroups bool `json:"enable_secgroups"` + // External IP ExternalIP string `json:"externalIP"` @@ -786,6 +810,9 @@ type ItemVINS struct { // VXLAN ID VXLANID uint64 `json:"vxlanId"` + + // Zone ID + ZoneID uint64 `json:"zoneId"` } // List of VINS diff --git a/pkg/cloudbroker/vins/nat_rule_add.go b/pkg/cloudbroker/vins/nat_rule_add.go index cba8a5b..d024b5b 100644 --- a/pkg/cloudbroker/vins/nat_rule_add.go +++ b/pkg/cloudbroker/vins/nat_rule_add.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // NATRuleAddRequest struct to create NAT rules diff --git a/pkg/cloudbroker/vins/nat_rule_del.go b/pkg/cloudbroker/vins/nat_rule_del.go index 3fd9760..2721a79 100644 --- a/pkg/cloudbroker/vins/nat_rule_del.go +++ b/pkg/cloudbroker/vins/nat_rule_del.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // NATRuleDelRequest struct to delete NAT rule diff --git a/pkg/cloudbroker/vins/nat_rule_list.go b/pkg/cloudbroker/vins/nat_rule_list.go index f760a4e..0f66f87 100644 --- a/pkg/cloudbroker/vins/nat_rule_list.go +++ b/pkg/cloudbroker/vins/nat_rule_list.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // NATRuleListRequest struct to get list of NAT rules diff --git a/pkg/cloudbroker/vins/net_qos.go b/pkg/cloudbroker/vins/net_qos.go index f73a4af..77fddfb 100644 --- a/pkg/cloudbroker/vins/net_qos.go +++ b/pkg/cloudbroker/vins/net_qos.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // NetQOSRequest struct to update all VINS interfaces QOS diff --git a/pkg/cloudbroker/vins/restore.go b/pkg/cloudbroker/vins/restore.go index e93b397..62541d8 100644 --- a/pkg/cloudbroker/vins/restore.go +++ b/pkg/cloudbroker/vins/restore.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // RestoreRequest struct for restore diff --git a/pkg/cloudbroker/vins/serialize.go b/pkg/cloudbroker/vins/serialize.go index 472cd51..9f20463 100644 --- a/pkg/cloudbroker/vins/serialize.go +++ b/pkg/cloudbroker/vins/serialize.go @@ -3,7 +3,7 @@ package vins import ( "encoding/json" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/serialization" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/serialization" ) // Serialize returns JSON-serialized []byte. Used as a wrapper over json.Marshal and json.MarshalIndent functions. diff --git a/pkg/cloudbroker/vins/static_route_access_grant.go b/pkg/cloudbroker/vins/static_route_access_grant.go index 3c4f68f..ab46ec7 100644 --- a/pkg/cloudbroker/vins/static_route_access_grant.go +++ b/pkg/cloudbroker/vins/static_route_access_grant.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // StaticRouteAccessGrantRequest struct to grant access to static route to Compute/ViNS diff --git a/pkg/cloudbroker/vins/static_route_access_revoke.go b/pkg/cloudbroker/vins/static_route_access_revoke.go index e770ec3..83ba684 100644 --- a/pkg/cloudbroker/vins/static_route_access_revoke.go +++ b/pkg/cloudbroker/vins/static_route_access_revoke.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // StaticRouteAccessRevokeRequest struct to revoke access to static route to Compute/ViNS diff --git a/pkg/cloudbroker/vins/static_route_add.go b/pkg/cloudbroker/vins/static_route_add.go index a9e89ac..5ff7f62 100644 --- a/pkg/cloudbroker/vins/static_route_add.go +++ b/pkg/cloudbroker/vins/static_route_add.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // StaticRouteAddRequest struct to add static route diff --git a/pkg/cloudbroker/vins/static_route_del.go b/pkg/cloudbroker/vins/static_route_del.go index 768b98b..47c5d09 100644 --- a/pkg/cloudbroker/vins/static_route_del.go +++ b/pkg/cloudbroker/vins/static_route_del.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // StaticRouteDelRequest struct to remove static route from ViNS diff --git a/pkg/cloudbroker/vins/static_route_list.go b/pkg/cloudbroker/vins/static_route_list.go index d42ef8c..0722129 100644 --- a/pkg/cloudbroker/vins/static_route_list.go +++ b/pkg/cloudbroker/vins/static_route_list.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // StaticRouteListRequest struct for static route list diff --git a/pkg/cloudbroker/vins/update.go b/pkg/cloudbroker/vins/update.go new file mode 100644 index 0000000..edce7cc --- /dev/null +++ b/pkg/cloudbroker/vins/update.go @@ -0,0 +1,51 @@ +package vins + +import ( + "context" + "net/http" + "strconv" + + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" +) + +// UpdateRequest struct to update vins parameters +type UpdateRequest struct { + // VINS ID + // Required: true + VINSID uint64 `url:"vins_id" json:"vins_id" validate:"required"` + + // Name + // Required: false + Name string `url:"name,omitempty" json:"name,omitempty"` + + // Desc + // Required: false + Desc string `url:"desc,omitempty" json:"desc,omitempty"` + + // Flag indicating whether security groups are enabled for this network + // Required: false + EnableSecGroups interface{} `url:"enable_secgroups,omitempty" json:"enable_secgroups,omitempty" validate:"omitempty,isBool"` +} + +// Update updates a vins parameters +func (v VINS) Update(ctx context.Context, req UpdateRequest) (bool, error) { + err := validators.ValidateRequest(req) + if err != nil { + return false, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/vins/update" + + res, err := v.client.DecortApiCall(ctx, http.MethodPost, url, req) + if err != nil { + return false, err + } + + result, err := strconv.ParseBool(string(res)) + if err != nil { + return false, err + } + + return result, nil + +} diff --git a/pkg/cloudbroker/vins/vins.go b/pkg/cloudbroker/vins/vins.go index ca7c77d..6fa46ef 100644 --- a/pkg/cloudbroker/vins/vins.go +++ b/pkg/cloudbroker/vins/vins.go @@ -2,7 +2,7 @@ package vins import ( - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/interfaces" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/interfaces" ) // Structure for creating request to VINS diff --git a/pkg/cloudbroker/vins/vnfdev_redeploy.go b/pkg/cloudbroker/vins/vnfdev_redeploy.go index e6e3d4f..a050ae0 100644 --- a/pkg/cloudbroker/vins/vnfdev_redeploy.go +++ b/pkg/cloudbroker/vins/vnfdev_redeploy.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // VNFDevRedeployRequest struct to redeploy VNF devices diff --git a/pkg/cloudbroker/vins/vnfdev_reset.go b/pkg/cloudbroker/vins/vnfdev_reset.go index 26e334e..5d36925 100644 --- a/pkg/cloudbroker/vins/vnfdev_reset.go +++ b/pkg/cloudbroker/vins/vnfdev_reset.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // VNFDevResetRequest struct to reset VNF device diff --git a/pkg/cloudbroker/vins/vnfdev_restart.go b/pkg/cloudbroker/vins/vnfdev_restart.go index a7b386d..cf8da09 100644 --- a/pkg/cloudbroker/vins/vnfdev_restart.go +++ b/pkg/cloudbroker/vins/vnfdev_restart.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // VNFDevRestartRequest struct to reboot VINSes primary VNF device diff --git a/pkg/cloudbroker/vins/vnfdev_start.go b/pkg/cloudbroker/vins/vnfdev_start.go index 9c079c5..3423bd6 100644 --- a/pkg/cloudbroker/vins/vnfdev_start.go +++ b/pkg/cloudbroker/vins/vnfdev_start.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // VNFDevStartRequest struct to start VNF devices diff --git a/pkg/cloudbroker/vins/vnfdev_stop.go b/pkg/cloudbroker/vins/vnfdev_stop.go index c7baa3b..ab6830c 100644 --- a/pkg/cloudbroker/vins/vnfdev_stop.go +++ b/pkg/cloudbroker/vins/vnfdev_stop.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" ) // VNFDevStopRequest struct to stop VNF devices diff --git a/pkg/cloudbroker/zone.go b/pkg/cloudbroker/zone.go new file mode 100644 index 0000000..b842218 --- /dev/null +++ b/pkg/cloudbroker/zone.go @@ -0,0 +1,10 @@ +package cloudbroker + +import ( + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/pkg/cloudbroker/zone" +) + +// Accessing the Zone method group +func (ca *CloudBroker) Zone() *zone.Zone { + return zone.New(ca.client) +} diff --git a/pkg/cloudbroker/zone/add_node.go b/pkg/cloudbroker/zone/add_node.go new file mode 100644 index 0000000..15e15a4 --- /dev/null +++ b/pkg/cloudbroker/zone/add_node.go @@ -0,0 +1,43 @@ +package zone + +import ( + "context" + "net/http" + "strconv" + + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" +) + +// AddNodeRequest struct to add node to zone +type AddNodeRequest struct { + // ID of zone + // Required: true + ID uint64 `url:"id" json:"id" validate:"required"` + + // List of node ids + // Required: true + NodeIDs []uint64 `url:"nodeIds" json:"nodeIds" validate:"required"` +} + +// AddNode add nodes to zone +func (e Zone) AddNode(ctx context.Context, req AddNodeRequest) (bool, error) { + err := validators.ValidateRequest(req) + if err != nil { + return false, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/zone/addNode" + + res, err := e.client.DecortApiCall(ctx, http.MethodPost, url, req) + + if err != nil { + return false, err + } + + result, err := strconv.ParseBool(string(res)) + if err != nil { + return false, err + } + + return result, nil +} diff --git a/pkg/cloudbroker/zone/create.go b/pkg/cloudbroker/zone/create.go new file mode 100644 index 0000000..0b87967 --- /dev/null +++ b/pkg/cloudbroker/zone/create.go @@ -0,0 +1,43 @@ +package zone + +import ( + "context" + "net/http" + "strconv" + + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" +) + +// CreateRequest struct to create zone +type CreateRequest struct { + // Name of zone + // Required: true + Name string `url:"name" json:"name" validate:"required"` + + // Description + // Required: false + Description string `url:"description,omitempty" json:"description,omitempty"` +} + +// Create creates zone object +func (e Zone) Create(ctx context.Context, req CreateRequest) (uint64, error) { + err := validators.ValidateRequest(req) + if err != nil { + return 0, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/zone/create" + + res, err := e.client.DecortApiCall(ctx, http.MethodPost, url, req) + + if err != nil { + return 0, err + } + + result, err := strconv.ParseUint(string(res), 10, 64) + if err != nil { + return 0, err + } + + return result, nil +} diff --git a/pkg/cloudbroker/zone/del_node.go b/pkg/cloudbroker/zone/del_node.go new file mode 100644 index 0000000..f1bc7f0 --- /dev/null +++ b/pkg/cloudbroker/zone/del_node.go @@ -0,0 +1,43 @@ +package zone + +import ( + "context" + "net/http" + "strconv" + + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" +) + +// DelNodeRequest struct to remove node from zone +type DelNodeRequest struct { + // ID of zone + // Required: true + ID uint64 `url:"id" json:"id" validate:"required"` + + // List of node ids + // Required: true + NodeIDs []uint64 `url:"nodeIds" json:"nodeIds" validate:"required"` +} + +// DelNode remove nodes from zone +func (e Zone) DelNode(ctx context.Context, req DelNodeRequest) (bool, error) { + err := validators.ValidateRequest(req) + if err != nil { + return false, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/zone/delNode" + + res, err := e.client.DecortApiCall(ctx, http.MethodPost, url, req) + + if err != nil { + return false, err + } + + result, err := strconv.ParseBool(string(res)) + if err != nil { + return false, err + } + + return result, nil +} diff --git a/pkg/cloudbroker/zone/delete.go b/pkg/cloudbroker/zone/delete.go new file mode 100644 index 0000000..202c908 --- /dev/null +++ b/pkg/cloudbroker/zone/delete.go @@ -0,0 +1,39 @@ +package zone + +import ( + "context" + "net/http" + "strconv" + + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" +) + +// DeleteRequest struct to delete zone +type DeleteRequest struct { + // ID of zone + // Required: true + ID uint64 `url:"id" json:"id" validate:"required"` +} + +// Delete deletes zone object +func (e Zone) Delete(ctx context.Context, req DeleteRequest) (bool, error) { + err := validators.ValidateRequest(req) + if err != nil { + return false, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/zone/delete" + + res, err := e.client.DecortApiCall(ctx, http.MethodPost, url, req) + + if err != nil { + return false, err + } + + result, err := strconv.ParseBool(string(res)) + if err != nil { + return false, err + } + + return result, nil +} diff --git a/pkg/cloudbroker/zone/filter.go b/pkg/cloudbroker/zone/filter.go new file mode 100644 index 0000000..ec55a7a --- /dev/null +++ b/pkg/cloudbroker/zone/filter.go @@ -0,0 +1,53 @@ +package zone + +// FilterByID returns ListZones with specified ID. +func (list ListZones) FilterByID(id uint64) ListZones { + predicate := func(izone RecordZone) bool { + return izone.ID == id + } + + return list.FilterFunc(predicate) +} + +// FilterByName returns ListZones with specified Name. +func (list ListZones) FilterByName(name string) ListZones { + predicate := func(izone RecordZone) bool { + return izone.Name == name + } + + return list.FilterFunc(predicate) +} + +// FilterByStatus returns ListZones with specified Status. +func (list ListZones) FilterByStatus(status string) ListZones { + predicate := func(izone RecordZone) bool { + return izone.Status == status + } + + return list.FilterFunc(predicate) +} + +// FilterFunc allows filtering ListZones based on a user-specified predicate. +func (list ListZones) FilterFunc(predicate func(RecordZone) bool) ListZones { + var result ListZones + + for _, item := range list.Data { + if predicate(item) { + result.Data = append(result.Data, item) + } + } + + result.EntryCount = uint64(len(result.Data)) + + return result +} + +// FindOne returns first found RecordZone +// If none was found, returns an empty struct. +func (list ListZones) FindOne() RecordZone { + if list.EntryCount == 0 { + return RecordZone{} + } + + return list.Data[0] +} diff --git a/pkg/cloudbroker/zone/filter_test.go b/pkg/cloudbroker/zone/filter_test.go new file mode 100644 index 0000000..5966796 --- /dev/null +++ b/pkg/cloudbroker/zone/filter_test.go @@ -0,0 +1,86 @@ +package zone + +import "testing" + +var zones = ListZones{ + Data: []RecordZone{ + + { + ID: 2, + GUID: 0, + GID: 0, + Name: "System Config", + Description: "", + Deletable: true, + Status: "LOCKED", + CreatedTime: 1640995200, // 2022-01-01 + UpdatedTime: 1640995200, + NodeIDs: nil, + }, + { + ID: 5, + GUID: 5500, + GID: 6600, + Name: "ssss Nodes", + Description: " infrastructure", + Deletable: true, + Status: "DISABLED", + CreatedTime: 1577836800, // 2020-01-01 + UpdatedTime: 1580515200, // 2020-02-01 + NodeIDs: []uint64{777, 888, 999}, + }, + { + ID: 10, + GUID: 5500, + GID: 6600, + Name: "node", + Description: "infrastructure", + Deletable: true, + Status: "DISABLED", + CreatedTime: 1577836800, + UpdatedTime: 1580515200, + NodeIDs: []uint64{777, 888, 999}, + }, + }, +} + +func TestFilterByID(t *testing.T) { + actual := zones.FilterByID(10).FindOne() + + if actual.ID != 10 { + t.Fatal("expected ID 10, found: ", actual.ID) + } +} + +func TestFilterByName(t *testing.T) { + name := "node" + actual := zones.FilterByName(name).FindOne() + + if actual.Name != name { + t.Fatal("expected ", name, " found: ", actual.Name) + } +} + +func TestFilterByStatus(t *testing.T) { + actual := zones.FilterByStatus("DISABLED") + + if len(actual.Data) != 2 { + t.Fatal("expected 2 found, actual: ", len(actual.Data)) + } + + for _, item := range actual.Data { + if item.Status != "DISABLED" { + t.Fatal("expected Status 'DISABLED', found: ", item.Status) + } + } +} + +func TestFilterFunc(t *testing.T) { + actual := zones.FilterFunc(func(ien RecordZone) bool { + return ien.Deletable == true + }) + + if len(actual.Data) != 3 { + t.Fatal("expected 3 elements, found: ", len(actual.Data)) + } +} diff --git a/pkg/cloudbroker/zone/get.go b/pkg/cloudbroker/zone/get.go new file mode 100644 index 0000000..425286b --- /dev/null +++ b/pkg/cloudbroker/zone/get.go @@ -0,0 +1,46 @@ +package zone + +import ( + "context" + "encoding/json" + "net/http" + + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" +) + +// GetRequest struct to get detailed information about zone +type GetRequest struct { + // ID of zone + // Required: true + ID uint64 `url:"id" json:"id" validate:"required"` +} + +// Get gets detailed information about zone struct +func (e Zone) Get(ctx context.Context, req GetRequest) (*RecordZone, error) { + res, err := e.GetRaw(ctx, req) + if err != nil { + return nil, err + } + + info := RecordZone{} + + err = json.Unmarshal(res, &info) + if err != nil { + return nil, err + } + + return &info, nil +} + +// GetRaw gets detailed information about zone as an array of bytes +func (e Zone) GetRaw(ctx context.Context, req GetRequest) ([]byte, error) { + err := validators.ValidateRequest(req) + if err != nil { + return nil, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/zone/get" + + res, err := e.client.DecortApiCall(ctx, http.MethodPost, url, req) + return res, err +} diff --git a/pkg/cloudbroker/zone/ids.go b/pkg/cloudbroker/zone/ids.go new file mode 100644 index 0000000..33f6193 --- /dev/null +++ b/pkg/cloudbroker/zone/ids.go @@ -0,0 +1,10 @@ +package zone + +// IDs gets array of IDs from ListZones struct +func (le ListZones) IDs() []uint64 { + res := make([]uint64, 0, len(le.Data)) + for _, e := range le.Data { + res = append(res, e.ID) + } + return res +} diff --git a/pkg/cloudbroker/zone/list.go b/pkg/cloudbroker/zone/list.go new file mode 100644 index 0000000..a17d7b7 --- /dev/null +++ b/pkg/cloudbroker/zone/list.go @@ -0,0 +1,84 @@ +package zone + +import ( + "context" + "encoding/json" + "net/http" + + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" +) + +// ListRequest struct to get list of zones +type ListRequest struct { + + // Find by ID + // Required: false + ByID uint64 `url:"by_id,omitempty" json:"by_id,omitempty"` + + // Find by Grid ID + // Required: false + GID uint64 `url:"gid,omitempty" json:"gid,omitempty"` + + // Find by name + // Required: false + Name string `url:"name,omitempty" json:"name,omitempty"` + + // Find by description + // Required: false + Description string `url:"description,omitempty" json:"description,omitempty"` + + // Find by status + // Required: false + Status string `url:"status,omitempty" json:"status,omitempty"` + + // Find by deletable + // Required: false + Deletable bool `url:"deletable,omitempty" json:"deletable,omitempty"` + + // Find by node ID + // Required: false + NodeID uint64 `url:"nodeId,omitempty" json:"nodeId,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 + // Required: false + Size uint64 `url:"size,omitempty" json:"size,omitempty"` +} + +// List gets list of all zones as a ListZones struct +func (e Zone) List(ctx context.Context, req ListRequest) (*ListZones, error) { + + res, err := e.ListRaw(ctx, req) + if err != nil { + return nil, err + } + + list := ListZones{} + + err = json.Unmarshal(res, &list) + if err != nil { + return nil, err + } + + return &list, nil +} + +// ListRaw gets list of all available zones as an array of bytes +func (e Zone) ListRaw(ctx context.Context, req ListRequest) ([]byte, error) { + + if err := validators.ValidateRequest(req); err != nil { + return nil, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/zone/list" + + res, err := e.client.DecortApiCall(ctx, http.MethodPost, url, req) + return res, err +} diff --git a/pkg/cloudbroker/zone/models.go b/pkg/cloudbroker/zone/models.go new file mode 100644 index 0000000..110f9f9 --- /dev/null +++ b/pkg/cloudbroker/zone/models.go @@ -0,0 +1,63 @@ +package zone + +type ListZones struct { + // Entry count + EntryCount uint64 `json:"entryCount"` + + // Data + Data []RecordZone `json:"data"` +} + +// Detailed information about the zone record +type RecordZone struct { + // ID + ID uint64 `json:"id"` + + // GUID + GUID uint64 `json:"guid"` + + // GID + GID uint64 `json:"gid"` + + // Name + Name string `json:"name"` + + // List of associated account IDs + AccountIDs []uint64 `json:"accountIds"` + + // List of associated bservice IDs + BserviceIDs []uint64 `json:"bserviceIds"` + + // List of associated compute IDs + ComputeIDs []uint64 `json:"computeIds"` + + // Description + Description string `json:"description"` + + // Deletable flag + Deletable bool `json:"deletable"` + + // List of associated ExtNet IDs + ExtnetIDs []uint64 `json:"extnetIds"` + + // List of associated K8s IDs + K8SIDs []uint64 `json:"k8sIds"` + + // List of associated LB IDs + LBIDs []uint64 `json:"lbIds"` + + // Status + Status string `json:"status"` + + // Created timestamp + CreatedTime uint64 `json:"createdTime"` + + // Updated timestamp + UpdatedTime uint64 `json:"updatedTime"` + + // List of associated Node IDs + NodeIDs []uint64 `json:"nodeIds"` + + // List of associated VINS IDs + VinsIDs []uint64 `json:"vinsIds"` +} diff --git a/pkg/cloudbroker/zone/serialize.go b/pkg/cloudbroker/zone/serialize.go new file mode 100644 index 0000000..4ecb2a6 --- /dev/null +++ b/pkg/cloudbroker/zone/serialize.go @@ -0,0 +1,43 @@ +package zone + +import ( + "encoding/json" + + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/serialization" +) + +// Serialize returns JSON-serialized []byte. Used as a wrapper over json.Marshal and json.MarshalIndent functions. +// +// In order to serialize with indent make sure to follow these guidelines: +// - First argument -> prefix +// - Second argument -> indent +func (list ListZones) Serialize(params ...string) (serialization.Serialized, error) { + if list.EntryCount == 0 { + return []byte{}, nil + } + + if len(params) > 1 { + prefix := params[0] + indent := params[1] + + return json.MarshalIndent(list, prefix, indent) + } + + return json.Marshal(list) +} + +// Serialize returns JSON-serialized []byte. Used as a wrapper over json.Marshal and json.MarshalIndent functions. +// +// In order to serialize with indent make sure to follow these guidelines: +// - First argument -> prefix +// - Second argument -> indent +func (item RecordZone) Serialize(params ...string) (serialization.Serialized, error) { + if len(params) > 1 { + prefix := params[0] + indent := params[1] + + return json.MarshalIndent(item, prefix, indent) + } + + return json.Marshal(item) +} diff --git a/pkg/cloudbroker/zone/update.go b/pkg/cloudbroker/zone/update.go new file mode 100644 index 0000000..413dc2e --- /dev/null +++ b/pkg/cloudbroker/zone/update.go @@ -0,0 +1,47 @@ +package zone + +import ( + "context" + "net/http" + "strconv" + + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" +) + +// UpdateRequest struct to update zone +type UpdateRequest struct { + // ID of zone + // Required: true + ID uint64 `url:"id" json:"id" validate:"required"` + + // Name of zone + // Required: false + Name string `url:"name,omitempty" json:"name,omitempty"` + + // Description + // Required: false + Description string `url:"description,omitempty" json:"description,omitempty"` +} + +// Update updates zone object +func (e Zone) Update(ctx context.Context, req UpdateRequest) (bool, error) { + err := validators.ValidateRequest(req) + if err != nil { + return false, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/zone/update" + + res, err := e.client.DecortApiCall(ctx, http.MethodPost, url, req) + + if err != nil { + return false, err + } + + result, err := strconv.ParseBool(string(res)) + if err != nil { + return false, err + } + + return result, nil +} diff --git a/pkg/cloudbroker/zone/zone.go b/pkg/cloudbroker/zone/zone.go new file mode 100644 index 0000000..cd157db --- /dev/null +++ b/pkg/cloudbroker/zone/zone.go @@ -0,0 +1,18 @@ +// API Actor for use zones +package zone + +import ( + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/interfaces" +) + +// Structure for creating request to zone +type Zone struct { + client interfaces.Caller +} + +// Builder for zone endpoints +func New(client interfaces.Caller) *Zone { + return &Zone{ + client, + } +} diff --git a/pkg/sdn/access_groups.go b/pkg/sdn/access_groups.go new file mode 100644 index 0000000..5b7bca1 --- /dev/null +++ b/pkg/sdn/access_groups.go @@ -0,0 +1,10 @@ +package sdn + +import ( + ag "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/pkg/sdn/acsgroups" +) + +// Accessing the SDN method group +func (sdn *SDN) AccessGroups() *ag.AccessGroups { + return ag.New(sdn.client) +} diff --git a/pkg/sdn/acsgroups/access_groups.go b/pkg/sdn/acsgroups/access_groups.go new file mode 100644 index 0000000..58f675b --- /dev/null +++ b/pkg/sdn/acsgroups/access_groups.go @@ -0,0 +1,18 @@ +// API Actor API for managing SDN access groups +package acsgroups + +import ( + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/interfaces" +) + +// Structure for creating request to access groups +type AccessGroups struct { + client interfaces.Caller +} + +// Builder for access groups endpoints +func New(client interfaces.Caller) *AccessGroups { + return &AccessGroups{ + client, + } +} diff --git a/pkg/sdn/acsgroups/create.go b/pkg/sdn/acsgroups/create.go new file mode 100644 index 0000000..d24d508 --- /dev/null +++ b/pkg/sdn/acsgroups/create.go @@ -0,0 +1,45 @@ +package acsgroups + +import ( + "context" + "encoding/json" + "net/http" + + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/constants" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" +) + +// CreateRequest struct to create access group +type CreateRequest struct { + // Comment of the access group + // Required: true + Comment string `url:"comment" json:"comment" validate:"required"` + + // Name of acces group + // Required: true + DisplayName string `url:"display_name" json:"display_name" validate:"required"` +} + +// Create creates a access groups +func (i AccessGroups) Create(ctx context.Context, req CreateRequest) (*AccessGroupItem, error) { + err := validators.ValidateRequest(req) + if err != nil { + return nil, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/sdn/access_group/create" + + res, err := i.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req) + if err != nil { + return nil, err + } + + info := AccessGroupItem{} + + err = json.Unmarshal(res, &info) + if err != nil { + return nil, err + } + + return &info, nil +} diff --git a/pkg/sdn/acsgroups/delete.go b/pkg/sdn/acsgroups/delete.go new file mode 100644 index 0000000..23f5a45 --- /dev/null +++ b/pkg/sdn/acsgroups/delete.go @@ -0,0 +1,39 @@ +package acsgroups + +import ( + "context" + "net/http" + "strconv" + + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/constants" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" +) + +// DeleteRequest struct to delete access group +type DeleteRequest struct { + // Comment of the access group + // Required: true + GroupID string `url:"access_group_id" json:"access_group_id" validate:"required"` +} + +// Delete a access groups +func (i AccessGroups) Delete(ctx context.Context, req DeleteRequest) (bool, error) { + err := validators.ValidateRequest(req) + if err != nil { + return false, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/sdn/access_group/delete" + + res, err := i.client.DecortApiCallCtype(ctx, http.MethodDelete, url, constants.MIMEJSON, req) + if err != nil { + return false, err + } + + result, err := strconv.ParseBool(string(res)) + if err != nil { + return false, err + } + + return result, nil +} diff --git a/pkg/sdn/acsgroups/filter.go b/pkg/sdn/acsgroups/filter.go new file mode 100644 index 0000000..2ac4355 --- /dev/null +++ b/pkg/sdn/acsgroups/filter.go @@ -0,0 +1,42 @@ +package acsgroups + +// FilterByID returns AccessGroupList with specified ID. +func (agl AccessGroupList) FilterByID(id string) AccessGroupList { + predicate := func(ia AccessGroup) bool { + return ia.ID == id + } + + return agl.FilterFunc(predicate) +} + +// FilterByName returns AccessGroupList with specified Name. +func (agl AccessGroupList) FilterByName(name string) AccessGroupList { + predicate := func(ia AccessGroup) bool { + return ia.DisplayName == name + } + + return agl.FilterFunc(predicate) +} + +// FilterFunc allows filtering AccessGroupList based on a user-specified predicate. +func (agl AccessGroupList) FilterFunc(predicate func(AccessGroup) bool) AccessGroupList { + var result AccessGroupList + + for _, acc := range agl.AccessGroups { + if predicate(acc) { + result.AccessGroups = append(result.AccessGroups, acc) + } + } + + return result +} + +// FindOne returns first element. +// If none was found, returns an empty struct. +func (agl AccessGroupList) FindOne() AccessGroup { + if len(agl.AccessGroups) == 0 { + return AccessGroup{} + } + + return agl.AccessGroups[0] +} diff --git a/pkg/sdn/acsgroups/filter_test.go b/pkg/sdn/acsgroups/filter_test.go new file mode 100644 index 0000000..bb55a21 --- /dev/null +++ b/pkg/sdn/acsgroups/filter_test.go @@ -0,0 +1,89 @@ +package acsgroups + +import ( + "testing" +) + +var testAccessGroups = AccessGroupList{ + AccessGroups: []AccessGroup{ + { + ID: "group1", + DisplayName: "Developers", + Comment: "First group", + CreatedAt: "2023-01-01", + CreatedBy: "admin", + }, + { + ID: "group2", + DisplayName: "Admins", + Comment: "Second group", + CreatedAt: "2023-01-02", + CreatedBy: "admin", + }, + { + ID: "group3", + DisplayName: "Users", + Comment: "Third group", + CreatedAt: "2023-01-03", + CreatedBy: "admin", + }, + }, +} + +func TestFilterByID(t *testing.T) { + actual := testAccessGroups.FilterByID("group2").FindOne() + + if actual.ID != "group2" { + t.Fatal("actual:", actual.ID, "> expected: group2") + } +} + +func TestFilterByName(t *testing.T) { + actual := testAccessGroups.FilterByName("Users").FindOne() + + if actual.DisplayName != "Users" { + t.Fatal("actual:", actual.DisplayName, ">> expected: Users") + } +} + +func TestFilterFunc(t *testing.T) { + actual := testAccessGroups.FilterFunc(func(ag AccessGroup) bool { + return ag.Comment == "Second group" + }) + + if len(actual.AccessGroups) != 1 || actual.AccessGroups[0].ID != "group2" { + t.Fatal("Expected 1 group with comment 'Second group', found:", len(actual.AccessGroups)) + } +} + +func TestFindOneWithResults(t *testing.T) { + result := testAccessGroups.FilterByID("group1").FindOne() + if result.ID != "group1" { + t.Fatal("Expected group1, got:", result.ID) + } +} + +func TestFindOneEmpty(t *testing.T) { + emptyList := AccessGroupList{} + result := emptyList.FindOne() + + if result.ID != "" || result.DisplayName != "" { + t.Fatal("Expected empty AccessGroup, got:", result) + } +} + +func TestFilterByIDNotFound(t *testing.T) { + actual := testAccessGroups.FilterByID("nonexistent") + + if len(actual.AccessGroups) != 0 { + t.Fatal("Expected 0 groups, found:", len(actual.AccessGroups)) + } +} + +func TestFilterByNameNotFound(t *testing.T) { + actual := testAccessGroups.FilterByName("Nonexistent Group") + + if len(actual.AccessGroups) != 0 { + t.Fatal("Expected 0 groups, found:", len(actual.AccessGroups)) + } +} diff --git a/pkg/sdn/acsgroups/ids.go b/pkg/sdn/acsgroups/ids.go new file mode 100644 index 0000000..1c925e8 --- /dev/null +++ b/pkg/sdn/acsgroups/ids.go @@ -0,0 +1,19 @@ +package acsgroups + +// IDs gets array of IDs from AccessGroupList struct +func (agl AccessGroupList) IDs() []string { + res := make([]string, 0, len(agl.AccessGroups)) + for _, c := range agl.AccessGroups { + res = append(res, c.ID) + } + return res +} + +// IDs gets array of IDs from UsersList struct +func (ul UsersList) IDs() []string { + res := make([]string, 0, len(ul.Users)) + for _, c := range ul.Users { + res = append(res, c.ID) + } + return res +} diff --git a/pkg/sdn/acsgroups/list.go b/pkg/sdn/acsgroups/list.go new file mode 100644 index 0000000..a1fb036 --- /dev/null +++ b/pkg/sdn/acsgroups/list.go @@ -0,0 +1,80 @@ +package acsgroups + +import ( + "context" + "encoding/json" + "net/http" + + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" +) + +// ListGroupsRequest struct to get a list of access groups +type ListGroupsRequest struct { + // Find by enabled status, true or false + // Required: false + Enabled interface{} `url:"enabled,omitempty" json:"enabled,omitempty" validate:"omitempty,isBool"` + + // Find by deleted status, true or false + // Required: false + Deleted interface{} `url:"deleted,omitempty" json:"deleted,omitempty" validate:"omitempty,isBool"` + + // Display name filter + // Required: false + DisplayName string `url:"display_name,omitempty" json:"display_name,omitempty"` + + // Page number for pagination + // Required: false + Page uint64 `url:"page,omitempty" json:"page,omitempty"` + + // Number of results per page + // Required: false + PerPage uint64 `url:"per_page,omitempty" json:"per_page,omitempty"` + + // Field to sort by (display_name, created_at, updated_at, deleted_at, owner_login) + // Required: false + SortBy string `url:"sort_by,omitempty" json:"sort_by,omitempty"` + + // Sort order (asc/desc) + // Required: false + SortOrder string `url:"sort_order,omitempty" json:"sort_order,omitempty"` + + // Creation date lower bound (inclusive) + // Required: false + CreatedFrom string `url:"created_from,omitempty" json:"created_from,omitempty"` + + // Creation date upper bound (inclusive) + // Required: false + CreatedTo string `url:"created_to,omitempty" json:"created_to,omitempty"` +} + +// List of access groups +func (i AccessGroups) List(ctx context.Context, req ListGroupsRequest) (*AccessGroupList, error) { + res, err := i.ListRaw(ctx, req) + if err != nil { + return nil, err + } + + groups := []AccessGroup{} + + err = json.Unmarshal(res, &groups) + if err != nil { + return nil, err + } + + result := AccessGroupList{AccessGroups: groups} + + return &result, nil +} + +// ListRaw gets a list of all users as an array of bytes +func (a AccessGroups) ListRaw(ctx context.Context, req ListGroupsRequest) ([]byte, error) { + + if err := validators.ValidateRequest(req); err != nil { + return nil, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/sdn/access_group/list" + + res, err := a.client.DecortApiCall(ctx, http.MethodGet, url, req) + return res, err +} diff --git a/pkg/sdn/acsgroups/models.go b/pkg/sdn/acsgroups/models.go new file mode 100644 index 0000000..fb70f4a --- /dev/null +++ b/pkg/sdn/acsgroups/models.go @@ -0,0 +1,49 @@ +package acsgroups + +type AccessGroupItem struct { + Name string `json:"display_name"` + ID string `json:"id"` +} + +type AccessGroupList struct { + AccessGroups []AccessGroup +} + +type AccessGroup struct { + ID string `json:"id"` + DisplayName string `json:"display_name"` + Comment string `json:"comment"` + CreatedAt string `json:"created_at"` + CreatedBy string `json:"created_by"` + UpdatedAt string `json:"updated_at"` + UpdatedBy string `json:"updated_by"` + NetObjectAccessGroup NetObjectAccessGroup `json:"net_object_access_group"` + DefaultSecurityPolicy DefaultSecurityPolicy `json:"default_security_policy"` +} + +type NetObjectAccessGroup struct { + ID string `json:"id"` + VersionID int64 `json:"version_id"` + AccessGroupID string `json:"access_group_id"` +} + +type DefaultSecurityPolicy struct { + ID string `json:"id"` + DisplayName string `json:"display_name"` + Description string `json:"description"` + VersionID int64 `json:"version_id"` + AccessGroupID string `json:"access_group_id"` + DefaultAclDrop string `json:"default_acl_drop"` + DefaultOpenSessionDrop bool `json:"default_open_session_drop"` +} + +type User struct { + Name string `json:"display_name"` + ID string `json:"id"` + RoleID string `json:"role_id"` + Login string `json:"login"` +} + +type UsersList struct { + Users []User +} diff --git a/pkg/sdn/acsgroups/path.go b/pkg/sdn/acsgroups/path.go new file mode 100644 index 0000000..63a3a2f --- /dev/null +++ b/pkg/sdn/acsgroups/path.go @@ -0,0 +1,49 @@ +package acsgroups + +import ( + "context" + "encoding/json" + "net/http" + + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/constants" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" +) + +// PatchRequest struct to update access group +type PatchRequest struct { + // Access group ID + // Required: true + AccessGroupID string `url:"access_group_id" json:"access_group_id" validate:"required"` + + // Comment of the acces group + // Required: false + Comment string `url:"comment,omitempty" json:"comment,omitempty"` + + // Name of acces group + // Required: false + DisplayName string `url:"display_name,omitempty" json:"display_name,omitempty"` +} + +// Update updates a access groups +func (i AccessGroups) Patch(ctx context.Context, req PatchRequest) (*AccessGroup, error) { + err := validators.ValidateRequest(req) + if err != nil { + return nil, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/sdn/access_group/patch" + + res, err := i.client.DecortApiCallCtype(ctx, http.MethodPatch, url, constants.MIMEJSON, req) + if err != nil { + return nil, err + } + + info := AccessGroup{} + + err = json.Unmarshal(res, &info) + if err != nil { + return nil, err + } + + return &info, nil +} diff --git a/pkg/sdn/acsgroups/user_add.go b/pkg/sdn/acsgroups/user_add.go new file mode 100644 index 0000000..0465f89 --- /dev/null +++ b/pkg/sdn/acsgroups/user_add.go @@ -0,0 +1,41 @@ +package acsgroups + +import ( + "context" + "net/http" + + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/constants" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" +) + +// UserAddRequest struct to userAdd access group +type UserAddRequest struct { + // Comment of the access group + // Required: true + GroupID string `url:"access_group_id" json:"access_group_id" validate:"required"` + + // Access group role ID + // Required: true + AccessGroupRoleID string `url:"access_group_role_id" json:"access_group_role_id" validate:"required"` + + // User ID + // Required: true + UserID string `url:"user_id" json:"user_id" validate:"required"` +} + +// UserAdd a access groups +func (i AccessGroups) UserAdd(ctx context.Context, req UserAddRequest) (bool, error) { + err := validators.ValidateRequest(req) + if err != nil { + return false, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/sdn/access_group/user_add" + + _, err = i.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req) + if err != nil { + return false, err + } + + return true, nil +} diff --git a/pkg/sdn/acsgroups/user_delete.go b/pkg/sdn/acsgroups/user_delete.go new file mode 100644 index 0000000..3aad53c --- /dev/null +++ b/pkg/sdn/acsgroups/user_delete.go @@ -0,0 +1,37 @@ +package acsgroups + +import ( + "context" + "net/http" + + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/constants" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" +) + +// UserDeleteRequest struct to userDelete access group +type UserDeleteRequest struct { + // Comment of the access group + // Required: true + GroupID string `url:"access_group_id" json:"access_group_id" validate:"required"` + + // User ID + // Required: true + UserID string `url:"user_id" json:"user_id" validate:"required"` +} + +// UserDelete a access groups +func (i AccessGroups) UserDelete(ctx context.Context, req UserDeleteRequest) (bool, error) { + err := validators.ValidateRequest(req) + if err != nil { + return false, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/sdn/access_group/user_delete" + + _, err = i.client.DecortApiCallCtype(ctx, http.MethodDelete, url, constants.MIMEJSON, req) + if err != nil { + return false, err + } + + return true, nil +} diff --git a/pkg/sdn/acsgroups/user_list.go b/pkg/sdn/acsgroups/user_list.go new file mode 100644 index 0000000..343928a --- /dev/null +++ b/pkg/sdn/acsgroups/user_list.go @@ -0,0 +1,113 @@ +package acsgroups + +import ( + "context" + "encoding/json" + "net/http" + + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" +) + +// UsersListRequest struct to get a list of users +type UsersListRequest struct { + // Access group identifier + // Required: true + AccessGroupID string `url:"access_group_id" json:"access_group_id" validate:"required"` + + // Filter by global role + // Required: false + GlobalRole string `url:"global_role,omitempty" json:"global_role,omitempty"` + + // Filter by access group role + // Required: false + AccessGroupRole string `url:"access_group_role,omitempty" json:"access_group_role,omitempty"` + + // Filter by enabled status (true/false) + // Required: false + Enabled interface{} `url:"enabled,omitempty" json:"enabled,omitempty" validate:"omitempty,isBool"` + + // Filter by deleted status (true/false) + // Required: false + Deleted interface{} `url:"deleted,omitempty" json:"deleted,omitempty" validate:"omitempty,isBool"` + + // Filter by display name + // Required: false + DisplayName string `url:"display_name,omitempty" json:"display_name,omitempty"` + + // Filter by user login + // Required: false + Login string `url:"login,omitempty" json:"login,omitempty"` + + // Filter by creator login + // Required: false + CreatedBy string `url:"created_by,omitempty" json:"created_by,omitempty"` + + // Filter by last updater login + // Required: false + UpdatedBy string `url:"updated_by,omitempty" json:"updated_by,omitempty"` + + // Filter by deleter login + // Required: false + DeletedBy string `url:"deleted_by,omitempty" json:"deleted_by,omitempty"` + + // Filter by disabler login + // Required: false + DisabledBy string `url:"disabled_by,omitempty" json:"disabled_by,omitempty"` + + // Page number for pagination + // Required: false + Page uint64 `url:"page,omitempty" json:"page,omitempty"` + + // Number of results per page + // Required: false + PerPage uint64 `url:"per_page,omitempty" json:"per_page,omitempty"` + + // Field to sort by (display_name, email, phone, created_at, updated_at, deleted_at) + // Required: false + SortBy string `url:"sort_by,omitempty" json:"sort_by,omitempty"` + + // Sort order (asc/desc) + // Required: false + SortOrder string `url:"sort_order,omitempty" json:"sort_order,omitempty"` + + // Creation date lower bound (inclusive) + // Required: false + CreatedFrom string `url:"created_from,omitempty" json:"created_from,omitempty"` + + // Creation date upper bound (exclusive) + // Required: false + CreatedTo string `url:"created_to,omitempty" json:"created_to,omitempty"` +} + +// List of access groups +func (i AccessGroups) UsersList(ctx context.Context, req UsersListRequest) (*UsersList, error) { + + res, err := i.UserListRaw(ctx, req) + if err != nil { + return nil, err + } + + users := []User{} + + err = json.Unmarshal(res, &users) + if err != nil { + return nil, err + } + + result := UsersList{Users: users} + + return &result, nil +} + +// ListRaw gets a list of all users as an array of bytes +func (a AccessGroups) UserListRaw(ctx context.Context, req UsersListRequest) ([]byte, error) { + + if err := validators.ValidateRequest(req); err != nil { + return nil, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/sdn/access_group/user_list" + + res, err := a.client.DecortApiCall(ctx, http.MethodGet, url, req) + return res, err +} diff --git a/pkg/sdn/acsgroups/user_update_role.go b/pkg/sdn/acsgroups/user_update_role.go new file mode 100644 index 0000000..7a9d756 --- /dev/null +++ b/pkg/sdn/acsgroups/user_update_role.go @@ -0,0 +1,41 @@ +package acsgroups + +import ( + "context" + "net/http" + + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/constants" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators" +) + +// UserUpdateRoleRequest struct to userUpdateRole access group +type UserUpdateRoleRequest struct { + // Comment of the access group + // Required: true + GroupID string `url:"access_group_id" json:"access_group_id" validate:"required"` + + // Access group role ID + // Required: true + AccessGroupRoleID string `url:"access_group_role_id" json:"access_group_role_id" validate:"required"` + + // User ID + // Required: true + UserID string `url:"user_id" json:"user_id" validate:"required"` +} + +// UserUpdateRole a access groups +func (i AccessGroups) UserUpdateRole(ctx context.Context, req UserUpdateRoleRequest) (bool, error) { + err := validators.ValidateRequest(req) + if err != nil { + return false, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/sdn/access_group/update_role" + + _, err = i.client.DecortApiCallCtype(ctx, http.MethodPut, url, constants.MIMEJSON, req) + if err != nil { + return false, err + } + + return true, nil +} diff --git a/pkg/sdn/sdn.go b/pkg/sdn/sdn.go new file mode 100644 index 0000000..3cef8bc --- /dev/null +++ b/pkg/sdn/sdn.go @@ -0,0 +1,16 @@ +// List of method groups for the SDN +package sdn + +import "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/interfaces" + +// Structure for creating request to SDN groups +type SDN struct { + client interfaces.Caller +} + +// Builder to get access to SDN +func New(client interfaces.Caller) *SDN { + return &SDN{ + client: client, + } +} diff --git a/universal-client.go b/universal-client.go index 7832ae6..13f6b0a 100644 --- a/universal-client.go +++ b/universal-client.go @@ -4,9 +4,9 @@ import ( "fmt" "reflect" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/config" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/pkg/cloudapi" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/pkg/cloudbroker" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/config" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/pkg/cloudapi" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/pkg/cloudbroker" ) type ClientInterface interface {