v1.5.0-gamma2
This commit is contained in:
@@ -62,7 +62,7 @@ func (la ListAccounts) FilterFunc(predicate func(ItemAccount) bool) ListAccounts
|
||||
// FindOne returns first found ItemAccount.
|
||||
// If none was found, returns an empty struct.
|
||||
func (la ListAccounts) FindOne() ItemAccount {
|
||||
if la.EntryCount == 0 {
|
||||
if len(la.Data) == 0 {
|
||||
return ItemAccount{}
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ type ListRequest struct {
|
||||
|
||||
// Find by name
|
||||
// Required: false
|
||||
Name string `urL:"name,omitempty" json:"name,omitempty"`
|
||||
Name string `url:"name,omitempty" json:"name,omitempty"`
|
||||
|
||||
// Find by access control list
|
||||
// Required: false
|
||||
|
||||
@@ -13,10 +13,50 @@ type ListComputesRequest struct {
|
||||
// ID an account
|
||||
// Required: true
|
||||
AccountID uint64 `url:"accountId" json:"accountId" validate:"required"`
|
||||
|
||||
// Find by compute id
|
||||
// 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 resource group name
|
||||
// Required: false
|
||||
RGName string `url:"rgName,omitempty" json:"rgName,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 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 all compute instances under specified account, accessible by the user
|
||||
func (a Account) ListComputes(ctx context.Context, req ListComputesRequest) (ListComputes, error) {
|
||||
func (a Account) ListComputes(ctx context.Context, req ListComputesRequest) (*ListComputes, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
for _, validationError := range validators.GetErrors(err) {
|
||||
@@ -38,5 +78,5 @@ func (a Account) ListComputes(ctx context.Context, req ListComputesRequest) (Lis
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return list, nil
|
||||
return &list, nil
|
||||
}
|
||||
|
||||
@@ -15,6 +15,18 @@ type ListDeletedRequest struct {
|
||||
// Page size
|
||||
// Required: false
|
||||
Size uint64 `url:"size,omitempty" json:"size,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 access control list
|
||||
// Required: false
|
||||
ACL string `url:"acl,omitempty" json:"acl,omitempty"`
|
||||
}
|
||||
|
||||
// ListDeleted gets list all deleted accounts the user has access to
|
||||
|
||||
@@ -13,10 +13,34 @@ type ListDisksRequest struct {
|
||||
// ID an account
|
||||
// Required: true
|
||||
AccountID uint64 `url:"accountId" json:"accountId" validate:"required"`
|
||||
|
||||
// Find by disk id
|
||||
// Required: false
|
||||
DiskID uint64 `url:"diskId,omitempty" json:"diskId,omitempty"`
|
||||
|
||||
// Find by name
|
||||
// Required: false
|
||||
Name string `url:"name,omitempty" json:"name,omitempty"`
|
||||
|
||||
// Find by max size disk
|
||||
// Required: false
|
||||
DiskMaxSize uint64 `url:"diskMaxSize,omitempty" json:"diskMaxSize,omitempty"`
|
||||
|
||||
// Type of the disks
|
||||
// Required: false
|
||||
Type string `url:"type,omitempty" json:"type,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"`
|
||||
}
|
||||
|
||||
// ListDisks gets list all currently unattached disks under specified account
|
||||
func (a Account) ListDisks(ctx context.Context, req ListDisksRequest) (ListDisks, error) {
|
||||
func (a Account) ListDisks(ctx context.Context, req ListDisksRequest) (*ListDisks, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
for _, validationError := range validators.GetErrors(err) {
|
||||
@@ -38,5 +62,5 @@ func (a Account) ListDisks(ctx context.Context, req ListDisksRequest) (ListDisks
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return list, nil
|
||||
return &list, nil
|
||||
}
|
||||
|
||||
@@ -10,13 +10,45 @@ import (
|
||||
|
||||
// Request struct for get list FLIPGroups
|
||||
type ListFLIPGroupsRequest struct {
|
||||
// ID an account
|
||||
// ID of the account
|
||||
// Required: true
|
||||
AccountID uint64 `url:"accountId" json:"accountId" validate:"required"`
|
||||
|
||||
// Find by name
|
||||
// Required: false
|
||||
Name string `url:"name,omitempty" json:"name,omitempty"`
|
||||
|
||||
// Find by vinsId
|
||||
// Required: false
|
||||
VINSID uint64 `url:"vinsId,omitempty" json:"vinsId,omitempty"`
|
||||
|
||||
// Find by VINS name
|
||||
// Required: false
|
||||
VINSName string `url:"vinsName,omitempty" json:"vinsName,omitempty"`
|
||||
|
||||
// Find by external network id
|
||||
// Required: false
|
||||
ExtNetID uint64 `url:"extnetId,omitempty" json:"extnetId,omitempty"`
|
||||
|
||||
// Find by IP
|
||||
// Required: false
|
||||
ByIP string `url:"byIp,omitempty" json:"byIp,omitempty"`
|
||||
|
||||
// Find by flipGroup Id
|
||||
// Required: false
|
||||
FLIPGroupID uint64 `url:"flipGroupId,omitempty" json:"flipGroupId,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"`
|
||||
}
|
||||
|
||||
// ListFLIPGroups gets list all FLIPGroups under specified account, accessible by the user
|
||||
func (a Account) ListFLIPGroups(ctx context.Context, req ListFLIPGroupsRequest) (ListFLIPGroups, error) {
|
||||
func (a Account) ListFLIPGroups(ctx context.Context, req ListFLIPGroupsRequest) (*ListFLIPGroups, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
for _, validationError := range validators.GetErrors(err) {
|
||||
@@ -38,5 +70,5 @@ func (a Account) ListFLIPGroups(ctx context.Context, req ListFLIPGroupsRequest)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return list, nil
|
||||
return &list, nil
|
||||
}
|
||||
|
||||
@@ -13,10 +13,38 @@ type ListRGRequest struct {
|
||||
// ID an account
|
||||
// Required: true
|
||||
AccountID uint64 `url:"accountId" json:"accountId" validate:"required"`
|
||||
|
||||
// Page number
|
||||
// Required: false
|
||||
Page uint64 `url:"page,omitempty" json:"page,omitempty"`
|
||||
|
||||
// Page size
|
||||
// Required: false
|
||||
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
||||
|
||||
// Find by resource group id
|
||||
// Required: false
|
||||
RGID uint64 `url:"rgId,omitempty" json:"rgId,omitempty"`
|
||||
|
||||
// Find by name
|
||||
// Required: false
|
||||
Name string `url:"name,omitempty" json:"name,omitempty"`
|
||||
|
||||
// Find by vinsId
|
||||
// Required: false
|
||||
VINSID uint64 `url:"vinsId,omitempty" json:"vinsId,omitempty"`
|
||||
|
||||
// Find by VM ID
|
||||
// Required: false
|
||||
VMID uint64 `url:"vmId,omitempty" json:"vmId,omitempty"`
|
||||
|
||||
// Find by status
|
||||
// Required: false
|
||||
Status string `url:"status,omitempty" json:"status,omitempty"`
|
||||
}
|
||||
|
||||
// ListRG gets list all resource groups under specified account, accessible by the user
|
||||
func (a Account) ListRG(ctx context.Context, req ListRGRequest) (ListRG, error) {
|
||||
func (a Account) ListRG(ctx context.Context, req ListRGRequest) (*ListRG, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
for _, validationError := range validators.GetErrors(err) {
|
||||
@@ -38,5 +66,5 @@ func (a Account) ListRG(ctx context.Context, req ListRGRequest) (ListRG, error)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return list, nil
|
||||
return &list, nil
|
||||
}
|
||||
|
||||
@@ -13,10 +13,34 @@ type ListVINSRequest struct {
|
||||
// ID an account
|
||||
// Required: true
|
||||
AccountID uint64 `url:"accountId" json:"accountId" validate:"required"`
|
||||
|
||||
// Find by VINS ID
|
||||
// Required: false
|
||||
VINSID uint64 `url:"vins,omitempty" json:"vinsId,omitempty"`
|
||||
|
||||
// Find by name
|
||||
// Required: false
|
||||
Name string `url:"name,omitempty" json:"name,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"`
|
||||
|
||||
// Page size
|
||||
// Required: false
|
||||
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
||||
}
|
||||
|
||||
// ListVINS gets list all ViNSes under specified account, accessible by the user
|
||||
func (a Account) ListVINS(ctx context.Context, req ListVINSRequest) (ListVINS, error) {
|
||||
func (a Account) ListVINS(ctx context.Context, req ListVINSRequest) (*ListVINS, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
for _, validationError := range validators.GetErrors(err) {
|
||||
@@ -38,5 +62,5 @@ func (a Account) ListVINS(ctx context.Context, req ListVINSRequest) (ListVINS, e
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return list, nil
|
||||
return &list, nil
|
||||
}
|
||||
|
||||
@@ -112,7 +112,7 @@ type DiskUsage struct {
|
||||
DiskSize float64 `json:"disksize"`
|
||||
|
||||
// Disk size max
|
||||
DiskSizeMax uint64 `json:"disksizemax"`
|
||||
DiskSizeMax float64 `json:"disksizemax"`
|
||||
}
|
||||
|
||||
// Information about resources
|
||||
@@ -299,7 +299,13 @@ type ItemCompute struct {
|
||||
}
|
||||
|
||||
// List of computes
|
||||
type ListComputes []ItemCompute
|
||||
type ListComputes struct {
|
||||
// Data
|
||||
Data []ItemCompute `json:"data"`
|
||||
|
||||
// Entry count
|
||||
EntryCount uint64 `json:"entryCount"`
|
||||
}
|
||||
|
||||
// Main information about disk
|
||||
type ItemDisk struct {
|
||||
@@ -326,7 +332,13 @@ type ItemDisk struct {
|
||||
}
|
||||
|
||||
// List of disks
|
||||
type ListDisks []ItemDisk
|
||||
type ListDisks struct {
|
||||
// Data
|
||||
Data []ItemDisk `json:"data"`
|
||||
|
||||
// Entry count
|
||||
EntryCount uint64 `json:"entryCount"`
|
||||
}
|
||||
|
||||
// Main information about VINS
|
||||
type ItemVINS struct {
|
||||
@@ -383,7 +395,13 @@ type ItemVINS struct {
|
||||
}
|
||||
|
||||
// List of VINS
|
||||
type ListVINS []ItemVINS
|
||||
type ListVINS struct {
|
||||
// Data
|
||||
Data []ItemVINS `json:"data"`
|
||||
|
||||
// Entry count
|
||||
EntryCount uint64 `json:"entryCount"`
|
||||
}
|
||||
|
||||
// Main info about audit
|
||||
type ItemAudit struct {
|
||||
@@ -497,7 +515,13 @@ type ItemRG struct {
|
||||
}
|
||||
|
||||
// List of Resource groups
|
||||
type ListRG []ItemRG
|
||||
type ListRG struct {
|
||||
// Data
|
||||
Data []ItemRG `json:"data"`
|
||||
|
||||
// Enrtry count
|
||||
EntryCount uint64 `json:"entryCount"`
|
||||
}
|
||||
|
||||
// Main information about template
|
||||
type ItemTemplate struct {
|
||||
@@ -602,4 +626,10 @@ type ItemFLIPGroup struct {
|
||||
}
|
||||
|
||||
// List of FLIPGroups
|
||||
type ListFLIPGroups []ItemFLIPGroup
|
||||
type ListFLIPGroups struct {
|
||||
// Data
|
||||
Data []ItemFLIPGroup `json:"data"`
|
||||
|
||||
// Entry count
|
||||
EntryCount uint64 `json:"entryCount"`
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
// - First argument -> prefix
|
||||
// - Second argument -> indent
|
||||
func (la ListAccounts) Serialize(params ...string) (serialization.Serialized, error) {
|
||||
if la.EntryCount == 0 {
|
||||
if len(la.Data) == 0 {
|
||||
return []byte{}, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ import "sort"
|
||||
//
|
||||
// If inverse param is set to true, the order is reversed.
|
||||
func (la ListAccounts) SortByCreatedTime(inverse bool) ListAccounts {
|
||||
if la.EntryCount < 2 {
|
||||
if len(la.Data) < 2 {
|
||||
return la
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ func (la ListAccounts) SortByCreatedTime(inverse bool) ListAccounts {
|
||||
//
|
||||
// If inverse param is set to true, the order is reversed.
|
||||
func (la ListAccounts) SortByUpdatedTime(inverse bool) ListAccounts {
|
||||
if la.EntryCount < 2 {
|
||||
if len(la.Data) < 2 {
|
||||
return la
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ func (la ListAccounts) SortByUpdatedTime(inverse bool) ListAccounts {
|
||||
//
|
||||
// If inverse param is set to true, the order is reversed.
|
||||
func (la ListAccounts) SortByDeletedTime(inverse bool) ListAccounts {
|
||||
if la.EntryCount < 2 {
|
||||
if len(la.Data) < 2 {
|
||||
return la
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,42 @@ import (
|
||||
|
||||
// Request struct for get deleted computes list
|
||||
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 name
|
||||
// Required: false
|
||||
RGName string `url:"rgName,omitempty" json:"rgName,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 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"`
|
||||
|
||||
@@ -13,10 +13,34 @@ type ListPCIDeviceRequest struct {
|
||||
// Identifier compute
|
||||
// Required: true
|
||||
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
|
||||
|
||||
// Find by resource group ID
|
||||
// Required: false
|
||||
RGID uint64 `url:"rgId,omitempty" json:"rgId,omitempty"`
|
||||
|
||||
// Find by device id
|
||||
// Required: false
|
||||
DevID uint64 `url:"devId,omitempty" json:"devId,omitempty"`
|
||||
|
||||
// Find by type
|
||||
// Required: false
|
||||
Type string `url:"type,omitempty" json:"type,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"`
|
||||
}
|
||||
|
||||
// ListPCIDevice gets list PCI device
|
||||
func (c Compute) ListPCIDevice(ctx context.Context, req ListPCIDeviceRequest) ([]interface{}, error) {
|
||||
func (c Compute) ListPCIDevice(ctx context.Context, req ListPCIDeviceRequest) (*ListPCIDevices, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
for _, validationError := range validators.GetErrors(err) {
|
||||
@@ -31,12 +55,12 @@ func (c Compute) ListPCIDevice(ctx context.Context, req ListPCIDeviceRequest) ([
|
||||
return nil, err
|
||||
}
|
||||
|
||||
list := []interface{}{}
|
||||
list := ListPCIDevices{}
|
||||
|
||||
err = json.Unmarshal(res, &list)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return list, nil
|
||||
return &list, nil
|
||||
}
|
||||
|
||||
@@ -13,10 +13,34 @@ type ListVGPURequest struct {
|
||||
// Identifier compute
|
||||
// Required: true
|
||||
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
|
||||
|
||||
// Find by GPU id
|
||||
// Required: false
|
||||
GPUID uint64 `url:"gpuId,omitempty" json:"gpuId,omitempty"`
|
||||
|
||||
// Find by type
|
||||
// Required: false
|
||||
Type string `url:"type,omitempty" json:"type,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"`
|
||||
|
||||
// Include deleted computes. If using field 'status', then includedeleted will be ignored
|
||||
// Required: false
|
||||
IncludeDeleted bool `url:"includedeleted,omitempty" json:"includedeleted,omitempty"`
|
||||
}
|
||||
|
||||
// ListVGPU gets list vGPU
|
||||
func (c Compute) ListVGPU(ctx context.Context, req ListVGPURequest) ([]interface{}, error) {
|
||||
func (c Compute) ListVGPU(ctx context.Context, req ListVGPURequest) (*ListVGPUs, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
for _, validationError := range validators.GetErrors(err) {
|
||||
@@ -24,19 +48,19 @@ func (c Compute) ListVGPU(ctx context.Context, req ListVGPURequest) ([]interface
|
||||
}
|
||||
}
|
||||
|
||||
url := "/cloudapi/compute/listVgpu"
|
||||
url := "/cloudapi/compute/listVGpu"
|
||||
|
||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
list := []interface{}{}
|
||||
list := ListVGPUs{}
|
||||
|
||||
err = json.Unmarshal(res, &list)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return list, nil
|
||||
return &list, nil
|
||||
}
|
||||
|
||||
@@ -915,3 +915,21 @@ type ListComputes struct {
|
||||
// Entry count
|
||||
EntryCount uint64 `json:"entryCount"`
|
||||
}
|
||||
|
||||
// List VGPUs
|
||||
type ListVGPUs struct {
|
||||
// Data
|
||||
Data []interface{} `json:"data"`
|
||||
|
||||
// Entry count
|
||||
EntryCount uint64 `json:"entryCount"`
|
||||
}
|
||||
|
||||
// List PCI devices
|
||||
type ListPCIDevices struct {
|
||||
// Data
|
||||
Data []interface{} `json:"data"`
|
||||
|
||||
// Entry count
|
||||
EntryCount uint64 `json:"entryCount"`
|
||||
}
|
||||
|
||||
@@ -8,6 +8,26 @@ import (
|
||||
|
||||
// Request struct for get list of deleted disks
|
||||
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 name
|
||||
// Required: false
|
||||
AccountName string `url:"accountName,omitempty" json:"accountName,omitempty"`
|
||||
|
||||
// Find by max size disk
|
||||
// Required: false
|
||||
DiskMaxSize int64 `url:"diskMaxSize,omitempty" json:"diskMaxSize,omitempty"`
|
||||
|
||||
// Find by shared, true or false
|
||||
// Required: false
|
||||
Shared bool `url:"shared,omitempty" json:"shared,omitempty"`
|
||||
|
||||
// ID of the account the disks belong to
|
||||
// Required: false
|
||||
AccountID uint64 `url:"accountId,omitempty" json:"accountId,omitempty"`
|
||||
|
||||
@@ -11,10 +11,18 @@ type ListTypesRequest struct {
|
||||
// Show detailed disk types by seps
|
||||
// Required: true
|
||||
Detailed bool `url:"detailed" json:"detailed" validate:"required"`
|
||||
|
||||
// Page number
|
||||
// Required: false
|
||||
Page uint64 `url:"page,omitempty" json:"page,omitempty"`
|
||||
|
||||
// Page size
|
||||
// Required: false
|
||||
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
||||
}
|
||||
|
||||
// ListTypes gets list defined disk types
|
||||
func (d Disks) ListTypes(ctx context.Context, req ListTypesRequest) ([]interface{}, error) {
|
||||
func (d Disks) ListTypes(ctx context.Context, req ListTypesRequest) (*ListTypes, error) {
|
||||
url := "/cloudapi/disks/listTypes"
|
||||
|
||||
res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
@@ -22,12 +30,12 @@ func (d Disks) ListTypes(ctx context.Context, req ListTypesRequest) ([]interface
|
||||
return nil, err
|
||||
}
|
||||
|
||||
list := make([]interface{}, 0)
|
||||
list := ListTypes{}
|
||||
|
||||
err = json.Unmarshal(res, &list)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return list, nil
|
||||
return &list, nil
|
||||
}
|
||||
|
||||
@@ -442,3 +442,11 @@ type RecordDisk struct {
|
||||
// Virtual machine ID
|
||||
VMID uint64 `json:"vmid"`
|
||||
}
|
||||
|
||||
type ListTypes struct {
|
||||
// Data
|
||||
Data []interface{} `json:"data"`
|
||||
|
||||
// Entry count
|
||||
EntryCount uint64 `json:"entryCount"`
|
||||
}
|
||||
|
||||
@@ -139,11 +139,8 @@ type RecordExtNet struct {
|
||||
// Meta
|
||||
Meta []interface{} `json:"_meta"`
|
||||
|
||||
// CheckIPs
|
||||
CheckIPs []string `json:"checkIPs"`
|
||||
|
||||
// CheckIps
|
||||
CheckIps []string `json:"checkIps"`
|
||||
CheckIPs []string `json:"checkIps"`
|
||||
|
||||
// Default
|
||||
Default bool `json:"default"`
|
||||
|
||||
@@ -40,21 +40,23 @@ func (li ListImages) FilterByBootType(bootType string) ListImages {
|
||||
func (li ListImages) FilterFunc(predicate func(ItemImage) bool) ListImages {
|
||||
var result ListImages
|
||||
|
||||
for _, item := range li {
|
||||
for _, item := range li.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 ItemImage
|
||||
// If none was found, returns an empty struct.
|
||||
func (li ListImages) FindOne() ItemImage {
|
||||
if len(li) == 0 {
|
||||
if len(li.Data) == 0 {
|
||||
return ItemImage{}
|
||||
}
|
||||
|
||||
return li[0]
|
||||
return li.Data[0]
|
||||
}
|
||||
|
||||
@@ -3,66 +3,69 @@ package image
|
||||
import "testing"
|
||||
|
||||
var images = ListImages{
|
||||
ItemImage{
|
||||
AccountID: 0,
|
||||
Architecture: "X86_64",
|
||||
BootType: "bios",
|
||||
Bootable: true,
|
||||
Description: "",
|
||||
Drivers: []string{
|
||||
"KVM_X86",
|
||||
Data: []ItemImage{
|
||||
{
|
||||
AccountID: 0,
|
||||
Architecture: "X86_64",
|
||||
BootType: "bios",
|
||||
Bootable: true,
|
||||
Description: "",
|
||||
Drivers: []string{
|
||||
"KVM_X86",
|
||||
},
|
||||
HotResize: true,
|
||||
ID: 9882,
|
||||
LinkTo: 0,
|
||||
Name: "u16",
|
||||
Pool: "vmstor",
|
||||
Size: 5,
|
||||
Status: "CREATED",
|
||||
Type: "linux",
|
||||
Username: "",
|
||||
Virtual: false,
|
||||
},
|
||||
HotResize: true,
|
||||
ID: 9882,
|
||||
LinkTo: 0,
|
||||
Name: "u16",
|
||||
Pool: "vmstor",
|
||||
Size: 5,
|
||||
Status: "CREATED",
|
||||
Type: "linux",
|
||||
Username: "",
|
||||
Virtual: false,
|
||||
},
|
||||
ItemImage{
|
||||
AccountID: 0,
|
||||
Architecture: "X86_64",
|
||||
BootType: "bois",
|
||||
Bootable: true,
|
||||
Description: "",
|
||||
Drivers: []string{
|
||||
"KVM_X86",
|
||||
{
|
||||
AccountID: 0,
|
||||
Architecture: "X86_64",
|
||||
BootType: "bois",
|
||||
Bootable: true,
|
||||
Description: "",
|
||||
Drivers: []string{
|
||||
"KVM_X86",
|
||||
},
|
||||
HotResize: false,
|
||||
ID: 9884,
|
||||
LinkTo: 0,
|
||||
Name: "alpine-virt-3.17",
|
||||
Pool: "vmstor",
|
||||
Size: 1,
|
||||
Status: "CREATED",
|
||||
Type: "linux",
|
||||
Username: "",
|
||||
Virtual: true,
|
||||
},
|
||||
HotResize: false,
|
||||
ID: 9884,
|
||||
LinkTo: 0,
|
||||
Name: "alpine-virt-3.17",
|
||||
Pool: "vmstor",
|
||||
Size: 1,
|
||||
Status: "CREATED",
|
||||
Type: "linux",
|
||||
Username: "",
|
||||
Virtual: true,
|
||||
},
|
||||
ItemImage{
|
||||
AccountID: 1,
|
||||
Architecture: "X86_64",
|
||||
BootType: "bios",
|
||||
Bootable: true,
|
||||
Description: "",
|
||||
Drivers: []string{
|
||||
"KVM_X86",
|
||||
{
|
||||
AccountID: 1,
|
||||
Architecture: "X86_64",
|
||||
BootType: "bios",
|
||||
Bootable: true,
|
||||
Description: "",
|
||||
Drivers: []string{
|
||||
"KVM_X86",
|
||||
},
|
||||
HotResize: true,
|
||||
ID: 9885,
|
||||
LinkTo: 0,
|
||||
Name: "test",
|
||||
Pool: "vmstor",
|
||||
Size: 4,
|
||||
Status: "DESTROYED",
|
||||
Type: "linux",
|
||||
Username: "",
|
||||
Virtual: false,
|
||||
},
|
||||
HotResize: true,
|
||||
ID: 9885,
|
||||
LinkTo: 0,
|
||||
Name: "test",
|
||||
Pool: "vmstor",
|
||||
Size: 4,
|
||||
Status: "DESTROYED",
|
||||
Type: "linux",
|
||||
Username: "",
|
||||
Virtual: false,
|
||||
},
|
||||
EntryCount: 3,
|
||||
}
|
||||
|
||||
func TestFilterByID(t *testing.T) {
|
||||
@@ -84,11 +87,11 @@ func TestFilterByName(t *testing.T) {
|
||||
func TestFilterByStatus(t *testing.T) {
|
||||
actual := images.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 'CREATED', found: ", item.Status)
|
||||
}
|
||||
@@ -98,11 +101,11 @@ func TestFilterByStatus(t *testing.T) {
|
||||
func TestFilterByBootType(t *testing.T) {
|
||||
actual := images.FilterByBootType("bios")
|
||||
|
||||
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.BootType != "bios" {
|
||||
t.Fatal("expected BootType 'bios', found: ", item.BootType)
|
||||
}
|
||||
@@ -110,15 +113,15 @@ func TestFilterByBootType(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestFilterFunc(t *testing.T) {
|
||||
actual := images.FilterFunc(func(ii ItemImage) bool {
|
||||
return ii.Virtual == true
|
||||
})
|
||||
actual := images.FilterFunc(func(ii ItemImage) bool {
|
||||
return ii.Virtual == true
|
||||
})
|
||||
|
||||
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))
|
||||
}
|
||||
|
||||
if actual[0].Virtual != true {
|
||||
if actual.Data[0].Virtual != true {
|
||||
t.Fatal("expected Virtual true, found false")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,9 +8,53 @@ import (
|
||||
|
||||
// Request struct for get list available images
|
||||
type ListRequest struct {
|
||||
// Optional account ID to include account images
|
||||
// Find by storage endpoint provider ID
|
||||
// Required: false
|
||||
AccountID uint64 `url:"accountId,omitempty" json:"accountId,omitempty"`
|
||||
SEPID uint64 `url:"sepId,omitempty" json:"sepId,omitempty"`
|
||||
|
||||
// Find by id
|
||||
// Required: false
|
||||
ByID uint64 `url:"by_id,omitempty" json:"by_id,omitempty"`
|
||||
|
||||
// Find by ID
|
||||
// Required: false
|
||||
Name string `url:"name,omitempty" json:"name,omitempty"`
|
||||
|
||||
// Find by status
|
||||
// Required: false
|
||||
Status string `url:"status,omitempty" json:"status,omitempty"`
|
||||
|
||||
// Find by architecture
|
||||
// Required: false
|
||||
Architecture string `url:"architecture,omitempty" json:"architecture,omitempty"`
|
||||
|
||||
// Find by type
|
||||
// Required: false
|
||||
TypeImage string `url:"typeImage,omitempty" json:"typeImage,omitempty"`
|
||||
|
||||
// Find by image size
|
||||
// Required: false
|
||||
ImageSize uint64 `url:"imageSize,omitempty" json:"imageSize,omitempty"`
|
||||
|
||||
// Find by SEP name
|
||||
// Required: false
|
||||
SEPName string `url:"sepName,omitempty" json:"sepName,omitempty"`
|
||||
|
||||
// Find by pool
|
||||
// Required: false
|
||||
Pool string `url:"pool,omitempty" json:"pool,omitempty"`
|
||||
|
||||
// Find by public True or False
|
||||
// Required: false
|
||||
Public bool `url:"public,omitempty" json:"public,omitempty"`
|
||||
|
||||
// Find by hot resize True or False
|
||||
// Required: false
|
||||
HotResize bool `url:"hotResize,omitempty" json:"hotResize,omitempty"`
|
||||
|
||||
// Find by bootable True or False
|
||||
// Required: false
|
||||
Bootable bool `url:"bootable,omitempty" json:"bootable,omitempty"`
|
||||
|
||||
// Page number
|
||||
// Required: false
|
||||
@@ -22,7 +66,7 @@ type ListRequest struct {
|
||||
}
|
||||
|
||||
// List gets list available images, optionally filtering by account ID
|
||||
func (i Image) List(ctx context.Context, req ListRequest) (ListImages, error) {
|
||||
func (i Image) List(ctx context.Context, req ListRequest) (*ListImages, error) {
|
||||
url := "/cloudapi/image/list"
|
||||
|
||||
res, err := i.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
@@ -37,5 +81,5 @@ func (i Image) List(ctx context.Context, req ListRequest) (ListImages, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return list, nil
|
||||
return &list, nil
|
||||
}
|
||||
|
||||
@@ -58,7 +58,13 @@ type ItemImage struct {
|
||||
}
|
||||
|
||||
// List of information about images
|
||||
type ListImages []ItemImage
|
||||
type ListImages struct {
|
||||
// Data
|
||||
Data []ItemImage `json:"data"`
|
||||
|
||||
// Entry count
|
||||
EntryCount uint64 `json:"entryCount"`
|
||||
}
|
||||
|
||||
// History
|
||||
type History struct {
|
||||
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
// - First argument -> prefix
|
||||
// - Second argument -> indent
|
||||
func (li ListImages) Serialize(params ...string) (serialization.Serialized, error) {
|
||||
if len(li) == 0 {
|
||||
if len(li.Data) == 0 {
|
||||
return []byte{}, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,26 @@ import (
|
||||
|
||||
// Request struct for get list information about deleted images
|
||||
type ListDeletedRequest struct {
|
||||
// Find by ID
|
||||
// Required: false
|
||||
ByID uint64 `url:"k8cId,omitempty" json:"k8cId,omitempty"`
|
||||
|
||||
// Find by name
|
||||
// Required: false
|
||||
Name string `url:"name,omitempty" json:"name,omitempty"`
|
||||
|
||||
// Find by worker driver
|
||||
// Required: false
|
||||
WorkerDriver string `url:"workerDriver,omitempty" json:"workerDriver,omitempty"`
|
||||
|
||||
// Find by master driver
|
||||
// Required: false
|
||||
MasterDriver string `url:"masterDriver,omitempty" json:"masterDriver,omitempty"`
|
||||
|
||||
// Find by network plugin
|
||||
// Required: false
|
||||
NetworkPlugins string `url:"netPlugins,omitempty" json:"netPlugins,omitempty"`
|
||||
|
||||
// Page number
|
||||
// Required: false
|
||||
Page uint64 `url:"page,omitempty" json:"page,omitempty"`
|
||||
|
||||
@@ -76,21 +76,23 @@ func (lkc ListK8SClusters) FilterByDeletedBy(deletedBy string) ListK8SClusters {
|
||||
func (lkc ListK8SClusters) FilterFunc(predicate func(ItemK8SCluster) bool) ListK8SClusters {
|
||||
var result ListK8SClusters
|
||||
|
||||
for _, item := range lkc {
|
||||
for _, item := range lkc.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 ItemK8SCluster
|
||||
// If none was found, returns an empty struct.
|
||||
func (lkc ListK8SClusters) FindOne() ItemK8SCluster {
|
||||
if len(lkc) == 0 {
|
||||
if len(lkc.Data) == 0 {
|
||||
return ItemK8SCluster{}
|
||||
}
|
||||
|
||||
return lkc[0]
|
||||
return lkc.Data[0]
|
||||
}
|
||||
|
||||
@@ -3,86 +3,88 @@ package k8s
|
||||
import "testing"
|
||||
|
||||
var k8sItems = ListK8SClusters{
|
||||
ItemK8SCluster{
|
||||
AccountID: 1,
|
||||
AccountName: "test_1",
|
||||
ACL: []interface{}{},
|
||||
BServiceID: 1,
|
||||
CIID: 1,
|
||||
Config: nil,
|
||||
CreatedBy: "test_user",
|
||||
CreatedTime: 132454563,
|
||||
DeletedBy: "",
|
||||
DeletedTime: 0,
|
||||
Description: "",
|
||||
ExtNetID: 1,
|
||||
GID: 0,
|
||||
GUID: 1,
|
||||
ID: 1,
|
||||
LBID: 1,
|
||||
Milestones: 999999,
|
||||
Name: "k8s_1",
|
||||
RGID: 1,
|
||||
RGName: "rg_1",
|
||||
Status: "ENABLED",
|
||||
TechStatus: "STARTED",
|
||||
UpdatedBy: "",
|
||||
UpdatedTime: 0,
|
||||
VINSID: 0,
|
||||
},
|
||||
ItemK8SCluster{
|
||||
AccountID: 2,
|
||||
AccountName: "test_2",
|
||||
ACL: []interface{}{},
|
||||
BServiceID: 2,
|
||||
CIID: 2,
|
||||
Config: nil,
|
||||
CreatedBy: "test_user",
|
||||
CreatedTime: 132454638,
|
||||
DeletedBy: "",
|
||||
DeletedTime: 0,
|
||||
Description: "",
|
||||
ExtNetID: 2,
|
||||
GID: 0,
|
||||
GUID: 2,
|
||||
ID: 2,
|
||||
LBID: 2,
|
||||
Milestones: 999999,
|
||||
Name: "k8s_2",
|
||||
RGID: 2,
|
||||
RGName: "rg_2",
|
||||
Status: "ENABLED",
|
||||
TechStatus: "STARTED",
|
||||
UpdatedBy: "",
|
||||
UpdatedTime: 0,
|
||||
VINSID: 0,
|
||||
},
|
||||
ItemK8SCluster{
|
||||
AccountID: 3,
|
||||
AccountName: "test_3",
|
||||
ACL: []interface{}{},
|
||||
BServiceID: 3,
|
||||
CIID: 3,
|
||||
Config: nil,
|
||||
CreatedBy: "test_user",
|
||||
CreatedTime: 132454682,
|
||||
DeletedBy: "",
|
||||
DeletedTime: 0,
|
||||
Description: "",
|
||||
ExtNetID: 3,
|
||||
GID: 0,
|
||||
GUID: 3,
|
||||
ID: 3,
|
||||
LBID: 3,
|
||||
Milestones: 999999,
|
||||
Name: "k8s_3",
|
||||
RGID: 3,
|
||||
RGName: "rg_3",
|
||||
Status: "DISABLED",
|
||||
TechStatus: "STOPPED",
|
||||
UpdatedBy: "",
|
||||
UpdatedTime: 0,
|
||||
VINSID: 0,
|
||||
Data: []ItemK8SCluster{
|
||||
{
|
||||
AccountID: 1,
|
||||
AccountName: "test_1",
|
||||
ACL: []interface{}{},
|
||||
BServiceID: 1,
|
||||
CIID: 1,
|
||||
Config: nil,
|
||||
CreatedBy: "test_user",
|
||||
CreatedTime: 132454563,
|
||||
DeletedBy: "",
|
||||
DeletedTime: 0,
|
||||
Description: "",
|
||||
ExtNetID: 1,
|
||||
GID: 0,
|
||||
GUID: 1,
|
||||
ID: 1,
|
||||
LBID: 1,
|
||||
Milestones: 999999,
|
||||
Name: "k8s_1",
|
||||
RGID: 1,
|
||||
RGName: "rg_1",
|
||||
Status: "ENABLED",
|
||||
TechStatus: "STARTED",
|
||||
UpdatedBy: "",
|
||||
UpdatedTime: 0,
|
||||
VINSID: 0,
|
||||
},
|
||||
{
|
||||
AccountID: 2,
|
||||
AccountName: "test_2",
|
||||
ACL: []interface{}{},
|
||||
BServiceID: 2,
|
||||
CIID: 2,
|
||||
Config: nil,
|
||||
CreatedBy: "test_user",
|
||||
CreatedTime: 132454638,
|
||||
DeletedBy: "",
|
||||
DeletedTime: 0,
|
||||
Description: "",
|
||||
ExtNetID: 2,
|
||||
GID: 0,
|
||||
GUID: 2,
|
||||
ID: 2,
|
||||
LBID: 2,
|
||||
Milestones: 999999,
|
||||
Name: "k8s_2",
|
||||
RGID: 2,
|
||||
RGName: "rg_2",
|
||||
Status: "ENABLED",
|
||||
TechStatus: "STARTED",
|
||||
UpdatedBy: "",
|
||||
UpdatedTime: 0,
|
||||
VINSID: 0,
|
||||
},
|
||||
{
|
||||
AccountID: 3,
|
||||
AccountName: "test_3",
|
||||
ACL: []interface{}{},
|
||||
BServiceID: 3,
|
||||
CIID: 3,
|
||||
Config: nil,
|
||||
CreatedBy: "test_user",
|
||||
CreatedTime: 132454682,
|
||||
DeletedBy: "",
|
||||
DeletedTime: 0,
|
||||
Description: "",
|
||||
ExtNetID: 3,
|
||||
GID: 0,
|
||||
GUID: 3,
|
||||
ID: 3,
|
||||
LBID: 3,
|
||||
Milestones: 999999,
|
||||
Name: "k8s_3",
|
||||
RGID: 3,
|
||||
RGName: "rg_3",
|
||||
Status: "DISABLED",
|
||||
TechStatus: "STOPPED",
|
||||
UpdatedBy: "",
|
||||
UpdatedTime: 0,
|
||||
VINSID: 0,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
@@ -121,11 +123,11 @@ func TestFilterByRGID(t *testing.T) {
|
||||
func TestFilterByStatus(t *testing.T) {
|
||||
actual := k8sItems.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)
|
||||
}
|
||||
@@ -135,11 +137,11 @@ func TestFilterByStatus(t *testing.T) {
|
||||
func TestFilterByTechStatus(t *testing.T) {
|
||||
actual := k8sItems.FilterByTechStatus("STARTED")
|
||||
|
||||
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.TechStatus != "STARTED" {
|
||||
t.Fatal("expected TechStatus 'STARTED', found: ", item.TechStatus)
|
||||
}
|
||||
@@ -149,11 +151,11 @@ func TestFilterByTechStatus(t *testing.T) {
|
||||
func TestFilterByCreatedBy(t *testing.T) {
|
||||
actual := k8sItems.FilterByCreatedBy("test_user")
|
||||
|
||||
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.CreatedBy != "test_user" {
|
||||
t.Fatal("expected CreatedBy 'test_user', found: ", item.CreatedBy)
|
||||
}
|
||||
@@ -163,8 +165,8 @@ func TestFilterByCreatedBy(t *testing.T) {
|
||||
func TestFilterByDeletedBy(t *testing.T) {
|
||||
actual := k8sItems.FilterByDeletedBy("test_user")
|
||||
|
||||
if len(actual) != 0 {
|
||||
t.Fatal("expected 0 found, actual: ", len(actual))
|
||||
if len(actual.Data) != 0 {
|
||||
t.Fatal("expected 0 found, actual: ", len(actual.Data))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -182,7 +184,7 @@ func TestFilterFunc(t *testing.T) {
|
||||
func TestSortByCreatedTime(t *testing.T) {
|
||||
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")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,38 @@ import (
|
||||
|
||||
// Request struct for get list information K8S
|
||||
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
|
||||
// Required: false
|
||||
IncludeDeleted bool `url:"includedeleted,omitempty" json:"includedeleted,omitempty"`
|
||||
@@ -22,7 +54,7 @@ type ListRequest struct {
|
||||
}
|
||||
|
||||
// List gets list all kubernetes clusters the user has access to
|
||||
func (k8s K8S) List(ctx context.Context, req ListRequest) (ListK8SClusters, error) {
|
||||
func (k8s K8S) List(ctx context.Context, req ListRequest) (*ListK8SClusters, error) {
|
||||
url := "/cloudapi/k8s/list"
|
||||
|
||||
res, err := k8s.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
@@ -37,5 +69,5 @@ func (k8s K8S) List(ctx context.Context, req ListRequest) (ListK8SClusters, erro
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return list, nil
|
||||
return &list, nil
|
||||
}
|
||||
|
||||
@@ -8,6 +8,38 @@ import (
|
||||
|
||||
// Request struct for get list deleted kubernetes cluster
|
||||
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 status
|
||||
// Required: false
|
||||
Status string `url:"status,omitempty" json:"status,omitempty"`
|
||||
|
||||
// Find by techStatus
|
||||
// Required: false
|
||||
TechStatus string `url:"techStatus,omitempty" json:"techStatus,omitempty"`
|
||||
|
||||
// Page number
|
||||
// Required: false
|
||||
Page uint64 `url:"page,omitempty" json:"page,omitempty"`
|
||||
@@ -18,7 +50,7 @@ type ListDeletedRequest struct {
|
||||
}
|
||||
|
||||
// ListDeleted gets all deleted kubernetes clusters the user has access to
|
||||
func (k8s K8S) ListDeleted(ctx context.Context, req ListDeletedRequest) (ListK8SClusters, error) {
|
||||
func (k8s K8S) ListDeleted(ctx context.Context, req ListDeletedRequest) (*ListK8SClusters, error) {
|
||||
url := "/cloudapi/k8s/listDeleted"
|
||||
|
||||
res, err := k8s.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
@@ -33,5 +65,5 @@ func (k8s K8S) ListDeleted(ctx context.Context, req ListDeletedRequest) (ListK8S
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return list, nil
|
||||
return &list, nil
|
||||
}
|
||||
|
||||
@@ -293,4 +293,10 @@ type RecordServiceAccount struct {
|
||||
}
|
||||
|
||||
// List of kubernetes clusters
|
||||
type ListK8SClusters []ItemK8SCluster
|
||||
type ListK8SClusters struct {
|
||||
// Data
|
||||
Data []ItemK8SCluster `json:"data"`
|
||||
|
||||
// Entry count
|
||||
EntryCount uint64 `json:"entryCount"`
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
// - First argument -> prefix
|
||||
// - Second argument -> indent
|
||||
func (lkc ListK8SClusters) Serialize(params ...string) (serialization.Serialized, error) {
|
||||
if len(lkc) == 0 {
|
||||
if len(lkc.Data) == 0 {
|
||||
return []byte{}, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -6,16 +6,16 @@ import "sort"
|
||||
//
|
||||
// If inverse param is set to true, the order is reversed.
|
||||
func (lkc ListK8SClusters) SortByCreatedTime(inverse bool) ListK8SClusters {
|
||||
if len(lkc) < 2 {
|
||||
if len(lkc.Data) < 2 {
|
||||
return lkc
|
||||
}
|
||||
|
||||
sort.Slice(lkc, func(i, j int) bool {
|
||||
sort.Slice(lkc.Data, func(i, j int) bool {
|
||||
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
|
||||
@@ -25,16 +25,16 @@ func (lkc ListK8SClusters) SortByCreatedTime(inverse bool) ListK8SClusters {
|
||||
//
|
||||
// If inverse param is set to true, the order is reversed.
|
||||
func (lkc ListK8SClusters) SortByUpdatedTime(inverse bool) ListK8SClusters {
|
||||
if len(lkc) < 2 {
|
||||
if len(lkc.Data) < 2 {
|
||||
return lkc
|
||||
}
|
||||
|
||||
sort.Slice(lkc, func(i, j int) bool {
|
||||
sort.Slice(lkc.Data, func(i, j int) bool {
|
||||
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
|
||||
@@ -44,16 +44,16 @@ func (lkc ListK8SClusters) SortByUpdatedTime(inverse bool) ListK8SClusters {
|
||||
//
|
||||
// If inverse param is set to true, the order is reversed.
|
||||
func (lkc ListK8SClusters) SortByDeletedTime(inverse bool) ListK8SClusters {
|
||||
if len(lkc) < 2 {
|
||||
if len(lkc.Data) < 2 {
|
||||
return lkc
|
||||
}
|
||||
|
||||
sort.Slice(lkc, func(i, j int) bool {
|
||||
sort.Slice(lkc.Data, func(i, j int) bool {
|
||||
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
|
||||
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
@@ -18,8 +19,8 @@ type WorkerAddRequest struct {
|
||||
WorkersGroupID uint64 `url:"workersGroupId" json:"workersGroupId" validate:"required"`
|
||||
|
||||
// How many worker nodes to add
|
||||
// Required: true
|
||||
Num uint64 `url:"num" json:"num" validate:"required"`
|
||||
// Required: false
|
||||
Num uint64 `url:"num,omitempty" json:"num,omitempty"`
|
||||
}
|
||||
|
||||
// WorkerAdd add worker nodes to a Kubernetes cluster
|
||||
|
||||
@@ -20,7 +20,7 @@ type WorkersGroupGetByNameRequest struct {
|
||||
}
|
||||
|
||||
// WorkersGroupGetByName gets worker group metadata by name
|
||||
func (k8s K8S) WorkersGroupGetByName(ctx context.Context, req WorkersGroupGetByNameRequest) (*RecordK8SGroups, error) {
|
||||
func (k8s K8S) WorkersGroupGetByName(ctx context.Context, req WorkersGroupGetByNameRequest) (*ItemK8SGroup, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
for _, validationError := range validators.GetErrors(err) {
|
||||
@@ -35,7 +35,7 @@ func (k8s K8S) WorkersGroupGetByName(ctx context.Context, req WorkersGroupGetByN
|
||||
return nil, err
|
||||
}
|
||||
|
||||
info := RecordK8SGroups{}
|
||||
info := ItemK8SGroup{}
|
||||
|
||||
err = json.Unmarshal(res, &info)
|
||||
if err != nil {
|
||||
|
||||
@@ -44,7 +44,7 @@ func (ll ListLB) FilterByImageID(imageID uint64) ListLB {
|
||||
}
|
||||
|
||||
// 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)
|
||||
|
||||
req := k8s.GetRequest{
|
||||
@@ -60,28 +60,32 @@ func (ll ListLB) FilterByK8SID(ctx context.Context, k8sID uint64, decortClient i
|
||||
return cluster.LBID == ill.ID
|
||||
}
|
||||
|
||||
return ll.FilterFunc(predicate), nil
|
||||
result := ll.FilterFunc(predicate)
|
||||
|
||||
return &result, nil
|
||||
}
|
||||
|
||||
// FilterFunc allows filtering ListLB based on a user-specified predicate.
|
||||
func (ll ListLB) FilterFunc(predicate func(ItemLoadBalancer) bool) ListLB {
|
||||
var result ListLB
|
||||
|
||||
for _, item := range ll {
|
||||
for _, item := range ll.Data {
|
||||
if predicate(item) {
|
||||
result = append(result, item)
|
||||
result.Data = append(result.Data, item)
|
||||
}
|
||||
}
|
||||
|
||||
result.EntryCount = uint64(len(ll.Data))
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
// FindOne returns first found ItemLoadBalancer
|
||||
// If none was found, returns an empty struct.
|
||||
func (ll ListLB) FindOne() ItemLoadBalancer {
|
||||
if len(ll) == 0 {
|
||||
if len(ll.Data) == 0 {
|
||||
return ItemLoadBalancer{}
|
||||
}
|
||||
|
||||
return ll[0]
|
||||
return ll.Data[0]
|
||||
}
|
||||
|
||||
@@ -3,93 +3,96 @@ package lb
|
||||
import "testing"
|
||||
|
||||
var lbs = ListLB{
|
||||
ItemLoadBalancer{
|
||||
DPAPIPassword: "0000",
|
||||
RecordLB: RecordLB{
|
||||
HAMode: true,
|
||||
ACL: []interface{}{},
|
||||
Backends: []ItemBackend{},
|
||||
CreatedBy: "test_user_1",
|
||||
CreatedTime: 1636667448,
|
||||
DeletedBy: "",
|
||||
DeletedTime: 0,
|
||||
Description: "",
|
||||
DPAPIUser: "api_user",
|
||||
ExtNetID: 2522,
|
||||
Frontends: []ItemFrontend{},
|
||||
GID: 212,
|
||||
GUID: 1,
|
||||
ID: 1,
|
||||
ImageID: 2121,
|
||||
Milestones: 129000,
|
||||
Name: "k8s-lb-test-1",
|
||||
RGID: 25090,
|
||||
RGName: "",
|
||||
Status: "ENABLED",
|
||||
TechStatus: "STARTED",
|
||||
UpdatedBy: "",
|
||||
UpdatedTime: 0,
|
||||
VINSID: 101,
|
||||
},
|
||||
},
|
||||
ItemLoadBalancer{
|
||||
DPAPIPassword: "0000",
|
||||
RecordLB: RecordLB{
|
||||
HAMode: false,
|
||||
ACL: []interface{}{},
|
||||
Backends: []ItemBackend{},
|
||||
CreatedBy: "test_user_2",
|
||||
CreatedTime: 1636667506,
|
||||
DeletedBy: "",
|
||||
DeletedTime: 0,
|
||||
Description: "",
|
||||
DPAPIUser: "api_user_2",
|
||||
ExtNetID: 2524,
|
||||
Frontends: []ItemFrontend{},
|
||||
GID: 212,
|
||||
GUID: 2,
|
||||
ID: 2,
|
||||
ImageID: 2129,
|
||||
Milestones: 129013,
|
||||
Name: "k8s-lb-test-2",
|
||||
RGID: 25092,
|
||||
RGName: "",
|
||||
Status: "ENABLED",
|
||||
TechStatus: "STOPPED",
|
||||
UpdatedBy: "",
|
||||
UpdatedTime: 0,
|
||||
VINSID: 102,
|
||||
},
|
||||
},
|
||||
ItemLoadBalancer{
|
||||
DPAPIPassword: "0000",
|
||||
RecordLB: RecordLB{
|
||||
HAMode: true,
|
||||
ACL: []interface{}{},
|
||||
Backends: []ItemBackend{},
|
||||
CreatedBy: "te2t_user_3",
|
||||
CreatedTime: 1636667534,
|
||||
DeletedBy: "",
|
||||
DeletedTime: 0,
|
||||
Description: "",
|
||||
DPAPIUser: "api_user_3",
|
||||
ExtNetID: 2536,
|
||||
Frontends: []ItemFrontend{},
|
||||
GID: 212,
|
||||
GUID: 3,
|
||||
ID: 3,
|
||||
ImageID: 2139,
|
||||
Milestones: 129025,
|
||||
Name: "k8s-lb-test-3",
|
||||
RGID: 25106,
|
||||
RGName: "",
|
||||
Status: "DISABLED",
|
||||
TechStatus: "STOPPED",
|
||||
UpdatedBy: "",
|
||||
UpdatedTime: 0,
|
||||
VINSID: 118,
|
||||
Data: []ItemLoadBalancer{
|
||||
{
|
||||
DPAPIPassword: "0000",
|
||||
RecordLB: RecordLB{
|
||||
HAMode: true,
|
||||
ACL: []interface{}{},
|
||||
Backends: []ItemBackend{},
|
||||
CreatedBy: "test_user_1",
|
||||
CreatedTime: 1636667448,
|
||||
DeletedBy: "",
|
||||
DeletedTime: 0,
|
||||
Description: "",
|
||||
DPAPIUser: "api_user",
|
||||
ExtNetID: 2522,
|
||||
Frontends: []ItemFrontend{},
|
||||
GID: 212,
|
||||
GUID: 1,
|
||||
ID: 1,
|
||||
ImageID: 2121,
|
||||
Milestones: 129000,
|
||||
Name: "k8s-lb-test-1",
|
||||
RGID: 25090,
|
||||
RGName: "",
|
||||
Status: "ENABLED",
|
||||
TechStatus: "STARTED",
|
||||
UpdatedBy: "",
|
||||
UpdatedTime: 0,
|
||||
VINSID: 101,
|
||||
},
|
||||
},
|
||||
{
|
||||
DPAPIPassword: "0000",
|
||||
RecordLB: RecordLB{
|
||||
HAMode: false,
|
||||
ACL: []interface{}{},
|
||||
Backends: []ItemBackend{},
|
||||
CreatedBy: "test_user_2",
|
||||
CreatedTime: 1636667506,
|
||||
DeletedBy: "",
|
||||
DeletedTime: 0,
|
||||
Description: "",
|
||||
DPAPIUser: "api_user_2",
|
||||
ExtNetID: 2524,
|
||||
Frontends: []ItemFrontend{},
|
||||
GID: 212,
|
||||
GUID: 2,
|
||||
ID: 2,
|
||||
ImageID: 2129,
|
||||
Milestones: 129013,
|
||||
Name: "k8s-lb-test-2",
|
||||
RGID: 25092,
|
||||
RGName: "",
|
||||
Status: "ENABLED",
|
||||
TechStatus: "STOPPED",
|
||||
UpdatedBy: "",
|
||||
UpdatedTime: 0,
|
||||
VINSID: 102,
|
||||
},
|
||||
},
|
||||
{
|
||||
DPAPIPassword: "0000",
|
||||
RecordLB: RecordLB{
|
||||
HAMode: true,
|
||||
ACL: []interface{}{},
|
||||
Backends: []ItemBackend{},
|
||||
CreatedBy: "te2t_user_3",
|
||||
CreatedTime: 1636667534,
|
||||
DeletedBy: "",
|
||||
DeletedTime: 0,
|
||||
Description: "",
|
||||
DPAPIUser: "api_user_3",
|
||||
ExtNetID: 2536,
|
||||
Frontends: []ItemFrontend{},
|
||||
GID: 212,
|
||||
GUID: 3,
|
||||
ID: 3,
|
||||
ImageID: 2139,
|
||||
Milestones: 129025,
|
||||
Name: "k8s-lb-test-3",
|
||||
RGID: 25106,
|
||||
RGName: "",
|
||||
Status: "DISABLED",
|
||||
TechStatus: "STOPPED",
|
||||
UpdatedBy: "",
|
||||
UpdatedTime: 0,
|
||||
VINSID: 118,
|
||||
},
|
||||
},
|
||||
},
|
||||
EntryCount: 3,
|
||||
}
|
||||
|
||||
func TestFilterByID(t *testing.T) {
|
||||
@@ -129,7 +132,7 @@ func TestFilterFunc(t *testing.T) {
|
||||
return rl.Status == "DISABLED"
|
||||
})
|
||||
|
||||
for _, item := range actual {
|
||||
for _, item := range actual.Data {
|
||||
if item.Status != "DISABLED" {
|
||||
t.Fatal("expected Status 'DISABLED', found: ", item.Status)
|
||||
}
|
||||
@@ -139,7 +142,7 @@ func TestFilterFunc(t *testing.T) {
|
||||
func TestSortByCreatedTime(t *testing.T) {
|
||||
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")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,38 @@ import (
|
||||
|
||||
// Request struct for get list of load balancers
|
||||
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
|
||||
// Required: false
|
||||
IncludeDeleted bool `url:"includedeleted,omitempty" json:"includedeleted,omitempty"`
|
||||
@@ -22,7 +54,7 @@ type ListRequest struct {
|
||||
}
|
||||
|
||||
// List gets list all load balancers
|
||||
func (l LB) List(ctx context.Context, req ListRequest) (ListLB, error) {
|
||||
func (l LB) List(ctx context.Context, req ListRequest) (*ListLB, error) {
|
||||
url := "/cloudapi/lb/list"
|
||||
|
||||
res, err := l.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
@@ -37,5 +69,5 @@ func (l LB) List(ctx context.Context, req ListRequest) (ListLB, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return list, nil
|
||||
return &list, nil
|
||||
}
|
||||
|
||||
@@ -8,6 +8,34 @@ import (
|
||||
|
||||
// Request struct for get list of deleted load balancers
|
||||
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
|
||||
// Required: false
|
||||
Page uint64 `url:"page,omitempty" json:"page,omitempty"`
|
||||
@@ -18,7 +46,7 @@ type ListDeletedRequest struct {
|
||||
}
|
||||
|
||||
// ListDeleted gets list of deleted load balancers
|
||||
func (l LB) ListDeleted(ctx context.Context, req ListDeletedRequest) (ListLB, error) {
|
||||
func (l LB) ListDeleted(ctx context.Context, req ListDeletedRequest) (*ListLB, error) {
|
||||
url := "/cloudapi/lb/listDeleted"
|
||||
|
||||
res, err := l.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
@@ -33,5 +61,5 @@ func (l LB) ListDeleted(ctx context.Context, req ListDeletedRequest) (ListLB, er
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return list, nil
|
||||
return &list, nil
|
||||
}
|
||||
|
||||
@@ -90,7 +90,13 @@ type ItemLoadBalancer struct {
|
||||
}
|
||||
|
||||
// List of load balancers
|
||||
type ListLB []ItemLoadBalancer
|
||||
type ListLB struct {
|
||||
// Data
|
||||
Data []ItemLoadBalancer `json:"data"`
|
||||
|
||||
// EntryCount
|
||||
EntryCount uint64 `json:"entryCount"`
|
||||
}
|
||||
|
||||
// Main information about backend
|
||||
type ItemBackend struct {
|
||||
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
// - First argument -> prefix
|
||||
// - Second argument -> indent
|
||||
func (ll ListLB) Serialize(params ...string) (serialization.Serialized, error) {
|
||||
if len(ll) == 0 {
|
||||
if len(ll.Data) == 0 {
|
||||
return []byte{}, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -6,16 +6,16 @@ import "sort"
|
||||
//
|
||||
// If inverse param is set to true, the order is reversed.
|
||||
func (ll ListLB) SortByCreatedTime(inverse bool) ListLB {
|
||||
if len(ll) < 2 {
|
||||
if len(ll.Data) < 2 {
|
||||
return ll
|
||||
}
|
||||
|
||||
sort.Slice(ll, func(i, j int) bool {
|
||||
sort.Slice(ll.Data, func(i, j int) bool {
|
||||
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
|
||||
@@ -25,16 +25,16 @@ func (ll ListLB) SortByCreatedTime(inverse bool) ListLB {
|
||||
//
|
||||
// If inverse param is set to true, the order is reversed.
|
||||
func (ll ListLB) SortByUpdatedTime(inverse bool) ListLB {
|
||||
if len(ll) < 2 {
|
||||
if len(ll.Data) < 2 {
|
||||
return ll
|
||||
}
|
||||
|
||||
sort.Slice(ll, func(i, j int) bool {
|
||||
sort.Slice(ll.Data, func(i, j int) bool {
|
||||
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
|
||||
@@ -44,16 +44,16 @@ func (ll ListLB) SortByUpdatedTime(inverse bool) ListLB {
|
||||
//
|
||||
// If inverse param is set to true, the order is reversed.
|
||||
func (ll ListLB) SortByDeletedTime(inverse bool) ListLB {
|
||||
if len(ll) < 2 {
|
||||
if len(ll.Data) < 2 {
|
||||
return ll
|
||||
}
|
||||
|
||||
sort.Slice(ll, func(i, j int) bool {
|
||||
sort.Slice(ll.Data, func(i, j int) bool {
|
||||
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
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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"`
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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) (ListPortForwards, error) {
|
||||
func (r RG) ListPFW(ctx context.Context, req ListPFWRequest) (*ListPortForwards, 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) (ListPortForwards,
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return list, nil
|
||||
return &list, nil
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -449,7 +449,13 @@ type ItemCompute struct {
|
||||
}
|
||||
|
||||
// List of computes
|
||||
type ListComputes []ItemCompute
|
||||
type ListComputes struct {
|
||||
//Data
|
||||
Data []ItemCompute `json:"data"`
|
||||
|
||||
// Entry count
|
||||
EntryCount uint64 `json:"entryCount"`
|
||||
}
|
||||
|
||||
// Main information about load balancer
|
||||
type RecordLoadBalancer struct {
|
||||
@@ -563,7 +569,13 @@ type ItemBackend struct {
|
||||
type ListBackends []ItemBackend
|
||||
|
||||
// List of load balancers
|
||||
type ListLB []ItemLoadBalancer
|
||||
type ListLB struct {
|
||||
// Data
|
||||
Data []ItemLoadBalancer `json:"data"`
|
||||
|
||||
// Entry count
|
||||
EntryCount uint64 `json:"entryCount"`
|
||||
}
|
||||
|
||||
// Server settings
|
||||
type RecordServerSettings struct {
|
||||
@@ -704,7 +716,13 @@ type ItemPortForward struct {
|
||||
}
|
||||
|
||||
// List of port forwards
|
||||
type ListPortForwards []ItemPortForward
|
||||
type ListPortForwards struct {
|
||||
//Data
|
||||
Data []ItemPortForward `json:"data"`
|
||||
|
||||
// Entry count
|
||||
EntryCount uint64 `json:"entryCount"`
|
||||
}
|
||||
|
||||
// Main information about VINS
|
||||
type ItemVINS struct {
|
||||
@@ -761,7 +779,13 @@ type ItemVINS struct {
|
||||
}
|
||||
|
||||
// List of VINSes
|
||||
type ListVINS []ItemVINS
|
||||
type ListVINS struct {
|
||||
// Data
|
||||
Data []ItemVINS `json:"data"`
|
||||
|
||||
// Entry count
|
||||
EntryCount uint64 `json:"entryCount"`
|
||||
}
|
||||
|
||||
// Main information about usage of resource
|
||||
type RecordResourceUsage struct {
|
||||
|
||||
@@ -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"`
|
||||
|
||||
Reference in New Issue
Block a user