Compare commits
1 Commits
v1.5.0-gam
...
v1.5.0-del
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5025a17ea4 |
143
CHANGELOG.md
143
CHANGELOG.md
@@ -1,4 +1,143 @@
|
|||||||
## Version 1.4.7
|
## Version 1.5.0
|
||||||
|
|
||||||
|
### Feature
|
||||||
|
|
||||||
|
- Updated lists responses models in:
|
||||||
|
- - cloudapi/account/list
|
||||||
|
- - cloudbroker/account/list
|
||||||
|
- - cloudapi/bservice/list
|
||||||
|
- - cloudapi/compute/list
|
||||||
|
- - cloudbroker/compute/list
|
||||||
|
- - cloudapi/computeci/list
|
||||||
|
- - cloudapi/disks/list
|
||||||
|
- - cloudbroker/disks/list
|
||||||
|
- - cloudapi/extnet/list
|
||||||
|
- - cloudbroker/extnet/list
|
||||||
|
- - cloudapi/flipgroup/list
|
||||||
|
- - cloudapi/image/list
|
||||||
|
- - cloudbroker/image/list
|
||||||
|
- - cloudapi/k8ci/list
|
||||||
|
- - cloudbroker/k8ci/list
|
||||||
|
- - cloudapi/k8s/list
|
||||||
|
- - cloudapi/k8s/listDeleted
|
||||||
|
- - cloudbroker/k8s/list
|
||||||
|
- - cloudbroker/k8s/listDeleted
|
||||||
|
- - cloudapi/tasks/list
|
||||||
|
- - cloudbroker/tasks/list
|
||||||
|
- - cloudapi/rg/list
|
||||||
|
- - cloudbroker/rg/list
|
||||||
|
- - cloudapi/vins/list
|
||||||
|
- - cloudbroker/vins/list
|
||||||
|
- - cloudapi/account/listDeleted
|
||||||
|
- - cloudapi/account/listCompute
|
||||||
|
- - cloudapi/account/listDisks
|
||||||
|
- - cloudapi/account/listFlipGroups
|
||||||
|
- - cloudapi/account/listRG
|
||||||
|
- - cloudapi/account/listVINS
|
||||||
|
- - cloudapi/compute/listDeleted
|
||||||
|
- - cloudapi/disks/listDeleted
|
||||||
|
- - cloudapi/disks/listTypes
|
||||||
|
- - cloudapi/k8ci/listDeleted
|
||||||
|
- - cloudapi/lb/list
|
||||||
|
- - cloudapi/lb/listDeleted
|
||||||
|
- - cloudbroker/lb/list
|
||||||
|
- - cloudbroker/lb/listDeleted
|
||||||
|
- - cloudapi/rg/listComputes
|
||||||
|
- - cloudapi/rg/listDeleted
|
||||||
|
- - cloudapi/rg/listLb
|
||||||
|
- - cloudapi/rg/listPFW
|
||||||
|
- - cloudapi/rg/listVins
|
||||||
|
- - cloudapi/vins/listDeleted
|
||||||
|
- - cloudbroker/account/listComputes
|
||||||
|
- - cloudbroker/account/listDeleted
|
||||||
|
- - cloudbroker/account/listDisks
|
||||||
|
- - cloudbroker/account/listFlipGroups
|
||||||
|
- - cloudbroker/account/listRG
|
||||||
|
- - cloudbroker/account/listVINS
|
||||||
|
- - cloudbroker/compute/listDeleted
|
||||||
|
- - cloudapi/compute/listPciDevice
|
||||||
|
- - cloudbroker/compute/listPciDevice
|
||||||
|
- - cloudapi/compute/listVGpu
|
||||||
|
- - cloudbroker/compute/listVGpu
|
||||||
|
- - cloudbroker/disks/listTypes
|
||||||
|
- - cloudbroker/grid/list
|
||||||
|
- - cloudbroker/grid/listEmails
|
||||||
|
- - cloudbroker/k8ci/listDeleted
|
||||||
|
- - cloudbroker/pcidevice/list
|
||||||
|
- - cloudbroker/rg/affinityGroupsList
|
||||||
|
- - cloudbroker/rg/listDeleted
|
||||||
|
- - cloudbroker/rg/listComputes
|
||||||
|
- - cloudbroker/rg/listLB
|
||||||
|
- - cloudbroker/rg/listPfw
|
||||||
|
- - cloudbroker/rg/listResourceConsumption
|
||||||
|
- - cloudbroker/rg/listVins
|
||||||
|
- - cloudbroker/sep/list
|
||||||
|
- - cloudbroker/vgpu/list
|
||||||
|
- - cloudbroker/vins/extnetList
|
||||||
|
- - cloudbroker/vins/IpList
|
||||||
|
- - cloudbroker/vins/natRuleList
|
||||||
|
|
||||||
|
- Added new endpoints:
|
||||||
|
- - cloudapi/rg/getResourceConsumption
|
||||||
|
- - cloudapi/rg/listResourceConsumption
|
||||||
|
- - cloudbroker/rg/getResourceConsumption
|
||||||
|
- - cloudbroker/rg/listResourceConsumption
|
||||||
|
- - cloudapi/account/getResourceConsumption
|
||||||
|
- - cloudapi/account/listResourceConsumption
|
||||||
|
- - cloudbroker/account/getResourceConsumption
|
||||||
|
- - cloudbroker/account/listResourceConsumption
|
||||||
|
- - cloudbroker/grid/getResourceConsumption
|
||||||
|
- - cloudbroker/grid/listResourceConsumption
|
||||||
|
|
||||||
|
- Added field CU_DM to ResourceLimits model (account, rg)
|
||||||
|
|
||||||
|
- Added field ReferenceID to SnapshotExtended model in cloudapi/compute/get
|
||||||
|
|
||||||
|
- Added field Interfaces in requests:
|
||||||
|
- - cloudapi/kvmppc/create
|
||||||
|
- - cloudapi/kvmppc/createBlank
|
||||||
|
- - cloudapi/kvmx86/create
|
||||||
|
- - cloudapi/kvmx86/createBlank
|
||||||
|
- - cloudbroker/kvmppc/create
|
||||||
|
- - cloudbroker/kvmppc/createBlank
|
||||||
|
- - cloudbroker/kvmx86/create
|
||||||
|
- - cloudbroker/kvmx86/createBlank
|
||||||
|
|
||||||
|
- Added UpdatedBy field to task model in cloudbroker/task/get
|
||||||
|
|
||||||
|
- Made optional fields in requests:
|
||||||
|
- - Reason (cloudbroker/account/delete)
|
||||||
|
- - Reason (cloudbroker/account/restore)
|
||||||
|
- - Gateway (cloudbroker/extnet/create)
|
||||||
|
- - Reason (cloudbroker/image/delete)
|
||||||
|
- - Num (cloudapi/k8s/workerAdd)
|
||||||
|
- - NetID (cloudbroker/vins/extnetConnect)
|
||||||
|
|
||||||
|
- Updated cloudapi/rg/get model
|
||||||
|
|
||||||
|
- Deleted field Username from cloudbroker/account/update request
|
||||||
|
|
||||||
|
- Deleted field EmailAddress from cloudbroker/account/update request
|
||||||
|
|
||||||
|
- Added field DiskType to cloudbroker/compute/diskAttach request
|
||||||
|
|
||||||
|
- Added field Reason to cloudbroker/compute/diskQos request
|
||||||
|
|
||||||
|
- Added field Enabled to cloudbroker/compute/netAttach response model
|
||||||
|
|
||||||
|
- Added field CPUAllocationRatio to cloudbroker/image/listStacks response model
|
||||||
|
|
||||||
|
- Added field Descr to cloudbroker/image/listStacks response model
|
||||||
|
|
||||||
|
- Added field MemAllocationRatio to cloudbroker/image/listStacks response model
|
||||||
|
|
||||||
|
- Updated cloudapi/k8s/workersGroupByName response model
|
||||||
|
|
||||||
|
- Deleted field LBImageID from cloudbroker/k8ci/create request
|
||||||
|
|
||||||
|
- Deleted field ImageID from cloudbroker/lb/create request
|
||||||
|
|
||||||
|
- Deleted field Reason from cloudbroker/vins/extnetList request
|
||||||
|
|
||||||
### Bugfix
|
### Bugfix
|
||||||
- Deleted validate:"required" tag from IPCIDR field in cloudapi/vins/createInRg request struct
|
- Changed the Excluded field type in cloudbroker/extnet/get response model
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ Decort SDK - это библиотека, написанная на языке G
|
|||||||
- Версия 1.2.x Decort-SDK соответствует 3.8.5 версии платформы
|
- Версия 1.2.x Decort-SDK соответствует 3.8.5 версии платформы
|
||||||
- Версия 1.3.x Decort-SDK соответствует 3.8.5 версии платформы
|
- Версия 1.3.x Decort-SDK соответствует 3.8.5 версии платформы
|
||||||
- Версия 1.4.x Decort-SDK соответствует 3.8.6 версии платформы
|
- Версия 1.4.x Decort-SDK соответствует 3.8.6 версии платформы
|
||||||
|
- Версия 1.5.x Decort-SDK соответствует 3.8.7 версии платформы
|
||||||
|
|
||||||
## Оглавление
|
## Оглавление
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,23 @@ import (
|
|||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type Interface struct {
|
||||||
|
// Network type
|
||||||
|
// Should be one of:
|
||||||
|
// - VINS
|
||||||
|
// - EXTNET
|
||||||
|
NetType string `url:"netType" json:"netType" validate:"required,kvmNetType"`
|
||||||
|
|
||||||
|
// Network ID for connect to,
|
||||||
|
// for EXTNET - external network ID,
|
||||||
|
// for VINS - VINS ID,
|
||||||
|
NetID uint64 `url:"netId" json:"netId" validate:"required"`
|
||||||
|
|
||||||
|
// IP address to assign to this VM when connecting to the specified network
|
||||||
|
// Required: false
|
||||||
|
IPAddr string `url:"ipAddr,omitempty" json:"ipAddr,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
// Request struct for create KVM PowerPC VM
|
// Request struct for create KVM PowerPC VM
|
||||||
type CreateRequest struct {
|
type CreateRequest struct {
|
||||||
// ID of the resource group, which will own this VM
|
// ID of the resource group, which will own this VM
|
||||||
@@ -45,24 +62,9 @@ type CreateRequest struct {
|
|||||||
// Required: false
|
// Required: false
|
||||||
Pool string `url:"pool,omitempty" json:"pool,omitempty"`
|
Pool string `url:"pool,omitempty" json:"pool,omitempty"`
|
||||||
|
|
||||||
// Network type
|
// Slice of structs with net interface description.
|
||||||
// Should be one of:
|
|
||||||
// - VINS
|
|
||||||
// - EXTNET
|
|
||||||
// - NONE
|
|
||||||
// Required: false
|
// Required: false
|
||||||
NetType string `url:"netType,omitempty" json:"netType,omitempty" validate:"omitempty,kvmNetType"`
|
Interfaces []Interface `url:"interfaces,omitempty" json:"interfaces,omitempty" validate:"omitempty,min=1,dive"`
|
||||||
|
|
||||||
// Network ID for connect to,
|
|
||||||
// for EXTNET - external network ID,
|
|
||||||
// for ViNS - ViNS ID,
|
|
||||||
// when netType is not "NONE"
|
|
||||||
// Required: false
|
|
||||||
NetID uint64 `url:"netId,omitempty" json:"netId,omitempty"`
|
|
||||||
|
|
||||||
// IP address to assign to this VM when connecting to the specified network
|
|
||||||
// Required: false
|
|
||||||
IPAddr string `url:"ipAddr,omitempty" json:"ipAddr,omitempty"`
|
|
||||||
|
|
||||||
// Input data for cloud-init facility
|
// Input data for cloud-init facility
|
||||||
// Required: false
|
// Required: false
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ type CreateBlankRequest struct {
|
|||||||
// Required: true
|
// Required: true
|
||||||
BootDisk uint64 `url:"bootDisk" json:"bootDisk" validate:"required"`
|
BootDisk uint64 `url:"bootDisk" json:"bootDisk" validate:"required"`
|
||||||
|
|
||||||
// ID of SEP to create boot disk on.
|
// ID of SEP to create boot disk on
|
||||||
// Uses images SEP ID if not set
|
// Uses images SEP ID if not set
|
||||||
// Required: true
|
// Required: true
|
||||||
SEPID uint64 `url:"sepId" json:"sepId" validate:"required"`
|
SEPID uint64 `url:"sepId" json:"sepId" validate:"required"`
|
||||||
@@ -40,24 +40,9 @@ type CreateBlankRequest struct {
|
|||||||
// Required: true
|
// Required: true
|
||||||
Pool string `url:"pool" json:"pool" validate:"required"`
|
Pool string `url:"pool" json:"pool" validate:"required"`
|
||||||
|
|
||||||
// Network type
|
// Slice of structs with net interface description
|
||||||
// Should be one of:
|
|
||||||
// - VINS
|
|
||||||
// - EXTNET
|
|
||||||
// - NONE
|
|
||||||
// Required: false
|
// Required: false
|
||||||
NetType string `url:"netType,omitempty" json:"netType,omitempty" validate:"omitempty,kvmNetType"`
|
Interfaces []Interface `url:"interfaces,omitempty" json:"interfaces,omitempty" validate:"omitempty,min=1,dive"`
|
||||||
|
|
||||||
// Network ID for connect to,
|
|
||||||
// for EXTNET - external network ID,
|
|
||||||
// for VINS - VINS ID,
|
|
||||||
// when network type is not "NONE"
|
|
||||||
// Required: false
|
|
||||||
NetID uint64 `url:"netId,omitempty" json:"netId,omitempty"`
|
|
||||||
|
|
||||||
// IP address to assign to this VM when connecting to the specified network
|
|
||||||
// Required: false
|
|
||||||
IPAddr string `url:"ipAddr,omitempty" json:"ipAddr,omitempty"`
|
|
||||||
|
|
||||||
// Text description of this VM
|
// Text description of this VM
|
||||||
// Required: false
|
// Required: false
|
||||||
|
|||||||
@@ -63,6 +63,7 @@ type CreateRequest struct {
|
|||||||
Pool string `url:"pool,omitempty" json:"pool,omitempty"`
|
Pool string `url:"pool,omitempty" json:"pool,omitempty"`
|
||||||
|
|
||||||
// Slice of structs with net interface description.
|
// Slice of structs with net interface description.
|
||||||
|
// Required: false
|
||||||
Interfaces []Interface `url:"interfaces,omitempty" json:"interfaces,omitempty" validate:"omitempty,min=1,dive"`
|
Interfaces []Interface `url:"interfaces,omitempty" json:"interfaces,omitempty" validate:"omitempty,min=1,dive"`
|
||||||
|
|
||||||
// Input data for cloud-init facility
|
// Input data for cloud-init facility
|
||||||
|
|||||||
@@ -41,7 +41,9 @@ type CreateBlankRequest struct {
|
|||||||
Pool string `url:"pool" json:"pool" validate:"required"`
|
Pool string `url:"pool" json:"pool" validate:"required"`
|
||||||
|
|
||||||
// Slice of structs with net interface description.
|
// Slice of structs with net interface description.
|
||||||
|
// Required: false
|
||||||
Interfaces []Interface `url:"interfaces,omitempty" json:"interfaces,omitempty" validate:"omitempty,min=1,dive"`
|
Interfaces []Interface `url:"interfaces,omitempty" json:"interfaces,omitempty" validate:"omitempty,min=1,dive"`
|
||||||
|
|
||||||
// Text description of this VM
|
// Text description of this VM
|
||||||
// Required: false
|
// Required: false
|
||||||
Description string `url:"desc,omitempty" json:"desc,omitempty"`
|
Description string `url:"desc,omitempty" json:"desc,omitempty"`
|
||||||
|
|||||||
@@ -1,46 +0,0 @@
|
|||||||
package compute
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"encoding/json"
|
|
||||||
"net/http"
|
|
||||||
|
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Request struct for get list GPU for compute
|
|
||||||
type ListGPURequest struct {
|
|
||||||
// ID of compute instance
|
|
||||||
// Required: true
|
|
||||||
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
|
|
||||||
|
|
||||||
// Also list destroyed
|
|
||||||
// Required: false
|
|
||||||
ListDestroyed bool `url:"list_destroyed,omitempty" json:"list_destroyed,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// ListVGPU gets list GPU for compute
|
|
||||||
func (c Compute) ListGPU(ctx context.Context, req ListGPURequest) ([]interface{}, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
for _, validationError := range validators.GetErrors(err) {
|
|
||||||
return nil, validators.ValidationError(validationError)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudbroker/compute/listGpu"
|
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
list := make([]interface{}, 0)
|
|
||||||
|
|
||||||
err = json.Unmarshal(res, &list)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return list, nil
|
|
||||||
}
|
|
||||||
@@ -137,7 +137,7 @@ type RecordExtNet struct {
|
|||||||
DNS []string `json:"dns"`
|
DNS []string `json:"dns"`
|
||||||
|
|
||||||
// List excludes
|
// List excludes
|
||||||
Excluded []string `json:"excluded"`
|
Excluded ListReservations `json:"excluded"`
|
||||||
|
|
||||||
// Gateway
|
// Gateway
|
||||||
Gateway string `json:"gateway"`
|
Gateway string `json:"gateway"`
|
||||||
|
|||||||
@@ -103,7 +103,7 @@ type CreateRequest struct {
|
|||||||
// Create kubernetes cluster with masters nodes behind load balancer if true.
|
// Create kubernetes cluster with masters nodes behind load balancer if true.
|
||||||
// Otherwise give all cluster nodes direct external addresses from selected external network
|
// Otherwise give all cluster nodes direct external addresses from selected external network
|
||||||
// Required: false
|
// Required: false
|
||||||
WithLB bool `url:"withLB,omitempty" json:"withLB,omitempty"`
|
WithLB bool `url:"withLB" json:"withLB"`
|
||||||
|
|
||||||
// Text description of this kubernetes cluster
|
// Text description of this kubernetes cluster
|
||||||
// Required: false
|
// Required: false
|
||||||
|
|||||||
@@ -76,21 +76,23 @@ func (lkc ListK8S) FilterByDeletedBy(deletedBy string) ListK8S {
|
|||||||
func (lkc ListK8S) FilterFunc(predicate func(ItemK8S) bool) ListK8S {
|
func (lkc ListK8S) FilterFunc(predicate func(ItemK8S) bool) ListK8S {
|
||||||
var result ListK8S
|
var result ListK8S
|
||||||
|
|
||||||
for _, item := range lkc {
|
for _, item := range lkc.Data {
|
||||||
if predicate(item) {
|
if predicate(item) {
|
||||||
result = append(result, item)
|
result.Data = append(result.Data, item)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
result.EntryCount = uint64(len(result.Data))
|
||||||
|
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
// FindOne returns first found ItemK8S
|
// FindOne returns first found ItemK8S
|
||||||
// If none was found, returns an empty struct.
|
// If none was found, returns an empty struct.
|
||||||
func (lkc ListK8S) FindOne() ItemK8S {
|
func (lkc ListK8S) FindOne() ItemK8S {
|
||||||
if len(lkc) == 0 {
|
if len(lkc.Data) == 0 {
|
||||||
return ItemK8S{}
|
return ItemK8S{}
|
||||||
}
|
}
|
||||||
|
|
||||||
return lkc[0]
|
return lkc.Data[0]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,96 +3,99 @@ package k8s
|
|||||||
import "testing"
|
import "testing"
|
||||||
|
|
||||||
var k8sItems = ListK8S{
|
var k8sItems = ListK8S{
|
||||||
ItemK8S{
|
Data: []ItemK8S{
|
||||||
AccountID: 1,
|
{
|
||||||
AccountName: "test_1",
|
AccountID: 1,
|
||||||
ACL: []interface{}{},
|
AccountName: "test_1",
|
||||||
BServiceID: 1,
|
ACL: []interface{}{},
|
||||||
CIID: 1,
|
BServiceID: 1,
|
||||||
Config: nil,
|
CIID: 1,
|
||||||
CreatedBy: "test_user",
|
Config: nil,
|
||||||
CreatedTime: 132454563,
|
CreatedBy: "test_user",
|
||||||
DeletedBy: "",
|
CreatedTime: 132454563,
|
||||||
DeletedTime: 0,
|
DeletedBy: "",
|
||||||
Description: "",
|
DeletedTime: 0,
|
||||||
ExtNetID: 1,
|
Description: "",
|
||||||
GID: 0,
|
ExtNetID: 1,
|
||||||
GUID: 1,
|
GID: 0,
|
||||||
ID: 1,
|
GUID: 1,
|
||||||
LBID: 1,
|
ID: 1,
|
||||||
Milestones: 999999,
|
LBID: 1,
|
||||||
Name: "k8s_1",
|
Milestones: 999999,
|
||||||
RGID: 1,
|
Name: "k8s_1",
|
||||||
RGName: "rg_1",
|
RGID: 1,
|
||||||
ServiceAccount: ServiceAccount{},
|
RGName: "rg_1",
|
||||||
SSHKey: "sample_key",
|
ServiceAccount: ServiceAccount{},
|
||||||
Status: "ENABLED",
|
SSHKey: "sample_key",
|
||||||
TechStatus: "STARTED",
|
Status: "ENABLED",
|
||||||
UpdatedBy: "",
|
TechStatus: "STARTED",
|
||||||
UpdatedTime: 0,
|
UpdatedBy: "",
|
||||||
VINSID: 0,
|
UpdatedTime: 0,
|
||||||
WorkersGroup: []RecordK8SGroup{},
|
VINSID: 0,
|
||||||
},
|
WorkersGroup: []RecordK8SGroup{},
|
||||||
ItemK8S{
|
},
|
||||||
AccountID: 2,
|
{
|
||||||
AccountName: "test_2",
|
AccountID: 2,
|
||||||
ACL: []interface{}{},
|
AccountName: "test_2",
|
||||||
BServiceID: 2,
|
ACL: []interface{}{},
|
||||||
CIID: 2,
|
BServiceID: 2,
|
||||||
Config: nil,
|
CIID: 2,
|
||||||
CreatedBy: "test_user",
|
Config: nil,
|
||||||
CreatedTime: 132454638,
|
CreatedBy: "test_user",
|
||||||
DeletedBy: "",
|
CreatedTime: 132454638,
|
||||||
DeletedTime: 0,
|
DeletedBy: "",
|
||||||
Description: "",
|
DeletedTime: 0,
|
||||||
ExtNetID: 2,
|
Description: "",
|
||||||
GID: 0,
|
ExtNetID: 2,
|
||||||
GUID: 2,
|
GID: 0,
|
||||||
ID: 2,
|
GUID: 2,
|
||||||
LBID: 2,
|
ID: 2,
|
||||||
Milestones: 999999,
|
LBID: 2,
|
||||||
Name: "k8s_2",
|
Milestones: 999999,
|
||||||
RGID: 2,
|
Name: "k8s_2",
|
||||||
RGName: "rg_2",
|
RGID: 2,
|
||||||
ServiceAccount: ServiceAccount{},
|
RGName: "rg_2",
|
||||||
SSHKey: "sample_key",
|
ServiceAccount: ServiceAccount{},
|
||||||
Status: "ENABLED",
|
SSHKey: "sample_key",
|
||||||
TechStatus: "STARTED",
|
Status: "ENABLED",
|
||||||
UpdatedBy: "",
|
TechStatus: "STARTED",
|
||||||
UpdatedTime: 0,
|
UpdatedBy: "",
|
||||||
VINSID: 0,
|
UpdatedTime: 0,
|
||||||
WorkersGroup: []RecordK8SGroup{},
|
VINSID: 0,
|
||||||
},
|
WorkersGroup: []RecordK8SGroup{},
|
||||||
ItemK8S{
|
},
|
||||||
AccountID: 3,
|
{
|
||||||
AccountName: "test_3",
|
AccountID: 3,
|
||||||
ACL: []interface{}{},
|
AccountName: "test_3",
|
||||||
BServiceID: 3,
|
ACL: []interface{}{},
|
||||||
CIID: 3,
|
BServiceID: 3,
|
||||||
Config: nil,
|
CIID: 3,
|
||||||
CreatedBy: "test_user",
|
Config: nil,
|
||||||
CreatedTime: 132454682,
|
CreatedBy: "test_user",
|
||||||
DeletedBy: "",
|
CreatedTime: 132454682,
|
||||||
DeletedTime: 0,
|
DeletedBy: "",
|
||||||
Description: "",
|
DeletedTime: 0,
|
||||||
ExtNetID: 3,
|
Description: "",
|
||||||
GID: 0,
|
ExtNetID: 3,
|
||||||
GUID: 3,
|
GID: 0,
|
||||||
ID: 3,
|
GUID: 3,
|
||||||
LBID: 3,
|
ID: 3,
|
||||||
Milestones: 999999,
|
LBID: 3,
|
||||||
Name: "k8s_3",
|
Milestones: 999999,
|
||||||
RGID: 3,
|
Name: "k8s_3",
|
||||||
RGName: "rg_3",
|
RGID: 3,
|
||||||
ServiceAccount: ServiceAccount{},
|
RGName: "rg_3",
|
||||||
SSHKey: "sample_key",
|
ServiceAccount: ServiceAccount{},
|
||||||
Status: "DISABLED",
|
SSHKey: "sample_key",
|
||||||
TechStatus: "STOPPED",
|
Status: "DISABLED",
|
||||||
UpdatedBy: "",
|
TechStatus: "STOPPED",
|
||||||
UpdatedTime: 0,
|
UpdatedBy: "",
|
||||||
VINSID: 0,
|
UpdatedTime: 0,
|
||||||
WorkersGroup: []RecordK8SGroup{},
|
VINSID: 0,
|
||||||
|
WorkersGroup: []RecordK8SGroup{},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
EntryCount: 3,
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestFilterByID(t *testing.T) {
|
func TestFilterByID(t *testing.T) {
|
||||||
@@ -130,11 +133,11 @@ func TestFilterByRGID(t *testing.T) {
|
|||||||
func TestFilterByStatus(t *testing.T) {
|
func TestFilterByStatus(t *testing.T) {
|
||||||
actual := k8sItems.FilterByStatus("ENABLED")
|
actual := k8sItems.FilterByStatus("ENABLED")
|
||||||
|
|
||||||
if len(actual) != 2 {
|
if len(actual.Data) != 2 {
|
||||||
t.Fatal("expected 2 found, actual: ", len(actual))
|
t.Fatal("expected 2 found, actual: ", len(actual.Data))
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, item := range actual {
|
for _, item := range actual.Data {
|
||||||
if item.Status != "ENABLED" {
|
if item.Status != "ENABLED" {
|
||||||
t.Fatal("expected Status 'ENABLED', found: ", item.Status)
|
t.Fatal("expected Status 'ENABLED', found: ", item.Status)
|
||||||
}
|
}
|
||||||
@@ -144,11 +147,11 @@ func TestFilterByStatus(t *testing.T) {
|
|||||||
func TestFilterByTechStatus(t *testing.T) {
|
func TestFilterByTechStatus(t *testing.T) {
|
||||||
actual := k8sItems.FilterByTechStatus("STARTED")
|
actual := k8sItems.FilterByTechStatus("STARTED")
|
||||||
|
|
||||||
if len(actual) != 2 {
|
if len(actual.Data) != 2 {
|
||||||
t.Fatal("expected 2 found, actual: ", len(actual))
|
t.Fatal("expected 2 found, actual: ", len(actual.Data))
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, item := range actual {
|
for _, item := range actual.Data {
|
||||||
if item.TechStatus != "STARTED" {
|
if item.TechStatus != "STARTED" {
|
||||||
t.Fatal("expected TechStatus 'STARTED', found: ", item.TechStatus)
|
t.Fatal("expected TechStatus 'STARTED', found: ", item.TechStatus)
|
||||||
}
|
}
|
||||||
@@ -158,11 +161,11 @@ func TestFilterByTechStatus(t *testing.T) {
|
|||||||
func TestFilterByCreatedBy(t *testing.T) {
|
func TestFilterByCreatedBy(t *testing.T) {
|
||||||
actual := k8sItems.FilterByCreatedBy("test_user")
|
actual := k8sItems.FilterByCreatedBy("test_user")
|
||||||
|
|
||||||
if len(actual) != 3 {
|
if len(actual.Data) != 3 {
|
||||||
t.Fatal("expected 3 found, actual: ", len(actual))
|
t.Fatal("expected 3 found, actual: ", len(actual.Data))
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, item := range actual {
|
for _, item := range actual.Data {
|
||||||
if item.CreatedBy != "test_user" {
|
if item.CreatedBy != "test_user" {
|
||||||
t.Fatal("expected CreatedBy 'test_user', found: ", item.CreatedBy)
|
t.Fatal("expected CreatedBy 'test_user', found: ", item.CreatedBy)
|
||||||
}
|
}
|
||||||
@@ -172,8 +175,8 @@ func TestFilterByCreatedBy(t *testing.T) {
|
|||||||
func TestFilterByDeletedBy(t *testing.T) {
|
func TestFilterByDeletedBy(t *testing.T) {
|
||||||
actual := k8sItems.FilterByDeletedBy("test_user")
|
actual := k8sItems.FilterByDeletedBy("test_user")
|
||||||
|
|
||||||
if len(actual) != 0 {
|
if len(actual.Data) != 0 {
|
||||||
t.Fatal("expected 0 found, actual: ", len(actual))
|
t.Fatal("expected 0 found, actual: ", len(actual.Data))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -191,7 +194,7 @@ func TestFilterFunc(t *testing.T) {
|
|||||||
func TestSortByCreatedTime(t *testing.T) {
|
func TestSortByCreatedTime(t *testing.T) {
|
||||||
actual := k8sItems.SortByCreatedTime(false)
|
actual := k8sItems.SortByCreatedTime(false)
|
||||||
|
|
||||||
if actual[0].CreatedTime != 132454563 || actual[2].CreatedTime != 132454682 {
|
if actual.Data[0].CreatedTime != 132454563 || actual.Data[2].CreatedTime != 132454682 {
|
||||||
t.Fatal("expected ascending sort, seems to be inversed")
|
t.Fatal("expected ascending sort, seems to be inversed")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,38 @@ import (
|
|||||||
|
|
||||||
// Request struct for get list information K8S
|
// Request struct for get list information K8S
|
||||||
type ListRequest struct {
|
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"`
|
||||||
|
|
||||||
|
// Find by IP address
|
||||||
|
// Required: false
|
||||||
|
IPAddress string `url:"ipAddress,omitempty" json:"ipAddress,omitempty"`
|
||||||
|
|
||||||
|
// Find by resource group ID
|
||||||
|
// Required: false
|
||||||
|
RGID uint64 `url:"rgId,omitempty" json:"rgId,omitempty"`
|
||||||
|
|
||||||
|
// Find by lbId
|
||||||
|
// Required: false
|
||||||
|
LBID uint64 `url:"lbId,omitempty" json:"lbId,omitempty"`
|
||||||
|
|
||||||
|
// Find by basicServiceId
|
||||||
|
// Required: false
|
||||||
|
BasicServiceID uint64 `url:"basicServiceId,omitempty" json:"basicServiceId,omitempty"`
|
||||||
|
|
||||||
|
// Find by status
|
||||||
|
// Required: false
|
||||||
|
Status string `url:"status,omitempty" json:"status,omitempty"`
|
||||||
|
|
||||||
|
// Find by techStatus
|
||||||
|
// Required: false
|
||||||
|
TechStatus string `url:"techStatus,omitempty" json:"techStatus,omitempty"`
|
||||||
|
|
||||||
// Include deleted clusters in result
|
// Include deleted clusters in result
|
||||||
// Required: false
|
// Required: false
|
||||||
IncludeDeleted bool `url:"includedeleted,omitempty" json:"includedeleted,omitempty"`
|
IncludeDeleted bool `url:"includedeleted,omitempty" json:"includedeleted,omitempty"`
|
||||||
@@ -22,7 +54,7 @@ type ListRequest struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// List gets list all kubernetes clusters
|
// List gets list all kubernetes clusters
|
||||||
func (k K8S) List(ctx context.Context, req ListRequest) (ListK8S, error) {
|
func (k K8S) List(ctx context.Context, req ListRequest) (*ListK8S, error) {
|
||||||
|
|
||||||
url := "/cloudbroker/k8s/list"
|
url := "/cloudbroker/k8s/list"
|
||||||
|
|
||||||
@@ -38,5 +70,5 @@ func (k K8S) List(ctx context.Context, req ListRequest) (ListK8S, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return list, nil
|
return &list, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,34 @@ import (
|
|||||||
|
|
||||||
// Request struct for get list deleted kubernetes cluster
|
// Request struct for get list deleted kubernetes cluster
|
||||||
type ListDeletedRequest struct {
|
type ListDeletedRequest 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"`
|
||||||
|
|
||||||
|
// Find by IP address
|
||||||
|
// Required: false
|
||||||
|
IPAddress string `url:"ipAddress,omitempty" json:"ipAddress,omitempty"`
|
||||||
|
|
||||||
|
// Find by resource group ID
|
||||||
|
// Required: false
|
||||||
|
RGID uint64 `url:"rgId,omitempty" json:"rgId,omitempty"`
|
||||||
|
|
||||||
|
// Find by lbId
|
||||||
|
// Required: false
|
||||||
|
LBID uint64 `url:"lbId,omitempty" json:"lbId,omitempty"`
|
||||||
|
|
||||||
|
// Find by basicServiceId
|
||||||
|
// Required: false
|
||||||
|
BasicServiceID uint64 `url:"basicServiceId,omitempty" json:"basicServiceId,omitempty"`
|
||||||
|
|
||||||
|
// Find by techStatus
|
||||||
|
// Required: false
|
||||||
|
TechStatus string `url:"techStatus,omitempty" json:"techStatus,omitempty"`
|
||||||
|
|
||||||
// Page number
|
// Page number
|
||||||
// Required: false
|
// Required: false
|
||||||
Page uint64 `url:"page,omitempty" json:"page,omitempty"`
|
Page uint64 `url:"page,omitempty" json:"page,omitempty"`
|
||||||
@@ -18,7 +46,7 @@ type ListDeletedRequest struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ListDeleted gets all deleted kubernetes clusters
|
// ListDeleted gets all deleted kubernetes clusters
|
||||||
func (k K8S) ListDeleted(ctx context.Context, req ListDeletedRequest) (ListK8S, error) {
|
func (k K8S) ListDeleted(ctx context.Context, req ListDeletedRequest) (*ListK8S, error) {
|
||||||
|
|
||||||
url := "/cloudbroker/k8s/listDeleted"
|
url := "/cloudbroker/k8s/listDeleted"
|
||||||
|
|
||||||
@@ -34,5 +62,5 @@ func (k K8S) ListDeleted(ctx context.Context, req ListDeletedRequest) (ListK8S,
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return list, nil
|
return &list, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -295,4 +295,10 @@ type ServiceAccount struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// List K8S
|
// List K8S
|
||||||
type ListK8S []ItemK8S
|
type ListK8S struct {
|
||||||
|
// Data
|
||||||
|
Data []ItemK8S `json:"data"`
|
||||||
|
|
||||||
|
// Entry count
|
||||||
|
EntryCount uint64 `json:"entryCount"`
|
||||||
|
}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import (
|
|||||||
// - First argument -> prefix
|
// - First argument -> prefix
|
||||||
// - Second argument -> indent
|
// - Second argument -> indent
|
||||||
func (lkc ListK8S) Serialize(params ...string) (serialization.Serialized, error) {
|
func (lkc ListK8S) Serialize(params ...string) (serialization.Serialized, error) {
|
||||||
if len(lkc) == 0 {
|
if len(lkc.Data) == 0 {
|
||||||
return []byte{}, nil
|
return []byte{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,16 +6,16 @@ import "sort"
|
|||||||
//
|
//
|
||||||
// If inverse param is set to true, the order is reversed.
|
// If inverse param is set to true, the order is reversed.
|
||||||
func (lkc ListK8S) SortByCreatedTime(inverse bool) ListK8S {
|
func (lkc ListK8S) SortByCreatedTime(inverse bool) ListK8S {
|
||||||
if len(lkc) < 2 {
|
if len(lkc.Data) < 2 {
|
||||||
return lkc
|
return lkc
|
||||||
}
|
}
|
||||||
|
|
||||||
sort.Slice(lkc, func(i, j int) bool {
|
sort.Slice(lkc.Data, func(i, j int) bool {
|
||||||
if inverse {
|
if inverse {
|
||||||
return lkc[i].CreatedTime > lkc[j].CreatedTime
|
return lkc.Data[i].CreatedTime > lkc.Data[j].CreatedTime
|
||||||
}
|
}
|
||||||
|
|
||||||
return lkc[i].CreatedTime < lkc[j].CreatedTime
|
return lkc.Data[i].CreatedTime < lkc.Data[j].CreatedTime
|
||||||
})
|
})
|
||||||
|
|
||||||
return lkc
|
return lkc
|
||||||
@@ -25,16 +25,16 @@ func (lkc ListK8S) SortByCreatedTime(inverse bool) ListK8S {
|
|||||||
//
|
//
|
||||||
// If inverse param is set to true, the order is reversed.
|
// If inverse param is set to true, the order is reversed.
|
||||||
func (lkc ListK8S) SortByUpdatedTime(inverse bool) ListK8S {
|
func (lkc ListK8S) SortByUpdatedTime(inverse bool) ListK8S {
|
||||||
if len(lkc) < 2 {
|
if len(lkc.Data) < 2 {
|
||||||
return lkc
|
return lkc
|
||||||
}
|
}
|
||||||
|
|
||||||
sort.Slice(lkc, func(i, j int) bool {
|
sort.Slice(lkc.Data, func(i, j int) bool {
|
||||||
if inverse {
|
if inverse {
|
||||||
return lkc[i].UpdatedTime > lkc[j].UpdatedTime
|
return lkc.Data[i].UpdatedTime > lkc.Data[j].UpdatedTime
|
||||||
}
|
}
|
||||||
|
|
||||||
return lkc[i].UpdatedTime < lkc[j].UpdatedTime
|
return lkc.Data[i].UpdatedTime < lkc.Data[j].UpdatedTime
|
||||||
})
|
})
|
||||||
|
|
||||||
return lkc
|
return lkc
|
||||||
@@ -44,16 +44,16 @@ func (lkc ListK8S) SortByUpdatedTime(inverse bool) ListK8S {
|
|||||||
//
|
//
|
||||||
// If inverse param is set to true, the order is reversed.
|
// If inverse param is set to true, the order is reversed.
|
||||||
func (lkc ListK8S) SortByDeletedTime(inverse bool) ListK8S {
|
func (lkc ListK8S) SortByDeletedTime(inverse bool) ListK8S {
|
||||||
if len(lkc) < 2 {
|
if len(lkc.Data) < 2 {
|
||||||
return lkc
|
return lkc
|
||||||
}
|
}
|
||||||
|
|
||||||
sort.Slice(lkc, func(i, j int) bool {
|
sort.Slice(lkc.Data, func(i, j int) bool {
|
||||||
if inverse {
|
if inverse {
|
||||||
return lkc[i].DeletedTime > lkc[j].DeletedTime
|
return lkc.Data[i].DeletedTime > lkc.Data[j].DeletedTime
|
||||||
}
|
}
|
||||||
|
|
||||||
return lkc[i].DeletedTime < lkc[j].DeletedTime
|
return lkc.Data[i].DeletedTime < lkc.Data[j].DeletedTime
|
||||||
})
|
})
|
||||||
|
|
||||||
return lkc
|
return lkc
|
||||||
|
|||||||
@@ -8,6 +8,23 @@ import (
|
|||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type Interface struct {
|
||||||
|
// Network type
|
||||||
|
// Should be one of:
|
||||||
|
// - VINS
|
||||||
|
// - EXTNET
|
||||||
|
NetType string `url:"netType" json:"netType" validate:"required,kvmNetType"`
|
||||||
|
|
||||||
|
// Network ID for connect to,
|
||||||
|
// for EXTNET - external network ID,
|
||||||
|
// for VINS - VINS ID,
|
||||||
|
NetID uint64 `url:"netId" json:"netId" validate:"required"`
|
||||||
|
|
||||||
|
// IP address to assign to this VM when connecting to the specified network
|
||||||
|
// Required: false
|
||||||
|
IPAddr string `url:"ipAddr,omitempty" json:"ipAddr,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
// Request struct for create KVM PowerPC VM
|
// Request struct for create KVM PowerPC VM
|
||||||
type CreateRequest struct {
|
type CreateRequest struct {
|
||||||
// ID of the resource group, which will own this VM
|
// ID of the resource group, which will own this VM
|
||||||
@@ -45,24 +62,9 @@ type CreateRequest struct {
|
|||||||
// Required: false
|
// Required: false
|
||||||
Pool string `url:"pool,omitempty" json:"pool,omitempty"`
|
Pool string `url:"pool,omitempty" json:"pool,omitempty"`
|
||||||
|
|
||||||
// Network type
|
// Slice of structs with net interface description.
|
||||||
// Should be one of:
|
|
||||||
// - VINS
|
|
||||||
// - EXTNET
|
|
||||||
// - NONE
|
|
||||||
// Required: false
|
// Required: false
|
||||||
NetType string `url:"netType,omitempty" json:"netType,omitempty" validate:"omitempty,kvmNetType"`
|
Interfaces []Interface `url:"interfaces,omitempty" json:"interfaces,omitempty" validate:"omitempty,min=1,dive"`
|
||||||
|
|
||||||
// Network ID for connect to,
|
|
||||||
// for EXTNET - external network ID,
|
|
||||||
// for VINS - VINS ID,
|
|
||||||
// when network type is not "NONE"
|
|
||||||
// Required: false
|
|
||||||
NetID uint64 `url:"netId,omitempty" json:"netId,omitempty"`
|
|
||||||
|
|
||||||
// IP address to assign to this VM when connecting to the specified network
|
|
||||||
// Required: false
|
|
||||||
IPAddr string `url:"ipAddr,omitempty" json:"ipAddr,omitempty"`
|
|
||||||
|
|
||||||
// Input data for cloud-init facility
|
// Input data for cloud-init facility
|
||||||
// Required: false
|
// Required: false
|
||||||
@@ -76,10 +78,6 @@ type CreateRequest struct {
|
|||||||
// Required: false
|
// Required: false
|
||||||
Start bool `url:"start,omitempty" json:"start,omitempty"`
|
Start bool `url:"start,omitempty" json:"start,omitempty"`
|
||||||
|
|
||||||
// Stack ID
|
|
||||||
// Required: false
|
|
||||||
StackID uint64 `url:"stackId,omitempty" json:"stackId,omitempty"`
|
|
||||||
|
|
||||||
// System name
|
// System name
|
||||||
// Required: false
|
// Required: false
|
||||||
IS string `url:"IS,omitempty" json:"IS,omitempty"`
|
IS string `url:"IS,omitempty" json:"IS,omitempty"`
|
||||||
@@ -87,10 +85,6 @@ type CreateRequest struct {
|
|||||||
// Compute purpose
|
// Compute purpose
|
||||||
// Required: false
|
// Required: false
|
||||||
IPAType string `url:"ipaType,omitempty" json:"ipaType,omitempty"`
|
IPAType string `url:"ipaType,omitempty" json:"ipaType,omitempty"`
|
||||||
|
|
||||||
// Reason for action
|
|
||||||
// Required: false
|
|
||||||
Reason string `url:"reason,omitempty" json:"reason,omitempty"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create creates KVM PowerPC VM based on specified OS image
|
// Create creates KVM PowerPC VM based on specified OS image
|
||||||
|
|||||||
@@ -40,24 +40,9 @@ type CreateBlankRequest struct {
|
|||||||
// Required: true
|
// Required: true
|
||||||
Pool string `url:"pool" json:"pool" validate:"required"`
|
Pool string `url:"pool" json:"pool" validate:"required"`
|
||||||
|
|
||||||
// Network type
|
// Slice of structs with net interface description.
|
||||||
// Should be one of:
|
|
||||||
// - VINS
|
|
||||||
// - EXTNET
|
|
||||||
// - NONE
|
|
||||||
// Required: false
|
// Required: false
|
||||||
NetType string `url:"netType,omitempty" json:"netType,omitempty" validate:"omitempty,kvmNetType"`
|
Interfaces []Interface `url:"interfaces,omitempty" json:"interfaces,omitempty" validate:"omitempty,min=1,dive"`
|
||||||
|
|
||||||
// Network ID for connect to,
|
|
||||||
// for EXTNET - external network ID,
|
|
||||||
// for VINS - VINS ID,
|
|
||||||
// when network type is not "NONE"
|
|
||||||
// Required: false
|
|
||||||
NetID uint64 `url:"netId,omitempty" json:"netId,omitempty"`
|
|
||||||
|
|
||||||
// IP address to assign to this VM when connecting to the specified network
|
|
||||||
// Required: false
|
|
||||||
IPAddr string `url:"ipAddr,omitempty" json:"ipAddr,omitempty"`
|
|
||||||
|
|
||||||
// Text description of this VM
|
// Text description of this VM
|
||||||
// Required: false
|
// Required: false
|
||||||
|
|||||||
@@ -48,20 +48,9 @@ type MassCreateRequest struct {
|
|||||||
// Required: false
|
// Required: false
|
||||||
Pool string `url:"pool,omitempty" json:"pool,omitempty"`
|
Pool string `url:"pool,omitempty" json:"pool,omitempty"`
|
||||||
|
|
||||||
// Network type
|
// Slice of structs with net interface description.
|
||||||
// Should be one of:
|
|
||||||
// - VINS
|
|
||||||
// - EXTNET
|
|
||||||
// - NONE
|
|
||||||
// Required: false
|
// Required: false
|
||||||
NetType string `url:"netType,omitempty" json:"netType,omitempty" validate:"omitempty,kvmNetType"`
|
Interfaces []Interface `url:"interfaces,omitempty" json:"interfaces,omitempty" validate:"omitempty,min=1,dive"`
|
||||||
|
|
||||||
// Network ID for connect to,
|
|
||||||
// for EXTNET - external network ID,
|
|
||||||
// for VINS - VINS ID,
|
|
||||||
// when network type is not "NONE"
|
|
||||||
// Required: false
|
|
||||||
NetID uint64 `url:"netId,omitempty" json:"netId,omitempty"`
|
|
||||||
|
|
||||||
// Input data for cloud-init facility
|
// Input data for cloud-init facility
|
||||||
// Required: false
|
// Required: false
|
||||||
|
|||||||
@@ -8,6 +8,23 @@ import (
|
|||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type Interface struct {
|
||||||
|
// Network type
|
||||||
|
// Should be one of:
|
||||||
|
// - VINS
|
||||||
|
// - EXTNET
|
||||||
|
NetType string `url:"netType" json:"netType" validate:"required,kvmNetType"`
|
||||||
|
|
||||||
|
// Network ID for connect to,
|
||||||
|
// for EXTNET - external network ID,
|
||||||
|
// for VINS - VINS ID,
|
||||||
|
NetID uint64 `url:"netId" json:"netId" validate:"required"`
|
||||||
|
|
||||||
|
// IP address to assign to this VM when connecting to the specified network
|
||||||
|
// Required: false
|
||||||
|
IPAddr string `url:"ipAddr,omitempty" json:"ipAddr,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
// Request struct for create KVM x86 VM
|
// Request struct for create KVM x86 VM
|
||||||
type CreateRequest struct {
|
type CreateRequest struct {
|
||||||
// ID of the resource group, which will own this VM
|
// ID of the resource group, which will own this VM
|
||||||
@@ -45,24 +62,9 @@ type CreateRequest struct {
|
|||||||
// Required: false
|
// Required: false
|
||||||
Pool string `url:"pool,omitempty" json:"pool,omitempty"`
|
Pool string `url:"pool,omitempty" json:"pool,omitempty"`
|
||||||
|
|
||||||
// Network type
|
// Slice of structs with net interface description.
|
||||||
// Should be one of:
|
|
||||||
// - VINS
|
|
||||||
// - EXTNET
|
|
||||||
// - NONE
|
|
||||||
// Required: false
|
// Required: false
|
||||||
NetType string `url:"netType,omitempty" json:"netType,omitempty" validate:"omitempty,kvmNetType"`
|
Interfaces []Interface `url:"interfaces,omitempty" json:"interfaces,omitempty" validate:"omitempty,min=1,dive"`
|
||||||
|
|
||||||
// Network ID for connect to,
|
|
||||||
// for EXTNET - external network ID,
|
|
||||||
// for VINS - VINS ID,
|
|
||||||
// when network type is not "NONE"
|
|
||||||
// Required: false
|
|
||||||
NetID uint64 `url:"netId,omitempty" json:"netId,omitempty"`
|
|
||||||
|
|
||||||
// IP address to assign to this VM when connecting to the specified network
|
|
||||||
// Required: false
|
|
||||||
IPAddr string `url:"ipAddr,omitempty" json:"ipAddr,omitempty"`
|
|
||||||
|
|
||||||
// Input data for cloud-init facility
|
// Input data for cloud-init facility
|
||||||
// Required: false
|
// Required: false
|
||||||
@@ -88,6 +90,10 @@ type CreateRequest struct {
|
|||||||
// Required: false
|
// Required: false
|
||||||
IPAType string `url:"ipaType,omitempty" json:"ipaType,omitempty"`
|
IPAType string `url:"ipaType,omitempty" json:"ipaType,omitempty"`
|
||||||
|
|
||||||
|
// Custom fields for Compute. Must be dict
|
||||||
|
// Required: false
|
||||||
|
CustomField string `url:"customFields,omitempty" json:"customFields,omitempty"`
|
||||||
|
|
||||||
// Reason for action
|
// Reason for action
|
||||||
// Required: false
|
// Required: false
|
||||||
Reason string `url:"reason,omitempty" json:"reason,omitempty"`
|
Reason string `url:"reason,omitempty" json:"reason,omitempty"`
|
||||||
|
|||||||
@@ -40,24 +40,9 @@ type CreateBlankRequest struct {
|
|||||||
// Required: true
|
// Required: true
|
||||||
Pool string `url:"pool" json:"pool" validate:"required"`
|
Pool string `url:"pool" json:"pool" validate:"required"`
|
||||||
|
|
||||||
// Network type
|
// Slice of structs with net interface description.
|
||||||
// Should be one of:
|
|
||||||
// - VINS
|
|
||||||
// - EXTNET
|
|
||||||
// - NONE
|
|
||||||
// Required: false
|
// Required: false
|
||||||
NetType string `url:"netType,omitempty" json:"netType,omitempty" validate:"omitempty,kvmNetType"`
|
Interfaces []Interface `url:"interfaces,omitempty" json:"interfaces,omitempty" validate:"omitempty,min=1,dive"`
|
||||||
|
|
||||||
// Network ID for connect to,
|
|
||||||
// for EXTNET - external network ID,
|
|
||||||
// for VINS - VINS ID,
|
|
||||||
// when network type is not "NONE"
|
|
||||||
// Required: false
|
|
||||||
NetID uint64 `url:"netId,omitempty" json:"netId,omitempty"`
|
|
||||||
|
|
||||||
// IP address to assign to this VM when connecting to the specified network
|
|
||||||
// Required: false
|
|
||||||
IPAddr string `url:"ipAddr,omitempty" json:"ipAddr,omitempty"`
|
|
||||||
|
|
||||||
// Text description of this VM
|
// Text description of this VM
|
||||||
// Required: false
|
// Required: false
|
||||||
|
|||||||
@@ -48,24 +48,9 @@ type MassCreateRequest struct {
|
|||||||
// Required: false
|
// Required: false
|
||||||
Pool string `url:"pool,omitempty" json:"pool,omitempty"`
|
Pool string `url:"pool,omitempty" json:"pool,omitempty"`
|
||||||
|
|
||||||
// Network type
|
// Slice of structs with net interface description.
|
||||||
// Should be one of:
|
|
||||||
// - VINS
|
|
||||||
// - EXTNET
|
|
||||||
// - NONE
|
|
||||||
// Required: false
|
// Required: false
|
||||||
NetType string `url:"netType,omitempty" json:"netType,omitempty" validate:"omitempty,kvmNetType"`
|
Interfaces []Interface `url:"interfaces,omitempty" json:"interfaces,omitempty" validate:"omitempty,min=1,dive"`
|
||||||
|
|
||||||
// Network ID for connect to,
|
|
||||||
// for EXTNET - external network ID,
|
|
||||||
// for VINS - VINS ID,
|
|
||||||
// when network type is not "NONE"
|
|
||||||
// Required: false
|
|
||||||
NetID uint64 `url:"netId,omitempty" json:"netId,omitempty"`
|
|
||||||
|
|
||||||
// IP address to assign to this VM when connecting to the specified network
|
|
||||||
// Required: false
|
|
||||||
IPAddr string `url:"ipAddr,omitempty" json:"ipAddr,omitempty"`
|
|
||||||
|
|
||||||
// Input data for cloud-init facility
|
// Input data for cloud-init facility
|
||||||
// Required: false
|
// Required: false
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ type BackendCreateRequest struct {
|
|||||||
Weight uint64 `url:"weight,omitempty" json:"weight,omitempty"`
|
Weight uint64 `url:"weight,omitempty" json:"weight,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// BackendCreate creates new backend on the specified load balancer
|
// BackendCreate creates new backend on the specified load balancer
|
||||||
func (lb LB) BackendCreate(ctx context.Context, req BackendCreateRequest) (bool, error) {
|
func (lb LB) BackendCreate(ctx context.Context, req BackendCreateRequest) (bool, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -19,10 +19,6 @@ type CreateRequest struct {
|
|||||||
// Required: true
|
// Required: true
|
||||||
Name string `url:"name" json:"name" validate:"required"`
|
Name string `url:"name" json:"name" validate:"required"`
|
||||||
|
|
||||||
// OS image ID to create load balancer from
|
|
||||||
// Required: false
|
|
||||||
ImageID uint64 `url:"imageId,omitempty" json:"imageId,omitempty"`
|
|
||||||
|
|
||||||
// External network to connect this load balancer to
|
// External network to connect this load balancer to
|
||||||
// Required: true
|
// Required: true
|
||||||
ExtNetID uint64 `url:"extnetId" json:"extnetId" validate:"required"`
|
ExtNetID uint64 `url:"extnetId" json:"extnetId" validate:"required"`
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ func (ll ListLB) FilterByImageID(imageID uint64) ListLB {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// FilterByK8SID returns ListLB used by specified K8S cluster.
|
// FilterByK8SID returns ListLB used by specified K8S cluster.
|
||||||
func (ll ListLB) FilterByK8SID(ctx context.Context, k8sID uint64, decortClient interfaces.Caller) (ListLB, error) {
|
func (ll ListLB) FilterByK8SID(ctx context.Context, k8sID uint64, decortClient interfaces.Caller) (*ListLB, error) {
|
||||||
caller := k8s.New(decortClient)
|
caller := k8s.New(decortClient)
|
||||||
|
|
||||||
req := k8s.GetRequest{
|
req := k8s.GetRequest{
|
||||||
@@ -60,28 +60,32 @@ func (ll ListLB) FilterByK8SID(ctx context.Context, k8sID uint64, decortClient i
|
|||||||
return cluster.LBID == rlb.ID
|
return cluster.LBID == rlb.ID
|
||||||
}
|
}
|
||||||
|
|
||||||
return ll.FilterFunc(predicate), nil
|
res := ll.FilterFunc(predicate)
|
||||||
|
|
||||||
|
return &res, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// FilterFunc allows filtering ListLB based on a user-specified predicate.
|
// FilterFunc allows filtering ListLB based on a user-specified predicate.
|
||||||
func (ll ListLB) FilterFunc(predicate func(RecordLB) bool) ListLB {
|
func (ll ListLB) FilterFunc(predicate func(RecordLB) bool) ListLB {
|
||||||
var result ListLB
|
var result ListLB
|
||||||
|
|
||||||
for _, item := range ll {
|
for _, item := range ll.Data {
|
||||||
if predicate(item) {
|
if predicate(item) {
|
||||||
result = append(result, item)
|
result.Data = append(result.Data, item)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
result.EntryCount = uint64(len(result.Data))
|
||||||
|
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
// FindOne returns first found RecordLB
|
// FindOne returns first found RecordLB
|
||||||
// If none was found, returns an empty struct.
|
// If none was found, returns an empty struct.
|
||||||
func (ll ListLB) FindOne() RecordLB {
|
func (ll ListLB) FindOne() RecordLB {
|
||||||
if len(ll) == 0 {
|
if len(ll.Data) == 0 {
|
||||||
return RecordLB{}
|
return RecordLB{}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ll[0]
|
return ll.Data[0]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,99 +3,102 @@ package lb
|
|||||||
import "testing"
|
import "testing"
|
||||||
|
|
||||||
var lbs = ListLB{
|
var lbs = ListLB{
|
||||||
RecordLB{
|
Data: []RecordLB{
|
||||||
HAMode: true,
|
{
|
||||||
CKey: "",
|
HAMode: true,
|
||||||
Meta: []interface{}{},
|
CKey: "",
|
||||||
ACL: []interface{}{},
|
Meta: []interface{}{},
|
||||||
Backends: []ItemBackend{},
|
ACL: []interface{}{},
|
||||||
CreatedBy: "test_user_1",
|
Backends: []ItemBackend{},
|
||||||
CreatedTime: 1636667448,
|
CreatedBy: "test_user_1",
|
||||||
DeletedBy: "",
|
CreatedTime: 1636667448,
|
||||||
DeletedTime: 0,
|
DeletedBy: "",
|
||||||
Description: "",
|
DeletedTime: 0,
|
||||||
DPAPIPassword: "0000",
|
Description: "",
|
||||||
DPAPIUser: "api_user",
|
DPAPIPassword: "0000",
|
||||||
ExtNetID: 2522,
|
DPAPIUser: "api_user",
|
||||||
Frontends: []ItemFrontend{},
|
ExtNetID: 2522,
|
||||||
GID: 212,
|
Frontends: []ItemFrontend{},
|
||||||
GUID: 1,
|
GID: 212,
|
||||||
ID: 1,
|
GUID: 1,
|
||||||
ImageID: 2121,
|
ID: 1,
|
||||||
Milestones: 129000,
|
ImageID: 2121,
|
||||||
Name: "k8s-lb-test-1",
|
Milestones: 129000,
|
||||||
PrimaryNode: Node{},
|
Name: "k8s-lb-test-1",
|
||||||
RGID: 25090,
|
PrimaryNode: Node{},
|
||||||
RGName: "",
|
RGID: 25090,
|
||||||
SecondaryNode: Node{},
|
RGName: "",
|
||||||
Status: "ENABLED",
|
SecondaryNode: Node{},
|
||||||
TechStatus: "STARTED",
|
Status: "ENABLED",
|
||||||
UpdatedBy: "",
|
TechStatus: "STARTED",
|
||||||
UpdatedTime: 0,
|
UpdatedBy: "",
|
||||||
VINSID: 101,
|
UpdatedTime: 0,
|
||||||
},
|
VINSID: 101,
|
||||||
RecordLB{
|
},
|
||||||
HAMode: false,
|
{
|
||||||
CKey: "",
|
HAMode: false,
|
||||||
Meta: []interface{}{},
|
CKey: "",
|
||||||
ACL: []interface{}{},
|
Meta: []interface{}{},
|
||||||
Backends: []ItemBackend{},
|
ACL: []interface{}{},
|
||||||
CreatedBy: "test_user_2",
|
Backends: []ItemBackend{},
|
||||||
CreatedTime: 1636667506,
|
CreatedBy: "test_user_2",
|
||||||
DeletedBy: "",
|
CreatedTime: 1636667506,
|
||||||
DeletedTime: 0,
|
DeletedBy: "",
|
||||||
Description: "",
|
DeletedTime: 0,
|
||||||
DPAPIPassword: "0000",
|
Description: "",
|
||||||
DPAPIUser: "api_user_2",
|
DPAPIPassword: "0000",
|
||||||
ExtNetID: 2524,
|
DPAPIUser: "api_user_2",
|
||||||
Frontends: []ItemFrontend{},
|
ExtNetID: 2524,
|
||||||
GID: 212,
|
Frontends: []ItemFrontend{},
|
||||||
GUID: 2,
|
GID: 212,
|
||||||
ID: 2,
|
GUID: 2,
|
||||||
ImageID: 2129,
|
ID: 2,
|
||||||
Milestones: 129013,
|
ImageID: 2129,
|
||||||
Name: "k8s-lb-test-2",
|
Milestones: 129013,
|
||||||
PrimaryNode: Node{},
|
Name: "k8s-lb-test-2",
|
||||||
RGID: 25092,
|
PrimaryNode: Node{},
|
||||||
RGName: "",
|
RGID: 25092,
|
||||||
SecondaryNode: Node{},
|
RGName: "",
|
||||||
Status: "ENABLED",
|
SecondaryNode: Node{},
|
||||||
TechStatus: "STOPPED",
|
Status: "ENABLED",
|
||||||
UpdatedBy: "",
|
TechStatus: "STOPPED",
|
||||||
UpdatedTime: 0,
|
UpdatedBy: "",
|
||||||
VINSID: 102,
|
UpdatedTime: 0,
|
||||||
},
|
VINSID: 102,
|
||||||
RecordLB{
|
},
|
||||||
HAMode: true,
|
{
|
||||||
CKey: "",
|
HAMode: true,
|
||||||
Meta: []interface{}{},
|
CKey: "",
|
||||||
ACL: []interface{}{},
|
Meta: []interface{}{},
|
||||||
Backends: []ItemBackend{},
|
ACL: []interface{}{},
|
||||||
CreatedBy: "te2t_user_3",
|
Backends: []ItemBackend{},
|
||||||
CreatedTime: 1636667534,
|
CreatedBy: "te2t_user_3",
|
||||||
DeletedBy: "",
|
CreatedTime: 1636667534,
|
||||||
DeletedTime: 0,
|
DeletedBy: "",
|
||||||
Description: "",
|
DeletedTime: 0,
|
||||||
DPAPIPassword: "0000",
|
Description: "",
|
||||||
DPAPIUser: "api_user_3",
|
DPAPIPassword: "0000",
|
||||||
ExtNetID: 2536,
|
DPAPIUser: "api_user_3",
|
||||||
Frontends: []ItemFrontend{},
|
ExtNetID: 2536,
|
||||||
GID: 212,
|
Frontends: []ItemFrontend{},
|
||||||
GUID: 3,
|
GID: 212,
|
||||||
ID: 3,
|
GUID: 3,
|
||||||
ImageID: 2139,
|
ID: 3,
|
||||||
Milestones: 129025,
|
ImageID: 2139,
|
||||||
Name: "k8s-lb-test-3",
|
Milestones: 129025,
|
||||||
PrimaryNode: Node{},
|
Name: "k8s-lb-test-3",
|
||||||
RGID: 25106,
|
PrimaryNode: Node{},
|
||||||
RGName: "",
|
RGID: 25106,
|
||||||
SecondaryNode: Node{},
|
RGName: "",
|
||||||
Status: "DISABLED",
|
SecondaryNode: Node{},
|
||||||
TechStatus: "STOPPED",
|
Status: "DISABLED",
|
||||||
UpdatedBy: "",
|
TechStatus: "STOPPED",
|
||||||
UpdatedTime: 0,
|
UpdatedBy: "",
|
||||||
VINSID: 118,
|
UpdatedTime: 0,
|
||||||
|
VINSID: 118,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
EntryCount: 3,
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestFilterByID(t *testing.T) {
|
func TestFilterByID(t *testing.T) {
|
||||||
@@ -135,7 +138,7 @@ func TestFilterFunc(t *testing.T) {
|
|||||||
return rl.Status == "DISABLED"
|
return rl.Status == "DISABLED"
|
||||||
})
|
})
|
||||||
|
|
||||||
for _, item := range actual {
|
for _, item := range actual.Data {
|
||||||
if item.Status != "DISABLED" {
|
if item.Status != "DISABLED" {
|
||||||
t.Fatal("expected Status 'DISABLED', found: ", item.Status)
|
t.Fatal("expected Status 'DISABLED', found: ", item.Status)
|
||||||
}
|
}
|
||||||
@@ -145,7 +148,7 @@ func TestFilterFunc(t *testing.T) {
|
|||||||
func TestSortByCreatedTime(t *testing.T) {
|
func TestSortByCreatedTime(t *testing.T) {
|
||||||
actual := lbs.SortByCreatedTime(true)
|
actual := lbs.SortByCreatedTime(true)
|
||||||
|
|
||||||
if actual[0].CreatedTime != 1636667534 || actual[2].CreatedTime != 1636667448 {
|
if actual.Data[0].CreatedTime != 1636667534 || actual.Data[2].CreatedTime != 1636667448 {
|
||||||
t.Fatal("expected descending order, found ascending")
|
t.Fatal("expected descending order, found ascending")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,38 @@ import (
|
|||||||
|
|
||||||
// Request struct for get list of load balancers
|
// Request struct for get list of load balancers
|
||||||
type ListRequest struct {
|
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"`
|
||||||
|
|
||||||
|
// Find by account ID
|
||||||
|
// Required: false
|
||||||
|
AccountID uint64 `url:"accountID,omitempty" json:"accountID,omitempty"`
|
||||||
|
|
||||||
|
// Find by resource group ID
|
||||||
|
// 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 frontend Ip
|
||||||
|
// Required: false
|
||||||
|
FrontIP string `url:"frontIp,omitempty" json:"frontIp,omitempty"`
|
||||||
|
|
||||||
|
// Find by backend Ip
|
||||||
|
// Required: false
|
||||||
|
BackIP string `url:"backIp,omitempty" json:"backIp,omitempty"`
|
||||||
|
|
||||||
// Included deleted load balancers
|
// Included deleted load balancers
|
||||||
// Required: false
|
// Required: false
|
||||||
IncludeDeleted bool `url:"includedeleted,omitempty" json:"includedeleted,omitempty"`
|
IncludeDeleted bool `url:"includedeleted,omitempty" json:"includedeleted,omitempty"`
|
||||||
@@ -22,7 +54,7 @@ type ListRequest struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// List gets list all load balancers
|
// List gets list all load balancers
|
||||||
func (lb LB) List(ctx context.Context, req ListRequest) (ListLB, error) {
|
func (lb LB) List(ctx context.Context, req ListRequest) (*ListLB, error) {
|
||||||
url := "/cloudbroker/lb/list"
|
url := "/cloudbroker/lb/list"
|
||||||
|
|
||||||
res, err := lb.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
res, err := lb.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
@@ -37,6 +69,6 @@ func (lb LB) List(ctx context.Context, req ListRequest) (ListLB, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return list, nil
|
return &list, nil
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,34 @@ import (
|
|||||||
|
|
||||||
// Request struct for get list of deleted load balancers
|
// Request struct for get list of deleted load balancers
|
||||||
type ListDeletedRequest struct {
|
type ListDeletedRequest 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"`
|
||||||
|
|
||||||
|
// Find by account ID
|
||||||
|
// Required: false
|
||||||
|
AccountID uint64 `url:"accountID,omitempty" json:"accountID,omitempty"`
|
||||||
|
|
||||||
|
// Find by resource group ID
|
||||||
|
// 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 frontend Ip
|
||||||
|
// Required: false
|
||||||
|
FrontIP string `url:"frontIp,omitempty" json:"frontIp,omitempty"`
|
||||||
|
|
||||||
|
// Find by backend Ip
|
||||||
|
// Required: false
|
||||||
|
BackIP string `url:"backIp,omitempty" json:"backIp,omitempty"`
|
||||||
|
|
||||||
// Page number
|
// Page number
|
||||||
// Required: false
|
// Required: false
|
||||||
Page uint64 `url:"page,omitempty" json:"page,omitempty"`
|
Page uint64 `url:"page,omitempty" json:"page,omitempty"`
|
||||||
@@ -18,7 +46,7 @@ type ListDeletedRequest struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ListDeleted gets list of deleted load balancers
|
// ListDeleted gets list of deleted load balancers
|
||||||
func (lb LB) ListDeleted(ctx context.Context, req ListDeletedRequest) (ListLB, error) {
|
func (lb LB) ListDeleted(ctx context.Context, req ListDeletedRequest) (*ListLB, error) {
|
||||||
url := "/cloudbroker/lb/listDeleted"
|
url := "/cloudbroker/lb/listDeleted"
|
||||||
|
|
||||||
res, err := lb.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
res, err := lb.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
@@ -33,6 +61,6 @@ func (lb LB) ListDeleted(ctx context.Context, req ListDeletedRequest) (ListLB, e
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return list, nil
|
return &list, nil
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -134,7 +134,13 @@ type Node struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// List of load balancers
|
// List of load balancers
|
||||||
type ListLB []RecordLB
|
type ListLB struct {
|
||||||
|
// Data
|
||||||
|
Data []RecordLB `json:"data"`
|
||||||
|
|
||||||
|
// Entry count
|
||||||
|
EntryCount uint64 `json:"entryCount"`
|
||||||
|
}
|
||||||
|
|
||||||
// Detailed information about load balancer
|
// Detailed information about load balancer
|
||||||
type RecordLB struct {
|
type RecordLB struct {
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import (
|
|||||||
// - First argument -> prefix
|
// - First argument -> prefix
|
||||||
// - Second argument -> indent
|
// - Second argument -> indent
|
||||||
func (ll ListLB) Serialize(params ...string) (serialization.Serialized, error) {
|
func (ll ListLB) Serialize(params ...string) (serialization.Serialized, error) {
|
||||||
if len(ll) == 0 {
|
if len(ll.Data) == 0 {
|
||||||
return []byte{}, nil
|
return []byte{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,16 +6,16 @@ import "sort"
|
|||||||
//
|
//
|
||||||
// If inverse param is set to true, the order is reversed.
|
// If inverse param is set to true, the order is reversed.
|
||||||
func (ll ListLB) SortByCreatedTime(inverse bool) ListLB {
|
func (ll ListLB) SortByCreatedTime(inverse bool) ListLB {
|
||||||
if len(ll) < 2 {
|
if len(ll.Data) < 2 {
|
||||||
return ll
|
return ll
|
||||||
}
|
}
|
||||||
|
|
||||||
sort.Slice(ll, func(i, j int) bool {
|
sort.Slice(ll.Data, func(i, j int) bool {
|
||||||
if inverse {
|
if inverse {
|
||||||
return ll[i].CreatedTime > ll[j].CreatedTime
|
return ll.Data[i].CreatedTime > ll.Data[j].CreatedTime
|
||||||
}
|
}
|
||||||
|
|
||||||
return ll[i].CreatedTime < ll[j].CreatedTime
|
return ll.Data[i].CreatedTime < ll.Data[j].CreatedTime
|
||||||
})
|
})
|
||||||
|
|
||||||
return ll
|
return ll
|
||||||
@@ -25,16 +25,16 @@ func (ll ListLB) SortByCreatedTime(inverse bool) ListLB {
|
|||||||
//
|
//
|
||||||
// If inverse param is set to true, the order is reversed.
|
// If inverse param is set to true, the order is reversed.
|
||||||
func (ll ListLB) SortByUpdatedTime(inverse bool) ListLB {
|
func (ll ListLB) SortByUpdatedTime(inverse bool) ListLB {
|
||||||
if len(ll) < 2 {
|
if len(ll.Data) < 2 {
|
||||||
return ll
|
return ll
|
||||||
}
|
}
|
||||||
|
|
||||||
sort.Slice(ll, func(i, j int) bool {
|
sort.Slice(ll.Data, func(i, j int) bool {
|
||||||
if inverse {
|
if inverse {
|
||||||
return ll[i].UpdatedTime > ll[j].UpdatedTime
|
return ll.Data[i].UpdatedTime > ll.Data[j].UpdatedTime
|
||||||
}
|
}
|
||||||
|
|
||||||
return ll[i].UpdatedTime < ll[j].UpdatedTime
|
return ll.Data[i].UpdatedTime < ll.Data[j].UpdatedTime
|
||||||
})
|
})
|
||||||
|
|
||||||
return ll
|
return ll
|
||||||
@@ -44,16 +44,16 @@ func (ll ListLB) SortByUpdatedTime(inverse bool) ListLB {
|
|||||||
//
|
//
|
||||||
// If inverse param is set to true, the order is reversed.
|
// If inverse param is set to true, the order is reversed.
|
||||||
func (ll ListLB) SortByDeletedTime(inverse bool) ListLB {
|
func (ll ListLB) SortByDeletedTime(inverse bool) ListLB {
|
||||||
if len(ll) < 2 {
|
if len(ll.Data) < 2 {
|
||||||
return ll
|
return ll
|
||||||
}
|
}
|
||||||
|
|
||||||
sort.Slice(ll, func(i, j int) bool {
|
sort.Slice(ll.Data, func(i, j int) bool {
|
||||||
if inverse {
|
if inverse {
|
||||||
return ll[i].DeletedTime > ll[j].DeletedTime
|
return ll.Data[i].DeletedTime > ll.Data[j].DeletedTime
|
||||||
}
|
}
|
||||||
|
|
||||||
return ll[i].DeletedTime < ll[j].DeletedTime
|
return ll.Data[i].DeletedTime < ll.Data[j].DeletedTime
|
||||||
})
|
})
|
||||||
|
|
||||||
return ll
|
return ll
|
||||||
|
|||||||
@@ -6,11 +6,41 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type ListRequest struct {
|
||||||
|
// Find by id
|
||||||
|
// Required: false
|
||||||
|
ByID uint64 `url:"by_id,omitempty" json:"by_id,omitempty"`
|
||||||
|
|
||||||
|
// Find by computeId
|
||||||
|
// Required: false
|
||||||
|
ComputeID uint64 `url:"computeId,omitempty" json:"computeId,omitempty"`
|
||||||
|
|
||||||
|
// Find by name
|
||||||
|
// Required: false
|
||||||
|
Name string `url:"name,omitempty" json:"name,omitempty"`
|
||||||
|
|
||||||
|
// Find by rgId
|
||||||
|
// Required: false
|
||||||
|
RGID uint64 `url:"rgId,omitempty" json:"rgId,omitempty"`
|
||||||
|
|
||||||
|
// Find by status
|
||||||
|
// Required: false
|
||||||
|
Status string `url:"status,omitempty" json:"status,omitempty"`
|
||||||
|
|
||||||
|
// Page number
|
||||||
|
// Required: false
|
||||||
|
Page uint64 `url:"page,omitempty" json:"page,omitempty"`
|
||||||
|
|
||||||
|
// Page size
|
||||||
|
// Required: false
|
||||||
|
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
// List gets list all pci devices
|
// List gets list all pci devices
|
||||||
func (p PCIDevice) List(ctx context.Context) (ListPCIDevices, error) {
|
func (p PCIDevice) List(ctx context.Context, req ListRequest) (*ListPCIDevices, error) {
|
||||||
url := "/cloudbroker/pcidevice/list"
|
url := "/cloudbroker/pcidevice/list"
|
||||||
|
|
||||||
res, err := p.client.DecortApiCall(ctx, http.MethodPost, url, nil)
|
res, err := p.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -22,5 +52,5 @@ func (p PCIDevice) List(ctx context.Context) (ListPCIDevices, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return list, nil
|
return &list, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,4 +40,11 @@ type ItemPCIDevice struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// List PCI devices
|
// List PCI devices
|
||||||
type ListPCIDevices []ItemPCIDevice
|
type ListPCIDevices struct {
|
||||||
|
// Data
|
||||||
|
Data []ItemPCIDevice `json:"data"`
|
||||||
|
|
||||||
|
// Entry count
|
||||||
|
EntryCount uint64 `json:"entryCount"`
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import (
|
|||||||
// - First argument -> prefix
|
// - First argument -> prefix
|
||||||
// - Second argument -> indent
|
// - Second argument -> indent
|
||||||
func (l ListPCIDevices) Serialize(params ...string) (serialization.Serialized, error) {
|
func (l ListPCIDevices) Serialize(params ...string) (serialization.Serialized, error) {
|
||||||
if len(l) == 0 {
|
if len(l.Data) == 0 {
|
||||||
return []byte{}, nil
|
return []byte{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ type AffinityGroupsListRequest struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// AffinityGroupsList gets all currently defined affinity groups in this resource group with compute IDs
|
// AffinityGroupsList gets all currently defined affinity groups in this resource group with compute IDs
|
||||||
func (r RG) AffinityGroupsList(ctx context.Context, req AffinityGroupsListRequest) (map[string][]uint64, error) {
|
func (r RG) AffinityGroupsList(ctx context.Context, req AffinityGroupsListRequest) (*ListAffinityGroup, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
for _, validationError := range validators.GetErrors(err) {
|
for _, validationError := range validators.GetErrors(err) {
|
||||||
@@ -31,12 +31,12 @@ func (r RG) AffinityGroupsList(ctx context.Context, req AffinityGroupsListReques
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
list := make(map[string][]uint64)
|
list := ListAffinityGroup{}
|
||||||
|
|
||||||
err = json.Unmarshal(res, &list)
|
err = json.Unmarshal(res, &list)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return list, nil
|
return &list, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -67,21 +67,23 @@ func (lrg ListRG) FilterByDefNetID(defNetID int64) ListRG {
|
|||||||
func (lrg ListRG) FilterFunc(predicate func(ItemRG) bool) ListRG {
|
func (lrg ListRG) FilterFunc(predicate func(ItemRG) bool) ListRG {
|
||||||
var result ListRG
|
var result ListRG
|
||||||
|
|
||||||
for _, item := range lrg {
|
for _, item := range lrg.Data {
|
||||||
if predicate(item) {
|
if predicate(item) {
|
||||||
result = append(result, item)
|
result.Data = append(result.Data, item)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
result.EntryCount = uint64(len(result.Data))
|
||||||
|
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
// FindOne returns first found ItemRG.
|
// FindOne returns first found ItemRG.
|
||||||
// If none was found, returns an empty struct.
|
// If none was found, returns an empty struct.
|
||||||
func (lrg ListRG) FindOne() ItemRG {
|
func (lrg ListRG) FindOne() ItemRG {
|
||||||
if len(lrg) == 0 {
|
if len(lrg.Data) == 0 {
|
||||||
return ItemRG{}
|
return ItemRG{}
|
||||||
}
|
}
|
||||||
|
|
||||||
return lrg[0]
|
return lrg.Data[0]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,140 +3,143 @@ package rg
|
|||||||
import "testing"
|
import "testing"
|
||||||
|
|
||||||
var rgs = ListRG{
|
var rgs = ListRG{
|
||||||
{
|
Data: []ItemRG{
|
||||||
AccountID: 1,
|
{
|
||||||
AccountName: "std",
|
AccountID: 1,
|
||||||
ACL: []ACL{
|
AccountName: "std",
|
||||||
{
|
ACL: []ACL{
|
||||||
Explicit: true,
|
{
|
||||||
GUID: "",
|
Explicit: true,
|
||||||
Right: "ARCXDU",
|
GUID: "",
|
||||||
Status: "CONFIRMED",
|
Right: "ARCXDU",
|
||||||
Type: "U",
|
Status: "CONFIRMED",
|
||||||
UserGroupID: "sample_user_1@decs3o",
|
Type: "U",
|
||||||
|
UserGroupID: "sample_user_1@decs3o",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
CreatedBy: "sample_user_1@decs3o",
|
||||||
CreatedBy: "sample_user_1@decs3o",
|
CreatedTime: 1676645305,
|
||||||
CreatedTime: 1676645305,
|
DefNetID: 1,
|
||||||
DefNetID: 1,
|
DefNetType: "NONE",
|
||||||
DefNetType: "NONE",
|
DeletedBy: "",
|
||||||
DeletedBy: "",
|
DeletedTime: 0,
|
||||||
DeletedTime: 0,
|
Description: "",
|
||||||
Description: "",
|
GID: 212,
|
||||||
GID: 212,
|
GUID: 7971,
|
||||||
GUID: 7971,
|
ID: 7971,
|
||||||
ID: 7971,
|
LockStatus: "UNLOCKED",
|
||||||
LockStatus: "UNLOCKED",
|
Milestones: 363459,
|
||||||
Milestones: 363459,
|
Name: "rg_1",
|
||||||
Name: "rg_1",
|
RegisterComputes: false,
|
||||||
RegisterComputes: false,
|
ResourceLimits: ResourceLimits{
|
||||||
ResourceLimits: ResourceLimits{
|
CUC: -1,
|
||||||
CUC: -1,
|
CuD: -1,
|
||||||
CuD: -1,
|
CUI: -1,
|
||||||
CUI: -1,
|
CUM: -1,
|
||||||
CUM: -1,
|
CUNP: -1,
|
||||||
CUNP: -1,
|
GPUUnits: -1,
|
||||||
GPUUnits: -1,
|
|
||||||
},
|
|
||||||
Secret: "",
|
|
||||||
Status: "CREATED",
|
|
||||||
UpdatedBy: "",
|
|
||||||
UpdatedTime: 0,
|
|
||||||
VINS: []uint64{},
|
|
||||||
VMs: []uint64{},
|
|
||||||
ResTypes: []string{},
|
|
||||||
UniqPools: []string{},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
AccountID: 2,
|
|
||||||
AccountName: "std_2",
|
|
||||||
ACL: []ACL{
|
|
||||||
{
|
|
||||||
Explicit: true,
|
|
||||||
GUID: "",
|
|
||||||
Right: "ARCXDU",
|
|
||||||
Status: "CONFIRMED",
|
|
||||||
Type: "U",
|
|
||||||
UserGroupID: "sample_user_1@decs3o",
|
|
||||||
},
|
},
|
||||||
|
Secret: "",
|
||||||
|
Status: "CREATED",
|
||||||
|
UpdatedBy: "",
|
||||||
|
UpdatedTime: 0,
|
||||||
|
VINS: []uint64{},
|
||||||
|
VMs: []uint64{},
|
||||||
|
ResTypes: []string{},
|
||||||
|
UniqPools: []string{},
|
||||||
},
|
},
|
||||||
CreatedBy: "sample_user_1@decs3o",
|
{
|
||||||
CreatedTime: 1676645461,
|
AccountID: 2,
|
||||||
DefNetID: 2,
|
AccountName: "std_2",
|
||||||
DefNetType: "NONE",
|
ACL: []ACL{
|
||||||
DeletedBy: "",
|
{
|
||||||
DeletedTime: 0,
|
Explicit: true,
|
||||||
Description: "",
|
GUID: "",
|
||||||
GID: 212,
|
Right: "ARCXDU",
|
||||||
GUID: 7972,
|
Status: "CONFIRMED",
|
||||||
ID: 7972,
|
Type: "U",
|
||||||
LockStatus: "UNLOCKED",
|
UserGroupID: "sample_user_1@decs3o",
|
||||||
Milestones: 363468,
|
},
|
||||||
Name: "rg_2",
|
|
||||||
RegisterComputes: false,
|
|
||||||
ResourceLimits: ResourceLimits{
|
|
||||||
CUC: -1,
|
|
||||||
CuD: -1,
|
|
||||||
CUI: -1,
|
|
||||||
CUM: -1,
|
|
||||||
CUNP: -1,
|
|
||||||
GPUUnits: -1,
|
|
||||||
},
|
|
||||||
Secret: "",
|
|
||||||
Status: "CREATED",
|
|
||||||
UpdatedBy: "",
|
|
||||||
UpdatedTime: 0,
|
|
||||||
VINS: []uint64{},
|
|
||||||
VMs: []uint64{},
|
|
||||||
ResTypes: []string{},
|
|
||||||
UniqPools: []string{},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
AccountID: 3,
|
|
||||||
AccountName: "std_3",
|
|
||||||
ACL: []ACL{
|
|
||||||
{
|
|
||||||
Explicit: true,
|
|
||||||
GUID: "",
|
|
||||||
Right: "ARCXDU",
|
|
||||||
Status: "CONFIRMED",
|
|
||||||
Type: "U",
|
|
||||||
UserGroupID: "sample_user_2@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,
|
||||||
|
ResourceLimits: ResourceLimits{
|
||||||
|
CUC: -1,
|
||||||
|
CuD: -1,
|
||||||
|
CUI: -1,
|
||||||
|
CUM: -1,
|
||||||
|
CUNP: -1,
|
||||||
|
GPUUnits: -1,
|
||||||
|
},
|
||||||
|
Secret: "",
|
||||||
|
Status: "CREATED",
|
||||||
|
UpdatedBy: "",
|
||||||
|
UpdatedTime: 0,
|
||||||
|
VINS: []uint64{},
|
||||||
|
VMs: []uint64{},
|
||||||
|
ResTypes: []string{},
|
||||||
|
UniqPools: []string{},
|
||||||
},
|
},
|
||||||
CreatedBy: "sample_user_2@decs3o",
|
{
|
||||||
CreatedTime: 1676645548,
|
AccountID: 3,
|
||||||
DefNetID: 3,
|
AccountName: "std_3",
|
||||||
DefNetType: "NONE",
|
ACL: []ACL{
|
||||||
DeletedBy: "",
|
{
|
||||||
DeletedTime: 0,
|
Explicit: true,
|
||||||
Description: "",
|
GUID: "",
|
||||||
GID: 212,
|
Right: "ARCXDU",
|
||||||
GUID: 7973,
|
Status: "CONFIRMED",
|
||||||
ID: 7973,
|
Type: "U",
|
||||||
LockStatus: "kjLOCKED",
|
UserGroupID: "sample_user_2@decs3o",
|
||||||
Milestones: 363471,
|
},
|
||||||
Name: "rg_3",
|
},
|
||||||
RegisterComputes: false,
|
CreatedBy: "sample_user_2@decs3o",
|
||||||
ResourceLimits: ResourceLimits{
|
CreatedTime: 1676645548,
|
||||||
CUC: -1,
|
DefNetID: 3,
|
||||||
CuD: -1,
|
DefNetType: "NONE",
|
||||||
CUI: -1,
|
DeletedBy: "",
|
||||||
CUM: -1,
|
DeletedTime: 0,
|
||||||
CUNP: -1,
|
Description: "",
|
||||||
GPUUnits: -1,
|
GID: 212,
|
||||||
|
GUID: 7973,
|
||||||
|
ID: 7973,
|
||||||
|
LockStatus: "kjLOCKED",
|
||||||
|
Milestones: 363471,
|
||||||
|
Name: "rg_3",
|
||||||
|
RegisterComputes: false,
|
||||||
|
ResourceLimits: ResourceLimits{
|
||||||
|
CUC: -1,
|
||||||
|
CuD: -1,
|
||||||
|
CUI: -1,
|
||||||
|
CUM: -1,
|
||||||
|
CUNP: -1,
|
||||||
|
GPUUnits: -1,
|
||||||
|
},
|
||||||
|
Secret: "",
|
||||||
|
Status: "DISABLED",
|
||||||
|
UpdatedBy: "",
|
||||||
|
UpdatedTime: 0,
|
||||||
|
VINS: []uint64{},
|
||||||
|
VMs: []uint64{
|
||||||
|
48500,
|
||||||
|
},
|
||||||
|
ResTypes: []string{},
|
||||||
|
UniqPools: []string{},
|
||||||
},
|
},
|
||||||
Secret: "",
|
|
||||||
Status: "DISABLED",
|
|
||||||
UpdatedBy: "",
|
|
||||||
UpdatedTime: 0,
|
|
||||||
VINS: []uint64{},
|
|
||||||
VMs: []uint64{
|
|
||||||
48500,
|
|
||||||
},
|
|
||||||
ResTypes: []string{},
|
|
||||||
UniqPools: []string{},
|
|
||||||
},
|
},
|
||||||
|
EntryCount: 3,
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestFilterByID(t *testing.T) {
|
func TestFilterByID(t *testing.T) {
|
||||||
@@ -158,11 +161,11 @@ func TestFilterByName(t *testing.T) {
|
|||||||
func TestFilterByCreatedBy(t *testing.T) {
|
func TestFilterByCreatedBy(t *testing.T) {
|
||||||
actual := rgs.FilterByCreatedBy("sample_user_1@decs3o")
|
actual := rgs.FilterByCreatedBy("sample_user_1@decs3o")
|
||||||
|
|
||||||
if len(actual) != 2 {
|
if len(actual.Data) != 2 {
|
||||||
t.Fatal("expected 2 found, actual: ", len(actual))
|
t.Fatal("expected 2 found, actual: ", len(actual.Data))
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, item := range actual {
|
for _, item := range actual.Data {
|
||||||
if item.CreatedBy != "sample_user_1@decs3o" {
|
if item.CreatedBy != "sample_user_1@decs3o" {
|
||||||
t.Fatal("expected CreatedBy 'sample_user_1@decs3o', found: ", item.CreatedBy)
|
t.Fatal("expected CreatedBy 'sample_user_1@decs3o', found: ", item.CreatedBy)
|
||||||
}
|
}
|
||||||
@@ -172,11 +175,11 @@ func TestFilterByCreatedBy(t *testing.T) {
|
|||||||
func TestFilterByStatus(t *testing.T) {
|
func TestFilterByStatus(t *testing.T) {
|
||||||
actual := rgs.FilterByStatus("CREATED")
|
actual := rgs.FilterByStatus("CREATED")
|
||||||
|
|
||||||
if len(actual) != 2 {
|
if len(actual.Data) != 2 {
|
||||||
t.Fatal("expected 2 found, actual: ", len(actual))
|
t.Fatal("expected 2 found, actual: ", len(actual.Data))
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, item := range actual {
|
for _, item := range actual.Data {
|
||||||
if item.Status != "CREATED" {
|
if item.Status != "CREATED" {
|
||||||
t.Fatal("expected Status 'ENABLED', found: ", item.Status)
|
t.Fatal("expected Status 'ENABLED', found: ", item.Status)
|
||||||
}
|
}
|
||||||
@@ -186,11 +189,11 @@ func TestFilterByStatus(t *testing.T) {
|
|||||||
func TestFilterByLockStatus(t *testing.T) {
|
func TestFilterByLockStatus(t *testing.T) {
|
||||||
actual := rgs.FilterByLockStatus("UNLOCKED")
|
actual := rgs.FilterByLockStatus("UNLOCKED")
|
||||||
|
|
||||||
if len(actual) != 2 {
|
if len(actual.Data) != 2 {
|
||||||
t.Fatal("expected 2 found, actual: ", len(actual))
|
t.Fatal("expected 2 found, actual: ", len(actual.Data))
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, item := range actual {
|
for _, item := range actual.Data {
|
||||||
if item.LockStatus != "UNLOCKED" {
|
if item.LockStatus != "UNLOCKED" {
|
||||||
t.Fatal("expected LockStatus 'UNLOCKED', found: ", item.LockStatus)
|
t.Fatal("expected LockStatus 'UNLOCKED', found: ", item.LockStatus)
|
||||||
}
|
}
|
||||||
@@ -200,11 +203,11 @@ func TestFilterByLockStatus(t *testing.T) {
|
|||||||
func TestFilterByDefNetType(t *testing.T) {
|
func TestFilterByDefNetType(t *testing.T) {
|
||||||
actual := rgs.FilterByDefNetType("NONE")
|
actual := rgs.FilterByDefNetType("NONE")
|
||||||
|
|
||||||
if len(actual) != 3 {
|
if len(actual.Data) != 3 {
|
||||||
t.Fatal("expected 3 found, actual: ", len(actual))
|
t.Fatal("expected 3 found, actual: ", len(actual.Data))
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, item := range actual {
|
for _, item := range actual.Data {
|
||||||
if item.DefNetType != "NONE" {
|
if item.DefNetType != "NONE" {
|
||||||
t.Fatal("expected DefNetType 'NONE', found: ", item.DefNetType)
|
t.Fatal("expected DefNetType 'NONE', found: ", item.DefNetType)
|
||||||
}
|
}
|
||||||
@@ -224,11 +227,11 @@ func TestFilterFunc(t *testing.T) {
|
|||||||
return len(ir.VMs) > 0
|
return len(ir.VMs) > 0
|
||||||
})
|
})
|
||||||
|
|
||||||
if len(actual) < 1 {
|
if len(actual.Data) < 1 {
|
||||||
t.Fatal("expected 1 found, actual: ", len(actual))
|
t.Fatal("expected 1 found, actual: ", len(actual.Data))
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, item := range actual {
|
for _, item := range actual.Data {
|
||||||
if len(item.VMs) < 1 {
|
if len(item.VMs) < 1 {
|
||||||
t.Fatal("expected VMs to contain at least 1 element, found empty")
|
t.Fatal("expected VMs to contain at least 1 element, found empty")
|
||||||
}
|
}
|
||||||
@@ -238,7 +241,7 @@ func TestFilterFunc(t *testing.T) {
|
|||||||
func TestSortByCreatedTime(t *testing.T) {
|
func TestSortByCreatedTime(t *testing.T) {
|
||||||
actual := rgs.SortByCreatedTime(true)
|
actual := rgs.SortByCreatedTime(true)
|
||||||
|
|
||||||
if actual[0].CreatedTime != 1676645548 || actual[2].CreatedTime != 1676645305 {
|
if actual.Data[0].CreatedTime != 1676645548 || actual.Data[2].CreatedTime != 1676645305 {
|
||||||
t.Fatal("expected descending order, found ascending")
|
t.Fatal("expected descending order, found ascending")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
42
pkg/cloudbroker/rg/get_resource_consumption.go
Normal file
42
pkg/cloudbroker/rg/get_resource_consumption.go
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
package rg
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"encoding/json"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Request struct for get detailed information about resource consumption for ResGroup
|
||||||
|
type GetResourceConsumptionRequest struct {
|
||||||
|
// Resource group ID
|
||||||
|
// Required: true
|
||||||
|
RGID uint64 `url:"rgId" json:"rgId" validate:"required"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetResourceConsumption gets resource consumption of the resource group
|
||||||
|
func (r RG) GetResourceConsumption(ctx context.Context, req GetResourceConsumptionRequest) (*ItemResourceConsumption, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
for _, validationError := range validators.GetErrors(err) {
|
||||||
|
return nil, validators.ValidationError(validationError)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudbroker/rg/getResourceConsumption"
|
||||||
|
|
||||||
|
res, err := r.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
info := ItemResourceConsumption{}
|
||||||
|
|
||||||
|
err = json.Unmarshal(res, &info)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return &info, nil
|
||||||
|
}
|
||||||
@@ -8,6 +8,34 @@ import (
|
|||||||
|
|
||||||
// Request struct for get list of resource groups
|
// Request struct for get list of resource groups
|
||||||
type ListRequest struct {
|
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"`
|
||||||
|
|
||||||
|
// Find by account ID
|
||||||
|
// Required: false
|
||||||
|
AccountID uint64 `url:"accountId,omitempty" json:"accountId,omitempty"`
|
||||||
|
|
||||||
|
// Find by name account
|
||||||
|
// Required: false
|
||||||
|
AccountName string `url:"accountName,omitempty" json:"accountName,omitempty"`
|
||||||
|
|
||||||
|
// Find by created after time (unix timestamp)
|
||||||
|
// Required: false
|
||||||
|
CreatedAfter uint64 `url:"createdAfter,omitempty" json:"createdAfter,omitempty"`
|
||||||
|
|
||||||
|
// Find by created before time (unix timestamp)
|
||||||
|
// Required: false
|
||||||
|
CreatedBefore uint64 `url:"createdBefore,omitempty" json:"createdBefore,omitempty"`
|
||||||
|
|
||||||
|
// Find by status
|
||||||
|
// Required: false
|
||||||
|
Status string `url:"status,omitempty" json:"status,omitempty"`
|
||||||
|
|
||||||
// Included deleted resource groups
|
// Included deleted resource groups
|
||||||
// Required: false
|
// Required: false
|
||||||
IncludeDeleted bool `url:"includedeleted,omitempty" json:"includedeleted,omitempty"`
|
IncludeDeleted bool `url:"includedeleted,omitempty" json:"includedeleted,omitempty"`
|
||||||
@@ -22,7 +50,7 @@ type ListRequest struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// List gets list of all resource groups the user has access to
|
// List gets list of all resource groups the user has access to
|
||||||
func (r RG) List(ctx context.Context, req ListRequest) (ListRG, error) {
|
func (r RG) List(ctx context.Context, req ListRequest) (*ListRG, error) {
|
||||||
url := "/cloudbroker/rg/list"
|
url := "/cloudbroker/rg/list"
|
||||||
|
|
||||||
res, err := r.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
res, err := r.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
@@ -37,5 +65,5 @@ func (r RG) List(ctx context.Context, req ListRequest) (ListRG, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return list, nil
|
return &list, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,13 +14,49 @@ type ListComputesRequest struct {
|
|||||||
// Required: true
|
// Required: true
|
||||||
RGID uint64 `url:"rgId" json:"rgId" validate:"required"`
|
RGID uint64 `url:"rgId" json:"rgId" validate:"required"`
|
||||||
|
|
||||||
// Reason for action
|
// Find by compute id
|
||||||
// Required: false
|
// Required: false
|
||||||
Reason string `url:"reason,omitempty" json:"reason,omitempty"`
|
ComputeID uint64 `url:"computeId,omitempty" json:"computeId,omitempty"`
|
||||||
|
|
||||||
|
// Find by name
|
||||||
|
// Required: false
|
||||||
|
Name string `url:"name,omitempty" json:"name,omitempty"`
|
||||||
|
|
||||||
|
// ID an account
|
||||||
|
// Required: false
|
||||||
|
AccountID uint64 `url:"accountId,omitempty" json:"accountId,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 ip address
|
||||||
|
// Required: false
|
||||||
|
IPAddress string `url:"ipAddress,omitempty" json:"ipAddress,omitempty"`
|
||||||
|
|
||||||
|
// Find by external network name
|
||||||
|
// Required: false
|
||||||
|
ExtNetName string `url:"extNetName,omitempty" json:"extNetName,omitempty"`
|
||||||
|
|
||||||
|
// Find by external network id
|
||||||
|
// Required: false
|
||||||
|
ExtNetID uint64 `url:"extNetId,omitempty" json:"extNetId,omitempty"`
|
||||||
|
|
||||||
|
// Page number
|
||||||
|
// Required: false
|
||||||
|
Page uint64 `url:"page,omitempty" json:"page,omitempty"`
|
||||||
|
|
||||||
|
// Page size
|
||||||
|
// Required: false
|
||||||
|
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// ListComputes gets list of all compute instances under specified resource group, accessible by the user
|
// ListComputes gets list of all compute instances under specified resource group, accessible by the user
|
||||||
func (r RG) ListComputes(ctx context.Context, req ListComputesRequest) (ListComputes, error) {
|
func (r RG) ListComputes(ctx context.Context, req ListComputesRequest) (*ListComputes, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
for _, validationError := range validators.GetErrors(err) {
|
for _, validationError := range validators.GetErrors(err) {
|
||||||
@@ -42,5 +78,5 @@ func (r RG) ListComputes(ctx context.Context, req ListComputesRequest) (ListComp
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return list, nil
|
return &list, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,34 @@ import (
|
|||||||
|
|
||||||
// Request struct for get list deleted resource groups
|
// Request struct for get list deleted resource groups
|
||||||
type ListDeletedRequest struct {
|
type ListDeletedRequest 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"`
|
||||||
|
|
||||||
|
// Find by account ID
|
||||||
|
// Required: false
|
||||||
|
AccountID uint64 `url:"accountId,omitempty" json:"accountId,omitempty"`
|
||||||
|
|
||||||
|
// Find by name account
|
||||||
|
// Required: false
|
||||||
|
AccountName string `url:"accountName,omitempty" json:"accountName,omitempty"`
|
||||||
|
|
||||||
|
// Find by created after time (unix timestamp)
|
||||||
|
// Required: false
|
||||||
|
CreatedAfter uint64 `url:"createdAfter,omitempty" json:"createdAfter,omitempty"`
|
||||||
|
|
||||||
|
// Find by created before time (unix timestamp)
|
||||||
|
// Required: false
|
||||||
|
CreatedBefore uint64 `url:"createdBefore,omitempty" json:"createdBefore,omitempty"`
|
||||||
|
|
||||||
|
// Find by status lock
|
||||||
|
// Required: false
|
||||||
|
LockStatus string `url:"lockStatus,omitempty" json:"lockStatus,omitempty"`
|
||||||
|
|
||||||
// Page number
|
// Page number
|
||||||
// Required: false
|
// Required: false
|
||||||
Page uint64 `url:"page,omitempty" json:"page,omitempty"`
|
Page uint64 `url:"page,omitempty" json:"page,omitempty"`
|
||||||
@@ -18,7 +46,7 @@ type ListDeletedRequest struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ListDeleted gets list all deleted resource groups the user has access to
|
// ListDeleted gets list all deleted resource groups the user has access to
|
||||||
func (r RG) ListDeleted(ctx context.Context, req ListDeletedRequest) (ListRG, error) {
|
func (r RG) ListDeleted(ctx context.Context, req ListDeletedRequest) (*ListRG, error) {
|
||||||
url := "/cloudbroker/rg/listDeleted"
|
url := "/cloudbroker/rg/listDeleted"
|
||||||
|
|
||||||
res, err := r.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
res, err := r.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
@@ -33,5 +61,5 @@ func (r RG) ListDeleted(ctx context.Context, req ListDeletedRequest) (ListRG, er
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return list, nil
|
return &list, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,10 +13,46 @@ type ListLBRequest struct {
|
|||||||
// Resource group ID
|
// Resource group ID
|
||||||
// Required: true
|
// Required: true
|
||||||
RGID uint64 `url:"rgId" json:"rgId" validate:"required"`
|
RGID uint64 `url:"rgId" json:"rgId" validate:"required"`
|
||||||
|
|
||||||
|
// 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"`
|
||||||
|
|
||||||
|
// Find by account ID
|
||||||
|
// Required: false
|
||||||
|
AccountID uint64 `url:"accountID,omitempty" json:"accountID,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 frontend Ip
|
||||||
|
// Required: false
|
||||||
|
FrontIP string `url:"frontIp,omitempty" json:"frontIp,omitempty"`
|
||||||
|
|
||||||
|
// Find by backend Ip
|
||||||
|
// Required: false
|
||||||
|
BackIP string `url:"backIp,omitempty" json:"backIp,omitempty"`
|
||||||
|
|
||||||
|
// Page number
|
||||||
|
// Required: false
|
||||||
|
Page uint64 `url:"page,omitempty" json:"page,omitempty"`
|
||||||
|
|
||||||
|
// Page size
|
||||||
|
// Required: false
|
||||||
|
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// ListLB gets list all load balancers in the specified resource group, accessible by the user
|
// ListLB gets list all load balancers in the specified resource group, accessible by the user
|
||||||
func (r RG) ListLB(ctx context.Context, req ListLBRequest) (ListLB, error) {
|
func (r RG) ListLB(ctx context.Context, req ListLBRequest) (*ListLB, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
for _, validationError := range validators.GetErrors(err) {
|
for _, validationError := range validators.GetErrors(err) {
|
||||||
@@ -38,5 +74,5 @@ func (r RG) ListLB(ctx context.Context, req ListLBRequest) (ListLB, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return list, nil
|
return &list, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ type ListPFWRequest struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ListPFW gets list port forward rules for the specified resource group
|
// ListPFW gets list port forward rules for the specified resource group
|
||||||
func (r RG) ListPFW(ctx context.Context, req ListPFWRequest) (ListPFW, error) {
|
func (r RG) ListPFW(ctx context.Context, req ListPFWRequest) (*ListPFW, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
for _, validationError := range validators.GetErrors(err) {
|
for _, validationError := range validators.GetErrors(err) {
|
||||||
@@ -38,5 +38,5 @@ func (r RG) ListPFW(ctx context.Context, req ListPFWRequest) (ListPFW, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return list, nil
|
return &list, nil
|
||||||
}
|
}
|
||||||
|
|||||||
26
pkg/cloudbroker/rg/list_resource_consumption.go
Normal file
26
pkg/cloudbroker/rg/list_resource_consumption.go
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
package rg
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"encoding/json"
|
||||||
|
"net/http"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ListResourceConsumption gets resource consumptions of the resource groups
|
||||||
|
func (r RG) ListResourceConsumption(ctx context.Context) (*ListResourceConsumption, error) {
|
||||||
|
url := "/cloudbroker/rg/listResourceConsumption"
|
||||||
|
|
||||||
|
res, err := r.client.DecortApiCall(ctx, http.MethodPost, url, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
list := ListResourceConsumption{}
|
||||||
|
|
||||||
|
err = json.Unmarshal(res, &list)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return &list, nil
|
||||||
|
}
|
||||||
@@ -14,13 +14,33 @@ type ListVINSRequest struct {
|
|||||||
// Required: true
|
// Required: true
|
||||||
RGID uint64 `url:"rgId" json:"rgId" validate:"required"`
|
RGID uint64 `url:"rgId" json:"rgId" validate:"required"`
|
||||||
|
|
||||||
// Reason for action
|
// Find by name
|
||||||
// Required: false
|
// Required: false
|
||||||
Reason string `url:"reason,omitempty" json:"reason,omitempty"`
|
Name string `url:"name,omitempty" json:"name,omitempty"`
|
||||||
|
|
||||||
|
// ID an account
|
||||||
|
// Required: false
|
||||||
|
AccountID uint64 `url:"accountId,omitempty" json:"accountId,omitempty"`
|
||||||
|
|
||||||
|
// Find by ip extnet address
|
||||||
|
// Required: false
|
||||||
|
ExtIP string `url:"extIp,omitempty" json:"extIp,omitempty"`
|
||||||
|
|
||||||
|
// Find by vins id
|
||||||
|
// Required: false
|
||||||
|
VINSID uint64 `url:"vinsId,omitempty" json:"vinsId,omitempty"`
|
||||||
|
|
||||||
|
// Page number
|
||||||
|
// Required: false
|
||||||
|
Page uint64 `url:"page,omitempty" json:"page,omitempty"`
|
||||||
|
|
||||||
|
// Page size
|
||||||
|
// Required: false
|
||||||
|
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// ListVINS gets list all ViNSes under specified resource group, accessible by the user
|
// ListVINS gets list all ViNSes under specified resource group, accessible by the user
|
||||||
func (r RG) ListVINS(ctx context.Context, req ListVINSRequest) (ListVINS, error) {
|
func (r RG) ListVINS(ctx context.Context, req ListVINSRequest) (*ListVINS, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
for _, validationError := range validators.GetErrors(err) {
|
for _, validationError := range validators.GetErrors(err) {
|
||||||
@@ -42,5 +62,5 @@ func (r RG) ListVINS(ctx context.Context, req ListVINSRequest) (ListVINS, error)
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return list, nil
|
return &list, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ type Reservation struct {
|
|||||||
DiskSize float64 `json:"disksize"`
|
DiskSize float64 `json:"disksize"`
|
||||||
|
|
||||||
// Max disk size
|
// Max disk size
|
||||||
DiskSizeMax uint64 `json:"disksizemax"`
|
DiskSizeMax float64 `json:"disksizemax"`
|
||||||
|
|
||||||
// External IPs
|
// External IPs
|
||||||
ExtIPs int64 `json:"extips"`
|
ExtIPs int64 `json:"extips"`
|
||||||
@@ -54,16 +54,26 @@ type DiskUsage struct {
|
|||||||
DiskSize float64 `json:"disksize"`
|
DiskSize float64 `json:"disksize"`
|
||||||
|
|
||||||
// Disk size max
|
// Disk size max
|
||||||
DiskSizeMax uint64 `json:"disksizemax"`
|
DiskSizeMax float64 `json:"disksizemax"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Resources usage information
|
// Resources usage information
|
||||||
type Resources struct {
|
type ItemResourceConsumption struct {
|
||||||
// Current information
|
// Current information
|
||||||
Current Reservation `json:"Current"`
|
Consumed Reservation `json:"Consumed"`
|
||||||
|
|
||||||
// Reserved information
|
// Reserved information
|
||||||
Reserved Reservation `json:"Reserved"`
|
Reserved Reservation `json:"Reserved"`
|
||||||
|
|
||||||
|
RGID uint64 `json:"rgid"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ListResourceConsumption struct {
|
||||||
|
// Data
|
||||||
|
Data []ItemResourceConsumption `json:"data"`
|
||||||
|
|
||||||
|
// Entry count
|
||||||
|
EntryCount uint64 `json:"entryCount"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Access Control List
|
// Access Control List
|
||||||
@@ -98,6 +108,9 @@ type ResourceLimits struct {
|
|||||||
// CUD
|
// CUD
|
||||||
CuD float64 `json:"CU_D"`
|
CuD float64 `json:"CU_D"`
|
||||||
|
|
||||||
|
// CUDM
|
||||||
|
CUDM float64 `json:"CU_DM"`
|
||||||
|
|
||||||
// CUI
|
// CUI
|
||||||
CUI float64 `json:"CU_I"`
|
CUI float64 `json:"CU_I"`
|
||||||
|
|
||||||
@@ -113,9 +126,6 @@ type ResourceLimits struct {
|
|||||||
|
|
||||||
// Detailed information about resource group
|
// Detailed information about resource group
|
||||||
type RecordRG struct {
|
type RecordRG struct {
|
||||||
// Resource information
|
|
||||||
Resources Resources `json:"Resources"`
|
|
||||||
|
|
||||||
// Main information about resource group
|
// Main information about resource group
|
||||||
ItemRG
|
ItemRG
|
||||||
}
|
}
|
||||||
@@ -158,6 +168,9 @@ type ItemRG struct {
|
|||||||
// Description
|
// Description
|
||||||
Description string `json:"desc"`
|
Description string `json:"desc"`
|
||||||
|
|
||||||
|
// Dirty
|
||||||
|
Dirty bool `json:"dirty"`
|
||||||
|
|
||||||
// Grid ID
|
// Grid ID
|
||||||
GID uint64 `json:"gid"`
|
GID uint64 `json:"gid"`
|
||||||
|
|
||||||
@@ -208,7 +221,13 @@ type ItemRG struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// List resource groups
|
// List resource groups
|
||||||
type ListRG []ItemRG
|
type ListRG struct {
|
||||||
|
// Data
|
||||||
|
Data []ItemRG `json:"data"`
|
||||||
|
|
||||||
|
// Entry count
|
||||||
|
EntryCount uint64 `json:"entryCount"`
|
||||||
|
}
|
||||||
|
|
||||||
// Main information about affinity group
|
// Main information about affinity group
|
||||||
type ItemAffinityGroupCompute struct {
|
type ItemAffinityGroupCompute struct {
|
||||||
@@ -337,7 +356,13 @@ type ItemCompute struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// List computes
|
// List computes
|
||||||
type ListComputes []ItemCompute
|
type ListComputes struct {
|
||||||
|
// Data
|
||||||
|
Data []ItemCompute `json:"data"`
|
||||||
|
|
||||||
|
// Entry count
|
||||||
|
EntryCount uint64 `json:"entryCount"`
|
||||||
|
}
|
||||||
|
|
||||||
// Main information about VINS
|
// Main information about VINS
|
||||||
type ItemVINS struct {
|
type ItemVINS struct {
|
||||||
@@ -394,7 +419,13 @@ type ItemVINS struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// List VINSes
|
// List VINSes
|
||||||
type ListVINS []ItemVINS
|
type ListVINS struct {
|
||||||
|
// Data
|
||||||
|
Data []ItemVINS `json:"data"`
|
||||||
|
|
||||||
|
// Entry count
|
||||||
|
EntryCount uint64 `json:"entryCount"`
|
||||||
|
}
|
||||||
|
|
||||||
// Main information about port forward
|
// Main information about port forward
|
||||||
type ItemPFW struct {
|
type ItemPFW struct {
|
||||||
@@ -424,7 +455,13 @@ type ItemPFW struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// List PFWs
|
// List PFWs
|
||||||
type ListPFW []ItemPFW
|
type ListPFW struct {
|
||||||
|
// Data
|
||||||
|
Data []ItemPFW `json:"data"`
|
||||||
|
|
||||||
|
// Entry count
|
||||||
|
EntryCount uint64 `json:"entryCount"`
|
||||||
|
}
|
||||||
|
|
||||||
// Server settings
|
// Server settings
|
||||||
type ServerSettings struct {
|
type ServerSettings struct {
|
||||||
@@ -640,4 +677,18 @@ type ItemLB struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// List load balancers
|
// List load balancers
|
||||||
type ListLB []ItemLB
|
type ListLB struct {
|
||||||
|
// Data
|
||||||
|
Data []ItemLB `json:"data"`
|
||||||
|
|
||||||
|
// Entry count
|
||||||
|
EntryCount uint64 `json:"entryCount"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ListAffinityGroup struct {
|
||||||
|
// Data
|
||||||
|
Data map[string][]uint64 `json:"data"`
|
||||||
|
|
||||||
|
// Entry count
|
||||||
|
EntryCount uint64 `json:"entryCount"`
|
||||||
|
}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import (
|
|||||||
// - First argument -> prefix
|
// - First argument -> prefix
|
||||||
// - Second argument -> indent
|
// - Second argument -> indent
|
||||||
func (lrg ListRG) Serialize(params ...string) (serialization.Serialized, error) {
|
func (lrg ListRG) Serialize(params ...string) (serialization.Serialized, error) {
|
||||||
if len(lrg) == 0 {
|
if len(lrg.Data) == 0 {
|
||||||
return []byte{}, nil
|
return []byte{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,16 +6,16 @@ import "sort"
|
|||||||
//
|
//
|
||||||
// If inverse param is set to true, the order is reversed.
|
// If inverse param is set to true, the order is reversed.
|
||||||
func (lrg ListRG) SortByCreatedTime(inverse bool) ListRG {
|
func (lrg ListRG) SortByCreatedTime(inverse bool) ListRG {
|
||||||
if len(lrg) < 2 {
|
if len(lrg.Data) < 2 {
|
||||||
return lrg
|
return lrg
|
||||||
}
|
}
|
||||||
|
|
||||||
sort.Slice(lrg, func(i, j int) bool {
|
sort.Slice(lrg.Data, func(i, j int) bool {
|
||||||
if inverse {
|
if inverse {
|
||||||
return lrg[i].CreatedTime > lrg[j].CreatedTime
|
return lrg.Data[i].CreatedTime > lrg.Data[j].CreatedTime
|
||||||
}
|
}
|
||||||
|
|
||||||
return lrg[i].CreatedTime < lrg[j].CreatedTime
|
return lrg.Data[i].CreatedTime < lrg.Data[j].CreatedTime
|
||||||
})
|
})
|
||||||
|
|
||||||
return lrg
|
return lrg
|
||||||
@@ -25,16 +25,16 @@ func (lrg ListRG) SortByCreatedTime(inverse bool) ListRG {
|
|||||||
//
|
//
|
||||||
// If inverse param is set to true, the order is reversed.
|
// If inverse param is set to true, the order is reversed.
|
||||||
func (lrg ListRG) SortByUpdatedTime(inverse bool) ListRG {
|
func (lrg ListRG) SortByUpdatedTime(inverse bool) ListRG {
|
||||||
if len(lrg) < 2 {
|
if len(lrg.Data) < 2 {
|
||||||
return lrg
|
return lrg
|
||||||
}
|
}
|
||||||
|
|
||||||
sort.Slice(lrg, func(i, j int) bool {
|
sort.Slice(lrg.Data, func(i, j int) bool {
|
||||||
if inverse {
|
if inverse {
|
||||||
return lrg[i].UpdatedTime > lrg[j].UpdatedTime
|
return lrg.Data[i].UpdatedTime > lrg.Data[j].UpdatedTime
|
||||||
}
|
}
|
||||||
|
|
||||||
return lrg[i].UpdatedTime < lrg[j].UpdatedTime
|
return lrg.Data[i].UpdatedTime < lrg.Data[j].UpdatedTime
|
||||||
})
|
})
|
||||||
|
|
||||||
return lrg
|
return lrg
|
||||||
@@ -44,16 +44,16 @@ func (lrg ListRG) SortByUpdatedTime(inverse bool) ListRG {
|
|||||||
//
|
//
|
||||||
// If inverse param is set to true, the order is reversed.
|
// If inverse param is set to true, the order is reversed.
|
||||||
func (lrg ListRG) SortByDeletedTime(inverse bool) ListRG {
|
func (lrg ListRG) SortByDeletedTime(inverse bool) ListRG {
|
||||||
if len(lrg) < 2 {
|
if len(lrg.Data) < 2 {
|
||||||
return lrg
|
return lrg
|
||||||
}
|
}
|
||||||
|
|
||||||
sort.Slice(lrg, func(i, j int) bool {
|
sort.Slice(lrg.Data, func(i, j int) bool {
|
||||||
if inverse {
|
if inverse {
|
||||||
return lrg[i].DeletedTime > lrg[j].DeletedTime
|
return lrg.Data[i].DeletedTime > lrg.Data[j].DeletedTime
|
||||||
}
|
}
|
||||||
|
|
||||||
return lrg[i].DeletedTime < lrg[j].DeletedTime
|
return lrg.Data[i].DeletedTime < lrg.Data[j].DeletedTime
|
||||||
})
|
})
|
||||||
|
|
||||||
return lrg
|
return lrg
|
||||||
|
|||||||
@@ -49,21 +49,23 @@ func (lsep ListSEP) FilterByType(sepType string) ListSEP {
|
|||||||
func (lsep ListSEP) FilterFunc(predicate func(RecordSEP) bool) ListSEP {
|
func (lsep ListSEP) FilterFunc(predicate func(RecordSEP) bool) ListSEP {
|
||||||
var result ListSEP
|
var result ListSEP
|
||||||
|
|
||||||
for _, item := range lsep {
|
for _, item := range lsep.Data {
|
||||||
if predicate(item) {
|
if predicate(item) {
|
||||||
result = append(result, item)
|
result.Data = append(result.Data, item)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
result.EntryCount = uint64(len(result.Data))
|
||||||
|
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
// FindOne returns first found RecordSEP
|
// FindOne returns first found RecordSEP
|
||||||
// If none was found, returns an empty struct.
|
// If none was found, returns an empty struct.
|
||||||
func (lsep ListSEP) FindOne() RecordSEP {
|
func (lsep ListSEP) FindOne() RecordSEP {
|
||||||
if len(lsep) == 0 {
|
if len(lsep.Data) == 0 {
|
||||||
return RecordSEP{}
|
return RecordSEP{}
|
||||||
}
|
}
|
||||||
|
|
||||||
return lsep[0]
|
return lsep.Data[0]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,110 +3,113 @@ package sep
|
|||||||
import "testing"
|
import "testing"
|
||||||
|
|
||||||
var seps = ListSEP{
|
var seps = ListSEP{
|
||||||
{
|
Data: []RecordSEP{
|
||||||
CKey: "",
|
{
|
||||||
Meta: []interface{}{
|
CKey: "",
|
||||||
"osismodel",
|
Meta: []interface{}{
|
||||||
"cloudbroker",
|
"osismodel",
|
||||||
"sep",
|
"cloudbroker",
|
||||||
1,
|
"sep",
|
||||||
},
|
1,
|
||||||
Config: map[string]interface{}{
|
|
||||||
"API_IPs": []string{
|
|
||||||
"10.212.3.61",
|
|
||||||
"10.212.3.62",
|
|
||||||
"10.212.3.63",
|
|
||||||
},
|
},
|
||||||
},
|
Config: map[string]interface{}{
|
||||||
ConsumedBy: []uint64{
|
"API_IPs": []string{
|
||||||
27,
|
"10.212.3.61",
|
||||||
},
|
"10.212.3.62",
|
||||||
Description: "",
|
"10.212.3.63",
|
||||||
GID: 212,
|
},
|
||||||
GUID: 1,
|
|
||||||
ID: 1,
|
|
||||||
Milestones: 278329,
|
|
||||||
Name: "sep_1",
|
|
||||||
ObjStatus: "CREATED",
|
|
||||||
ProvidedBy: []uint64{
|
|
||||||
24,
|
|
||||||
35,
|
|
||||||
29,
|
|
||||||
},
|
|
||||||
SharedWith: []uint64{},
|
|
||||||
TechStatus: "ENABLED",
|
|
||||||
Type: "DES",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
CKey: "",
|
|
||||||
Meta: []interface{}{
|
|
||||||
"osismodel",
|
|
||||||
"cloudbroker",
|
|
||||||
"sep",
|
|
||||||
1,
|
|
||||||
},
|
|
||||||
Config: map[string]interface{}{
|
|
||||||
"API_IPs": []string{
|
|
||||||
"10.212.3.64",
|
|
||||||
"10.212.3.65",
|
|
||||||
"10.212.3.66",
|
|
||||||
},
|
},
|
||||||
},
|
ConsumedBy: []uint64{
|
||||||
ConsumedBy: []uint64{
|
27,
|
||||||
32,
|
|
||||||
26,
|
|
||||||
},
|
|
||||||
Description: "",
|
|
||||||
GID: 212,
|
|
||||||
GUID: 2,
|
|
||||||
ID: 2,
|
|
||||||
Milestones: 278337,
|
|
||||||
Name: "sep_2",
|
|
||||||
ObjStatus: "CREATED",
|
|
||||||
ProvidedBy: []uint64{
|
|
||||||
36,
|
|
||||||
42,
|
|
||||||
35,
|
|
||||||
},
|
|
||||||
SharedWith: []uint64{},
|
|
||||||
TechStatus: "ENABLED",
|
|
||||||
Type: "DES",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
CKey: "",
|
|
||||||
Meta: []interface{}{
|
|
||||||
"osismodel",
|
|
||||||
"cloudbroker",
|
|
||||||
"sep",
|
|
||||||
1,
|
|
||||||
},
|
|
||||||
Config: map[string]interface{}{
|
|
||||||
"API_IPs": []string{
|
|
||||||
"10.212.3.67",
|
|
||||||
"10.212.3.68",
|
|
||||||
"10.212.3.69",
|
|
||||||
},
|
},
|
||||||
|
Description: "",
|
||||||
|
GID: 212,
|
||||||
|
GUID: 1,
|
||||||
|
ID: 1,
|
||||||
|
Milestones: 278329,
|
||||||
|
Name: "sep_1",
|
||||||
|
ObjStatus: "CREATED",
|
||||||
|
ProvidedBy: []uint64{
|
||||||
|
24,
|
||||||
|
35,
|
||||||
|
29,
|
||||||
|
},
|
||||||
|
SharedWith: []uint64{},
|
||||||
|
TechStatus: "ENABLED",
|
||||||
|
Type: "DES",
|
||||||
},
|
},
|
||||||
ConsumedBy: []uint64{
|
{
|
||||||
38,
|
CKey: "",
|
||||||
28,
|
Meta: []interface{}{
|
||||||
|
"osismodel",
|
||||||
|
"cloudbroker",
|
||||||
|
"sep",
|
||||||
|
1,
|
||||||
|
},
|
||||||
|
Config: map[string]interface{}{
|
||||||
|
"API_IPs": []string{
|
||||||
|
"10.212.3.64",
|
||||||
|
"10.212.3.65",
|
||||||
|
"10.212.3.66",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
ConsumedBy: []uint64{
|
||||||
|
32,
|
||||||
|
26,
|
||||||
|
},
|
||||||
|
Description: "",
|
||||||
|
GID: 212,
|
||||||
|
GUID: 2,
|
||||||
|
ID: 2,
|
||||||
|
Milestones: 278337,
|
||||||
|
Name: "sep_2",
|
||||||
|
ObjStatus: "CREATED",
|
||||||
|
ProvidedBy: []uint64{
|
||||||
|
36,
|
||||||
|
42,
|
||||||
|
35,
|
||||||
|
},
|
||||||
|
SharedWith: []uint64{},
|
||||||
|
TechStatus: "ENABLED",
|
||||||
|
Type: "DES",
|
||||||
},
|
},
|
||||||
Description: "",
|
{
|
||||||
GID: 212,
|
CKey: "",
|
||||||
GUID: 3,
|
Meta: []interface{}{
|
||||||
ID: 3,
|
"osismodel",
|
||||||
Milestones: 278345,
|
"cloudbroker",
|
||||||
Name: "sep_3",
|
"sep",
|
||||||
ObjStatus: "DESTROYED",
|
1,
|
||||||
ProvidedBy: []uint64{
|
},
|
||||||
49,
|
Config: map[string]interface{}{
|
||||||
48,
|
"API_IPs": []string{
|
||||||
41,
|
"10.212.3.67",
|
||||||
|
"10.212.3.68",
|
||||||
|
"10.212.3.69",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
ConsumedBy: []uint64{
|
||||||
|
38,
|
||||||
|
28,
|
||||||
|
},
|
||||||
|
Description: "",
|
||||||
|
GID: 212,
|
||||||
|
GUID: 3,
|
||||||
|
ID: 3,
|
||||||
|
Milestones: 278345,
|
||||||
|
Name: "sep_3",
|
||||||
|
ObjStatus: "DESTROYED",
|
||||||
|
ProvidedBy: []uint64{
|
||||||
|
49,
|
||||||
|
48,
|
||||||
|
41,
|
||||||
|
},
|
||||||
|
SharedWith: []uint64{},
|
||||||
|
TechStatus: "DISABLED",
|
||||||
|
Type: "DES",
|
||||||
},
|
},
|
||||||
SharedWith: []uint64{},
|
|
||||||
TechStatus: "DISABLED",
|
|
||||||
Type: "DES",
|
|
||||||
},
|
},
|
||||||
|
EntryCount: 3,
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestFilterByID(t *testing.T) {
|
func TestFilterByID(t *testing.T) {
|
||||||
@@ -128,11 +131,11 @@ func TestFilterByName(t *testing.T) {
|
|||||||
func TestFilterByObjStatus(t *testing.T) {
|
func TestFilterByObjStatus(t *testing.T) {
|
||||||
actual := seps.FilterByObjStatus("CREATED")
|
actual := seps.FilterByObjStatus("CREATED")
|
||||||
|
|
||||||
if len(actual) != 2 {
|
if len(actual.Data) != 2 {
|
||||||
t.Fatal("expected 2 found, actual: ", len(actual))
|
t.Fatal("expected 2 found, actual: ", len(actual.Data))
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, item := range actual {
|
for _, item := range actual.Data {
|
||||||
if item.ObjStatus != "CREATED" {
|
if item.ObjStatus != "CREATED" {
|
||||||
t.Fatal("expected ObjStatus 'CREATED', found: ", item.ObjStatus)
|
t.Fatal("expected ObjStatus 'CREATED', found: ", item.ObjStatus)
|
||||||
}
|
}
|
||||||
@@ -142,11 +145,11 @@ func TestFilterByObjStatus(t *testing.T) {
|
|||||||
func TestFilterByTechStatus(t *testing.T) {
|
func TestFilterByTechStatus(t *testing.T) {
|
||||||
actual := seps.FilterByTechStatus("ENABLED")
|
actual := seps.FilterByTechStatus("ENABLED")
|
||||||
|
|
||||||
if len(actual) != 2 {
|
if len(actual.Data) != 2 {
|
||||||
t.Fatal("expected 2 found, actual: ", len(actual))
|
t.Fatal("expected 2 found, actual: ", len(actual.Data))
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, item := range actual {
|
for _, item := range actual.Data {
|
||||||
if item.TechStatus != "ENABLED" {
|
if item.TechStatus != "ENABLED" {
|
||||||
t.Fatal("expected TechStatus 'ENABLED', found: ", item.TechStatus)
|
t.Fatal("expected TechStatus 'ENABLED', found: ", item.TechStatus)
|
||||||
}
|
}
|
||||||
@@ -156,11 +159,11 @@ func TestFilterByTechStatus(t *testing.T) {
|
|||||||
func TestFilterByType(t *testing.T) {
|
func TestFilterByType(t *testing.T) {
|
||||||
actual := seps.FilterByType("DES")
|
actual := seps.FilterByType("DES")
|
||||||
|
|
||||||
if len(actual) != 3 {
|
if len(actual.Data) != 3 {
|
||||||
t.Fatal("expected 3 found, actual: ", len(actual))
|
t.Fatal("expected 3 found, actual: ", len(actual.Data))
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, item := range actual {
|
for _, item := range actual.Data {
|
||||||
if item.Type != "DES" {
|
if item.Type != "DES" {
|
||||||
t.Fatal("expected Type 'DES', found: ", item.Type)
|
t.Fatal("expected Type 'DES', found: ", item.Type)
|
||||||
}
|
}
|
||||||
@@ -172,11 +175,11 @@ func TestFilterFunc(t *testing.T) {
|
|||||||
return len(rs.ConsumedBy) > 1
|
return len(rs.ConsumedBy) > 1
|
||||||
})
|
})
|
||||||
|
|
||||||
if len(actual) != 2 {
|
if len(actual.Data) != 2 {
|
||||||
t.Fatal("expected 2 found, actual: ", len(actual))
|
t.Fatal("expected 2 found, actual: ", len(actual.Data))
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, item := range actual {
|
for _, item := range actual.Data {
|
||||||
if len(item.ConsumedBy) <= 1 {
|
if len(item.ConsumedBy) <= 1 {
|
||||||
t.Fatal("expected ConsumedBy to contain more than 1 element, found: ", len(item.ConsumedBy))
|
t.Fatal("expected ConsumedBy to contain more than 1 element, found: ", len(item.ConsumedBy))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,34 @@ import (
|
|||||||
|
|
||||||
// Request struct for get list of SEPs
|
// Request struct for get list of SEPs
|
||||||
type ListRequest struct {
|
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"`
|
||||||
|
|
||||||
|
// Find by gId
|
||||||
|
// Required: false
|
||||||
|
GID uint64 `url:"gId,omitempty" json:"gId,omitempty"`
|
||||||
|
|
||||||
|
// Find by sep type
|
||||||
|
// Required: false
|
||||||
|
Type string `url:"type,omitempty" json:"type,omitempty"`
|
||||||
|
|
||||||
|
// Find by provided physical node id
|
||||||
|
// Required: false
|
||||||
|
ProvidedBy uint64 `url:"providedBy,omitempty" json:"providedBy,omitempty"`
|
||||||
|
|
||||||
|
// Find by techStatus
|
||||||
|
// Required: false
|
||||||
|
TechStatus string `url:"techStatus,omitempty" json:"techStatus,omitempty"`
|
||||||
|
|
||||||
|
// Find by consumed physical node id
|
||||||
|
// Required: false
|
||||||
|
ConsumedBy uint64 `url:"consumedBy,omitempty" json:"consumedBy,omitempty"`
|
||||||
|
|
||||||
// Page size
|
// Page size
|
||||||
// Required: false
|
// Required: false
|
||||||
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
||||||
@@ -18,7 +46,7 @@ type ListRequest struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// List gets list of SEPs
|
// List gets list of SEPs
|
||||||
func (s SEP) List(ctx context.Context, req ListRequest) (ListSEP, error) {
|
func (s SEP) List(ctx context.Context, req ListRequest) (*ListSEP, error) {
|
||||||
url := "/cloudbroker/sep/list"
|
url := "/cloudbroker/sep/list"
|
||||||
|
|
||||||
res, err := s.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
res, err := s.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
@@ -33,5 +61,5 @@ func (s SEP) List(ctx context.Context, req ListRequest) (ListSEP, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return list, nil
|
return &list, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -124,4 +124,10 @@ type RecordSEP struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// List SEPs
|
// List SEPs
|
||||||
type ListSEP []RecordSEP
|
type ListSEP struct {
|
||||||
|
// Data
|
||||||
|
Data []RecordSEP `json:"data"`
|
||||||
|
|
||||||
|
// Entry count
|
||||||
|
EntryCount uint64 `json:"entryCount"`
|
||||||
|
}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import (
|
|||||||
// - First argument -> prefix
|
// - First argument -> prefix
|
||||||
// - Second argument -> indent
|
// - Second argument -> indent
|
||||||
func (lsep ListSEP) Serialize(params ...string) (serialization.Serialized, error) {
|
func (lsep ListSEP) Serialize(params ...string) (serialization.Serialized, error) {
|
||||||
if len(lsep) == 0 {
|
if len(lsep.Data) == 0 {
|
||||||
return []byte{}, nil
|
return []byte{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ type ListRequest struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// List gets list user API task with status PROCESSING
|
// List gets list user API task with status PROCESSING
|
||||||
func (t Tasks) List(ctx context.Context, req ListRequest) (ListTasks, error) {
|
func (t Tasks) List(ctx context.Context, req ListRequest) (*ListTasks, error) {
|
||||||
url := "/cloudbroker/tasks/list"
|
url := "/cloudbroker/tasks/list"
|
||||||
|
|
||||||
res, err := t.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
res, err := t.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
@@ -33,5 +33,5 @@ func (t Tasks) List(ctx context.Context, req ListRequest) (ListTasks, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return item, nil
|
return &item, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,6 +45,13 @@ func (r *InfoResult) UnmarshalJSON(b []byte) error {
|
|||||||
|
|
||||||
// Detailed information about task
|
// Detailed information about task
|
||||||
type RecordTask struct {
|
type RecordTask struct {
|
||||||
|
// Updated by
|
||||||
|
UpdatedBy string `json:"updatedBy"`
|
||||||
|
|
||||||
|
ItemTask
|
||||||
|
}
|
||||||
|
|
||||||
|
type ItemTask struct {
|
||||||
// Audit ID
|
// Audit ID
|
||||||
AuditID string `json:"auditId"`
|
AuditID string `json:"auditId"`
|
||||||
|
|
||||||
@@ -74,4 +81,10 @@ type RecordTask struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// List of tasks
|
// List of tasks
|
||||||
type ListTasks []RecordTask
|
type ListTasks struct {
|
||||||
|
// Data
|
||||||
|
Data []ItemTask `json:"data"`
|
||||||
|
|
||||||
|
// Entry count
|
||||||
|
EntryCount uint64 `json:"entryCount"`
|
||||||
|
}
|
||||||
|
|||||||
@@ -8,6 +8,38 @@ import (
|
|||||||
|
|
||||||
// Request struct for getting list of VGPU
|
// Request struct for getting list of VGPU
|
||||||
type ListRequest struct {
|
type ListRequest struct {
|
||||||
|
// Find by id
|
||||||
|
// Required: false
|
||||||
|
ByID uint64 `url:"by_id,omitempty" json:"by_id,omitempty"`
|
||||||
|
|
||||||
|
// Find by vgpu status
|
||||||
|
// Required: false
|
||||||
|
Status string `url:"status,omitempty" json:"status,omitempty"`
|
||||||
|
|
||||||
|
// Find by vgpu type
|
||||||
|
// Required: false
|
||||||
|
Type string `url:"type,omitempty" json:"type,omitempty"`
|
||||||
|
|
||||||
|
// Find by vgpu mode
|
||||||
|
// Required: false
|
||||||
|
Mode string `url:"mode,omitempty" json:"mode,omitempty"`
|
||||||
|
|
||||||
|
// Find by id resgroup
|
||||||
|
// Required: false
|
||||||
|
RGID uint64 `url:"rgId,omitempty" json:"rgId,omitempty"`
|
||||||
|
|
||||||
|
// Find by account id
|
||||||
|
// Required: false
|
||||||
|
AccountID uint64 `url:"accountId,omitempty" json:"accountId,omitempty"`
|
||||||
|
|
||||||
|
// Find by compute id
|
||||||
|
// Required: false
|
||||||
|
ComputeID uint64 `url:"computeId,omitempty" json:"computeId,omitempty"`
|
||||||
|
|
||||||
|
// Find by pgpu id
|
||||||
|
// Required: false
|
||||||
|
PGPUID uint64 `url:"pgpuId,omitempty" json:"pgpuId,omitempty"`
|
||||||
|
|
||||||
// Page number
|
// Page number
|
||||||
// Required: false
|
// Required: false
|
||||||
Page uint64 `url:"page,omitempty" json:"page,omitempty"`
|
Page uint64 `url:"page,omitempty" json:"page,omitempty"`
|
||||||
@@ -18,7 +50,7 @@ type ListRequest struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// List gets list all VGPU
|
// List gets list all VGPU
|
||||||
func (v VGPU) List(ctx context.Context, req ListRequest) (ListVGPU, error) {
|
func (v VGPU) List(ctx context.Context, req ListRequest) (*ListVGPU, error) {
|
||||||
url := "/cloudbroker/vgpu/list"
|
url := "/cloudbroker/vgpu/list"
|
||||||
|
|
||||||
res, err := v.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
res, err := v.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
@@ -33,5 +65,5 @@ func (v VGPU) List(ctx context.Context, req ListRequest) (ListVGPU, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return list, nil
|
return &list, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -63,4 +63,10 @@ type ItemVGPU struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// List of VGPU
|
// List of VGPU
|
||||||
type ListVGPU []ItemVGPU
|
type ListVGPU struct {
|
||||||
|
// Data
|
||||||
|
Data []ItemVGPU `json:"data"`
|
||||||
|
|
||||||
|
// Entry count
|
||||||
|
EntryCount uint64 `json:"entryCount"`
|
||||||
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package vgpu
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/serialization"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/serialization"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -11,7 +12,7 @@ import (
|
|||||||
// - First argument -> prefix
|
// - First argument -> prefix
|
||||||
// - Second argument -> indent
|
// - Second argument -> indent
|
||||||
func (l ListVGPU) Serialize(params ...string) (serialization.Serialized, error) {
|
func (l ListVGPU) Serialize(params ...string) (serialization.Serialized, error) {
|
||||||
if len(l) == 0 {
|
if len(l.Data) == 0 {
|
||||||
return []byte{}, nil
|
return []byte{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,8 +15,8 @@ type ExtNetConnectRequest struct {
|
|||||||
VINSID uint64 `url:"vinsId" json:"vinsId" validate:"required"`
|
VINSID uint64 `url:"vinsId" json:"vinsId" validate:"required"`
|
||||||
|
|
||||||
// External network ID
|
// External network ID
|
||||||
// Required: true
|
// Required: false
|
||||||
NetID uint64 `url:"netId" json:"netId" validate:"required"`
|
NetID uint64 `url:"netId,omitempty" json:"netId,omitempty"`
|
||||||
|
|
||||||
// Directly set IP address
|
// Directly set IP address
|
||||||
// Required: false
|
// Required: false
|
||||||
|
|||||||
@@ -13,14 +13,10 @@ type ExtNetListRequest struct {
|
|||||||
// VINS ID
|
// VINS ID
|
||||||
// Required: true
|
// Required: true
|
||||||
VINSID uint64 `url:"vinsId" json:"vinsId" validate:"required"`
|
VINSID uint64 `url:"vinsId" json:"vinsId" validate:"required"`
|
||||||
|
|
||||||
// Reason for action
|
|
||||||
// Required: false
|
|
||||||
Reason string `url:"reason,omitempty" json:"reason,omitempty"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ExtNetList show list of VINS external network connections
|
// ExtNetList show list of VINS external network connections
|
||||||
func (v VINS) ExtNetList(ctx context.Context, req ExtNetListRequest) (ListExtNets, error) {
|
func (v VINS) ExtNetList(ctx context.Context, req ExtNetListRequest) (*ListExtNets, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
for _, validationError := range validators.GetErrors(err) {
|
for _, validationError := range validators.GetErrors(err) {
|
||||||
@@ -42,5 +38,5 @@ func (v VINS) ExtNetList(ctx context.Context, req ExtNetListRequest) (ListExtNet
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return list, nil
|
return &list, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -58,21 +58,23 @@ func (lv ListVINS) FilterByDeletedBy(deletedBy string) ListVINS {
|
|||||||
func (lv ListVINS) FilterFunc(predicate func(ItemVINS) bool) ListVINS {
|
func (lv ListVINS) FilterFunc(predicate func(ItemVINS) bool) ListVINS {
|
||||||
var result ListVINS
|
var result ListVINS
|
||||||
|
|
||||||
for _, item := range lv {
|
for _, item := range lv.Data {
|
||||||
if predicate(item) {
|
if predicate(item) {
|
||||||
result = append(result, item)
|
result.Data = append(result.Data, item)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
result.EntryCount = uint64(len(result.Data))
|
||||||
|
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
// FindOne returns first found ItemVINS
|
// FindOne returns first found ItemVINS
|
||||||
// If none was found, returns an empty struct.
|
// If none was found, returns an empty struct.
|
||||||
func (lv ListVINS) FindOne() ItemVINS {
|
func (lv ListVINS) FindOne() ItemVINS {
|
||||||
if len(lv) == 0 {
|
if len(lv.Data) == 0 {
|
||||||
return ItemVINS{}
|
return ItemVINS{}
|
||||||
}
|
}
|
||||||
|
|
||||||
return lv[0]
|
return lv.Data[0]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,144 +3,147 @@ package vins
|
|||||||
import "testing"
|
import "testing"
|
||||||
|
|
||||||
var vinsItems = ListVINS{
|
var vinsItems = ListVINS{
|
||||||
{
|
Data: []ItemVINS{
|
||||||
AccountID: 1,
|
{
|
||||||
AccountName: "std",
|
AccountID: 1,
|
||||||
CreatedBy: "sample_user_1@decs3o",
|
AccountName: "std",
|
||||||
CreatedTime: 1676898844,
|
CreatedBy: "sample_user_1@decs3o",
|
||||||
DefaultGW: "",
|
CreatedTime: 1676898844,
|
||||||
DefaultQOS: QOS{
|
DefaultGW: "",
|
||||||
ERate: 0,
|
DefaultQOS: QOS{
|
||||||
GUID: "",
|
ERate: 0,
|
||||||
InBurst: 0,
|
GUID: "",
|
||||||
InRate: 0,
|
InBurst: 0,
|
||||||
|
InRate: 0,
|
||||||
|
},
|
||||||
|
DeletedBy: "",
|
||||||
|
DeletedTime: 0,
|
||||||
|
Description: "",
|
||||||
|
ExternalIP: "",
|
||||||
|
GID: 212,
|
||||||
|
GUID: 1,
|
||||||
|
ID: 1,
|
||||||
|
LockStatus: "UNLOCKED",
|
||||||
|
ManagerID: 0,
|
||||||
|
ManagerType: "",
|
||||||
|
Milestones: 363485,
|
||||||
|
Name: "vins01",
|
||||||
|
NetMask: 24,
|
||||||
|
Network: "192.168.1.0/24",
|
||||||
|
PreReservationsNum: 32,
|
||||||
|
PriVNFDevID: 29557,
|
||||||
|
Redundant: false,
|
||||||
|
RGID: 7971,
|
||||||
|
RGName: "rg_01",
|
||||||
|
SecVNFDevID: 0,
|
||||||
|
Status: "ENABLED",
|
||||||
|
UpdatedBy: "",
|
||||||
|
UpdatedTime: 0,
|
||||||
|
UserManaged: true,
|
||||||
|
VNFs: ItemVNFs{
|
||||||
|
DHCP: 51997,
|
||||||
|
DNS: 0,
|
||||||
|
FW: 0,
|
||||||
|
GW: 0,
|
||||||
|
NAT: 0,
|
||||||
|
VPN: 0,
|
||||||
|
},
|
||||||
|
VXLANID: 3544,
|
||||||
},
|
},
|
||||||
DeletedBy: "",
|
{
|
||||||
DeletedTime: 0,
|
AccountID: 2,
|
||||||
Description: "",
|
AccountName: "std2",
|
||||||
ExternalIP: "",
|
CreatedBy: "sample_user_1@decs3o",
|
||||||
GID: 212,
|
CreatedTime: 1676898948,
|
||||||
GUID: 1,
|
DefaultGW: "",
|
||||||
ID: 1,
|
DefaultQOS: QOS{
|
||||||
LockStatus: "UNLOCKED",
|
ERate: 0,
|
||||||
ManagerID: 0,
|
GUID: "",
|
||||||
ManagerType: "",
|
InBurst: 0,
|
||||||
Milestones: 363485,
|
InRate: 0,
|
||||||
Name: "vins01",
|
},
|
||||||
NetMask: 24,
|
DeletedBy: "",
|
||||||
Network: "192.168.1.0/24",
|
DeletedTime: 0,
|
||||||
PreReservationsNum: 32,
|
Description: "",
|
||||||
PriVNFDevID: 29557,
|
ExternalIP: "",
|
||||||
Redundant: false,
|
GID: 212,
|
||||||
RGID: 7971,
|
GUID: 2,
|
||||||
RGName: "rg_01",
|
ID: 2,
|
||||||
SecVNFDevID: 0,
|
LockStatus: "LOCKED",
|
||||||
Status: "ENABLED",
|
ManagerID: 0,
|
||||||
UpdatedBy: "",
|
ManagerType: "",
|
||||||
UpdatedTime: 0,
|
Milestones: 363508,
|
||||||
UserManaged: true,
|
Name: "vins02",
|
||||||
VNFs: ItemVNFs{
|
NetMask: 24,
|
||||||
DHCP: 51997,
|
Network: "192.168.2.0/24",
|
||||||
DNS: 0,
|
PreReservationsNum: 32,
|
||||||
FW: 0,
|
PriVNFDevID: 29558,
|
||||||
GW: 0,
|
Redundant: false,
|
||||||
NAT: 0,
|
RGID: 7972,
|
||||||
VPN: 0,
|
RGName: "rg_02",
|
||||||
|
SecVNFDevID: 0,
|
||||||
|
Status: "ENABLED",
|
||||||
|
UpdatedBy: "",
|
||||||
|
UpdatedTime: 0,
|
||||||
|
UserManaged: true,
|
||||||
|
VNFs: ItemVNFs{
|
||||||
|
DHCP: 51998,
|
||||||
|
DNS: 0,
|
||||||
|
FW: 0,
|
||||||
|
GW: 0,
|
||||||
|
NAT: 0,
|
||||||
|
VPN: 0,
|
||||||
|
},
|
||||||
|
VXLANID: 3545,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
AccountID: 3,
|
||||||
|
AccountName: "std3",
|
||||||
|
CreatedBy: "sample_user_2@decs3o",
|
||||||
|
CreatedTime: 1676899026,
|
||||||
|
DefaultGW: "",
|
||||||
|
DefaultQOS: QOS{
|
||||||
|
ERate: 0,
|
||||||
|
GUID: "",
|
||||||
|
InBurst: 0,
|
||||||
|
InRate: 0,
|
||||||
|
},
|
||||||
|
DeletedBy: "",
|
||||||
|
DeletedTime: 0,
|
||||||
|
Description: "",
|
||||||
|
ExternalIP: "",
|
||||||
|
GID: 212,
|
||||||
|
GUID: 3,
|
||||||
|
ID: 3,
|
||||||
|
LockStatus: "UNLOCKED",
|
||||||
|
ManagerID: 0,
|
||||||
|
ManagerType: "",
|
||||||
|
Milestones: 363549,
|
||||||
|
Name: "vins03",
|
||||||
|
NetMask: 24,
|
||||||
|
Network: "192.168.3.0/24",
|
||||||
|
PreReservationsNum: 32,
|
||||||
|
PriVNFDevID: 29559,
|
||||||
|
Redundant: false,
|
||||||
|
RGID: 7973,
|
||||||
|
RGName: "rg_03",
|
||||||
|
SecVNFDevID: 0,
|
||||||
|
Status: "DISABLED",
|
||||||
|
UpdatedBy: "",
|
||||||
|
UpdatedTime: 0,
|
||||||
|
UserManaged: true,
|
||||||
|
VNFs: ItemVNFs{
|
||||||
|
DHCP: 51999,
|
||||||
|
DNS: 0,
|
||||||
|
FW: 0,
|
||||||
|
GW: 0,
|
||||||
|
NAT: 0,
|
||||||
|
VPN: 0,
|
||||||
|
},
|
||||||
|
VXLANID: 3546,
|
||||||
},
|
},
|
||||||
VXLANID: 3544,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
AccountID: 2,
|
|
||||||
AccountName: "std2",
|
|
||||||
CreatedBy: "sample_user_1@decs3o",
|
|
||||||
CreatedTime: 1676898948,
|
|
||||||
DefaultGW: "",
|
|
||||||
DefaultQOS: QOS{
|
|
||||||
ERate: 0,
|
|
||||||
GUID: "",
|
|
||||||
InBurst: 0,
|
|
||||||
InRate: 0,
|
|
||||||
},
|
|
||||||
DeletedBy: "",
|
|
||||||
DeletedTime: 0,
|
|
||||||
Description: "",
|
|
||||||
ExternalIP: "",
|
|
||||||
GID: 212,
|
|
||||||
GUID: 2,
|
|
||||||
ID: 2,
|
|
||||||
LockStatus: "LOCKED",
|
|
||||||
ManagerID: 0,
|
|
||||||
ManagerType: "",
|
|
||||||
Milestones: 363508,
|
|
||||||
Name: "vins02",
|
|
||||||
NetMask: 24,
|
|
||||||
Network: "192.168.2.0/24",
|
|
||||||
PreReservationsNum: 32,
|
|
||||||
PriVNFDevID: 29558,
|
|
||||||
Redundant: false,
|
|
||||||
RGID: 7972,
|
|
||||||
RGName: "rg_02",
|
|
||||||
SecVNFDevID: 0,
|
|
||||||
Status: "ENABLED",
|
|
||||||
UpdatedBy: "",
|
|
||||||
UpdatedTime: 0,
|
|
||||||
UserManaged: true,
|
|
||||||
VNFs: ItemVNFs{
|
|
||||||
DHCP: 51998,
|
|
||||||
DNS: 0,
|
|
||||||
FW: 0,
|
|
||||||
GW: 0,
|
|
||||||
NAT: 0,
|
|
||||||
VPN: 0,
|
|
||||||
},
|
|
||||||
VXLANID: 3545,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
AccountID: 3,
|
|
||||||
AccountName: "std3",
|
|
||||||
CreatedBy: "sample_user_2@decs3o",
|
|
||||||
CreatedTime: 1676899026,
|
|
||||||
DefaultGW: "",
|
|
||||||
DefaultQOS: QOS{
|
|
||||||
ERate: 0,
|
|
||||||
GUID: "",
|
|
||||||
InBurst: 0,
|
|
||||||
InRate: 0,
|
|
||||||
},
|
|
||||||
DeletedBy: "",
|
|
||||||
DeletedTime: 0,
|
|
||||||
Description: "",
|
|
||||||
ExternalIP: "",
|
|
||||||
GID: 212,
|
|
||||||
GUID: 3,
|
|
||||||
ID: 3,
|
|
||||||
LockStatus: "UNLOCKED",
|
|
||||||
ManagerID: 0,
|
|
||||||
ManagerType: "",
|
|
||||||
Milestones: 363549,
|
|
||||||
Name: "vins03",
|
|
||||||
NetMask: 24,
|
|
||||||
Network: "192.168.3.0/24",
|
|
||||||
PreReservationsNum: 32,
|
|
||||||
PriVNFDevID: 29559,
|
|
||||||
Redundant: false,
|
|
||||||
RGID: 7973,
|
|
||||||
RGName: "rg_03",
|
|
||||||
SecVNFDevID: 0,
|
|
||||||
Status: "DISABLED",
|
|
||||||
UpdatedBy: "",
|
|
||||||
UpdatedTime: 0,
|
|
||||||
UserManaged: true,
|
|
||||||
VNFs: ItemVNFs{
|
|
||||||
DHCP: 51999,
|
|
||||||
DNS: 0,
|
|
||||||
FW: 0,
|
|
||||||
GW: 0,
|
|
||||||
NAT: 0,
|
|
||||||
VPN: 0,
|
|
||||||
},
|
|
||||||
VXLANID: 3546,
|
|
||||||
},
|
},
|
||||||
|
EntryCount: 3,
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestFilterByID(t *testing.T) {
|
func TestFilterByID(t *testing.T) {
|
||||||
@@ -170,11 +173,11 @@ func TestFilterByAccountID(t *testing.T) {
|
|||||||
func TestFilterByCreatedBy(t *testing.T) {
|
func TestFilterByCreatedBy(t *testing.T) {
|
||||||
actual := vinsItems.FilterByCreatedBy("sample_user_1@decs3o")
|
actual := vinsItems.FilterByCreatedBy("sample_user_1@decs3o")
|
||||||
|
|
||||||
if len(actual) != 2 {
|
if len(actual.Data) != 2 {
|
||||||
t.Fatal("expected 2 found, actual: ", len(actual))
|
t.Fatal("expected 2 found, actual: ", len(actual.Data))
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, item := range actual {
|
for _, item := range actual.Data {
|
||||||
if item.CreatedBy != "sample_user_1@decs3o" {
|
if item.CreatedBy != "sample_user_1@decs3o" {
|
||||||
t.Fatal("expected CreatedBy 'sample_user_1@decs3o', found: ", item.CreatedBy)
|
t.Fatal("expected CreatedBy 'sample_user_1@decs3o', found: ", item.CreatedBy)
|
||||||
}
|
}
|
||||||
@@ -195,7 +198,7 @@ func TestFilterFunc(t *testing.T) {
|
|||||||
func TestSortByCreatedTime(t *testing.T) {
|
func TestSortByCreatedTime(t *testing.T) {
|
||||||
actual := vinsItems.SortByCreatedTime(false)
|
actual := vinsItems.SortByCreatedTime(false)
|
||||||
|
|
||||||
if actual[0].CreatedTime != 1676898844 || actual[2].CreatedTime != 1676899026 {
|
if actual.Data[0].CreatedTime != 1676898844 || actual.Data[2].CreatedTime != 1676899026 {
|
||||||
t.Fatal("expected ascending order, found descending")
|
t.Fatal("expected ascending order, found descending")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ type IPListRequest struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// IPList show DHCP IP reservations on VINS
|
// IPList show DHCP IP reservations on VINS
|
||||||
func (v VINS) IPList(ctx context.Context, req IPListRequest) (ListIPs, error) {
|
func (v VINS) IPList(ctx context.Context, req IPListRequest) (*ListIPs, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
for _, validationError := range validators.GetErrors(err) {
|
for _, validationError := range validators.GetErrors(err) {
|
||||||
@@ -38,5 +38,5 @@ func (v VINS) IPList(ctx context.Context, req IPListRequest) (ListIPs, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return list, nil
|
return &list, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,30 @@ import (
|
|||||||
|
|
||||||
// Request struct for get list of VINSes
|
// Request struct for get list of VINSes
|
||||||
type ListRequest struct {
|
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"`
|
||||||
|
|
||||||
|
// Find by account ID
|
||||||
|
// Required: false
|
||||||
|
AccountID uint64 `url:"accountId,omitempty" json:"accountId,omitempty"`
|
||||||
|
|
||||||
|
// Find by resource group id
|
||||||
|
// Required: false
|
||||||
|
RGID uint64 `url:"rgId,omitempty" json:"rgId,omitempty"`
|
||||||
|
|
||||||
|
// Find by external network IP
|
||||||
|
// Required: false
|
||||||
|
ExtIP string `url:"extIp,omitempty" json:"extIp,omitempty"`
|
||||||
|
|
||||||
|
// Include deleted
|
||||||
|
// Required: false
|
||||||
|
IncludeDeleted bool `url:"includeDeleted,omitempty" json:"includeDeleted,omitempty"`
|
||||||
|
|
||||||
// Page number
|
// Page number
|
||||||
// Required: false
|
// Required: false
|
||||||
Page uint64 `url:"page,omitempty" json:"page,omitempty"`
|
Page uint64 `url:"page,omitempty" json:"page,omitempty"`
|
||||||
@@ -18,7 +42,7 @@ type ListRequest struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// List gets list of VINSes
|
// List gets list of VINSes
|
||||||
func (v VINS) List(ctx context.Context, req ListRequest) (ListVINS, error) {
|
func (v VINS) List(ctx context.Context, req ListRequest) (*ListVINS, error) {
|
||||||
url := "/cloudbroker/vins/list"
|
url := "/cloudbroker/vins/list"
|
||||||
|
|
||||||
res, err := v.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
res, err := v.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
@@ -33,5 +57,5 @@ func (v VINS) List(ctx context.Context, req ListRequest) (ListVINS, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return list, nil
|
return &list, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,26 @@ import (
|
|||||||
|
|
||||||
// Request struct for get list of deleted VINSes
|
// Request struct for get list of deleted VINSes
|
||||||
type ListDeletedRequest struct {
|
type ListDeletedRequest 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"`
|
||||||
|
|
||||||
|
// Find by account ID
|
||||||
|
// Required: false
|
||||||
|
AccountID uint64 `url:"accountId,omitempty" json:"accountId,omitempty"`
|
||||||
|
|
||||||
|
// Find by resource group id
|
||||||
|
// Required: false
|
||||||
|
RGID uint64 `url:"rgId,omitempty" json:"rgId,omitempty"`
|
||||||
|
|
||||||
|
// Find by external network IP
|
||||||
|
// Required: false
|
||||||
|
ExtIP string `url:"extIp,omitempty" json:"extIp,omitempty"`
|
||||||
|
|
||||||
// Page number
|
// Page number
|
||||||
// Required: false
|
// Required: false
|
||||||
Page uint64 `url:"page,omitempty" json:"page,omitempty"`
|
Page uint64 `url:"page,omitempty" json:"page,omitempty"`
|
||||||
@@ -18,7 +38,7 @@ type ListDeletedRequest struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ListDeleted gets list of deleted VINSes
|
// ListDeleted gets list of deleted VINSes
|
||||||
func (v VINS) ListDeleted(ctx context.Context, req ListDeletedRequest) (ListVINS, error) {
|
func (v VINS) ListDeleted(ctx context.Context, req ListDeletedRequest) (*ListVINS, error) {
|
||||||
url := "/cloudbroker/vins/listDeleted"
|
url := "/cloudbroker/vins/listDeleted"
|
||||||
|
|
||||||
res, err := v.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
res, err := v.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
@@ -33,5 +53,5 @@ func (v VINS) ListDeleted(ctx context.Context, req ListDeletedRequest) (ListVINS
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return list, nil
|
return &list, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,7 +43,13 @@ type ItemExtNet struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// List of external networks
|
// List of external networks
|
||||||
type ListExtNets []ItemExtNet
|
type ListExtNets struct {
|
||||||
|
// Data
|
||||||
|
Data []ItemExtNet `json:"data"`
|
||||||
|
|
||||||
|
// Entry count
|
||||||
|
EntryCount uint64 `json:"entryCount"`
|
||||||
|
}
|
||||||
|
|
||||||
// MGMT
|
// MGMT
|
||||||
type MGMT struct {
|
type MGMT struct {
|
||||||
@@ -110,6 +116,9 @@ type ItemInterface struct {
|
|||||||
// Default GW
|
// Default GW
|
||||||
DefGW string `json:"defGw"`
|
DefGW string `json:"defGw"`
|
||||||
|
|
||||||
|
// Enabled
|
||||||
|
Enabled bool `json:"enabled"`
|
||||||
|
|
||||||
// FLIPGroup ID
|
// FLIPGroup ID
|
||||||
FLIPGroupID uint64 `json:"flipgroupId"`
|
FLIPGroupID uint64 `json:"flipgroupId"`
|
||||||
|
|
||||||
@@ -428,12 +437,27 @@ type RecordVINS struct {
|
|||||||
// Account ID
|
// Account ID
|
||||||
AccountID uint64 `json:"accountId"`
|
AccountID uint64 `json:"accountId"`
|
||||||
|
|
||||||
|
// Account name
|
||||||
|
AccountName string `json:"accountName"`
|
||||||
|
|
||||||
|
// Created by
|
||||||
|
CreatedBy string `json:"createdBy"`
|
||||||
|
|
||||||
|
// Created time
|
||||||
|
CreatedTime uint64 `json:"createdTime"`
|
||||||
|
|
||||||
// Default GW
|
// Default GW
|
||||||
DefaultGW string `json:"defaultGW"`
|
DefaultGW string `json:"defaultGW"`
|
||||||
|
|
||||||
// Default QOS
|
// Default QOS
|
||||||
DefaultQOS QOS `json:"defaultQos"`
|
DefaultQOS QOS `json:"defaultQos"`
|
||||||
|
|
||||||
|
// Deleted by
|
||||||
|
DeletedBy string `json:"deletedBy"`
|
||||||
|
|
||||||
|
// Deleted time
|
||||||
|
DeletedTime uint64 `json:"deletedTime"`
|
||||||
|
|
||||||
// Description
|
// Description
|
||||||
Description string `json:"desc"`
|
Description string `json:"desc"`
|
||||||
|
|
||||||
@@ -476,12 +500,21 @@ type RecordVINS struct {
|
|||||||
// Resource group ID
|
// Resource group ID
|
||||||
RGID uint64 `json:"rgId"`
|
RGID uint64 `json:"rgId"`
|
||||||
|
|
||||||
|
// Resource group name
|
||||||
|
RGName string `json:"rgName"`
|
||||||
|
|
||||||
// SecVNFDevID
|
// SecVNFDevID
|
||||||
SecVNFDevID uint64 `json:"secVnfDevId"`
|
SecVNFDevID uint64 `json:"secVnfDevId"`
|
||||||
|
|
||||||
// Status
|
// Status
|
||||||
Status string `json:"status"`
|
Status string `json:"status"`
|
||||||
|
|
||||||
|
// Updated by
|
||||||
|
UpdatedBy string `json:"updatedBy"`
|
||||||
|
|
||||||
|
// Updated time
|
||||||
|
UpdatedTime uint64 `json:"updatedTime"`
|
||||||
|
|
||||||
// User managed
|
// User managed
|
||||||
UserManaged bool `json:"userManaged"`
|
UserManaged bool `json:"userManaged"`
|
||||||
|
|
||||||
@@ -517,7 +550,13 @@ type ItemIP struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// List of information about IPs
|
// List of information about IPs
|
||||||
type ListIPs []ItemIP
|
type ListIPs struct {
|
||||||
|
// Data
|
||||||
|
Data []ItemIP `json:"data"`
|
||||||
|
|
||||||
|
// Entry count
|
||||||
|
EntryCount uint64 `json:"entryCount"`
|
||||||
|
}
|
||||||
|
|
||||||
// Main information about NAT rule
|
// Main information about NAT rule
|
||||||
type ItemNATRule struct {
|
type ItemNATRule struct {
|
||||||
@@ -547,7 +586,13 @@ type ItemNATRule struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// List NAT rules
|
// List NAT rules
|
||||||
type ListNATRules []ItemNATRule
|
type ListNATRules struct {
|
||||||
|
// Data
|
||||||
|
Data []ItemNATRule `json:"data"`
|
||||||
|
|
||||||
|
// Entry count
|
||||||
|
EntryCount uint64 `json:"entryCount"`
|
||||||
|
}
|
||||||
|
|
||||||
// Shorted information about VNF
|
// Shorted information about VNF
|
||||||
type ItemVNFs struct {
|
type ItemVNFs struct {
|
||||||
@@ -670,4 +715,12 @@ type ItemVINS struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// List of VINS
|
// List of VINS
|
||||||
type ListVINS []ItemVINS
|
type ListVINS struct {
|
||||||
|
// Data
|
||||||
|
Data []ItemVINS `json:"data"`
|
||||||
|
|
||||||
|
// Entry count
|
||||||
|
EntryCount uint64 `json:"entryCount"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type SearchVINS []ItemVINS
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ type NATRuleDelRequest struct {
|
|||||||
// ID of the rule to delete.
|
// ID of the rule to delete.
|
||||||
// Pass -1 to clear all rules at once
|
// Pass -1 to clear all rules at once
|
||||||
// Required: true
|
// Required: true
|
||||||
RuleID uint64 `url:"ruleId" json:"ruleId" validate:"required"`
|
RuleID int64 `url:"ruleId" json:"ruleId" validate:"required"`
|
||||||
|
|
||||||
// Reason for action
|
// Reason for action
|
||||||
// Required: false
|
// Required: false
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ type NATRuleListRequest struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NATRuleList gets list of NAT (port forwarding) rules
|
// NATRuleList gets list of NAT (port forwarding) rules
|
||||||
func (v VINS) NATRuleList(ctx context.Context, req NATRuleListRequest) (ListNATRules, error) {
|
func (v VINS) NATRuleList(ctx context.Context, req NATRuleListRequest) (*ListNATRules, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
for _, validationError := range validators.GetErrors(err) {
|
for _, validationError := range validators.GetErrors(err) {
|
||||||
@@ -42,5 +42,5 @@ func (v VINS) NATRuleList(ctx context.Context, req NATRuleListRequest) (ListNATR
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return list, nil
|
return &list, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ type SearchRequest struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Search search VINSes
|
// Search search VINSes
|
||||||
func (v VINS) Search(ctx context.Context, req SearchRequest) (ListVINS, error) {
|
func (v VINS) Search(ctx context.Context, req SearchRequest) (SearchVINS, error) {
|
||||||
url := "/cloudbroker/vins/search"
|
url := "/cloudbroker/vins/search"
|
||||||
|
|
||||||
res, err := v.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
res, err := v.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
@@ -38,7 +38,7 @@ func (v VINS) Search(ctx context.Context, req SearchRequest) (ListVINS, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
list := ListVINS{}
|
list := SearchVINS{}
|
||||||
|
|
||||||
err = json.Unmarshal(res, &list)
|
err = json.Unmarshal(res, &list)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import (
|
|||||||
// - First argument -> prefix
|
// - First argument -> prefix
|
||||||
// - Second argument -> indent
|
// - Second argument -> indent
|
||||||
func (lv ListVINS) Serialize(params ...string) (serialization.Serialized, error) {
|
func (lv ListVINS) Serialize(params ...string) (serialization.Serialized, error) {
|
||||||
if len(lv) == 0 {
|
if len(lv.Data) == 0 {
|
||||||
return []byte{}, nil
|
return []byte{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,16 +6,16 @@ import "sort"
|
|||||||
//
|
//
|
||||||
// If inverse param is set to true, the order is reversed.
|
// If inverse param is set to true, the order is reversed.
|
||||||
func (lv ListVINS) SortByCreatedTime(inverse bool) ListVINS {
|
func (lv ListVINS) SortByCreatedTime(inverse bool) ListVINS {
|
||||||
if len(lv) < 2 {
|
if len(lv.Data) < 2 {
|
||||||
return lv
|
return lv
|
||||||
}
|
}
|
||||||
|
|
||||||
sort.Slice(lv, func(i, j int) bool {
|
sort.Slice(lv.Data, func(i, j int) bool {
|
||||||
if inverse {
|
if inverse {
|
||||||
return lv[i].CreatedTime > lv[j].CreatedTime
|
return lv.Data[i].CreatedTime > lv.Data[j].CreatedTime
|
||||||
}
|
}
|
||||||
|
|
||||||
return lv[i].CreatedTime < lv[j].CreatedTime
|
return lv.Data[i].CreatedTime < lv.Data[j].CreatedTime
|
||||||
})
|
})
|
||||||
|
|
||||||
return lv
|
return lv
|
||||||
@@ -25,16 +25,16 @@ func (lv ListVINS) SortByCreatedTime(inverse bool) ListVINS {
|
|||||||
//
|
//
|
||||||
// If inverse param is set to true, the order is reversed.
|
// If inverse param is set to true, the order is reversed.
|
||||||
func (lv ListVINS) SortByUpdatedTime(inverse bool) ListVINS {
|
func (lv ListVINS) SortByUpdatedTime(inverse bool) ListVINS {
|
||||||
if len(lv) < 2 {
|
if len(lv.Data) < 2 {
|
||||||
return lv
|
return lv
|
||||||
}
|
}
|
||||||
|
|
||||||
sort.Slice(lv, func(i, j int) bool {
|
sort.Slice(lv.Data, func(i, j int) bool {
|
||||||
if inverse {
|
if inverse {
|
||||||
return lv[i].UpdatedTime > lv[j].UpdatedTime
|
return lv.Data[i].UpdatedTime > lv.Data[j].UpdatedTime
|
||||||
}
|
}
|
||||||
|
|
||||||
return lv[i].UpdatedTime < lv[j].UpdatedTime
|
return lv.Data[i].UpdatedTime < lv.Data[j].UpdatedTime
|
||||||
})
|
})
|
||||||
|
|
||||||
return lv
|
return lv
|
||||||
@@ -44,16 +44,16 @@ func (lv ListVINS) SortByUpdatedTime(inverse bool) ListVINS {
|
|||||||
//
|
//
|
||||||
// If inverse param is set to true, the order is reversed.
|
// If inverse param is set to true, the order is reversed.
|
||||||
func (lv ListVINS) SortByDeletedTime(inverse bool) ListVINS {
|
func (lv ListVINS) SortByDeletedTime(inverse bool) ListVINS {
|
||||||
if len(lv) < 2 {
|
if len(lv.Data) < 2 {
|
||||||
return lv
|
return lv
|
||||||
}
|
}
|
||||||
|
|
||||||
sort.Slice(lv, func(i, j int) bool {
|
sort.Slice(lv.Data, func(i, j int) bool {
|
||||||
if inverse {
|
if inverse {
|
||||||
return lv[i].DeletedTime > lv[j].DeletedTime
|
return lv.Data[i].DeletedTime > lv.Data[j].DeletedTime
|
||||||
}
|
}
|
||||||
|
|
||||||
return lv[i].DeletedTime < lv[j].DeletedTime
|
return lv.Data[i].DeletedTime < lv.Data[j].DeletedTime
|
||||||
})
|
})
|
||||||
|
|
||||||
return lv
|
return lv
|
||||||
|
|||||||
Reference in New Issue
Block a user