Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4c05d94552 | ||
|
|
dbd979b6f3 |
No files matched your search
+20
-89
@@ -1,9 +1,9 @@
|
||||
## Version 16.1.0
|
||||
## Version 16.3.0
|
||||
|
||||
|
||||
### Deprecated
|
||||
|
||||
Перечисленные методы будут удалены в `v17`
|
||||
Перечисленные методы будут удалены в `v1.17`
|
||||
|
||||
| Метод | CloudAPI | CloudBroker |
|
||||
| --- | --- | --- |
|
||||
@@ -21,97 +21,28 @@
|
||||
|
||||
### Добавлено
|
||||
|
||||
#### account
|
||||
| Идентификатор задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-1007 | Структура запроса `AddACLAccessRequest` и метод `AddACLAccess` в cloudapi/account и в cloudbroker/account |
|
||||
| BGOS-1007 | Структура запроса `DelACLAccessRequest` и метод `DelACLAccess` в cloudapi/account и в cloudbroker/account |
|
||||
| BGOS-1007 | Структура запроса `UpdateACLAccessRequest` и метод `UpdateACLAccess` в cloudapi/account и в cloudbroker/account |
|
||||
|
||||
#### backup
|
||||
| Идентификатор задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-1012 | Методы `AbortDisksBackup`, `BackupDisksWithSpeed`, `Info` и `SetBackupSpeed` в cloudbroker/backup |
|
||||
| BGOS-1012 | Структуры ответов `ListDisksWithSpeed` и `TotalBackupsInfo` в cloudbroker/backup |
|
||||
| BGOS-1018 | Опциональное поле `Speed` в структуры запроса `CreateDiskBackupRequest` и `Disk` в cloudbroker/backup |
|
||||
|
||||
|
||||
#### compute
|
||||
| Идентификатор задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-1009 | Структура запроса `AddACLAccessRequest` и метод `AddACLAccess` в cloudapi/compute и в cloudbroker/compute |
|
||||
| BGOS-1009 | Структура запроса `DeleteACLAccessRequest` и метод `DeleteACLAccess` в cloudapi/compute и в cloudbroker/compute |
|
||||
| BGOS-1009 | Структура запроса `UpdateACLAccessRequest` и метод `UpdateACLAccess` в cloudapi/compute и в cloudbroker/compute |
|
||||
| BGOS-1009 | Структура запроса `GetACLAccessRequest` и метод `GetACLAccess` в cloudapi/compute и в cloudbroker/compute |
|
||||
| BGOS-1014 | Вычисляемое поле `MemoryBalloonMode` в структуры ответа `ItemCompute` и `RecordCompute` в cloudapi/compute |
|
||||
| BGOS-1014 | Вычисляемое поле `MemoryBalloonMode` в структуры ответа `InfoCompute` и `RecordCompute` в cloudbroker/compute |
|
||||
| BGOS-1014 | Опциональное поле `MemoryBalloonMode` в структуру запроса `UpdateRequest` в cloudbroker/compute и cloudapi/compute |
|
||||
| BGOS-1016 | Вычисляемое поле `ProfileName` в структуру ответа `ItemVGPU` в cloudbroker/compute и cloudapi/compute |
|
||||
| BGOS-1019 | Вычисляемое поле `QoSPolicies` в структуру ответа `ItemShadowComputeInterface` в cloudbroker/compute |
|
||||
|
||||
#### disks
|
||||
| Идентификатор задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-1015 | Методы `DeleteAsync`, `DeleteDisksAsync`, `LimitIOAsync`, `RenameAsync`, `ReplicateAsync`, `ReplicationResumeAsync`, `ReplicationReverseAsync`, `ReplicationStartAsync`, `ReplicationStopAsync`, `ReplicationSuspendAsync`, `Resize2Async`, `RestoreAsync`, `ShareAsync`, `UnshareAsync`, `SnapshotDeleteAsync`, `SnapshotRollbackAsync`, `ChangeDiskStoragePolicyAsync` в cloudapi/disks |
|
||||
| BGOS-1015 | Методы `DeleteAsync`, `DeleteDisksAsync`, `DepresentAsync`, `LimitIOAsync`, `MigrateAbortAsync`, `PresentAsync`, `RenameAsync`, `ReplicateAsync`, `ReplicationResumeAsync`, `ReplicationReverseAsync`, `ReplicationStartAsync`, `ReplicationStopAsync`, `ReplicationSuspendAsync`, `Resize2Async`, `RestoreAsync`, `ShareAsync`, `UnshareAsync`, `SnapshotDeleteAsync`, `SnapshotRollbackAsync`, `ChangeDiskStoragePolicyAsync`, `UpdateAsync` в cloudbroker/disks |
|
||||
|
||||
#### extnet
|
||||
| Идентификатор задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-1013 | Опциональное поле `AutoAssignable` в структуру запроса `AddReserveIPRequest` в cloudbroker/extnet |
|
||||
| BGOS-1013 | Опциональное поле `AutoAssignable` в структуру запроса `GetReservedIP` в cloudbroker/extnet и cloudapi/extnet |
|
||||
| BGOS-1013 | Вычисляемое поле `AutoAssignable` в структуру ответа `Reservations` в cloudbroker/extnet и cloudapi/extnet |
|
||||
| BGOS-1034 | Методы `AsyncCreate`, `AsyncDeviceDeploy` и `AsyncSetHAMode` в cloudbroker/extnet |
|
||||
|
||||
|
||||
#### locations
|
||||
| Идентификатор задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-1032 | Вычисляемое поле `VMFoldersEnabled` в структуру ответа `ItemLocation` в cloudapi/locations |
|
||||
|
||||
#### vins
|
||||
| Идентификатор задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-1033 | Методы `AsyncCreateInAccount`, `AsyncCreateInRG`, `AsyncEnable`, `AsyncVNFDevRedeploy` и `AsyncVNFDevRestart` в cloudapi/vins |
|
||||
| BGOS-1033 | Методы `AsyncCreateInAccount`, `AsyncCreateInRG`, `AsyncEnable`, `AsyncVNFDevRedeploy`, `AsyncVNFDevRestart` и `AsyncVNFDevStart` в cloudbroker/vins |
|
||||
| BGOS-1033 | Структура запроса `DisableRequest` и метод `Disable` в cloudapi/vins |
|
||||
| BGOS-1033 | Структура запроса `EnableRequest` и метод `Enable` в cloudapi/vins |
|
||||
|
||||
### Исправлено
|
||||
|
||||
#### kvmx86
|
||||
| Идентификатор задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-1014 | Опциональное поле `MemoryBalloonMode` в структуры запроса `CreateRequest` и `CreateBlankRequest` в cloudapi/kvmx86 |
|
||||
| BGOS-1014 | Опциональное поле `MemoryBalloonMode` в структуры запроса `CreateRequest`, `CreateBlankRequest` и `MassCreateRequest` в cloudbroker/kvmx86 |
|
||||
|
||||
#### node
|
||||
| Идентификатор задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-1020 | Опциональное поле `Mode` в структуру запроса `PCIDeviceDriverToKernelRequest` в cloudbroker/node |
|
||||
|
||||
#### pcidevice
|
||||
| Идентификатор задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-990 | Опциональное поле `AccountID` в структуру запроса `ListRequest` в cloudapi/pcidevice и в структуры запроса `CreateRequest` и `ListRequest` в cloudbroker/pcidevice |
|
||||
| BGOS-990 | Вычисляемое поле `AccountID` в структуру ответа `ItemPCIDevice` в cloudapi/pcidevice и в структуру ответа `ItemPCIDevice` в cloudbroker/pcidevice |
|
||||
| BGOS-990 | Метод `AccessGrant` и структура запроса `AccessGrantRequest` в cloudbroker/pcidevice |
|
||||
| BGOS-990 | Метод `AccessRevoke` и структура запроса `AccessRevokeRequest` в cloudbroker/pcidevice |
|
||||
|
||||
#### rg
|
||||
| Идентификатор задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-1008 | Структура запроса `AddACLAccessRequest` и метод `AddACLAccess` в cloudapi/rg и в cloudbroker/rg |
|
||||
| BGOS-1008 | Структура запроса `DeleteACLAccessRequest` и метод `DeleteACLAccess` в cloudapi/rg и в cloudbroker/rg |
|
||||
| BGOS-1008 | Структура запроса `UpdateACLAccessRequest` и метод `UpdateACLAccess` в cloudapi/rg и в cloudbroker/rg |
|
||||
| BGOS-1008 | Структура запроса `GetACLAccessRequest` и метод `GetACLAccess` в cloudapi/rg и в cloudbroker/rg |
|
||||
|
||||
|
||||
#### vgpu
|
||||
| Идентификатор задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-1011 | Вычисляемое поле `ProfileName` в структуру ответа `ItemVGPU` в cloudbroker/vgpu и cloudapi/vgpu |
|
||||
|
||||
|
||||
### Удалено
|
||||
|
||||
#### account
|
||||
| Идентификатор задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-1021 | Вычисляемое поле `CanBeDeleted` из структуры ответа `ListRecordACL` в cloudapi/account |
|
||||
|
||||
#### network qos policy
|
||||
| Идентификатор задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-1017 | Вычисляемые поля `CreatedAt`, `UpdatedAt`, `CreatedBy` и `UpdatedBy` из структур ответа `ItemQoSPolicy` и `RecordQoSPolicy` в cloudapi/qospolicy и cloudbroker/qospolicy |
|
||||
| BGOS-1017 | Методы `FilterByCreatedBy` и `FilterByUpdatedBy` из cloudapi/qospolicy и cloudbroker/qospolicy |
|
||||
| BGOS-1017 | Методы `SortByCreatedAt` и `SortByUpdatedAt` из cloudapi/qospolicy и cloudbroker/qospolicy |
|
||||
|
||||
#### pcidevice
|
||||
| Идентификатор задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-990 | Опциональное поле `RGID` из структуры запроса `ListRequest` в cloudapi/pcidevice и из структур запроса `CreateRequest` и `ListRequest` в cloudbroker/pcidevice |
|
||||
| BGOS-990 | Вычисляемое поле `RGID` из структуры ответа `ItemPCIDevice` в cloudapi/pcidevice и из структуры ответа `ItemPCIDevice` в cloudbroker/pcidevice |
|
||||
| BGOS-1040 | JSON-тэг опционального поля `AsyncMode` с `asyncMode` на `async_mode` в структуре запроса `CreateRequest` в cloudapi/kvmx86 и cloudbroker/kvmx86 |
|
||||
@@ -159,6 +159,7 @@ go get -u repository.basistech.ru/BASIS/dynamix-golang-sdk/v16
|
||||
- `RG` - управление ресурсными группами аккаунта;
|
||||
- `Security group` – управление группами безопасности;
|
||||
- `SEP` - управление storage endpoint (sep);
|
||||
- `Session` - получение информации о сессиях;
|
||||
- `Storage policy` – управление политиками хранения;
|
||||
- `Tasks` - получение информации о ходе выполнения асинхронных задач (например, создание кластера);
|
||||
- `Trunk` - управление транковыми портами;
|
||||
@@ -369,6 +370,7 @@ func main() {
|
||||
- `pkg/cloudbroker/rg` - для `RG`
|
||||
- `pkg/cloudbroker/secgroup` - для `Security group`
|
||||
- `pkg/cloudbroker/sep` - для `SEP`
|
||||
- `pkg/cloudbroker/session` - для `Session`
|
||||
- `pkg/cloudbroker/stpolicy` - для `Storage policy`
|
||||
- `pkg/cloudbroker/tasks` - для `Tasks`
|
||||
- `pkg/cloudbroker/trunk` - для `Trunk`
|
||||
@@ -377,7 +379,7 @@ func main() {
|
||||
- `pkg/cloudbroker/vfpool` - для `VFPool`
|
||||
- `pkg/cloudbroker/vins` - для `VINS`
|
||||
- `pkg/cloudbroker/zone` - для `Zone`
|
||||
- **sdn**:
|
||||
- **sdn**:
|
||||
- `pkg/sdn/acsgroups` - для `Access groups`
|
||||
- `pkg/sdn/adrspools` - для `Address pool`
|
||||
- `pkg/sdn/defsecpolicies` - для `DefaultSecurityPolicies`
|
||||
@@ -572,6 +574,7 @@ func main() {
|
||||
- `.RG()` - для работы с `RG`
|
||||
- `.SecurityGroup()` - для работы с `Security Group`
|
||||
- `.SEP()` - для работы с `SEP`
|
||||
- `.Session()` - для работы с `Session`
|
||||
- `.StPolicy()` - для работы с `Storage Policy`
|
||||
- `.Tasks()` - для работы с `Tasks`
|
||||
- `.Trunk()` - для работы с `Trunk`
|
||||
@@ -581,7 +584,7 @@ func main() {
|
||||
- `.VINS()` - для работы с `VINS`
|
||||
- `.Zone()` - для работы с `Zone`
|
||||
|
||||
Доступные методы для `.SDN()`:
|
||||
Доступные методы для `.SDN()`:
|
||||
|
||||
- `.AccessGroup()` - для работы с `Access group`
|
||||
- `.AddressPool()` - для работы с `Addres pool`
|
||||
@@ -954,7 +957,7 @@ func main() {
|
||||
- ToString(): строковое представление результата выполнения задачи
|
||||
- ID() и Name(): получение ID и имени созданного в результате выполнения задачи ресурса
|
||||
- ToMaps(): получение списка карт, содержащих информацию о дисках, восстановленных в результате выполнения задачи.
|
||||
Все методы оборудованы возвратом ошибок. Непустая ошибка означает, что из поля Result нельзя получить информацию, которую предоставляет метод.
|
||||
Все методы оборудованы возвратом ошибок. Непустая ошибка означает, что из поля Result нельзя получить информацию, которую предоставляет метод.
|
||||
|
||||
```go
|
||||
package main
|
||||
@@ -1632,46 +1635,46 @@ package main
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v16/config"
|
||||
decort "repository.basistech.ru/BASIS/dynamix-golang-sdk/v16"
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v16/config"
|
||||
decort "repository.basistech.ru/BASIS/dynamix-golang-sdk/v16"
|
||||
)
|
||||
|
||||
func main() {
|
||||
// Настройка конфигурации
|
||||
legacyCfg := config.LegacyConfig{
|
||||
Username: "<USERNAME>",
|
||||
Password: "<PASSWORD>",
|
||||
Domain: "dynamix",
|
||||
DecortURL: "https://mr4.digitalenergy.online",
|
||||
Retries: 5,
|
||||
// Настройка конфигурации
|
||||
legacyCfg := config.LegacyConfig{
|
||||
Username: "<USERNAME>",
|
||||
Password: "<PASSWORD>",
|
||||
Domain: "dynamix",
|
||||
DecortURL: "https://mr4.digitalenergy.online",
|
||||
Retries: 5,
|
||||
}
|
||||
|
||||
legacyCfg.SetTimeout(5 * time.Minute)
|
||||
|
||||
cfg := config.UniversalConfig{
|
||||
LegacyConfig: &legacyCfg,
|
||||
}
|
||||
|
||||
legacyCfg.SetTimeout(5 * time.Minute)
|
||||
// Создание клиента
|
||||
universalClient := decort.NewUniversal(cfg)
|
||||
|
||||
cfg := config.UniversalConfig{
|
||||
LegacyConfig: &legacyCfg,
|
||||
}
|
||||
// Создание структуры запроса
|
||||
// CreateRequest - реквест на создание виртуальной машины
|
||||
req := kvmx86.CreateRequest{
|
||||
RGID: 123,
|
||||
Name: "compute",
|
||||
CPU: 4,
|
||||
RAM: 4096,
|
||||
ImageID: 321,
|
||||
}
|
||||
|
||||
// Создание клиента
|
||||
universalClient := decort.NewUniversal(cfg)
|
||||
// Выполнение запроса
|
||||
res, err := universalClient.CloudAPI().KVMX86().Create(context.Background(), req)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
// Создание структуры запроса
|
||||
// CreateRequest - реквест на создание виртуальной машины
|
||||
req := kvmx86.CreateRequest{
|
||||
RGID: 123,
|
||||
Name: "compute",
|
||||
CPU: 4,
|
||||
RAM: 4096,
|
||||
ImageID: 321,
|
||||
}
|
||||
|
||||
// Выполнение запроса
|
||||
res, err := universalClient.CloudAPI().KVMX86().Create(context.Background(), req)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
fmt.Println(res)
|
||||
fmt.Println(res)
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
@@ -90,6 +90,9 @@ type ListRequest struct {
|
||||
// Exclude audit lines from response
|
||||
// Required: false
|
||||
ExcludeAuditLines bool `url:"exclude_audit_lines,omitempty" json:"exclude_audit_lines,omitempty"`
|
||||
|
||||
// Public Session ID
|
||||
PublicSessionID string `json:"public_session_id"`
|
||||
}
|
||||
|
||||
// List gets audit records for the specified account object
|
||||
|
||||
@@ -2,7 +2,6 @@ package audit
|
||||
|
||||
// Main info about audit
|
||||
type RecordAudit struct {
|
||||
|
||||
// Arguments
|
||||
Arguments string `json:"args"`
|
||||
|
||||
@@ -41,6 +40,9 @@ type RecordAudit struct {
|
||||
|
||||
// User
|
||||
User string `json:"user"`
|
||||
|
||||
// Public Session ID
|
||||
PublicSessionID string `json:"public_session_id"`
|
||||
}
|
||||
|
||||
// Main info about audit
|
||||
@@ -81,6 +83,9 @@ type ItemAudit struct {
|
||||
// User
|
||||
User string `json:"user"`
|
||||
|
||||
// Public Session ID
|
||||
PublicSessionID string `json:"public_session_id"`
|
||||
|
||||
// TTL
|
||||
TTL string `json:"_ttl"`
|
||||
}
|
||||
|
||||
@@ -18,10 +18,6 @@ type ListVGPURequest struct {
|
||||
// Required: false
|
||||
GPUID uint64 `url:"gpuId,omitempty" json:"gpuId,omitempty"`
|
||||
|
||||
// Find by type
|
||||
// Required: false
|
||||
Type string `url:"type,omitempty" json:"type,omitempty"`
|
||||
|
||||
// Find by status
|
||||
// Required: false
|
||||
Status string `url:"status,omitempty" json:"status,omitempty"`
|
||||
|
||||
@@ -265,7 +265,7 @@ func (r CreateRequest) GetRAM() map[string]uint64 {
|
||||
|
||||
type wrapperCreateRequest struct {
|
||||
CreateRequest
|
||||
AsyncMode bool `json:"asyncMode"`
|
||||
AsyncMode bool `json:"async_mode"`
|
||||
}
|
||||
|
||||
// Create creates KVM x86 VM based on specified OS image
|
||||
|
||||
@@ -43,6 +43,9 @@ type ItemLocation struct {
|
||||
|
||||
// Is BRO enabled
|
||||
BROEnabled bool `json:"bro_enabled"`
|
||||
|
||||
// Are VM Folders enabled
|
||||
VMFoldersEnabled bool `json:"vm_folders_enabled"`
|
||||
}
|
||||
|
||||
// List of locations
|
||||
|
||||
@@ -73,10 +73,10 @@ type Rule struct {
|
||||
Protocol string `json:"protocol"`
|
||||
|
||||
// Priority Code Point (0-7). L2 marking
|
||||
PCPTag uint64 `json:"pcp_tag"`
|
||||
PCPTag *uint64 `json:"pcp_tag"`
|
||||
|
||||
// DSCP value (0-63). L3 marking
|
||||
DSCPValue uint64 `json:"dscp_value"`
|
||||
DSCPValue *uint64 `json:"dscp_value"`
|
||||
|
||||
// Source IP address
|
||||
SrcIP string `json:"src_ip"`
|
||||
|
||||
@@ -16,11 +16,11 @@ type UpdateRequest struct {
|
||||
|
||||
// New QoS policy name
|
||||
// Required: false
|
||||
Name string `url:"name,omitempty" json:"name,omitempty"`
|
||||
Name *string `url:"name,omitempty" json:"name,omitempty"`
|
||||
|
||||
// New QoS policy description
|
||||
// Required: false
|
||||
Description string `url:"description,omitempty" json:"description,omitempty"`
|
||||
Description *string `url:"description,omitempty" json:"description,omitempty"`
|
||||
}
|
||||
|
||||
func (qp QoSPolicy) Update(ctx context.Context, req UpdateRequest) (*RecordQoSPolicy, error) {
|
||||
|
||||
@@ -2,6 +2,7 @@ package vins
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
@@ -69,6 +70,11 @@ type CreateInAccountRequest struct {
|
||||
EnableDefaultGateway interface{} `url:"enable_default_gateway,omitempty" json:"enable_default_gateway,omitempty" validate:"omitempty,isBool"`
|
||||
}
|
||||
|
||||
type asyncWrapperCreateInAccountRequest struct {
|
||||
CreateInAccountRequest
|
||||
AsyncMode bool `url:"asyncMode" json:"asyncMode"`
|
||||
}
|
||||
|
||||
// CreateInAccount creates VINS in account level
|
||||
func (v VINS) CreateInAccount(ctx context.Context, req CreateInAccountRequest) (uint64, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
@@ -78,7 +84,12 @@ func (v VINS) CreateInAccount(ctx context.Context, req CreateInAccountRequest) (
|
||||
|
||||
url := "/cloudapi/vins/createInAccount"
|
||||
|
||||
res, err := v.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
|
||||
syncReq := asyncWrapperCreateInAccountRequest{
|
||||
CreateInAccountRequest: req,
|
||||
AsyncMode: false,
|
||||
}
|
||||
|
||||
res, err := v.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, syncReq)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
@@ -90,3 +101,32 @@ func (v VINS) CreateInAccount(ctx context.Context, req CreateInAccountRequest) (
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// CreateInAccount creates VINS in account level in async mode
|
||||
func (v VINS) AsyncCreateInAccount(ctx context.Context, req CreateInAccountRequest) (string, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
asyncReq := asyncWrapperCreateInAccountRequest{
|
||||
CreateInAccountRequest: req,
|
||||
AsyncMode: true,
|
||||
}
|
||||
|
||||
url := "/cloudapi/vins/createInAccount"
|
||||
|
||||
result, err := v.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, asyncReq)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
var resp string
|
||||
|
||||
err = json.Unmarshal(result, &resp)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return resp, nil
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package vins
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
@@ -63,6 +64,11 @@ type CreateInRGRequest struct {
|
||||
EnableDefaultGateway interface{} `url:"enable_default_gateway,omitempty" json:"enable_default_gateway,omitempty" validate:"omitempty,isBool"`
|
||||
}
|
||||
|
||||
type asyncWrapperCreateInRgRequest struct {
|
||||
CreateInRGRequest
|
||||
AsyncMode bool `url:"asyncMode" json:"asyncMode"`
|
||||
}
|
||||
|
||||
// CreateInRG creates VINS in resource group level
|
||||
func (v VINS) CreateInRG(ctx context.Context, req CreateInRGRequest) (uint64, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
@@ -72,7 +78,12 @@ func (v VINS) CreateInRG(ctx context.Context, req CreateInRGRequest) (uint64, er
|
||||
|
||||
url := "/cloudapi/vins/createInRG"
|
||||
|
||||
res, err := v.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
|
||||
syncReq := asyncWrapperCreateInRgRequest{
|
||||
CreateInRGRequest: req,
|
||||
AsyncMode: false,
|
||||
}
|
||||
|
||||
res, err := v.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, syncReq)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
@@ -84,3 +95,32 @@ func (v VINS) CreateInRG(ctx context.Context, req CreateInRGRequest) (uint64, er
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// CreateInRG creates VINS in resource group level in async mode
|
||||
func (v VINS) AsyncCreateInRG(ctx context.Context, req CreateInRGRequest) (string, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudapi/vins/createInRG"
|
||||
|
||||
syncReq := asyncWrapperCreateInRgRequest{
|
||||
CreateInRGRequest: req,
|
||||
AsyncMode: true,
|
||||
}
|
||||
|
||||
result, err := v.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, syncReq)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
var resp string
|
||||
|
||||
err = json.Unmarshal(result, &resp)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return resp, nil
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package vins
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v16/internal/validators"
|
||||
)
|
||||
|
||||
// DisableRequest struct to disable VINS
|
||||
type DisableRequest struct {
|
||||
// VINS ID
|
||||
// Required: true
|
||||
VINSID uint64 `url:"vinsId" json:"vinsId" validate:"required"`
|
||||
}
|
||||
|
||||
// Disable disables VINS
|
||||
func (v VINS) Disable(ctx context.Context, req DisableRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudapi/vins/disable"
|
||||
|
||||
res, err := v.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseBool(string(res))
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
|
||||
}
|
||||
@@ -1,62 +0,0 @@
|
||||
package vins
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v16/internal/validators"
|
||||
)
|
||||
|
||||
// DisableEnableRequest struct to disable/enable VINS
|
||||
type DisableEnableRequest struct {
|
||||
// VINS ID
|
||||
// Required: true
|
||||
VINSID uint64 `url:"vinsId" json:"vinsId" validate:"required"`
|
||||
}
|
||||
|
||||
// Disable disables VINS
|
||||
func (v VINS) Disable(ctx context.Context, req DisableEnableRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudapi/vins/disable"
|
||||
|
||||
res, err := v.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseBool(string(res))
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
|
||||
}
|
||||
|
||||
// Enable enables VINS
|
||||
func (v VINS) Enable(ctx context.Context, req DisableEnableRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudapi/vins/enable"
|
||||
|
||||
res, err := v.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseBool(string(res))
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
package vins
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v16/internal/validators"
|
||||
)
|
||||
|
||||
// EnableRequest struct to enable VINS
|
||||
type EnableRequest struct {
|
||||
// VINS ID
|
||||
// Required: true
|
||||
VINSID uint64 `url:"vinsId" json:"vinsId" validate:"required"`
|
||||
}
|
||||
|
||||
type asyncWrapperEnableRequest struct {
|
||||
EnableRequest
|
||||
AsyncMode bool `url:"asyncMode"`
|
||||
}
|
||||
|
||||
// Enable enables VINS
|
||||
func (v VINS) Enable(ctx context.Context, req EnableRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudapi/vins/enable"
|
||||
|
||||
syncReq := asyncWrapperEnableRequest{
|
||||
EnableRequest: req,
|
||||
AsyncMode: false,
|
||||
}
|
||||
|
||||
res, err := v.client.DecortApiCall(ctx, http.MethodPost, url, syncReq)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseBool(string(res))
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// Enable enables VINS by ID in async mode
|
||||
func (v VINS) AsyncEnable(ctx context.Context, req EnableRequest) (string, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudapi/vins/enable"
|
||||
|
||||
asyncReq := asyncWrapperEnableRequest{
|
||||
EnableRequest: req,
|
||||
AsyncMode: true,
|
||||
}
|
||||
|
||||
result, err := v.client.DecortApiCall(ctx, http.MethodPost, url, asyncReq)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
var resp string
|
||||
|
||||
err = json.Unmarshal(result, &resp)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return resp, nil
|
||||
}
|
||||
@@ -329,6 +329,9 @@ type ItemVNFInterface struct {
|
||||
// QOS
|
||||
QOS QOS `json:"qos"`
|
||||
|
||||
// List of QoS policies
|
||||
QoSPolicies []uint64 `json:"qos_policies"`
|
||||
|
||||
// Target
|
||||
Target string `json:"target"`
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ package vins
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
@@ -15,6 +16,11 @@ type VNFDevRedeployRequest struct {
|
||||
VINSID uint64 `url:"vinsId" json:"vinsId" validate:"required"`
|
||||
}
|
||||
|
||||
type asyncWrapperVNFDevRedeployRequest struct {
|
||||
VNFDevRedeployRequest
|
||||
AsyncMode bool `url:"asyncMode"`
|
||||
}
|
||||
|
||||
// VNFDevRedeploy redeploys VINS VNFDevs
|
||||
func (v VINS) VNFDevRedeploy(ctx context.Context, req VNFDevRedeployRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
@@ -24,7 +30,12 @@ func (v VINS) VNFDevRedeploy(ctx context.Context, req VNFDevRedeployRequest) (bo
|
||||
|
||||
url := "/cloudapi/vins/vnfdevRedeploy"
|
||||
|
||||
res, err := v.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
syncReq := asyncWrapperVNFDevRedeployRequest{
|
||||
VNFDevRedeployRequest: req,
|
||||
AsyncMode: false,
|
||||
}
|
||||
|
||||
res, err := v.client.DecortApiCall(ctx, http.MethodPost, url, syncReq)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
@@ -36,3 +47,32 @@ func (v VINS) VNFDevRedeploy(ctx context.Context, req VNFDevRedeployRequest) (bo
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// VNFDevRedeploy redeploys VINS VNFDevs in async mode
|
||||
func (v VINS) AsyncVNFDevRedeploy(ctx context.Context, req VNFDevRedeployRequest) (string, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudapi/vins/vnfdevRedeploy"
|
||||
|
||||
asyncReq := asyncWrapperVNFDevRedeployRequest{
|
||||
VNFDevRedeployRequest: req,
|
||||
AsyncMode: true,
|
||||
}
|
||||
|
||||
result, err := v.client.DecortApiCall(ctx, http.MethodPost, url, asyncReq)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
var resp string
|
||||
|
||||
err = json.Unmarshal(result, &resp)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return resp, nil
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package vins
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
@@ -15,6 +16,11 @@ type VNFDevRestartRequest struct {
|
||||
VINSID uint64 `url:"vinsId" json:"vinsId" validate:"required"`
|
||||
}
|
||||
|
||||
type asyncWrapperVNFDevRestartRequest struct {
|
||||
VNFDevRestartRequest
|
||||
AsyncMode bool `url:"asyncMode"`
|
||||
}
|
||||
|
||||
// VNFDevRestart reboots VINSes primary VNF device
|
||||
func (v VINS) VNFDevRestart(ctx context.Context, req VNFDevRestartRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
@@ -24,7 +30,12 @@ func (v VINS) VNFDevRestart(ctx context.Context, req VNFDevRestartRequest) (bool
|
||||
|
||||
url := "/cloudapi/vins/vnfdevRestart"
|
||||
|
||||
res, err := v.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
syncReq := asyncWrapperVNFDevRestartRequest{
|
||||
VNFDevRestartRequest: req,
|
||||
AsyncMode: false,
|
||||
}
|
||||
|
||||
res, err := v.client.DecortApiCall(ctx, http.MethodPost, url, syncReq)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
@@ -36,3 +47,32 @@ func (v VINS) VNFDevRestart(ctx context.Context, req VNFDevRestartRequest) (bool
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// VNFDevRestart reboots VINSes primary VNF device in async mode
|
||||
func (v VINS) AsyncVNFDevRestart(ctx context.Context, req VNFDevRestartRequest) (string, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudapi/vins/vnfdevRestart"
|
||||
|
||||
asyncReq := asyncWrapperVNFDevRestartRequest{
|
||||
VNFDevRestartRequest: req,
|
||||
AsyncMode: true,
|
||||
}
|
||||
|
||||
result, err := v.client.DecortApiCall(ctx, http.MethodPost, url, asyncReq)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
var resp string
|
||||
|
||||
err = json.Unmarshal(result, &resp)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return resp, nil
|
||||
}
|
||||
@@ -94,6 +94,9 @@ type ListRequest struct {
|
||||
// Exclude audit lines from response
|
||||
// Required: false
|
||||
ExcludeAuditLines bool `url:"exclude_audit_lines,omitempty" json:"exclude_audit_lines,omitempty"`
|
||||
|
||||
// Public Session ID
|
||||
PublicSessionID string `json:"public_session_id"`
|
||||
}
|
||||
|
||||
// List gets audit records for the specified account object
|
||||
|
||||
@@ -38,6 +38,9 @@ type ItemAudit struct {
|
||||
// User
|
||||
User string `json:"user"`
|
||||
|
||||
// Public Session ID
|
||||
PublicSessionID string `json:"public_session_id"`
|
||||
|
||||
// TTL
|
||||
TTL string `json:"_ttl"`
|
||||
}
|
||||
@@ -93,6 +96,9 @@ type RecordAudit struct {
|
||||
// User
|
||||
User string `json:"user"`
|
||||
|
||||
// Public Session ID
|
||||
PublicSessionID string `json:"public_session_id"`
|
||||
|
||||
// TTL
|
||||
TTL string `json:"_ttl"`
|
||||
|
||||
|
||||
@@ -18,10 +18,6 @@ type ListVGPURequest struct {
|
||||
// Required: false
|
||||
GPUID uint64 `url:"gpuId,omitempty" json:"gpuId,omitempty"`
|
||||
|
||||
// Find by type
|
||||
// Required: false
|
||||
Type string `url:"type,omitempty" json:"type,omitempty"`
|
||||
|
||||
// Find by status
|
||||
// Required: false
|
||||
Status string `url:"status,omitempty" json:"status,omitempty"`
|
||||
|
||||
@@ -116,6 +116,11 @@ type wrapperCreateRequest struct {
|
||||
Routes []string `url:"routes,omitempty"`
|
||||
}
|
||||
|
||||
type asyncWrapperCreateRequest struct {
|
||||
wrapperCreateRequest
|
||||
AsyncMode bool `url:"async_mode"`
|
||||
}
|
||||
|
||||
// Create creates new external network into platform
|
||||
func (e ExtNet) Create(ctx context.Context, req CreateRequest) (uint64, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
@@ -145,9 +150,14 @@ func (e ExtNet) Create(ctx context.Context, req CreateRequest) (uint64, error) {
|
||||
Routes: routes,
|
||||
}
|
||||
|
||||
reqWrappedAsync := asyncWrapperCreateRequest{
|
||||
wrapperCreateRequest: reqWrapped,
|
||||
AsyncMode: true,
|
||||
}
|
||||
|
||||
url := "/cloudbroker/extnet/create"
|
||||
|
||||
res, err := e.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
||||
res, err := e.client.DecortApiCall(ctx, http.MethodPost, url, reqWrappedAsync)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
@@ -159,3 +169,54 @@ func (e ExtNet) Create(ctx context.Context, req CreateRequest) (uint64, error) {
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// AsyncCreate creates new external network into platform in async mode
|
||||
func (e ExtNet) AsyncCreate(ctx context.Context, req CreateRequest) (string, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
var routes []string
|
||||
|
||||
if len(req.Routes) != 0 {
|
||||
routes = make([]string, 0, len(req.Routes))
|
||||
|
||||
for r := range req.Routes {
|
||||
b, err := json.Marshal(req.Routes[r])
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
routes = append(routes, string(b))
|
||||
}
|
||||
} else {
|
||||
routes = []string{}
|
||||
}
|
||||
|
||||
reqWrapped := wrapperCreateRequest{
|
||||
CreateRequest: req,
|
||||
Routes: routes,
|
||||
}
|
||||
|
||||
reqWrappedAsync := asyncWrapperCreateRequest{
|
||||
wrapperCreateRequest: reqWrapped,
|
||||
AsyncMode: true,
|
||||
}
|
||||
|
||||
url := "/cloudbroker/extnet/create"
|
||||
|
||||
result, err := e.client.DecortApiCall(ctx, http.MethodPost, url, reqWrappedAsync)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
var resp string
|
||||
|
||||
err = json.Unmarshal(result, &resp)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return resp, nil
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package extnet
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
@@ -15,6 +16,11 @@ type DeviceDeployRequest struct {
|
||||
NetID uint64 `url:"net_id" json:"net_id" validate:"required"`
|
||||
}
|
||||
|
||||
type asyncWrapperDeviceDeployRequest struct {
|
||||
DeviceDeployRequest
|
||||
AsyncMode bool `url:"async_mode"`
|
||||
}
|
||||
|
||||
// DeviceDeploy deploys network device for external network (make not virtual, "physical")
|
||||
func (e ExtNet) DeviceDeploy(ctx context.Context, req DeviceDeployRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
@@ -24,7 +30,12 @@ func (e ExtNet) DeviceDeploy(ctx context.Context, req DeviceDeployRequest) (bool
|
||||
|
||||
url := "/cloudbroker/extnet/deviceDeploy"
|
||||
|
||||
res, err := e.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
syncReq := asyncWrapperDeviceDeployRequest{
|
||||
DeviceDeployRequest: req,
|
||||
AsyncMode: false,
|
||||
}
|
||||
|
||||
res, err := e.client.DecortApiCall(ctx, http.MethodPost, url, syncReq)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
@@ -36,3 +47,32 @@ func (e ExtNet) DeviceDeploy(ctx context.Context, req DeviceDeployRequest) (bool
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// AsyncDeviceDeploy deploys network device for external network (make not virtual, "physical") in async mode
|
||||
func (e ExtNet) AsyncDeviceDeploy(ctx context.Context, req DeviceDeployRequest) (string, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/extnet/deviceDeploy"
|
||||
|
||||
syncReq := asyncWrapperDeviceDeployRequest{
|
||||
DeviceDeployRequest: req,
|
||||
AsyncMode: true,
|
||||
}
|
||||
|
||||
result, err := e.client.DecortApiCall(ctx, http.MethodPost, url, syncReq)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
var resp string
|
||||
|
||||
err = json.Unmarshal(result, &resp)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return resp, nil
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package extnet
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
@@ -19,6 +20,11 @@ type SetHAModeRequest struct {
|
||||
HAMode bool `url:"highly_available" json:"highly_available" validate:"required"`
|
||||
}
|
||||
|
||||
type asyncWrapperSetHAModeRequest struct {
|
||||
SetHAModeRequest
|
||||
AsyncMode bool `url:"async_mode"`
|
||||
}
|
||||
|
||||
// SetHAMode set HA mode for external network
|
||||
func (e ExtNet) SetHAMode(ctx context.Context, req SetHAModeRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
@@ -28,7 +34,12 @@ func (e ExtNet) SetHAMode(ctx context.Context, req SetHAModeRequest) (bool, erro
|
||||
|
||||
url := "/cloudbroker/extnet/set_highly_available"
|
||||
|
||||
res, err := e.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
syncReq := asyncWrapperSetHAModeRequest{
|
||||
SetHAModeRequest: req,
|
||||
AsyncMode: true,
|
||||
}
|
||||
|
||||
res, err := e.client.DecortApiCall(ctx, http.MethodPost, url, syncReq)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
@@ -40,3 +51,32 @@ func (e ExtNet) SetHAMode(ctx context.Context, req SetHAModeRequest) (bool, erro
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// AsyncSetHAMode set HA mode for external network in async mode
|
||||
func (e ExtNet) AsyncSetHAMode(ctx context.Context, req SetHAModeRequest) (string, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/extnet/set_highly_available"
|
||||
|
||||
syncReq := asyncWrapperSetHAModeRequest{
|
||||
SetHAModeRequest: req,
|
||||
AsyncMode: true,
|
||||
}
|
||||
|
||||
result, err := e.client.DecortApiCall(ctx, http.MethodPost, url, syncReq)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
var resp string
|
||||
|
||||
err = json.Unmarshal(result, &resp)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return resp, nil
|
||||
}
|
||||
@@ -114,6 +114,9 @@ type RecordGrid struct {
|
||||
|
||||
// Is BRO enabled
|
||||
BROEnabled bool `json:"bro_enabled"`
|
||||
|
||||
// Budget
|
||||
Budget bool `json:"budget"`
|
||||
}
|
||||
|
||||
// Information about grid
|
||||
@@ -159,6 +162,9 @@ type ItemGridList struct {
|
||||
|
||||
// Is BRO enabled
|
||||
BROEnabled bool `json:"bro_enabled"`
|
||||
|
||||
// Budget
|
||||
Budget bool `json:"budget"`
|
||||
}
|
||||
|
||||
// List Grids
|
||||
|
||||
@@ -288,7 +288,7 @@ func (r CreateRequest) GetRAM() map[string]uint64 {
|
||||
|
||||
type wrapperCreateRequest struct {
|
||||
CreateRequest
|
||||
AsyncMode bool `json:"asyncMode"`
|
||||
AsyncMode bool `json:"async_mode"`
|
||||
}
|
||||
|
||||
// Create creates KVM PowerPC VM based on specified OS image
|
||||
|
||||
@@ -73,10 +73,10 @@ type Rule struct {
|
||||
Protocol string `json:"protocol"`
|
||||
|
||||
// Priority Code Point (0-7). L2 marking
|
||||
PCPTag uint64 `json:"pcp_tag"`
|
||||
PCPTag *uint64 `json:"pcp_tag"`
|
||||
|
||||
// DSCP value (0-63). L3 marking
|
||||
DSCPValue uint64 `json:"dscp_value"`
|
||||
DSCPValue *uint64 `json:"dscp_value"`
|
||||
|
||||
// Source IP address
|
||||
SrcIP string `json:"src_ip"`
|
||||
|
||||
@@ -16,11 +16,11 @@ type UpdateRequest struct {
|
||||
|
||||
// New QoS policy name
|
||||
// Required: false
|
||||
Name string `url:"name,omitempty" json:"name,omitempty"`
|
||||
Name *string `url:"name,omitempty" json:"name,omitempty"`
|
||||
|
||||
// New QoS policy description
|
||||
// Required: false
|
||||
Description string `url:"description,omitempty" json:"description,omitempty"`
|
||||
Description *string `url:"description,omitempty" json:"description,omitempty"`
|
||||
}
|
||||
|
||||
func (qp QoSPolicy) Update(ctx context.Context, req UpdateRequest) (*RecordQoSPolicy, error) {
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
package cloudbroker
|
||||
|
||||
import "repository.basistech.ru/BASIS/dynamix-golang-sdk/v16/pkg/cloudbroker/session"
|
||||
|
||||
// Accessing the session method group
|
||||
func (cb *CloudBroker) Session() *session.Session {
|
||||
return session.New(cb.client)
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package session
|
||||
|
||||
// FilterByID returns ListSession with specified ID.
|
||||
func (lsession ListSession) FilterByID(id string) ListSession {
|
||||
predicate := func(rsession ItemSession) bool {
|
||||
return rsession.PublicSessionID == id
|
||||
}
|
||||
|
||||
return lsession.FilterFunc(predicate)
|
||||
}
|
||||
|
||||
// FilterByName returns ListSession with specified User.
|
||||
func (lsession ListSession) FilterByUser(user string) ListSession {
|
||||
predicate := func(rsession ItemSession) bool {
|
||||
return rsession.User == user
|
||||
}
|
||||
|
||||
return lsession.FilterFunc(predicate)
|
||||
}
|
||||
|
||||
// FilterByObjStatus returns ListSession with specified IP.
|
||||
func (lsession ListSession) FilterByIP(ip string) ListSession {
|
||||
predicate := func(rsession ItemSession) bool {
|
||||
return rsession.IP == ip
|
||||
}
|
||||
|
||||
return lsession.FilterFunc(predicate)
|
||||
}
|
||||
|
||||
// FilterFunc allows filtering ListSession based on user-specified predicate.
|
||||
func (lsession ListSession) FilterFunc(predicate func(session ItemSession) bool) ListSession {
|
||||
var result ListSession
|
||||
|
||||
for _, item := range lsession.Data {
|
||||
if predicate(item) {
|
||||
result.Data = append(result.Data, item)
|
||||
}
|
||||
}
|
||||
|
||||
result.EntryCount = uint64(len(result.Data))
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
// FindOne returns first found ItemSession
|
||||
// If none was found, returns an empty struct.
|
||||
func (lsession ListSession) FindOne() ItemSession {
|
||||
if len(lsession.Data) == 0 {
|
||||
return ItemSession{}
|
||||
}
|
||||
|
||||
return lsession.Data[0]
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package session
|
||||
|
||||
import "testing"
|
||||
|
||||
var sessions = ListSession{
|
||||
Data: []ItemSession{
|
||||
{
|
||||
PublicSessionID: "06674bdf-13f1-4f78-a40a-242fd76e4cd1",
|
||||
IP: "10.244.0.243",
|
||||
User: "someuser",
|
||||
},
|
||||
{
|
||||
PublicSessionID: "06674bdf-13f1-4f78-a40a-242fd76e4cd5",
|
||||
IP: "10.244.0.242",
|
||||
User: "someuser2",
|
||||
},
|
||||
{
|
||||
PublicSessionID: "06674bdf-13f1-4f78-a40a-242fd76e4cd7",
|
||||
IP: "10.244.0.243",
|
||||
User: "someuser2",
|
||||
},
|
||||
},
|
||||
EntryCount: 3,
|
||||
}
|
||||
|
||||
func TestFilterByID(t *testing.T) {
|
||||
actual := sessions.FilterByID("06674bdf-13f1-4f78-a40a-242fd76e4cd1").FindOne()
|
||||
|
||||
if actual.PublicSessionID != "06674bdf-13f1-4f78-a40a-242fd76e4cd1" {
|
||||
t.Fatal("expected ID 1, found: ", actual.PublicSessionID)
|
||||
}
|
||||
}
|
||||
|
||||
func TestFilterByUser(t *testing.T) {
|
||||
actual := sessions.FilterByUser("someuser").FindOne()
|
||||
|
||||
if actual.User != "someuser" {
|
||||
t.Fatal("expected User 'someuser', found: ", actual.User)
|
||||
}
|
||||
}
|
||||
|
||||
func TestFilterByIP(t *testing.T) {
|
||||
actual := sessions.FilterByIP("10.244.0.243")
|
||||
|
||||
if len(actual.Data) != 2 {
|
||||
t.Fatal("expected 2 found, actual: ", len(actual.Data))
|
||||
}
|
||||
|
||||
for _, item := range actual.Data {
|
||||
if item.IP != "10.244.0.243" {
|
||||
t.Fatal("expected IP '10.244.0.243', found: ", item.IP)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package session
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v16/internal/validators"
|
||||
)
|
||||
|
||||
// GetRequest struct to get Session parameters
|
||||
type GetRequest struct {
|
||||
// Storage endpoint provider ID
|
||||
// Required: true
|
||||
PublicSessionID string `url:"public_session_id" json:"public_session_id" validate:"required"`
|
||||
}
|
||||
|
||||
// Get gets Session parameters as a RecordSession struct
|
||||
func (s Session) Get(ctx context.Context, req GetRequest) (*RecordSession, error) {
|
||||
res, err := s.GetRaw(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
info := RecordSession{}
|
||||
|
||||
err = json.Unmarshal(res, &info)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &info, nil
|
||||
}
|
||||
|
||||
// GetRaw gets Session parameters as an array of bytes
|
||||
func (s Session) GetRaw(ctx context.Context, req GetRequest) ([]byte, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/session/get"
|
||||
|
||||
res, err := s.client.DecortApiCall(ctx, http.MethodGet, url, req)
|
||||
return res, err
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package session
|
||||
|
||||
// IDs gets array of PublicSessionIDs from ListSession struct
|
||||
func (ls ListSession) IDs() []string {
|
||||
res := make([]string, 0, len(ls.Data))
|
||||
for _, s := range ls.Data {
|
||||
res = append(res, s.PublicSessionID)
|
||||
}
|
||||
return res
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
package session
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v16/internal/validators"
|
||||
)
|
||||
|
||||
type ListRequest struct {
|
||||
// Filter by username
|
||||
User string `url:"user,omitempty" json:"user,omitempty"`
|
||||
|
||||
// Filter by authorization system (bvs, decs3o, password)
|
||||
AuthorizeSystem string `url:"authorize_system,omitempty" json:"authorize_system,omitempty"`
|
||||
|
||||
// Filter by public session ID (UUID)
|
||||
PublicSessionID string `url:"public_session_id,omitempty" json:"public_session_id,omitempty"`
|
||||
|
||||
// Filter by sub from JWT
|
||||
Sub string `url:"sub,omitempty" json:"sub,omitempty"`
|
||||
|
||||
// Filter by sid from JWT
|
||||
SID uint64 `url:"sid,omitempty" json:"sid,omitempty"`
|
||||
|
||||
// Filter sessions with login_time >= timestamp (Unix timestamp)
|
||||
TimestampAt uint64 `url:"timestamp_at,omitempty" json:"timestamp_at,omitempty"`
|
||||
|
||||
// Filter sessions with login_time <= timestamp (Unix timestamp)
|
||||
TimestampTo uint64 `url:"timestamp_to,omitempty" json:"timestamp_to,omitempty"`
|
||||
|
||||
// Filter sessions active at this timestamp (login_time <= T < logout_time/expires_at)
|
||||
ActiveAt uint64 `url:"active_at,omitempty" json:"active_at,omitempty"`
|
||||
|
||||
// Page size
|
||||
// Required: false
|
||||
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
||||
|
||||
// Page number
|
||||
// Required: false
|
||||
Page uint64 `url:"page,omitempty" json:"page,omitempty"`
|
||||
|
||||
// Sort by one of supported fields, format +|-(field)
|
||||
// Required: false
|
||||
SortBy string `url:"sortBy,omitempty" json:"sortBy,omitempty"`
|
||||
}
|
||||
|
||||
// List gets list of sessions as a ListSession struct
|
||||
func (s Session) List(ctx context.Context, req ListRequest) (*ListSession, error) {
|
||||
|
||||
res, err := s.ListRaw(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
list := ListSession{}
|
||||
|
||||
err = json.Unmarshal(res, &list)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &list, nil
|
||||
}
|
||||
|
||||
// ListRaw gets list of sessions as an array of bytes
|
||||
func (s Session) ListRaw(ctx context.Context, req ListRequest) ([]byte, error) {
|
||||
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/session/list"
|
||||
|
||||
res, err := s.client.DecortApiCall(ctx, http.MethodGet, url, req)
|
||||
return res, err
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
package session
|
||||
|
||||
// Main information about a session
|
||||
type RecordSession struct {
|
||||
// Public session ID
|
||||
PublicSessionID string `json:"public_session_id"`
|
||||
|
||||
// Username
|
||||
User string `json:"user"`
|
||||
|
||||
// Subject from JWT
|
||||
Sub string `json:"sub"`
|
||||
|
||||
// Session ID from JWT
|
||||
SID string `json:"sid"`
|
||||
|
||||
// Authorization system
|
||||
AuthorizeSystem string `json:"authorize_system"`
|
||||
|
||||
// Client IP address
|
||||
IP string `json:"ip"`
|
||||
|
||||
// Client User-Agent
|
||||
UserAgent string `json:"user_agent"`
|
||||
|
||||
// First login time
|
||||
LoginTime string `json:"login_time"`
|
||||
|
||||
// Last activity time
|
||||
UpdatedAt string `json:"updated_at"`
|
||||
|
||||
// Logout time
|
||||
LogoutTime string `json:"logout_time"`
|
||||
|
||||
// Session expiration time
|
||||
Expires string `json:"expires"`
|
||||
|
||||
// OAuth provider type
|
||||
OAuthType string `json:"oauth_type"`
|
||||
}
|
||||
|
||||
// List of sessions
|
||||
type ListSession struct {
|
||||
// Data
|
||||
Data []ItemSession `json:"data"`
|
||||
|
||||
// Entry count
|
||||
EntryCount uint64 `json:"entryCount"`
|
||||
}
|
||||
|
||||
// A session item
|
||||
type ItemSession struct {
|
||||
// Public session ID
|
||||
PublicSessionID string `json:"public_session_id"`
|
||||
|
||||
// Username
|
||||
User string `json:"user"`
|
||||
|
||||
// Subject from JWT
|
||||
Sub string `json:"sub"`
|
||||
|
||||
// Session ID from JWT
|
||||
SID string `json:"sid"`
|
||||
|
||||
// Authorization system
|
||||
AuthorizeSystem string `json:"authorize_system"`
|
||||
|
||||
// Client IP address
|
||||
IP string `json:"ip"`
|
||||
|
||||
// Client User-Agent
|
||||
UserAgent string `json:"user_agent"`
|
||||
|
||||
// First login time
|
||||
LoginTime string `json:"login_time"`
|
||||
|
||||
// Last activity time
|
||||
UpdatedAt string `json:"updated_at"`
|
||||
|
||||
// Logout time
|
||||
LogoutTime string `json:"logout_time"`
|
||||
|
||||
// Session expiration time
|
||||
Expires string `json:"expires"`
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
// Operator actions for handling interventions on a session
|
||||
package session
|
||||
|
||||
import (
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v16/interfaces"
|
||||
)
|
||||
|
||||
// Structure for creating request to session
|
||||
type Session struct {
|
||||
client interfaces.Caller
|
||||
}
|
||||
|
||||
// Builder for Session endpoints
|
||||
func New(client interfaces.Caller) *Session {
|
||||
return &Session{
|
||||
client: client,
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package vins
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
@@ -69,6 +70,11 @@ type CreateInAccountRequest struct {
|
||||
EnableDefaultGateway interface{} `url:"enable_default_gateway,omitempty" json:"enable_default_gateway,omitempty" validate:"omitempty,isBool"`
|
||||
}
|
||||
|
||||
type asyncWrapperCreateInAccountRequest struct {
|
||||
CreateInAccountRequest
|
||||
AsyncMode bool `url:"asyncMode" json:"asyncMode"`
|
||||
}
|
||||
|
||||
// CreateInAccount creates VINS in account level
|
||||
func (v VINS) CreateInAccount(ctx context.Context, req CreateInAccountRequest) (uint64, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
@@ -78,7 +84,12 @@ func (v VINS) CreateInAccount(ctx context.Context, req CreateInAccountRequest) (
|
||||
|
||||
url := "/cloudbroker/vins/createInAccount"
|
||||
|
||||
res, err := v.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
|
||||
syncReq := asyncWrapperCreateInAccountRequest{
|
||||
CreateInAccountRequest: req,
|
||||
AsyncMode: false,
|
||||
}
|
||||
|
||||
res, err := v.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, syncReq)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
@@ -90,3 +101,32 @@ func (v VINS) CreateInAccount(ctx context.Context, req CreateInAccountRequest) (
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// CreateInAccount creates VINS in account level in async mode
|
||||
func (v VINS) AsyncCreateInAccount(ctx context.Context, req CreateInAccountRequest) (string, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
asyncReq := asyncWrapperCreateInAccountRequest{
|
||||
CreateInAccountRequest: req,
|
||||
AsyncMode: true,
|
||||
}
|
||||
|
||||
url := "/cloudbroker/vins/createInAccount"
|
||||
|
||||
result, err := v.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, asyncReq)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
var resp string
|
||||
|
||||
err = json.Unmarshal(result, &resp)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return resp, nil
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package vins
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
@@ -63,6 +64,11 @@ type CreateInRGRequest struct {
|
||||
EnableDefaultGateway interface{} `url:"enable_default_gateway,omitempty" json:"enable_default_gateway,omitempty" validate:"omitempty,isBool"`
|
||||
}
|
||||
|
||||
type asyncWrapperCreateInRgRequest struct {
|
||||
CreateInRGRequest
|
||||
AsyncMode bool `url:"asyncMode" json:"asyncMode"`
|
||||
}
|
||||
|
||||
// CreateInRG creates VINS in resource group level
|
||||
func (v VINS) CreateInRG(ctx context.Context, req CreateInRGRequest) (uint64, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
@@ -72,7 +78,12 @@ func (v VINS) CreateInRG(ctx context.Context, req CreateInRGRequest) (uint64, er
|
||||
|
||||
url := "/cloudbroker/vins/createInRG"
|
||||
|
||||
res, err := v.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
|
||||
syncReq := asyncWrapperCreateInRgRequest{
|
||||
CreateInRGRequest: req,
|
||||
AsyncMode: false,
|
||||
}
|
||||
|
||||
res, err := v.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, syncReq)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
@@ -84,3 +95,32 @@ func (v VINS) CreateInRG(ctx context.Context, req CreateInRGRequest) (uint64, er
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// CreateInRG creates VINS in resource group level in async mode
|
||||
func (v VINS) AsyncCreateInRG(ctx context.Context, req CreateInRGRequest) (string, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/vins/createInRG"
|
||||
|
||||
syncReq := asyncWrapperCreateInRgRequest{
|
||||
CreateInRGRequest: req,
|
||||
AsyncMode: true,
|
||||
}
|
||||
|
||||
result, err := v.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, syncReq)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
var resp string
|
||||
|
||||
err = json.Unmarshal(result, &resp)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return resp, nil
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package vins
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
@@ -15,6 +16,11 @@ type EnableRequest struct {
|
||||
VINSID uint64 `url:"vinsId" json:"vinsId" validate:"required"`
|
||||
}
|
||||
|
||||
type asyncWrapperEnableRequest struct {
|
||||
EnableRequest
|
||||
AsyncMode bool `url:"asyncMode"`
|
||||
}
|
||||
|
||||
// Enable enables VINS by ID
|
||||
func (v VINS) Enable(ctx context.Context, req EnableRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
@@ -24,7 +30,12 @@ func (v VINS) Enable(ctx context.Context, req EnableRequest) (bool, error) {
|
||||
|
||||
url := "/cloudbroker/vins/enable"
|
||||
|
||||
res, err := v.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
syncReq := asyncWrapperEnableRequest{
|
||||
EnableRequest: req,
|
||||
AsyncMode: false,
|
||||
}
|
||||
|
||||
res, err := v.client.DecortApiCall(ctx, http.MethodPost, url, syncReq)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
@@ -36,3 +47,32 @@ func (v VINS) Enable(ctx context.Context, req EnableRequest) (bool, error) {
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// Enable enables VINS by ID in async mode
|
||||
func (v VINS) AsyncEnable(ctx context.Context, req EnableRequest) (string, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/vins/enable"
|
||||
|
||||
asyncReq := asyncWrapperEnableRequest{
|
||||
EnableRequest: req,
|
||||
AsyncMode: true,
|
||||
}
|
||||
|
||||
result, err := v.client.DecortApiCall(ctx, http.MethodPost, url, asyncReq)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
var resp string
|
||||
|
||||
err = json.Unmarshal(result, &resp)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return resp, nil
|
||||
}
|
||||
@@ -173,6 +173,9 @@ type ItemInterface struct {
|
||||
// QOS
|
||||
QOS QOS `json:"qos"`
|
||||
|
||||
// List of QoS policies
|
||||
QoSPolicies []uint64 `json:"qos_policies"`
|
||||
|
||||
// Target
|
||||
Target string `json:"target"`
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ package vins
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
@@ -15,6 +16,11 @@ type VNFDevRedeployRequest struct {
|
||||
VINSID uint64 `url:"vinsId" json:"vinsId" validate:"required"`
|
||||
}
|
||||
|
||||
type asyncWrapperVNFDevRedeployRequest struct {
|
||||
VNFDevRedeployRequest
|
||||
AsyncMode bool `url:"asyncMode"`
|
||||
}
|
||||
|
||||
// VNFDevRedeploy redeploys VINS VNFDevs
|
||||
func (v VINS) VNFDevRedeploy(ctx context.Context, req VNFDevRedeployRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
@@ -24,7 +30,12 @@ func (v VINS) VNFDevRedeploy(ctx context.Context, req VNFDevRedeployRequest) (bo
|
||||
|
||||
url := "/cloudbroker/vins/vnfdevRedeploy"
|
||||
|
||||
res, err := v.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
syncReq := asyncWrapperVNFDevRedeployRequest{
|
||||
VNFDevRedeployRequest: req,
|
||||
AsyncMode: false,
|
||||
}
|
||||
|
||||
res, err := v.client.DecortApiCall(ctx, http.MethodPost, url, syncReq)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
@@ -36,3 +47,32 @@ func (v VINS) VNFDevRedeploy(ctx context.Context, req VNFDevRedeployRequest) (bo
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// VNFDevRedeploy redeploys VINS VNFDevs in async mode
|
||||
func (v VINS) AsyncVNFDevRedeploy(ctx context.Context, req VNFDevRedeployRequest) (string, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/vins/vnfdevRedeploy"
|
||||
|
||||
asyncReq := asyncWrapperVNFDevRedeployRequest{
|
||||
VNFDevRedeployRequest: req,
|
||||
AsyncMode: true,
|
||||
}
|
||||
|
||||
result, err := v.client.DecortApiCall(ctx, http.MethodPost, url, asyncReq)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
var resp string
|
||||
|
||||
err = json.Unmarshal(result, &resp)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return resp, nil
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package vins
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
@@ -15,6 +16,11 @@ type VNFDevRestartRequest struct {
|
||||
VINSID uint64 `url:"vinsId" json:"vinsId" validate:"required"`
|
||||
}
|
||||
|
||||
type asyncWrapperVNFDevRestartRequest struct {
|
||||
VNFDevRestartRequest
|
||||
AsyncMode bool `url:"asyncMode"`
|
||||
}
|
||||
|
||||
// VNFDevRestart reboots VINSes primary VNF device
|
||||
func (v VINS) VNFDevRestart(ctx context.Context, req VNFDevRestartRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
@@ -24,7 +30,12 @@ func (v VINS) VNFDevRestart(ctx context.Context, req VNFDevRestartRequest) (bool
|
||||
|
||||
url := "/cloudbroker/vins/vnfdevRestart"
|
||||
|
||||
res, err := v.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
syncReq := asyncWrapperVNFDevRestartRequest{
|
||||
VNFDevRestartRequest: req,
|
||||
AsyncMode: false,
|
||||
}
|
||||
|
||||
res, err := v.client.DecortApiCall(ctx, http.MethodPost, url, syncReq)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
@@ -36,3 +47,32 @@ func (v VINS) VNFDevRestart(ctx context.Context, req VNFDevRestartRequest) (bool
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// VNFDevRestart reboots VINSes primary VNF device in async mode
|
||||
func (v VINS) AsyncVNFDevRestart(ctx context.Context, req VNFDevRestartRequest) (string, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/vins/vnfdevRestart"
|
||||
|
||||
asyncReq := asyncWrapperVNFDevRestartRequest{
|
||||
VNFDevRestartRequest: req,
|
||||
AsyncMode: true,
|
||||
}
|
||||
|
||||
result, err := v.client.DecortApiCall(ctx, http.MethodPost, url, asyncReq)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
var resp string
|
||||
|
||||
err = json.Unmarshal(result, &resp)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return resp, nil
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package vins
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
@@ -15,6 +16,11 @@ type VNFDevStartRequest struct {
|
||||
VINSID uint64 `url:"vinsId" json:"vinsId" validate:"required"`
|
||||
}
|
||||
|
||||
type asyncWrapperVNFDevStartRequest struct {
|
||||
VNFDevStartRequest
|
||||
AsyncMode bool `url:"asyncMode"`
|
||||
}
|
||||
|
||||
// VNFDevStart starts VINSes primary VNF device
|
||||
func (v VINS) VNFDevStart(ctx context.Context, req VNFDevStartRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
@@ -24,7 +30,12 @@ func (v VINS) VNFDevStart(ctx context.Context, req VNFDevStartRequest) (bool, er
|
||||
|
||||
url := "/cloudbroker/vins/vnfdevStart"
|
||||
|
||||
res, err := v.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
syncReq := asyncWrapperVNFDevStartRequest{
|
||||
VNFDevStartRequest: req,
|
||||
AsyncMode: false,
|
||||
}
|
||||
|
||||
res, err := v.client.DecortApiCall(ctx, http.MethodPost, url, syncReq)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
@@ -36,3 +47,32 @@ func (v VINS) VNFDevStart(ctx context.Context, req VNFDevStartRequest) (bool, er
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// VNFDevStart starts VINSes primary VNF device
|
||||
func (v VINS) AsyncVNFDevStart(ctx context.Context, req VNFDevStartRequest) (string, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/vins/vnfdevStart"
|
||||
|
||||
asyncReq := asyncWrapperVNFDevStartRequest{
|
||||
VNFDevStartRequest: req,
|
||||
AsyncMode: true,
|
||||
}
|
||||
|
||||
result, err := v.client.DecortApiCall(ctx, http.MethodPost, url, asyncReq)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
var resp string
|
||||
|
||||
err = json.Unmarshal(result, &resp)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return resp, nil
|
||||
}
|
||||
Reference in new issue
Block a user