v1.5.0-gamma2
This commit is contained in:
@@ -1,34 +1,34 @@
|
||||
package account
|
||||
|
||||
// FilterByID returns ListDeleted with specified ID.
|
||||
func (ld ListDeleted) FilterByID(id uint64) ListDeleted {
|
||||
// FilterByID returns ListAccounts with specified ID.
|
||||
func (la ListAccounts) FilterByID(id uint64) ListAccounts {
|
||||
predicate := func(ia ItemAccount) bool {
|
||||
return ia.ID == id
|
||||
}
|
||||
|
||||
return ld.FilterFunc(predicate)
|
||||
return la.FilterFunc(predicate)
|
||||
}
|
||||
|
||||
// FilterByName returns ListDeleted with specified Name.
|
||||
func (ld ListDeleted) FilterByName(name string) ListDeleted {
|
||||
// FilterByName returns ListAccounts with specified Name.
|
||||
func (la ListAccounts) FilterByName(name string) ListAccounts {
|
||||
predicate := func(ia ItemAccount) bool {
|
||||
return ia.Name == name
|
||||
}
|
||||
|
||||
return ld.FilterFunc(predicate)
|
||||
return la.FilterFunc(predicate)
|
||||
}
|
||||
|
||||
// FilterByStatus returns ListDeleted with specified Status.
|
||||
func (ld ListDeleted) FilterByStatus(status string) ListDeleted {
|
||||
// FilterByStatus returns ListAccounts with specified Status.
|
||||
func (la ListAccounts) FilterByStatus(status string) ListAccounts {
|
||||
predicate := func(ia ItemAccount) bool {
|
||||
return ia.Status == status
|
||||
}
|
||||
|
||||
return ld.FilterFunc(predicate)
|
||||
return la.FilterFunc(predicate)
|
||||
}
|
||||
|
||||
// FilterByUserGroupID returns ListDeleted with specified UserGroupID.
|
||||
func (ld ListDeleted) FilterByUserGroupID(userGroupID string) ListDeleted {
|
||||
// FilterByUserGroupID returns ListAccounts with specified UserGroupID.
|
||||
func (la ListAccounts) FilterByUserGroupID(userGroupID string) ListAccounts {
|
||||
predicate := func(ia ItemAccount) bool {
|
||||
acl := ia.ACL
|
||||
|
||||
@@ -41,46 +41,48 @@ func (ld ListDeleted) FilterByUserGroupID(userGroupID string) ListDeleted {
|
||||
return false
|
||||
}
|
||||
|
||||
return ld.FilterFunc(predicate)
|
||||
return la.FilterFunc(predicate)
|
||||
}
|
||||
|
||||
// FilterByCompany returns ListDeleted with specified Company.
|
||||
func (ld ListDeleted) FilterByCompany(company string) ListDeleted {
|
||||
// FilterByCompany returns ListAccounts with specified Company.
|
||||
func (la ListAccounts) FilterByCompany(company string) ListAccounts {
|
||||
predicate := func(ia ItemAccount) bool {
|
||||
return ia.Company == company
|
||||
}
|
||||
|
||||
return ld.FilterFunc(predicate)
|
||||
return la.FilterFunc(predicate)
|
||||
}
|
||||
|
||||
// FilterByCreatedBy returns ListDeleted created by specified user.
|
||||
func (ld ListDeleted) FilterByCreatedBy(createdBy string) ListDeleted {
|
||||
// FilterByCreatedBy returns ListAccounts created by specified user.
|
||||
func (la ListAccounts) FilterByCreatedBy(createdBy string) ListAccounts {
|
||||
predicate := func(ia ItemAccount) bool {
|
||||
return ia.CreatedBy == createdBy
|
||||
}
|
||||
|
||||
return ld.FilterFunc(predicate)
|
||||
return la.FilterFunc(predicate)
|
||||
}
|
||||
|
||||
// FilterFunc allows filtering ListDeleted based on a user-specified predicate.
|
||||
func (ld ListDeleted) FilterFunc(predicate func(ItemAccount) bool) ListDeleted {
|
||||
var result ListDeleted
|
||||
// FilterFunc allows filtering ListAccounts based on a user-specified predicate.
|
||||
func (la ListAccounts) FilterFunc(predicate func(ItemAccount) bool) ListAccounts {
|
||||
var result ListAccounts
|
||||
|
||||
for _, item := range ld {
|
||||
for _, item := range la.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 ItemAccount.
|
||||
// If none was found, returns an empty struct.
|
||||
func (ld ListDeleted) FindOne() ItemAccount {
|
||||
if len(ld) == 0 {
|
||||
func (la ListAccounts) FindOne() ItemAccount {
|
||||
if len(la.Data) == 0 {
|
||||
return ItemAccount{}
|
||||
}
|
||||
|
||||
return ld[0]
|
||||
return la.Data[0]
|
||||
}
|
||||
|
||||
@@ -4,78 +4,81 @@ import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
var accounts = ListDeleted{
|
||||
ItemAccount{
|
||||
Meta: []interface{}{},
|
||||
InfoAccount: InfoAccount{
|
||||
ACL: []ACL{
|
||||
{
|
||||
Explicit: true,
|
||||
GUID: "",
|
||||
Right: "CXDRAU",
|
||||
Status: "CONFIRMED",
|
||||
Type: "U",
|
||||
UserGroupID: "not_really_timofey_tkachev_1@decs3o",
|
||||
var accounts = ListAccounts{
|
||||
Data: []ItemAccount{
|
||||
{
|
||||
Meta: []interface{}{},
|
||||
InfoAccount: InfoAccount{
|
||||
ACL: []ACL{
|
||||
{
|
||||
Explicit: true,
|
||||
GUID: "",
|
||||
Right: "CXDRAU",
|
||||
Status: "CONFIRMED",
|
||||
Type: "U",
|
||||
UserGroupID: "not_really_timofey_tkachev_1@decs3o",
|
||||
},
|
||||
},
|
||||
CreatedTime: 1676878820,
|
||||
DeletedTime: 0,
|
||||
ID: 132847,
|
||||
Name: "std_2",
|
||||
Status: "CONFIRMED",
|
||||
UpdatedTime: 1676645275,
|
||||
},
|
||||
},
|
||||
{
|
||||
Meta: []interface{}{},
|
||||
InfoAccount: InfoAccount{
|
||||
ACL: []ACL{
|
||||
{
|
||||
Explicit: true,
|
||||
GUID: "",
|
||||
Right: "CXDRAU",
|
||||
Status: "CONFIRMED",
|
||||
Type: "U",
|
||||
UserGroupID: "timofey_tkachev_1@decs3o",
|
||||
},
|
||||
},
|
||||
CreatedTime: 1676645275,
|
||||
DeletedTime: 1677723401,
|
||||
ID: 132846,
|
||||
Name: "std",
|
||||
Status: "DELETED",
|
||||
UpdatedTime: 1676645275,
|
||||
},
|
||||
},
|
||||
{
|
||||
Meta: []interface{}{},
|
||||
InfoAccount: InfoAccount{
|
||||
ACL: []ACL{
|
||||
{
|
||||
Explicit: true,
|
||||
GUID: "",
|
||||
Right: "CXDRAU",
|
||||
Status: "CONFIRMED",
|
||||
Type: "U",
|
||||
UserGroupID: "timofey_tkachev_1@decs3o",
|
||||
},
|
||||
{
|
||||
Explicit: true,
|
||||
GUID: "",
|
||||
Right: "CXDRAU",
|
||||
Status: "CONFIRMED",
|
||||
Type: "U",
|
||||
UserGroupID: "second_account@decs3o",
|
||||
},
|
||||
},
|
||||
CreatedTime: 1676883850,
|
||||
DeletedTime: 1676883899,
|
||||
ID: 132848,
|
||||
Name: "std_broker",
|
||||
Status: "DELETED",
|
||||
UpdatedTime: 1676878820,
|
||||
},
|
||||
CreatedTime: 1676878820,
|
||||
DeletedTime: 0,
|
||||
ID: 132847,
|
||||
Name: "std_2",
|
||||
Status: "CONFIRMED",
|
||||
UpdatedTime: 1676645275,
|
||||
},
|
||||
},
|
||||
ItemAccount{
|
||||
Meta: []interface{}{},
|
||||
InfoAccount: InfoAccount{
|
||||
ACL: []ACL{
|
||||
{
|
||||
Explicit: true,
|
||||
GUID: "",
|
||||
Right: "CXDRAU",
|
||||
Status: "CONFIRMED",
|
||||
Type: "U",
|
||||
UserGroupID: "timofey_tkachev_1@decs3o",
|
||||
},
|
||||
},
|
||||
CreatedTime: 1676645275,
|
||||
DeletedTime: 1677723401,
|
||||
ID: 132846,
|
||||
Name: "std",
|
||||
Status: "DELETED",
|
||||
UpdatedTime: 1676645275,
|
||||
},
|
||||
},
|
||||
ItemAccount{
|
||||
Meta: []interface{}{},
|
||||
InfoAccount: InfoAccount{
|
||||
ACL: []ACL{
|
||||
{
|
||||
Explicit: true,
|
||||
GUID: "",
|
||||
Right: "CXDRAU",
|
||||
Status: "CONFIRMED",
|
||||
Type: "U",
|
||||
UserGroupID: "timofey_tkachev_1@decs3o",
|
||||
},
|
||||
{
|
||||
Explicit: true,
|
||||
GUID: "",
|
||||
Right: "CXDRAU",
|
||||
Status: "CONFIRMED",
|
||||
Type: "U",
|
||||
UserGroupID: "second_account@decs3o",
|
||||
},
|
||||
},
|
||||
CreatedTime: 1676883850,
|
||||
DeletedTime: 1676883899,
|
||||
ID: 132848,
|
||||
Name: "std_broker",
|
||||
Status: "DELETED",
|
||||
UpdatedTime: 1676878820,
|
||||
},
|
||||
},
|
||||
EntryCount: 3,
|
||||
}
|
||||
|
||||
func TestFilterByID(t *testing.T) {
|
||||
@@ -109,11 +112,11 @@ func TestFilterByName(t *testing.T) {
|
||||
func TestFilterByStatus(t *testing.T) {
|
||||
actual := accounts.FilterByStatus("DELETED")
|
||||
|
||||
if len(actual) != 2 {
|
||||
t.Fatal("Expected 2 elements in slice, found: ", len(actual))
|
||||
if len(actual.Data) != 2 {
|
||||
t.Fatal("Expected 2 elements in slice, found: ", len(actual.Data))
|
||||
}
|
||||
|
||||
for _, item := range actual {
|
||||
for _, item := range actual.Data {
|
||||
if item.Status != "DELETED" {
|
||||
t.Fatal("expected DELETED, found: ", item.Status)
|
||||
}
|
||||
@@ -125,7 +128,7 @@ func TestFilterFunc(t *testing.T) {
|
||||
return ia.DeletedTime == 0
|
||||
})
|
||||
|
||||
for _, item := range actual {
|
||||
for _, item := range actual.Data {
|
||||
if item.DeletedTime != 0 {
|
||||
t.Fatal("Expected DeletedTime = 0, found: ", item.DeletedTime)
|
||||
}
|
||||
@@ -135,21 +138,21 @@ func TestFilterFunc(t *testing.T) {
|
||||
func TestSortingByCreatedTime(t *testing.T) {
|
||||
actual := accounts.SortByCreatedTime(false)
|
||||
|
||||
if actual[0].Name != "std" {
|
||||
t.Fatal("Expected account std as earliest, found: ", actual[0].Name)
|
||||
if actual.Data[0].Name != "std" {
|
||||
t.Fatal("Expected account std as earliest, found: ", actual.Data[0].Name)
|
||||
}
|
||||
|
||||
actual = accounts.SortByCreatedTime(true)
|
||||
|
||||
if actual[0].Name != "std_broker" {
|
||||
t.Fatal("Expected account std_broker as latest, found: ", actual[0].Name)
|
||||
if actual.Data[0].Name != "std_broker" {
|
||||
t.Fatal("Expected account std_broker as latest, found: ", actual.Data[0].Name)
|
||||
}
|
||||
}
|
||||
|
||||
func TestFilterEmpty(t *testing.T) {
|
||||
actual := accounts.FilterByID(0)
|
||||
|
||||
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))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,27 +10,27 @@ import (
|
||||
type ListRequest struct {
|
||||
// Find by ID
|
||||
// Required: false
|
||||
ByID uint64 `url:"by_id" json:"by_id"`
|
||||
ByID uint64 `url:"by_id,omitempty" json:"by_id,omitempty"`
|
||||
|
||||
// Find by name
|
||||
// Required: false
|
||||
Name string `urL:"name" json:"name"`
|
||||
Name string `url:"name,omitempty" json:"name,omitempty"`
|
||||
|
||||
// Find by access control list
|
||||
// Required: false
|
||||
ACL string `url:"acl" json:"acl"`
|
||||
ACL string `url:"acl,omitempty" json:"acl,omitempty"`
|
||||
|
||||
// Find by status
|
||||
// Required: false
|
||||
Status string `url:"status" json:"status"`
|
||||
Status string `url:"status,omitempty" json:"status,omitempty"`
|
||||
|
||||
// Page number
|
||||
// Required: false
|
||||
Page uint64 `url:"page" json:"page"`
|
||||
Page uint64 `url:"page,omitempty" json:"page,omitempty"`
|
||||
|
||||
// Page size
|
||||
// Required: false
|
||||
Size uint64 `url:"size" json:"size"`
|
||||
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
||||
}
|
||||
|
||||
// List gets list all accounts the user has access to
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -8,17 +8,29 @@ import (
|
||||
|
||||
// Request struct for get list deleted accounts
|
||||
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 access control list
|
||||
// Required: false
|
||||
ACL string `url:"acl,omitempty" json:"acl,omitempty"`
|
||||
|
||||
// Page number
|
||||
// Required: false
|
||||
Page uint64 `url:"page" json:"page"`
|
||||
Page uint64 `url:"page,omitempty" json:"page,omitempty"`
|
||||
|
||||
// Page size
|
||||
// Required: false
|
||||
Size uint64 `url:"size" json:"size"`
|
||||
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
||||
}
|
||||
|
||||
// ListDeleted gets list all deleted accounts the user has access to
|
||||
func (a Account) ListDeleted(ctx context.Context, req ListDeletedRequest) (ListDeleted, error) {
|
||||
func (a Account) ListDeleted(ctx context.Context, req ListDeletedRequest) (*ListAccounts, error) {
|
||||
url := "/cloudbroker/account/listDeleted"
|
||||
|
||||
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
@@ -26,12 +38,12 @@ func (a Account) ListDeleted(ctx context.Context, req ListDeletedRequest) (ListD
|
||||
return nil, err
|
||||
}
|
||||
|
||||
list := ListDeleted{}
|
||||
list := ListAccounts{}
|
||||
|
||||
err = json.Unmarshal(res, &list)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return list, nil
|
||||
return &list, nil
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -13,10 +13,42 @@ type ListFLIPGroupsRequest struct {
|
||||
// ID an 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) {
|
||||
@@ -28,7 +52,7 @@ func (a Account) ListVINS(ctx context.Context, req ListVINSRequest) (ListVINS, e
|
||||
|
||||
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return ListVINS{}, err
|
||||
return nil, err
|
||||
}
|
||||
|
||||
list := ListVINS{}
|
||||
@@ -38,5 +62,5 @@ func (a Account) ListVINS(ctx context.Context, req ListVINSRequest) (ListVINS, e
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return list, nil
|
||||
return &list, nil
|
||||
}
|
||||
|
||||
@@ -98,7 +98,7 @@ type ACL struct {
|
||||
|
||||
// Resource limits
|
||||
type ResourceLimits struct {
|
||||
// CuC
|
||||
// CuC
|
||||
CuC float64 `json:"CU_C"`
|
||||
|
||||
// CuD
|
||||
@@ -210,18 +210,23 @@ type ItemAccount struct {
|
||||
InfoAccount
|
||||
}
|
||||
|
||||
// List of accounts
|
||||
type ListDeleted []ItemAccount
|
||||
|
||||
// List of accounts
|
||||
type ListAccounts struct {
|
||||
// Data
|
||||
Data []ItemAccount `json:"data"`
|
||||
|
||||
// Entry count
|
||||
EntryCount uint64 `json:"entryCount"`
|
||||
}
|
||||
|
||||
// List of computes
|
||||
type ListComputes []ItemCompute
|
||||
type ListComputes struct {
|
||||
// Data
|
||||
Data []ItemCompute `json:"data"`
|
||||
|
||||
// Entry count
|
||||
EntryCount uint64 `json:"entryCount"`
|
||||
}
|
||||
|
||||
// Main information about compute
|
||||
type ItemCompute struct {
|
||||
@@ -287,7 +292,13 @@ type ItemCompute struct {
|
||||
}
|
||||
|
||||
// List of disks
|
||||
type ListDisks []ItemDisk
|
||||
type ListDisks struct {
|
||||
// Data
|
||||
Data []ItemDisk `json:"data"`
|
||||
|
||||
// Entry count
|
||||
EntryCount uint64 `json:"entryCount"`
|
||||
}
|
||||
|
||||
// Main information about disks
|
||||
type ItemDisk struct {
|
||||
@@ -314,7 +325,13 @@ type ItemDisk struct {
|
||||
}
|
||||
|
||||
// List of FLIPGroups
|
||||
type ListFLIPGroups []ItemFLIPGroup
|
||||
type ListFLIPGroups struct {
|
||||
// Data
|
||||
Data []ItemFLIPGroup `json:"data"`
|
||||
|
||||
// Entry count
|
||||
EntryCount uint64 `json:"entryCount"`
|
||||
}
|
||||
|
||||
// Main information about FLIPGroup
|
||||
type ItemFLIPGroup struct {
|
||||
@@ -500,7 +517,13 @@ type ItemRG struct {
|
||||
}
|
||||
|
||||
// List of resource groups
|
||||
type ListRG []ItemRG
|
||||
type ListRG struct {
|
||||
// Data
|
||||
Data []ItemRG `json:"data"`
|
||||
|
||||
// Entry count
|
||||
EntryCount uint64 `json:"entryCount"`
|
||||
}
|
||||
|
||||
// Main information about VINS
|
||||
type ItemVINS struct {
|
||||
@@ -557,4 +580,10 @@ type ItemVINS struct {
|
||||
}
|
||||
|
||||
// List of VINSes
|
||||
type ListVINS []ItemVINS
|
||||
type ListVINS struct {
|
||||
//Data
|
||||
Data []ItemVINS `json:"data"`
|
||||
|
||||
// Entry count
|
||||
EntryCount uint64 `json:"entryCount"`
|
||||
}
|
||||
|
||||
@@ -6,26 +6,6 @@ import (
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/serialization"
|
||||
)
|
||||
|
||||
// Serialize returns JSON-serialized []byte. Used as a wrapper over json.Marshal and json.MarshalIndent functions.
|
||||
//
|
||||
// In order to serialize with indent make sure to follow these guidelines:
|
||||
// - First argument -> prefix
|
||||
// - Second argument -> indent
|
||||
func (ld ListDeleted) Serialize(params ...string) (serialization.Serialized, error) {
|
||||
if len(ld) == 0 {
|
||||
return []byte{}, nil
|
||||
}
|
||||
|
||||
if len(params) > 1 {
|
||||
prefix := params[0]
|
||||
indent := params[1]
|
||||
|
||||
return json.MarshalIndent(ld, prefix, indent)
|
||||
}
|
||||
|
||||
return json.Marshal(ld)
|
||||
}
|
||||
|
||||
// Serialize returns JSON-serialized []byte. Used as a wrapper over json.Marshal and json.MarshalIndent functions.
|
||||
//
|
||||
// In order to serialize with indent make sure to follow these guidelines:
|
||||
|
||||
@@ -2,68 +2,11 @@ package account
|
||||
|
||||
import "sort"
|
||||
|
||||
// SortByCreatedTime sorts ListDeleted by the CreatedTime field in ascending order.
|
||||
//
|
||||
// If inverse param is set to true, the order is reversed.
|
||||
func (ld ListDeleted) SortByCreatedTime(inverse bool) ListDeleted {
|
||||
if len(ld) < 2 {
|
||||
return ld
|
||||
}
|
||||
|
||||
sort.Slice(ld, func(i, j int) bool {
|
||||
if inverse {
|
||||
return ld[i].CreatedTime > ld[j].CreatedTime
|
||||
}
|
||||
|
||||
return ld[i].CreatedTime < ld[j].CreatedTime
|
||||
})
|
||||
|
||||
return ld
|
||||
}
|
||||
|
||||
// SortByUpdatedTime sorts ListDeleted by the UpdatedTime field in ascending order.
|
||||
//
|
||||
// If inverse param is set to true, the order is reversed.
|
||||
func (ld ListDeleted) SortByUpdatedTime(inverse bool) ListDeleted {
|
||||
if len(ld) < 2 {
|
||||
return ld
|
||||
}
|
||||
|
||||
sort.Slice(ld, func(i, j int) bool {
|
||||
if inverse {
|
||||
return ld[i].UpdatedTime > ld[j].UpdatedTime
|
||||
}
|
||||
|
||||
return ld[i].UpdatedTime < ld[j].UpdatedTime
|
||||
})
|
||||
|
||||
return ld
|
||||
}
|
||||
|
||||
// SortByDeletedTime sorts ListDeleted by the DeletedTime field in ascending order.
|
||||
//
|
||||
// If inverse param is set to true, the order is reversed.
|
||||
func (ld ListDeleted) SortByDeletedTime(inverse bool) ListDeleted {
|
||||
if len(ld) < 2 {
|
||||
return ld
|
||||
}
|
||||
|
||||
sort.Slice(ld, func(i, j int) bool {
|
||||
if inverse {
|
||||
return ld[i].DeletedTime > ld[j].DeletedTime
|
||||
}
|
||||
|
||||
return ld[i].DeletedTime < ld[j].DeletedTime
|
||||
})
|
||||
|
||||
return ld
|
||||
}
|
||||
|
||||
// SortByCreatedTime sorts ListAccounts by the CreatedTime field in ascending order.
|
||||
//
|
||||
// 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
|
||||
}
|
||||
|
||||
@@ -82,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
|
||||
}
|
||||
|
||||
@@ -101,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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user