Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1f8637400f | ||
| 89831894df | |||
| 92431c5c65 | |||
|
|
c7a2c4ed5a | ||
| 0c44daa241 | |||
|
|
650b1c158b |
199
CHANGELOG.md
199
CHANGELOG.md
@@ -1,202 +1,13 @@
|
||||
## Version 1.11
|
||||
|
||||
### Добавлено
|
||||
|
||||
#### account
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-304 | Опциональное поле `Description` в структуру запроса `UpdateCreateRequest` в cloudapi/account |
|
||||
| BGOS-304 | Опциональное поле `Description` в структуры запроса `CreateRequest`, `UpdateCreateRequest` в cloudbroker/account |
|
||||
| BGOS-304 | Поле `Description` в структуры ответа `ItemRG`, `RecordAccount`, `ItemAccount` в cloudapi/account и cloudbroker/account |
|
||||
| BGOS-316 | Опциональное поле `Reason` в структуру запроса `DisableEnableRequest` в cloudapi/account |
|
||||
| BGOS-316 | Опциональное поле `Reason` в структуры запроса `RestoreRequest`, `DisableAccountsRequest`, `DisableRequest` в cloudbroker/account |
|
||||
|
||||
#### apiaccess
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-306 | Метод `GetDefault` и структура ответа `ItemAPIAccessDefault` в cloudbroker/apiaccess |
|
||||
| BGOS-309 | Обязательные поля `APIGroup`, `APIMethod`, `APIObject` в структуру запроса `APIFindRequest` в cloudbroker/apiaccess |
|
||||
| BGOS-309 | Поле `DPDK` в структуры ответа `CloudAPIEndpoints` и `CloudBrokerEndpoints` в cloudbroker/apiaccess |
|
||||
|
||||
#### audit
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-307 | Опциональное поле `RequestID` в структуру запроса `ListRequest` в cloudapi/audit |
|
||||
| BGOS-337 | Поле `PhysicalNode` в структуру ответа `ItemLinkedJobs` в cloudbroker/audit |
|
||||
| BGOS-395 | Поле `TTL` в структуру ответа `RecordAudit` в cloudbroker/audit |
|
||||
| BGOS-395 | Поля `Args`, `Kwargs`, `RemoteAddr`, `Result`, `TimestampEnd`, `TTL` в структуру ответа `ItemAudit` в cloudbroker/audit |
|
||||
| BGOS-340 | Поле `Tags` в структуре ответа `ItemAudit` в cloudbroker/audit |
|
||||
|
||||
### bservice
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-317 | Опциональное поле `Chipset` в структуру запроса `GroupAddRequest` в cloudapi/bservice |
|
||||
| BGOS-354 | Опциональное поле `Chipset` в структуру запроса `GroupResizeRequest` в cloudapi/bservice |
|
||||
| BGOS-357 | Поле `Chipset` в структуру ответа `ItemGroupCompute` в cloudapi/bservice |
|
||||
|
||||
#### compute
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-311 | Опциональное поле `StackName` в структуру запроса `ListRequest` в cloudbroker/list |
|
||||
| BGOS-312 | Опциональные поля `LoaderType`, `BootType`, `NetworkInterfaceNaming`, `HotResize` в структуру запроса `UpdateRequest` в cloudapi/compute и cloudbroker/compute |
|
||||
| BGOS-312 | Поля `LoaderType`, `BootType`, `NetworkInterfaceNaming`, `HotResize` в структуры ответа `InfoCompute`, `RecordCompute`, `ItemCompute` в cloudapi/compute и cloudbroker/compute |
|
||||
| BGOS-348 | Полe `NID` в структуру ответа `ItemCompute` в cloudbroker/compute |
|
||||
| BGOS-348 | Структуры ответов `ItemDeletedCompute`, `ListDeletedComputes` в cloudbroker/compute |
|
||||
| BGOS-388 | Поля `UpdatedBy`, `SizeAvailable` в структуру ответа `ItemDisk` в cloudapi/compute |
|
||||
| BGOS-388 | Поле `SizeAvailable` в структуру ответа `ItemDisk` в cloudbroker/compute |
|
||||
| BGOS-392 | Метод `ChangeMAC` и структура запроса `ChangeMACRequest` в cloudapi/compute и cloudbroker/compute |
|
||||
| BGOS-403 | Опциональное поле `MACAddr` в cloudapi/compute/netAttach и cloudbroker/compute/netAttach |
|
||||
|
||||
#### disks
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-318 | Опциональное поле `Name` в структуру запроса `DeleteRequest` в cloudbroker/disks |
|
||||
| BGOS-408 | Поля `DeletedBy`, `CreatedBy`, `MachineID`, `MachineName`, `UpdatedTime` и `Milestones` в структуру ответа `ItemDisk` и `RecordDisk` в cloudapi/disks |
|
||||
| BGOS-408 | Поля `DeletedBy`, `CreatedBy`, `UpdatedTime` и `UpdatedBy` в структуру ответа `RecordDisk` в cloudbroker/disks |
|
||||
| BGOS-401 | Поля `SizeAvailable` и `UpdatedBy` в структуру ответа `InfoDisk` в cloudbroker/disks |
|
||||
| BGOS-401 | Поля `SizeAvailable` и `UpdatedBy` в структуры ответа `ItemDisk` и `RecordDisk` в cloudapi/disks |
|
||||
|
||||
#### extnet
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-356 | Опциональное поле `OVSBridge` в структуру запроса `ListRequest` в cloudapi/extnet |
|
||||
| BGOS-351 | Поле `NTP` в структуру ответа `RecordExtNet` в cloudapi/extnet и cloudbroker/extnet |
|
||||
|
||||
#### image
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-315 | Поле `SnapshotID` в структуру ответа `RecordImage` в cloudapi/image |
|
||||
|
||||
#### k8s
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-304 | Поле `Description` в структуру ответа `RecordK8S` в cloudapi/k8s и cloudbroker/k8s |
|
||||
|
||||
#### kvmx86
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-312 | Опциональные поля `LoaderType`, `BootType`, `NetworkInterfaceNaming`, `HotResize` в структуру запроса `CreateBlankRequest` в cloudapi/kvmx86 и cloudbroker/kvmx86 |
|
||||
| BGOS-312 | Опциональное поле `MAC` в структуру запроса `Interface` в cloudapi/kvmx86 и cloudbroker/kvmx86 |
|
||||
|
||||
#### node
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-397 | Метод `SetVFsParams` и структура запроса `SetVFsParamsRequest` в cloudbroker/node |
|
||||
|
||||
#### prometheus
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-405 | Метод `Computes` структура запроса `ComputesRequest` и структура ответа `ComputesData` в cloudbroker/prometheus |
|
||||
|
||||
#### resmon
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-341 | Поля `ID`, `SizeAvailable` в структуру ответа `ItemDisk` сloudbroker/resmon |
|
||||
|
||||
#### sep
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-343 | Метод `GetTemplate` и структура запроса `GetTemplateRequest` в cloudbroker/sep |
|
||||
| BGOS-301 | Метод `ListAvailableSEPAndPools` структура запроса `ListAvailableSEPAndPoolsRequest` и структура ответа `ListAvailableSEP` в cloudapi/sep и cloudbroker/sep |
|
||||
| BGOS-299 | Обязательное поле `Force` в структуру запроса `DelConsumerNodesRequest` в cloudbroker/sep |
|
||||
|
||||
#### stack
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-389 | Структура ответа `LibGuestFSTools` входящая в структуру ответа `Packages` в cloudbroker/stack |
|
||||
|
||||
#### user
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-303 | Опциональное поле `SortBy` в структуру запроса `GetAuditRequest` cloudapi/user |
|
||||
|
||||
#### vins
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-300 | Опциональное поле `Status` в структуру запроса `ListRequest` cloudapi/vins и cloudbroker/vins |
|
||||
## Version 1.11.6
|
||||
|
||||
### Удалено
|
||||
|
||||
#### apiaccess
|
||||
#### Account
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-309 | Обязательное поле `APIName` из структуры запроса `APIFindRequest` в cloudbroker/apiacces |
|
||||
| BGOS-309 | Метод `GetPreGroups` в cloudbroker/apiaccess |
|
||||
| BGOS-309 | Опциональное поле `CreatedBy` из структуры запроса `ListRequest` в cloudbroker/apiaccess |
|
||||
| BGOS-309 | Метод `ListDeletedRequest` и структура запроса `ListDeletedRequest` и в cloudbroker/apiaccess |
|
||||
| BGOS-309 | Поля `CreatedBy`, `UpdatedBy`, `DeletedBy`, `Milestone` из структуры ответа `ItemAPIAccess` в cloudbroker/apiaccess |
|
||||
| BGOS-553 | Метод `Create` в cloudapi/account |
|
||||
|
||||
#### compute
|
||||
#### Image
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-338 | Опциональное поле `Depresent` из структуры запроса `StopRequest` в cloudbroker/compute |
|
||||
| BGOS-344 | Методы `RepairBootFS`, `MassRepairBootFS`, `Registration` в cloudbroker/compute |
|
||||
| BGOS-353 | Поля `PCISlot`, `BusNumber` из структуры ответа `InfoDisk` в cloudapi/compute и cloudbroker/compute |
|
||||
|
||||
#### disks
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-298 | Опциональные поля `Type, SSDSize` из структуры запроса `CreateRequest` в cloudapi/disks и cloudbroker/disks |
|
||||
| BGOS-338 | Обязательное поле `GID` из структуры запроса `CreateRequest` в cloudapi/disks и cloudbroker/disks |
|
||||
|
||||
#### image
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-338 | Обязательное поле `GID` из структур запроса `CreateRequest`, `CreateCDROMImageRequest` в cloudbroker/image |
|
||||
|
||||
#### node
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-308 | Опциональное поле `VDiskAction` из структуры запроса `MaintenanceRequest` в cloudbroker/node |
|
||||
|
||||
#### rg
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-342 | Опциональное поле `RegisterComputes` из структур запроса `CreateRequest`, `UpdateRequest` в cloudapi/rg и cloudbroker/rg |
|
||||
|
||||
### Исправлено
|
||||
|
||||
#### apiaccess
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-308 | Изменены все теги `json` и `url` в структурах ответов и запросов с `CamelCase` на `snake_case` в cloudbroker/apiaccess |
|
||||
|
||||
#### audit
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-346 | Изменены все теги `json` и `url` в структурах запросов с `CamelCase` на `snake_case` в cloudapi/audit и cloudbroker/audit |
|
||||
|
||||
#### compute
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-314 | Измененен тип с `[]uint64` на `map[strint]uint64` полей `PresentTo` в структурах ответа `ItemComputeDisk`, `ItemDisk` в cloudapi/compute и cloudbroker/compute |
|
||||
| BGOS-355 | Переименованны поля с `Pinned` на `PinnedToStack` в структурах ответа `InfoCompute, RecordCompute, ItemCompute` в cloudapi/compute и cloudbroker/compute |
|
||||
| BGOS-355 | Изменен тип поля с `PinnedToStack` (ранее `Pinned`) с `bool` на `int` в структурах ответа `InfoCompute, RecordCompute` в cloudbroker/compute |
|
||||
| BGOS-388 | Изменен json тег поля `PCISlot` с `pciSlot` на `pci_slot` в структурах ответа `ItemDisk` в cloudapi/compute и cloudbroker/compute |
|
||||
| BGOS-392 | Изменены все теги `json` и `url` в структуре запроса `ChangeIPRequest` с `CamelCase` на `snake_case` в cloudapi/compute и cloudbroker/compute |
|
||||
|
||||
#### disks
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-314 | Измененен тип с `[]uint64` на `map[strint]uint64` полей `PresentTo` в структурах ответа `ItemDiskUnattached`, `RecordDisk`, `ItemDisk`, `InfoDisk` в cloudapi/disks и cloudbroker/disks |
|
||||
| BGOS-408 | Перенесены поля с `MachindeID` и `MachineName` из структуры ответа `ItemDisk` в `RecordDisk` в cloudbroker/disks |
|
||||
|
||||
#### image
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-314 | Измененен тип с `[]uint64` на `map[strint]uint64` полей `PresentTo` в структурах ответа `ItemImage`, `RecordImage` в cloudapi/image и cloudbroker/image |
|
||||
|
||||
#### image
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-305 | Изменен тип опционального поля `AccountIDs` c []uint64 на []int64 в моделях `GrantAccessRequest`, `RevokeAccessRequest` в cloudbroker/image |
|
||||
|
||||
#### resmon
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-341 | Изменен тип поле `SizeUsed`, `SizeMax` с int64 на float64 в структуре ответа `ItemDisk` сloudbroker/resmon |
|
||||
|
||||
#### sep
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-398 | Обязательные поля `Trust` и `Spoofchk` заменены на `VFParams` в структуре запроса `SetVFsNumberRequest` в cloudbroker/node |
|
||||
| BGOS-552 | Метод `UploadImageFile` в cloudbroker/image |
|
||||
39
README.md
39
README.md
@@ -79,6 +79,8 @@ Decort SDK - это библиотека, написанная на языке G
|
||||
- [Создание универсального клиента](#создание-универсального-клиента)
|
||||
- [Пример создания универсального клиента](#пример-создания-универсального-клиента)
|
||||
- [Пример выполнения запроса](#пример-выполнения-запроса-4)
|
||||
- [Проверка соответствия версии платформы и версии dynamix](#проверка-соответствия-версии-платформы-и-версии-dynamix)
|
||||
- [Пример выполнения запроса](#пример-выполнения-запроса-5)
|
||||
|
||||
## Установка
|
||||
|
||||
@@ -114,6 +116,7 @@ go get -u repository.basistech.ru/BASIS/decort-golang-sdk
|
||||
- `KVMx86` - создание виртуальной машины x86;
|
||||
- `LB` - управление балансировщиками нагрузки;
|
||||
- `Locations` - получение информации о grid площадки;
|
||||
- `Prometheus` - получение статистики prometheus;
|
||||
- `RG` - управление ресурсными группами аккаунта;
|
||||
- `SEP` - управление storage endpoint (sep);
|
||||
- `Stack` - получение информации о вычислительных узлах;
|
||||
@@ -299,8 +302,9 @@ func main() {
|
||||
- `pkg/cloudapi/kvmx86` - для `KVMX86`
|
||||
- `pkg/cloudapi/lb` - для `LB`
|
||||
- `pkg/cloudapi/locations` - для `Locations`
|
||||
- `pkg/cloudapi/prometheus` - для `Prometheus`
|
||||
- `pkg/cloudapi/rg` - для `RG`
|
||||
- `pkg/cloudbroker/sep` - для `SEP`
|
||||
- `pkg/cloudapi/sep` - для `SEP`
|
||||
- `pkg/cloudapi/stack` - для `Stack`
|
||||
- `pkg/cloudapi/tasks` - для `Tasks`
|
||||
- `pkg/cloudapi/vfpool` - для `VFPool`
|
||||
@@ -486,6 +490,7 @@ func main() {
|
||||
- `.KVMx86()` - для работы с `KVMX86`
|
||||
- `.LB()` - для работы с `LB`
|
||||
- `.Locations()` - для работы с `Locations`
|
||||
- `.Prometheus()` - для работы с `Prometheus`
|
||||
- `.RG()` - для работы с `RG`
|
||||
- `.SEP()` - для работы с `SEP`
|
||||
- `.Stack()` - для работы с `Stack`
|
||||
@@ -1601,4 +1606,36 @@ func main() {
|
||||
|
||||
fmt.Println(res)
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
## Проверка соответствия версии платформы и версии dynamix
|
||||
|
||||
С версии 1.11.5 для каждого клиента добавлен метод `Check` для проверки соответствия decort-sdk и платформы dynamix.
|
||||
В случае соответсвия decort-sdk и платформы dynamix возвращается структура, содержащая информацию о версии и актуальном билде платформы.
|
||||
|
||||
#### Пример выполнения запроса
|
||||
|
||||
```go
|
||||
import (
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/config"
|
||||
)
|
||||
|
||||
func main(){
|
||||
// Настройка конфигурации
|
||||
config := config.Config{
|
||||
AppID: "<APP_ID>",
|
||||
AppSecret: "<APP_SECRET>",
|
||||
SSOURL: "https://sso.digitalenergy.online",
|
||||
DecortURL: "https://mr4.digitalenergy.online",
|
||||
Retries: 5,
|
||||
SSLSkipVerify: true,
|
||||
}
|
||||
|
||||
// Создание клиента
|
||||
client := decort.New(config)
|
||||
|
||||
// Проверка соответствия версии
|
||||
checkInfo, err := client.Check()
|
||||
}
|
||||
```
|
||||
88
check.go
Normal file
88
check.go
Normal file
@@ -0,0 +1,88 @@
|
||||
package decortsdk
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants"
|
||||
)
|
||||
|
||||
type CheckInfo struct {
|
||||
Version string `json:"version"`
|
||||
Build uint64 `json:"build"`
|
||||
}
|
||||
|
||||
const versionURL = "/system/info/version"
|
||||
|
||||
func (de DecortClient) Check() (*CheckInfo, error) {
|
||||
res, err := de.DecortApiCall(context.Background(), http.MethodGet, versionURL, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
info := CheckInfo{}
|
||||
|
||||
err = json.Unmarshal([]byte(strings.Replace(strings.Trim(string(res), `"`), "\\", "", -1)), &info)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if v, ok := constants.VersionMap[info.Version]; ok {
|
||||
if v == "-" {
|
||||
return &info, nil
|
||||
}
|
||||
return nil, errors.New(fmt.Sprintf("SDK don't support platform version %s, please use %s SDK version", info.Version, v))
|
||||
}
|
||||
|
||||
return nil, errors.New(fmt.Sprintf("platform version %s isn't supported", info.Version))
|
||||
}
|
||||
|
||||
func (bvs BVSDecortClient) Check() (*CheckInfo, error) {
|
||||
res, err := bvs.DecortApiCall(context.Background(), http.MethodGet, versionURL, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
info := CheckInfo{}
|
||||
|
||||
err = json.Unmarshal([]byte(strings.Replace(strings.Trim(string(res), `"`), "\\", "", -1)), &info)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if v, ok := constants.VersionMap[info.Version]; ok {
|
||||
if v == "-" {
|
||||
return &info, nil
|
||||
}
|
||||
return nil, errors.New(fmt.Sprintf("SDK don't support platform version %s, please use %s SDK version", info.Version, v))
|
||||
}
|
||||
|
||||
return nil, errors.New(fmt.Sprintf("platform version %s isn't supported", info.Version))
|
||||
}
|
||||
|
||||
func (ldc LegacyDecortClient) Check() (*CheckInfo, error) {
|
||||
res, err := ldc.DecortApiCall(context.Background(), http.MethodGet, versionURL, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
info := CheckInfo{}
|
||||
|
||||
err = json.Unmarshal([]byte(strings.Replace(strings.Trim(string(res), `"`), "\\", "", -1)), &info)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if v, ok := constants.VersionMap[info.Version]; ok {
|
||||
if v == "-" {
|
||||
return &info, nil
|
||||
}
|
||||
return nil, errors.New(fmt.Sprintf("SDK don't support platform version %s, please use %s SDK version", info.Version, v))
|
||||
}
|
||||
|
||||
return nil, errors.New(fmt.Sprintf("platform version %s isn't supported", info.Version))
|
||||
}
|
||||
@@ -12,3 +12,7 @@ var FileName = map[string]string{
|
||||
}
|
||||
|
||||
var K8sValues = []string{"labels", "taints", "annotations, additionalSANs"}
|
||||
|
||||
var VersionMap = map[string]string{
|
||||
"4.3.0": "-",
|
||||
}
|
||||
|
||||
@@ -271,6 +271,11 @@ func registerAllValidators(validate *validator.Validate) error {
|
||||
return err
|
||||
}
|
||||
|
||||
err = validate.RegisterValidation("loaderType", loaderTypeValidator)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = validate.RegisterValidation("language", languageValidator)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@@ -1,75 +0,0 @@
|
||||
package account
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// CreateRequest struct for creating account
|
||||
type CreateRequest struct {
|
||||
// Display name
|
||||
// Required: true
|
||||
Name string `url:"name" json:"name" validate:"required"`
|
||||
|
||||
// Name of the account
|
||||
// Required: true
|
||||
Username string `url:"username" json:"username" validate:"required"`
|
||||
|
||||
// Email
|
||||
// Required: false
|
||||
EmailAddress string `url:"emailaddress,omitempty" json:"emailaddress,omitempty" validate:"omitempty,email"`
|
||||
|
||||
// Max size of memory in MB
|
||||
// Required: false
|
||||
MaxMemoryCapacity int64 `url:"maxMemoryCapacity,omitempty" json:"maxMemoryCapacity,omitempty"`
|
||||
|
||||
// Max size of aggregated vdisks in GB
|
||||
// Required: false
|
||||
MaxVDiskCapacity int64 `url:"maxVDiskCapacity,omitempty" json:"maxVDiskCapacity,omitempty"`
|
||||
|
||||
// Max number of CPU cores
|
||||
// Required: false
|
||||
MaxCPUCapacity int64 `url:"maxCPUCapacity,omitempty" json:"maxCPUCapacity,omitempty"`
|
||||
|
||||
// Max sent/received network transfer peering
|
||||
// Required: false
|
||||
MaxNetworkPeerTransfer int64 `url:"maxNetworkPeerTransfer,omitempty" json:"maxNetworkPeerTransfer,omitempty"`
|
||||
|
||||
// Max number of assigned public IPs
|
||||
// Required: false
|
||||
MaxNumPublicIP int64 `url:"maxNumPublicIP,omitempty" json:"maxNumPublicIP,omitempty"`
|
||||
|
||||
// If true send emails when a user is granted access to resources
|
||||
// Required: false
|
||||
SendAccessEmails bool `url:"sendAccessEmails" json:"sendAccessEmails"`
|
||||
|
||||
// Limit (positive) or disable (0) GPU resources
|
||||
// Required: false
|
||||
GPUUnits int64 `url:"gpu_units,omitempty" json:"gpu_units,omitempty"`
|
||||
}
|
||||
|
||||
// Create creates account
|
||||
// Setting a cloud unit maximum to -1 or empty will not put any restrictions on the resource
|
||||
func (a Account) Create(ctx context.Context, req CreateRequest) (uint64, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return 0, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudapi/account/create"
|
||||
|
||||
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseUint(string(res), 10, 64)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
@@ -74,7 +74,7 @@ type GroupAddRequest struct {
|
||||
|
||||
//Chipset "i440fx" or "Q35
|
||||
//Required: false
|
||||
Chipset string `url:"chipset,omitempty" json:"chipset,omitempty" validate:"chipset"`
|
||||
Chipset string `url:"chipset,omitempty" json:"chipset,omitempty" validate:"chipset,omitempty"`
|
||||
}
|
||||
|
||||
// GetRAM returns RAM field values
|
||||
|
||||
@@ -39,10 +39,6 @@ type CreateTemplateFromBlankRequest struct {
|
||||
// Required: false
|
||||
AccountID uint64 `url:"accountId,omitempty" json:"accountId,omitempty"`
|
||||
|
||||
// SEP ID
|
||||
// Required: false
|
||||
SepID uint64 `url:"sepId,omitempty" json:"sepId,omitempty"`
|
||||
|
||||
// Pool for image create
|
||||
// Required: false
|
||||
PoolName string `url:"poolName,omitempty" json:"poolName,omitempty"`
|
||||
|
||||
@@ -494,8 +494,8 @@ type RecordCompute struct {
|
||||
// Userdata
|
||||
Userdata interface{} `json:"userdata"`
|
||||
|
||||
// vGPU IDs
|
||||
VGPUs []uint64 `json:"vgpus"`
|
||||
// vGPUs list
|
||||
VGPUs []VGPUItem `json:"vgpus"`
|
||||
|
||||
// Virtual image ID
|
||||
VirtualImageID uint64 `json:"virtualImageId"`
|
||||
@@ -507,6 +507,65 @@ type RecordCompute struct {
|
||||
VNCPassword string `json:"vncPasswd"`
|
||||
}
|
||||
|
||||
type VGPUItem struct {
|
||||
// ID
|
||||
ID uint64 `json:"id"`
|
||||
|
||||
// GID
|
||||
GID uint64 `json:"gid"`
|
||||
|
||||
// Type
|
||||
Type string `json:"type"`
|
||||
|
||||
// Mode
|
||||
Mode string `json:"mode"`
|
||||
|
||||
// Status
|
||||
Status string `json:"status"`
|
||||
|
||||
// ProfileID
|
||||
ProfileID uint64 `json:"profileId"`
|
||||
|
||||
// RAM
|
||||
RAM uint64 `json:"ram"`
|
||||
|
||||
// LastUpdateTime
|
||||
LastUpdateTime uint64 `json:"lastUpdateTime"`
|
||||
|
||||
// CreatedTime
|
||||
CreatedTime uint64 `json:"createdTime"`
|
||||
|
||||
// DeletedTime
|
||||
DeletedTime uint64 `json:"deletedTime"`
|
||||
|
||||
// VMID
|
||||
VMID uint64 `json:"vmid"`
|
||||
|
||||
// PGPuid
|
||||
PGPuid uint64 `json:"pgpuid"`
|
||||
|
||||
// ReferenceID
|
||||
ReferenceID string `json:"referenceId"`
|
||||
|
||||
// AccountID
|
||||
AccountID uint64 `json:"accountId"`
|
||||
|
||||
// RgID
|
||||
RgID uint64 `json:"rgId"`
|
||||
|
||||
// LastClaimedBy
|
||||
LastClaimedBy uint64 `json:"lastClaimedBy"`
|
||||
|
||||
// PCISlot
|
||||
PCISlot uint64 `json:"pciSlot"`
|
||||
|
||||
// BusNumber
|
||||
BusNumber uint64 `json:"bus_number"`
|
||||
|
||||
// GUID
|
||||
GUID uint64 `json:"guid"`
|
||||
}
|
||||
|
||||
// Information about libvirt settings
|
||||
type LibvirtSettings struct {
|
||||
// TX mode
|
||||
@@ -754,7 +813,7 @@ type ItemComputeDisk struct {
|
||||
Shareable bool `json:"shareable"`
|
||||
|
||||
// Size available
|
||||
SizeAvailable uint64 `json:"sizeAvailable"`
|
||||
SizeAvailable float64 `json:"sizeAvailable"`
|
||||
|
||||
// Size max
|
||||
SizeMax uint64 `json:"sizeMax"`
|
||||
@@ -775,7 +834,7 @@ type ItemComputeDisk struct {
|
||||
Type string `json:"type"`
|
||||
|
||||
// Updated by
|
||||
UpdatedBy uint64 `json:"updatedBy"`
|
||||
UpdatedBy string `json:"updatedBy"`
|
||||
|
||||
// Virtual machine ID
|
||||
VMID uint64 `json:"vmid"`
|
||||
|
||||
@@ -30,24 +30,21 @@ type UpdateRequest struct {
|
||||
// Default: none
|
||||
NumaAffinity string `url:"numaAffinity,omitempty" json:"numaAffinity,omitempty" validate:"omitempty,numaAffinity"`
|
||||
|
||||
// Run VM on dedicated CPUs. To use this feature, the system must be pre-configured by allocating CPUs on the physical node
|
||||
// Run VM on dedicated CPUs. To use this feature, the system must be pre-configured by allocating CPUs on the physical node, true or false
|
||||
// Required: false
|
||||
// Default: false
|
||||
CPUPin bool `url:"cpupin" json:"cpupin"`
|
||||
CPUPin interface{} `url:"cpupin,omitempty" json:"cpupin,omitempty" validate:"omitempty,isBool"`
|
||||
|
||||
// Type of the emulated system, Q35 or i440fx
|
||||
// Required: false
|
||||
Chipset string `url:"chipset,omitempty" json:"chipset,omitempty" validate:"omitempty,chipset"`
|
||||
|
||||
// Use Huge Pages to allocate RAM of the virtual machine. The system must be pre-configured by allocating Huge Pages on the physical node
|
||||
// Use Huge Pages to allocate RAM of the virtual machine. The system must be pre-configured by allocating Huge Pages on the physical node, true or false
|
||||
// Required: false
|
||||
// Default: false
|
||||
HPBacked bool `url:"hpBacked" json:"hpBacked"`
|
||||
HPBacked interface{} `url:"hpBacked,omitempty" json:"hpBacked,omitempty" validate:"omitempty,isBool"`
|
||||
|
||||
// Auto start when node restarted
|
||||
// Auto start when node restarted, true or false
|
||||
// Required: false
|
||||
// Default: false
|
||||
AutoStart bool `url:"autoStart" json:"autoStart"`
|
||||
AutoStart interface{} `url:"autoStart,omitempty" json:"autoStart,omitempty" validate:"omitempty,isBool"`
|
||||
|
||||
// Recommended isolated CPUs. Field is ignored if compute.cpupin=False or compute.pinned=False
|
||||
// Required: false
|
||||
@@ -65,9 +62,9 @@ type UpdateRequest struct {
|
||||
// Required: false
|
||||
NetworkInterfaceNaming string `url:"networkInterfaceNaming,omitempty" json:"networkInterfaceNaming,omitempty" validate:"omitempty,networkInterfaceNaming"`
|
||||
|
||||
// Does this machine supports hot resize
|
||||
// Does this machine supports hot resize, true or false
|
||||
// Required: false
|
||||
HotResize bool `url:"hotResize,omitempty" json:"hotResize,omitempty"`
|
||||
HotResize interface{} `url:"hotResize,omitempty" json:"hotResize,omitempty" validate:"omitempty,isBool"`
|
||||
}
|
||||
|
||||
// Update updates some properties of the compute
|
||||
|
||||
@@ -45,10 +45,6 @@ type FromPlatformDiskRequest struct {
|
||||
// Required: false
|
||||
AccountID uint64 `url:"accountId,omitempty" json:"accountId,omitempty"`
|
||||
|
||||
// SEP ID
|
||||
// Required: false
|
||||
SepID uint64 `url:"sepId,omitempty" json:"sepId,omitempty"`
|
||||
|
||||
// Pool for image create
|
||||
// Required: false
|
||||
PoolName string `url:"poolName,omitempty" json:"poolName,omitempty"`
|
||||
|
||||
@@ -105,7 +105,7 @@ type ItemDisk struct {
|
||||
SepID uint64 `json:"sepId"`
|
||||
|
||||
// Size available
|
||||
SizeAvailable uint64 `json:"sizeAvailable"`
|
||||
SizeAvailable float64 `json:"sizeAvailable"`
|
||||
|
||||
// Size max
|
||||
SizeMax uint64 `json:"sizeMax"`
|
||||
@@ -463,7 +463,7 @@ type RecordDisk struct {
|
||||
Shareable bool `json:"shareable"`
|
||||
|
||||
// Size available
|
||||
SizeAvailable uint64 `json:"sizeAvailable"`
|
||||
SizeAvailable float64 `json:"sizeAvailable"`
|
||||
|
||||
// Size max
|
||||
SizeMax uint64 `json:"sizeMax"`
|
||||
|
||||
@@ -28,6 +28,9 @@ type ItemLocation struct {
|
||||
|
||||
// CKey
|
||||
CKey string `json:"_ckey"`
|
||||
|
||||
// Support of SDN
|
||||
SDNSupport bool `json:"sdn_support"`
|
||||
}
|
||||
|
||||
// List of locations
|
||||
|
||||
8
pkg/cloudapi/prometheus.go
Normal file
8
pkg/cloudapi/prometheus.go
Normal file
@@ -0,0 +1,8 @@
|
||||
package cloudapi
|
||||
|
||||
import "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/prometheus"
|
||||
|
||||
// Accessing the Resmon method group
|
||||
func (ca *CloudAPI) Prometheus() *prometheus.Prometheus {
|
||||
return prometheus.New(ca.client)
|
||||
}
|
||||
57
pkg/cloudapi/prometheus/compute_cpu_load.go
Normal file
57
pkg/cloudapi/prometheus/compute_cpu_load.go
Normal file
@@ -0,0 +1,57 @@
|
||||
package prometheus
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
type ComputeCPULoadRequest struct {
|
||||
// Compute ID
|
||||
// Required: true
|
||||
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
|
||||
|
||||
// Time to loads of statistic in seconds
|
||||
// Required: false
|
||||
ForLast uint64 `url:"forLast,omitempty" json:"forLast,omitempty"`
|
||||
|
||||
// The reading interval in seconds
|
||||
// Required: false
|
||||
Step uint64 `url:"step,omitempty" json:"step,omitempty"`
|
||||
|
||||
// Number of zeros after the decimal point
|
||||
// Required: false
|
||||
DecimalPlaces uint64 `url:"decimalPlaces,omitempty" json:"decimalPlaces,omitempty"`
|
||||
}
|
||||
|
||||
// Per-second CPU time consumed by Compute in percent, average over the time step specified
|
||||
func (p Prometheus) ComputeCPULoad(ctx context.Context, req ComputeCPULoadRequest) (*PrometheusData, error) {
|
||||
res, err := p.ComputeCPULoadRaw(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
info := PrometheusData{}
|
||||
|
||||
err = json.Unmarshal(res, &info)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &info, nil
|
||||
}
|
||||
|
||||
// GetRaw gets information about compute as an array of bytes
|
||||
func (p Prometheus) ComputeCPULoadRaw(ctx context.Context, req ComputeCPULoadRequest) ([]byte, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudapi/prometheus/computeCPUload"
|
||||
|
||||
res, err := p.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
return res, err
|
||||
}
|
||||
53
pkg/cloudapi/prometheus/compute_memory_available.go
Normal file
53
pkg/cloudapi/prometheus/compute_memory_available.go
Normal file
@@ -0,0 +1,53 @@
|
||||
package prometheus
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
type ComputeMemoryAvailableRequest struct {
|
||||
// Compute ID
|
||||
// Required: true
|
||||
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
|
||||
|
||||
// Time to loads of statistic in seconds
|
||||
// Required: false
|
||||
ForLast uint64 `url:"forLast,omitempty" json:"forLast,omitempty"`
|
||||
|
||||
// The reading interval in seconds
|
||||
// Required: false
|
||||
Step uint64 `url:"step,omitempty" json:"step,omitempty"`
|
||||
}
|
||||
|
||||
// Available Memory
|
||||
func (p Prometheus) ComputeMemoryAvailable(ctx context.Context, req ComputeMemoryAvailableRequest) (*PrometheusData, error) {
|
||||
res, err := p.ComputeMemoryAvailableRaw(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
info := PrometheusData{}
|
||||
|
||||
err = json.Unmarshal(res, &info)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &info, nil
|
||||
}
|
||||
|
||||
// GetRaw gets information about compute as an array of bytes
|
||||
func (p Prometheus) ComputeMemoryAvailableRaw(ctx context.Context, req ComputeMemoryAvailableRequest) ([]byte, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudapi/prometheus/computeMemoryAvailable"
|
||||
|
||||
res, err := p.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
return res, err
|
||||
}
|
||||
53
pkg/cloudapi/prometheus/compute_memory_unused.go
Normal file
53
pkg/cloudapi/prometheus/compute_memory_unused.go
Normal file
@@ -0,0 +1,53 @@
|
||||
package prometheus
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
type ComputeMemoryUnusedRequest struct {
|
||||
// Compute ID
|
||||
// Required: true
|
||||
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
|
||||
|
||||
// Time to loads of statistic in seconds
|
||||
// Required: false
|
||||
ForLast uint64 `url:"forLast,omitempty" json:"forLast,omitempty"`
|
||||
|
||||
// The reading interval in seconds
|
||||
// Required: false
|
||||
Step uint64 `url:"step,omitempty" json:"step,omitempty"`
|
||||
}
|
||||
|
||||
// Unused Memory
|
||||
func (p Prometheus) ComputeMemoryUnused(ctx context.Context, req ComputeMemoryUnusedRequest) (*PrometheusData, error) {
|
||||
res, err := p.ComputeMemoryUnusedRaw(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
info := PrometheusData{}
|
||||
|
||||
err = json.Unmarshal(res, &info)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &info, nil
|
||||
}
|
||||
|
||||
// GetRaw gets information about compute as an array of bytes
|
||||
func (p Prometheus) ComputeMemoryUnusedRaw(ctx context.Context, req ComputeMemoryUnusedRequest) ([]byte, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudapi/prometheus/computeMemoryUnused"
|
||||
|
||||
res, err := p.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
return res, err
|
||||
}
|
||||
53
pkg/cloudapi/prometheus/compute_memory_usable.go
Normal file
53
pkg/cloudapi/prometheus/compute_memory_usable.go
Normal file
@@ -0,0 +1,53 @@
|
||||
package prometheus
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
type ComputeMemoryUsableRequest struct {
|
||||
// Compute ID
|
||||
// Required: true
|
||||
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
|
||||
|
||||
// Time to loads of statistic in seconds
|
||||
// Required: false
|
||||
ForLast uint64 `url:"forLast,omitempty" json:"forLast,omitempty"`
|
||||
|
||||
// The reading interval in seconds
|
||||
// Required: false
|
||||
Step uint64 `url:"step,omitempty" json:"step,omitempty"`
|
||||
}
|
||||
|
||||
// Usable Memory
|
||||
func (p Prometheus) ComputeMemoryUsable(ctx context.Context, req ComputeMemoryUsableRequest) (*PrometheusData, error) {
|
||||
res, err := p.ComputeMemoryUsableRaw(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
info := PrometheusData{}
|
||||
|
||||
err = json.Unmarshal(res, &info)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &info, nil
|
||||
}
|
||||
|
||||
// GetRaw gets information about compute as an array of bytes
|
||||
func (p Prometheus) ComputeMemoryUsableRaw(ctx context.Context, req ComputeMemoryUsableRequest) ([]byte, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudapi/prometheus/computeMemoryUsable"
|
||||
|
||||
res, err := p.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
return res, err
|
||||
}
|
||||
53
pkg/cloudapi/prometheus/compute_memory_usage.go
Normal file
53
pkg/cloudapi/prometheus/compute_memory_usage.go
Normal file
@@ -0,0 +1,53 @@
|
||||
package prometheus
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
type ComputeMemoryUsageRequest struct {
|
||||
// Compute ID
|
||||
// Required: true
|
||||
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
|
||||
|
||||
// Time to loads of statistic in seconds
|
||||
// Required: false
|
||||
ForLast uint64 `url:"forLast,omitempty" json:"forLast,omitempty"`
|
||||
|
||||
// The reading interval in seconds
|
||||
// Required: false
|
||||
Step uint64 `url:"step,omitempty" json:"step,omitempty"`
|
||||
}
|
||||
|
||||
// Memory Usage
|
||||
func (p Prometheus) ComputeMemoryUsage(ctx context.Context, req ComputeMemoryUsageRequest) (*PrometheusData, error) {
|
||||
res, err := p.ComputeMemoryUsageRaw(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
info := PrometheusData{}
|
||||
|
||||
err = json.Unmarshal(res, &info)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &info, nil
|
||||
}
|
||||
|
||||
// GetRaw gets information about compute as an array of bytes
|
||||
func (p Prometheus) ComputeMemoryUsageRaw(ctx context.Context, req ComputeMemoryUsageRequest) ([]byte, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudapi/prometheus/computeMemoryUsage"
|
||||
|
||||
res, err := p.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
return res, err
|
||||
}
|
||||
53
pkg/cloudapi/prometheus/compute_memory_used.go
Normal file
53
pkg/cloudapi/prometheus/compute_memory_used.go
Normal file
@@ -0,0 +1,53 @@
|
||||
package prometheus
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
type ComputeMemoryUsedRequest struct {
|
||||
// Compute ID
|
||||
// Required: true
|
||||
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
|
||||
|
||||
// Time to loads of statistic in seconds
|
||||
// Required: false
|
||||
ForLast uint64 `url:"forLast,omitempty" json:"forLast,omitempty"`
|
||||
|
||||
// The reading interval in seconds
|
||||
// Required: false
|
||||
Step uint64 `url:"step,omitempty" json:"step,omitempty"`
|
||||
}
|
||||
|
||||
// Used Memory
|
||||
func (p Prometheus) ComputeMemoryUsed(ctx context.Context, req ComputeMemoryUsedRequest) (*PrometheusData, error) {
|
||||
res, err := p.ComputeMemoryUsedRaw(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
info := PrometheusData{}
|
||||
|
||||
err = json.Unmarshal(res, &info)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &info, nil
|
||||
}
|
||||
|
||||
// GetRaw gets information about compute as an array of bytes
|
||||
func (p Prometheus) ComputeMemoryUsedRaw(ctx context.Context, req ComputeMemoryUsedRequest) ([]byte, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudapi/prometheus/computeMemoryUsed"
|
||||
|
||||
res, err := p.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
return res, err
|
||||
}
|
||||
57
pkg/cloudapi/prometheus/compute_read_bytes.go
Normal file
57
pkg/cloudapi/prometheus/compute_read_bytes.go
Normal file
@@ -0,0 +1,57 @@
|
||||
package prometheus
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
type ComputeReadBytesRequest struct {
|
||||
// Compute ID
|
||||
// Required: true
|
||||
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
|
||||
|
||||
// Time to loads of statistic in seconds
|
||||
// Required: false
|
||||
ForLast uint64 `url:"forLast,omitempty" json:"forLast,omitempty"`
|
||||
|
||||
// The reading interval in seconds
|
||||
// Required: false
|
||||
Step uint64 `url:"step,omitempty" json:"step,omitempty"`
|
||||
|
||||
// Number of zeros after the decimal point
|
||||
// Required: false
|
||||
DecimalPlaces uint64 `url:"decimalPlaces,omitempty" json:"decimalPlaces,omitempty"`
|
||||
}
|
||||
|
||||
// Read Bytes
|
||||
func (p Prometheus) ComputeReadBytes(ctx context.Context, req ComputeReadBytesRequest) (*PrometheusData, error) {
|
||||
res, err := p.ComputeReadBytesRaw(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
info := PrometheusData{}
|
||||
|
||||
err = json.Unmarshal(res, &info)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &info, nil
|
||||
}
|
||||
|
||||
// GetRaw gets information about compute as an array of bytes
|
||||
func (p Prometheus) ComputeReadBytesRaw(ctx context.Context, req ComputeReadBytesRequest) ([]byte, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudapi/prometheus/computeReadBytes"
|
||||
|
||||
res, err := p.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
return res, err
|
||||
}
|
||||
57
pkg/cloudapi/prometheus/compute_read_requests.go
Normal file
57
pkg/cloudapi/prometheus/compute_read_requests.go
Normal file
@@ -0,0 +1,57 @@
|
||||
package prometheus
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
type ComputeReadRequestsRequest struct {
|
||||
// Compute ID
|
||||
// Required: true
|
||||
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
|
||||
|
||||
// Time to loads of statistic in seconds
|
||||
// Required: false
|
||||
ForLast uint64 `url:"forLast,omitempty" json:"forLast,omitempty"`
|
||||
|
||||
// The reading interval in seconds
|
||||
// Required: false
|
||||
Step uint64 `url:"step,omitempty" json:"step,omitempty"`
|
||||
|
||||
// Number of zeros after the decimal point
|
||||
// Required: false
|
||||
DecimalPlaces uint64 `url:"decimalPlaces,omitempty" json:"decimalPlaces,omitempty"`
|
||||
}
|
||||
|
||||
// Read Requests
|
||||
func (p Prometheus) ComputeReadRequests(ctx context.Context, req ComputeReadRequestsRequest) (*PrometheusData, error) {
|
||||
res, err := p.ComputeReadRequestsRaw(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
info := PrometheusData{}
|
||||
|
||||
err = json.Unmarshal(res, &info)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &info, nil
|
||||
}
|
||||
|
||||
// GetRaw gets information about compute as an array of bytes
|
||||
func (p Prometheus) ComputeReadRequestsRaw(ctx context.Context, req ComputeReadRequestsRequest) ([]byte, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudapi/prometheus/computeReadRequests"
|
||||
|
||||
res, err := p.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
return res, err
|
||||
}
|
||||
57
pkg/cloudapi/prometheus/compute_receive_bytes.go
Normal file
57
pkg/cloudapi/prometheus/compute_receive_bytes.go
Normal file
@@ -0,0 +1,57 @@
|
||||
package prometheus
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
type ComputeReceiveBytesRequest struct {
|
||||
// Compute ID
|
||||
// Required: true
|
||||
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
|
||||
|
||||
// Time to loads of statistic in seconds
|
||||
// Required: false
|
||||
ForLast uint64 `url:"forLast,omitempty" json:"forLast,omitempty"`
|
||||
|
||||
// The reading interval in seconds
|
||||
// Required: false
|
||||
Step uint64 `url:"step,omitempty" json:"step,omitempty"`
|
||||
|
||||
// Number of zeros after the decimal point
|
||||
// Required: false
|
||||
DecimalPlaces uint64 `url:"decimalPlaces,omitempty" json:"decimalPlaces,omitempty"`
|
||||
}
|
||||
|
||||
// Receive Bytes
|
||||
func (p Prometheus) ComputeReceiveBytes(ctx context.Context, req ComputeReceiveBytesRequest) (*PrometheusData, error) {
|
||||
res, err := p.ComputeReceiveBytesRaw(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
info := PrometheusData{}
|
||||
|
||||
err = json.Unmarshal(res, &info)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &info, nil
|
||||
}
|
||||
|
||||
// GetRaw gets information about compute as an array of bytes
|
||||
func (p Prometheus) ComputeReceiveBytesRaw(ctx context.Context, req ComputeReceiveBytesRequest) ([]byte, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudapi/prometheus/computeReceiveBytes"
|
||||
|
||||
res, err := p.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
return res, err
|
||||
}
|
||||
57
pkg/cloudapi/prometheus/compute_receive_packets.go
Normal file
57
pkg/cloudapi/prometheus/compute_receive_packets.go
Normal file
@@ -0,0 +1,57 @@
|
||||
package prometheus
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
type ComputeReceivePacketsRequest struct {
|
||||
// Compute ID
|
||||
// Required: true
|
||||
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
|
||||
|
||||
// Time to loads of statistic in seconds
|
||||
// Required: false
|
||||
ForLast uint64 `url:"forLast,omitempty" json:"forLast,omitempty"`
|
||||
|
||||
// The reading interval in seconds
|
||||
// Required: false
|
||||
Step uint64 `url:"step,omitempty" json:"step,omitempty"`
|
||||
|
||||
// Number of zeros after the decimal point
|
||||
// Required: false
|
||||
DecimalPlaces uint64 `url:"decimalPlaces,omitempty" json:"decimalPlaces,omitempty"`
|
||||
}
|
||||
|
||||
// Receive Packets
|
||||
func (p Prometheus) ComputeReceivePackets(ctx context.Context, req ComputeReceivePacketsRequest) (*PrometheusData, error) {
|
||||
res, err := p.ComputeReceivePacketsRaw(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
info := PrometheusData{}
|
||||
|
||||
err = json.Unmarshal(res, &info)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &info, nil
|
||||
}
|
||||
|
||||
// GetRaw gets information about compute as an array of bytes
|
||||
func (p Prometheus) ComputeReceivePacketsRaw(ctx context.Context, req ComputeReceivePacketsRequest) ([]byte, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudapi/prometheus/computeReceivePackets"
|
||||
|
||||
res, err := p.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
return res, err
|
||||
}
|
||||
57
pkg/cloudapi/prometheus/compute_transmit_bytes.go
Normal file
57
pkg/cloudapi/prometheus/compute_transmit_bytes.go
Normal file
@@ -0,0 +1,57 @@
|
||||
package prometheus
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
type ComputeTransmitBytesRequest struct {
|
||||
// Compute ID
|
||||
// Required: true
|
||||
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
|
||||
|
||||
// Time to loads of statistic in seconds
|
||||
// Required: false
|
||||
ForLast uint64 `url:"forLast,omitempty" json:"forLast,omitempty"`
|
||||
|
||||
// The reading interval in seconds
|
||||
// Required: false
|
||||
Step uint64 `url:"step,omitempty" json:"step,omitempty"`
|
||||
|
||||
// Number of zeros after the decimal point
|
||||
// Required: false
|
||||
DecimalPlaces uint64 `url:"decimalPlaces,omitempty" json:"decimalPlaces,omitempty"`
|
||||
}
|
||||
|
||||
// Transmit Bytes
|
||||
func (p Prometheus) ComputeTransmitBytes(ctx context.Context, req ComputeTransmitBytesRequest) (*PrometheusData, error) {
|
||||
res, err := p.ComputeTransmitBytesRaw(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
info := PrometheusData{}
|
||||
|
||||
err = json.Unmarshal(res, &info)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &info, nil
|
||||
}
|
||||
|
||||
// GetRaw gets information about compute as an array of bytes
|
||||
func (p Prometheus) ComputeTransmitBytesRaw(ctx context.Context, req ComputeTransmitBytesRequest) ([]byte, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudapi/prometheus/computeTransmitBytes"
|
||||
|
||||
res, err := p.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
return res, err
|
||||
}
|
||||
57
pkg/cloudapi/prometheus/compute_transmit_packets.go
Normal file
57
pkg/cloudapi/prometheus/compute_transmit_packets.go
Normal file
@@ -0,0 +1,57 @@
|
||||
package prometheus
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
type ComputeTransmitPacketsRequest struct {
|
||||
// Compute ID
|
||||
// Required: true
|
||||
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
|
||||
|
||||
// Time to loads of statistic in seconds
|
||||
// Required: false
|
||||
ForLast uint64 `url:"forLast,omitempty" json:"forLast,omitempty"`
|
||||
|
||||
// The reading interval in seconds
|
||||
// Required: false
|
||||
Step uint64 `url:"step,omitempty" json:"step,omitempty"`
|
||||
|
||||
// Number of zeros after the decimal point
|
||||
// Required: false
|
||||
DecimalPlaces uint64 `url:"decimalPlaces,omitempty" json:"decimalPlaces,omitempty"`
|
||||
}
|
||||
|
||||
// Transmit Packets
|
||||
func (p Prometheus) ComputeTransmitPackets(ctx context.Context, req ComputeTransmitPacketsRequest) (*PrometheusData, error) {
|
||||
res, err := p.ComputeTransmitPacketsRaw(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
info := PrometheusData{}
|
||||
|
||||
err = json.Unmarshal(res, &info)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &info, nil
|
||||
}
|
||||
|
||||
// GetRaw gets information about compute as an array of bytes
|
||||
func (p Prometheus) ComputeTransmitPacketsRaw(ctx context.Context, req ComputeTransmitPacketsRequest) ([]byte, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudapi/prometheus/computeTransmitPackets"
|
||||
|
||||
res, err := p.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
return res, err
|
||||
}
|
||||
57
pkg/cloudapi/prometheus/compute_write_bytes.go
Normal file
57
pkg/cloudapi/prometheus/compute_write_bytes.go
Normal file
@@ -0,0 +1,57 @@
|
||||
package prometheus
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
type ComputeWriteBytesRequest struct {
|
||||
// Compute ID
|
||||
// Required: true
|
||||
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
|
||||
|
||||
// Time to loads of statistic in seconds
|
||||
// Required: false
|
||||
ForLast uint64 `url:"forLast,omitempty" json:"forLast,omitempty"`
|
||||
|
||||
// The reading interval in seconds
|
||||
// Required: false
|
||||
Step uint64 `url:"step,omitempty" json:"step,omitempty"`
|
||||
|
||||
// Number of zeros after the decimal point
|
||||
// Required: false
|
||||
DecimalPlaces uint64 `url:"decimalPlaces,omitempty" json:"decimalPlaces,omitempty"`
|
||||
}
|
||||
|
||||
// Write Bytes
|
||||
func (p Prometheus) ComputeWriteBytes(ctx context.Context, req ComputeWriteBytesRequest) (*PrometheusData, error) {
|
||||
res, err := p.ComputeWriteBytesRaw(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
info := PrometheusData{}
|
||||
|
||||
err = json.Unmarshal(res, &info)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &info, nil
|
||||
}
|
||||
|
||||
// GetRaw gets information about compute as an array of bytes
|
||||
func (p Prometheus) ComputeWriteBytesRaw(ctx context.Context, req ComputeWriteBytesRequest) ([]byte, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudapi/prometheus/computeWriteBytes"
|
||||
|
||||
res, err := p.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
return res, err
|
||||
}
|
||||
57
pkg/cloudapi/prometheus/compute_write_requests.go
Normal file
57
pkg/cloudapi/prometheus/compute_write_requests.go
Normal file
@@ -0,0 +1,57 @@
|
||||
package prometheus
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
type ComputeWriteRequestsRequest struct {
|
||||
// Compute ID
|
||||
// Required: true
|
||||
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
|
||||
|
||||
// Time to loads of statistic in seconds
|
||||
// Required: false
|
||||
ForLast uint64 `url:"forLast,omitempty" json:"forLast,omitempty"`
|
||||
|
||||
// The reading interval in seconds
|
||||
// Required: false
|
||||
Step uint64 `url:"step,omitempty" json:"step,omitempty"`
|
||||
|
||||
// Number of zeros after the decimal point
|
||||
// Required: false
|
||||
DecimalPlaces uint64 `url:"decimalPlaces,omitempty" json:"decimalPlaces,omitempty"`
|
||||
}
|
||||
|
||||
// Write Requests
|
||||
func (p Prometheus) ComputeWriteRequests(ctx context.Context, req ComputeWriteRequestsRequest) (*PrometheusData, error) {
|
||||
res, err := p.ComputeWriteRequestsRaw(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
info := PrometheusData{}
|
||||
|
||||
err = json.Unmarshal(res, &info)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &info, nil
|
||||
}
|
||||
|
||||
// GetRaw gets information about compute as an array of bytes
|
||||
func (p Prometheus) ComputeWriteRequestsRaw(ctx context.Context, req ComputeWriteRequestsRequest) ([]byte, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudapi/prometheus/computeWriteRequests"
|
||||
|
||||
res, err := p.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
return res, err
|
||||
}
|
||||
77
pkg/cloudapi/prometheus/computes.go
Normal file
77
pkg/cloudapi/prometheus/computes.go
Normal file
@@ -0,0 +1,77 @@
|
||||
package prometheus
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
const (
|
||||
ComputeCPULoad = "computeCPUload"
|
||||
ComputeMemoryUsage = "computeMemoryUsage"
|
||||
ComputeMemoryUsable = "computeMemoryUsable"
|
||||
ComputeMemoryUnused = "computeMemoryUnused"
|
||||
ComputeMemoryUsed = "computeMemoryUsed"
|
||||
ComputeMemoryAvailable = "computeMemoryAvailable"
|
||||
ComputeReadBytes = "computeReadBytes"
|
||||
ComputeReadRequests = "computeReadRequests"
|
||||
ComputeReceiveBytes = "computeReceiveBytes"
|
||||
ComputeTransmitBytes = "computeTransmitBytes"
|
||||
ComputeTransmitPackets = "computeTransmitPackets"
|
||||
ComputeWriteBytes = "computeWriteBytes"
|
||||
ComputeWriteRequests = "computeWriteRequests"
|
||||
)
|
||||
|
||||
type ComputesRequest struct {
|
||||
// List of compute IDs to fetch metrics for
|
||||
// Required: true
|
||||
ComputeIDs []uint64 `url:"computeIds" json:"computeIds" validate:"required"`
|
||||
|
||||
// List of compute IDs to fetch metrics for
|
||||
// Required: true
|
||||
MetricIDs []string `url:"metricIds" json:"metricIds" validate:"required"`
|
||||
|
||||
// Time to loads of statistic in seconds
|
||||
// Required: false
|
||||
ForLast uint64 `url:"forLast,omitempty" json:"forLast,omitempty"`
|
||||
|
||||
// The reading interval in seconds
|
||||
// Required: false
|
||||
Step uint64 `url:"step,omitempty" json:"step,omitempty"`
|
||||
|
||||
// Number of zeros after the decimal point
|
||||
// Required: false
|
||||
DecimalPlaces uint64 `url:"decimalPlaces,omitempty" json:"decimalPlaces,omitempty"`
|
||||
}
|
||||
|
||||
// Get multiple metrics for multiple compute instances
|
||||
func (p Prometheus) Computes(ctx context.Context, req ComputesRequest) (*ComputesData, error) {
|
||||
res, err := p.ComputesRaw(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
info := ComputesData{}
|
||||
|
||||
err = json.Unmarshal(res, &info)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &info, nil
|
||||
}
|
||||
|
||||
// GetRaw gets information about compute as an array of bytes
|
||||
func (p Prometheus) ComputesRaw(ctx context.Context, req ComputesRequest) ([]byte, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudapi/prometheus/computes"
|
||||
|
||||
res, err := p.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
return res, err
|
||||
}
|
||||
40
pkg/cloudapi/prometheus/models.go
Normal file
40
pkg/cloudapi/prometheus/models.go
Normal file
@@ -0,0 +1,40 @@
|
||||
package prometheus
|
||||
|
||||
// PrometheusData represents an array of data points
|
||||
type PrometheusData []PrometheusPoint
|
||||
|
||||
// PrometheusPoint represents a single data point
|
||||
type PrometheusPoint struct {
|
||||
// Value of the metric at a specific point in time
|
||||
Value float64 `json:"value"`
|
||||
|
||||
// Timestamp the Unix timestamp.
|
||||
Timestamp uint64 `json:"timestamp"`
|
||||
}
|
||||
|
||||
// ComputesData represents an array of data points for computes
|
||||
type ComputesData []ItemCompute
|
||||
|
||||
// ItemCompute represents a single data of compute
|
||||
type ItemCompute struct {
|
||||
// Compute ID
|
||||
ComputeID uint64 `json:"computeId"`
|
||||
|
||||
// Array of metrics
|
||||
Metrics []ItemMetric `json:"metrics"`
|
||||
|
||||
// Error
|
||||
Error string `json:"error"`
|
||||
}
|
||||
|
||||
// ItemMetric represents a single data point of metric
|
||||
type ItemMetric struct {
|
||||
// Metric ID
|
||||
MetricID string `json:"metricId"`
|
||||
|
||||
// Data represents an array of data points
|
||||
Data PrometheusData `json:"data"`
|
||||
|
||||
// Error
|
||||
Error string `json:"error"`
|
||||
}
|
||||
15
pkg/cloudapi/prometheus/prometheus.go
Normal file
15
pkg/cloudapi/prometheus/prometheus.go
Normal file
@@ -0,0 +1,15 @@
|
||||
package prometheus
|
||||
|
||||
import (
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/interfaces"
|
||||
)
|
||||
|
||||
type Prometheus struct {
|
||||
client interfaces.Caller
|
||||
}
|
||||
|
||||
func New(client interfaces.Caller) *Prometheus {
|
||||
return &Prometheus{
|
||||
client: client,
|
||||
}
|
||||
}
|
||||
@@ -17,20 +17,19 @@ var rgs = ListResourceGroups{
|
||||
UserGroupID: "sample_user_1@decs3o",
|
||||
},
|
||||
},
|
||||
CreatedBy: "sample_user_1@decs3o",
|
||||
CreatedTime: 1676645305,
|
||||
DefNetID: 1,
|
||||
DefNetType: "NONE",
|
||||
DeletedBy: "",
|
||||
DeletedTime: 0,
|
||||
Description: "",
|
||||
GID: 212,
|
||||
GUID: 7971,
|
||||
ID: 7971,
|
||||
LockStatus: "UNLOCKED",
|
||||
Milestones: 363459,
|
||||
Name: "rg_1",
|
||||
RegisterComputes: false,
|
||||
CreatedBy: "sample_user_1@decs3o",
|
||||
CreatedTime: 1676645305,
|
||||
DefNetID: 1,
|
||||
DefNetType: "NONE",
|
||||
DeletedBy: "",
|
||||
DeletedTime: 0,
|
||||
Description: "",
|
||||
GID: 212,
|
||||
GUID: 7971,
|
||||
ID: 7971,
|
||||
LockStatus: "UNLOCKED",
|
||||
Milestones: 363459,
|
||||
Name: "rg_1",
|
||||
ResourceLimits: ResourceLimits{
|
||||
CUC: -1,
|
||||
CUI: -1,
|
||||
@@ -60,20 +59,19 @@ var rgs = ListResourceGroups{
|
||||
UserGroupID: "sample_user_1@decs3o",
|
||||
},
|
||||
},
|
||||
CreatedBy: "sample_user_1@decs3o",
|
||||
CreatedTime: 1676645461,
|
||||
DefNetID: 2,
|
||||
DefNetType: "NONE",
|
||||
DeletedBy: "",
|
||||
DeletedTime: 0,
|
||||
Description: "",
|
||||
GID: 212,
|
||||
GUID: 7972,
|
||||
ID: 7972,
|
||||
LockStatus: "UNLOCKED",
|
||||
Milestones: 363468,
|
||||
Name: "rg_2",
|
||||
RegisterComputes: false,
|
||||
CreatedBy: "sample_user_1@decs3o",
|
||||
CreatedTime: 1676645461,
|
||||
DefNetID: 2,
|
||||
DefNetType: "NONE",
|
||||
DeletedBy: "",
|
||||
DeletedTime: 0,
|
||||
Description: "",
|
||||
GID: 212,
|
||||
GUID: 7972,
|
||||
ID: 7972,
|
||||
LockStatus: "UNLOCKED",
|
||||
Milestones: 363468,
|
||||
Name: "rg_2",
|
||||
ResourceLimits: ResourceLimits{
|
||||
CUC: -1,
|
||||
CUI: -1,
|
||||
@@ -103,20 +101,19 @@ var rgs = ListResourceGroups{
|
||||
UserGroupID: "sample_user_2@decs3o",
|
||||
},
|
||||
},
|
||||
CreatedBy: "sample_user_2@decs3o",
|
||||
CreatedTime: 1676645548,
|
||||
DefNetID: 3,
|
||||
DefNetType: "NONE",
|
||||
DeletedBy: "",
|
||||
DeletedTime: 0,
|
||||
Description: "",
|
||||
GID: 212,
|
||||
GUID: 7973,
|
||||
ID: 7973,
|
||||
LockStatus: "kjLOCKED",
|
||||
Milestones: 363471,
|
||||
Name: "rg_3",
|
||||
RegisterComputes: false,
|
||||
CreatedBy: "sample_user_2@decs3o",
|
||||
CreatedTime: 1676645548,
|
||||
DefNetID: 3,
|
||||
DefNetType: "NONE",
|
||||
DeletedBy: "",
|
||||
DeletedTime: 0,
|
||||
Description: "",
|
||||
GID: 212,
|
||||
GUID: 7973,
|
||||
ID: 7973,
|
||||
LockStatus: "kjLOCKED",
|
||||
Milestones: 363471,
|
||||
Name: "rg_3",
|
||||
ResourceLimits: ResourceLimits{
|
||||
CUC: -1,
|
||||
CUI: -1,
|
||||
|
||||
@@ -128,9 +128,6 @@ type RecordResourceGroup struct {
|
||||
// Name
|
||||
Name string `json:"name"`
|
||||
|
||||
// RegisterComputes
|
||||
RegisterComputes bool `json:"registerComputes"`
|
||||
|
||||
// Resource limits
|
||||
ResourceLimits ResourceLimits `json:"resourceLimits"`
|
||||
|
||||
@@ -224,9 +221,6 @@ type ItemResourceGroup struct {
|
||||
// Name
|
||||
Name string `json:"name"`
|
||||
|
||||
// RegisterComputes
|
||||
RegisterComputes bool `json:"registerComputes"`
|
||||
|
||||
// Resource limits
|
||||
ResourceLimits ResourceLimits `json:"resourceLimits"`
|
||||
|
||||
|
||||
@@ -16,6 +16,14 @@ type DeleteRequest struct {
|
||||
// Whether to completely delete the account
|
||||
// Required: false
|
||||
Permanently bool `url:"permanently,omitempty" json:"permanently,omitempty"`
|
||||
|
||||
// Name of account
|
||||
// Required: false
|
||||
Name string `url:"name,omitempty" json:"name,omitempty"`
|
||||
|
||||
// Reason of deleting
|
||||
// Required: false
|
||||
Reason string `url:"reason,omitempty" json:"reason,omitempty"`
|
||||
}
|
||||
|
||||
// Delete completes delete an account from the system Returns true if account is deleted or was already deleted or never existed
|
||||
|
||||
@@ -21,9 +21,7 @@ type APIFindRequest struct {
|
||||
|
||||
//API endpoint to find (delete, create, etc)
|
||||
//Required: true
|
||||
APIMethod string `url:"api_method" json:"api_method" valudate:"required"`
|
||||
|
||||
|
||||
APIMethod string `url:"api_method" json:"api_method" validate:"required"`
|
||||
}
|
||||
|
||||
// APIFind outputs a list of apiaccess groups that mention the specified API function.
|
||||
|
||||
@@ -22,6 +22,9 @@ type ListRequest struct {
|
||||
// Required: false
|
||||
Status string `url:"status,omitempty" json:"status,omitempty"`
|
||||
|
||||
// Find by description
|
||||
// Required: false
|
||||
Desc string `url:"desc,omitempty" json:"desc,omitempty"`
|
||||
|
||||
// Find by created after time (unix timestamp)
|
||||
// Required: false
|
||||
|
||||
8
pkg/cloudbroker/bservice.go
Normal file
8
pkg/cloudbroker/bservice.go
Normal file
@@ -0,0 +1,8 @@
|
||||
package cloudbroker
|
||||
|
||||
import "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/bservice"
|
||||
|
||||
// Accessing the BService method group
|
||||
func (ca *CloudBroker) BService() *bservice.BService {
|
||||
return bservice.New(ca.client)
|
||||
}
|
||||
15
pkg/cloudbroker/bservice/bservice.go
Normal file
15
pkg/cloudbroker/bservice/bservice.go
Normal file
@@ -0,0 +1,15 @@
|
||||
package bservice
|
||||
|
||||
import "repository.basistech.ru/BASIS/decort-golang-sdk/interfaces"
|
||||
|
||||
// Structure for creating request to bservice
|
||||
type BService struct {
|
||||
client interfaces.Caller
|
||||
}
|
||||
|
||||
// Builder for bservice endpoints
|
||||
func New(client interfaces.Caller) *BService {
|
||||
return &BService{
|
||||
client,
|
||||
}
|
||||
}
|
||||
50
pkg/cloudbroker/bservice/create.go
Normal file
50
pkg/cloudbroker/bservice/create.go
Normal file
@@ -0,0 +1,50 @@
|
||||
package bservice
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// CreateRequest struct for BasicService
|
||||
type CreateRequest struct {
|
||||
// Name of the service
|
||||
// Required: true
|
||||
Name string `url:"name" json:"name" validate:"required"`
|
||||
|
||||
// ID of the Resource Group where this service will be placed
|
||||
// Required: true
|
||||
RGID uint64 `url:"rgId" json:"rgId" validate:"required"`
|
||||
|
||||
// Name of the user to deploy SSH key for. Pass empty string if no SSH key deployment is required
|
||||
// Required: false
|
||||
SSHUser string `url:"sshUser,omitempty" json:"sshUser,omitempty"`
|
||||
|
||||
// SSH key to deploy for the specified user. Same key will be deployed to all computes of the service
|
||||
// Required: false
|
||||
SSHKey string `url:"sshKey,omitempty" json:"sshKey,omitempty"`
|
||||
}
|
||||
|
||||
// Create creates blank BasicService instance
|
||||
func (b BService) Create(ctx context.Context, req CreateRequest) (uint64, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return 0, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/bservice/create"
|
||||
|
||||
res, err := b.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseUint(string(res), 10, 64)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
42
pkg/cloudbroker/bservice/delete.go
Normal file
42
pkg/cloudbroker/bservice/delete.go
Normal file
@@ -0,0 +1,42 @@
|
||||
package bservice
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// DeleteRequest struct to delete basic service
|
||||
type DeleteRequest struct {
|
||||
// ID of the BasicService to be delete
|
||||
// Required: true
|
||||
ServiceID uint64 `url:"serviceId" json:"serviceId" validate:"required"`
|
||||
|
||||
// If set to False, Basic service will be deleted to recycle bin. Otherwise destroyed immediately
|
||||
// Required: true
|
||||
Permanently bool `url:"permanently" json:"permanently"`
|
||||
}
|
||||
|
||||
// Delete deletes BasicService instance
|
||||
func (b BService) Delete(ctx context.Context, req DeleteRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/bservice/delete"
|
||||
|
||||
res, err := b.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseBool(string(res))
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
40
pkg/cloudbroker/bservice/disable.go
Normal file
40
pkg/cloudbroker/bservice/disable.go
Normal file
@@ -0,0 +1,40 @@
|
||||
package bservice
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// DisableRequest struct for disable service
|
||||
type DisableRequest struct {
|
||||
// ID of the service to disable
|
||||
// Required: true
|
||||
ServiceID uint64 `url:"serviceId" json:"serviceId" validate:"required"`
|
||||
}
|
||||
|
||||
// Disable disables service.
|
||||
// Disabling a service technically means setting model status
|
||||
// of all computes and service itself to DISABLED and stopping all computes.
|
||||
func (b BService) Disable(ctx context.Context, req DisableRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/bservice/disable"
|
||||
|
||||
res, err := b.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseBool(string(res))
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
41
pkg/cloudbroker/bservice/enable.go
Normal file
41
pkg/cloudbroker/bservice/enable.go
Normal file
@@ -0,0 +1,41 @@
|
||||
package bservice
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// EnableRequest struct to disable service
|
||||
type EnableRequest struct {
|
||||
// ID of the service to enable
|
||||
// Required: true
|
||||
ServiceID uint64 `url:"serviceId" json:"serviceId" validate:"required"`
|
||||
}
|
||||
|
||||
// Enable enables service.
|
||||
// Enabling a service technically means setting model status of
|
||||
// all computes and service itself to ENABLED.
|
||||
// It does not start computes.
|
||||
func (b BService) Enable(ctx context.Context, req EnableRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/bservice/enable"
|
||||
|
||||
res, err := b.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseBool(string(res))
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
71
pkg/cloudbroker/bservice/filter.go
Normal file
71
pkg/cloudbroker/bservice/filter.go
Normal file
@@ -0,0 +1,71 @@
|
||||
package bservice
|
||||
|
||||
// FilterByID returns ListBasicServices with specified ID.
|
||||
func (lbs ListBasicServices) FilterByID(id uint64) ListBasicServices {
|
||||
predicate := func(ibs ItemBasicService) bool {
|
||||
return ibs.ID == id
|
||||
}
|
||||
|
||||
return lbs.FilterFunc(predicate)
|
||||
}
|
||||
|
||||
// FilterByName returns ListBasicServices with specified Name.
|
||||
func (lbs ListBasicServices) FilterByName(name string) ListBasicServices {
|
||||
predicate := func(ibs ItemBasicService) bool {
|
||||
return ibs.Name == name
|
||||
}
|
||||
|
||||
return lbs.FilterFunc(predicate)
|
||||
}
|
||||
|
||||
// FilterByRGID returns ListBasicServices with specified RGID.
|
||||
func (lbs ListBasicServices) FilterByRGID(rgID uint64) ListBasicServices {
|
||||
predicate := func(ibs ItemBasicService) bool {
|
||||
return ibs.RGID == rgID
|
||||
}
|
||||
|
||||
return lbs.FilterFunc(predicate)
|
||||
}
|
||||
|
||||
// FilterByStatus returns ListBasicServices with specified Status.
|
||||
func (lbs ListBasicServices) FilterByStatus(status string) ListBasicServices {
|
||||
predicate := func(ibs ItemBasicService) bool {
|
||||
return ibs.Status == status
|
||||
}
|
||||
|
||||
return lbs.FilterFunc(predicate)
|
||||
}
|
||||
|
||||
// FilterByTechStatus returns ListBasicServices with specified TechStatus.
|
||||
func (lbs ListBasicServices) FilterByTechStatus(techStatus string) ListBasicServices {
|
||||
predicate := func(ibs ItemBasicService) bool {
|
||||
return ibs.TechStatus == techStatus
|
||||
}
|
||||
|
||||
return lbs.FilterFunc(predicate)
|
||||
}
|
||||
|
||||
// FilterFunc allows filtering ListResourceGroups based on a user-specified predicate.
|
||||
func (lbs ListBasicServices) FilterFunc(predicate func(ItemBasicService) bool) ListBasicServices {
|
||||
var result ListBasicServices
|
||||
|
||||
for _, item := range lbs.Data {
|
||||
if predicate(item) {
|
||||
result.Data = append(result.Data, item)
|
||||
}
|
||||
}
|
||||
|
||||
result.EntryCount = uint64(len(lbs.Data))
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
// FindOne returns first found ItemBasicService
|
||||
// If none was found, returns an empty struct.
|
||||
func (lbs ListBasicServices) FindOne() ItemBasicService {
|
||||
if lbs.EntryCount == 0 {
|
||||
return ItemBasicService{}
|
||||
}
|
||||
|
||||
return lbs.Data[0]
|
||||
}
|
||||
155
pkg/cloudbroker/bservice/filter_test.go
Normal file
155
pkg/cloudbroker/bservice/filter_test.go
Normal file
@@ -0,0 +1,155 @@
|
||||
package bservice
|
||||
|
||||
import "testing"
|
||||
|
||||
var bservices = ListBasicServices{
|
||||
Data: []ItemBasicService{
|
||||
{
|
||||
AccountID: 1,
|
||||
AccountName: "std_1",
|
||||
BaseDomain: "",
|
||||
CreatedBy: "sample_user_1@decs3o",
|
||||
CreatedTime: 1677743675,
|
||||
DeletedBy: "",
|
||||
DeletedTime: 0,
|
||||
GID: 212,
|
||||
Groups: []uint64{},
|
||||
GUID: 1,
|
||||
ID: 1,
|
||||
Name: "bservice_1",
|
||||
ParentSrvID: 0,
|
||||
ParentSrvType: "",
|
||||
RGID: 7971,
|
||||
RGName: "rg_1",
|
||||
SSHUser: "",
|
||||
Status: "CREATED",
|
||||
TechStatus: "STOPPED",
|
||||
UpdatedBy: "",
|
||||
UpdatedTime: 0,
|
||||
UserManaged: true,
|
||||
},
|
||||
{
|
||||
AccountID: 2,
|
||||
AccountName: "std_2",
|
||||
BaseDomain: "",
|
||||
CreatedBy: "sample_user_1@decs3o",
|
||||
CreatedTime: 1677743736,
|
||||
DeletedBy: "",
|
||||
DeletedTime: 0,
|
||||
GID: 212,
|
||||
Groups: []uint64{},
|
||||
GUID: 2,
|
||||
ID: 2,
|
||||
Name: "bservice_2",
|
||||
ParentSrvID: 0,
|
||||
ParentSrvType: "",
|
||||
RGID: 7972,
|
||||
RGName: "rg_2",
|
||||
SSHUser: "",
|
||||
Status: "CREATED",
|
||||
TechStatus: "STOPPED",
|
||||
UpdatedBy: "",
|
||||
UpdatedTime: 0,
|
||||
UserManaged: true,
|
||||
},
|
||||
{
|
||||
AccountID: 3,
|
||||
AccountName: "std_3",
|
||||
BaseDomain: "",
|
||||
CreatedBy: "sample_user_2@decs3o",
|
||||
CreatedTime: 1677743830,
|
||||
DeletedBy: "",
|
||||
DeletedTime: 0,
|
||||
GID: 212,
|
||||
Groups: []uint64{},
|
||||
GUID: 3,
|
||||
ID: 3,
|
||||
Name: "bservice_3",
|
||||
ParentSrvID: 0,
|
||||
ParentSrvType: "",
|
||||
RGID: 7973,
|
||||
RGName: "rg_3",
|
||||
SSHUser: "",
|
||||
Status: "ENABLED",
|
||||
TechStatus: "STARTED",
|
||||
UpdatedBy: "",
|
||||
UpdatedTime: 0,
|
||||
UserManaged: true,
|
||||
},
|
||||
},
|
||||
EntryCount: 3,
|
||||
}
|
||||
|
||||
func TestFilterByID(t *testing.T) {
|
||||
actual := bservices.FilterByID(1).FindOne()
|
||||
|
||||
if actual.ID != 1 {
|
||||
t.Fatal("expected ID 1, found: ", actual.ID)
|
||||
}
|
||||
}
|
||||
|
||||
func TestFilterByName(t *testing.T) {
|
||||
actual := bservices.FilterByName("bservice_3").FindOne()
|
||||
|
||||
if actual.Name != "bservice_3" {
|
||||
t.Fatal("expected Name 'bservice_3', found: ", actual.Name)
|
||||
}
|
||||
}
|
||||
|
||||
func TestFilterByRGID(t *testing.T) {
|
||||
actual := bservices.FilterByRGID(7971).FindOne()
|
||||
|
||||
if actual.RGID != 7971 {
|
||||
t.Fatal("expected RGID 7971, found: ", actual.RGID)
|
||||
}
|
||||
}
|
||||
|
||||
func TestFilterByStatus(t *testing.T) {
|
||||
actual := bservices.FilterByStatus("CREATED")
|
||||
|
||||
if len(actual.Data) != 2 {
|
||||
t.Fatal("expected 2 found, actual: ", len(actual.Data))
|
||||
}
|
||||
|
||||
for _, item := range actual.Data {
|
||||
if item.Status != "CREATED" {
|
||||
t.Fatal("expected Status 'CREATED', found: ", item.Status)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestFilterByTechStatus(t *testing.T) {
|
||||
actual := bservices.FilterByTechStatus("STOPPED")
|
||||
|
||||
if len(actual.Data) != 2 {
|
||||
t.Fatal("expected 2 found, actual: ", len(actual.Data))
|
||||
}
|
||||
|
||||
for _, item := range actual.Data {
|
||||
if item.TechStatus != "STOPPED" {
|
||||
t.Fatal("expected TechStatus 'STOPPED', found: ", item.TechStatus)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestFilterFunc(t *testing.T) {
|
||||
actual := bservices.FilterFunc(func(ibs ItemBasicService) bool {
|
||||
return ibs.CreatedBy == "sample_user_2@decs3o"
|
||||
})
|
||||
|
||||
if len(actual.Data) > 1 {
|
||||
t.Fatal("expected 1 found, actual: ", len(actual.Data))
|
||||
}
|
||||
|
||||
if actual.FindOne().CreatedBy != "sample_user_2@decs3o" {
|
||||
t.Fatal("expected 'sample_user_2@decs3o', found: ", actual.FindOne().CreatedBy)
|
||||
}
|
||||
}
|
||||
|
||||
func TestSortByCreatedTime(t *testing.T) {
|
||||
actual := bservices.SortByCreatedTime(true)
|
||||
|
||||
if actual.Data[0].CreatedTime != 1677743830 || actual.Data[2].CreatedTime != 1677743675 {
|
||||
t.Fatal("expected descending order, found ascending")
|
||||
}
|
||||
}
|
||||
46
pkg/cloudbroker/bservice/get.go
Normal file
46
pkg/cloudbroker/bservice/get.go
Normal file
@@ -0,0 +1,46 @@
|
||||
package bservice
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// GetRequest struct to get detailed information about service
|
||||
type GetRequest struct {
|
||||
// ID of the service to query information
|
||||
// Required: true
|
||||
ServiceID uint64 `url:"serviceId" json:"serviceId" validate:"required"`
|
||||
}
|
||||
|
||||
// Get gets detailed specifications for the BasicService as a RecordBasicService struct
|
||||
func (b BService) Get(ctx context.Context, req GetRequest) (*RecordBasicService, error) {
|
||||
res, err := b.GetRaw(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
info := RecordBasicService{}
|
||||
|
||||
err = json.Unmarshal(res, &info)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &info, nil
|
||||
}
|
||||
|
||||
// GetRaw gets detailed specifications for the BasicService as an array of bytes
|
||||
func (b BService) GetRaw(ctx context.Context, req GetRequest) ([]byte, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/bservice/get"
|
||||
|
||||
res, err := b.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
return res, err
|
||||
}
|
||||
112
pkg/cloudbroker/bservice/group_add.go
Normal file
112
pkg/cloudbroker/bservice/group_add.go
Normal file
@@ -0,0 +1,112 @@
|
||||
package bservice
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// GroupAddRequest struct to create new compute group within BasicService
|
||||
type GroupAddRequest struct {
|
||||
// ID of the Basic Service to add a group to
|
||||
// Required: true
|
||||
ServiceID uint64 `url:"serviceId" json:"serviceId" validate:"required"`
|
||||
|
||||
// Name of the Compute Group to add
|
||||
// Required: true
|
||||
Name string `url:"name" json:"name" validate:"required"`
|
||||
|
||||
// Computes number. Defines how many computes must be there in the group
|
||||
// Required: true
|
||||
Count uint64 `url:"count" json:"count" validate:"required"`
|
||||
|
||||
// Compute CPU number. All computes in the group have the same CPU count
|
||||
// Required: true
|
||||
CPU uint64 `url:"cpu" json:"cpu" validate:"required"`
|
||||
|
||||
// Compute RAM volume in MB. All computes in the group have the same RAM volume
|
||||
// Required: true
|
||||
RAM uint64 `url:"ram" json:"ram" validate:"required"`
|
||||
|
||||
// Compute boot disk size in GB
|
||||
// Required: true
|
||||
Disk uint64 `url:"disk" json:"disk" validate:"required"`
|
||||
|
||||
// OS image ID to create computes from
|
||||
// Required: true
|
||||
ImageID uint64 `url:"imageId" json:"imageId" validate:"required"`
|
||||
|
||||
// Compute driver
|
||||
// should be one of:
|
||||
// - KVM_X86
|
||||
// Required: true
|
||||
Driver string `url:"driver" json:"driver" validate:"driver"`
|
||||
|
||||
// Storage endpoint provider ID
|
||||
// Required: false
|
||||
SEPID uint64 `url:"sepId,omitempty" json:"sepId,omitempty"`
|
||||
|
||||
// Pool to use if sepId is set, can be also empty if needed to be chosen by system
|
||||
// Required: false
|
||||
SEPPool string `url:"sepPool,omitempty" json:"sepPool,omitempty"`
|
||||
|
||||
// Group role tag. Can be empty string, does not have to be unique
|
||||
// Required: false
|
||||
Role string `url:"role,omitempty" json:"role,omitempty"`
|
||||
|
||||
// List of ViNSes to connect computes to
|
||||
// Required: false
|
||||
VINSes []uint64 `url:"vinses,omitempty" json:"vinses,omitempty"`
|
||||
|
||||
// List of external networks to connect computes to
|
||||
// Required: false
|
||||
ExtNets []uint64 `url:"extnets,omitempty" json:"extnets,omitempty"`
|
||||
|
||||
// Time of Compute Group readiness
|
||||
// Required: false
|
||||
TimeoutStart uint64 `url:"timeoutStart,omitempty" json:"timeoutStart,omitempty"`
|
||||
|
||||
// Meta data for working group computes, format YAML "user_data": 1111
|
||||
// Required: false
|
||||
UserData string `url:"userData,omitempty" json:"userData,omitempty"`
|
||||
|
||||
//Chipset "i440fx" or "Q35
|
||||
//Required: false
|
||||
Chipset string `url:"chipset,omitempty" json:"chipset,omitempty" validate:"chipset"`
|
||||
}
|
||||
|
||||
// GetRAM returns RAM field values
|
||||
func (r GroupAddRequest) GetRAM() map[string]uint64 {
|
||||
|
||||
res := make(map[string]uint64, 1)
|
||||
|
||||
res["RAM"] = r.RAM
|
||||
|
||||
return res
|
||||
}
|
||||
|
||||
// GroupAdd creates new Compute Group within BasicService.
|
||||
// Compute Group is NOT started automatically,
|
||||
// so you need to explicitly start it
|
||||
func (b BService) GroupAdd(ctx context.Context, req GroupAddRequest) (uint64, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return 0, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/bservice/groupAdd"
|
||||
|
||||
res, err := b.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseUint(string(res), 10, 64)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
46
pkg/cloudbroker/bservice/group_compute_remove.go
Normal file
46
pkg/cloudbroker/bservice/group_compute_remove.go
Normal file
@@ -0,0 +1,46 @@
|
||||
package bservice
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// GroupComputeRemoveRequest struct to remove group compute
|
||||
type GroupComputeRemoveRequest struct {
|
||||
// ID of the Basic Service
|
||||
// Required: true
|
||||
ServiceID uint64 `url:"serviceId" json:"serviceId" validate:"required"`
|
||||
|
||||
// ID of the Compute GROUP
|
||||
// Required: true
|
||||
CompGroupID uint64 `url:"compgroupId" json:"compgroupId" validate:"required"`
|
||||
|
||||
// ID of the Compute
|
||||
// Required: true
|
||||
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
|
||||
}
|
||||
|
||||
// GroupComputeRemove makes group compute remove of the Basic Service
|
||||
func (b BService) GroupComputeRemove(ctx context.Context, req GroupComputeRemoveRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/bservice/groupComputeRemove"
|
||||
|
||||
res, err := b.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseBool(string(res))
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
44
pkg/cloudbroker/bservice/group_get.go
Normal file
44
pkg/cloudbroker/bservice/group_get.go
Normal file
@@ -0,0 +1,44 @@
|
||||
package bservice
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// GroupGetRequest struct to get detailed information about Compute Group
|
||||
type GroupGetRequest struct {
|
||||
// ID of the Basic Service of Compute Group
|
||||
// Required: true
|
||||
ServiceID uint64 `url:"serviceId" json:"serviceId" validate:"required"`
|
||||
|
||||
// ID of the Compute Group
|
||||
// Required: true
|
||||
CompGroupID uint64 `url:"compgroupId" json:"compgroupId" validate:"required"`
|
||||
}
|
||||
|
||||
// GroupGet gets detailed specifications for the Compute Group
|
||||
func (b BService) GroupGet(ctx context.Context, req GroupGetRequest) (*RecordGroup, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/bservice/groupGet"
|
||||
|
||||
res, err := b.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
info := RecordGroup{}
|
||||
|
||||
err = json.Unmarshal(res, &info)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &info, nil
|
||||
}
|
||||
48
pkg/cloudbroker/bservice/group_parent_remove.go
Normal file
48
pkg/cloudbroker/bservice/group_parent_remove.go
Normal file
@@ -0,0 +1,48 @@
|
||||
package bservice
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// GroupParentRemoveRequest struct to remove parent Compute Group
|
||||
// relation from the specified Compute Group
|
||||
type GroupParentRemoveRequest struct {
|
||||
// ID of the Basic Service of Compute Group
|
||||
// Required: true
|
||||
ServiceID uint64 `url:"serviceId" json:"serviceId" validate:"required"`
|
||||
|
||||
// ID of the Compute Group
|
||||
// Required: true
|
||||
CompGroupID uint64 `url:"compgroupId" json:"compgroupId" validate:"required"`
|
||||
|
||||
// ID of the parent Compute Group
|
||||
// to remove from the current Compute Group
|
||||
// Required: true
|
||||
ParentID uint64 `url:"parentId" json:"parentId" validate:"required"`
|
||||
}
|
||||
|
||||
// GroupParentRemove removes parent Compute Group relation to the specified Compute Group
|
||||
func (b BService) GroupParentRemove(ctx context.Context, req GroupParentRemoveRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/bservice/groupParentRemove"
|
||||
|
||||
res, err := b.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseBool(string(res))
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
46
pkg/cloudbroker/bservice/group_parrent_add.go
Normal file
46
pkg/cloudbroker/bservice/group_parrent_add.go
Normal file
@@ -0,0 +1,46 @@
|
||||
package bservice
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// GroupParentAddRequest struct to add parent Compute Group relation to the specified Compute Group
|
||||
type GroupParentAddRequest struct {
|
||||
// ID of the Basic Service of Compute Group
|
||||
// Required: true
|
||||
ServiceID uint64 `url:"serviceId" json:"serviceId" validate:"required"`
|
||||
|
||||
// ID of the Compute Group
|
||||
// Required: true
|
||||
CompGroupID uint64 `url:"compgroupId" json:"compgroupId" validate:"required"`
|
||||
|
||||
// ID of the parent Compute Group to register with the current Compute Group
|
||||
// Required: true
|
||||
ParentID uint64 `url:"parentId" json:"parentId" validate:"required"`
|
||||
}
|
||||
|
||||
// GroupParentAdd add parent Compute Group relation to the specified Compute Group
|
||||
func (b BService) GroupParentAdd(ctx context.Context, req GroupParentAddRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/bservice/groupParentAdd"
|
||||
|
||||
res, err := b.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseBool(string(res))
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
43
pkg/cloudbroker/bservice/group_remove.go
Normal file
43
pkg/cloudbroker/bservice/group_remove.go
Normal file
@@ -0,0 +1,43 @@
|
||||
package bservice
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// GroupRemoveRequest struct for destroy the specified Compute Group
|
||||
type GroupRemoveRequest struct {
|
||||
// ID of the Basic Service of Compute Group
|
||||
// Required: true
|
||||
ServiceID uint64 `url:"serviceId" json:"serviceId" validate:"required"`
|
||||
|
||||
// ID of the Compute Group
|
||||
// Required: true
|
||||
CompGroupID uint64 `url:"compgroupId" json:"compgroupId" validate:"required"`
|
||||
}
|
||||
|
||||
// GroupRemove destroy the specified Compute Group
|
||||
func (b BService) GroupRemove(ctx context.Context, req GroupRemoveRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/bservice/groupRemove"
|
||||
|
||||
res, err := b.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return false, err
|
||||
|
||||
}
|
||||
|
||||
result, err := strconv.ParseBool(string(res))
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
59
pkg/cloudbroker/bservice/group_resize.go
Normal file
59
pkg/cloudbroker/bservice/group_resize.go
Normal file
@@ -0,0 +1,59 @@
|
||||
package bservice
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// GroupResizeRequest struct to resize the group
|
||||
type GroupResizeRequest struct {
|
||||
// ID of the Basic Service of Compute Group
|
||||
// Required: true
|
||||
ServiceID uint64 `url:"serviceId" json:"serviceId" validate:"required"`
|
||||
|
||||
// ID of the Compute Group to resize
|
||||
// Required: true
|
||||
CompGroupID uint64 `url:"compgroupId" json:"compgroupId" validate:"required"`
|
||||
|
||||
// Either delta or absolute value of computes
|
||||
// Required: true
|
||||
Count int64 `url:"count" json:"count" validate:"required"`
|
||||
|
||||
//Chipset for new computes, either i440fx or Q35 (i440fx by default)
|
||||
//Available values : i440fx, Q35
|
||||
//Default value : i440fx
|
||||
//Required: true
|
||||
Chipset string `url:"chipset" json:"chipset" validate:"required,chipset"`
|
||||
|
||||
// Either delta or absolute value of computes
|
||||
// Should be one of:
|
||||
// - ABSOLUTE
|
||||
// - RELATIVE
|
||||
// Required: true
|
||||
Mode string `url:"mode" json:"mode" validate:"bserviceMode"`
|
||||
}
|
||||
|
||||
// GroupResize resize the group by changing the number of computes
|
||||
func (b BService) GroupResize(ctx context.Context, req GroupResizeRequest) (uint64, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return 0, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/bservice/groupResize"
|
||||
|
||||
res, err := b.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseUint(string(res), 10, 64)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
42
pkg/cloudbroker/bservice/group_start.go
Normal file
42
pkg/cloudbroker/bservice/group_start.go
Normal file
@@ -0,0 +1,42 @@
|
||||
package bservice
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// GroupStartRequest struct to start the specified Compute Group
|
||||
type GroupStartRequest struct {
|
||||
// ID of the Basic Service of Compute Group
|
||||
// Required: true
|
||||
ServiceID uint64 `url:"serviceId" json:"serviceId" validate:"required"`
|
||||
|
||||
// ID of the Compute Group to start
|
||||
// Required: true
|
||||
CompGroupID uint64 `url:"compgroupId" json:"compgroupId" validate:"required"`
|
||||
}
|
||||
|
||||
// GroupStart starts the specified Compute Group within BasicService
|
||||
func (b BService) GroupStart(ctx context.Context, req GroupStartRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/bservice/groupStart"
|
||||
|
||||
res, err := b.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseBool(string(res))
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
46
pkg/cloudbroker/bservice/group_stop.go
Normal file
46
pkg/cloudbroker/bservice/group_stop.go
Normal file
@@ -0,0 +1,46 @@
|
||||
package bservice
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// GroupStopRequest struct to stop the specified Compute Group
|
||||
type GroupStopRequest struct {
|
||||
// ID of the Basic Service of Compute Group
|
||||
// Required: true
|
||||
ServiceID uint64 `url:"serviceId" json:"serviceId" validate:"required"`
|
||||
|
||||
// ID of the Compute Group to stop
|
||||
// Required: true
|
||||
CompGroupID uint64 `url:"compgroupId" json:"compgroupId" validate:"required"`
|
||||
|
||||
// Force stop Compute Group
|
||||
// Required: false
|
||||
Force bool `url:"force,omitempty" json:"force,omitempty"`
|
||||
}
|
||||
|
||||
// GroupStop stops the specified Compute Group within BasicService
|
||||
func (b BService) GroupStop(ctx context.Context, req GroupStopRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/bservice/groupStop"
|
||||
|
||||
res, err := b.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseBool(string(res))
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
76
pkg/cloudbroker/bservice/group_update.go
Normal file
76
pkg/cloudbroker/bservice/group_update.go
Normal file
@@ -0,0 +1,76 @@
|
||||
package bservice
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// GroupUpdateRequest struct to update existing Compute group
|
||||
type GroupUpdateRequest struct {
|
||||
// ID of the Basic Service of Compute Group
|
||||
// Required: true
|
||||
ServiceID uint64 `url:"serviceId" json:"serviceId" validate:"required"`
|
||||
|
||||
// ID of the Compute Group
|
||||
// Required: true
|
||||
CompGroupID uint64 `url:"compgroupId" json:"compgroupId" validate:"required"`
|
||||
|
||||
// Specify non-empty string to update Compute Group name
|
||||
// Required: false
|
||||
Name string `url:"name,omitempty" json:"name,omitempty"`
|
||||
|
||||
// Specify non-empty string to update group role
|
||||
// Required: false
|
||||
Role string `url:"role,omitempty" json:"role,omitempty"`
|
||||
|
||||
// Specify positive value to set new compute CPU count
|
||||
// Required: false
|
||||
CPU uint64 `url:"cpu,omitempty" json:"cpu,omitempty"`
|
||||
|
||||
// Specify positive value to set new compute RAM volume in MB
|
||||
// Required: false
|
||||
RAM uint64 `url:"ram,omitempty" json:"ram,omitempty"`
|
||||
|
||||
// Specify new compute boot disk size in GB
|
||||
// Required: false
|
||||
Disk uint64 `url:"disk,omitempty" json:"disk,omitempty"`
|
||||
|
||||
// Force resize Compute Group
|
||||
// Required: false
|
||||
Force bool `url:"force,omitempty" json:"force,omitempty"`
|
||||
}
|
||||
|
||||
// GetRAM returns RAM field values
|
||||
func (r GroupUpdateRequest) GetRAM() map[string]uint64 {
|
||||
|
||||
res := make(map[string]uint64, 1)
|
||||
|
||||
res["RAM"] = r.RAM
|
||||
|
||||
return res
|
||||
}
|
||||
|
||||
// GroupUpdate updates existing Compute group within Basic Service and apply new settings to its computes as necessary
|
||||
func (b BService) GroupUpdate(ctx context.Context, req GroupUpdateRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/bservice/groupUpdate"
|
||||
|
||||
res, err := b.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseBool(string(res))
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
46
pkg/cloudbroker/bservice/group_update_extnet.go
Normal file
46
pkg/cloudbroker/bservice/group_update_extnet.go
Normal file
@@ -0,0 +1,46 @@
|
||||
package bservice
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// GroupUpdateExtNetRequest struct to update External Network settings
|
||||
type GroupUpdateExtNetRequest struct {
|
||||
// ID of the Basic Service of Compute Group
|
||||
// Required: true
|
||||
ServiceID uint64 `url:"serviceId" json:"serviceId" validate:"required"`
|
||||
|
||||
// ID of the Compute Group
|
||||
// Required: true
|
||||
CompGroupID uint64 `url:"compgroupId" json:"compgroupId" validate:"required"`
|
||||
|
||||
// List of Extnets to connect computes
|
||||
// Required: false
|
||||
ExtNets []uint64 `url:"extnets,omitempty" json:"extnets,omitempty"`
|
||||
}
|
||||
|
||||
// GroupUpdateExtNet updates External Network settings for the group according to the new list
|
||||
func (b BService) GroupUpdateExtNet(ctx context.Context, req GroupUpdateExtNetRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/bservice/groupUpdateExtnet"
|
||||
|
||||
res, err := b.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseBool(string(res))
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
46
pkg/cloudbroker/bservice/group_update_vins.go
Normal file
46
pkg/cloudbroker/bservice/group_update_vins.go
Normal file
@@ -0,0 +1,46 @@
|
||||
package bservice
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// GroupUpdateVINSRequest struct to update VINS settings
|
||||
type GroupUpdateVINSRequest struct {
|
||||
// ID of the Basic Service of Compute Group
|
||||
// Required: true
|
||||
ServiceID uint64 `url:"serviceId" json:"serviceId" validate:"required"`
|
||||
|
||||
// ID of the Compute Group
|
||||
// Required: true
|
||||
CompGroupID uint64 `url:"compgroupId" json:"compgroupId" validate:"required"`
|
||||
|
||||
// List of ViNSes to connect computes
|
||||
// Required: false
|
||||
VINSes []uint64 `url:"vinses,omitempty" json:"vinses,omitempty"`
|
||||
}
|
||||
|
||||
// GroupUpdateVINS update ViNS settings for the group according to the new list
|
||||
func (b BService) GroupUpdateVINS(ctx context.Context, req GroupUpdateVINSRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/bservice/groupUpdateVins"
|
||||
|
||||
res, err := b.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseBool(string(res))
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
87
pkg/cloudbroker/bservice/list.go
Normal file
87
pkg/cloudbroker/bservice/list.go
Normal file
@@ -0,0 +1,87 @@
|
||||
package bservice
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// ListRequest struct to get list of BasicService instances
|
||||
type ListRequest struct {
|
||||
// Find by ID
|
||||
// Required: false
|
||||
ByID uint64 `url:"by_id,omitempty" json:"by_id,omitempty"`
|
||||
|
||||
// Find by name
|
||||
// Required: false
|
||||
Name string `url:"name,omitempty" json:"name,omitempty"`
|
||||
|
||||
// ID of the account to query for BasicService instances
|
||||
// Required: false
|
||||
AccountID uint64 `url:"accountId,omitempty" json:"accountId,omitempty"`
|
||||
|
||||
// Find by resource group name
|
||||
// Required: false
|
||||
RGName string `url:"rgName,omitempty" json:"rgName,omitempty"`
|
||||
|
||||
// ID of the resource group to query for BasicService instances
|
||||
// Required: false
|
||||
RGID uint64 `url:"rgId,omitempty" json:"rgId,omitempty"`
|
||||
|
||||
// Find by tech status
|
||||
// Required: false
|
||||
TechStatus string `url:"techStatus,omitempty" json:"techStatus,omitempty"`
|
||||
|
||||
// Find by status
|
||||
// Required: false
|
||||
Status string `url:"status,omitempty" json:"status,omitempty"`
|
||||
|
||||
// Find by account name
|
||||
// Required: false
|
||||
AccountName string `url:"accountName,omitempty" json:"accountName,omitempty"`
|
||||
|
||||
// Sort by one of supported fields, format +|-(field)
|
||||
// Required: false
|
||||
SortBy string `url:"sortBy,omitempty" json:"sortBy,omitempty" validate:"omitempty,sortBy"`
|
||||
|
||||
// Page number
|
||||
// Required: false
|
||||
Page uint64 `url:"page,omitempty" json:"page,omitempty"`
|
||||
|
||||
// Page size
|
||||
// Required: false
|
||||
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
||||
}
|
||||
|
||||
// List gets list of BasicService instances associated with the specified Resource Group as a ListBasicServices struct
|
||||
func (b BService) List(ctx context.Context, req ListRequest) (*ListBasicServices, error) {
|
||||
|
||||
res, err := b.ListRaw(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
list := ListBasicServices{}
|
||||
|
||||
err = json.Unmarshal(res, &list)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &list, nil
|
||||
}
|
||||
|
||||
// ListRaw gets list of BasicService instances associated with the specified Resource Group as an array of bytes
|
||||
func (b BService) ListRaw(ctx context.Context, req ListRequest) ([]byte, error) {
|
||||
|
||||
if err := validators.ValidateRequest(req); err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/bservice/list"
|
||||
|
||||
res, err := b.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
return res, err
|
||||
}
|
||||
56
pkg/cloudbroker/bservice/list_deleted.go
Normal file
56
pkg/cloudbroker/bservice/list_deleted.go
Normal file
@@ -0,0 +1,56 @@
|
||||
package bservice
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// ListDeletedRequest struct to get list of deleted BasicService instances
|
||||
type ListDeletedRequest struct {
|
||||
// ID of the account to query for BasicService instances
|
||||
// Required: false
|
||||
AccountID uint64 `url:"accountId,omitempty" json:"accountId,omitempty"`
|
||||
|
||||
// ID of the resource group to query for BasicService instances
|
||||
// Required: false
|
||||
RGID uint64 `url:"rgId,omitempty" json:"rgId,omitempty"`
|
||||
|
||||
// Sort by one of supported fields, format +|-(field)
|
||||
// Required: false
|
||||
SortBy string `url:"sortBy,omitempty" json:"sortBy,omitempty" validate:"omitempty,sortBy"`
|
||||
|
||||
// Page number
|
||||
// Required: false
|
||||
Page uint64 `url:"page,omitempty" json:"page,omitempty"`
|
||||
|
||||
// Page size
|
||||
// Required: false
|
||||
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
||||
}
|
||||
|
||||
// ListDeleted gets list of deleted BasicService instances associated with the specified Resource Group
|
||||
func (b BService) ListDeleted(ctx context.Context, req ListDeletedRequest) (*ListBasicServices, error) {
|
||||
|
||||
if err := validators.ValidateRequest(req); err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/bservice/listDeleted"
|
||||
|
||||
res, err := b.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
list := ListBasicServices{}
|
||||
|
||||
err = json.Unmarshal(res, &list)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &list, nil
|
||||
}
|
||||
401
pkg/cloudbroker/bservice/models.go
Normal file
401
pkg/cloudbroker/bservice/models.go
Normal file
@@ -0,0 +1,401 @@
|
||||
package bservice
|
||||
|
||||
// Detailed info about BasicService
|
||||
type RecordBasicService struct {
|
||||
// Account ID
|
||||
AccountID uint64 `json:"accountId"`
|
||||
|
||||
// Account name
|
||||
AccountName string `json:"accountName"`
|
||||
|
||||
// Base domain
|
||||
BaseDomain string `json:"baseDomain"`
|
||||
|
||||
// List Computes
|
||||
Computes ListComputes `json:"computes"`
|
||||
|
||||
// Number of cores
|
||||
CPUTotal uint64 `json:"cpuTotal"`
|
||||
|
||||
// Created by
|
||||
CreatedBy string `json:"createdBy"`
|
||||
|
||||
// Created time
|
||||
CreatedTime uint64 `json:"createdTime"`
|
||||
|
||||
// Deleted by
|
||||
DeletedBy string `json:"deletedBy"`
|
||||
|
||||
// Deleted time
|
||||
DeletedTime uint64 `json:"deletedTime"`
|
||||
|
||||
// Amount of disk space used, GB
|
||||
DiskTotal uint64 `json:"diskTotal"`
|
||||
|
||||
// Grid ID
|
||||
GID uint64 `json:"gid"`
|
||||
|
||||
// List of Service Compute Groups
|
||||
Groups ListGroups `json:"groups"`
|
||||
|
||||
// GUID
|
||||
GUID uint64 `json:"guid"`
|
||||
|
||||
// ID
|
||||
ID uint64 `json:"id"`
|
||||
|
||||
// Milestones
|
||||
Milestones uint64 `json:"milestones"`
|
||||
|
||||
// Name
|
||||
Name string `json:"name"`
|
||||
|
||||
// Parent service ID
|
||||
ParentSrvID uint64 `json:"parentSrvId"`
|
||||
|
||||
// Parent service type
|
||||
ParentSrvType string `json:"parentSrvType"`
|
||||
|
||||
// Total amount of RAM, MB
|
||||
RAMTotal uint64 `json:"ramTotal"`
|
||||
|
||||
// Resource group ID
|
||||
RGID uint64 `json:"rgId"`
|
||||
|
||||
// Resource group name
|
||||
RGName string `json:"rgName"`
|
||||
|
||||
// List of snapshots
|
||||
Snapshots ListSnapshots `json:"snapshots"`
|
||||
|
||||
// SSH key for connection
|
||||
SSHKey string `json:"sshKey"`
|
||||
|
||||
// Username for SSH connection
|
||||
SSHUser string `json:"sshUser"`
|
||||
|
||||
// status
|
||||
Status string `json:"status"`
|
||||
|
||||
// TechStatus
|
||||
TechStatus string `json:"techStatus"`
|
||||
|
||||
// Updated by
|
||||
UpdatedBy string `json:"updatedBy"`
|
||||
|
||||
// Updated time
|
||||
UpdatedTime uint64 `json:"updatedTime"`
|
||||
|
||||
// Whether user controlled
|
||||
UserManaged bool `json:"userManaged"`
|
||||
}
|
||||
|
||||
// List of Groups
|
||||
type ListGroups []ItemGroup
|
||||
|
||||
// Main information about Group
|
||||
type ItemGroup struct {
|
||||
// Amount of computes
|
||||
Computes uint64 `json:"computes"`
|
||||
|
||||
// Consistency
|
||||
Consistency bool `json:"consistency"`
|
||||
|
||||
// Group ID
|
||||
ID uint64 `json:"id"`
|
||||
|
||||
// Group name
|
||||
Name string `json:"name"`
|
||||
|
||||
// Status
|
||||
Status string `json:"status"`
|
||||
|
||||
// TechStatus
|
||||
TechStatus string `json:"techStatus"`
|
||||
}
|
||||
|
||||
// List of Computes
|
||||
type ListComputes []ItemCompute
|
||||
|
||||
// Main information about Compute
|
||||
type ItemCompute struct {
|
||||
// Account ID
|
||||
AccountID uint64 `json:"accountId"`
|
||||
|
||||
// Architecture
|
||||
Architecture string `json:"arch"`
|
||||
|
||||
// Compute group ID
|
||||
CompGroupID uint64 `json:"compgroupId"`
|
||||
|
||||
// Compute group name
|
||||
CompGroupName string `json:"compgroupName"`
|
||||
|
||||
// compute group role
|
||||
CompGroupRole string `json:"compgroupRole"`
|
||||
|
||||
// ID
|
||||
ID uint64 `json:"id"`
|
||||
|
||||
// Name
|
||||
Name string `json:"name"`
|
||||
|
||||
// Resource group ID
|
||||
RGID uint64 `json:"rgId"`
|
||||
|
||||
// StackID
|
||||
StackID uint64 `json:"stackId"`
|
||||
|
||||
// Status
|
||||
Status string `json:"status"`
|
||||
|
||||
// Tech status
|
||||
TechStatus string `json:"techStatus"`
|
||||
}
|
||||
|
||||
// List of Snapshot
|
||||
type ListSnapshots []ItemSnapshot
|
||||
|
||||
// Main information about Snapshot
|
||||
type ItemSnapshot struct {
|
||||
// GUID
|
||||
GUID string `json:"guid"`
|
||||
|
||||
// Label
|
||||
Label string `json:"label"`
|
||||
|
||||
// Timestamp
|
||||
Timestamp uint64 `json:"timestamp"`
|
||||
|
||||
// Valid or not
|
||||
Valid bool `json:"valid"`
|
||||
}
|
||||
|
||||
// List of BasicServices
|
||||
type ListBasicServices struct {
|
||||
Data []ItemBasicService `json:"data"`
|
||||
|
||||
EntryCount uint64 `json:"entryCount"`
|
||||
}
|
||||
|
||||
// Main information about BasicService
|
||||
type ItemBasicService struct {
|
||||
// Account ID
|
||||
AccountID uint64 `json:"accountId"`
|
||||
|
||||
// Account name
|
||||
AccountName string `json:"accountName"`
|
||||
|
||||
// Base domain
|
||||
BaseDomain string `json:"baseDomain"`
|
||||
|
||||
// Created by
|
||||
CreatedBy string `json:"createdBy"`
|
||||
|
||||
// Created time
|
||||
CreatedTime uint64 `json:"createdTime"`
|
||||
|
||||
// Deleted by
|
||||
DeletedBy string `json:"deletedBy"`
|
||||
|
||||
// Deleted time
|
||||
DeletedTime uint64 `json:"deletedTime"`
|
||||
|
||||
// Grid ID
|
||||
GID uint64 `json:"gid"`
|
||||
|
||||
// List of group IDs
|
||||
Groups []uint64 `json:"groups"`
|
||||
|
||||
// GUID
|
||||
GUID uint64 `json:"guid"`
|
||||
|
||||
// ID
|
||||
ID uint64 `json:"id"`
|
||||
|
||||
// Name
|
||||
Name string `json:"name"`
|
||||
|
||||
// Milestones
|
||||
Milestones uint64 `json:"milestones"`
|
||||
|
||||
// Parent service ID
|
||||
ParentSrvID uint64 `json:"parentSrvId"`
|
||||
|
||||
// Parent service type
|
||||
ParentSrvType string `json:"parentSrvType"`
|
||||
|
||||
// Resource group ID
|
||||
RGID uint64 `json:"rgId"`
|
||||
|
||||
// Resource group name
|
||||
RGName string `json:"rgName"`
|
||||
|
||||
// List of snapshots
|
||||
Snapshots ListSnapshots `json:"snapshots"`
|
||||
|
||||
// SSH key for connection
|
||||
SSHKey string `json:"sshKey"`
|
||||
|
||||
// SSH user
|
||||
SSHUser string `json:"sshUser"`
|
||||
|
||||
// Status
|
||||
Status string `json:"status"`
|
||||
|
||||
// TechStatus
|
||||
TechStatus string `json:"techStatus"`
|
||||
|
||||
// Updated by
|
||||
UpdatedBy string `json:"updatedBy"`
|
||||
|
||||
// Updated time
|
||||
UpdatedTime uint64 `json:"updatedTime"`
|
||||
|
||||
// User Managed or not
|
||||
UserManaged bool `json:"userManaged"`
|
||||
}
|
||||
|
||||
// List of Snapshots
|
||||
type ListInfoSnapshots struct {
|
||||
// Data
|
||||
Data ListSnapshots `json:"data"`
|
||||
|
||||
// EntryCount
|
||||
EntryCount uint64 `json:"entryCount"`
|
||||
}
|
||||
|
||||
// Main information about Group
|
||||
type RecordGroup struct {
|
||||
// Account ID
|
||||
AccountID uint64 `json:"accountId"`
|
||||
|
||||
// Account Name
|
||||
AccountName string `json:"accountName"`
|
||||
|
||||
// List of Computes
|
||||
Computes ListGroupComputes `json:"computes"`
|
||||
|
||||
// Consistency or not
|
||||
Consistency bool `json:"consistency"`
|
||||
|
||||
// Number of CPU
|
||||
CPU uint64 `json:"cpu"`
|
||||
|
||||
// Created by
|
||||
CreatedBy string `json:"createdBy"`
|
||||
|
||||
// Created time
|
||||
CreatedTime uint64 `json:"createdTime"`
|
||||
|
||||
// Deleted by
|
||||
DeletedBy string `json:"deletedBy"`
|
||||
|
||||
// Deleted time
|
||||
DeletedTime uint64 `json:"deletedTime"`
|
||||
|
||||
// Amount of disk
|
||||
Disk uint64 `json:"disk"`
|
||||
|
||||
// Driver
|
||||
Driver string `json:"driver"`
|
||||
|
||||
// list of External Network IDs
|
||||
ExtNets []uint64 `json:"extnets"`
|
||||
|
||||
// Grid ID
|
||||
GID uint64 `json:"gid"`
|
||||
|
||||
// GUID
|
||||
GUID uint64 `json:"guid"`
|
||||
|
||||
// ID
|
||||
ID uint64 `json:"id"`
|
||||
|
||||
// Image ID
|
||||
ImageID uint64 `json:"imageId"`
|
||||
|
||||
// Milestones
|
||||
Milestones uint64 `json:"milestones"`
|
||||
|
||||
// Name
|
||||
Name string `json:"name"`
|
||||
|
||||
// List of Parent IDs
|
||||
Parents []uint64 `json:"parents"`
|
||||
|
||||
// Pool name
|
||||
PoolName string `json:"poolName"`
|
||||
|
||||
// Number of RAM, MB
|
||||
RAM uint64 `json:"ram"`
|
||||
|
||||
// Resource group ID
|
||||
RGID uint64 `json:"rgId"`
|
||||
|
||||
// Resource group name
|
||||
RGName string `json:"rgName"`
|
||||
|
||||
// Role
|
||||
Role string `json:"role"`
|
||||
|
||||
// SEPID
|
||||
SEPID uint64 `json:"sepId"`
|
||||
|
||||
// Sequence number
|
||||
SeqNo uint64 `json:"seqNo"`
|
||||
|
||||
// Service ID
|
||||
ServiceID uint64 `json:"serviceId"`
|
||||
|
||||
// Status
|
||||
Status string `json:"status"`
|
||||
|
||||
// TechStatus
|
||||
TechStatus string `json:"techStatus"`
|
||||
|
||||
// Timeout Start
|
||||
TimeoutStart uint64 `json:"timeoutStart"`
|
||||
|
||||
// Updated by
|
||||
UpdatedBy string `json:"updatedBy"`
|
||||
|
||||
// Updated time
|
||||
UpdatedTime uint64 `json:"updatedTime"`
|
||||
|
||||
// List of VINS IDs
|
||||
VINSes []uint64 `json:"vinses"`
|
||||
}
|
||||
|
||||
// List of Group Computes
|
||||
type ListGroupComputes []ItemGroupCompute
|
||||
|
||||
// Main information about Group Compute
|
||||
type ItemGroupCompute struct {
|
||||
// ID
|
||||
ID uint64 `json:"id"`
|
||||
|
||||
// IP Addresses
|
||||
IPAddresses []string `json:"ipAddresses"`
|
||||
|
||||
// Name
|
||||
Name string `json:"name"`
|
||||
|
||||
// List of information about OS Users
|
||||
OSUsers ListOSUsers `json:"osUsers"`
|
||||
|
||||
//Chipset
|
||||
Chipset string `json:"chipset"`
|
||||
}
|
||||
|
||||
// List of information about OS Users
|
||||
type ListOSUsers []ItemOSUser
|
||||
|
||||
// Main information about OS User
|
||||
type ItemOSUser struct {
|
||||
// Login
|
||||
Login string `json:"login"`
|
||||
|
||||
// Password
|
||||
Password string `json:"password"`
|
||||
}
|
||||
38
pkg/cloudbroker/bservice/restore.go
Normal file
38
pkg/cloudbroker/bservice/restore.go
Normal file
@@ -0,0 +1,38 @@
|
||||
package bservice
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// RestoreRequest struct to restore BasicService instance
|
||||
type RestoreRequest struct {
|
||||
// ID of the BasicService to be restored
|
||||
// Required: true
|
||||
ServiceID uint64 `url:"serviceId" json:"serviceId" validate:"required"`
|
||||
}
|
||||
|
||||
// Restore restores BasicService instance
|
||||
func (b BService) Restore(ctx context.Context, req RestoreRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/bservice/restore"
|
||||
|
||||
res, err := b.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseBool(string(res))
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
42
pkg/cloudbroker/bservice/snapshot_create.go
Normal file
42
pkg/cloudbroker/bservice/snapshot_create.go
Normal file
@@ -0,0 +1,42 @@
|
||||
package bservice
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// SnapshotCreateRequest struct to create snapshot
|
||||
type SnapshotCreateRequest struct {
|
||||
// ID of the Basic Service
|
||||
// Required: true
|
||||
ServiceID uint64 `url:"serviceId" json:"serviceId" validate:"required"`
|
||||
|
||||
// Label of the snapshot
|
||||
// Required: true
|
||||
Label string `url:"label" json:"label" validate:"required"`
|
||||
}
|
||||
|
||||
// SnapshotCreate create snapshot of the Basic Service
|
||||
func (b BService) SnapshotCreate(ctx context.Context, req SnapshotCreateRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/bservice/snapshotCreate"
|
||||
|
||||
res, err := b.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseBool(string(res))
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
42
pkg/cloudbroker/bservice/snapshot_delete.go
Normal file
42
pkg/cloudbroker/bservice/snapshot_delete.go
Normal file
@@ -0,0 +1,42 @@
|
||||
package bservice
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// SnapshotDeleteRequest struct to delete snapshot
|
||||
type SnapshotDeleteRequest struct {
|
||||
// ID of the Basic Service
|
||||
// Required: true
|
||||
ServiceID uint64 `url:"serviceId" json:"serviceId" validate:"required"`
|
||||
|
||||
// Label of the snapshot
|
||||
// Required: true
|
||||
Label string `url:"label" json:"label" validate:"required"`
|
||||
}
|
||||
|
||||
// SnapshotDelete delete snapshot of the Basic Service
|
||||
func (b BService) SnapshotDelete(ctx context.Context, req SnapshotDeleteRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/bservice/snapshotDelete"
|
||||
|
||||
res, err := b.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseBool(string(res))
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
40
pkg/cloudbroker/bservice/snapshot_list.go
Normal file
40
pkg/cloudbroker/bservice/snapshot_list.go
Normal file
@@ -0,0 +1,40 @@
|
||||
package bservice
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// SnapshotListRequest struct to get list of existing snapshots
|
||||
type SnapshotListRequest struct {
|
||||
// ID of the Basic Service
|
||||
// Required: true
|
||||
ServiceID uint64 `url:"serviceId" json:"serviceId" validate:"required"`
|
||||
}
|
||||
|
||||
// SnapshotList gets list existing snapshots of the Basic Service
|
||||
func (b BService) SnapshotList(ctx context.Context, req SnapshotListRequest) (*ListInfoSnapshots, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/bservice/snapshotList"
|
||||
|
||||
res, err := b.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
list := ListInfoSnapshots{}
|
||||
|
||||
err = json.Unmarshal(res, &list)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &list, nil
|
||||
}
|
||||
42
pkg/cloudbroker/bservice/snapshot_rollback.go
Normal file
42
pkg/cloudbroker/bservice/snapshot_rollback.go
Normal file
@@ -0,0 +1,42 @@
|
||||
package bservice
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// SnapshotRollbackRequest struct to rollback snapshot
|
||||
type SnapshotRollbackRequest struct {
|
||||
// ID of the Basic Service
|
||||
// Required: true
|
||||
ServiceID uint64 `url:"serviceId" json:"serviceId" validate:"required"`
|
||||
|
||||
// Label of the snapshot
|
||||
// Required: true
|
||||
Label string `url:"label" json:"label" validate:"required"`
|
||||
}
|
||||
|
||||
// SnapshotRollback rollback snapshot of the Basic Service
|
||||
func (b BService) SnapshotRollback(ctx context.Context, req SnapshotRollbackRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/bservice/snapshotRollback"
|
||||
|
||||
res, err := b.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseBool(string(res))
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
60
pkg/cloudbroker/bservice/sorting.go
Normal file
60
pkg/cloudbroker/bservice/sorting.go
Normal file
@@ -0,0 +1,60 @@
|
||||
package bservice
|
||||
|
||||
import "sort"
|
||||
|
||||
// SortByCreatedTime sorts ListBasicServices by the CreatedTime field in ascending order.
|
||||
//
|
||||
// If inverse param is set to true, the order is reversed.
|
||||
func (lbs ListBasicServices) SortByCreatedTime(inverse bool) ListBasicServices {
|
||||
if lbs.EntryCount < 2 {
|
||||
return lbs
|
||||
}
|
||||
|
||||
sort.Slice(lbs.Data, func(i, j int) bool {
|
||||
if inverse {
|
||||
return lbs.Data[i].CreatedTime > lbs.Data[j].CreatedTime
|
||||
}
|
||||
|
||||
return lbs.Data[i].CreatedTime < lbs.Data[j].CreatedTime
|
||||
})
|
||||
|
||||
return lbs
|
||||
}
|
||||
|
||||
// SortByUpdatedTime sorts ListBasicServices by the UpdatedTime field in ascending order.
|
||||
//
|
||||
// If inverse param is set to true, the order is reversed.
|
||||
func (lbs ListBasicServices) SortByUpdatedTime(inverse bool) ListBasicServices {
|
||||
if lbs.EntryCount < 2 {
|
||||
return lbs
|
||||
}
|
||||
|
||||
sort.Slice(lbs.Data, func(i, j int) bool {
|
||||
if inverse {
|
||||
return lbs.Data[i].UpdatedTime > lbs.Data[j].UpdatedTime
|
||||
}
|
||||
|
||||
return lbs.Data[i].UpdatedTime < lbs.Data[j].UpdatedTime
|
||||
})
|
||||
|
||||
return lbs
|
||||
}
|
||||
|
||||
// SortByDeletedTime sorts ListBasicServices by the DeletedTime field in ascending order.
|
||||
//
|
||||
// If inverse param is set to true, the order is reversed.
|
||||
func (lbs ListBasicServices) SortByDeletedTime(inverse bool) ListBasicServices {
|
||||
if lbs.EntryCount < 2 {
|
||||
return lbs
|
||||
}
|
||||
|
||||
sort.Slice(lbs.Data, func(i, j int) bool {
|
||||
if inverse {
|
||||
return lbs.Data[i].DeletedTime > lbs.Data[j].DeletedTime
|
||||
}
|
||||
|
||||
return lbs.Data[i].DeletedTime < lbs.Data[j].DeletedTime
|
||||
})
|
||||
|
||||
return lbs
|
||||
}
|
||||
40
pkg/cloudbroker/bservice/start.go
Normal file
40
pkg/cloudbroker/bservice/start.go
Normal file
@@ -0,0 +1,40 @@
|
||||
package bservice
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// StartRequest struct to start service
|
||||
type StartRequest struct {
|
||||
// ID of the service to start
|
||||
// Required: true
|
||||
ServiceID uint64 `url:"serviceId" json:"serviceId" validate:"required"`
|
||||
}
|
||||
|
||||
// Start starts service.
|
||||
// Starting a service technically means starting computes from all
|
||||
// service groups according to group relations
|
||||
func (b BService) Start(ctx context.Context, req StartRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/bservice/start"
|
||||
|
||||
res, err := b.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseBool(string(res))
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
40
pkg/cloudbroker/bservice/stop.go
Normal file
40
pkg/cloudbroker/bservice/stop.go
Normal file
@@ -0,0 +1,40 @@
|
||||
package bservice
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// StopRequest struct to stop service
|
||||
type StopRequest struct {
|
||||
// ID of the service to stop
|
||||
// Required: true
|
||||
ServiceID uint64 `url:"serviceId" json:"serviceId" validate:"required"`
|
||||
}
|
||||
|
||||
// Stop stops service.
|
||||
// Stopping a service technically means stopping computes from
|
||||
// all service groups
|
||||
func (b BService) Stop(ctx context.Context, req StopRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/bservice/stop"
|
||||
|
||||
res, err := b.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseBool(string(res))
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
@@ -39,10 +39,6 @@ type CreateTemplateFromBlankRequest struct {
|
||||
// Required: false
|
||||
AccountID uint64 `url:"accountId,omitempty" json:"accountId,omitempty"`
|
||||
|
||||
// SEP ID
|
||||
// Required: false
|
||||
SepID uint64 `url:"sepId,omitempty" json:"sepId,omitempty"`
|
||||
|
||||
// Pool for image create
|
||||
// Required: false
|
||||
PoolName string `url:"poolName,omitempty" json:"poolName,omitempty"`
|
||||
|
||||
@@ -470,7 +470,7 @@ type ItemDisk struct {
|
||||
SizeUsed float64 `json:"sizeUsed"`
|
||||
|
||||
// Size available
|
||||
SizeAvailable uint64 `json:"sizeAvailable"`
|
||||
SizeAvailable float64 `json:"sizeAvailable"`
|
||||
|
||||
// List detailed snapshots
|
||||
Snapshots ListDetailedSnapshots `json:"snapshots"`
|
||||
@@ -485,7 +485,7 @@ type ItemDisk struct {
|
||||
Type string `json:"type"`
|
||||
|
||||
// Updated by
|
||||
UpdatedBy uint64 `json:"updatedBy"`
|
||||
UpdatedBy string `json:"updatedBy"`
|
||||
|
||||
// Virtual machine ID
|
||||
VMID uint64 `json:"vmid"`
|
||||
@@ -1074,8 +1074,8 @@ type RecordCompute struct {
|
||||
// Userdata
|
||||
Userdata interface{} `json:"userdata"`
|
||||
|
||||
// List VGPU IDs
|
||||
VGPUs []uint64 `json:"vgpus"`
|
||||
// List VGPU
|
||||
VGPUs []VGPUItem `json:"vgpus"`
|
||||
|
||||
// Virtual image ID
|
||||
VirtualImageID uint64 `json:"virtualImageId"`
|
||||
@@ -1087,6 +1087,65 @@ type RecordCompute struct {
|
||||
VNCPassword string `json:"vncPasswd"`
|
||||
}
|
||||
|
||||
type VGPUItem struct {
|
||||
// ID
|
||||
ID uint64 `json:"id"`
|
||||
|
||||
// GID
|
||||
GID uint64 `json:"gid"`
|
||||
|
||||
// Type
|
||||
Type string `json:"type"`
|
||||
|
||||
// Mode
|
||||
Mode string `json:"mode"`
|
||||
|
||||
// Status
|
||||
Status string `json:"status"`
|
||||
|
||||
// ProfileID
|
||||
ProfileID uint64 `json:"profileId"`
|
||||
|
||||
// RAM
|
||||
RAM uint64 `json:"ram"`
|
||||
|
||||
// LastUpdateTime
|
||||
LastUpdateTime uint64 `json:"lastUpdateTime"`
|
||||
|
||||
// CreatedTime
|
||||
CreatedTime uint64 `json:"createdTime"`
|
||||
|
||||
// DeletedTime
|
||||
DeletedTime uint64 `json:"deletedTime"`
|
||||
|
||||
// VMID
|
||||
VMID uint64 `json:"vmid"`
|
||||
|
||||
// PGPuid
|
||||
PGPuid uint64 `json:"pgpuid"`
|
||||
|
||||
// ReferenceID
|
||||
ReferenceID string `json:"referenceId"`
|
||||
|
||||
// AccountID
|
||||
AccountID uint64 `json:"accountId"`
|
||||
|
||||
// RgID
|
||||
RgID uint64 `json:"rgId"`
|
||||
|
||||
// LastClaimedBy
|
||||
LastClaimedBy uint64 `json:"lastClaimedBy"`
|
||||
|
||||
// PCISlot
|
||||
PCISlot uint64 `json:"pciSlot"`
|
||||
|
||||
// BusNumber
|
||||
BusNumber uint64 `json:"bus_number"`
|
||||
|
||||
// GUID
|
||||
GUID uint64 `json:"guid"`
|
||||
}
|
||||
|
||||
// Information about of disk IDs
|
||||
type ListInfoDisks []InfoDisk
|
||||
|
||||
|
||||
@@ -30,29 +30,26 @@ type UpdateRequest struct {
|
||||
// Default: none
|
||||
NumaAffinity string `url:"numaAffinity,omitempty" json:"numaAffinity,omitempty" validate:"omitempty,numaAffinity"`
|
||||
|
||||
// Run VM on dedicated CPUs. To use this feature, the system must be pre-configured by allocating CPUs on the physical node
|
||||
// Run VM on dedicated CPUs. To use this feature, the system must be pre-configured by allocating CPUs on the physical node, true or false
|
||||
// Required: false
|
||||
// Default: false
|
||||
CPUPin bool `url:"cpupin" json:"cpupin"`
|
||||
CPUPin interface{} `url:"cpupin,omitempty" json:"cpupin,omitempty" validate:"omitempty,isBool"`
|
||||
|
||||
// Type of the emulated system, Q35 or i440fx
|
||||
// Required: false
|
||||
Chipset string `url:"chipset,omitempty" json:"chipset,omitempty" validate:"omitempty,chipset"`
|
||||
|
||||
// Use Huge Pages to allocate RAM of the virtual machine. The system must be pre-configured by allocating Huge Pages on the physical node
|
||||
// Use Huge Pages to allocate RAM of the virtual machine. The system must be pre-configured by allocating Huge Pages on the physical node, true or false
|
||||
// Required: false
|
||||
// Default: false
|
||||
HPBacked bool `url:"hpBacked" json:"hpBacked"`
|
||||
HPBacked interface{} `url:"hpBacked,omitempty" json:"hpBacked,omitempty" validate:"omitempty,isBool"`
|
||||
|
||||
// Auto start when node restarted
|
||||
// Auto start when node restarted, true or false
|
||||
// Required: false
|
||||
// Default: false
|
||||
AutoStart bool `url:"autoStart" json:"autoStart"`
|
||||
AutoStart interface{} `url:"autoStart,omitempty" json:"autoStart,omitempty" validate:"omitempty,isBool"`
|
||||
|
||||
// Recommended isolated CPUs. Field is ignored if compute.cpupin=False or compute.pinned=False
|
||||
// Required: false
|
||||
PreferredCPU []int64 `url:"preferredCpu,omitempty" json:"preferredCpu,omitempty" validate:"omitempty,preferredCPU"`
|
||||
|
||||
|
||||
// VM type linux, windows or unknown
|
||||
// Required: false
|
||||
LoaderType string `url:"loaderType,omitempty" json:"loaderType,omitempty" validate:"omitempty,loaderType"`
|
||||
@@ -65,9 +62,9 @@ type UpdateRequest struct {
|
||||
// Required: false
|
||||
NetworkInterfaceNaming string `url:"networkInterfaceNaming,omitempty" json:"networkInterfaceNaming,omitempty" validate:"omitempty,networkInterfaceNaming"`
|
||||
|
||||
// Does this machine supports hot resize
|
||||
// Does this machine supports hot resize, true or false
|
||||
// Required: false
|
||||
HotResize bool `url:"hotResize,omitempty" json:"hotResize,omitempty"`
|
||||
HotResize interface{} `url:"hotResize,omitempty" json:"hotResize,omitempty" validate:"omitempty,isBool"`
|
||||
}
|
||||
|
||||
// Update updates some properties of the compute
|
||||
|
||||
@@ -5,11 +5,12 @@ import "testing"
|
||||
var disks = ListDisks{
|
||||
Data: []ItemDisk{
|
||||
{
|
||||
MachineID: 0,
|
||||
MachineName: "",
|
||||
|
||||
RecordDisk: RecordDisk{
|
||||
DeviceName: "vda",
|
||||
SEPType: "",
|
||||
MachineID: 0,
|
||||
MachineName: "",
|
||||
DeviceName: "vda",
|
||||
SEPType: "",
|
||||
InfoDisk: InfoDisk{
|
||||
AccountID: 132847,
|
||||
AccountName: "std_2",
|
||||
@@ -64,11 +65,12 @@ var disks = ListDisks{
|
||||
},
|
||||
},
|
||||
{
|
||||
MachineID: 0,
|
||||
MachineName: "",
|
||||
|
||||
RecordDisk: RecordDisk{
|
||||
DeviceName: "vda",
|
||||
SEPType: "",
|
||||
MachineID: 0,
|
||||
MachineName: "",
|
||||
DeviceName: "vda",
|
||||
SEPType: "",
|
||||
InfoDisk: InfoDisk{
|
||||
AccountID: 132852,
|
||||
AccountName: "std",
|
||||
|
||||
@@ -45,10 +45,6 @@ type FromPlatformDiskRequest struct {
|
||||
// Required: false
|
||||
AccountID uint64 `url:"accountId,omitempty" json:"accountId,omitempty"`
|
||||
|
||||
// SEP ID
|
||||
// Required: false
|
||||
SepID uint64 `url:"sepId,omitempty" json:"sepId,omitempty"`
|
||||
|
||||
// Pool for image create
|
||||
// Required: false
|
||||
PoolName string `url:"poolName,omitempty" json:"poolName,omitempty"`
|
||||
|
||||
@@ -156,7 +156,7 @@ type InfoDisk struct {
|
||||
Shareable bool `json:"shareable"`
|
||||
|
||||
// Size available
|
||||
SizeAvailable uint64 `json:"sizeAvailable"`
|
||||
SizeAvailable float64 `json:"sizeAvailable"`
|
||||
|
||||
// Size max
|
||||
SizeMax int64 `json:"sizeMax"`
|
||||
|
||||
@@ -1,39 +0,0 @@
|
||||
package image
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"os"
|
||||
)
|
||||
|
||||
// UploadImageFileResponse struct to enable image
|
||||
type UploadImageFileResponse struct {
|
||||
// ImageFileUri
|
||||
ImageFileUri string `json:"image_file_uri"`
|
||||
}
|
||||
|
||||
// UploadImageFile uploads file image to platform
|
||||
func (i Image) UploadImageFile(ctx context.Context, filePath string) (string, error) {
|
||||
file, err := os.ReadFile(filePath)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("can not read file %v", err)
|
||||
}
|
||||
|
||||
url := "/cloudbroker/image/uploadImageFile"
|
||||
|
||||
res, err := i.client.DecortApiCall(ctx, http.MethodPost, url, file)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
result := UploadImageFileResponse{}
|
||||
|
||||
err = json.Unmarshal(res, &result)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return result.ImageFileUri, nil
|
||||
}
|
||||
@@ -13,9 +13,9 @@ type EnableNodesRequest struct {
|
||||
// Required: true
|
||||
NIDs []uint64 `url:"nids" json:"nids" validate:"required"`
|
||||
|
||||
// Message
|
||||
// Reason
|
||||
// Required: false
|
||||
Message string `url:"message,omitempty" json:"message,omitempty"`
|
||||
Reason string `url:"reason,omitempty" json:"reason,omitempty"`
|
||||
}
|
||||
|
||||
// EnableNodes enables nodes from maintenance status to enabled
|
||||
|
||||
@@ -371,7 +371,7 @@ type Bridges struct {
|
||||
// Backplane1
|
||||
type Backplane1 struct {
|
||||
Interfaces []string `json:"interfaces"`
|
||||
NumaNode uint64 `json:"numa_node"`
|
||||
NumaNode int64 `json:"numa_node"`
|
||||
}
|
||||
|
||||
// Role
|
||||
|
||||
@@ -18,7 +18,7 @@ type ComputeMemoryAvailableRequest struct {
|
||||
ForLast uint64 `url:"forLast,omitempty" json:"forLast,omitempty"`
|
||||
|
||||
// The reading interval in seconds
|
||||
// Required: true
|
||||
// Required: false
|
||||
Step uint64 `url:"step,omitempty" json:"step,omitempty"`
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ type ComputeMemoryUnusedRequest struct {
|
||||
ForLast uint64 `url:"forLast,omitempty" json:"forLast,omitempty"`
|
||||
|
||||
// The reading interval in seconds
|
||||
// Required: true
|
||||
// Required: false
|
||||
Step uint64 `url:"step,omitempty" json:"step,omitempty"`
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ type ComputeMemoryUsableRequest struct {
|
||||
ForLast uint64 `url:"forLast,omitempty" json:"forLast,omitempty"`
|
||||
|
||||
// The reading interval in seconds
|
||||
// Required: true
|
||||
// Required: false
|
||||
Step uint64 `url:"step,omitempty" json:"step,omitempty"`
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ type ComputeMemoryUsageRequest struct {
|
||||
ForLast uint64 `url:"forLast,omitempty" json:"forLast,omitempty"`
|
||||
|
||||
// The reading interval in seconds
|
||||
// Required: true
|
||||
// Required: false
|
||||
Step uint64 `url:"step,omitempty" json:"step,omitempty"`
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ type ComputeMemoryUsedRequest struct {
|
||||
ForLast uint64 `url:"forLast,omitempty" json:"forLast,omitempty"`
|
||||
|
||||
// The reading interval in seconds
|
||||
// Required: true
|
||||
// Required: false
|
||||
Step uint64 `url:"step,omitempty" json:"step,omitempty"`
|
||||
}
|
||||
|
||||
|
||||
@@ -18,11 +18,11 @@ type ComputeReadBytesRequest struct {
|
||||
ForLast uint64 `url:"forLast,omitempty" json:"forLast,omitempty"`
|
||||
|
||||
// The reading interval in seconds
|
||||
// Required: true
|
||||
// Required: false
|
||||
Step uint64 `url:"step,omitempty" json:"step,omitempty"`
|
||||
|
||||
// Number of zeros after the decimal point
|
||||
// Required: true
|
||||
// Required: false
|
||||
DecimalPlaces uint64 `url:"decimalPlaces,omitempty" json:"decimalPlaces,omitempty"`
|
||||
}
|
||||
|
||||
|
||||
@@ -18,11 +18,11 @@ type ComputeReadRequestsRequest struct {
|
||||
ForLast uint64 `url:"forLast,omitempty" json:"forLast,omitempty"`
|
||||
|
||||
// The reading interval in seconds
|
||||
// Required: true
|
||||
// Required: false
|
||||
Step uint64 `url:"step,omitempty" json:"step,omitempty"`
|
||||
|
||||
// Number of zeros after the decimal point
|
||||
// Required: true
|
||||
// Required: false
|
||||
DecimalPlaces uint64 `url:"decimalPlaces,omitempty" json:"decimalPlaces,omitempty"`
|
||||
}
|
||||
|
||||
|
||||
@@ -18,11 +18,11 @@ type ComputeReceiveBytesRequest struct {
|
||||
ForLast uint64 `url:"forLast,omitempty" json:"forLast,omitempty"`
|
||||
|
||||
// The reading interval in seconds
|
||||
// Required: true
|
||||
// Required: false
|
||||
Step uint64 `url:"step,omitempty" json:"step,omitempty"`
|
||||
|
||||
// Number of zeros after the decimal point
|
||||
// Required: true
|
||||
// Required: false
|
||||
DecimalPlaces uint64 `url:"decimalPlaces,omitempty" json:"decimalPlaces,omitempty"`
|
||||
}
|
||||
|
||||
|
||||
@@ -18,11 +18,11 @@ type ComputeReceivePacketsRequest struct {
|
||||
ForLast uint64 `url:"forLast,omitempty" json:"forLast,omitempty"`
|
||||
|
||||
// The reading interval in seconds
|
||||
// Required: true
|
||||
// Required: false
|
||||
Step uint64 `url:"step,omitempty" json:"step,omitempty"`
|
||||
|
||||
// Number of zeros after the decimal point
|
||||
// Required: true
|
||||
// Required: false
|
||||
DecimalPlaces uint64 `url:"decimalPlaces,omitempty" json:"decimalPlaces,omitempty"`
|
||||
}
|
||||
|
||||
|
||||
@@ -18,11 +18,11 @@ type ComputeTransmitBytesRequest struct {
|
||||
ForLast uint64 `url:"forLast,omitempty" json:"forLast,omitempty"`
|
||||
|
||||
// The reading interval in seconds
|
||||
// Required: true
|
||||
// Required: false
|
||||
Step uint64 `url:"step,omitempty" json:"step,omitempty"`
|
||||
|
||||
// Number of zeros after the decimal point
|
||||
// Required: true
|
||||
// Required: false
|
||||
DecimalPlaces uint64 `url:"decimalPlaces,omitempty" json:"decimalPlaces,omitempty"`
|
||||
}
|
||||
|
||||
|
||||
@@ -18,11 +18,11 @@ type ComputeTransmitPacketsRequest struct {
|
||||
ForLast uint64 `url:"forLast,omitempty" json:"forLast,omitempty"`
|
||||
|
||||
// The reading interval in seconds
|
||||
// Required: true
|
||||
// Required: false
|
||||
Step uint64 `url:"step,omitempty" json:"step,omitempty"`
|
||||
|
||||
// Number of zeros after the decimal point
|
||||
// Required: true
|
||||
// Required: false
|
||||
DecimalPlaces uint64 `url:"decimalPlaces,omitempty" json:"decimalPlaces,omitempty"`
|
||||
}
|
||||
|
||||
|
||||
@@ -18,11 +18,11 @@ type ComputeWriteBytesRequest struct {
|
||||
ForLast uint64 `url:"forLast,omitempty" json:"forLast,omitempty"`
|
||||
|
||||
// The reading interval in seconds
|
||||
// Required: true
|
||||
// Required: false
|
||||
Step uint64 `url:"step,omitempty" json:"step,omitempty"`
|
||||
|
||||
// Number of zeros after the decimal point
|
||||
// Required: true
|
||||
// Required: false
|
||||
DecimalPlaces uint64 `url:"decimalPlaces,omitempty" json:"decimalPlaces,omitempty"`
|
||||
}
|
||||
|
||||
|
||||
@@ -18,11 +18,11 @@ type ComputeWriteRequestsRequest struct {
|
||||
ForLast uint64 `url:"forLast,omitempty" json:"forLast,omitempty"`
|
||||
|
||||
// The reading interval in seconds
|
||||
// Required: true
|
||||
// Required: false
|
||||
Step uint64 `url:"step,omitempty" json:"step,omitempty"`
|
||||
|
||||
// Number of zeros after the decimal point
|
||||
// Required: true
|
||||
// Required: false
|
||||
DecimalPlaces uint64 `url:"decimalPlaces,omitempty" json:"decimalPlaces,omitempty"`
|
||||
}
|
||||
|
||||
|
||||
@@ -38,11 +38,11 @@ type ComputesRequest struct {
|
||||
ForLast uint64 `url:"forLast,omitempty" json:"forLast,omitempty"`
|
||||
|
||||
// The reading interval in seconds
|
||||
// Required: true
|
||||
// Required: false
|
||||
Step uint64 `url:"step,omitempty" json:"step,omitempty"`
|
||||
|
||||
// Number of zeros after the decimal point
|
||||
// Required: true
|
||||
// Required: false
|
||||
DecimalPlaces uint64 `url:"decimalPlaces,omitempty" json:"decimalPlaces,omitempty"`
|
||||
}
|
||||
|
||||
|
||||
@@ -17,20 +17,19 @@ var rgs = ListRG{
|
||||
UserGroupID: "sample_user_1@decs3o",
|
||||
},
|
||||
},
|
||||
CreatedBy: "sample_user_1@decs3o",
|
||||
CreatedTime: 1676645305,
|
||||
DefNetID: 1,
|
||||
DefNetType: "NONE",
|
||||
DeletedBy: "",
|
||||
DeletedTime: 0,
|
||||
Description: "",
|
||||
GID: 212,
|
||||
GUID: 7971,
|
||||
ID: 7971,
|
||||
LockStatus: "UNLOCKED",
|
||||
Milestones: 363459,
|
||||
Name: "rg_1",
|
||||
RegisterComputes: false,
|
||||
CreatedBy: "sample_user_1@decs3o",
|
||||
CreatedTime: 1676645305,
|
||||
DefNetID: 1,
|
||||
DefNetType: "NONE",
|
||||
DeletedBy: "",
|
||||
DeletedTime: 0,
|
||||
Description: "",
|
||||
GID: 212,
|
||||
GUID: 7971,
|
||||
ID: 7971,
|
||||
LockStatus: "UNLOCKED",
|
||||
Milestones: 363459,
|
||||
Name: "rg_1",
|
||||
ResourceLimits: ResourceLimits{
|
||||
CUC: -1,
|
||||
CuD: -1,
|
||||
@@ -61,20 +60,19 @@ var rgs = ListRG{
|
||||
UserGroupID: "sample_user_1@decs3o",
|
||||
},
|
||||
},
|
||||
CreatedBy: "sample_user_1@decs3o",
|
||||
CreatedTime: 1676645461,
|
||||
DefNetID: 2,
|
||||
DefNetType: "NONE",
|
||||
DeletedBy: "",
|
||||
DeletedTime: 0,
|
||||
Description: "",
|
||||
GID: 212,
|
||||
GUID: 7972,
|
||||
ID: 7972,
|
||||
LockStatus: "UNLOCKED",
|
||||
Milestones: 363468,
|
||||
Name: "rg_2",
|
||||
RegisterComputes: false,
|
||||
CreatedBy: "sample_user_1@decs3o",
|
||||
CreatedTime: 1676645461,
|
||||
DefNetID: 2,
|
||||
DefNetType: "NONE",
|
||||
DeletedBy: "",
|
||||
DeletedTime: 0,
|
||||
Description: "",
|
||||
GID: 212,
|
||||
GUID: 7972,
|
||||
ID: 7972,
|
||||
LockStatus: "UNLOCKED",
|
||||
Milestones: 363468,
|
||||
Name: "rg_2",
|
||||
ResourceLimits: ResourceLimits{
|
||||
CUC: -1,
|
||||
CuD: -1,
|
||||
@@ -105,20 +103,19 @@ var rgs = ListRG{
|
||||
UserGroupID: "sample_user_2@decs3o",
|
||||
},
|
||||
},
|
||||
CreatedBy: "sample_user_2@decs3o",
|
||||
CreatedTime: 1676645548,
|
||||
DefNetID: 3,
|
||||
DefNetType: "NONE",
|
||||
DeletedBy: "",
|
||||
DeletedTime: 0,
|
||||
Description: "",
|
||||
GID: 212,
|
||||
GUID: 7973,
|
||||
ID: 7973,
|
||||
LockStatus: "kjLOCKED",
|
||||
Milestones: 363471,
|
||||
Name: "rg_3",
|
||||
RegisterComputes: false,
|
||||
CreatedBy: "sample_user_2@decs3o",
|
||||
CreatedTime: 1676645548,
|
||||
DefNetID: 3,
|
||||
DefNetType: "NONE",
|
||||
DeletedBy: "",
|
||||
DeletedTime: 0,
|
||||
Description: "",
|
||||
GID: 212,
|
||||
GUID: 7973,
|
||||
ID: 7973,
|
||||
LockStatus: "kjLOCKED",
|
||||
Milestones: 363471,
|
||||
Name: "rg_3",
|
||||
ResourceLimits: ResourceLimits{
|
||||
CUC: -1,
|
||||
CuD: -1,
|
||||
|
||||
@@ -196,9 +196,6 @@ type ItemRG struct {
|
||||
// Name
|
||||
Name string `json:"name"`
|
||||
|
||||
// Register computes
|
||||
RegisterComputes bool `json:"registerComputes"`
|
||||
|
||||
// Resource limits
|
||||
ResourceLimits ResourceLimits `json:"resourceLimits"`
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
1. Тесты находятся по директории `decort-sdk/tests/platform_upgrade`
|
||||
2. Внутри директории нужно создать и заполнить файл `.env` по аналогии с `.env.template` для доступа к платформе
|
||||
3. Внутри директории нужно создать и заполнить файл `input.json`, содержащий json с раздела [POST /system/docgenerator/prepareCatalog](https://delta.qa.loc/system/ActorApi?group=system#!/system__docgenerator/post_system_docgenerator_prepareCatalog) (для получения json нажать кнопку Try it Out!) - требуется только для тестов запросов и тестов API методов
|
||||
3. Внутри директории нужно создать и заполнить файл `input.json`, содержащий json из метода [POST /system/docgenerator/prepareCatalog](https://delta.qa.loc/portal/#/api/system) (для получения json нажать кнопку Try it Out!) - требуется только для тестов запросов и тестов API методов
|
||||
|
||||
Примечание: тесты можно запускать напрямую методами среды разработки либо из командной строки из нужной директории, например командой `go test -v -run <TestName>`, где `<TestName>` - название запускаемого теста.
|
||||
|
||||
|
||||
@@ -21,19 +21,19 @@ import (
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/stack"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/tasks"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/vins"
|
||||
disks_cb "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/disks"
|
||||
image_cb "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/image"
|
||||
node_cb "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/node"
|
||||
|
||||
account_cb "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/account"
|
||||
audit_cb "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/audit"
|
||||
bservice_cb "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/bservice"
|
||||
compute_cb "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/compute"
|
||||
disks_cb "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/disks"
|
||||
extnet_cb "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/extnet"
|
||||
flipgroup_cb "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/flipgroup"
|
||||
grid_cb "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/grid"
|
||||
image_cb "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/image"
|
||||
k8ci_cb "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/k8ci"
|
||||
k8s_cb "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/k8s"
|
||||
lb_cb "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/lb"
|
||||
node_cb "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/node"
|
||||
pcidevice_cb "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/pcidevice"
|
||||
rg_cb "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/rg"
|
||||
sep_cb "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/sep"
|
||||
@@ -51,8 +51,6 @@ func TestGetListCloudAPI(t *testing.T) {
|
||||
t.Fatalf("Cannot get client: %v", err)
|
||||
}
|
||||
|
||||
const logFileName = "test_get_list_cloudAPI.log"
|
||||
var testLogs []string
|
||||
// Account
|
||||
// List
|
||||
bytes, err = client.CloudAPI().Account().ListRaw(context.Background(), account.ListRequest{})
|
||||
@@ -60,7 +58,7 @@ func TestGetListCloudAPI(t *testing.T) {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
testLogs = append(testLogs, getResult("Account list", bytes, account.ListAccounts{}, t))
|
||||
getResult("Account list", bytes, account.ListAccounts{}, t)
|
||||
// Get
|
||||
listAcc, _ := client.CloudAPI().Account().List(context.Background(), account.ListRequest{})
|
||||
if len(listAcc.Data) > 0 {
|
||||
@@ -69,7 +67,7 @@ func TestGetListCloudAPI(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
testLogs = append(testLogs, getResult("Account get", bytes, account.RecordAccount{}, t))
|
||||
getResult("Account get", bytes, account.RecordAccount{}, t)
|
||||
} else {
|
||||
t.Errorf("Can not test Account get because account list is empty")
|
||||
}
|
||||
@@ -80,7 +78,7 @@ func TestGetListCloudAPI(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
testLogs = append(testLogs, getResult("Bservice list", bytes, bservice.ListBasicServices{}, t))
|
||||
getResult("Bservice list", bytes, bservice.ListBasicServices{}, t)
|
||||
// Get
|
||||
listBServ, _ := client.CloudAPI().BService().List(context.Background(), bservice.ListRequest{})
|
||||
if len(listBServ.Data) > 0 {
|
||||
@@ -89,7 +87,7 @@ func TestGetListCloudAPI(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
testLogs = append(testLogs, getResult("Bservice get", bytes, bservice.RecordBasicService{}, t))
|
||||
getResult("Bservice get", bytes, bservice.RecordBasicService{}, t)
|
||||
} else {
|
||||
t.Errorf("Can not test Bservice get because bservice list is empty")
|
||||
}
|
||||
@@ -100,7 +98,7 @@ func TestGetListCloudAPI(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
testLogs = append(testLogs, getResult("Compute list", bytes, compute.ListComputes{}, t))
|
||||
getResult("Compute list", bytes, compute.ListComputes{}, t)
|
||||
// Get
|
||||
listComp, _ := client.CloudAPI().Compute().List(context.Background(), compute.ListRequest{})
|
||||
if len(listComp.Data) > 0 {
|
||||
@@ -109,7 +107,7 @@ func TestGetListCloudAPI(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
testLogs = append(testLogs, getResult("Compute get", bytes, compute.RecordCompute{}, t))
|
||||
getResult("Compute get", bytes, compute.RecordCompute{}, t)
|
||||
} else {
|
||||
t.Errorf("Can not test Compute get because compute list is empty")
|
||||
}
|
||||
@@ -120,7 +118,7 @@ func TestGetListCloudAPI(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
testLogs = append(testLogs, getResult("Disk list", bytes, disks.ListDisks{}, t))
|
||||
getResult("Disk list", bytes, disks.ListDisks{}, t)
|
||||
// Get
|
||||
listDisk, _ := client.CloudAPI().Disks().List(context.Background(), disks.ListRequest{})
|
||||
if len(listDisk.Data) > 0 {
|
||||
@@ -129,7 +127,7 @@ func TestGetListCloudAPI(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
testLogs = append(testLogs, getResult("Disk get", bytes, disks.RecordDisk{}, t))
|
||||
getResult("Disk get", bytes, disks.RecordDisk{}, t)
|
||||
} else {
|
||||
t.Errorf("Can not test Disk get because disk list is empty")
|
||||
}
|
||||
@@ -140,7 +138,7 @@ func TestGetListCloudAPI(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
testLogs = append(testLogs, getResult("ExtNet list", bytes, extnet.ListExtNets{}, t))
|
||||
getResult("ExtNet list", bytes, extnet.ListExtNets{}, t)
|
||||
// Get
|
||||
listExtNet, _ := client.CloudAPI().ExtNet().List(context.Background(), extnet.ListRequest{})
|
||||
if len(listExtNet.Data) > 0 {
|
||||
@@ -149,7 +147,7 @@ func TestGetListCloudAPI(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
testLogs = append(testLogs, getResult("ExtNet get", bytes, extnet.RecordExtNet{}, t))
|
||||
getResult("ExtNet get", bytes, extnet.RecordExtNet{}, t)
|
||||
} else {
|
||||
t.Errorf("Can not test ExtNet get because listExtNet list is empty")
|
||||
}
|
||||
@@ -160,7 +158,7 @@ func TestGetListCloudAPI(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
testLogs = append(testLogs, getResult("FLIPGroup list", bytes, flipgroup.ListFLIPGroups{}, t))
|
||||
getResult("FLIPGroup list", bytes, flipgroup.ListFLIPGroups{}, t)
|
||||
// Get
|
||||
listFG, _ := client.CloudAPI().FLIPGroup().List(context.Background(), flipgroup.ListRequest{})
|
||||
if len(listFG.Data) > 0 {
|
||||
@@ -169,7 +167,7 @@ func TestGetListCloudAPI(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
testLogs = append(testLogs, getResult("FLIPGroup get", bytes, flipgroup.RecordFLIPGroup{}, t))
|
||||
getResult("FLIPGroup get", bytes, flipgroup.RecordFLIPGroup{}, t)
|
||||
} else {
|
||||
t.Errorf("Can not test FLIPGroup get because flipgroup list is empty")
|
||||
}
|
||||
@@ -180,7 +178,7 @@ func TestGetListCloudAPI(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
testLogs = append(testLogs, getResult("Image list", bytes, image.ListImages{}, t))
|
||||
getResult("Image list", bytes, image.ListImages{}, t)
|
||||
// Get
|
||||
listImg, _ := client.CloudAPI().Image().List(context.Background(), image.ListRequest{})
|
||||
if len(listImg.Data) > 0 {
|
||||
@@ -189,7 +187,7 @@ func TestGetListCloudAPI(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
testLogs = append(testLogs, getResult("Image get", bytes, image.RecordImage{}, t))
|
||||
getResult("Image get", bytes, image.RecordImage{}, t)
|
||||
} else {
|
||||
t.Errorf("Can not test Image get because Image list is empty")
|
||||
}
|
||||
@@ -200,7 +198,7 @@ func TestGetListCloudAPI(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
testLogs = append(testLogs, getResult("K8CI list", bytes, k8ci.ListK8CI{}, t))
|
||||
getResult("K8CI list", bytes, k8ci.ListK8CI{}, t)
|
||||
// Get
|
||||
listk8ci, _ := client.CloudAPI().K8CI().List(context.Background(), k8ci.ListRequest{})
|
||||
if len(listk8ci.Data) > 0 {
|
||||
@@ -209,7 +207,7 @@ func TestGetListCloudAPI(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
testLogs = append(testLogs, getResult("K8CI get", bytes, k8ci.RecordK8CI{}, t))
|
||||
getResult("K8CI get", bytes, k8ci.RecordK8CI{}, t)
|
||||
} else {
|
||||
t.Errorf("Can not test K8CI get because K8CI list is empty")
|
||||
}
|
||||
@@ -220,7 +218,7 @@ func TestGetListCloudAPI(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
testLogs = append(testLogs, getResult("K8S list", bytes, k8s.ListK8SClusters{}, t))
|
||||
getResult("K8S list", bytes, k8s.ListK8SClusters{}, t)
|
||||
// Get
|
||||
listk8s, _ := client.CloudAPI().K8S().List(context.Background(), k8s.ListRequest{})
|
||||
if len(listk8s.Data) > 0 {
|
||||
@@ -229,7 +227,7 @@ func TestGetListCloudAPI(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
testLogs = append(testLogs, getResult("K8S get", bytes, k8s.RecordK8S{}, t))
|
||||
getResult("K8S get", bytes, k8s.RecordK8S{}, t)
|
||||
} else {
|
||||
t.Errorf("Can not test K8S get because K8S list is empty")
|
||||
}
|
||||
@@ -240,7 +238,7 @@ func TestGetListCloudAPI(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
testLogs = append(testLogs, getResult("LB list", bytes, lb.ListLB{}, t))
|
||||
getResult("LB list", bytes, lb.ListLB{}, t)
|
||||
// Get
|
||||
listLB, _ := client.CloudAPI().LB().List(context.Background(), lb.ListRequest{})
|
||||
if len(listLB.Data) > 0 {
|
||||
@@ -249,7 +247,7 @@ func TestGetListCloudAPI(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
testLogs = append(testLogs, getResult("LB get", bytes, lb.RecordLB{}, t))
|
||||
getResult("LB get", bytes, lb.RecordLB{}, t)
|
||||
} else {
|
||||
t.Errorf("Can not test LB get because LB list is empty")
|
||||
}
|
||||
@@ -260,7 +258,7 @@ func TestGetListCloudAPI(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
testLogs = append(testLogs, getResult("Locations list", bytes, locations.ListLocations{}, t))
|
||||
getResult("Locations list", bytes, locations.ListLocations{}, t)
|
||||
|
||||
// RG
|
||||
// List
|
||||
@@ -268,7 +266,7 @@ func TestGetListCloudAPI(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
testLogs = append(testLogs, getResult("RG list", bytes, rg.ListResourceGroups{}, t))
|
||||
getResult("RG list", bytes, rg.ListResourceGroups{}, t)
|
||||
// Get
|
||||
listRG, _ := client.CloudAPI().RG().List(context.Background(), rg.ListRequest{})
|
||||
if len(listRG.Data) > 0 {
|
||||
@@ -277,7 +275,7 @@ func TestGetListCloudAPI(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
testLogs = append(testLogs, getResult("RG get", bytes, rg.RecordResourceGroup{}, t))
|
||||
getResult("RG get", bytes, rg.RecordResourceGroup{}, t)
|
||||
} else {
|
||||
t.Errorf("Can not test RG get because RG list is empty")
|
||||
}
|
||||
@@ -288,7 +286,7 @@ func TestGetListCloudAPI(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
testLogs = append(testLogs, getResult("SEP list", bytes, sep.ListAvailableSEP{}, t))
|
||||
getResult("SEP list", bytes, sep.ListAvailableSEP{}, t)
|
||||
|
||||
// Stack
|
||||
// List
|
||||
@@ -296,7 +294,7 @@ func TestGetListCloudAPI(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
testLogs = append(testLogs, getResult("Stack list", bytes, stack.ListStacks{}, t))
|
||||
getResult("Stack list", bytes, stack.ListStacks{}, t)
|
||||
|
||||
// Tasks
|
||||
// List
|
||||
@@ -304,7 +302,7 @@ func TestGetListCloudAPI(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
testLogs = append(testLogs, getResult("Tasks list", bytes, tasks.ListTasks{}, t))
|
||||
getResult("Tasks list", bytes, tasks.ListTasks{}, t)
|
||||
// Get
|
||||
listTasks, _ := client.CloudAPI().Tasks().List(context.Background(), tasks.ListRequest{})
|
||||
if len(listTasks.Data) > 0 {
|
||||
@@ -313,7 +311,7 @@ func TestGetListCloudAPI(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
testLogs = append(testLogs, getResult("Tasks get", bytes, tasks.RecordAsyncTask{}, t))
|
||||
getResult("Tasks get", bytes, tasks.RecordAsyncTask{}, t)
|
||||
} else {
|
||||
t.Errorf("Can not test Tasks get because Tasks list is empty")
|
||||
}
|
||||
@@ -324,7 +322,7 @@ func TestGetListCloudAPI(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
testLogs = append(testLogs, getResult("VINS list", bytes, vins.ListVINS{}, t))
|
||||
getResult("VINS list", bytes, vins.ListVINS{}, t)
|
||||
// Get
|
||||
listVINS, _ := client.CloudAPI().VINS().List(context.Background(), vins.ListRequest{})
|
||||
if len(listVINS.Data) > 0 {
|
||||
@@ -333,12 +331,11 @@ func TestGetListCloudAPI(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
testLogs = append(testLogs, getResult("VINS get", bytes, vins.RecordVINS{}, t))
|
||||
getResult("VINS get", bytes, vins.RecordVINS{}, t)
|
||||
} else {
|
||||
t.Errorf("Can not test VINS get because VINS list is empty")
|
||||
}
|
||||
|
||||
compareLogs(logFileName, testLogs, t, "get")
|
||||
}
|
||||
|
||||
// WARNING: not working correctly due to inclusions of tagless structures in cloudbroker
|
||||
@@ -351,15 +348,13 @@ func TestGetListCloudbroker(t *testing.T) {
|
||||
t.Fatalf("Cannot get client: %v", err)
|
||||
}
|
||||
|
||||
const logFileName = "test_get_list_cloudbroker.log"
|
||||
var testLogs = make([]string, 0)
|
||||
// Account
|
||||
// List
|
||||
bytes, err = client.CloudBroker().Account().ListRaw(context.Background(), account_cb.ListRequest{})
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
testLogs = append(testLogs, getResult("Account list", bytes, account_cb.ListAccounts{}, t))
|
||||
getResult("Account list", bytes, account_cb.ListAccounts{}, t)
|
||||
// Get
|
||||
listAcc, _ := client.CloudBroker().Account().List(context.Background(), account_cb.ListRequest{})
|
||||
if len(listAcc.Data) > 0 {
|
||||
@@ -368,7 +363,7 @@ func TestGetListCloudbroker(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
testLogs = append(testLogs, getResult("Account get", bytes, account_cb.RecordAccount{}, t))
|
||||
getResult("Account get", bytes, account_cb.RecordAccount{}, t)
|
||||
} else {
|
||||
t.Errorf("Can not test Account get because account list is empty")
|
||||
}
|
||||
@@ -379,7 +374,7 @@ func TestGetListCloudbroker(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
testLogs = append(testLogs, getResult("Audit list", bytes, audit_cb.ListAudits{}, t))
|
||||
getResult("Audit list", bytes, audit_cb.ListAudits{}, t)
|
||||
// Get
|
||||
listAudits, _ := client.CloudBroker().Audit().List(context.Background(), audit_cb.ListRequest{})
|
||||
if len(listAudits.Data) > 0 {
|
||||
@@ -388,18 +383,38 @@ func TestGetListCloudbroker(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
testLogs = append(testLogs, getResult("Audit get", bytes, audit_cb.RecordAudit{}, t))
|
||||
getResult("Audit get", bytes, audit_cb.RecordAudit{}, t)
|
||||
} else {
|
||||
t.Errorf("Can not test Audit get because Audit list is empty")
|
||||
}
|
||||
|
||||
// Bservice
|
||||
// List
|
||||
bytes, err = client.CloudBroker().BService().ListRaw(context.Background(), bservice_cb.ListRequest{})
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
getResult("Bservice list", bytes, bservice_cb.ListBasicServices{}, t)
|
||||
// Get
|
||||
listBServ, _ := client.CloudBroker().BService().List(context.Background(), bservice_cb.ListRequest{})
|
||||
if len(listBServ.Data) > 0 {
|
||||
id := listBServ.Data[0].ID
|
||||
bytes, err = client.CloudBroker().BService().GetRaw(context.Background(), bservice_cb.GetRequest{ServiceID: id})
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
getResult("Bservice get", bytes, bservice_cb.RecordBasicService{}, t)
|
||||
} else {
|
||||
t.Errorf("Can not test Bservice get because bservice list is empty")
|
||||
}
|
||||
|
||||
// Compute
|
||||
// List
|
||||
bytes, err = client.CloudBroker().Compute().ListRaw(context.Background(), compute_cb.ListRequest{})
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
testLogs = append(testLogs, getResult("Compute list", bytes, compute_cb.ListComputes{}, t))
|
||||
getResult("Compute list", bytes, compute_cb.ListComputes{}, t)
|
||||
// Get
|
||||
listComp, _ := client.CloudBroker().Compute().List(context.Background(), compute_cb.ListRequest{})
|
||||
if len(listComp.Data) > 0 {
|
||||
@@ -408,7 +423,7 @@ func TestGetListCloudbroker(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
testLogs = append(testLogs, getResult("Compute get", bytes, compute_cb.RecordCompute{}, t))
|
||||
getResult("Compute get", bytes, compute_cb.RecordCompute{}, t)
|
||||
} else {
|
||||
t.Errorf("Can not test Compute get because compute list is empty")
|
||||
}
|
||||
@@ -419,7 +434,7 @@ func TestGetListCloudbroker(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
testLogs = append(testLogs, getResult("Disk list", bytes, disks_cb.ListDisks{}, t))
|
||||
getResult("Disk list", bytes, disks_cb.ListDisks{}, t)
|
||||
// Get
|
||||
listDisk, _ := client.CloudBroker().Disks().List(context.Background(), disks_cb.ListRequest{})
|
||||
if len(listDisk.Data) > 0 {
|
||||
@@ -428,7 +443,7 @@ func TestGetListCloudbroker(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
testLogs = append(testLogs, getResult("Disk get", bytes, disks_cb.RecordDisk{}, t))
|
||||
getResult("Disk get", bytes, disks_cb.RecordDisk{}, t)
|
||||
} else {
|
||||
t.Errorf("Can not test Disk get because disk list is empty")
|
||||
}
|
||||
@@ -439,7 +454,7 @@ func TestGetListCloudbroker(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
testLogs = append(testLogs, getResult("ExtNet list", bytes, extnet_cb.ListExtNet{}, t))
|
||||
getResult("ExtNet list", bytes, extnet_cb.ListExtNet{}, t)
|
||||
// Get
|
||||
listExtNet, _ := client.CloudBroker().ExtNet().List(context.Background(), extnet_cb.ListRequest{})
|
||||
if len(listExtNet.Data) > 0 {
|
||||
@@ -448,7 +463,7 @@ func TestGetListCloudbroker(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
testLogs = append(testLogs, getResult("ExtNet get", bytes, extnet_cb.RecordExtNet{}, t))
|
||||
getResult("ExtNet get", bytes, extnet_cb.RecordExtNet{}, t)
|
||||
} else {
|
||||
t.Errorf("Can not test ExtNet get because listExtNet list is empty")
|
||||
}
|
||||
@@ -459,7 +474,7 @@ func TestGetListCloudbroker(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
testLogs = append(testLogs, getResult("FLIPGroup list", bytes, flipgroup_cb.ListFLIPGroups{}, t))
|
||||
getResult("FLIPGroup list", bytes, flipgroup_cb.ListFLIPGroups{}, t)
|
||||
// Get
|
||||
listFG, _ := client.CloudBroker().FLIPGroup().List(context.Background(), flipgroup_cb.ListRequest{})
|
||||
if len(listFG.Data) > 0 {
|
||||
@@ -468,7 +483,7 @@ func TestGetListCloudbroker(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
testLogs = append(testLogs, getResult("FLIPGroup get", bytes, flipgroup_cb.RecordFLIPGroup{}, t))
|
||||
getResult("FLIPGroup get", bytes, flipgroup_cb.RecordFLIPGroup{}, t)
|
||||
} else {
|
||||
t.Errorf("Can not test FLIPGroup get because flipgroup list is empty")
|
||||
}
|
||||
@@ -479,7 +494,7 @@ func TestGetListCloudbroker(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
testLogs = append(testLogs, getResult("Grid list", bytes, grid_cb.ListGrids{}, t))
|
||||
getResult("Grid list", bytes, grid_cb.ListGrids{}, t)
|
||||
// Get
|
||||
listGrid, _ := client.CloudBroker().Grid().List(context.Background(), grid_cb.ListRequest{})
|
||||
if len(listGrid.Data) > 0 {
|
||||
@@ -488,7 +503,7 @@ func TestGetListCloudbroker(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
testLogs = append(testLogs, getResult("Grid get", bytes, grid_cb.RecordGrid{}, t))
|
||||
getResult("Grid get", bytes, grid_cb.RecordGrid{}, t)
|
||||
} else {
|
||||
t.Errorf("Can not test Grid get because Grid list is empty")
|
||||
}
|
||||
@@ -499,7 +514,7 @@ func TestGetListCloudbroker(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
testLogs = append(testLogs, getResult("Image list", bytes, image_cb.ListImages{}, t))
|
||||
getResult("Image list", bytes, image_cb.ListImages{}, t)
|
||||
// Get
|
||||
listImg, _ := client.CloudBroker().Image().List(context.Background(), image_cb.ListRequest{})
|
||||
if len(listImg.Data) > 0 {
|
||||
@@ -508,7 +523,7 @@ func TestGetListCloudbroker(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
testLogs = append(testLogs, getResult("Image get", bytes, image_cb.RecordImage{}, t))
|
||||
getResult("Image get", bytes, image_cb.RecordImage{}, t)
|
||||
} else {
|
||||
t.Errorf("Can not test Image get because Image list is empty")
|
||||
}
|
||||
@@ -519,7 +534,7 @@ func TestGetListCloudbroker(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
testLogs = append(testLogs, getResult("K8CI list", bytes, k8ci_cb.ListK8CI{}, t))
|
||||
getResult("K8CI list", bytes, k8ci_cb.ListK8CI{}, t)
|
||||
// Get
|
||||
listk8ci, _ := client.CloudBroker().K8CI().List(context.Background(), k8ci_cb.ListRequest{})
|
||||
if len(listk8ci.Data) > 0 {
|
||||
@@ -528,7 +543,7 @@ func TestGetListCloudbroker(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
testLogs = append(testLogs, getResult("K8CI get", bytes, k8ci_cb.RecordK8CI{}, t))
|
||||
getResult("K8CI get", bytes, k8ci_cb.RecordK8CI{}, t)
|
||||
} else {
|
||||
t.Errorf("Can not test K8CI get because K8CI list is empty")
|
||||
}
|
||||
@@ -539,7 +554,7 @@ func TestGetListCloudbroker(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
testLogs = append(testLogs, getResult("K8S list", bytes, k8s_cb.ListK8S{}, t))
|
||||
getResult("K8S list", bytes, k8s_cb.ListK8S{}, t)
|
||||
// Get
|
||||
listk8s, _ := client.CloudBroker().K8S().List(context.Background(), k8s_cb.ListRequest{})
|
||||
if len(listk8s.Data) > 0 {
|
||||
@@ -548,7 +563,7 @@ func TestGetListCloudbroker(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
testLogs = append(testLogs, getResult("K8S get", bytes, k8s_cb.RecordK8S{}, t))
|
||||
getResult("K8S get", bytes, k8s_cb.RecordK8S{}, t)
|
||||
} else {
|
||||
t.Errorf("Can not test K8S get because K8S list is empty")
|
||||
}
|
||||
@@ -559,7 +574,7 @@ func TestGetListCloudbroker(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
testLogs = append(testLogs, getResult("LB list", bytes, lb_cb.ListLB{}, t))
|
||||
getResult("LB list", bytes, lb_cb.ListLB{}, t)
|
||||
// Get
|
||||
listLB, _ := client.CloudBroker().LB().List(context.Background(), lb_cb.ListRequest{})
|
||||
if len(listLB.Data) > 0 {
|
||||
@@ -568,7 +583,7 @@ func TestGetListCloudbroker(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
testLogs = append(testLogs, getResult("LB get", bytes, lb_cb.RecordLB{}, t))
|
||||
getResult("LB get", bytes, lb_cb.RecordLB{}, t)
|
||||
} else {
|
||||
t.Errorf("Can not test LB get because LB list is empty")
|
||||
}
|
||||
@@ -579,7 +594,7 @@ func TestGetListCloudbroker(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
testLogs = append(testLogs, getResult("Node list", bytes, node_cb.ListNodes{}, t))
|
||||
getResult("Node list", bytes, node_cb.ListNodes{}, t)
|
||||
// Get
|
||||
listNode, _ := client.CloudBroker().Node().List(context.Background(), node_cb.ListRequest{})
|
||||
if len(listLB.Data) > 0 {
|
||||
@@ -588,7 +603,7 @@ func TestGetListCloudbroker(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
testLogs = append(testLogs, getResult("Node get", bytes, node_cb.RecordNode{}, t))
|
||||
getResult("Node get", bytes, node_cb.RecordNode{}, t)
|
||||
} else {
|
||||
t.Errorf("Can not test Node get because LB list is empty")
|
||||
}
|
||||
@@ -599,7 +614,7 @@ func TestGetListCloudbroker(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
testLogs = append(testLogs, getResult("Pcidevice list", bytes, pcidevice_cb.ListPCIDevices{}, t))
|
||||
getResult("Pcidevice list", bytes, pcidevice_cb.ListPCIDevices{}, t)
|
||||
|
||||
// RG
|
||||
// List
|
||||
@@ -607,7 +622,7 @@ func TestGetListCloudbroker(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
testLogs = append(testLogs, getResult("RG list", bytes, rg_cb.ListRG{}, t))
|
||||
getResult("RG list", bytes, rg_cb.ListRG{}, t)
|
||||
// Get
|
||||
listRG, _ := client.CloudBroker().RG().List(context.Background(), rg_cb.ListRequest{})
|
||||
if len(listRG.Data) > 0 {
|
||||
@@ -616,7 +631,7 @@ func TestGetListCloudbroker(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
testLogs = append(testLogs, getResult("RG get", bytes, rg_cb.RecordRG{}, t))
|
||||
getResult("RG get", bytes, rg_cb.RecordRG{}, t)
|
||||
} else {
|
||||
t.Errorf("Can not test RG get because RG list is empty")
|
||||
}
|
||||
@@ -627,7 +642,7 @@ func TestGetListCloudbroker(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
testLogs = append(testLogs, getResult("SEP list", bytes, sep_cb.ListSEP{}, t))
|
||||
getResult("SEP list", bytes, sep_cb.ListSEP{}, t)
|
||||
// Get
|
||||
listSEP, _ := client.CloudBroker().SEP().List(context.Background(), sep_cb.ListRequest{})
|
||||
if len(listSEP.Data) > 0 {
|
||||
@@ -636,7 +651,7 @@ func TestGetListCloudbroker(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
testLogs = append(testLogs, getResult("SEP get", bytes, sep_cb.RecordSEP{}, t))
|
||||
getResult("SEP get", bytes, sep_cb.RecordSEP{}, t)
|
||||
} else {
|
||||
t.Errorf("Can not test SEP get because SEP list is empty")
|
||||
}
|
||||
@@ -645,7 +660,7 @@ func TestGetListCloudbroker(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
testLogs = append(testLogs, getResult("SEP and pools list", bytes, sep_cb.ListAvailableSEP{}, t))
|
||||
getResult("SEP and pools list", bytes, sep_cb.ListAvailableSEP{}, t)
|
||||
|
||||
// Stack
|
||||
// List
|
||||
@@ -653,7 +668,7 @@ func TestGetListCloudbroker(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
testLogs = append(testLogs, getResult("Stack list", bytes, stack_cb.ListStacks{}, t))
|
||||
getResult("Stack list", bytes, stack_cb.ListStacks{}, t)
|
||||
// Get
|
||||
listStack, _ := client.CloudBroker().Stack().List(context.Background(), stack_cb.ListRequest{})
|
||||
if len(listStack.Data) > 0 {
|
||||
@@ -662,7 +677,7 @@ func TestGetListCloudbroker(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
testLogs = append(testLogs, getResult("Stack get", bytes, stack_cb.InfoStack{}, t))
|
||||
getResult("Stack get", bytes, stack_cb.InfoStack{}, t)
|
||||
} else {
|
||||
t.Errorf("Can not test Stack get because Stack list is empty")
|
||||
}
|
||||
@@ -673,7 +688,7 @@ func TestGetListCloudbroker(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
testLogs = append(testLogs, getResult("Tasks list", bytes, tasks_cb.ListTasks{}, t))
|
||||
getResult("Tasks list", bytes, tasks_cb.ListTasks{}, t)
|
||||
|
||||
// VINS
|
||||
// List
|
||||
@@ -681,7 +696,7 @@ func TestGetListCloudbroker(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
testLogs = append(testLogs, getResult("VINS list", bytes, vins_cb.ListVINS{}, t))
|
||||
getResult("VINS list", bytes, vins_cb.ListVINS{}, t)
|
||||
// Get
|
||||
listVINS, _ := client.CloudBroker().VINS().List(context.Background(), vins_cb.ListRequest{})
|
||||
if len(listVINS.Data) > 0 {
|
||||
@@ -690,11 +705,10 @@ func TestGetListCloudbroker(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
testLogs = append(testLogs, getResult("VINS get", bytes, vins_cb.RecordVINS{}, t))
|
||||
getResult("VINS get", bytes, vins_cb.RecordVINS{}, t)
|
||||
} else {
|
||||
t.Errorf("Can not test VINS get because VINS list is empty")
|
||||
}
|
||||
compareLogs(logFileName, testLogs, t, "get")
|
||||
}
|
||||
|
||||
// TestRequestsCloudAPI tests platform requests vs. golang request structures in sdk for cloudapi requests
|
||||
@@ -737,4 +751,38 @@ func TestGetAllPaths(t *testing.T) {
|
||||
}
|
||||
t.Errorf(errorText)
|
||||
}
|
||||
|
||||
caTestUrls := getRequestsMapCloudAPI()
|
||||
cbTestUrls := getRequestsMapCloudbroker()
|
||||
|
||||
urlsInTest := make([]string, len(caTestUrls)+len(cbTestUrls))
|
||||
|
||||
i := 0
|
||||
for k := range caTestUrls {
|
||||
urlsInTest[i] = k
|
||||
i++
|
||||
}
|
||||
for k := range cbTestUrls {
|
||||
urlsInTest[i] = k
|
||||
i++
|
||||
}
|
||||
|
||||
missingUrls = getMissingDecortUrls(jsonUrls, urlsInTest)
|
||||
if len(missingUrls) > 0 {
|
||||
errorText := fmt.Sprintf("Below API handlers (%d in total) need to be added to request map:\n", len(missingUrls))
|
||||
for _, r := range missingUrls {
|
||||
errorText += fmt.Sprintln(r)
|
||||
}
|
||||
t.Errorf(errorText)
|
||||
}
|
||||
|
||||
deprecatedUrls = getDeprecatedDecortUrls(jsonUrls, urlsInTest)
|
||||
if len(deprecatedUrls) > 0 {
|
||||
errorText := fmt.Sprintf("Below API handlers (%d in total) need to be delete to request map:\n", len(deprecatedUrls))
|
||||
for _, r := range deprecatedUrls {
|
||||
errorText += fmt.Sprintln(r)
|
||||
}
|
||||
t.Errorf(errorText)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -16,7 +16,9 @@ import (
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/lb"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/locations"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/pcidevice"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/prometheus"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/rg"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/sep"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/stack"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/tasks"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/user"
|
||||
@@ -41,6 +43,7 @@ import (
|
||||
lb_cb "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/lb"
|
||||
node_cb "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/node"
|
||||
pcidevice_cb "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/pcidevice"
|
||||
prometheus_cb "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/prometheus"
|
||||
rg_cb "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/rg"
|
||||
sep_cb "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/sep"
|
||||
stack_cb "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/stack"
|
||||
@@ -188,6 +191,8 @@ func getRequestsMapCloudAPI() map[string]interface{} {
|
||||
"/restmachine/cloudapi/compute/userList": compute.UserListRequest{},
|
||||
"/restmachine/cloudapi/compute/userRevoke": compute.UserRevokeRequest{},
|
||||
"/restmachine/cloudapi/compute/userUpdate": compute.UserUpdateRequest{},
|
||||
"/restmachine/cloudapi/compute/changeMac": compute.ChangeMACRequest{},
|
||||
"/restmachine/cloudapi/compute/changeIp": compute.ChangeIPRequest{},
|
||||
|
||||
// disks
|
||||
"/restmachine/cloudapi/disks/create": disks.CreateRequest{},
|
||||
@@ -315,6 +320,23 @@ func getRequestsMapCloudAPI() map[string]interface{} {
|
||||
// pcidevice
|
||||
"/restmachine/cloudapi/pcidevice/list": pcidevice.ListRequest{},
|
||||
|
||||
// prometheus
|
||||
"/restmachine/cloudapi/prometheus/computeTransmitPackets": prometheus.ComputeTransmitPacketsRequest{},
|
||||
"/restmachine/cloudapi/prometheus/computeWriteRequests": prometheus.ComputeWriteRequestsRequest{},
|
||||
"/restmachine/cloudapi/prometheus/computeCPUload": prometheus.ComputeCPULoadRequest{},
|
||||
"/restmachine/cloudapi/prometheus/computeTransmitBytes": prometheus.ComputeTransmitBytesRequest{},
|
||||
"/restmachine/cloudapi/prometheus/computeMemoryUsed": prometheus.ComputeMemoryUsedRequest{},
|
||||
"/restmachine/cloudapi/prometheus/computeMemoryUsable": prometheus.ComputeMemoryUsableRequest{},
|
||||
"/restmachine/cloudapi/prometheus/computeMemoryAvailable": prometheus.ComputeMemoryAvailableRequest{},
|
||||
"/restmachine/cloudapi/prometheus/computeReceiveBytes": prometheus.ComputeReceiveBytesRequest{},
|
||||
"/restmachine/cloudapi/prometheus/computes": prometheus.ComputesRequest{},
|
||||
"/restmachine/cloudapi/prometheus/computeReceivePackets": prometheus.ComputeReceivePacketsRequest{},
|
||||
"/restmachine/cloudapi/prometheus/computeReadRequests": prometheus.ComputeReadRequestsRequest{},
|
||||
"/restmachine/cloudapi/prometheus/computeWriteBytes": prometheus.ComputeWriteBytesRequest{},
|
||||
"/restmachine/cloudapi/prometheus/computeReadBytes": prometheus.ComputeReadBytesRequest{},
|
||||
"/restmachine/cloudapi/prometheus/computeMemoryUsage": prometheus.ComputeMemoryUsageRequest{},
|
||||
"/restmachine/cloudapi/prometheus/computeMemoryUnused": prometheus.ComputeMemoryUnusedRequest{},
|
||||
|
||||
// rg
|
||||
"/restmachine/cloudapi/rg/accessGrant": rg.AccessGrantRequest{},
|
||||
"/restmachine/cloudapi/rg/accessRevoke": rg.AccessRevokeRequest{},
|
||||
@@ -339,6 +361,10 @@ func getRequestsMapCloudAPI() map[string]interface{} {
|
||||
"/restmachine/cloudapi/rg/setDefNet": rg.SetDefNetRequest{},
|
||||
"/restmachine/cloudapi/rg/update": rg.UpdateRequest{},
|
||||
"/restmachine/cloudapi/rg/usage": rg.UsageRequest{},
|
||||
"/restmachine/cloudapi/rg/removeDefNet": rg.RemoveDefNetRequest{},
|
||||
|
||||
// sep
|
||||
"/restmachine/cloudapi/sep/listAvailableSepAndPools": sep.ListAvailableSEPAndPoolsRequest{},
|
||||
|
||||
// stack, tasks
|
||||
"/restmachine/cloudapi/stack/get": stack.GetRequest{},
|
||||
@@ -427,27 +453,28 @@ func getRequestsMapCloudbroker() map[string]interface{} {
|
||||
"/restmachine/cloudbroker/account/updateUser": account_cb.UpdateUserRequest{},
|
||||
|
||||
// apiaccess_cb
|
||||
"/restmachine/cloudbroker/apiaccess/apisExclude": apiaccess_cb.APIsExcludeRequest{},
|
||||
"/restmachine/cloudbroker/apiaccess/apiFind": apiaccess_cb.APIFindRequest{},
|
||||
"/restmachine/cloudbroker/apiaccess/apisInclude": apiaccess_cb.APIsIncludeRequest{},
|
||||
"/restmachine/cloudbroker/apiaccess/copy": apiaccess_cb.CopyRequest{},
|
||||
"/restmachine/cloudbroker/apiaccess/create": apiaccess_cb.CreateRequest{},
|
||||
"/restmachine/cloudbroker/apiaccess/delete": apiaccess_cb.DeleteRequest{},
|
||||
"/restmachine/cloudbroker/apiaccess/descUpdate": apiaccess_cb.DescUpdateRequest{},
|
||||
"/restmachine/cloudbroker/apiaccess/get": apiaccess_cb.GetRequest{},
|
||||
"/restmachine/cloudbroker/apiaccess/getFull": EmptyStruct{},
|
||||
"/restmachine/cloudbroker/apiaccess/getPreGroups": EmptyStruct{},
|
||||
"/restmachine/cloudbroker/apiaccess/list": apiaccess_cb.ListRequest{},
|
||||
"/restmachine/cloudbroker/apiaccess/setDefault": apiaccess_cb.SetDefaultRequest{},
|
||||
"/restmachine/cloudbroker/apiaccess/subtract": apiaccess_cb.SubtractRequest{},
|
||||
"/restmachine/cloudbroker/apiaccess/union": apiaccess_cb.UnionRequest{},
|
||||
"/restmachine/cloudbroker/apiaccess/update": apiaccess_cb.UpdateRequest{},
|
||||
"/restmachine/cloudbroker/apiaccess/userList": apiaccess_cb.UserListRequest{},
|
||||
"/restmachine/cloudbroker/apiaccess/apisExclude": apiaccess_cb.APIsExcludeRequest{},
|
||||
"/restmachine/cloudbroker/apiaccess/apiFind": apiaccess_cb.APIFindRequest{},
|
||||
"/restmachine/cloudbroker/apiaccess/apisInclude": apiaccess_cb.APIsIncludeRequest{},
|
||||
"/restmachine/cloudbroker/apiaccess/copy": apiaccess_cb.CopyRequest{},
|
||||
"/restmachine/cloudbroker/apiaccess/create": apiaccess_cb.CreateRequest{},
|
||||
"/restmachine/cloudbroker/apiaccess/delete": apiaccess_cb.DeleteRequest{},
|
||||
"/restmachine/cloudbroker/apiaccess/descUpdate": apiaccess_cb.DescUpdateRequest{},
|
||||
"/restmachine/cloudbroker/apiaccess/get": apiaccess_cb.GetRequest{},
|
||||
"/restmachine/cloudbroker/apiaccess/getFull": EmptyStruct{},
|
||||
"/restmachine/cloudbroker/apiaccess/list": apiaccess_cb.ListRequest{},
|
||||
"/restmachine/cloudbroker/apiaccess/setDefault": apiaccess_cb.SetDefaultRequest{},
|
||||
"/restmachine/cloudbroker/apiaccess/subtract": apiaccess_cb.SubtractRequest{},
|
||||
"/restmachine/cloudbroker/apiaccess/union": apiaccess_cb.UnionRequest{},
|
||||
"/restmachine/cloudbroker/apiaccess/update": apiaccess_cb.UpdateRequest{},
|
||||
"/restmachine/cloudbroker/apiaccess/userList": apiaccess_cb.UserListRequest{},
|
||||
"/restmachine/cloudbroker/apiaccess/getDefault": EmptyStruct{},
|
||||
|
||||
// audit_cb
|
||||
"/restmachine/cloudbroker/audit/get": audit_cb.GetRequest{},
|
||||
"/restmachine/cloudbroker/audit/linkedJobs": audit_cb.LinkedJobsRequest{},
|
||||
"/restmachine/cloudbroker/audit/list": audit_cb.ListRequest{},
|
||||
"/restmachine/cloudbroker/audit/get": audit_cb.GetRequest{},
|
||||
"/restmachine/cloudbroker/audit/linkedJobs": audit_cb.LinkedJobsRequest{},
|
||||
"/restmachine/cloudbroker/audit/list": audit_cb.ListRequest{},
|
||||
"/restmachine/cloudbroker/audit/exportAuditsToFile": EmptyStruct{},
|
||||
|
||||
// backup_cb
|
||||
"/restmachine/cloudbroker/backup/createDiskBackup": backup_cb.CreateDiskBackupRequest{},
|
||||
@@ -548,6 +575,9 @@ func getRequestsMapCloudbroker() map[string]interface{} {
|
||||
"/restmachine/cloudbroker/compute/userList": compute_cb.UserListRequest{},
|
||||
"/restmachine/cloudbroker/compute/userRevoke": compute_cb.UserRevokeRequest{},
|
||||
"/restmachine/cloudbroker/compute/userUpdate": compute_cb.UserUpdateRequest{},
|
||||
"/restmachine/cloudbroker/compute/changeIp": compute_cb.ChangeIPRequest{},
|
||||
"/restmachine/cloudbroker/compute/changeMac": compute_cb.ChangeMACRequest{},
|
||||
"/restmachine/cloudbroker/compute/setNetConfig": compute_cb.SetNetConfigRequest{},
|
||||
|
||||
// disks
|
||||
"/restmachine/cloudbroker/disks/create": disks_cb.CreateRequest{},
|
||||
@@ -570,7 +600,6 @@ func getRequestsMapCloudbroker() map[string]interface{} {
|
||||
"/restmachine/cloudbroker/disks/replicationStatus": disks_cb.ReplicationStatusRequest{},
|
||||
"/restmachine/cloudbroker/disks/replicationStop": disks_cb.ReplicationStopRequest{},
|
||||
"/restmachine/cloudbroker/disks/replicationSuspend": disks_cb.ReplicationSuspendRequest{},
|
||||
"/restmachine/cloudbroker/disks/resize": disks_cb.ResizeRequest{},
|
||||
"/restmachine/cloudbroker/disks/resize2": disks_cb.ResizeRequest{},
|
||||
"/restmachine/cloudbroker/disks/restore": disks_cb.RestoreRequest{},
|
||||
"/restmachine/cloudbroker/disks/search": disks_cb.SearchRequest{},
|
||||
@@ -652,6 +681,7 @@ func getRequestsMapCloudbroker() map[string]interface{} {
|
||||
"/restmachine/cloudbroker/grid/setMemAllocationRatio": grid_cb.SetMemAllocationRatioRequest{},
|
||||
"/restmachine/cloudbroker/grid/setPasswordPolicy": grid_cb.SetPasswordPolicyRequest{},
|
||||
"/restmachine/cloudbroker/grid/status": EmptyStruct{},
|
||||
"/restmachine/cloudbroker/grid/getSettings": grid_cb.GetSettingsRequest{},
|
||||
|
||||
// group
|
||||
"/restmachine/cloudbroker/group/get": group_cb.GetRequest{},
|
||||
@@ -768,6 +798,7 @@ func getRequestsMapCloudbroker() map[string]interface{} {
|
||||
"/restmachine/cloudbroker/node/setsriovstatus": node_cb.SetSRIOVStatusRequest{},
|
||||
"/restmachine/cloudbroker/node/setVFsNumber": node_cb.SetVFsNumberRequest{},
|
||||
"/restmachine/cloudbroker/node/update": node_cb.UpdateRequest{},
|
||||
"/restmachine/cloudbroker/node/setVFsParams": node_cb.VFParam{},
|
||||
|
||||
// pcidevice
|
||||
"/restmachine/cloudbroker/pcidevice/create": pcidevice_cb.CreateRequest{},
|
||||
@@ -776,6 +807,23 @@ func getRequestsMapCloudbroker() map[string]interface{} {
|
||||
"/restmachine/cloudbroker/pcidevice/enable": pcidevice_cb.EnableRequest{},
|
||||
"/restmachine/cloudbroker/pcidevice/list": pcidevice_cb.ListRequest{},
|
||||
|
||||
// prometheus
|
||||
"/restmachine/cloudbroker/prometheus/computeTransmitPackets": prometheus_cb.ComputeTransmitPacketsRequest{},
|
||||
"/restmachine/cloudbroker/prometheus/computeWriteRequests": prometheus_cb.ComputeWriteRequestsRequest{},
|
||||
"/restmachine/cloudbroker/prometheus/computeCPUload": prometheus_cb.ComputeCPULoadRequest{},
|
||||
"/restmachine/cloudbroker/prometheus/computeTransmitBytes": prometheus_cb.ComputeTransmitBytesRequest{},
|
||||
"/restmachine/cloudbroker/prometheus/computeMemoryUsed": prometheus_cb.ComputeMemoryUsedRequest{},
|
||||
"/restmachine/cloudbroker/prometheus/computeMemoryUsable": prometheus_cb.ComputeMemoryUsableRequest{},
|
||||
"/restmachine/cloudbroker/prometheus/computeMemoryAvailable": prometheus_cb.ComputeMemoryAvailableRequest{},
|
||||
"/restmachine/cloudbroker/prometheus/computeReceiveBytes": prometheus_cb.ComputeReceiveBytesRequest{},
|
||||
"/restmachine/cloudbroker/prometheus/computes": prometheus_cb.ComputesRequest{},
|
||||
"/restmachine/cloudbroker/prometheus/computeReceivePackets": prometheus_cb.ComputeReceivePacketsRequest{},
|
||||
"/restmachine/cloudbroker/prometheus/computeReadRequests": prometheus_cb.ComputeReadRequestsRequest{},
|
||||
"/restmachine/cloudbroker/prometheus/computeWriteBytes": prometheus_cb.ComputeWriteBytesRequest{},
|
||||
"/restmachine/cloudbroker/prometheus/computeReadBytes": prometheus_cb.ComputeReadBytesRequest{},
|
||||
"/restmachine/cloudbroker/prometheus/computeMemoryUsage": prometheus_cb.ComputeMemoryUsageRequest{},
|
||||
"/restmachine/cloudbroker/prometheus/computeMemoryUnused": prometheus_cb.ComputeMemoryUnusedRequest{},
|
||||
|
||||
// rg
|
||||
"/restmachine/cloudbroker/rg/accessGrant": rg_cb.AccessGrantRequest{},
|
||||
"/restmachine/cloudbroker/rg/accessRevoke": rg_cb.AccessRevokeRequest{},
|
||||
@@ -807,31 +855,35 @@ func getRequestsMapCloudbroker() map[string]interface{} {
|
||||
"/restmachine/cloudbroker/rg/updateComputeFeatures": rg_cb.UpdateComputeFeaturesRequest{},
|
||||
"/restmachine/cloudbroker/rg/updateResourceTypes": rg_cb.UpdateResourceTypesRequest{},
|
||||
"/restmachine/cloudbroker/rg/usage": rg_cb.UsageRequest{},
|
||||
"/restmachine/cloudbroker/rg/removeDefNet": rg_cb.RemoveDefNetRequest{},
|
||||
|
||||
// sep
|
||||
"/restmachine/cloudbroker/sep/accessGrant": sep_cb.AccessGrantRequest{},
|
||||
"/restmachine/cloudbroker/sep/accessGrantToPool": sep_cb.AccessGrantToPoolRequest{},
|
||||
"/restmachine/cloudbroker/sep/accessRevoke": sep_cb.AccessRevokeRequest{},
|
||||
"/restmachine/cloudbroker/sep/accessRevokeToPool": sep_cb.AccessRevokeToPoolRequest{},
|
||||
"/restmachine/cloudbroker/sep/addConsumerNodes": sep_cb.AddConsumerNodesRequest{},
|
||||
"/restmachine/cloudbroker/sep/addPool": sep_cb.AddPoolRequest{},
|
||||
"/restmachine/cloudbroker/sep/addProviderNodes": sep_cb.AddProviderNodesRequest{},
|
||||
"/restmachine/cloudbroker/sep/configFieldEdit": sep_cb.ConfigFieldEditRequest{},
|
||||
"/restmachine/cloudbroker/sep/configInsert": sep_cb.ConfigInsertRequest{},
|
||||
"/restmachine/cloudbroker/sep/configValidate": sep_cb.ConfigValidateRequest{},
|
||||
"/restmachine/cloudbroker/sep/consumption": sep_cb.ConsumptionRequest{},
|
||||
"/restmachine/cloudbroker/sep/create": sep_cb.CreateRequest{},
|
||||
"/restmachine/cloudbroker/sep/decommission": sep_cb.DecommissionRequest{},
|
||||
"/restmachine/cloudbroker/sep/delConsumerNodes": sep_cb.DelConsumerNodesRequest{},
|
||||
"/restmachine/cloudbroker/sep/delete": sep_cb.DeleteRequest{},
|
||||
"/restmachine/cloudbroker/sep/delPool": sep_cb.DelPoolRequest{},
|
||||
"/restmachine/cloudbroker/sep/disable": sep_cb.DisableRequest{},
|
||||
"/restmachine/cloudbroker/sep/diskList": sep_cb.DiskListRequest{},
|
||||
"/restmachine/cloudbroker/sep/enable": sep_cb.EnableRequest{},
|
||||
"/restmachine/cloudbroker/sep/get": sep_cb.GetRequest{},
|
||||
"/restmachine/cloudbroker/sep/getConfig": sep_cb.GetConfigRequest{},
|
||||
"/restmachine/cloudbroker/sep/getPool": sep_cb.GetPoolRequest{},
|
||||
"/restmachine/cloudbroker/sep/list": sep_cb.ListRequest{},
|
||||
"/restmachine/cloudbroker/sep/accessGrant": sep_cb.AccessGrantRequest{},
|
||||
"/restmachine/cloudbroker/sep/accessGrantToPool": sep_cb.AccessGrantToPoolRequest{},
|
||||
"/restmachine/cloudbroker/sep/accessRevoke": sep_cb.AccessRevokeRequest{},
|
||||
"/restmachine/cloudbroker/sep/accessRevokeToPool": sep_cb.AccessRevokeToPoolRequest{},
|
||||
"/restmachine/cloudbroker/sep/addConsumerNodes": sep_cb.AddConsumerNodesRequest{},
|
||||
"/restmachine/cloudbroker/sep/addPool": sep_cb.AddPoolRequest{},
|
||||
"/restmachine/cloudbroker/sep/addProviderNodes": sep_cb.AddProviderNodesRequest{},
|
||||
"/restmachine/cloudbroker/sep/configFieldEdit": sep_cb.ConfigFieldEditRequest{},
|
||||
"/restmachine/cloudbroker/sep/configInsert": sep_cb.ConfigInsertRequest{},
|
||||
"/restmachine/cloudbroker/sep/configValidate": sep_cb.ConfigValidateRequest{},
|
||||
"/restmachine/cloudbroker/sep/consumption": sep_cb.ConsumptionRequest{},
|
||||
"/restmachine/cloudbroker/sep/create": sep_cb.CreateRequest{},
|
||||
"/restmachine/cloudbroker/sep/decommission": sep_cb.DecommissionRequest{},
|
||||
"/restmachine/cloudbroker/sep/delConsumerNodes": sep_cb.DelConsumerNodesRequest{},
|
||||
"/restmachine/cloudbroker/sep/delete": sep_cb.DeleteRequest{},
|
||||
"/restmachine/cloudbroker/sep/delPool": sep_cb.DelPoolRequest{},
|
||||
"/restmachine/cloudbroker/sep/disable": sep_cb.DisableRequest{},
|
||||
"/restmachine/cloudbroker/sep/diskList": sep_cb.DiskListRequest{},
|
||||
"/restmachine/cloudbroker/sep/enable": sep_cb.EnableRequest{},
|
||||
"/restmachine/cloudbroker/sep/get": sep_cb.GetRequest{},
|
||||
"/restmachine/cloudbroker/sep/getConfig": sep_cb.GetConfigRequest{},
|
||||
"/restmachine/cloudbroker/sep/getPool": sep_cb.GetPoolRequest{},
|
||||
"/restmachine/cloudbroker/sep/list": sep_cb.ListRequest{},
|
||||
"/restmachine/cloudbroker/sep/sharedLockStop": sep_cb.SharedLockStopRequest{},
|
||||
"/restmachine/cloudbroker/sep/listAvailableSepAndPools": sep_cb.ListAvailableSEPAndPoolsRequest{},
|
||||
"/restmachine/cloudbroker/sep/sharedLockStart": sep_cb.SharedLockStartRequest{},
|
||||
|
||||
// stack
|
||||
"/restmachine/cloudbroker/stack/get": stack_cb.GetRequest{},
|
||||
|
||||
@@ -1,119 +0,0 @@
|
||||
package test
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"encoding/json"
|
||||
"io"
|
||||
"os"
|
||||
"regexp"
|
||||
"sort"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func compareLogs(logFileName string, logsData []string, t *testing.T, testType string) {
|
||||
if _, err := os.Stat(logFileName); os.IsNotExist(err) {
|
||||
file, err := os.Create(logFileName)
|
||||
if err != nil {
|
||||
t.Errorf("Failed to create log file: %v", err)
|
||||
}
|
||||
defer file.Close()
|
||||
|
||||
writer := bufio.NewWriter(file)
|
||||
|
||||
jsonData, err := json.MarshalIndent(logsData, "", " ")
|
||||
if err != nil {
|
||||
t.Errorf("Failed to marshal logsData to JSON: %v", err)
|
||||
}
|
||||
|
||||
_, err = writer.WriteString(string(jsonData))
|
||||
if err != nil {
|
||||
t.Errorf("Failed to write JSON to log file: %v", err)
|
||||
}
|
||||
|
||||
writer.Flush()
|
||||
} else {
|
||||
file, err := os.Open(logFileName)
|
||||
if err != nil {
|
||||
t.Errorf("Failed to open log file: %v", err)
|
||||
}
|
||||
defer file.Close()
|
||||
|
||||
reader := bufio.NewReader(file)
|
||||
var sb strings.Builder
|
||||
for {
|
||||
line, err := reader.ReadString('\n')
|
||||
if err != nil {
|
||||
if err == io.EOF {
|
||||
sb.WriteString(strings.TrimSpace(line))
|
||||
break
|
||||
}
|
||||
t.Errorf("Error reading log file: %v", err)
|
||||
return
|
||||
}
|
||||
sb.WriteString(strings.TrimSpace(line))
|
||||
}
|
||||
|
||||
var fileContent = sb.String()
|
||||
|
||||
var fileLogsData []string
|
||||
err = json.Unmarshal([]byte(fileContent), &fileLogsData)
|
||||
if err != nil {
|
||||
t.Errorf("Failed to unmarshal JSON from log file: %v", err)
|
||||
}
|
||||
|
||||
if len(fileLogsData) != len(logsData) {
|
||||
t.Errorf("Log data length does not match. Got: %d, Expected: %d", len(fileLogsData), len(logsData))
|
||||
}
|
||||
|
||||
var allLinesMatch = true
|
||||
|
||||
switch testType {
|
||||
default:
|
||||
for i := range logsData {
|
||||
if sortBracketsContent(fileLogsData[i]) != sortBracketsContent(logsData[i]) {
|
||||
allLinesMatch = false
|
||||
t.Errorf("Line %d does not match. Got: %s, Expected: %s", i+1, sortBracketsContent(fileLogsData[i]), sortBracketsContent(logsData[i]))
|
||||
}
|
||||
}
|
||||
if allLinesMatch {
|
||||
t.Log("\nAll lines match the log file.")
|
||||
}
|
||||
case "request":
|
||||
var tmp = make(map[string]struct{})
|
||||
for _, v := range fileLogsData {
|
||||
if _, ok := tmp[v]; ok {
|
||||
delete(tmp, v)
|
||||
} else {
|
||||
tmp[v] = struct{}{}
|
||||
}
|
||||
|
||||
}
|
||||
for _, v := range logsData {
|
||||
if _, ok := tmp[v]; ok {
|
||||
delete(tmp, v)
|
||||
} else {
|
||||
tmp[v] = struct{}{}
|
||||
}
|
||||
|
||||
}
|
||||
if len(tmp) == 0 {
|
||||
t.Log("\nAll lines match the log file.")
|
||||
return
|
||||
}
|
||||
for i := range tmp {
|
||||
t.Errorf("Line %s does not match.", i)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func sortBracketsContent(log string) string {
|
||||
re := regexp.MustCompile(`\[([^\[\]]*)\]`)
|
||||
return re.ReplaceAllStringFunc(log, func(match string) string {
|
||||
content := match[1 : len(match)-1]
|
||||
parts := strings.Split(content, " ")
|
||||
sort.Strings(parts)
|
||||
return "[" + strings.Join(parts, " ") + "]"
|
||||
})
|
||||
}
|
||||
@@ -51,15 +51,12 @@ func getBytesFromJSON(fileName string, t *testing.T) []byte {
|
||||
|
||||
func getErrorsFromJSON(bytes []byte, t *testing.T, cloud string) {
|
||||
var requests map[string]interface{}
|
||||
var logFileName string
|
||||
|
||||
switch cloud {
|
||||
case "cloudapi":
|
||||
requests = getRequestsMapCloudAPI()
|
||||
logFileName = "test_requests_cloudAPI.log"
|
||||
case "cloudbroker":
|
||||
requests = getRequestsMapCloudbroker()
|
||||
logFileName = "test_requests_cloudbroker.log"
|
||||
default:
|
||||
t.Fatalf("Wrong cloud provided, expected `cloudapi` or `cloudbroker`, got %s", cloud)
|
||||
}
|
||||
@@ -151,7 +148,6 @@ func getErrorsFromJSON(bytes []byte, t *testing.T, cloud string) {
|
||||
t.Error(msg)
|
||||
dataLogs = append(dataLogs, msg)
|
||||
}
|
||||
compareLogs(logFileName, dataLogs, t, "request")
|
||||
}
|
||||
|
||||
// checkName checks if name field from platform has the same value as json tag in golang structure (maybe including omitempty)
|
||||
|
||||
@@ -11,7 +11,6 @@ import (
|
||||
var DEPRECATED_GROUPS = []string{
|
||||
"/cloudapi/machine/",
|
||||
"/cloudapi/cloudspace/",
|
||||
"/cloudapi/prometheus/",
|
||||
"//cloudbroker/pgpu/",
|
||||
"/cloudapi/gpu/",
|
||||
"/cloudapi/portforwarding/",
|
||||
@@ -28,7 +27,6 @@ var DEPRECATED_GROUPS = []string{
|
||||
"/cloudbroker/account/listCS",
|
||||
"/cloudbroker/machine/",
|
||||
"/cloudbroker/bservice/",
|
||||
"/cloudbroker/prometheus/",
|
||||
"/cloudbroker/auditcollector/",
|
||||
"/cloudbroker/health/",
|
||||
"/cloudbroker/metering/",
|
||||
|
||||
Reference in New Issue
Block a user