v1.5.0-gamma2
This commit is contained in:
@@ -23,14 +23,14 @@ type CreateRequest struct {
|
||||
// Required: true
|
||||
IPCIDR string `url:"ipcidr" json:"ipcidr" validate:"required"`
|
||||
|
||||
// External network gateway IP address
|
||||
// Required: true
|
||||
Gateway string `url:"gateway" json:"gateway" validate:"required"`
|
||||
|
||||
// VLAN ID
|
||||
// Required: true
|
||||
VLANID uint64 `url:"vlanId" json:"vlanId" validate:"required"`
|
||||
|
||||
// External network gateway IP address
|
||||
// Required: false
|
||||
Gateway string `url:"gateway,omitempty" json:"gateway,omitempty"`
|
||||
|
||||
// List of DNS addresses
|
||||
// Required: false
|
||||
DNS []string `url:"dns,omitempty" json:"dns,omitempty"`
|
||||
|
||||
@@ -31,21 +31,23 @@ func (lenet ListExtNet) FilterByStatus(status string) ListExtNet {
|
||||
func (lenet ListExtNet) FilterFunc(predicate func(ItemExtNet) bool) ListExtNet {
|
||||
var result ListExtNet
|
||||
|
||||
for _, item := range lenet {
|
||||
for _, item := range lenet.Data {
|
||||
if predicate(item) {
|
||||
result = append(result, item)
|
||||
result.Data = append(result.Data, item)
|
||||
}
|
||||
}
|
||||
|
||||
result.EntryCount = uint64(len(lenet.Data))
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
// FindOne returns first found ItemExtNet
|
||||
// If none was found, returns an empty struct.
|
||||
func (lenet ListExtNet) FindOne() ItemExtNet {
|
||||
if len(lenet) == 0 {
|
||||
if len(lenet.Data) == 0 {
|
||||
return ItemExtNet{}
|
||||
}
|
||||
|
||||
return lenet[0]
|
||||
return lenet.Data[0]
|
||||
}
|
||||
|
||||
@@ -3,74 +3,76 @@ package extnet
|
||||
import "testing"
|
||||
|
||||
var extnets = ListExtNet{
|
||||
ItemExtNet{
|
||||
CKey: "",
|
||||
Meta: []interface{}{},
|
||||
CheckIPs: []string{},
|
||||
Default: false,
|
||||
DefaultQOS: QOS{},
|
||||
Description: "",
|
||||
FreeIPs: 0,
|
||||
GID: 212,
|
||||
GUID: 3,
|
||||
ID: 3,
|
||||
IPCIDR: "176.118.164.0/24",
|
||||
Milestones: 1355466,
|
||||
Name: "176.118.164.0/24",
|
||||
NetworkID: 0,
|
||||
OVSBridge: "",
|
||||
PreReservationsNum: 0,
|
||||
PriVNFDevID: 0,
|
||||
SharedWith: []interface{}{},
|
||||
Status: "ENABLED",
|
||||
VLANID: 0,
|
||||
VNFs: VNFs{},
|
||||
},
|
||||
ItemExtNet{
|
||||
CKey: "",
|
||||
Meta: []interface{}{},
|
||||
CheckIPs: []string{},
|
||||
Default: false,
|
||||
DefaultQOS: QOS{},
|
||||
Description: "",
|
||||
FreeIPs: 0,
|
||||
GID: 212,
|
||||
GUID: 10,
|
||||
ID: 10,
|
||||
IPCIDR: "45.134.255.0/24",
|
||||
Milestones: 2135543,
|
||||
Name: "45.134.255.0/24",
|
||||
NetworkID: 0,
|
||||
OVSBridge: "",
|
||||
PreReservationsNum: 0,
|
||||
PriVNFDevID: 0,
|
||||
SharedWith: []interface{}{},
|
||||
Status: "ENABLED",
|
||||
VLANID: 0,
|
||||
VNFs: VNFs{},
|
||||
},
|
||||
ItemExtNet{
|
||||
CKey: "",
|
||||
Meta: []interface{}{},
|
||||
CheckIPs: []string{},
|
||||
Default: false,
|
||||
DefaultQOS: QOS{},
|
||||
Description: "",
|
||||
FreeIPs: 0,
|
||||
GID: 212,
|
||||
GUID: 13,
|
||||
ID: 13,
|
||||
IPCIDR: "88.218.249.0/24",
|
||||
Milestones: 1232134,
|
||||
Name: "88.218.249.0/24",
|
||||
NetworkID: 0,
|
||||
OVSBridge: "",
|
||||
PreReservationsNum: 0,
|
||||
PriVNFDevID: 0,
|
||||
SharedWith: []interface{}{},
|
||||
Status: "DISABLED",
|
||||
VLANID: 0,
|
||||
VNFs: VNFs{},
|
||||
Data: []ItemExtNet{
|
||||
{
|
||||
CKey: "",
|
||||
Meta: []interface{}{},
|
||||
CheckIPs: []string{},
|
||||
Default: false,
|
||||
DefaultQOS: QOS{},
|
||||
Description: "",
|
||||
FreeIPs: 0,
|
||||
GID: 212,
|
||||
GUID: 3,
|
||||
ID: 3,
|
||||
IPCIDR: "176.118.164.0/24",
|
||||
Milestones: 1355466,
|
||||
Name: "176.118.164.0/24",
|
||||
NetworkID: 0,
|
||||
OVSBridge: "",
|
||||
PreReservationsNum: 0,
|
||||
PriVNFDevID: 0,
|
||||
SharedWith: []interface{}{},
|
||||
Status: "ENABLED",
|
||||
VLANID: 0,
|
||||
VNFs: VNFs{},
|
||||
},
|
||||
{
|
||||
CKey: "",
|
||||
Meta: []interface{}{},
|
||||
CheckIPs: []string{},
|
||||
Default: false,
|
||||
DefaultQOS: QOS{},
|
||||
Description: "",
|
||||
FreeIPs: 0,
|
||||
GID: 212,
|
||||
GUID: 10,
|
||||
ID: 10,
|
||||
IPCIDR: "45.134.255.0/24",
|
||||
Milestones: 2135543,
|
||||
Name: "45.134.255.0/24",
|
||||
NetworkID: 0,
|
||||
OVSBridge: "",
|
||||
PreReservationsNum: 0,
|
||||
PriVNFDevID: 0,
|
||||
SharedWith: []interface{}{},
|
||||
Status: "ENABLED",
|
||||
VLANID: 0,
|
||||
VNFs: VNFs{},
|
||||
},
|
||||
{
|
||||
CKey: "",
|
||||
Meta: []interface{}{},
|
||||
CheckIPs: []string{},
|
||||
Default: false,
|
||||
DefaultQOS: QOS{},
|
||||
Description: "",
|
||||
FreeIPs: 0,
|
||||
GID: 212,
|
||||
GUID: 13,
|
||||
ID: 13,
|
||||
IPCIDR: "88.218.249.0/24",
|
||||
Milestones: 1232134,
|
||||
Name: "88.218.249.0/24",
|
||||
NetworkID: 0,
|
||||
OVSBridge: "",
|
||||
PreReservationsNum: 0,
|
||||
PriVNFDevID: 0,
|
||||
SharedWith: []interface{}{},
|
||||
Status: "DISABLED",
|
||||
VLANID: 0,
|
||||
VNFs: VNFs{},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
@@ -94,11 +96,11 @@ func TestFilterByName(t *testing.T) {
|
||||
func TestFilterByStatus(t *testing.T) {
|
||||
actual := extnets.FilterByStatus("ENABLED")
|
||||
|
||||
if len(actual) != 2 {
|
||||
t.Fatal("expected 2 found, actual: ", len(actual))
|
||||
if len(actual.Data) != 2 {
|
||||
t.Fatal("expected 2 found, actual: ", len(actual.Data))
|
||||
}
|
||||
|
||||
for _, item := range actual {
|
||||
for _, item := range actual.Data {
|
||||
if item.Status != "ENABLED" {
|
||||
t.Fatal("expected Status 'ENABLED', found: ", item.Status)
|
||||
}
|
||||
@@ -110,7 +112,7 @@ func TestFilterFunc(t *testing.T) {
|
||||
return ien.IPCIDR == ien.Name
|
||||
})
|
||||
|
||||
if len(actual) != 3 {
|
||||
t.Fatal("expected 3 elements, found: ", len(actual))
|
||||
if len(actual.Data) != 3 {
|
||||
t.Fatal("expected 3 elements, found: ", len(actual.Data))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,10 +8,34 @@ import (
|
||||
|
||||
// Request struct for get list external network
|
||||
type ListRequest struct {
|
||||
// Filter by account ID
|
||||
// Find by account ID
|
||||
// Required: false
|
||||
AccountID uint64 `url:"accountId,omitempty" json:"accountId,omitempty"`
|
||||
|
||||
// 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 network ip address
|
||||
// Required: false
|
||||
Network string `url:"network,omitempty" json:"network,omitempty"`
|
||||
|
||||
// Find by vlan ID
|
||||
// Required: false
|
||||
VLANID uint64 `url:"vlanId,omitempty" json:"vlanId,omitempty"`
|
||||
|
||||
// Find by vnfDevices ID
|
||||
// Required: false
|
||||
VNFDevID uint64 `url:"vnfDevId,omitempty" json:"vnfDevId,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"`
|
||||
@@ -22,7 +46,7 @@ type ListRequest struct {
|
||||
}
|
||||
|
||||
// List gets list all available external networks
|
||||
func (e ExtNet) List(ctx context.Context, req ListRequest) (ListExtNet, error) {
|
||||
func (e ExtNet) List(ctx context.Context, req ListRequest) (*ListExtNet, error) {
|
||||
url := "/cloudbroker/extnet/list"
|
||||
|
||||
res, err := e.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
@@ -37,5 +61,5 @@ func (e ExtNet) List(ctx context.Context, req ListRequest) (ListExtNet, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return list, nil
|
||||
return &list, nil
|
||||
}
|
||||
|
||||
@@ -117,18 +117,21 @@ type ItemExtNet struct {
|
||||
}
|
||||
|
||||
// List external networks
|
||||
type ListExtNet []ItemExtNet
|
||||
type ListExtNet struct {
|
||||
// Data
|
||||
Data []ItemExtNet `json:"data"`
|
||||
|
||||
// Entry count
|
||||
EntryCount uint64 `json:"entryCount"`
|
||||
}
|
||||
|
||||
// Detailed information about external network
|
||||
type RecordExtNet struct {
|
||||
// Main information about external network
|
||||
ItemExtNet
|
||||
|
||||
// CheckIPs
|
||||
CheckIPs []string `json:"checkIPs"`
|
||||
|
||||
// CheckIps
|
||||
CheckIps []string `json:"checkIps"`
|
||||
CheckIPs []string `json:"checkIps"`
|
||||
|
||||
// List DNS
|
||||
DNS []string `json:"dns"`
|
||||
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
// - First argument -> prefix
|
||||
// - Second argument -> indent
|
||||
func (lenet ListExtNet) Serialize(params ...string) (serialization.Serialized, error) {
|
||||
if len(lenet) == 0 {
|
||||
if len(lenet.Data) == 0 {
|
||||
return []byte{}, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user