v16.1.0
v16.1.0
This commit is contained in:
@@ -45,24 +45,6 @@ func (lqp ListQoSPolicies) FilterByDescription(description string) ListQoSPolici
|
||||
return lqp.FilterFunc(predicate)
|
||||
}
|
||||
|
||||
// FilterByCreatedBy returns ListQoSPolicies with specified CreatedBy
|
||||
func (lqp ListQoSPolicies) FilterByCreatedBy(createdBy string) ListQoSPolicies {
|
||||
predicate := func(iqp ItemQoSPolicy) bool {
|
||||
return iqp.CreatedBy == createdBy
|
||||
}
|
||||
|
||||
return lqp.FilterFunc(predicate)
|
||||
}
|
||||
|
||||
// FilterByUpdatedBy returns ListQoSPolicies with specified UpdatedBy
|
||||
func (lqp ListQoSPolicies) FilterByUpdatedBy(updatedBy string) ListQoSPolicies {
|
||||
predicate := func(iqp ItemQoSPolicy) bool {
|
||||
return iqp.UpdatedBy == updatedBy
|
||||
}
|
||||
|
||||
return lqp.FilterFunc(predicate)
|
||||
}
|
||||
|
||||
// FilterFunc allows filtering ListQoSPolicies based on a user-specified predicate
|
||||
func (lqp ListQoSPolicies) FilterFunc(predicate func(ItemQoSPolicy) bool) ListQoSPolicies {
|
||||
var result ListQoSPolicies
|
||||
|
||||
@@ -10,7 +10,6 @@ var qosPolicies = ListQoSPolicies{
|
||||
Name: "qos1",
|
||||
Description: "some desc",
|
||||
Status: "ENABLED",
|
||||
CreatedBy: "user",
|
||||
},
|
||||
{
|
||||
ID: 3,
|
||||
@@ -18,7 +17,6 @@ var qosPolicies = ListQoSPolicies{
|
||||
Name: "qos3",
|
||||
Description: "some desc",
|
||||
Status: "ENABLED",
|
||||
CreatedBy: "anotheruser",
|
||||
},
|
||||
{
|
||||
ID: 5,
|
||||
@@ -26,8 +24,6 @@ var qosPolicies = ListQoSPolicies{
|
||||
Name: "qos5",
|
||||
Description: "some other desc",
|
||||
Status: "DISABLED",
|
||||
CreatedBy: "anotheruser",
|
||||
UpdatedBy: "user",
|
||||
},
|
||||
},
|
||||
EntryCount: 3,
|
||||
@@ -74,24 +70,3 @@ func TestFilterByStatus(t *testing.T) {
|
||||
t.Fatal("expected Status DISABLED, found: ", actual.Status)
|
||||
}
|
||||
}
|
||||
|
||||
func TestFilterByCreatedBy(t *testing.T) {
|
||||
actual := qosPolicies.FilterByCreatedBy("anotheruser")
|
||||
|
||||
if len(actual.Data) != 2 {
|
||||
t.Fatal("expected 2 found, actual: ", len(actual.Data))
|
||||
}
|
||||
|
||||
for _, item := range actual.Data {
|
||||
if item.CreatedBy != "anotheruser" {
|
||||
t.Fatal("expected CreatedBy 'anotheruser', found: ", item.CreatedBy)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestFilterByUpdatedBy(t *testing.T) {
|
||||
actual := qosPolicies.FilterByUpdatedBy("user").FindOne()
|
||||
if actual.UpdatedBy != "user" {
|
||||
t.Fatal("expected UpdatedBy 'user', found: ", actual.UpdatedBy)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,18 +27,6 @@ type ItemQoSPolicy struct {
|
||||
// Status of the QoS policy
|
||||
Status string `json:"status"`
|
||||
|
||||
// Created at (unix timestamp)
|
||||
CreatedAt uint64 `json:"created_at"`
|
||||
|
||||
// Updated at (unix timestamp)
|
||||
UpdatedAt uint64 `json:"updated_at"`
|
||||
|
||||
// Created by
|
||||
CreatedBy string `json:"created_by"`
|
||||
|
||||
// Updated by
|
||||
UpdatedBy string `json:"updated_by"`
|
||||
|
||||
// List of rules
|
||||
Rules Rules `json:"rules"`
|
||||
}
|
||||
@@ -62,18 +50,6 @@ type RecordQoSPolicy struct {
|
||||
// Status of the QoS policy
|
||||
Status string `json:"status"`
|
||||
|
||||
// Created at (unix timestamp)
|
||||
CreatedAt uint64 `json:"created_at"`
|
||||
|
||||
// Updated at (unix timestamp)
|
||||
UpdatedAt uint64 `json:"updated_at"`
|
||||
|
||||
// Created by
|
||||
CreatedBy string `json:"created_by"`
|
||||
|
||||
// Updated by
|
||||
UpdatedBy string `json:"updated_by"`
|
||||
|
||||
// List of rules
|
||||
Rules Rules `json:"rules"`
|
||||
}
|
||||
|
||||
@@ -1,39 +0,0 @@
|
||||
package qospolicy
|
||||
|
||||
import "sort"
|
||||
|
||||
// SortByCreatedAt sorts ListQosPolicies by the CreatedAt field in ascending order
|
||||
// If inverse param is set to true, the order is reversed
|
||||
func (lqp ListQoSPolicies) SortByCreatedAt(inverse bool) ListQoSPolicies {
|
||||
if len(lqp.Data) < 2 {
|
||||
return lqp
|
||||
}
|
||||
|
||||
sort.Slice(lqp.Data, func(i, j int) bool {
|
||||
if inverse {
|
||||
return lqp.Data[i].CreatedAt > lqp.Data[j].CreatedAt
|
||||
}
|
||||
|
||||
return lqp.Data[i].CreatedAt < lqp.Data[j].CreatedAt
|
||||
})
|
||||
|
||||
return lqp
|
||||
}
|
||||
|
||||
// SortByUpdatedAt sorts ListQosPolicies by the UpdatedAt field in ascending order
|
||||
// If inverse param is set to true, the order is reversed
|
||||
func (lqp ListQoSPolicies) SortByUpdatedAt(inverse bool) ListQoSPolicies {
|
||||
if len(lqp.Data) < 2 {
|
||||
return lqp
|
||||
}
|
||||
|
||||
sort.Slice(lqp.Data, func(i, j int) bool {
|
||||
if inverse {
|
||||
return lqp.Data[i].UpdatedAt > lqp.Data[j].UpdatedAt
|
||||
}
|
||||
|
||||
return lqp.Data[i].UpdatedAt < lqp.Data[j].UpdatedAt
|
||||
})
|
||||
|
||||
return lqp
|
||||
}
|
||||
Reference in New Issue
Block a user