v1.5.0-delta

This commit is contained in:
Никита Сорокин
2023-07-13 15:28:07 +03:00
parent 7c787f6fce
commit 5025a17ea4
71 changed files with 1602 additions and 936 deletions

View File

@@ -16,7 +16,7 @@ type AffinityGroupsListRequest struct {
}
// 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)
if err != nil {
for _, validationError := range validators.GetErrors(err) {
@@ -31,12 +31,12 @@ func (r RG) AffinityGroupsList(ctx context.Context, req AffinityGroupsListReques
return nil, err
}
list := make(map[string][]uint64)
list := ListAffinityGroup{}
err = json.Unmarshal(res, &list)
if err != nil {
return nil, err
}
return list, nil
return &list, nil
}

View File

@@ -67,21 +67,23 @@ func (lrg ListRG) FilterByDefNetID(defNetID int64) ListRG {
func (lrg ListRG) FilterFunc(predicate func(ItemRG) bool) ListRG {
var result ListRG
for _, item := range lrg {
for _, item := range lrg.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 ItemRG.
// If none was found, returns an empty struct.
func (lrg ListRG) FindOne() ItemRG {
if len(lrg) == 0 {
if len(lrg.Data) == 0 {
return ItemRG{}
}
return lrg[0]
return lrg.Data[0]
}

View File

@@ -3,140 +3,143 @@ package rg
import "testing"
var rgs = ListRG{
{
AccountID: 1,
AccountName: "std",
ACL: []ACL{
{
Explicit: true,
GUID: "",
Right: "ARCXDU",
Status: "CONFIRMED",
Type: "U",
UserGroupID: "sample_user_1@decs3o",
Data: []ItemRG{
{
AccountID: 1,
AccountName: "std",
ACL: []ACL{
{
Explicit: true,
GUID: "",
Right: "ARCXDU",
Status: "CONFIRMED",
Type: "U",
UserGroupID: "sample_user_1@decs3o",
},
},
},
CreatedBy: "sample_user_1@decs3o",
CreatedTime: 1676645305,
DefNetID: 1,
DefNetType: "NONE",
DeletedBy: "",
DeletedTime: 0,
Description: "",
GID: 212,
GUID: 7971,
ID: 7971,
LockStatus: "UNLOCKED",
Milestones: 363459,
Name: "rg_1",
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: 2,
AccountName: "std_2",
ACL: []ACL{
{
Explicit: true,
GUID: "",
Right: "ARCXDU",
Status: "CONFIRMED",
Type: "U",
UserGroupID: "sample_user_1@decs3o",
CreatedBy: "sample_user_1@decs3o",
CreatedTime: 1676645305,
DefNetID: 1,
DefNetType: "NONE",
DeletedBy: "",
DeletedTime: 0,
Description: "",
GID: 212,
GUID: 7971,
ID: 7971,
LockStatus: "UNLOCKED",
Milestones: 363459,
Name: "rg_1",
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_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{},
},
{
AccountID: 3,
AccountName: "std_3",
ACL: []ACL{
{
Explicit: true,
GUID: "",
Right: "ARCXDU",
Status: "CONFIRMED",
Type: "U",
UserGroupID: "sample_user_2@decs3o",
{
AccountID: 2,
AccountName: "std_2",
ACL: []ACL{
{
Explicit: true,
GUID: "",
Right: "ARCXDU",
Status: "CONFIRMED",
Type: "U",
UserGroupID: "sample_user_1@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,
DefNetID: 3,
DefNetType: "NONE",
DeletedBy: "",
DeletedTime: 0,
Description: "",
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,
{
AccountID: 3,
AccountName: "std_3",
ACL: []ACL{
{
Explicit: true,
GUID: "",
Right: "ARCXDU",
Status: "CONFIRMED",
Type: "U",
UserGroupID: "sample_user_2@decs3o",
},
},
CreatedBy: "sample_user_2@decs3o",
CreatedTime: 1676645548,
DefNetID: 3,
DefNetType: "NONE",
DeletedBy: "",
DeletedTime: 0,
Description: "",
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) {
@@ -158,11 +161,11 @@ func TestFilterByName(t *testing.T) {
func TestFilterByCreatedBy(t *testing.T) {
actual := rgs.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)
}
@@ -172,11 +175,11 @@ func TestFilterByCreatedBy(t *testing.T) {
func TestFilterByStatus(t *testing.T) {
actual := rgs.FilterByStatus("CREATED")
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 != "CREATED" {
t.Fatal("expected Status 'ENABLED', found: ", item.Status)
}
@@ -186,11 +189,11 @@ func TestFilterByStatus(t *testing.T) {
func TestFilterByLockStatus(t *testing.T) {
actual := rgs.FilterByLockStatus("UNLOCKED")
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.LockStatus != "UNLOCKED" {
t.Fatal("expected LockStatus 'UNLOCKED', found: ", item.LockStatus)
}
@@ -200,11 +203,11 @@ func TestFilterByLockStatus(t *testing.T) {
func TestFilterByDefNetType(t *testing.T) {
actual := rgs.FilterByDefNetType("NONE")
if len(actual) != 3 {
t.Fatal("expected 3 found, actual: ", len(actual))
if len(actual.Data) != 3 {
t.Fatal("expected 3 found, actual: ", len(actual.Data))
}
for _, item := range actual {
for _, item := range actual.Data {
if item.DefNetType != "NONE" {
t.Fatal("expected DefNetType 'NONE', found: ", item.DefNetType)
}
@@ -224,11 +227,11 @@ func TestFilterFunc(t *testing.T) {
return len(ir.VMs) > 0
})
if len(actual) < 1 {
t.Fatal("expected 1 found, actual: ", len(actual))
if len(actual.Data) < 1 {
t.Fatal("expected 1 found, actual: ", len(actual.Data))
}
for _, item := range actual {
for _, item := range actual.Data {
if len(item.VMs) < 1 {
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) {
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")
}
}

View 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
}

View File

@@ -8,6 +8,34 @@ import (
// Request struct for get list of resource groups
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
// Required: false
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
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"
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 list, nil
return &list, nil
}

View File

@@ -14,13 +14,49 @@ type ListComputesRequest struct {
// Required: true
RGID uint64 `url:"rgId" json:"rgId" validate:"required"`
// Reason for action
// Find by compute id
// 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
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)
if err != nil {
for _, validationError := range validators.GetErrors(err) {
@@ -42,5 +78,5 @@ func (r RG) ListComputes(ctx context.Context, req ListComputesRequest) (ListComp
return nil, err
}
return list, nil
return &list, nil
}

View File

@@ -8,6 +8,34 @@ import (
// Request struct for get list deleted resource groups
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
// Required: false
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
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"
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 list, nil
return &list, nil
}

View File

@@ -13,10 +13,46 @@ type ListLBRequest struct {
// Resource group ID
// Required: true
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
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)
if err != nil {
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 list, nil
return &list, nil
}

View File

@@ -16,7 +16,7 @@ type ListPFWRequest struct {
}
// 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)
if err != nil {
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 list, nil
return &list, nil
}

View 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
}

View File

@@ -14,13 +14,33 @@ type ListVINSRequest struct {
// Required: true
RGID uint64 `url:"rgId" json:"rgId" validate:"required"`
// Reason for action
// Find by name
// 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
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)
if err != nil {
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 list, nil
return &list, nil
}

View File

@@ -30,7 +30,7 @@ type Reservation struct {
DiskSize float64 `json:"disksize"`
// Max disk size
DiskSizeMax uint64 `json:"disksizemax"`
DiskSizeMax float64 `json:"disksizemax"`
// External IPs
ExtIPs int64 `json:"extips"`
@@ -54,16 +54,26 @@ type DiskUsage struct {
DiskSize float64 `json:"disksize"`
// Disk size max
DiskSizeMax uint64 `json:"disksizemax"`
DiskSizeMax float64 `json:"disksizemax"`
}
// Resources usage information
type Resources struct {
type ItemResourceConsumption struct {
// Current information
Current Reservation `json:"Current"`
Consumed Reservation `json:"Consumed"`
// Reserved information
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
@@ -98,6 +108,9 @@ type ResourceLimits struct {
// CUD
CuD float64 `json:"CU_D"`
// CUDM
CUDM float64 `json:"CU_DM"`
// CUI
CUI float64 `json:"CU_I"`
@@ -113,9 +126,6 @@ type ResourceLimits struct {
// Detailed information about resource group
type RecordRG struct {
// Resource information
Resources Resources `json:"Resources"`
// Main information about resource group
ItemRG
}
@@ -158,6 +168,9 @@ type ItemRG struct {
// Description
Description string `json:"desc"`
// Dirty
Dirty bool `json:"dirty"`
// Grid ID
GID uint64 `json:"gid"`
@@ -208,7 +221,13 @@ type ItemRG struct {
}
// 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
type ItemAffinityGroupCompute struct {
@@ -337,7 +356,13 @@ type ItemCompute struct {
}
// List computes
type ListComputes []ItemCompute
type ListComputes struct {
// Data
Data []ItemCompute `json:"data"`
// Entry count
EntryCount uint64 `json:"entryCount"`
}
// Main information about VINS
type ItemVINS struct {
@@ -394,7 +419,13 @@ type ItemVINS struct {
}
// List VINSes
type ListVINS []ItemVINS
type ListVINS struct {
// Data
Data []ItemVINS `json:"data"`
// Entry count
EntryCount uint64 `json:"entryCount"`
}
// Main information about port forward
type ItemPFW struct {
@@ -424,7 +455,13 @@ type ItemPFW struct {
}
// List PFWs
type ListPFW []ItemPFW
type ListPFW struct {
// Data
Data []ItemPFW `json:"data"`
// Entry count
EntryCount uint64 `json:"entryCount"`
}
// Server settings
type ServerSettings struct {
@@ -640,4 +677,18 @@ type ItemLB struct {
}
// 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"`
}

View File

@@ -12,7 +12,7 @@ import (
// - First argument -> prefix
// - Second argument -> indent
func (lrg ListRG) Serialize(params ...string) (serialization.Serialized, error) {
if len(lrg) == 0 {
if len(lrg.Data) == 0 {
return []byte{}, nil
}

View File

@@ -6,16 +6,16 @@ import "sort"
//
// If inverse param is set to true, the order is reversed.
func (lrg ListRG) SortByCreatedTime(inverse bool) ListRG {
if len(lrg) < 2 {
if len(lrg.Data) < 2 {
return lrg
}
sort.Slice(lrg, func(i, j int) bool {
sort.Slice(lrg.Data, func(i, j int) bool {
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
@@ -25,16 +25,16 @@ func (lrg ListRG) SortByCreatedTime(inverse bool) ListRG {
//
// If inverse param is set to true, the order is reversed.
func (lrg ListRG) SortByUpdatedTime(inverse bool) ListRG {
if len(lrg) < 2 {
if len(lrg.Data) < 2 {
return lrg
}
sort.Slice(lrg, func(i, j int) bool {
sort.Slice(lrg.Data, func(i, j int) bool {
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
@@ -44,16 +44,16 @@ func (lrg ListRG) SortByUpdatedTime(inverse bool) ListRG {
//
// If inverse param is set to true, the order is reversed.
func (lrg ListRG) SortByDeletedTime(inverse bool) ListRG {
if len(lrg) < 2 {
if len(lrg.Data) < 2 {
return lrg
}
sort.Slice(lrg, func(i, j int) bool {
sort.Slice(lrg.Data, func(i, j int) bool {
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