v1.5.0-delta
This commit is contained in:
@@ -15,8 +15,8 @@ type ExtNetConnectRequest struct {
|
||||
VINSID uint64 `url:"vinsId" json:"vinsId" validate:"required"`
|
||||
|
||||
// External network ID
|
||||
// Required: true
|
||||
NetID uint64 `url:"netId" json:"netId" validate:"required"`
|
||||
// Required: false
|
||||
NetID uint64 `url:"netId,omitempty" json:"netId,omitempty"`
|
||||
|
||||
// Directly set IP address
|
||||
// Required: false
|
||||
|
||||
@@ -13,14 +13,10 @@ type ExtNetListRequest struct {
|
||||
// VINS ID
|
||||
// Required: true
|
||||
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
|
||||
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)
|
||||
if err != nil {
|
||||
for _, validationError := range validators.GetErrors(err) {
|
||||
@@ -42,5 +38,5 @@ func (v VINS) ExtNetList(ctx context.Context, req ExtNetListRequest) (ListExtNet
|
||||
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 {
|
||||
var result ListVINS
|
||||
|
||||
for _, item := range lv {
|
||||
for _, item := range lv.Data {
|
||||
if predicate(item) {
|
||||
result = append(result, item)
|
||||
result.Data = append(result.Data, item)
|
||||
}
|
||||
}
|
||||
|
||||
result.EntryCount = uint64(len(result.Data))
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
// FindOne returns first found ItemVINS
|
||||
// If none was found, returns an empty struct.
|
||||
func (lv ListVINS) FindOne() ItemVINS {
|
||||
if len(lv) == 0 {
|
||||
if len(lv.Data) == 0 {
|
||||
return ItemVINS{}
|
||||
}
|
||||
|
||||
return lv[0]
|
||||
return lv.Data[0]
|
||||
}
|
||||
|
||||
@@ -3,144 +3,147 @@ package vins
|
||||
import "testing"
|
||||
|
||||
var vinsItems = ListVINS{
|
||||
{
|
||||
AccountID: 1,
|
||||
AccountName: "std",
|
||||
CreatedBy: "sample_user_1@decs3o",
|
||||
CreatedTime: 1676898844,
|
||||
DefaultGW: "",
|
||||
DefaultQOS: QOS{
|
||||
ERate: 0,
|
||||
GUID: "",
|
||||
InBurst: 0,
|
||||
InRate: 0,
|
||||
Data: []ItemVINS{
|
||||
{
|
||||
AccountID: 1,
|
||||
AccountName: "std",
|
||||
CreatedBy: "sample_user_1@decs3o",
|
||||
CreatedTime: 1676898844,
|
||||
DefaultGW: "",
|
||||
DefaultQOS: QOS{
|
||||
ERate: 0,
|
||||
GUID: "",
|
||||
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,
|
||||
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,
|
||||
{
|
||||
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,
|
||||
},
|
||||
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) {
|
||||
@@ -170,11 +173,11 @@ func TestFilterByAccountID(t *testing.T) {
|
||||
func TestFilterByCreatedBy(t *testing.T) {
|
||||
actual := vinsItems.FilterByCreatedBy("sample_user_1@decs3o")
|
||||
|
||||
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.CreatedBy != "sample_user_1@decs3o" {
|
||||
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) {
|
||||
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")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ type IPListRequest struct {
|
||||
}
|
||||
|
||||
// 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)
|
||||
if err != nil {
|
||||
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 list, nil
|
||||
return &list, nil
|
||||
}
|
||||
|
||||
@@ -8,6 +8,30 @@ import (
|
||||
|
||||
// Request struct for get list of VINSes
|
||||
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
|
||||
// Required: false
|
||||
Page uint64 `url:"page,omitempty" json:"page,omitempty"`
|
||||
@@ -18,7 +42,7 @@ type ListRequest struct {
|
||||
}
|
||||
|
||||
// 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"
|
||||
|
||||
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 list, nil
|
||||
return &list, nil
|
||||
}
|
||||
|
||||
@@ -8,6 +8,26 @@ import (
|
||||
|
||||
// Request struct for get list of deleted VINSes
|
||||
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
|
||||
// Required: false
|
||||
Page uint64 `url:"page,omitempty" json:"page,omitempty"`
|
||||
@@ -18,7 +38,7 @@ type ListDeletedRequest struct {
|
||||
}
|
||||
|
||||
// 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"
|
||||
|
||||
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 list, nil
|
||||
return &list, nil
|
||||
}
|
||||
|
||||
@@ -43,7 +43,13 @@ type ItemExtNet struct {
|
||||
}
|
||||
|
||||
// List of external networks
|
||||
type ListExtNets []ItemExtNet
|
||||
type ListExtNets struct {
|
||||
// Data
|
||||
Data []ItemExtNet `json:"data"`
|
||||
|
||||
// Entry count
|
||||
EntryCount uint64 `json:"entryCount"`
|
||||
}
|
||||
|
||||
// MGMT
|
||||
type MGMT struct {
|
||||
@@ -110,6 +116,9 @@ type ItemInterface struct {
|
||||
// Default GW
|
||||
DefGW string `json:"defGw"`
|
||||
|
||||
// Enabled
|
||||
Enabled bool `json:"enabled"`
|
||||
|
||||
// FLIPGroup ID
|
||||
FLIPGroupID uint64 `json:"flipgroupId"`
|
||||
|
||||
@@ -428,12 +437,27 @@ type RecordVINS struct {
|
||||
// Account ID
|
||||
AccountID uint64 `json:"accountId"`
|
||||
|
||||
// Account name
|
||||
AccountName string `json:"accountName"`
|
||||
|
||||
// Created by
|
||||
CreatedBy string `json:"createdBy"`
|
||||
|
||||
// Created time
|
||||
CreatedTime uint64 `json:"createdTime"`
|
||||
|
||||
// Default GW
|
||||
DefaultGW string `json:"defaultGW"`
|
||||
|
||||
// Default QOS
|
||||
DefaultQOS QOS `json:"defaultQos"`
|
||||
|
||||
// Deleted by
|
||||
DeletedBy string `json:"deletedBy"`
|
||||
|
||||
// Deleted time
|
||||
DeletedTime uint64 `json:"deletedTime"`
|
||||
|
||||
// Description
|
||||
Description string `json:"desc"`
|
||||
|
||||
@@ -476,12 +500,21 @@ type RecordVINS struct {
|
||||
// Resource group ID
|
||||
RGID uint64 `json:"rgId"`
|
||||
|
||||
// Resource group name
|
||||
RGName string `json:"rgName"`
|
||||
|
||||
// SecVNFDevID
|
||||
SecVNFDevID uint64 `json:"secVnfDevId"`
|
||||
|
||||
// Status
|
||||
Status string `json:"status"`
|
||||
|
||||
// Updated by
|
||||
UpdatedBy string `json:"updatedBy"`
|
||||
|
||||
// Updated time
|
||||
UpdatedTime uint64 `json:"updatedTime"`
|
||||
|
||||
// User managed
|
||||
UserManaged bool `json:"userManaged"`
|
||||
|
||||
@@ -517,7 +550,13 @@ type ItemIP struct {
|
||||
}
|
||||
|
||||
// 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
|
||||
type ItemNATRule struct {
|
||||
@@ -547,7 +586,13 @@ type ItemNATRule struct {
|
||||
}
|
||||
|
||||
// List NAT rules
|
||||
type ListNATRules []ItemNATRule
|
||||
type ListNATRules struct {
|
||||
// Data
|
||||
Data []ItemNATRule `json:"data"`
|
||||
|
||||
// Entry count
|
||||
EntryCount uint64 `json:"entryCount"`
|
||||
}
|
||||
|
||||
// Shorted information about VNF
|
||||
type ItemVNFs struct {
|
||||
@@ -670,4 +715,12 @@ type ItemVINS struct {
|
||||
}
|
||||
|
||||
// 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.
|
||||
// Pass -1 to clear all rules at once
|
||||
// Required: true
|
||||
RuleID uint64 `url:"ruleId" json:"ruleId" validate:"required"`
|
||||
RuleID int64 `url:"ruleId" json:"ruleId" validate:"required"`
|
||||
|
||||
// Reason for action
|
||||
// Required: false
|
||||
|
||||
@@ -20,7 +20,7 @@ type NATRuleListRequest struct {
|
||||
}
|
||||
|
||||
// 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)
|
||||
if err != nil {
|
||||
for _, validationError := range validators.GetErrors(err) {
|
||||
@@ -42,5 +42,5 @@ func (v VINS) NATRuleList(ctx context.Context, req NATRuleListRequest) (ListNATR
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return list, nil
|
||||
return &list, nil
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ type SearchRequest struct {
|
||||
}
|
||||
|
||||
// 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"
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
list := ListVINS{}
|
||||
list := SearchVINS{}
|
||||
|
||||
err = json.Unmarshal(res, &list)
|
||||
if err != nil {
|
||||
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
// - First argument -> prefix
|
||||
// - Second argument -> indent
|
||||
func (lv ListVINS) Serialize(params ...string) (serialization.Serialized, error) {
|
||||
if len(lv) == 0 {
|
||||
if len(lv.Data) == 0 {
|
||||
return []byte{}, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -6,16 +6,16 @@ import "sort"
|
||||
//
|
||||
// If inverse param is set to true, the order is reversed.
|
||||
func (lv ListVINS) SortByCreatedTime(inverse bool) ListVINS {
|
||||
if len(lv) < 2 {
|
||||
if len(lv.Data) < 2 {
|
||||
return lv
|
||||
}
|
||||
|
||||
sort.Slice(lv, func(i, j int) bool {
|
||||
sort.Slice(lv.Data, func(i, j int) bool {
|
||||
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
|
||||
@@ -25,16 +25,16 @@ func (lv ListVINS) SortByCreatedTime(inverse bool) ListVINS {
|
||||
//
|
||||
// If inverse param is set to true, the order is reversed.
|
||||
func (lv ListVINS) SortByUpdatedTime(inverse bool) ListVINS {
|
||||
if len(lv) < 2 {
|
||||
if len(lv.Data) < 2 {
|
||||
return lv
|
||||
}
|
||||
|
||||
sort.Slice(lv, func(i, j int) bool {
|
||||
sort.Slice(lv.Data, func(i, j int) bool {
|
||||
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
|
||||
@@ -44,16 +44,16 @@ func (lv ListVINS) SortByUpdatedTime(inverse bool) ListVINS {
|
||||
//
|
||||
// If inverse param is set to true, the order is reversed.
|
||||
func (lv ListVINS) SortByDeletedTime(inverse bool) ListVINS {
|
||||
if len(lv) < 2 {
|
||||
if len(lv.Data) < 2 {
|
||||
return lv
|
||||
}
|
||||
|
||||
sort.Slice(lv, func(i, j int) bool {
|
||||
sort.Slice(lv.Data, func(i, j int) bool {
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user