Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| cd741b7f11 | |||
| a85ad3acd5 | |||
| 823dfb49bc | |||
| e6440bc4a3 | |||
| 84c0248019 |
46
CHANGELOG.md
46
CHANGELOG.md
@@ -1,20 +1,30 @@
|
|||||||
## Version 1.6.7
|
## Version 1.7.2
|
||||||
|
|
||||||
## Bugfix
|
## Bugfix
|
||||||
- Refactoring client and legacy-client
|
- Fix panic in clients
|
||||||
- Delete tag "required" in RecursiveDelete field model DeleteUserRequest in cloudbroker/account/delete_user
|
- Add refresh Token in BVS authorization mode and refactoring bvs_client
|
||||||
- Delete tag "omitempty" in RecursiveDelete field model DeleteUserRequest in cloudapi/account/delete_user
|
- Delete tag validate and omitempty in Permanently field, DeleteRequest model in cloudApi/k8s/delete cloudBroker/k8s/delete
|
||||||
- Delete tag "required" in Ratio field model SetCPUAllocationRatioRequest in cloudbroker/account/set_cpu_allocation_ratio
|
- Add Page and Size fields into model AffinityGroupsListRequest in cloudbroker/rg/affinity_groups_list;
|
||||||
- Change tag from "requireD" to "required" in K8SID field model WorkerRestartRequest in cloudbroker/k8s/worker_restart
|
- Change type of Data field from for model ListAffinityGroup in cloudbroker/rg/affinity_groups_list for correct parsing;
|
||||||
- Add tag "required" in UserIDs field model DeleteUsersRequest in cloudbroker/users/delete_users
|
- Add new models ListAffinityGroupItems and ItemAffinityGroup to support correct parsing for model ListAffinityGroup in cloudbroker/rg/affinity_groups_list;
|
||||||
- Change tag "validate" in ComputeID field model SnapshotEvictDiskRequest in cloudbroker/compute/snapshot_evict_disk
|
- Add missing IDs() method for model ListAffinityGroupItems in cloudbroker/rg/affinity_groups_list;
|
||||||
- Delete unnecessary validation in ListRaw method in cloudbroker/apiaccess/list
|
- Add ResourceLimits field into model ItemResourceConsumption in cloudbroker/rg/models;
|
||||||
- Delete unnecessary validation in ListDeleted method in cloudbroker/apiaccess/list_deleted
|
- Add LockStatus field into model ListRequest in cloudbroker/rg/list;
|
||||||
- Delete unnecessary validation in GetAudit method in cloudbroker/user/get_audit
|
- Fix url for cloudbroker/grid/getDiagnosisGet
|
||||||
- Delete unnecessary validation in ListRaw method in cloudbroker/user/list
|
- Create ListUsers model with Data and EntryCount fields in cloudbroker/compute/models;
|
||||||
- Delete unnecessary validation in ListTypes method in cloudbroker/disks/list_types
|
- Change type of return structure for UserList method from RecordACL to ListUsers in cloudbroker/compute/user_list;
|
||||||
- Delete tag "required" in Active field model ListRequest in cloudbroker/group/list
|
- Create ListSnapShot model with Data and EntryCount fields in cloudbroker/compute/models;
|
||||||
- Delete unnecessary validation in List method in cloudbroker/group/list
|
- Change type of return structure for SnapshotList from ListSnapshots to *ListSnapShot in cloudbroker/compute/snapshot_list;
|
||||||
- Change type from "APIsEndpoints" to "APIString" in APIs field in APIsIncludeRequest model in cloudbroker/apiaccess/apis_include
|
- Change json tag for TotalDiskSize field for model ItemCompute in cloudbroker/compute/models;
|
||||||
- Change type from "APIsEndpoints" to "APIString" in APIs field in APIsExcludeRequest model in cloudbroker/apiaccess/apis_exclude
|
- Add NeedReboot and CdImageId fields for model InfoCompute in cloudbroker/compute/models;
|
||||||
- Refactoring multiple errors out put after validation in all cloudapi and cloudbroker groups, in client and legacy-client
|
- Reorganize ListPFW model by adding Data and EntryCount fields with json tags in cloudbroker/compute/models;
|
||||||
|
- Fix IDs() method for ListPFW model in cloudbroker/compute/ids;
|
||||||
|
- Change type of return structure for PFWList method from ListPFW to *ListPFW in cloudbroker/compute/pfw_list.
|
||||||
|
|
||||||
|
|
||||||
|
## Feature
|
||||||
|
- Add endpoints AccessAdd AccessRemote in cloudBroker/k8ci
|
||||||
|
- Add endpoints Audit in cloudBroker
|
||||||
|
- Add AuthBroker field to model RecordGrid in cloudbroker/grid/models
|
||||||
|
- Add AuthBroker field to model ItemGridList in cloudbroker/grid/models
|
||||||
|
- Add endpoints DeleteCustomFields in cloudbroker/compute
|
||||||
|
|||||||
365
README.md
365
README.md
@@ -11,6 +11,7 @@ Decort SDK - это библиотека, написанная на языке G
|
|||||||
- Версия 1.4.x Decort-SDK соответствует 3.8.6 версии платформы
|
- Версия 1.4.x Decort-SDK соответствует 3.8.6 версии платформы
|
||||||
- Версия 1.5.x Decort-SDK соответствует 3.8.7 версии платформы
|
- Версия 1.5.x Decort-SDK соответствует 3.8.7 версии платформы
|
||||||
- Версия 1.6.x Decort-SDK соответствует 3.8.8 версии платформы
|
- Версия 1.6.x Decort-SDK соответствует 3.8.8 версии платформы
|
||||||
|
- Версия 1.7.х Decort-SDK соответствует 3.8.9 версии платформы
|
||||||
|
|
||||||
## Оглавление
|
## Оглавление
|
||||||
|
|
||||||
@@ -167,7 +168,7 @@ import (
|
|||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
// Парсинг конфигурации из JSON-файла
|
// Парсинг конфигурации из JSON-файла
|
||||||
cfg := config.ParseConfigJSON("<PATH>")
|
cfg, _ := config.ParseConfigJSON("<PATH>")
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -634,7 +635,7 @@ filtered := resp.
|
|||||||
```go
|
```go
|
||||||
func main() {
|
func main() {
|
||||||
// Чтение конфигурации из файла
|
// Чтение конфигурации из файла
|
||||||
cfg := config.ParseConfigJSON("<PATH>")
|
cfg, _ := config.ParseConfigJSON("<PATH>")
|
||||||
|
|
||||||
// Создание клиента
|
// Создание клиента
|
||||||
client := decort.New(cfg)
|
client := decort.New(cfg)
|
||||||
@@ -766,6 +767,52 @@ func main() {
|
|||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Получение списка уникальных идентификаторов (ID) объекта
|
||||||
|
|
||||||
|
Для всех структур, имеющих поля со списками объектов с уникальными числовыми идентификаторами (ID), добавлены методы IDs(), возвращающие массивы уникальных идентификаторов объектов в этих списках.
|
||||||
|
|
||||||
|
```go
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"log"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/config"
|
||||||
|
decort "repository.basistech.ru/BASIS/decort-golang-sdk"
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/bservice"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
// Настройка конфигурации
|
||||||
|
cfg := config.Config{
|
||||||
|
AppID: "<APPID>",
|
||||||
|
AppSecret: "<APPSECRET>",
|
||||||
|
SSOURL: "https://sso.digitalenergy.online",
|
||||||
|
DecortURL: "https://mr4.digitalenergy.online",
|
||||||
|
Retries: 5,
|
||||||
|
}
|
||||||
|
|
||||||
|
// Создание клиента
|
||||||
|
client := decort.New(cfg)
|
||||||
|
|
||||||
|
// Создание структуры запроса GetRequest на получение информации о сервисе и выполнение запроса с помощью конвейера
|
||||||
|
req := bservice.GetRequest{
|
||||||
|
ServiceID: 123,
|
||||||
|
}
|
||||||
|
res, err := client.CloudAPI().BService().Get(context.Background(), req)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Получение списков ID ComputeIDs и GroupIDs экземпляра res типа RecordBasicService по полям Computes и Groups, соответственно
|
||||||
|
computeIDs := res.Computes.IDs()
|
||||||
|
groupIDs := res.Groups.IDs()
|
||||||
|
fmt.Println(computeIDs)
|
||||||
|
fmt.Println(groupIDs)
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
## Работа с legacy клиентом
|
## Работа с legacy клиентом
|
||||||
|
|
||||||
Работа с legacy клиентом применяется для пользователей, которые не используют для авторизации decs3o.
|
Работа с legacy клиентом применяется для пользователей, которые не используют для авторизации decs3o.
|
||||||
@@ -817,7 +864,7 @@ import (
|
|||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
// Парсинг конфигурации из YAML-файла
|
// Парсинг конфигурации из YAML-файла
|
||||||
legacyCfg := config.ParseLegacyConfigYAML("<PATH>")
|
legacyCfg, _ := config.ParseLegacyConfigYAML("<PATH>")
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -890,6 +937,7 @@ func main() {
|
|||||||
legacyCfg := config.LegacyConfig{
|
legacyCfg := config.LegacyConfig{
|
||||||
Username: "<USERNAME>",
|
Username: "<USERNAME>",
|
||||||
Password: "<PASSWORD>",
|
Password: "<PASSWORD>",
|
||||||
|
Domain: "dynamix",
|
||||||
DecortURL: "https://mr4.digitalenergy.online",
|
DecortURL: "https://mr4.digitalenergy.online",
|
||||||
Retries: 5,
|
Retries: 5,
|
||||||
}
|
}
|
||||||
@@ -915,3 +963,314 @@ func main() {
|
|||||||
|
|
||||||
fmt.Println(res)
|
fmt.Println(res)
|
||||||
}
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## Работа с BVS клиентом
|
||||||
|
|
||||||
|
Работа с BVS клиентом применяется для пользователей, которые используют для авторизации BVS.
|
||||||
|
|
||||||
|
### Настройка параметров BVS в кабинете администратора
|
||||||
|
|
||||||
|
Для корректной работы функции обновления токена необходимо соблюдать следующие условия:
|
||||||
|
|
||||||
|
на странице администратора по следующему пути: домены-<имя вашего домена>-(символ i)-токены
|
||||||
|
- параметр "Время жизни токена доступа" - устанавливается для всего домена. Не применяется есть по следующему пути: безопасность-клиентские_системы-(символ i)-токены-"Время жизни токена доступа" не выставлено иное время, которое имеет больший приоритет для конкретной клиентской системы
|
||||||
|
- параметр "Время простоя сессии" - время жизни токена обновления. В случае указания количества минут меньше, чем время жизни токена, то обновление токена будет работать некорректно. Редомендуется указывать время или равное или больше времени жизни токена
|
||||||
|
- параметр "Максимальное время жизни сессии" - время в течение которого возможно производить обновление токена. Если данный параметр будет равен времени жизни токена, то обновление токена будет работать некорректно. Редомендуется указывать время больше времени жизни токена
|
||||||
|
|
||||||
|
### Настройка конфигурации BVS клиента
|
||||||
|
|
||||||
|
Сначала, необходимо создать переменную конфигурации клиента. Конфигурация состоит как из обязательных, так и необязательных полей.
|
||||||
|
|
||||||
|
| Поле | Тип | Обязательный | Описание |
|
||||||
|
| ------------- | --------------------------------------------- | ------------ | ------------------------------------------------------------------ |
|
||||||
|
| Username | string | Да | username пользователя |
|
||||||
|
| Password | string | Да | пароль пользователя |
|
||||||
|
| AppID | string | Да | app_id ключа для выполнения запросов |
|
||||||
|
| AppSecret | string | Да | app_secret ключ для выполнения запроса |
|
||||||
|
| DecortURL | string | Да | URL адрес платформы, с которой будет осуществляться взаимодействие |
|
||||||
|
| SSOURL | string | Да | URL адрес сервиса аутентификации и авторизации |
|
||||||
|
| Domain | string | Да | Имя домена |
|
||||||
|
| Retries | uint | Нет | Кол-во неудачных попыток выполнения запроса, по умолчанию - 5 |
|
||||||
|
| Timeout | config.Duration | Нет | Таймаут HTTP клиента, по умолчанию - без ограничений |
|
||||||
|
| SSLSkipVerify | bool | Нет | Пропуск проверки подлинности сертификата |
|
||||||
|
| Token | struct{} [см. ниже](#описание-структуры-token)| Нет | JWT токен |
|
||||||
|
| PathCfg | string | Нет | Путь записи конфигурации в файл |
|
||||||
|
| PathToken | string | Нет | Путь записи токена в файл |
|
||||||
|
| TimeToRefresh | uint | Нет | Количество минут, за сколько до истечения срока действия токена выполнится его обновление, по умолчанию - 1 минута |
|
||||||
|
|
||||||
|
### Описание структуры token
|
||||||
|
| Параметр | Тип | Описание |
|
||||||
|
| ------------ | ------ | ------------------------------- |
|
||||||
|
| AccessToken | string | Токен |
|
||||||
|
| TokenType | string | Тип токена |
|
||||||
|
| RefreshToken | string | Токен для запроса на обновление |
|
||||||
|
| Expiry | time | Время жизни токена |
|
||||||
|
|
||||||
|
#### Пример конфигурации BVS клиента
|
||||||
|
|
||||||
|
```go
|
||||||
|
import (
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/config"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main(){
|
||||||
|
// Настройка конфигурации
|
||||||
|
BvsCfg := config.BVSConfig{
|
||||||
|
AppID: "<APP_ID>",
|
||||||
|
AppSecret: "<APP_SECRET>",
|
||||||
|
Username: "<USERNAME>",
|
||||||
|
Password: "<PASSWORD>",
|
||||||
|
SSOURL: "https://bvs-delta.qa.loc:8443"
|
||||||
|
DecortURL: "https://delta.qa.loc",
|
||||||
|
Domain: "dynamix"
|
||||||
|
Retries: 5,
|
||||||
|
}
|
||||||
|
|
||||||
|
BvsCfg.SetTimeout(5 * time.Minute)
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Парсинг BVS конфигурации из файла
|
||||||
|
|
||||||
|
Также возможно создать переменную конфигурации из JSON или YAML файла, используя функцию `ParseConfigBVSJSON` (или `ParseConfigBVSYAML`) из пакета config.
|
||||||
|
<br>
|
||||||
|
*См. пример файлов конфигурации ниже и в директории `samples/`.*
|
||||||
|
|
||||||
|
```go
|
||||||
|
import (
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/config"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
// Парсинг конфигурации из YAML-файла
|
||||||
|
BVSCfg, _ := config.ParseConfigBVSYAML("<PATH>")
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Парсинг BVS токена из файла
|
||||||
|
|
||||||
|
Также возможно создать переменную токена из JSON или YAML файла, используя функцию `ParseTokenBVSJSON` (или `ParseTokenBVSYAML`) из пакета config.
|
||||||
|
<br>
|
||||||
|
*См. пример файлов конфигурации ниже и в директории `samples/`.*
|
||||||
|
|
||||||
|
```go
|
||||||
|
import (
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/config"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
// Парсинг токена из json-файла
|
||||||
|
BVSToken, _ := config.ParseTokenBVSJSON("<PATH>")
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Пример BVS JSON конфигурации
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"username": "<USERNAME>",
|
||||||
|
"password": "<PASSWORD>",
|
||||||
|
"appId": "<APP_ID>",
|
||||||
|
"appSecret": "<APP_SECRET>",
|
||||||
|
"ssoUrl": "https://bvs-delta.qa.loc:8443",
|
||||||
|
"decortUrl": "https://delta.qa.loc",
|
||||||
|
"domain": "dynamix",
|
||||||
|
"token": {
|
||||||
|
"access_token": "string_token",
|
||||||
|
"token_type": "bearer",
|
||||||
|
"refresh_token": "string_refresh_token",
|
||||||
|
"expiry": "2023-11-24T12:40:27.954150524+03:00"
|
||||||
|
},
|
||||||
|
"retries": 5,
|
||||||
|
"sslSkipVerify": true,
|
||||||
|
"timeout": "5m",
|
||||||
|
"path_cfg": "config",
|
||||||
|
"path_token": "token",
|
||||||
|
"timeToRefresh": 5
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Пример BVS YAML конфигурации
|
||||||
|
```yaml
|
||||||
|
username: <USERNAME>
|
||||||
|
password: <PASSWORD>
|
||||||
|
appId: <APP_ID>
|
||||||
|
appSecret: <APP_SECRET>
|
||||||
|
ssoUrl: https://bvs-delta.qa.loc:8443
|
||||||
|
decortUrl: https://delta.qa.loc
|
||||||
|
domain: dynamix
|
||||||
|
token":
|
||||||
|
access_token: string_token
|
||||||
|
token_type: bearer
|
||||||
|
refresh_token: string_refresh_token
|
||||||
|
expiry: 2023-11-24T12:40:27.954150524+03:00
|
||||||
|
retries: 5
|
||||||
|
sslSkipVerify: true
|
||||||
|
timeout: 5m
|
||||||
|
path_cfg: config
|
||||||
|
path_token: token
|
||||||
|
timeToRefresh: 5
|
||||||
|
```
|
||||||
|
### Создание BVS клиента
|
||||||
|
|
||||||
|
Создание клиента происходит с помощью функции-строителя `NewBVS` из основного пакета `decort-sdk`, для избежания проблем с именами, пакету можно присвоить алиас `decort`. Функция принимает конфигурацию, возвращает структуру `DecortClient`, с помощью которой можно взаимодействовать с платформой.
|
||||||
|
|
||||||
|
#### Пример создания BVS клиента
|
||||||
|
|
||||||
|
```go
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/config"
|
||||||
|
decort "repository.basistech.ru/BASIS/decort-golang-sdk"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
// Настройка конфигурации
|
||||||
|
BVSCfg := config.BVSConfig{
|
||||||
|
Username: "<USERNAME>",
|
||||||
|
Password: "<PASSWORD>",
|
||||||
|
AppID: "<APPID>",
|
||||||
|
AppSecret: "<APPSECRET>",
|
||||||
|
SSOURL: "https://bvs-delta.qa.loc:8443"
|
||||||
|
DecortURL: "https://mr4.digitalenergy.online",
|
||||||
|
Domain: "dynamix",
|
||||||
|
Retries: 5,
|
||||||
|
}
|
||||||
|
|
||||||
|
BVSCfg.SetTimeout(5 * time.Minute)
|
||||||
|
|
||||||
|
// Создание клиента
|
||||||
|
BVSClient := decort.NewBVS(cfg)
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Пример получения BVS токена
|
||||||
|
|
||||||
|
В случае указания значения в переменной конфигурации `PathCfg` токен и конфигурация будут записаны в файл в формате `json`, переменная `PathToken` служит для записи токена в файл в формате `json`
|
||||||
|
|
||||||
|
```go
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/config"
|
||||||
|
decort "repository.basistech.ru/BASIS/decort-golang-sdk"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
// Настройка конфигурации
|
||||||
|
BVSCfg := config.config.BVSConfig{
|
||||||
|
Username: "<USERNAME>",
|
||||||
|
Password: "<PASSWORD>",
|
||||||
|
AppID: "<APPID>",
|
||||||
|
AppSecret: "<APPSECRET>",
|
||||||
|
SSOURL: "https://bvs-delta.qa.loc:8443"
|
||||||
|
DecortURL: "https://mr4.digitalenergy.online",
|
||||||
|
Domain: "dynamix",
|
||||||
|
PathCfg: "config",
|
||||||
|
Retries: 5,
|
||||||
|
}
|
||||||
|
|
||||||
|
// Создание клиента
|
||||||
|
BVSClient := decort.NewBVS(cfg)
|
||||||
|
|
||||||
|
// Выполнение запроса на получение токена
|
||||||
|
token, err := client.GetToken(context.Background())
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Println(token)
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Пример обновления BVS токена
|
||||||
|
|
||||||
|
В случае указания значения в переменной конфигурации `PathCfg` обновленный токен и конфигурация будут записаны в файл в формате `json`, переменная `PathToken` служит для записи токена в файл в формате `json`
|
||||||
|
|
||||||
|
```go
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/config"
|
||||||
|
decort "repository.basistech.ru/BASIS/decort-golang-sdk"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
// Настройка конфигурации
|
||||||
|
BVSCfg := config.config.BVSConfig{
|
||||||
|
Username: "<USERNAME>",
|
||||||
|
Password: "<PASSWORD>",
|
||||||
|
AppID: "<APPID>",
|
||||||
|
AppSecret: "<APPSECRET>",
|
||||||
|
SSOURL: "https://bvs-delta.qa.loc:8443"
|
||||||
|
DecortURL: "https://mr4.digitalenergy.online",
|
||||||
|
Domain: "dynamix",
|
||||||
|
PathToken: "token",
|
||||||
|
Retries: 5,
|
||||||
|
}
|
||||||
|
|
||||||
|
// Создание клиента
|
||||||
|
BVSClient := decort.NewBVS(cfg)
|
||||||
|
|
||||||
|
// Выполнение запроса на обновление токена
|
||||||
|
token, err := client.RefreshToken(context.Background())
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Println(token)
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Пример выполнения запроса
|
||||||
|
|
||||||
|
```go
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/config"
|
||||||
|
decort "repository.basistech.ru/BASIS/decort-golang-sdk"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
// Настройка конфигурации
|
||||||
|
BVSCfg := config.config.BVSConfig{
|
||||||
|
Username: "<USERNAME>",
|
||||||
|
Password: "<PASSWORD>",
|
||||||
|
AppID: "<APPID>",
|
||||||
|
AppSecret: "<APPSECRET>",
|
||||||
|
SSOURL: "https://bvs-delta.qa.loc:8443"
|
||||||
|
DecortURL: "https://mr4.digitalenergy.online",
|
||||||
|
Domain: "dynamix",
|
||||||
|
Retries: 5,
|
||||||
|
}
|
||||||
|
|
||||||
|
// Создание клиента
|
||||||
|
BVSClient := decort.NewBVS(cfg)
|
||||||
|
|
||||||
|
// Создание структуры запроса
|
||||||
|
// CreateRequest - реквест на создание виртуальной машины
|
||||||
|
req := kvmx86.CreateRequest{
|
||||||
|
RGID: 123,
|
||||||
|
Name: "compute",
|
||||||
|
CPU: 4,
|
||||||
|
RAM: 4096,
|
||||||
|
ImageID: 321,
|
||||||
|
}
|
||||||
|
|
||||||
|
// Выполнение запроса
|
||||||
|
res, err := client.CloudAPI().KVMX86().Create(context.Background(), req)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Println(res)
|
||||||
|
}
|
||||||
23
client.go
23
client.go
@@ -16,6 +16,7 @@ import (
|
|||||||
|
|
||||||
"github.com/google/go-querystring/query"
|
"github.com/google/go-querystring/query"
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/config"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/config"
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants"
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi"
|
||||||
k8s_ca "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/k8s"
|
k8s_ca "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/k8s"
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker"
|
||||||
@@ -88,7 +89,7 @@ func (dc *DecortClient) DecortApiCall(ctx context.Context, method, url string, p
|
|||||||
body = bytes.NewBufferString(values.Encode())
|
body = bytes.NewBufferString(values.Encode())
|
||||||
}
|
}
|
||||||
|
|
||||||
req, err := http.NewRequestWithContext(ctx, method, dc.decortURL+"/restmachine"+url, body)
|
req, err := http.NewRequestWithContext(ctx, method, dc.decortURL+constants.Restmachine+url, body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -162,23 +163,25 @@ func (dc *DecortClient) do(req *http.Request, ctype string) (*http.Response, err
|
|||||||
// var resp *http.Response
|
// var resp *http.Response
|
||||||
// var err error
|
// var err error
|
||||||
buf, _ := io.ReadAll(req.Body)
|
buf, _ := io.ReadAll(req.Body)
|
||||||
// req = req.Clone(req.Context())
|
|
||||||
|
|
||||||
// for i := uint64(0); i < dc.cfg.Retries; i++ {
|
// for i := uint64(0); i < dc.cfg.Retries; i++ {
|
||||||
|
// req = req.Clone(req.Context())
|
||||||
req.Body = io.NopCloser(bytes.NewBuffer(buf))
|
req.Body = io.NopCloser(bytes.NewBuffer(buf))
|
||||||
resp, err := dc.client.Do(req)
|
resp, err := dc.client.Do(req)
|
||||||
|
if err != nil || resp == nil {
|
||||||
|
return resp, err
|
||||||
|
}
|
||||||
|
|
||||||
// if err == nil {
|
|
||||||
if resp.StatusCode == 200 {
|
if resp.StatusCode == 200 {
|
||||||
return resp, err
|
return resp, err
|
||||||
}
|
}
|
||||||
respBytes, _ := io.ReadAll(resp.Body)
|
|
||||||
err = fmt.Errorf("%s", respBytes)
|
|
||||||
resp.Body.Close()
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
return nil, fmt.Errorf("could not execute request: %w", err)
|
respBytes, err := io.ReadAll(resp.Body)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
resp.Body.Close()
|
||||||
|
return resp, errors.New(string(respBytes))
|
||||||
}
|
}
|
||||||
|
|
||||||
func createK8sCloudApi(req k8s_ca.CreateRequest) (*bytes.Buffer, string) {
|
func createK8sCloudApi(req k8s_ca.CreateRequest) (*bytes.Buffer, string) {
|
||||||
@@ -402,7 +405,7 @@ func createK8sCloudBroker(req k8s_cb.CreateRequest) (*bytes.Buffer, string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_ = writer.WriteField("extnetOnly", strconv.FormatBool(req.ExtNetOnly))
|
_ = writer.WriteField("extnetOnly", strconv.FormatBool(req.ExtNetOnly))
|
||||||
|
|
||||||
ct := writer.FormDataContentType()
|
ct := writer.FormDataContentType()
|
||||||
|
|
||||||
writer.Close()
|
writer.Close()
|
||||||
|
|||||||
519
client_bvs.go
Normal file
519
client_bvs.go
Normal file
@@ -0,0 +1,519 @@
|
|||||||
|
package decortsdk
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
"context"
|
||||||
|
"crypto/tls"
|
||||||
|
"encoding/json"
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
"io"
|
||||||
|
"mime/multipart"
|
||||||
|
"net/http"
|
||||||
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
"sync"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/google/go-querystring/query"
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/config"
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants"
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi"
|
||||||
|
k8s_ca "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/k8s"
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker"
|
||||||
|
k8s_cb "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/k8s"
|
||||||
|
)
|
||||||
|
|
||||||
|
// HTTP-client for platform
|
||||||
|
type BVSDecortClient struct {
|
||||||
|
client *http.Client
|
||||||
|
cfg config.BVSConfig
|
||||||
|
mutex *sync.Mutex
|
||||||
|
decortURL string
|
||||||
|
}
|
||||||
|
|
||||||
|
type tokenJSON struct {
|
||||||
|
AccessToken string `json:"access_token"`
|
||||||
|
TokenType string `json:"token_type"`
|
||||||
|
RefreshToken string `json:"refresh_token"`
|
||||||
|
ExpiresIn uint64 `json:"expires_in"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Сlient builder
|
||||||
|
func NewBVS(cfg config.BVSConfig) *BVSDecortClient {
|
||||||
|
if cfg.Retries == 0 {
|
||||||
|
cfg.Retries = 5
|
||||||
|
}
|
||||||
|
if cfg.TimeToRefresh == 0 {
|
||||||
|
cfg.TimeToRefresh = 1
|
||||||
|
}
|
||||||
|
|
||||||
|
return &BVSDecortClient{
|
||||||
|
decortURL: cfg.DecortURL,
|
||||||
|
client: &http.Client{
|
||||||
|
Transport: &http.Transport{
|
||||||
|
TLSClientConfig: &tls.Config{
|
||||||
|
//nolint:gosec
|
||||||
|
InsecureSkipVerify: cfg.SSLSkipVerify,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
cfg: cfg,
|
||||||
|
mutex: &sync.Mutex{},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// CloudAPI builder
|
||||||
|
func (bdc *BVSDecortClient) CloudAPI() *cloudapi.CloudAPI {
|
||||||
|
return cloudapi.New(bdc)
|
||||||
|
}
|
||||||
|
|
||||||
|
// CloudBroker builder
|
||||||
|
func (bdc *BVSDecortClient) CloudBroker() *cloudbroker.CloudBroker {
|
||||||
|
return cloudbroker.New(bdc)
|
||||||
|
}
|
||||||
|
|
||||||
|
// DecortApiCall method for sending requests to the platform
|
||||||
|
func (bdc *BVSDecortClient) DecortApiCall(ctx context.Context, method, url string, params interface{}) ([]byte, error) {
|
||||||
|
k8sCaCreateReq, okCa := params.(k8s_ca.CreateRequest)
|
||||||
|
k8sCbCreateReq, okCb := params.(k8s_cb.CreateRequest)
|
||||||
|
var body *bytes.Buffer
|
||||||
|
var ctype string
|
||||||
|
|
||||||
|
if okCa {
|
||||||
|
body, ctype = createK8sCloudApiBVS(k8sCaCreateReq)
|
||||||
|
} else if okCb {
|
||||||
|
body, ctype = createK8sCloudBrokerBVS(k8sCbCreateReq)
|
||||||
|
} else {
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
if bdc.cfg.Token.AccessToken == "" {
|
||||||
|
if _, err = bdc.GetToken(ctx); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
reqCopy := req.Clone(ctx)
|
||||||
|
//nolint:bodyclose
|
||||||
|
//work defer, error lint
|
||||||
|
resp, err := bdc.do(req, ctype)
|
||||||
|
if err != nil {
|
||||||
|
if err.Error() == "access is denied" {
|
||||||
|
if _, err = bdc.GetToken(ctx); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
//nolint:bodyclose
|
||||||
|
//we close the body in case of any error
|
||||||
|
resp, err = bdc.do(reqCopy, ctype)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
defer resp.Body.Close()
|
||||||
|
|
||||||
|
respBytes, err := io.ReadAll(resp.Body)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if resp.StatusCode != 200 {
|
||||||
|
return nil, errors.New(string(respBytes))
|
||||||
|
}
|
||||||
|
|
||||||
|
return respBytes, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetToken allows you to get a token and returns the token structure, when specifying the PathCfg variable,
|
||||||
|
// the token and configuration will be written to a file,
|
||||||
|
// when specifying the PathToken variable, the token will be written to a file
|
||||||
|
func (bdc *BVSDecortClient) GetToken(ctx context.Context) (config.Token, error) {
|
||||||
|
bdc.mutex.Lock()
|
||||||
|
defer bdc.mutex.Unlock()
|
||||||
|
|
||||||
|
body := fmt.Sprintf("grant_type=password&client_id=%s&client_secret=%s&username=%s&password=%s&response_type=token&scope=openid", bdc.cfg.AppID, bdc.cfg.AppSecret, bdc.cfg.Username, bdc.cfg.Password)
|
||||||
|
bodyReader := strings.NewReader(body)
|
||||||
|
|
||||||
|
bdc.cfg.SSOURL = strings.TrimSuffix(bdc.cfg.SSOURL, "/")
|
||||||
|
|
||||||
|
req, _ := http.NewRequestWithContext(ctx, "POST", bdc.cfg.SSOURL+"/realms/"+bdc.cfg.Domain+"/protocol/openid-connect/token", bodyReader)
|
||||||
|
req.Header.Add("Content-Type", "application/x-www-form-urlencoded")
|
||||||
|
|
||||||
|
resp, err := bdc.client.Do(req)
|
||||||
|
if err != nil {
|
||||||
|
return config.Token{}, fmt.Errorf("cannot get token: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
tokenBytes, _ := io.ReadAll(resp.Body)
|
||||||
|
resp.Body.Close()
|
||||||
|
|
||||||
|
if resp.StatusCode != 200 {
|
||||||
|
return config.Token{}, fmt.Errorf("cannot get token: %s", tokenBytes)
|
||||||
|
}
|
||||||
|
|
||||||
|
var tj tokenJSON
|
||||||
|
|
||||||
|
if err = json.Unmarshal(tokenBytes, &tj); err != nil {
|
||||||
|
return config.Token{}, fmt.Errorf("cannot unmarshal token: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
bdc.cfg.Token = config.Token{
|
||||||
|
AccessToken: tj.AccessToken,
|
||||||
|
TokenType: tj.TokenType,
|
||||||
|
RefreshToken: tj.RefreshToken,
|
||||||
|
Expiry: tj.expiry(),
|
||||||
|
}
|
||||||
|
|
||||||
|
if bdc.cfg.PathCfg != "" {
|
||||||
|
ser, _ := bdc.cfg.Serialize("", " ")
|
||||||
|
_ = ser.WriteToFile(bdc.cfg.PathCfg)
|
||||||
|
}
|
||||||
|
|
||||||
|
if bdc.cfg.PathToken != "" {
|
||||||
|
ser, _ := bdc.cfg.Token.Serialize("", " ")
|
||||||
|
_ = ser.WriteToFile(bdc.cfg.PathToken)
|
||||||
|
}
|
||||||
|
|
||||||
|
return bdc.cfg.Token, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// RefreshToken allows you to refresh a token and returns the token structure, when specifying the PathCfg variable,
|
||||||
|
// the token and configuration will be written to a file,
|
||||||
|
// when specifying the PathToken variable, the token will be written to a file
|
||||||
|
func (bdc *BVSDecortClient) RefreshToken(ctx context.Context) (config.Token, error) {
|
||||||
|
bdc.mutex.Lock()
|
||||||
|
defer bdc.mutex.Unlock()
|
||||||
|
|
||||||
|
body := fmt.Sprintf("grant_type=refresh_token&client_id=%s&client_secret=%s&refresh_token=%s&scope=openid", bdc.cfg.AppID, bdc.cfg.AppSecret, bdc.cfg.Token.RefreshToken)
|
||||||
|
bodyReader := strings.NewReader(body)
|
||||||
|
|
||||||
|
bdc.cfg.SSOURL = strings.TrimSuffix(bdc.cfg.SSOURL, "/")
|
||||||
|
|
||||||
|
req, _ := http.NewRequestWithContext(ctx, "POST", bdc.cfg.SSOURL+"/realms/"+bdc.cfg.Domain+"/protocol/openid-connect/token", bodyReader)
|
||||||
|
req.Header.Add("Content-Type", "application/x-www-form-urlencoded")
|
||||||
|
|
||||||
|
resp, err := bdc.client.Do(req)
|
||||||
|
if err != nil {
|
||||||
|
return config.Token{}, fmt.Errorf("cannot refresh token: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
tokenBytes, _ := io.ReadAll(resp.Body)
|
||||||
|
resp.Body.Close()
|
||||||
|
|
||||||
|
if resp.StatusCode != 200 {
|
||||||
|
return config.Token{}, fmt.Errorf("cannot refresh token: %s", tokenBytes)
|
||||||
|
}
|
||||||
|
|
||||||
|
var tj tokenJSON
|
||||||
|
|
||||||
|
if err = json.Unmarshal(tokenBytes, &tj); err != nil {
|
||||||
|
return config.Token{}, fmt.Errorf("cannot unmarshal after refresh token: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
bdc.cfg.Token = config.Token{
|
||||||
|
AccessToken: tj.AccessToken,
|
||||||
|
TokenType: tj.TokenType,
|
||||||
|
RefreshToken: tj.RefreshToken,
|
||||||
|
Expiry: tj.expiry(),
|
||||||
|
}
|
||||||
|
|
||||||
|
if bdc.cfg.PathCfg != "" {
|
||||||
|
ser, _ := bdc.cfg.Serialize("", " ")
|
||||||
|
_ = ser.WriteToFile(bdc.cfg.PathCfg)
|
||||||
|
}
|
||||||
|
|
||||||
|
if bdc.cfg.PathToken != "" {
|
||||||
|
ser, _ := bdc.cfg.Token.Serialize("", " ")
|
||||||
|
_ = ser.WriteToFile(bdc.cfg.PathToken)
|
||||||
|
}
|
||||||
|
|
||||||
|
return bdc.cfg.Token, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *tokenJSON) expiry() (t time.Time) {
|
||||||
|
if v := e.ExpiresIn; v != 0 {
|
||||||
|
return time.Now().Add(time.Duration(v) * time.Second)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func (bdc *BVSDecortClient) do(req *http.Request, ctype string) (*http.Response, error) {
|
||||||
|
if ctype != "" {
|
||||||
|
req.Header.Add("Content-Type", ctype)
|
||||||
|
} else {
|
||||||
|
req.Header.Add("Content-Type", "application/x-www-form-urlencoded")
|
||||||
|
}
|
||||||
|
req.Header.Add("Authorization", "bearer "+bdc.cfg.Token.AccessToken)
|
||||||
|
req.Header.Set("Accept", "application/json")
|
||||||
|
|
||||||
|
buf, _ := io.ReadAll(req.Body)
|
||||||
|
|
||||||
|
req.Body = io.NopCloser(bytes.NewBuffer(buf))
|
||||||
|
resp, err := bdc.client.Do(req)
|
||||||
|
if err != nil || resp == nil {
|
||||||
|
return resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if resp.StatusCode == 401 {
|
||||||
|
resp.Body.Close()
|
||||||
|
return resp, errors.New("access is denied")
|
||||||
|
}
|
||||||
|
|
||||||
|
if resp.StatusCode == 200 {
|
||||||
|
return resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
respBytes, err := io.ReadAll(resp.Body)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
resp.Body.Close()
|
||||||
|
return resp, errors.New(string(respBytes))
|
||||||
|
}
|
||||||
|
|
||||||
|
func createK8sCloudApiBVS(req k8s_ca.CreateRequest) (*bytes.Buffer, string) {
|
||||||
|
reqBody := &bytes.Buffer{}
|
||||||
|
writer := multipart.NewWriter(reqBody)
|
||||||
|
if req.OidcCertificate != "" {
|
||||||
|
part, _ := writer.CreateFormFile("oidcCertificate", "ca.crt")
|
||||||
|
_, _ = io.Copy(part, strings.NewReader(req.OidcCertificate))
|
||||||
|
}
|
||||||
|
|
||||||
|
_ = writer.WriteField("name", req.Name)
|
||||||
|
_ = writer.WriteField("rgId", strconv.FormatUint(req.RGID, 10))
|
||||||
|
_ = writer.WriteField("k8ciId", strconv.FormatUint(req.K8SCIID, 10))
|
||||||
|
_ = writer.WriteField("workerGroupName", req.WorkerGroupName)
|
||||||
|
_ = writer.WriteField("networkPlugin", req.NetworkPlugin)
|
||||||
|
|
||||||
|
if req.MasterSEPID != 0 {
|
||||||
|
_ = writer.WriteField("masterSepId", strconv.FormatUint(req.MasterSEPID, 10))
|
||||||
|
}
|
||||||
|
if req.MasterSEPPool != "" {
|
||||||
|
_ = writer.WriteField("masterSepPool", req.MasterSEPPool)
|
||||||
|
}
|
||||||
|
if req.WorkerSEPID != 0 {
|
||||||
|
_ = writer.WriteField("workerSepId", strconv.FormatUint(req.WorkerSEPID, 10))
|
||||||
|
}
|
||||||
|
if req.WorkerSEPPool != "" {
|
||||||
|
_ = writer.WriteField("workerSepPool", req.WorkerSEPPool)
|
||||||
|
}
|
||||||
|
|
||||||
|
if req.Labels != nil {
|
||||||
|
for _, v := range req.Labels {
|
||||||
|
_ = writer.WriteField("labels", v)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if req.Taints != nil {
|
||||||
|
for _, v := range req.Taints {
|
||||||
|
_ = writer.WriteField("taints", v)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if req.Annotations != nil {
|
||||||
|
for _, v := range req.Annotations {
|
||||||
|
_ = writer.WriteField("annotations", v)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if req.MasterCPU != 0 {
|
||||||
|
_ = writer.WriteField("masterCpu", strconv.FormatUint(uint64(req.MasterCPU), 10))
|
||||||
|
}
|
||||||
|
if req.MasterNum != 0 {
|
||||||
|
_ = writer.WriteField("masterNum", strconv.FormatUint(uint64(req.MasterNum), 10))
|
||||||
|
}
|
||||||
|
if req.MasterRAM != 0 {
|
||||||
|
_ = writer.WriteField("masterRam", strconv.FormatUint(uint64(req.MasterRAM), 10))
|
||||||
|
}
|
||||||
|
if req.MasterDisk != 0 {
|
||||||
|
_ = writer.WriteField("masterDisk", strconv.FormatUint(uint64(req.MasterDisk), 10))
|
||||||
|
}
|
||||||
|
if req.WorkerCPU != 0 {
|
||||||
|
_ = writer.WriteField("workerCpu", strconv.FormatUint(uint64(req.WorkerCPU), 10))
|
||||||
|
}
|
||||||
|
if req.WorkerNum != 0 {
|
||||||
|
_ = writer.WriteField("workerNum", strconv.FormatUint(uint64(req.WorkerNum), 10))
|
||||||
|
}
|
||||||
|
if req.WorkerRAM != 0 {
|
||||||
|
_ = writer.WriteField("workerRam", strconv.FormatUint(uint64(req.WorkerRAM), 10))
|
||||||
|
}
|
||||||
|
if req.WorkerDisk != 0 {
|
||||||
|
_ = writer.WriteField("workerDisk", strconv.FormatUint(uint64(req.WorkerDisk), 10))
|
||||||
|
}
|
||||||
|
if req.ExtNetID != 0 {
|
||||||
|
_ = writer.WriteField("extnetId", strconv.FormatUint(req.ExtNetID, 10))
|
||||||
|
}
|
||||||
|
if req.VinsId != 0 {
|
||||||
|
_ = writer.WriteField("vinsId", strconv.FormatUint(req.VinsId, 10))
|
||||||
|
}
|
||||||
|
if !req.WithLB {
|
||||||
|
_ = writer.WriteField("withLB", strconv.FormatBool(req.WithLB))
|
||||||
|
}
|
||||||
|
|
||||||
|
_ = writer.WriteField("highlyAvailableLB", strconv.FormatBool(req.HighlyAvailable))
|
||||||
|
|
||||||
|
if req.AdditionalSANs != nil {
|
||||||
|
for _, v := range req.AdditionalSANs {
|
||||||
|
_ = writer.WriteField("additionalSANs", v)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if req.InitConfiguration != "" {
|
||||||
|
_ = writer.WriteField("initConfiguration", req.InitConfiguration)
|
||||||
|
}
|
||||||
|
if req.ClusterConfiguration != "" {
|
||||||
|
_ = writer.WriteField("clusterConfiguration", req.ClusterConfiguration)
|
||||||
|
}
|
||||||
|
if req.KubeletConfiguration != "" {
|
||||||
|
_ = writer.WriteField("kubeletConfiguration", req.KubeletConfiguration)
|
||||||
|
}
|
||||||
|
if req.KubeProxyConfiguration != "" {
|
||||||
|
_ = writer.WriteField("kubeProxyConfiguration", req.KubeProxyConfiguration)
|
||||||
|
}
|
||||||
|
if req.JoinConfiguration != "" {
|
||||||
|
_ = writer.WriteField("joinConfiguration", req.JoinConfiguration)
|
||||||
|
}
|
||||||
|
if req.Description != "" {
|
||||||
|
_ = writer.WriteField("desc", req.Description)
|
||||||
|
}
|
||||||
|
if req.UserData != "" {
|
||||||
|
_ = writer.WriteField("userData", req.UserData)
|
||||||
|
}
|
||||||
|
|
||||||
|
_ = writer.WriteField("extnetOnly", strconv.FormatBool(req.ExtNetOnly))
|
||||||
|
|
||||||
|
ct := writer.FormDataContentType()
|
||||||
|
writer.Close()
|
||||||
|
|
||||||
|
return reqBody, ct
|
||||||
|
}
|
||||||
|
|
||||||
|
func createK8sCloudBrokerBVS(req k8s_cb.CreateRequest) (*bytes.Buffer, string) {
|
||||||
|
reqBody := &bytes.Buffer{}
|
||||||
|
writer := multipart.NewWriter(reqBody)
|
||||||
|
if req.OidcCertificate != "" {
|
||||||
|
part, _ := writer.CreateFormFile("oidcCertificate", "ca.crt")
|
||||||
|
_, _ = io.Copy(part, strings.NewReader(req.OidcCertificate))
|
||||||
|
}
|
||||||
|
|
||||||
|
_ = writer.WriteField("name", req.Name)
|
||||||
|
_ = writer.WriteField("rgId", strconv.FormatUint(req.RGID, 10))
|
||||||
|
_ = writer.WriteField("k8ciId", strconv.FormatUint(req.K8CIID, 10))
|
||||||
|
_ = writer.WriteField("workerGroupName", req.WorkerGroupName)
|
||||||
|
_ = writer.WriteField("networkPlugin", req.NetworkPlugin)
|
||||||
|
|
||||||
|
if req.MasterSEPID != 0 {
|
||||||
|
_ = writer.WriteField("masterSepId", strconv.FormatUint(req.MasterSEPID, 10))
|
||||||
|
}
|
||||||
|
if req.MasterSEPPool != "" {
|
||||||
|
_ = writer.WriteField("masterSepPool", req.MasterSEPPool)
|
||||||
|
}
|
||||||
|
if req.WorkerSEPID != 0 {
|
||||||
|
_ = writer.WriteField("workerSepId", strconv.FormatUint(req.WorkerSEPID, 10))
|
||||||
|
}
|
||||||
|
if req.WorkerSEPPool != "" {
|
||||||
|
_ = writer.WriteField("workerSepPool", req.WorkerSEPPool)
|
||||||
|
}
|
||||||
|
|
||||||
|
if req.Labels != nil {
|
||||||
|
for _, v := range req.Labels {
|
||||||
|
_ = writer.WriteField("labels", v)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if req.Taints != nil {
|
||||||
|
for _, v := range req.Taints {
|
||||||
|
_ = writer.WriteField("taints", v)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if req.Annotations != nil {
|
||||||
|
for _, v := range req.Annotations {
|
||||||
|
_ = writer.WriteField("annotations", v)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if req.MasterCPU != 0 {
|
||||||
|
_ = writer.WriteField("masterCpu", strconv.FormatUint(req.MasterCPU, 10))
|
||||||
|
}
|
||||||
|
if req.MasterNum != 0 {
|
||||||
|
_ = writer.WriteField("masterNum", strconv.FormatUint(req.MasterNum, 10))
|
||||||
|
}
|
||||||
|
if req.MasterRAM != 0 {
|
||||||
|
_ = writer.WriteField("masterRam", strconv.FormatUint(req.MasterRAM, 10))
|
||||||
|
}
|
||||||
|
if req.MasterDisk != 0 {
|
||||||
|
_ = writer.WriteField("masterDisk", strconv.FormatUint(req.MasterDisk, 10))
|
||||||
|
}
|
||||||
|
if req.WorkerCPU != 0 {
|
||||||
|
_ = writer.WriteField("workerCpu", strconv.FormatUint(req.WorkerCPU, 10))
|
||||||
|
}
|
||||||
|
if req.WorkerNum != 0 {
|
||||||
|
_ = writer.WriteField("workerNum", strconv.FormatUint(req.WorkerNum, 10))
|
||||||
|
}
|
||||||
|
if req.WorkerRAM != 0 {
|
||||||
|
_ = writer.WriteField("workerRam", strconv.FormatUint(req.WorkerRAM, 10))
|
||||||
|
}
|
||||||
|
if req.WorkerDisk != 0 {
|
||||||
|
_ = writer.WriteField("workerDisk", strconv.FormatUint(req.WorkerDisk, 10))
|
||||||
|
}
|
||||||
|
if req.ExtNetID != 0 {
|
||||||
|
_ = writer.WriteField("extnetId", strconv.FormatUint(req.ExtNetID, 10))
|
||||||
|
}
|
||||||
|
if req.VinsId != 0 {
|
||||||
|
_ = writer.WriteField("vinsId", strconv.FormatUint(req.VinsId, 10))
|
||||||
|
}
|
||||||
|
if !req.WithLB {
|
||||||
|
_ = writer.WriteField("withLB", strconv.FormatBool(req.WithLB))
|
||||||
|
}
|
||||||
|
|
||||||
|
_ = writer.WriteField("highlyAvailableLB", strconv.FormatBool(req.HighlyAvailable))
|
||||||
|
|
||||||
|
if req.AdditionalSANs != nil {
|
||||||
|
for _, v := range req.AdditionalSANs {
|
||||||
|
_ = writer.WriteField("additionalSANs", v)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if req.InitConfiguration != "" {
|
||||||
|
_ = writer.WriteField("initConfiguration", req.InitConfiguration)
|
||||||
|
}
|
||||||
|
if req.ClusterConfiguration != "" {
|
||||||
|
_ = writer.WriteField("clusterConfiguration", req.ClusterConfiguration)
|
||||||
|
}
|
||||||
|
if req.KubeletConfiguration != "" {
|
||||||
|
_ = writer.WriteField("kubeletConfiguration", req.KubeletConfiguration)
|
||||||
|
}
|
||||||
|
if req.KubeProxyConfiguration != "" {
|
||||||
|
_ = writer.WriteField("kubeProxyConfiguration", req.KubeProxyConfiguration)
|
||||||
|
}
|
||||||
|
if req.JoinConfiguration != "" {
|
||||||
|
_ = writer.WriteField("joinConfiguration", req.JoinConfiguration)
|
||||||
|
}
|
||||||
|
if req.Description != "" {
|
||||||
|
_ = writer.WriteField("desc", req.Description)
|
||||||
|
}
|
||||||
|
if req.UserData != "" {
|
||||||
|
_ = writer.WriteField("userData", req.UserData)
|
||||||
|
}
|
||||||
|
|
||||||
|
_ = writer.WriteField("extnetOnly", strconv.FormatBool(req.ExtNetOnly))
|
||||||
|
|
||||||
|
ct := writer.FormDataContentType()
|
||||||
|
|
||||||
|
writer.Close()
|
||||||
|
return reqBody, ct
|
||||||
|
}
|
||||||
216
config/config_bvs.go
Normal file
216
config/config_bvs.go
Normal file
@@ -0,0 +1,216 @@
|
|||||||
|
package config
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"os"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"gopkg.in/yaml.v3"
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/serialization"
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
|
)
|
||||||
|
|
||||||
|
type BVSConfig struct {
|
||||||
|
// ServiceAccount username
|
||||||
|
// Required: true
|
||||||
|
// Example : "osh_mikoev"
|
||||||
|
Username string `json:"username" yaml:"username" validate:"required"`
|
||||||
|
|
||||||
|
// ServiceAccount password
|
||||||
|
// Required: true
|
||||||
|
// Example: "[1o>hYkjnJr)HI78q7t&#%8Lm"
|
||||||
|
Password string `json:"password" yaml:"password" validate:"required"`
|
||||||
|
|
||||||
|
// Domain name
|
||||||
|
// Required: true
|
||||||
|
// Example: "dynamix"
|
||||||
|
Domain string `json:"domain" yaml:"domain" validate:"required"`
|
||||||
|
|
||||||
|
// Application (client) identifier for authorization
|
||||||
|
// in the cloud platform controller in oauth2 mode.
|
||||||
|
// Required: true
|
||||||
|
// Example: "ewqfrvea7s890avw804389qwguf234h0otfi3w4eiu"
|
||||||
|
AppID string `json:"appId" yaml:"appId" validate:"required"`
|
||||||
|
|
||||||
|
// Application (client) secret code for authorization
|
||||||
|
// in the cloud platform controller in oauth2 mode.
|
||||||
|
// Example: "frvet09rvesfis0c9erv9fsov0vsdfi09ovds0f"
|
||||||
|
AppSecret string `json:"appSecret" yaml:"appSecret" validate:"required"`
|
||||||
|
|
||||||
|
// Platform authentication service address
|
||||||
|
// Required: true
|
||||||
|
// Example: "https://sso.digitalenergy.online"
|
||||||
|
SSOURL string `json:"ssoUrl" yaml:"ssoUrl" validate:"url"`
|
||||||
|
|
||||||
|
// The address of the platform on which the actions are planned
|
||||||
|
// Required: true
|
||||||
|
// Example: "https://mr4.digitalenergy.online"
|
||||||
|
DecortURL string `json:"decortUrl" yaml:"decortUrl" validate:"url"`
|
||||||
|
|
||||||
|
// JWT platform token
|
||||||
|
// Required: false
|
||||||
|
// Example: "qwqwdfwv68979we0q9bfv7e9sbvd89798qrwv97ff"
|
||||||
|
Token Token `json:"token" yaml:"token"`
|
||||||
|
|
||||||
|
// Amount platform request attempts
|
||||||
|
// Default value: 5
|
||||||
|
// Required: false
|
||||||
|
Retries uint64 `json:"retries" yaml:"retries"`
|
||||||
|
|
||||||
|
// Skip verify
|
||||||
|
// Required: false
|
||||||
|
SSLSkipVerify bool `json:"sslSkipVerify" yaml:"sslSkipVerify"`
|
||||||
|
|
||||||
|
// HTTP client timeout, unlimited if left empty
|
||||||
|
// Required: false
|
||||||
|
Timeout Duration `json:"timeout" yaml:"timeout"`
|
||||||
|
|
||||||
|
// The path of the configuration file entry
|
||||||
|
// Required: false
|
||||||
|
PathCfg string `json:"path_cfg" yaml:"path_cfg"`
|
||||||
|
|
||||||
|
// The path of the token file entry
|
||||||
|
// Required: false
|
||||||
|
PathToken string `json:"path_token" yaml:"path_token"`
|
||||||
|
|
||||||
|
// The number of minutes before the expiration of the token, a refresh will be made
|
||||||
|
// Required: false
|
||||||
|
TimeToRefresh int64 `json:"timeToRefresh" yaml:"timeToRefresh"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type Token struct {
|
||||||
|
// AccessToken is the token that authorizes and authenticates
|
||||||
|
// the requests.
|
||||||
|
// Required: false
|
||||||
|
AccessToken string `json:"access_token" yaml:"access_token"`
|
||||||
|
|
||||||
|
// TokenType is the type of token.
|
||||||
|
// The Type method returns either this or "Bearer", the default.
|
||||||
|
// Required: false
|
||||||
|
TokenType string `json:"token_type" yaml:"token_type"`
|
||||||
|
|
||||||
|
// RefreshToken is a token that's used by the application
|
||||||
|
// (as opposed to the user) to refresh the access token
|
||||||
|
// if it expires.
|
||||||
|
// Required: false
|
||||||
|
RefreshToken string `json:"refresh_token" yaml:"refresh_token"`
|
||||||
|
|
||||||
|
// Expiry is the optional expiration time of the access token.
|
||||||
|
// Required: false
|
||||||
|
Expiry time.Time `json:"expiry" yaml:"expiry"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetTimeout is used to set HTTP client timeout.
|
||||||
|
func (c *BVSConfig) SetTimeout(dur time.Duration) {
|
||||||
|
c.Timeout = Duration(dur)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ParseConfigJSON parses Config from specified JSON-formatted file.
|
||||||
|
func ParseConfigBVSJSON(path string) (BVSConfig, error) {
|
||||||
|
file, err := os.ReadFile(path)
|
||||||
|
if err != nil {
|
||||||
|
return BVSConfig{}, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var config BVSConfig
|
||||||
|
|
||||||
|
err = json.Unmarshal(file, &config)
|
||||||
|
if err != nil {
|
||||||
|
return BVSConfig{}, err
|
||||||
|
}
|
||||||
|
|
||||||
|
err = validators.ValidateConfig(config)
|
||||||
|
if err != nil {
|
||||||
|
return BVSConfig{}, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
|
}
|
||||||
|
|
||||||
|
return config, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ParseConfigJSON parses Token from specified JSON-formatted file.
|
||||||
|
func ParseTokenBVSJSON(path string) (Token, error) {
|
||||||
|
file, err := os.ReadFile(path)
|
||||||
|
if err != nil {
|
||||||
|
return Token{}, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var token Token
|
||||||
|
|
||||||
|
err = json.Unmarshal(file, &token)
|
||||||
|
if err != nil {
|
||||||
|
return Token{}, err
|
||||||
|
}
|
||||||
|
|
||||||
|
err = validators.ValidateConfig(token)
|
||||||
|
if err != nil {
|
||||||
|
return Token{}, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
|
}
|
||||||
|
|
||||||
|
return token, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ParseTokenBVSYAML parses Token from specified YAML-formatted file.
|
||||||
|
func ParseTokenBVSYAML(path string) (Token, error) {
|
||||||
|
file, err := os.ReadFile(path)
|
||||||
|
if err != nil {
|
||||||
|
return Token{}, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var token Token
|
||||||
|
|
||||||
|
err = yaml.Unmarshal(file, &token)
|
||||||
|
if err != nil {
|
||||||
|
return Token{}, err
|
||||||
|
}
|
||||||
|
|
||||||
|
err = validators.ValidateConfig(token)
|
||||||
|
if err != nil {
|
||||||
|
return Token{}, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
|
}
|
||||||
|
|
||||||
|
return token, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ParseConfigYAML parses Config from specified YAML-formatted file.
|
||||||
|
func ParseConfigBVSYAML(path string) (BVSConfig, error) {
|
||||||
|
file, err := os.ReadFile(path)
|
||||||
|
if err != nil {
|
||||||
|
return BVSConfig{}, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var config BVSConfig
|
||||||
|
|
||||||
|
err = yaml.Unmarshal(file, &config)
|
||||||
|
if err != nil {
|
||||||
|
return BVSConfig{}, err
|
||||||
|
}
|
||||||
|
|
||||||
|
err = validators.ValidateConfig(config)
|
||||||
|
if err != nil {
|
||||||
|
return BVSConfig{}, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
|
}
|
||||||
|
|
||||||
|
return config, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t Token) Serialize(params ...string) (serialization.Serialized, error) {
|
||||||
|
if len(params) > 1 {
|
||||||
|
prefix := params[0]
|
||||||
|
indent := params[1]
|
||||||
|
|
||||||
|
return json.MarshalIndent(t, prefix, indent)
|
||||||
|
}
|
||||||
|
|
||||||
|
return json.Marshal(t)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c BVSConfig) Serialize(params ...string) (serialization.Serialized, error) {
|
||||||
|
if len(params) > 1 {
|
||||||
|
prefix := params[0]
|
||||||
|
indent := params[1]
|
||||||
|
|
||||||
|
return json.MarshalIndent(c, prefix, indent)
|
||||||
|
}
|
||||||
|
|
||||||
|
return json.Marshal(c)
|
||||||
|
}
|
||||||
@@ -22,6 +22,8 @@ func (d *Duration) UnmarshalYAML(unmarshal func(interface{}) error) error {
|
|||||||
}
|
}
|
||||||
*d = Duration(tmp)
|
*d = Duration(tmp)
|
||||||
return nil
|
return nil
|
||||||
|
case float64:
|
||||||
|
return nil
|
||||||
default:
|
default:
|
||||||
return fmt.Errorf("invalid duration %v", value)
|
return fmt.Errorf("invalid duration %v", value)
|
||||||
}
|
}
|
||||||
@@ -40,6 +42,8 @@ func (d *Duration) UnmarshalJSON(b []byte) error {
|
|||||||
}
|
}
|
||||||
*d = Duration(tmp)
|
*d = Duration(tmp)
|
||||||
return nil
|
return nil
|
||||||
|
case float64:
|
||||||
|
return nil
|
||||||
default:
|
default:
|
||||||
return fmt.Errorf("invalid duration %v", value)
|
return fmt.Errorf("invalid duration %v", value)
|
||||||
}
|
}
|
||||||
|
|||||||
7
go.mod
7
go.mod
@@ -11,9 +11,10 @@ require (
|
|||||||
require (
|
require (
|
||||||
github.com/go-playground/locales v0.14.1 // indirect
|
github.com/go-playground/locales v0.14.1 // indirect
|
||||||
github.com/go-playground/universal-translator v0.18.1 // indirect
|
github.com/go-playground/universal-translator v0.18.1 // indirect
|
||||||
|
github.com/google/go-cmp v0.5.9 // indirect
|
||||||
github.com/kr/text v0.2.0 // indirect
|
github.com/kr/text v0.2.0 // indirect
|
||||||
github.com/leodido/go-urn v1.2.1 // indirect
|
github.com/leodido/go-urn v1.2.1 // indirect
|
||||||
golang.org/x/crypto v0.5.0 // indirect
|
golang.org/x/crypto v0.15.0 // indirect
|
||||||
golang.org/x/sys v0.4.0 // indirect
|
golang.org/x/sys v0.14.0 // indirect
|
||||||
golang.org/x/text v0.6.0 // indirect
|
golang.org/x/text v0.14.0 // indirect
|
||||||
)
|
)
|
||||||
|
|||||||
15
go.sum
15
go.sum
@@ -8,8 +8,9 @@ github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJn
|
|||||||
github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=
|
github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=
|
||||||
github.com/go-playground/validator/v10 v10.11.2 h1:q3SHpufmypg+erIExEKUmsgmhDTyhcJ38oeKGACXohU=
|
github.com/go-playground/validator/v10 v10.11.2 h1:q3SHpufmypg+erIExEKUmsgmhDTyhcJ38oeKGACXohU=
|
||||||
github.com/go-playground/validator/v10 v10.11.2/go.mod h1:NieE624vt4SCTJtD87arVLvdmjPAeV8BQlHtMnw9D7s=
|
github.com/go-playground/validator/v10 v10.11.2/go.mod h1:NieE624vt4SCTJtD87arVLvdmjPAeV8BQlHtMnw9D7s=
|
||||||
github.com/google/go-cmp v0.5.2 h1:X2ev0eStA3AbceY54o37/0PQ/UWqKEiiO2dKL5OPaFM=
|
|
||||||
github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||||
|
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
|
||||||
|
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||||
github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8=
|
github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8=
|
||||||
github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU=
|
github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU=
|
||||||
github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0=
|
github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0=
|
||||||
@@ -23,12 +24,12 @@ github.com/rogpeppe/go-internal v1.8.0 h1:FCbCCtXNOY3UtUuHUYaghJg4y7Fd14rXifAYUA
|
|||||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||||
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||||
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
|
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
|
||||||
golang.org/x/crypto v0.5.0 h1:U/0M97KRkSFvyD/3FSmdP5W5swImpNgle/EHFhOsQPE=
|
golang.org/x/crypto v0.15.0 h1:frVn1TEaCEaZcn3Tmd7Y2b5KKPaZ+I32Q2OA3kYp5TA=
|
||||||
golang.org/x/crypto v0.5.0/go.mod h1:NK/OQwhpMQP3MwtdjgLlYHnH9ebylxKWv3e0fK+mkQU=
|
golang.org/x/crypto v0.15.0/go.mod h1:4ChreQoLWfG3xLDer1WdlH5NdlQ3+mwnQq1YTKY+72g=
|
||||||
golang.org/x/sys v0.4.0 h1:Zr2JFtRQNX3BCZ8YtxRE9hNJYC8J6I1MVbMg6owUp18=
|
golang.org/x/sys v0.14.0 h1:Vz7Qs629MkJkGyHxUlRHizWJRG2j8fbQKjELVSNhy7Q=
|
||||||
golang.org/x/sys v0.4.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||||
golang.org/x/text v0.6.0 h1:3XmdazWV+ubf7QgHSTWeykHOci5oeekaGJBLkrkaw4k=
|
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
|
||||||
golang.org/x/text v0.6.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
|
||||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
|
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
|
||||||
|
|||||||
5
internal/constants/constants.go
Normal file
5
internal/constants/constants.go
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
package constants
|
||||||
|
|
||||||
|
const Restmachine = "/restmachine"
|
||||||
|
|
||||||
|
|
||||||
@@ -17,6 +17,7 @@ import (
|
|||||||
|
|
||||||
"github.com/google/go-querystring/query"
|
"github.com/google/go-querystring/query"
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/config"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/config"
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants"
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi"
|
||||||
k8s_ca "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/k8s"
|
k8s_ca "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/k8s"
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker"
|
||||||
@@ -78,7 +79,7 @@ func (ldc *LegacyDecortClient) DecortApiCall(ctx context.Context, method, url st
|
|||||||
|
|
||||||
k8sCaCreateReq, okCa := params.(k8s_ca.CreateRequest)
|
k8sCaCreateReq, okCa := params.(k8s_ca.CreateRequest)
|
||||||
k8sCbCreateReq, okCb := params.(k8s_cb.CreateRequest)
|
k8sCbCreateReq, okCb := params.(k8s_cb.CreateRequest)
|
||||||
|
|
||||||
var body *bytes.Buffer
|
var body *bytes.Buffer
|
||||||
var ctype string
|
var ctype string
|
||||||
|
|
||||||
@@ -93,8 +94,8 @@ func (ldc *LegacyDecortClient) DecortApiCall(ctx context.Context, method, url st
|
|||||||
}
|
}
|
||||||
body = bytes.NewBufferString(values.Encode() + fmt.Sprintf("&authkey=%s", ldc.cfg.Token))
|
body = bytes.NewBufferString(values.Encode() + fmt.Sprintf("&authkey=%s", ldc.cfg.Token))
|
||||||
}
|
}
|
||||||
|
|
||||||
req, err := http.NewRequestWithContext(ctx, method, ldc.decortURL+"/restmachine"+url, body)
|
req, err := http.NewRequestWithContext(ctx, method, ldc.decortURL+constants.Restmachine+url, body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -159,24 +160,25 @@ func (ldc *LegacyDecortClient) do(req *http.Request, ctype string) (*http.Respon
|
|||||||
// var resp *http.Response
|
// var resp *http.Response
|
||||||
// var err error
|
// var err error
|
||||||
buf, _ := io.ReadAll(req.Body)
|
buf, _ := io.ReadAll(req.Body)
|
||||||
// req = req.Clone(req.Context())
|
|
||||||
|
|
||||||
// for i := uint64(0); i < ldc.cfg.Retries; i++ {
|
// for i := uint64(0); i < ldc.cfg.Retries; i++ {
|
||||||
|
// req = req.Clone(req.Context())
|
||||||
req.Body = io.NopCloser(bytes.NewBuffer(buf))
|
req.Body = io.NopCloser(bytes.NewBuffer(buf))
|
||||||
resp, err := ldc.client.Do(req)
|
resp, err := ldc.client.Do(req)
|
||||||
|
if err != nil || resp == nil {
|
||||||
|
return resp, err
|
||||||
|
}
|
||||||
|
|
||||||
// if err == nil {
|
|
||||||
if resp.StatusCode == 200 {
|
if resp.StatusCode == 200 {
|
||||||
return resp, err
|
return resp, err
|
||||||
}
|
}
|
||||||
respBytes, _ := io.ReadAll(resp.Body)
|
|
||||||
err = fmt.Errorf("%s", respBytes)
|
|
||||||
resp.Body.Close()
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
return nil, fmt.Errorf("could not execute request: %w", err)
|
respBytes, err := io.ReadAll(resp.Body)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
resp.Body.Close()
|
||||||
|
return resp, errors.New(string(respBytes))
|
||||||
}
|
}
|
||||||
|
|
||||||
func createK8sCloudApiLegacy(req k8s_ca.CreateRequest, token string) (*bytes.Buffer, string) {
|
func createK8sCloudApiLegacy(req k8s_ca.CreateRequest, token string) (*bytes.Buffer, string) {
|
||||||
@@ -402,7 +404,7 @@ func createK8sCloudBrokerLegacy(req k8s_cb.CreateRequest, token string) (*bytes.
|
|||||||
}
|
}
|
||||||
|
|
||||||
_ = writer.WriteField("extnetOnly", strconv.FormatBool(req.ExtNetOnly))
|
_ = writer.WriteField("extnetOnly", strconv.FormatBool(req.ExtNetOnly))
|
||||||
|
|
||||||
_ = writer.WriteField("authkey", token)
|
_ = writer.WriteField("authkey", token)
|
||||||
|
|
||||||
ct := writer.FormDataContentType()
|
ct := writer.FormDataContentType()
|
||||||
|
|||||||
73
pkg/cloudapi/account/ids.go
Normal file
73
pkg/cloudapi/account/ids.go
Normal file
@@ -0,0 +1,73 @@
|
|||||||
|
package account
|
||||||
|
|
||||||
|
// IDs gets array of AccountIDs from ListAccounts struct
|
||||||
|
func (la ListAccounts) IDs() []uint64 {
|
||||||
|
res := make([]uint64, 0, len(la.Data))
|
||||||
|
for _, acc := range la.Data {
|
||||||
|
res = append(res, acc.ID)
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDs gets array of ComputeIDs from ListComputes struct
|
||||||
|
func (lc ListComputes) IDs() []uint64 {
|
||||||
|
res := make([]uint64, 0, len(lc.Data))
|
||||||
|
for _, c := range lc.Data {
|
||||||
|
res = append(res, c.ComputeID)
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDs gets array of DiskIDs from ListDisks struct
|
||||||
|
func (ld ListDisks) IDs() []uint64 {
|
||||||
|
res := make([]uint64, 0, len(ld.Data))
|
||||||
|
for _, d := range ld.Data {
|
||||||
|
res = append(res, d.ID)
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDs gets array of FLIPGroupIDs from ListFLIPGroups struct
|
||||||
|
func (fg ListFLIPGroups) IDs() []uint64 {
|
||||||
|
res := make([]uint64, 0, len(fg.Data))
|
||||||
|
for _, g := range fg.Data {
|
||||||
|
res = append(res, g.ID)
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDs gets array of AccountIDs from ListResourceConsumption struct
|
||||||
|
func (rc ListResourceConsumption) IDs() []uint64 {
|
||||||
|
res := make([]uint64, 0, len(rc.Data))
|
||||||
|
for _, r := range rc.Data {
|
||||||
|
res = append(res, r.AccountID)
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDs gets array of RGIDs from ListRG struct
|
||||||
|
func (rg ListRG) IDs() []uint64 {
|
||||||
|
res := make([]uint64, 0, len(rg.Data))
|
||||||
|
for _, g := range rg.Data {
|
||||||
|
res = append(res, g.RGID)
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDs gets array of TemplateIDs from ListTemplates struct
|
||||||
|
func (lt ListTemplates) IDs() []uint64 {
|
||||||
|
res := make([]uint64, 0, len(lt.Data))
|
||||||
|
for _, t := range lt.Data {
|
||||||
|
res = append(res, t.ID)
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDs gets array of VINSIDs from ListVINS struct
|
||||||
|
func (lv ListVINS) IDs() []uint64 {
|
||||||
|
res := make([]uint64, 0, len(lv.Data))
|
||||||
|
for _, v := range lv.Data {
|
||||||
|
res = append(res, v.ID)
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
||||||
37
pkg/cloudapi/bservice/ids.go
Normal file
37
pkg/cloudapi/bservice/ids.go
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
package bservice
|
||||||
|
|
||||||
|
// IDs gets array of BasicServiceIDs from ListBasicServices struct
|
||||||
|
func (lbs ListBasicServices) IDs() []uint64 {
|
||||||
|
res := make([]uint64, 0, len(lbs.Data))
|
||||||
|
for _, bs := range lbs.Data {
|
||||||
|
res = append(res, bs.ID)
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDs gets array of ComputeIDs from ListComputes struct
|
||||||
|
func (lc ListComputes) IDs() []uint64 {
|
||||||
|
res := make([]uint64, 0, len(lc))
|
||||||
|
for _, c := range lc {
|
||||||
|
res = append(res, c.ID)
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDs gets array of GroupIDs from ListGroups struct
|
||||||
|
func (lg ListGroups) IDs() []uint64 {
|
||||||
|
res := make([]uint64, 0, len(lg))
|
||||||
|
for _, g := range lg {
|
||||||
|
res = append(res, g.ID)
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDs gets array of GroupComputeIDs from ListGroupComputes struct
|
||||||
|
func (lgc ListGroupComputes) IDs() []uint64 {
|
||||||
|
res := make([]uint64, 0, len(lgc))
|
||||||
|
for _, gc := range lgc {
|
||||||
|
res = append(res, gc.ID)
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
||||||
@@ -168,9 +168,18 @@ type ItemSnapshot struct {
|
|||||||
Valid bool `json:"valid"`
|
Valid bool `json:"valid"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// List of Snapshots
|
// List of Snapshot
|
||||||
type ListSnapshots []ItemSnapshot
|
type ListSnapshots []ItemSnapshot
|
||||||
|
|
||||||
|
// List of Snapshots
|
||||||
|
type ListInfoSnapshots struct {
|
||||||
|
// Data
|
||||||
|
Data ListSnapshots `json:"data"`
|
||||||
|
|
||||||
|
// EntryCount
|
||||||
|
EntryCount uint64 `json:"entryCount"`
|
||||||
|
}
|
||||||
|
|
||||||
// Main information about Group
|
// Main information about Group
|
||||||
type RecordGroup struct {
|
type RecordGroup struct {
|
||||||
// Account ID
|
// Account ID
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ type SnapshotListRequest struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// SnapshotList gets list existing snapshots of the Basic Service
|
// SnapshotList gets list existing snapshots of the Basic Service
|
||||||
func (b BService) SnapshotList(ctx context.Context, req SnapshotListRequest) (ListSnapshots, error) {
|
func (b BService) SnapshotList(ctx context.Context, req SnapshotListRequest) (*ListInfoSnapshots, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
@@ -29,12 +29,12 @@ func (b BService) SnapshotList(ctx context.Context, req SnapshotListRequest) (Li
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
list := ListSnapshots{}
|
list := ListInfoSnapshots{}
|
||||||
|
|
||||||
err = json.Unmarshal(res, &list)
|
err = json.Unmarshal(res, &list)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return list, nil
|
return &list, nil
|
||||||
}
|
}
|
||||||
|
|||||||
37
pkg/cloudapi/compute/ids.go
Normal file
37
pkg/cloudapi/compute/ids.go
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
package compute
|
||||||
|
|
||||||
|
// IDs gets array of ComputeIDs from ListComputes struct
|
||||||
|
func (lc ListComputes) IDs() []uint64 {
|
||||||
|
res := make([]uint64, 0, len(lc.Data))
|
||||||
|
for _, c := range lc.Data {
|
||||||
|
res = append(res, c.ID)
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDs gets array of DiskIDs from ListInfoDisks struct
|
||||||
|
func (li ListInfoDisks) IDs() []uint64 {
|
||||||
|
res := make([]uint64, 0, len(li))
|
||||||
|
for _, i := range li {
|
||||||
|
res = append(res, i.ID)
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDs gets array of PFWsIDs from ListPFWs struct
|
||||||
|
func (lp ListPFWs) IDs() []uint64 {
|
||||||
|
res := make([]uint64, 0, len(lp.Data))
|
||||||
|
for _, p := range lp.Data {
|
||||||
|
res = append(res, p.ID)
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDs gets array of DiskIDs from ListComputeDisks struct
|
||||||
|
func (lcd ListComputeDisks) IDs() []uint64 {
|
||||||
|
res := make([]uint64, 0, len(lcd))
|
||||||
|
for _, cd := range lcd {
|
||||||
|
res = append(res, cd.ID)
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
||||||
@@ -819,7 +819,7 @@ type ItemCompute struct {
|
|||||||
Devices interface{} `json:"devices"`
|
Devices interface{} `json:"devices"`
|
||||||
|
|
||||||
// List disk items
|
// List disk items
|
||||||
Disks []InfoDisk `json:"disks"`
|
Disks ListInfoDisks `json:"disks"`
|
||||||
|
|
||||||
// Driver
|
// Driver
|
||||||
Driver string `json:"driver"`
|
Driver string `json:"driver"`
|
||||||
@@ -918,6 +918,9 @@ type ItemCompute struct {
|
|||||||
VirtualImageID uint64 `json:"virtualImageId"`
|
VirtualImageID uint64 `json:"virtualImageId"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ListInfoDisks
|
||||||
|
type ListInfoDisks []InfoDisk
|
||||||
|
|
||||||
// Information Disk
|
// Information Disk
|
||||||
type InfoDisk struct {
|
type InfoDisk struct {
|
||||||
// ID
|
// ID
|
||||||
|
|||||||
28
pkg/cloudapi/disks/ids.go
Normal file
28
pkg/cloudapi/disks/ids.go
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
package disks
|
||||||
|
|
||||||
|
// IDs gets array of DiskIDs from ListDisks struct
|
||||||
|
func (ld ListDisks) IDs() []uint64 {
|
||||||
|
res := make([]uint64, 0, len(ld.Data))
|
||||||
|
for _, d := range ld.Data {
|
||||||
|
res = append(res, d.ID)
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDs gets array of DiskIDs from ListDisksUnattached struct
|
||||||
|
func (ldu ListDisksUnattached) IDs() []uint64 {
|
||||||
|
res := make([]uint64, 0, len(ldu.Data))
|
||||||
|
for _, d := range ldu.Data {
|
||||||
|
res = append(res, d.ID)
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDs gets array of DiskIDs from ListSearchDisks struct
|
||||||
|
func (lsd ListSearchDisks) IDs() []uint64 {
|
||||||
|
res := make([]uint64, 0, len(lsd))
|
||||||
|
for _, d := range lsd {
|
||||||
|
res = append(res, d.ID)
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
||||||
19
pkg/cloudapi/extnet/ids.go
Normal file
19
pkg/cloudapi/extnet/ids.go
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
package extnet
|
||||||
|
|
||||||
|
// IDs gets array of ExtNetIDs from ListExtNets struct
|
||||||
|
func (le ListExtNets) IDs() []uint64 {
|
||||||
|
res := make([]uint64, 0, len(le.Data))
|
||||||
|
for _, e := range le.Data {
|
||||||
|
res = append(res, e.ID)
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDs gets array of ComputeIDs from ListExtNetComputes struct
|
||||||
|
func (le ListExtNetComputes) IDs() []uint64 {
|
||||||
|
res := make([]uint64, 0, len(le.Data))
|
||||||
|
for _, e := range le.Data {
|
||||||
|
res = append(res, e.ID)
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
||||||
10
pkg/cloudapi/flipgroup/ids.go
Normal file
10
pkg/cloudapi/flipgroup/ids.go
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
package flipgroup
|
||||||
|
|
||||||
|
// IDs gets array of FLIPGroupIDs from ListFLIPGroups struct
|
||||||
|
func (le ListFLIPGroups) IDs() []uint64 {
|
||||||
|
res := make([]uint64, 0, len(le.Data))
|
||||||
|
for _, e := range le.Data {
|
||||||
|
res = append(res, e.ID)
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
||||||
19
pkg/cloudapi/image/ids.go
Normal file
19
pkg/cloudapi/image/ids.go
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
package image
|
||||||
|
|
||||||
|
// IDs gets array of ImageIDs from ListImages struct
|
||||||
|
func (li ListImages) IDs() []uint64 {
|
||||||
|
res := make([]uint64, 0, len(li.Data))
|
||||||
|
for _, i := range li.Data {
|
||||||
|
res = append(res, i.ID)
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDs gets array of HistoryIDs from ListHistories struct
|
||||||
|
func (lh ListHistories) IDs() []uint64 {
|
||||||
|
res := make([]uint64, 0, len(lh))
|
||||||
|
for _, h := range lh {
|
||||||
|
res = append(res, h.ID)
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
||||||
@@ -66,7 +66,10 @@ type ListImages struct {
|
|||||||
EntryCount uint64 `json:"entryCount"`
|
EntryCount uint64 `json:"entryCount"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// History
|
// ListHistories of record image
|
||||||
|
type ListHistories []History
|
||||||
|
|
||||||
|
// History of record image
|
||||||
type History struct {
|
type History struct {
|
||||||
// GUID
|
// GUID
|
||||||
GUID string `json:"guid"`
|
GUID string `json:"guid"`
|
||||||
@@ -123,7 +126,7 @@ type RecordImage struct {
|
|||||||
GUID uint64 `json:"guid"`
|
GUID uint64 `json:"guid"`
|
||||||
|
|
||||||
// History
|
// History
|
||||||
History []History `json:"history"`
|
History ListHistories `json:"history"`
|
||||||
|
|
||||||
// HotResize
|
// HotResize
|
||||||
HotResize bool `json:"hotResize"`
|
HotResize bool `json:"hotResize"`
|
||||||
|
|||||||
10
pkg/cloudapi/k8ci/ids.go
Normal file
10
pkg/cloudapi/k8ci/ids.go
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
package k8ci
|
||||||
|
|
||||||
|
// IDs gets array of K8CIIDs from ListK8CI struct
|
||||||
|
func (lk ListK8CI) IDs() []uint64 {
|
||||||
|
res := make([]uint64, 0, len(lk.Data))
|
||||||
|
for _, k := range lk.Data {
|
||||||
|
res = append(res, k.ID)
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
||||||
@@ -17,7 +17,7 @@ type DeleteRequest struct {
|
|||||||
// True if cluster is destroyed permanently.
|
// True if cluster is destroyed permanently.
|
||||||
// Otherwise it can be restored from Recycle Bin
|
// Otherwise it can be restored from Recycle Bin
|
||||||
// Required: true
|
// Required: true
|
||||||
Permanently bool `url:"permanently" json:"permanently" validate:"required"`
|
Permanently bool `url:"permanently" json:"permanently"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete deletes kubernetes cluster
|
// Delete deletes kubernetes cluster
|
||||||
|
|||||||
28
pkg/cloudapi/k8s/ids.go
Normal file
28
pkg/cloudapi/k8s/ids.go
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
package k8s
|
||||||
|
|
||||||
|
// IDs gets array of K8SIDs from ListK8SClusters struct
|
||||||
|
func (lk ListK8SClusters) IDs() []uint64 {
|
||||||
|
res := make([]uint64, 0, len(lk.Data))
|
||||||
|
for _, k := range lk.Data {
|
||||||
|
res = append(res, k.ID)
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDs gets array of K8SWorkerGroupIDs from ListK8SGroups struct
|
||||||
|
func (lwg ListK8SGroups) IDs() []uint64 {
|
||||||
|
res := make([]uint64, 0, len(lwg))
|
||||||
|
for _, wg := range lwg {
|
||||||
|
res = append(res, wg.ID)
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDs gets array of Worker or Master ComputesIDs from ListDetailedInfo struct
|
||||||
|
func (ldi ListDetailedInfo) IDs() []uint64 {
|
||||||
|
res := make([]uint64, 0, len(ldi))
|
||||||
|
for _, di := range ldi {
|
||||||
|
res = append(res, di.ID)
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
||||||
10
pkg/cloudapi/lb/ids.go
Normal file
10
pkg/cloudapi/lb/ids.go
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
package lb
|
||||||
|
|
||||||
|
// IDs gets array of LBIDs from ListLB struct
|
||||||
|
func (llb ListLB) IDs() []uint64 {
|
||||||
|
res := make([]uint64, 0, len(llb.Data))
|
||||||
|
for _, lb := range llb.Data {
|
||||||
|
res = append(res, lb.ID)
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
||||||
10
pkg/cloudapi/locations/ids.go
Normal file
10
pkg/cloudapi/locations/ids.go
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
package locations
|
||||||
|
|
||||||
|
// IDs gets array of LocationIDs from ListLocations struct
|
||||||
|
func (ll ListLocations) IDs() []uint64 {
|
||||||
|
res := make([]uint64, 0, len(ll.Data))
|
||||||
|
for _, l := range ll.Data {
|
||||||
|
res = append(res, l.GID)
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
||||||
64
pkg/cloudapi/rg/ids.go
Normal file
64
pkg/cloudapi/rg/ids.go
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
package rg
|
||||||
|
|
||||||
|
// IDs gets array of ResourceGroupIDs from ListResourceGroups struct
|
||||||
|
func (lrg ListResourceGroups) IDs() []uint64 {
|
||||||
|
res := make([]uint64, 0, len(lrg.Data))
|
||||||
|
for _, rg := range lrg.Data {
|
||||||
|
res = append(res, rg.ID)
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDs gets array of ComputeIDs from ListAffinityGroupsComputes struct
|
||||||
|
func (lag ListAffinityGroupsComputes) IDs() []uint64 {
|
||||||
|
res := make([]uint64, 0, len(lag))
|
||||||
|
for _, ag := range lag {
|
||||||
|
res = append(res, ag.ComputeID)
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDs gets array of ComputeIDs from ListComputes struct
|
||||||
|
func (lc ListComputes) IDs() []uint64 {
|
||||||
|
res := make([]uint64, 0, len(lc.Data))
|
||||||
|
for _, c := range lc.Data {
|
||||||
|
res = append(res, c.ID)
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDs gets array of LBIDs from ListLB struct
|
||||||
|
func (llb ListLB) IDs() []uint64 {
|
||||||
|
res := make([]uint64, 0, len(llb.Data))
|
||||||
|
for _, lb := range llb.Data {
|
||||||
|
res = append(res, lb.ID)
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDs gets array of VINSIDs from ListVINS struct
|
||||||
|
func (llb ListVINS) IDs() []uint64 {
|
||||||
|
res := make([]uint64, 0, len(llb.Data))
|
||||||
|
for _, lb := range llb.Data {
|
||||||
|
res = append(res, lb.ID)
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDs gets array of ResourceGroupIDs from ListResourceConsumption struct
|
||||||
|
func (lrc ListResourceConsumption) IDs() []uint64 {
|
||||||
|
res := make([]uint64, 0, len(lrc.Data))
|
||||||
|
for _, rc := range lrc.Data {
|
||||||
|
res = append(res, rc.RGID)
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDs gets array of ResourceGroupIDs from ListAffinityGroup struct
|
||||||
|
func (lag ListAffinityGroup) IDs() []uint64 {
|
||||||
|
res := make([]uint64, 0, len(lag))
|
||||||
|
for _, ag := range lag {
|
||||||
|
res = append(res, ag.ID)
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
||||||
@@ -331,9 +331,19 @@ type ItemAffinityGroupComputes struct {
|
|||||||
// List of affinity groups
|
// List of affinity groups
|
||||||
type ListAffinityGroupsComputes []ItemAffinityGroupComputes
|
type ListAffinityGroupsComputes []ItemAffinityGroupComputes
|
||||||
|
|
||||||
|
// Main information about
|
||||||
|
type ItemAffinityGroup struct {
|
||||||
|
ID uint64 `json:"id"`
|
||||||
|
NodeID uint64 `json:"node_id"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// List of affinity group
|
||||||
|
type ListAffinityGroup []ItemAffinityGroup
|
||||||
|
|
||||||
|
// List of affinity groups
|
||||||
type ListAffinityGroups struct {
|
type ListAffinityGroups struct {
|
||||||
// Data
|
// Data
|
||||||
Data []map[string][]uint64 `json:"data"`
|
Data []map[string]ListAffinityGroup `json:"data"`
|
||||||
|
|
||||||
// Entry count
|
// Entry count
|
||||||
EntryCount uint64 `json:"entryCount"`
|
EntryCount uint64 `json:"entryCount"`
|
||||||
|
|||||||
10
pkg/cloudapi/sizes/ids.go
Normal file
10
pkg/cloudapi/sizes/ids.go
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
package sizes
|
||||||
|
|
||||||
|
// IDs gets array of configured available flavours IDs from ListSizes struct
|
||||||
|
func (ls ListSizes) IDs() []uint64 {
|
||||||
|
res := make([]uint64, 0, len(ls.Data))
|
||||||
|
for _, s := range ls.Data {
|
||||||
|
res = append(res, s.ID)
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
||||||
10
pkg/cloudapi/stack/ids.go
Normal file
10
pkg/cloudapi/stack/ids.go
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
package stack
|
||||||
|
|
||||||
|
// IDs gets array of StackIDs from ListStacks struct
|
||||||
|
func (ls ListStacks) IDs() []uint64 {
|
||||||
|
res := make([]uint64, 0, len(ls.Data))
|
||||||
|
for _, s := range ls.Data {
|
||||||
|
res = append(res, s.ID)
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
||||||
64
pkg/cloudapi/vins/ids.go
Normal file
64
pkg/cloudapi/vins/ids.go
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
package vins
|
||||||
|
|
||||||
|
// IDs gets array of VINSIDs from ListVINS struct
|
||||||
|
func (lv ListVINS) IDs() []uint64 {
|
||||||
|
res := make([]uint64, 0, len(lv.Data))
|
||||||
|
for _, v := range lv.Data {
|
||||||
|
res = append(res, v.ID)
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDs gets array of ExtNetIDs from ListExtNets struct
|
||||||
|
func (le ListExtNets) IDs() []uint64 {
|
||||||
|
res := make([]uint64, 0, len(le.Data))
|
||||||
|
for _, e := range le.Data {
|
||||||
|
res = append(res, e.ExtNetID)
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDs gets array of ComputeIDs from ListVINSComputes struct
|
||||||
|
func (lvc ListVINSComputes) IDs() []uint64 {
|
||||||
|
res := make([]uint64, 0, len(lvc))
|
||||||
|
for _, vc := range lvc {
|
||||||
|
res = append(res, vc.ID)
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDs gets array of NATRuleConfigIDs from ListNATRulesConfig struct
|
||||||
|
func (lnrc ListNATRulesConfig) IDs() []uint64 {
|
||||||
|
res := make([]uint64, 0, len(lnrc))
|
||||||
|
for _, nrc := range lnrc {
|
||||||
|
res = append(res, nrc.ID)
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDs gets array of NATRuleIDs from ListNATRules struct
|
||||||
|
func (lnr ListNATRules) IDs() []uint64 {
|
||||||
|
res := make([]uint64, 0, len(lnr.Data))
|
||||||
|
for _, nr := range lnr.Data {
|
||||||
|
res = append(res, nr.ID)
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDs gets array of StaticRouteIDs from ListStaticRoutes struct
|
||||||
|
func (lsr ListStaticRoutes) IDs() []uint64 {
|
||||||
|
res := make([]uint64, 0, len(lsr.Data))
|
||||||
|
for _, sr := range lsr.Data {
|
||||||
|
res = append(res, sr.ID)
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDs gets array of RouteIDs from ListRoutes struct
|
||||||
|
func (lr ListRoutes) IDs() []uint64 {
|
||||||
|
res := make([]uint64, 0, len(lr))
|
||||||
|
for _, r := range lr {
|
||||||
|
res = append(res, r.ID)
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
||||||
64
pkg/cloudbroker/account/ids.go
Normal file
64
pkg/cloudbroker/account/ids.go
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
package account
|
||||||
|
|
||||||
|
// IDs gets array of AccountIDs from ListAccounts struct
|
||||||
|
func (la ListAccounts) IDs() []uint64 {
|
||||||
|
res := make([]uint64, 0, len(la.Data))
|
||||||
|
for _, acc := range la.Data {
|
||||||
|
res = append(res, acc.ID)
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDs gets array of ComputeIDs from ListComputes struct
|
||||||
|
func (lc ListComputes) IDs() []uint64 {
|
||||||
|
res := make([]uint64, 0, len(lc.Data))
|
||||||
|
for _, c := range lc.Data {
|
||||||
|
res = append(res, c.ID)
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDs gets array of DiskIDs from ListDisks struct
|
||||||
|
func (ld ListDisks) IDs() []uint64 {
|
||||||
|
res := make([]uint64, 0, len(ld.Data))
|
||||||
|
for _, d := range ld.Data {
|
||||||
|
res = append(res, d.ID)
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDs gets array of FLIPGroupIDs from ListFLIPGroups struct
|
||||||
|
func (fg ListFLIPGroups) IDs() []uint64 {
|
||||||
|
res := make([]uint64, 0, len(fg.Data))
|
||||||
|
for _, g := range fg.Data {
|
||||||
|
res = append(res, g.ID)
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDs gets array of AccountIDs from ListResourceConsumption struct
|
||||||
|
func (rc ListResources) IDs() []uint64 {
|
||||||
|
res := make([]uint64, 0, len(rc.Data))
|
||||||
|
for _, r := range rc.Data {
|
||||||
|
res = append(res, r.AccountID)
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDs gets array of RGIDs from ListRG struct
|
||||||
|
func (rg ListRG) IDs() []uint64 {
|
||||||
|
res := make([]uint64, 0, len(rg.Data))
|
||||||
|
for _, g := range rg.Data {
|
||||||
|
res = append(res, g.ID)
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDs gets array of VINSIDs from ListVINS struct
|
||||||
|
func (lv ListVINS) IDs() []uint64 {
|
||||||
|
res := make([]uint64, 0, len(lv.Data))
|
||||||
|
for _, v := range lv.Data {
|
||||||
|
res = append(res, v.ID)
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
||||||
10
pkg/cloudbroker/apiaccess/ids.go
Normal file
10
pkg/cloudbroker/apiaccess/ids.go
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
package apiaccess
|
||||||
|
|
||||||
|
// IDs gets array of APIAccessId from ListAPIAccess struct
|
||||||
|
func (laa ListAPIAccess) IDs() []uint64 {
|
||||||
|
res := make([]uint64, 0, len(laa.Data))
|
||||||
|
for _, apiaccess := range laa.Data {
|
||||||
|
res = append(res, apiaccess.ID)
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
||||||
@@ -103,56 +103,56 @@ type CloudAPIEndpoints struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type CloudBrokerEndpoints struct {
|
type CloudBrokerEndpoints struct {
|
||||||
Account []string `json:"account,omitempty"`
|
Account []string `json:"account,omitempty"`
|
||||||
APIAccess []string `json:"apiaccess,omitempty"`
|
APIAccess []string `json:"apiaccess,omitempty"`
|
||||||
Audit []string `json:"audit,omitempty"`
|
Audit interface{} `json:"audit,omitempty"`
|
||||||
AuditBeat []string `json:"auditbeat,omitempty"`
|
AuditBeat []string `json:"auditbeat,omitempty"`
|
||||||
AuditCollector []string `json:"auditcollector,omitempty"`
|
AuditCollector []string `json:"auditcollector,omitempty"`
|
||||||
BackupCreator []string `json:"backupcreator,omitempty"`
|
BackupCreator []string `json:"backupcreator,omitempty"`
|
||||||
BService []string `json:"bservice,omitempty"`
|
BService []string `json:"bservice,omitempty"`
|
||||||
CloudSpace []string `json:"cloudspace,omitempty"`
|
CloudSpace []string `json:"cloudspace,omitempty"`
|
||||||
Compute []string `json:"compute,omitempty"`
|
Compute []string `json:"compute,omitempty"`
|
||||||
ComputeCI []string `json:"computeci,omitempty"`
|
ComputeCI []string `json:"computeci,omitempty"`
|
||||||
Desnode []string `json:"desnode,omitempty"`
|
Desnode []string `json:"desnode,omitempty"`
|
||||||
Diagnostics []string `json:"diagnostics,omitempty"`
|
Diagnostics []string `json:"diagnostics,omitempty"`
|
||||||
Disks []string `json:"disks,omitempty"`
|
Disks []string `json:"disks,omitempty"`
|
||||||
Eco []string `json:"eco,omitempty"`
|
Eco []string `json:"eco,omitempty"`
|
||||||
ExtNet []string `json:"extnet,omitempty"`
|
ExtNet []string `json:"extnet,omitempty"`
|
||||||
FlIPgroup []string `json:"flipgroup,omitempty"`
|
FlIPgroup []string `json:"flipgroup,omitempty"`
|
||||||
Grid []string `json:"grid,omitempty"`
|
Grid []string `json:"grid,omitempty"`
|
||||||
Group []string `json:"group,omitempty"`
|
Group []string `json:"group,omitempty"`
|
||||||
Health []string `json:"health,omitempty"`
|
Health []string `json:"health,omitempty"`
|
||||||
IaaS []string `json:"iaas,omitempty"`
|
IaaS []string `json:"iaas,omitempty"`
|
||||||
Image []string `json:"image,omitempty"`
|
Image []string `json:"image,omitempty"`
|
||||||
Job []string `json:"job,omitempty"`
|
Job []string `json:"job,omitempty"`
|
||||||
K8CI []string `json:"k8ci,omitempty"`
|
K8CI []string `json:"k8ci,omitempty"`
|
||||||
K8S []string `json:"k8s,omitempty"`
|
K8S []string `json:"k8s,omitempty"`
|
||||||
KVMPPC []string `json:"kvmppc,omitempty"`
|
KVMPPC []string `json:"kvmppc,omitempty"`
|
||||||
KVMX86 []string `json:"kvmx86,omitempty"`
|
KVMX86 []string `json:"kvmx86,omitempty"`
|
||||||
LB []string `json:"lb,omitempty"`
|
LB []string `json:"lb,omitempty"`
|
||||||
Machine []string `json:"machine,omitempty"`
|
Machine []string `json:"machine,omitempty"`
|
||||||
Metering []string `json:"metering,omitempty"`
|
Metering []string `json:"metering,omitempty"`
|
||||||
Milestones []string `json:"milestones,omitempty"`
|
Milestones []string `json:"milestones,omitempty"`
|
||||||
Node []string `json:"node,omitempty"`
|
Node []string `json:"node,omitempty"`
|
||||||
Openshift []string `json:"openshift,omitempty"`
|
Openshift []string `json:"openshift,omitempty"`
|
||||||
OpenshiftCI []string `json:"openshiftci,omitempty"`
|
OpenshiftCI []string `json:"openshiftci,omitempty"`
|
||||||
Ovsnode []string `json:"ovsnode,omitempty"`
|
Ovsnode []string `json:"ovsnode,omitempty"`
|
||||||
PCIDevice []string `json:"pcidevice,omitempty"`
|
PCIDevice []string `json:"pcidevice,omitempty"`
|
||||||
PGPU []string `json:"pgpu,omitempty"`
|
PGPU []string `json:"pgpu,omitempty"`
|
||||||
Prometheus []string `json:"prometheus,omitempty"`
|
Prometheus []string `json:"prometheus,omitempty"`
|
||||||
QOS []string `json:"qos,omitempty"`
|
QOS []string `json:"qos,omitempty"`
|
||||||
Resmon []string `json:"resmon,omitempty"`
|
Resmon []string `json:"resmon,omitempty"`
|
||||||
RG []string `json:"rg,omitempty"`
|
RG []string `json:"rg,omitempty"`
|
||||||
Sep []string `json:"sep,omitempty"`
|
Sep []string `json:"sep,omitempty"`
|
||||||
Stack []string `json:"stack,omitempty"`
|
Stack []string `json:"stack,omitempty"`
|
||||||
Tasks []string `json:"tasks,omitempty"`
|
Tasks []string `json:"tasks,omitempty"`
|
||||||
TLock []string `json:"tlock,omitempty"`
|
TLock []string `json:"tlock,omitempty"`
|
||||||
User []string `json:"user,omitempty"`
|
User []string `json:"user,omitempty"`
|
||||||
VGPU []string `json:"vgpu,omitempty"`
|
VGPU []string `json:"vgpu,omitempty"`
|
||||||
VINS []string `json:"vins,omitempty"`
|
VINS []string `json:"vins,omitempty"`
|
||||||
VNFDev []string `json:"vnfdev,omitempty"`
|
VNFDev []string `json:"vnfdev,omitempty"`
|
||||||
ZeroAccess []string `json:"zeroaccess,omitempty"`
|
ZeroAccess []string `json:"zeroaccess,omitempty"`
|
||||||
All bool `json:"ALL,omitempty"`
|
All bool `json:"ALL,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type LibCloudEndpoints struct {
|
type LibCloudEndpoints struct {
|
||||||
|
|||||||
10
pkg/cloudbroker/audit.go
Normal file
10
pkg/cloudbroker/audit.go
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
package cloudbroker
|
||||||
|
|
||||||
|
import (
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/audit"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Accessing the Stack method group
|
||||||
|
func (cb *CloudBroker) Audit() *audit.Audit {
|
||||||
|
return audit.New(cb.client)
|
||||||
|
}
|
||||||
15
pkg/cloudbroker/audit/audit.go
Normal file
15
pkg/cloudbroker/audit/audit.go
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
package audit
|
||||||
|
|
||||||
|
import "repository.basistech.ru/BASIS/decort-golang-sdk/interfaces"
|
||||||
|
|
||||||
|
// Structure for creating request to audit
|
||||||
|
type Audit struct {
|
||||||
|
client interfaces.Caller
|
||||||
|
}
|
||||||
|
|
||||||
|
// Builder for audit endpoint
|
||||||
|
func New(client interfaces.Caller) *Audit{
|
||||||
|
return &Audit{
|
||||||
|
client: client,
|
||||||
|
}
|
||||||
|
}
|
||||||
46
pkg/cloudbroker/audit/get.go
Normal file
46
pkg/cloudbroker/audit/get.go
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
package audit
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"encoding/json"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
|
)
|
||||||
|
|
||||||
|
// GetRequest struct to get information about account
|
||||||
|
type GetRequest struct {
|
||||||
|
// Audit GUID
|
||||||
|
// Required: true
|
||||||
|
AuditGuid string `url:"auditGuid" json:"auditGuid" validate:"required"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get gets information about audit as a RecordAudit struct
|
||||||
|
func (a Audit) Get(ctx context.Context, req GetRequest) (*RecordAudit, error) {
|
||||||
|
res, err := a.GetRaw(ctx, req)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
info := RecordAudit{}
|
||||||
|
|
||||||
|
err = json.Unmarshal(res, &info)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return &info, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetRaw gets information about audit as an array of bytes
|
||||||
|
func (a Audit) GetRaw(ctx context.Context, req GetRequest) ([]byte, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudbroker/audit/get"
|
||||||
|
|
||||||
|
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
46
pkg/cloudbroker/audit/linked_jobs.go
Normal file
46
pkg/cloudbroker/audit/linked_jobs.go
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
package audit
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"encoding/json"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
|
)
|
||||||
|
|
||||||
|
// LinkedJobsRequest struct to get information about jobs linked with Audit
|
||||||
|
type LinkedJobsRequest struct {
|
||||||
|
// Audit GUID
|
||||||
|
// Required: true
|
||||||
|
AuditGuid string `url:"auditGuid" json:"auditGuid" validate:"required"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// LinkedJobs gets information about Linked Jobs as a ListLinkedJobs struct
|
||||||
|
func (a Audit) LinkedJobs(ctx context.Context, req LinkedJobsRequest) (*ListLinkedJobs, error) {
|
||||||
|
res, err := a.GetRawLinkedJobs(ctx, req)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
info := ListLinkedJobs{}
|
||||||
|
|
||||||
|
err = json.Unmarshal(res, &info)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return &info, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetRawLinkedJobs gets information about Linked Jobs as an array of bytes
|
||||||
|
func (a Audit) GetRawLinkedJobs(ctx context.Context, req LinkedJobsRequest) ([]byte, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudbroker/audit/linkedJobs"
|
||||||
|
|
||||||
|
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
64
pkg/cloudbroker/audit/list.go
Normal file
64
pkg/cloudbroker/audit/list.go
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
package audit
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"encoding/json"
|
||||||
|
"net/http"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ListRequest struct to give list of account audits
|
||||||
|
type ListRequest struct {
|
||||||
|
|
||||||
|
// Find all audits after point in time (unixtime)
|
||||||
|
// Required: false
|
||||||
|
TimestampAt uint64 `url:"timestampAt,omitempty" json:"timestampAt,omitempty"`
|
||||||
|
|
||||||
|
// Find all audits before point in time (unixtime)
|
||||||
|
// Required: false
|
||||||
|
TimestampTo uint64 `url:"timestampTo,omitempty" json:"timestampTo,omitempty"`
|
||||||
|
|
||||||
|
// Find by 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 HTTP status code
|
||||||
|
// Required: false
|
||||||
|
StatusCode uint64 `url:"statusCode,omitempty" json:"statusCode,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 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) {
|
||||||
|
url := "/cloudbroker/audit/list"
|
||||||
|
|
||||||
|
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
102
pkg/cloudbroker/audit/models.go
Normal file
102
pkg/cloudbroker/audit/models.go
Normal file
@@ -0,0 +1,102 @@
|
|||||||
|
package audit
|
||||||
|
|
||||||
|
// Main info about audit
|
||||||
|
type ItemAudit struct {
|
||||||
|
// Call
|
||||||
|
Call string `json:"call"`
|
||||||
|
|
||||||
|
// GUID
|
||||||
|
GUID string `json:"guid"`
|
||||||
|
|
||||||
|
// Response time
|
||||||
|
ResponseTime float64 `json:"responsetime"`
|
||||||
|
|
||||||
|
// Status code
|
||||||
|
StatusCode uint64 `json:"statuscode"`
|
||||||
|
|
||||||
|
// Timestamp
|
||||||
|
Timestamp float64 `json:"timestamp"`
|
||||||
|
|
||||||
|
// User
|
||||||
|
User string `json:"user"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// List of audits
|
||||||
|
type ListAudits struct {
|
||||||
|
// Data
|
||||||
|
Data []ItemAudit `json:"data"`
|
||||||
|
|
||||||
|
// EntryCount
|
||||||
|
EntryCount uint64 `json:"entryCount"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Main info about audit
|
||||||
|
type RecordAudit struct {
|
||||||
|
|
||||||
|
// Apitask
|
||||||
|
Apitask string `json:"apitask"`
|
||||||
|
|
||||||
|
// Arguments
|
||||||
|
Arguments string `json:"args"`
|
||||||
|
|
||||||
|
// Call
|
||||||
|
Call string `json:"call"`
|
||||||
|
|
||||||
|
// GUID
|
||||||
|
GUID string `json:"guid"`
|
||||||
|
|
||||||
|
// 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"`
|
||||||
|
|
||||||
|
// Tags
|
||||||
|
Tags string `json:"tags"`
|
||||||
|
|
||||||
|
// Timestamp
|
||||||
|
Timestamp float64 `json:"timestamp"`
|
||||||
|
|
||||||
|
// TimestampEnd
|
||||||
|
TimestampEnd float64 `json:"timestampEnd"`
|
||||||
|
|
||||||
|
// User
|
||||||
|
User string `json:"user"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// List of Linked Jobs
|
||||||
|
type ListLinkedJobs []ItemLinkedJobs
|
||||||
|
|
||||||
|
// Main info about Linked Jobs
|
||||||
|
type ItemLinkedJobs struct {
|
||||||
|
|
||||||
|
// CMD
|
||||||
|
CMD string `json:"cmd"`
|
||||||
|
|
||||||
|
// NID
|
||||||
|
NID uint64 `json:"nid"`
|
||||||
|
|
||||||
|
// state
|
||||||
|
State string `json:"state"`
|
||||||
|
|
||||||
|
// TimeCreate
|
||||||
|
TimeCreate uint64 `json:"timeCreate"`
|
||||||
|
|
||||||
|
// TimeStart
|
||||||
|
TimeStart uint64 `json:"timeStart"`
|
||||||
|
|
||||||
|
// TimeStop
|
||||||
|
TimeStop uint64 `json:"timeStop"`
|
||||||
|
|
||||||
|
// Timeout
|
||||||
|
Timeout uint64 `json:"timeout"`
|
||||||
|
}
|
||||||
38
pkg/cloudbroker/compute/delete_custom_fields.go
Normal file
38
pkg/cloudbroker/compute/delete_custom_fields.go
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
package compute
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"net/http"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
|
)
|
||||||
|
|
||||||
|
// DeleteCustomFieldsRequest struct to delete compute's custom fields
|
||||||
|
type DeleteCustomFieldsRequest struct {
|
||||||
|
// ID of the compute
|
||||||
|
// Required: true
|
||||||
|
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeleteCustomFields deletes computes custom fields
|
||||||
|
func (c Compute) DeleteCustomFields(ctx context.Context, req DeleteCustomFieldsRequest) (bool, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudbroker/compute/deleteCustomFields"
|
||||||
|
|
||||||
|
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
|
||||||
|
}
|
||||||
46
pkg/cloudbroker/compute/ids.go
Normal file
46
pkg/cloudbroker/compute/ids.go
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
package compute
|
||||||
|
|
||||||
|
// IDs gets array of ComputeIDs from ListComputes struct
|
||||||
|
func (lc ListComputes) IDs() []uint64 {
|
||||||
|
res := make([]uint64, 0, len(lc.Data))
|
||||||
|
for _, c := range lc.Data {
|
||||||
|
res = append(res, c.ID)
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDs gets array of DiskIDs from ListInfoDisks struct
|
||||||
|
func (lid ListInfoDisks) IDs() []uint64 {
|
||||||
|
res := make([]uint64, 0, len(lid))
|
||||||
|
for _, d := range lid {
|
||||||
|
res = append(res, d.ID)
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDs gets array of PFWsIDs from ListPFW struct
|
||||||
|
func (lp ListPFW) IDs() []uint64 {
|
||||||
|
res := make([]uint64, 0, len(lp.Data))
|
||||||
|
for _, p := range lp.Data {
|
||||||
|
res = append(res, p.ID)
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDs gets array of DiskIDs from ListDisks struct
|
||||||
|
func (ld ListDisks) IDs() []uint64 {
|
||||||
|
res := make([]uint64, 0, len(ld))
|
||||||
|
for _, d := range ld {
|
||||||
|
res = append(res, d.ID)
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDs gets array of PCIDeviceIDs from ListPCIDevices struct
|
||||||
|
func (lpd ListPCIDevices) IDs() []uint64 {
|
||||||
|
res := make([]uint64, 0, len(lpd.Data))
|
||||||
|
for _, pd := range lpd.Data {
|
||||||
|
res = append(res, pd.ID)
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
||||||
@@ -12,6 +12,14 @@ type RecordACL struct {
|
|||||||
RGACL ListACL `json:"rgACL"`
|
RGACL ListACL `json:"rgACL"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type ListUsers struct {
|
||||||
|
// Data
|
||||||
|
Data RecordACL `json:"data"`
|
||||||
|
|
||||||
|
// Entry count
|
||||||
|
EntryCount uint64 `json:"entryCount"`
|
||||||
|
}
|
||||||
|
|
||||||
// ACL information
|
// ACL information
|
||||||
type ItemACL struct {
|
type ItemACL struct {
|
||||||
// Explicit
|
// Explicit
|
||||||
@@ -75,6 +83,15 @@ type ItemSnapshot struct {
|
|||||||
// List of snapshots
|
// List of snapshots
|
||||||
type ListSnapshots []ItemSnapshot
|
type ListSnapshots []ItemSnapshot
|
||||||
|
|
||||||
|
// List of snapshots
|
||||||
|
type ListSnapShot struct {
|
||||||
|
// Data
|
||||||
|
Data []ItemSnapshot `json:"data"`
|
||||||
|
|
||||||
|
// Entry count
|
||||||
|
EntryCount uint64 `json:"entryCount"`
|
||||||
|
}
|
||||||
|
|
||||||
// Main information about snapshot usage
|
// Main information about snapshot usage
|
||||||
type ItemSnapshotUsage struct {
|
type ItemSnapshotUsage struct {
|
||||||
// Count
|
// Count
|
||||||
@@ -232,7 +249,13 @@ type ItemPFW struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// List port forwards
|
// List port forwards
|
||||||
type ListPFW []ItemPFW
|
type ListPFW struct {
|
||||||
|
// Data
|
||||||
|
Data []ItemPFW `json:"data"`
|
||||||
|
|
||||||
|
// Entry count
|
||||||
|
EntryCount uint64 `json:"entryCount"`
|
||||||
|
}
|
||||||
|
|
||||||
// Main information about rule
|
// Main information about rule
|
||||||
type ItemRule struct {
|
type ItemRule struct {
|
||||||
@@ -569,6 +592,9 @@ type InfoCompute struct {
|
|||||||
// Boot disk size
|
// Boot disk size
|
||||||
BootDiskSize uint64 `json:"bootdiskSize"`
|
BootDiskSize uint64 `json:"bootdiskSize"`
|
||||||
|
|
||||||
|
// cd Image Id
|
||||||
|
CdImageId uint64 `json:"cdImageId"`
|
||||||
|
|
||||||
// Clone reference
|
// Clone reference
|
||||||
CloneReference uint64 `json:"cloneReference"`
|
CloneReference uint64 `json:"cloneReference"`
|
||||||
|
|
||||||
@@ -638,6 +664,9 @@ type InfoCompute struct {
|
|||||||
// Name
|
// Name
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
|
|
||||||
|
// Need reboot
|
||||||
|
NeedReboot bool `json:"needReboot"`
|
||||||
|
|
||||||
// List OS users
|
// List OS users
|
||||||
OSUsers ListOSUsers `json:"osUsers"`
|
OSUsers ListOSUsers `json:"osUsers"`
|
||||||
|
|
||||||
@@ -720,16 +749,19 @@ type RecordCompute struct {
|
|||||||
InfoCompute
|
InfoCompute
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Information about of disk IDs
|
||||||
|
type ListInfoDisks []InfoDisk
|
||||||
|
|
||||||
// Main information about compute for list
|
// Main information about compute for list
|
||||||
type ItemCompute struct {
|
type ItemCompute struct {
|
||||||
// List of disk IDs
|
// List of disk IDs
|
||||||
Disks []InfoDisk `json:"disks"`
|
Disks ListInfoDisks `json:"disks"`
|
||||||
|
|
||||||
// Main information about compute
|
// Main information about compute
|
||||||
InfoCompute
|
InfoCompute
|
||||||
|
|
||||||
// Total disk size
|
// Total disk size
|
||||||
TotalDiskSize uint64 `json:"totalDiskSize"`
|
TotalDiskSize uint64 `json:"totalDisksSize"`
|
||||||
|
|
||||||
// VINS connected
|
// VINS connected
|
||||||
VINSConnected uint64 `json:"vinsConnected"`
|
VINSConnected uint64 `json:"vinsConnected"`
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ type PFWListRequest struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// PFWList gets compute port forwards list
|
// PFWList gets compute port forwards list
|
||||||
func (c Compute) PFWList(ctx context.Context, req PFWListRequest) (ListPFW, error) {
|
func (c Compute) PFWList(ctx context.Context, req PFWListRequest) (*ListPFW, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
@@ -40,5 +40,5 @@ func (c Compute) PFWList(ctx context.Context, req PFWListRequest) (ListPFW, erro
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return list, nil
|
return &list, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ type SnapshotListRequest struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// SnapshotList gets list of compute snapshots
|
// SnapshotList gets list of compute snapshots
|
||||||
func (c Compute) SnapshotList(ctx context.Context, req SnapshotListRequest) (ListSnapshots, error) {
|
func (c Compute) SnapshotList(ctx context.Context, req SnapshotListRequest) (*ListSnapShot, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
@@ -29,12 +29,12 @@ func (c Compute) SnapshotList(ctx context.Context, req SnapshotListRequest) (Lis
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
list := ListSnapshots{}
|
list := ListSnapShot{}
|
||||||
|
|
||||||
err = json.Unmarshal(res, &list)
|
err = json.Unmarshal(res, &list)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return list, nil
|
return &list, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ type UserListRequest struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// UserList gets users list for compute
|
// UserList gets users list for compute
|
||||||
func (c Compute) UserList(ctx context.Context, req UserListRequest) (*RecordACL, error) {
|
func (c Compute) UserList(ctx context.Context, req UserListRequest) (*ListUsers, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
@@ -29,7 +29,7 @@ func (c Compute) UserList(ctx context.Context, req UserListRequest) (*RecordACL,
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
list := RecordACL{}
|
list := ListUsers{}
|
||||||
|
|
||||||
err = json.Unmarshal(res, &list)
|
err = json.Unmarshal(res, &list)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
20
pkg/cloudbroker/disks/ids.go
Normal file
20
pkg/cloudbroker/disks/ids.go
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
package disks
|
||||||
|
|
||||||
|
// IDs gets array of DiskIDs from ListDisks struct
|
||||||
|
func (ld ListDisks) IDs() []uint64 {
|
||||||
|
res := make([]uint64, 0, len(ld.Data))
|
||||||
|
for _, d := range ld.Data {
|
||||||
|
res = append(res, d.ID)
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDs gets array of DiskIDs from ListUnattachedDisks struct
|
||||||
|
func (ldu ListUnattachedDisks) IDs() []uint64 {
|
||||||
|
res := make([]uint64, 0, len(ldu.Data))
|
||||||
|
for _, d := range ldu.Data {
|
||||||
|
res = append(res, d.ID)
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
19
pkg/cloudbroker/extnet/ids.go
Normal file
19
pkg/cloudbroker/extnet/ids.go
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
package extnet
|
||||||
|
|
||||||
|
// IDs gets array of ExtNetIDs from ListExtNet struct
|
||||||
|
func (le ListExtNet) IDs() []uint64 {
|
||||||
|
res := make([]uint64, 0, len(le.Data))
|
||||||
|
for _, e := range le.Data {
|
||||||
|
res = append(res, e.ID)
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDs gets array of StaticRouteIDs from ListStaticRoutes struct
|
||||||
|
func (lsr ListStaticRoutes) IDs() []uint64 {
|
||||||
|
res := make([]uint64, 0, len(lsr.Data))
|
||||||
|
for _, sr := range lsr.Data {
|
||||||
|
res = append(res, sr.ID)
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
||||||
10
pkg/cloudbroker/flipgroup/ids.go
Normal file
10
pkg/cloudbroker/flipgroup/ids.go
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
package flipgroup
|
||||||
|
|
||||||
|
// IDs gets array of FLIPGroupIDs from ListFLIPGroups struct
|
||||||
|
func (le ListFLIPGroups) IDs() []uint64 {
|
||||||
|
res := make([]uint64, 0, len(le.Data))
|
||||||
|
for _, e := range le.Data {
|
||||||
|
res = append(res, e.ID)
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
||||||
@@ -2,6 +2,7 @@ package grid
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
@@ -38,7 +39,7 @@ func (g Grid) GetDiagnosisGET(ctx context.Context, req GetDiagnosisRequest) (str
|
|||||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
url := "/cloudbroker/grid/getDiagnosis"
|
url := fmt.Sprintf("/cloudbroker/grid/getDiagnosis/?gid=%d", req.GID)
|
||||||
|
|
||||||
res, err := g.client.DecortApiCall(ctx, http.MethodGet, url, req)
|
res, err := g.client.DecortApiCall(ctx, http.MethodGet, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
19
pkg/cloudbroker/grid/ids.go
Normal file
19
pkg/cloudbroker/grid/ids.go
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
package grid
|
||||||
|
|
||||||
|
// IDs gets array of GRIDID from ListGrids struct
|
||||||
|
func (lg ListGrids) IDs() []uint64 {
|
||||||
|
res := make([]uint64, 0, len(lg.Data))
|
||||||
|
for _, e := range lg.Data {
|
||||||
|
res = append(res, e.GID)
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDs gets array of GRIDID from ListResourceConsumption struct
|
||||||
|
func (lg ListResourceConsumption) IDs() []uint64 {
|
||||||
|
res := make([]uint64, 0, len(lg.Data))
|
||||||
|
for _, e := range lg.Data {
|
||||||
|
res = append(res, e.GID)
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
||||||
@@ -67,6 +67,9 @@ type DiskUsage struct {
|
|||||||
|
|
||||||
// Detailed information about grid
|
// Detailed information about grid
|
||||||
type RecordGrid struct {
|
type RecordGrid struct {
|
||||||
|
// AuthBroker
|
||||||
|
AuthBroker []interface{} `json:"authBroker"`
|
||||||
|
|
||||||
// Flag
|
// Flag
|
||||||
Flag string `json:"flag"`
|
Flag string `json:"flag"`
|
||||||
|
|
||||||
@@ -91,6 +94,9 @@ type ItemGridList struct {
|
|||||||
// Resource information
|
// Resource information
|
||||||
Resources Resources `json:"Resources"`
|
Resources Resources `json:"Resources"`
|
||||||
|
|
||||||
|
// AuthBroker
|
||||||
|
AuthBroker []interface{} `json:"authBroker"`
|
||||||
|
|
||||||
// Flag
|
// Flag
|
||||||
Flag string `json:"flag"`
|
Flag string `json:"flag"`
|
||||||
|
|
||||||
|
|||||||
28
pkg/cloudbroker/image/ids.go
Normal file
28
pkg/cloudbroker/image/ids.go
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
package image
|
||||||
|
|
||||||
|
// IDs gets array of ImageIDs from ListImages struct
|
||||||
|
func (li ListImages) IDs() []uint64 {
|
||||||
|
res := make([]uint64, 0, len(li.Data))
|
||||||
|
for _, i := range li.Data {
|
||||||
|
res = append(res, i.ID)
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDs gets array of StackIDs from ListStacks struct
|
||||||
|
func (ls ListStacks) IDs() []uint64 {
|
||||||
|
res := make([]uint64, 0, len(ls.Data))
|
||||||
|
for _, h := range ls.Data {
|
||||||
|
res = append(res, h.ID)
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDs gets array of HistoryIDs from ListHistory struct
|
||||||
|
func (lh ListHistory) IDs() []uint64 {
|
||||||
|
res := make([]uint64, 0, len(lh))
|
||||||
|
for _, h := range lh {
|
||||||
|
res = append(res, h.ID)
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
||||||
36
pkg/cloudbroker/k8ci/access_add.go
Normal file
36
pkg/cloudbroker/k8ci/access_add.go
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
package k8ci
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
|
)
|
||||||
|
|
||||||
|
// AccessAddRequest struct for adding permission to access to account for a k8ci
|
||||||
|
type AccessAddRequest struct {
|
||||||
|
// ID of the K8 catalog item to add access for
|
||||||
|
// Required: true
|
||||||
|
K8CIID uint64 `url:"k8ciId" json:"k8ciId" validate:"required"`
|
||||||
|
|
||||||
|
// Account ID to add to the sharedWith access list
|
||||||
|
// Required: true
|
||||||
|
AccountId uint64 `url:"accountId" json:"accountId" validate:"required"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add accountId to sharedWith access list for k8ci.
|
||||||
|
func (k K8CI) AccessAdd (ctx context.Context, req AccessAddRequest) (string, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudbroker/k8ci/accessAdd"
|
||||||
|
|
||||||
|
res, err := k.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
|
||||||
|
return string(res), nil
|
||||||
|
}
|
||||||
36
pkg/cloudbroker/k8ci/access_remove.go
Normal file
36
pkg/cloudbroker/k8ci/access_remove.go
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
package k8ci
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
|
)
|
||||||
|
|
||||||
|
// AccessRemoveRequest struct for removing permission to access to account for a k8ci
|
||||||
|
type AccessRemoveRequest struct {
|
||||||
|
// ID of the K8 catalog item to remove access for
|
||||||
|
// Required: true
|
||||||
|
K8CIID uint64 `url:"k8ciId" json:"k8ciId" validate:"required"`
|
||||||
|
|
||||||
|
// Account ID to be removed from the sharedWith access list
|
||||||
|
// Required: true
|
||||||
|
AccountId uint64 `url:"accountId" json:"accountId" validate:"required"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Remove accountId from sharedWith access list for k8ci.
|
||||||
|
func (k K8CI) AccessRemove (ctx context.Context, req AccessRemoveRequest) (string, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudbroker/k8ci/accessRemove"
|
||||||
|
|
||||||
|
res, err := k.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
|
||||||
|
return string(res), nil
|
||||||
|
}
|
||||||
10
pkg/cloudbroker/k8ci/ids.go
Normal file
10
pkg/cloudbroker/k8ci/ids.go
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
package k8ci
|
||||||
|
|
||||||
|
// IDs gets array of K8CIIDs from ListK8CI struct
|
||||||
|
func (lk8ci ListK8CI) IDs() []uint64 {
|
||||||
|
res := make([]uint64, 0, len(lk8ci.Data))
|
||||||
|
for _, i := range lk8ci.Data {
|
||||||
|
res = append(res, i.ID)
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
||||||
@@ -17,7 +17,7 @@ type DeleteRequest struct {
|
|||||||
// True if cluster is destroyed permanently.
|
// True if cluster is destroyed permanently.
|
||||||
// Otherwise it can be restored from recycle bin
|
// Otherwise it can be restored from recycle bin
|
||||||
// Required: false
|
// Required: false
|
||||||
Permanently bool `url:"permanently,omitempty" json:"permanently,omitempty"`
|
Permanently bool `url:"permanently" json:"permanently"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete deletes kubernetes cluster
|
// Delete deletes kubernetes cluster
|
||||||
|
|||||||
30
pkg/cloudbroker/k8s/ids.go
Normal file
30
pkg/cloudbroker/k8s/ids.go
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
package k8s
|
||||||
|
|
||||||
|
// IDs gets array of K8SIDs from ListK8S struct
|
||||||
|
func (lk ListK8S) IDs() []uint64 {
|
||||||
|
res := make([]uint64, 0, len(lk.Data))
|
||||||
|
for _, k := range lk.Data {
|
||||||
|
res = append(res, k.ID)
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDs gets array of K8SWorkerGroupIDs from ListK8SGroups struct
|
||||||
|
func (lwg ListK8SGroup) IDs() []uint64 {
|
||||||
|
res := make([]uint64, 0, len(lwg))
|
||||||
|
for _, wg := range lwg {
|
||||||
|
res = append(res, wg.ID)
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDs gets array of Worker or Master ComputesIDs from ListDetailedInfo struct
|
||||||
|
func (ldi ListDetailedInfo) IDs() []uint64 {
|
||||||
|
res := make([]uint64, 0, len(ldi))
|
||||||
|
for _, di := range ldi {
|
||||||
|
res = append(res, di.ID)
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
10
pkg/cloudbroker/lb/ids.go
Normal file
10
pkg/cloudbroker/lb/ids.go
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
package lb
|
||||||
|
|
||||||
|
// IDs gets array of LBIDs from ListLB struct
|
||||||
|
func (llb ListLB) IDs() []uint64 {
|
||||||
|
res := make([]uint64, 0, len(llb.Data))
|
||||||
|
for _, lb := range llb.Data {
|
||||||
|
res = append(res, lb.ID)
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
||||||
@@ -29,10 +29,10 @@ func (l LB) HighlyAvailable(ctx context.Context, req HighlyAvailableRequest) (bo
|
|||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
result, err := strconv.ParseBool(string(res))
|
result, err := strconv.ParseUint(string(res), 10, 64)
|
||||||
if err != nil {
|
if err != nil || result != req.LBID {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return result, nil
|
return true, nil
|
||||||
}
|
}
|
||||||
|
|||||||
10
pkg/cloudbroker/pcidevice/ids.go
Normal file
10
pkg/cloudbroker/pcidevice/ids.go
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
package pcidevice
|
||||||
|
|
||||||
|
// IDs gets array of PCIDeviceIDs from ListPCIDevices struct
|
||||||
|
func (lpd ListPCIDevices) IDs() []uint64 {
|
||||||
|
res := make([]uint64, 0, len(lpd.Data))
|
||||||
|
for _, lb := range lpd.Data {
|
||||||
|
res = append(res, lb.ID)
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
||||||
@@ -13,6 +13,14 @@ type AffinityGroupsListRequest struct {
|
|||||||
// Resource group ID
|
// Resource group ID
|
||||||
// Required: true
|
// Required: true
|
||||||
RGID uint64 `url:"rgId" json:"rgId" validate:"required"`
|
RGID uint64 `url:"rgId" json:"rgId" validate:"required"`
|
||||||
|
|
||||||
|
// Page number
|
||||||
|
// Required: false
|
||||||
|
Page uint64 `url:"page,omitempty" json:"page,omitempty"`
|
||||||
|
|
||||||
|
// Page size
|
||||||
|
// Required: false
|
||||||
|
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// AffinityGroupsList gets all currently defined affinity groups in this resource group with compute IDs
|
// AffinityGroupsList gets all currently defined affinity groups in this resource group with compute IDs
|
||||||
|
|||||||
64
pkg/cloudbroker/rg/ids.go
Normal file
64
pkg/cloudbroker/rg/ids.go
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
package rg
|
||||||
|
|
||||||
|
// IDs gets array of ResourceGroupIDs from ListRG struct
|
||||||
|
func (lrg ListRG) IDs() []uint64 {
|
||||||
|
res := make([]uint64, 0, len(lrg.Data))
|
||||||
|
for _, rg := range lrg.Data {
|
||||||
|
res = append(res, rg.ID)
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDs gets array of ComputeIDs from ListComputes struct
|
||||||
|
func (lc ListComputes) IDs() []uint64 {
|
||||||
|
res := make([]uint64, 0, len(lc.Data))
|
||||||
|
for _, c := range lc.Data {
|
||||||
|
res = append(res, c.ID)
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDs gets array of LBIDs from ListLB struct
|
||||||
|
func (llb ListLB) IDs() []uint64 {
|
||||||
|
res := make([]uint64, 0, len(llb.Data))
|
||||||
|
for _, lb := range llb.Data {
|
||||||
|
res = append(res, lb.ID)
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDs gets array of VINSIDs from ListVINS struct
|
||||||
|
func (llb ListVINS) IDs() []uint64 {
|
||||||
|
res := make([]uint64, 0, len(llb.Data))
|
||||||
|
for _, vi := range llb.Data {
|
||||||
|
res = append(res, vi.ID)
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDs gets array of ResourceGroupIDs from ListResourceConsumption struct
|
||||||
|
func (lrc ListResourceConsumption) IDs() []uint64 {
|
||||||
|
res := make([]uint64, 0, len(lrc.Data))
|
||||||
|
for _, rg := range lrc.Data {
|
||||||
|
res = append(res, rg.RGID)
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDs gets array of VINSIDs from ListPFW struct
|
||||||
|
func (lpfw ListPFW) IDs() []uint64 {
|
||||||
|
res := make([]uint64, 0, len(lpfw.Data))
|
||||||
|
for _, pfw := range lpfw.Data {
|
||||||
|
res = append(res, pfw.VINSID)
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDs gets array of ComputeIDs from ListAffinityGroupItems struct
|
||||||
|
func (lag ListAffinityGroupItems) IDs() []uint64 {
|
||||||
|
res := make([]uint64, 0, len(lag))
|
||||||
|
for _, ag := range lag {
|
||||||
|
res = append(res, ag.ID)
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
||||||
@@ -36,6 +36,10 @@ type ListRequest struct {
|
|||||||
// Required: false
|
// Required: false
|
||||||
Status string `url:"status,omitempty" json:"status,omitempty"`
|
Status string `url:"status,omitempty" json:"status,omitempty"`
|
||||||
|
|
||||||
|
// Find by status lock
|
||||||
|
// Required: false
|
||||||
|
LockStatus string `url:"lockStatus,omitempty" json:"lockStatus,omitempty"`
|
||||||
|
|
||||||
// Included deleted resource groups
|
// Included deleted resource groups
|
||||||
// Required: false
|
// Required: false
|
||||||
IncludeDeleted bool `url:"includedeleted,omitempty" json:"includedeleted,omitempty"`
|
IncludeDeleted bool `url:"includedeleted,omitempty" json:"includedeleted,omitempty"`
|
||||||
|
|||||||
@@ -65,6 +65,10 @@ type ItemResourceConsumption struct {
|
|||||||
// Reserved information
|
// Reserved information
|
||||||
Reserved Reservation `json:"Reserved"`
|
Reserved Reservation `json:"Reserved"`
|
||||||
|
|
||||||
|
// Resource limits
|
||||||
|
ResourceLimits ResourceLimits `json:"resourceLimits"`
|
||||||
|
|
||||||
|
// Resource group ID
|
||||||
RGID uint64 `json:"rgid"`
|
RGID uint64 `json:"rgid"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -687,8 +691,15 @@ type ListLB struct {
|
|||||||
|
|
||||||
type ListAffinityGroup struct {
|
type ListAffinityGroup struct {
|
||||||
// Data
|
// Data
|
||||||
Data map[string][]uint64 `json:"data"`
|
Data []map[string]ListAffinityGroupItems `json:"data"`
|
||||||
|
|
||||||
// Entry count
|
// Entry count
|
||||||
EntryCount uint64 `json:"entryCount"`
|
EntryCount uint64 `json:"entryCount"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type ListAffinityGroupItems []ItemAffinityGroup
|
||||||
|
|
||||||
|
type ItemAffinityGroup struct {
|
||||||
|
ID uint64 `json:"id"`
|
||||||
|
NodeID uint64 `json:"node_id"`
|
||||||
|
}
|
||||||
|
|||||||
10
pkg/cloudbroker/sep/ids.go
Normal file
10
pkg/cloudbroker/sep/ids.go
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
package sep
|
||||||
|
|
||||||
|
// IDs gets array of SEPIDs from ListSEP struct
|
||||||
|
func (ls ListSEP) IDs() []uint64 {
|
||||||
|
res := make([]uint64, 0, len(ls.Data))
|
||||||
|
for _, s := range ls.Data {
|
||||||
|
res = append(res, s.ID)
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
||||||
10
pkg/cloudbroker/stack/ids.go
Normal file
10
pkg/cloudbroker/stack/ids.go
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
package stack
|
||||||
|
|
||||||
|
// IDs gets array of StackIDs from ListStacks struct
|
||||||
|
func (ls ListStacks) IDs() []uint64 {
|
||||||
|
res := make([]uint64, 0, len(ls.Data))
|
||||||
|
for _, s := range ls.Data {
|
||||||
|
res = append(res, s.ID)
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
||||||
@@ -1,4 +1,3 @@
|
|||||||
// Lists all the stack.
|
|
||||||
package stack
|
package stack
|
||||||
|
|
||||||
import "repository.basistech.ru/BASIS/decort-golang-sdk/interfaces"
|
import "repository.basistech.ru/BASIS/decort-golang-sdk/interfaces"
|
||||||
|
|||||||
10
pkg/cloudbroker/user/ids.go
Normal file
10
pkg/cloudbroker/user/ids.go
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
package user
|
||||||
|
|
||||||
|
// IDs gets array of UserIDs from ListAPIAccess struct
|
||||||
|
func (us ListAPIAccess) IDs() []uint64 {
|
||||||
|
res := make([]uint64, 0, len(us))
|
||||||
|
for _, us := range us {
|
||||||
|
res = append(res, us.ID)
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
||||||
10
pkg/cloudbroker/vgpu/ids.go
Normal file
10
pkg/cloudbroker/vgpu/ids.go
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
package vgpu
|
||||||
|
|
||||||
|
// IDs gets array of VGPUIDs from ListVGPU struct
|
||||||
|
func (lvg ListVGPU) IDs() []uint64 {
|
||||||
|
res := make([]uint64, 0, len(lvg.Data))
|
||||||
|
for _, s := range lvg.Data {
|
||||||
|
res = append(res, s.ID)
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
||||||
55
pkg/cloudbroker/vins/ids.go
Normal file
55
pkg/cloudbroker/vins/ids.go
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
package vins
|
||||||
|
|
||||||
|
// IDs gets array of VINSIDs from ListVINS struct
|
||||||
|
func (lv ListVINS) IDs() []uint64 {
|
||||||
|
res := make([]uint64, 0, len(lv.Data))
|
||||||
|
for _, v := range lv.Data {
|
||||||
|
res = append(res, v.ID)
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDs gets array of ExtNetIDs from ListExtNets struct
|
||||||
|
func (le ListExtNets) IDs() []uint64 {
|
||||||
|
res := make([]uint64, 0, len(le.Data))
|
||||||
|
for _, e := range le.Data {
|
||||||
|
res = append(res, e.ExtNetID)
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDs gets array of NATRuleIDs from ListNATRules struct
|
||||||
|
func (lnr ListNATRules) IDs() []uint64 {
|
||||||
|
res := make([]uint64, 0, len(lnr.Data))
|
||||||
|
for _, nrc := range lnr.Data {
|
||||||
|
res = append(res, nrc.ID)
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDs gets array of StaticRouteIDs from ListStaticRoutes struct
|
||||||
|
func (lsr ListStaticRoutes) IDs() []uint64 {
|
||||||
|
res := make([]uint64, 0, len(lsr.Data))
|
||||||
|
for _, sr := range lsr.Data {
|
||||||
|
res = append(res, sr.ID)
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDs gets array of RouteIDs from ListRoutes struct
|
||||||
|
func (lr ListRoutes) IDs() []uint64 {
|
||||||
|
res := make([]uint64, 0, len(lr))
|
||||||
|
for _, r := range lr {
|
||||||
|
res = append(res, r.ID)
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDs gets array of NATRuleConfigIDs from ListNatRule struct
|
||||||
|
func (lnrc ListNatRule) IDs() []uint64 {
|
||||||
|
res := make([]uint64, 0, len(lnrc))
|
||||||
|
for _, nrc := range lnrc {
|
||||||
|
res = append(res, nrc.ID)
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
||||||
@@ -336,6 +336,9 @@ type RecordGW struct {
|
|||||||
InfoVNF
|
InfoVNF
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// List NATRules
|
||||||
|
type ListNatRule []ItemNATRule
|
||||||
|
|
||||||
// NAT config
|
// NAT config
|
||||||
type NATConfig struct {
|
type NATConfig struct {
|
||||||
// Network mask
|
// Network mask
|
||||||
@@ -345,7 +348,7 @@ type NATConfig struct {
|
|||||||
Network string `json:"network"`
|
Network string `json:"network"`
|
||||||
|
|
||||||
// Rules
|
// Rules
|
||||||
Rules []ItemNATRule `json:"rules"`
|
Rules ListNatRule `json:"rules"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Main information about NAT
|
// Main information about NAT
|
||||||
|
|||||||
21
samples/config/bvs-config.json
Normal file
21
samples/config/bvs-config.json
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
{
|
||||||
|
"username": "<USERNAME>",
|
||||||
|
"password": "<PASSWORD>",
|
||||||
|
"appId": "<APP_ID>",
|
||||||
|
"appSecret": "<APP_SECRET>",
|
||||||
|
"ssoUrl": "https://bvs-delta.qa.loc:8443",
|
||||||
|
"decortUrl": "https://delta.qa.loc",
|
||||||
|
"domain": "dynamix",
|
||||||
|
"token": {
|
||||||
|
"access_token": "string_token",
|
||||||
|
"token_type": "bearer",
|
||||||
|
"refresh_token": "string_refresh_token",
|
||||||
|
"expiry": "2023-11-24T12:40:27.954150524+03:00"
|
||||||
|
},
|
||||||
|
"retries": 5,
|
||||||
|
"sslSkipVerify": true,
|
||||||
|
"timeout": "5m",
|
||||||
|
"path_cfg": "config",
|
||||||
|
"path_token": "token",
|
||||||
|
"timeToRefresh": 5
|
||||||
|
}
|
||||||
18
samples/config/bvs-config.yml
Normal file
18
samples/config/bvs-config.yml
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
username: <USERNAME>
|
||||||
|
password: <PASSWORD>
|
||||||
|
appId: <APP_ID>
|
||||||
|
appSecret: <APP_SECRET>
|
||||||
|
ssoUrl: https://bvs-delta.qa.loc:8443
|
||||||
|
decortUrl: https://delta.qa.loc
|
||||||
|
domain: dynamix
|
||||||
|
token":
|
||||||
|
access_token: string_token
|
||||||
|
token_type: bearer
|
||||||
|
refresh_token: string_refresh_token
|
||||||
|
expiry: 2023-11-24T12:40:27.954150524+03:00
|
||||||
|
retries: 5
|
||||||
|
sslSkipVerify: true
|
||||||
|
timeout: 5m
|
||||||
|
path_cfg: config
|
||||||
|
path_token: token
|
||||||
|
timeToRefresh: 5
|
||||||
Reference in New Issue
Block a user