v1.3.1
This commit is contained in:
@@ -165,7 +165,7 @@ type RecordAccount struct {
|
||||
CreatedTime uint64 `json:"createdTime"`
|
||||
|
||||
// Deactivation time
|
||||
DeactivationTime uint64 `json:"deactivationTime"`
|
||||
DeactivationTime float64 `json:"deactivationTime"`
|
||||
|
||||
// Deleted by
|
||||
DeletedBy string `json:"deletedBy"`
|
||||
|
||||
@@ -20,23 +20,23 @@ type UpdateRequest struct {
|
||||
|
||||
// Max size of memory in MB
|
||||
// Required: false
|
||||
MaxMemoryCapacity uint64 `url:"maxMemoryCapacity,omitempty" json:"maxMemoryCapacity,omitempty"`
|
||||
MaxMemoryCapacity int64 `url:"maxMemoryCapacity,omitempty" json:"maxMemoryCapacity,omitempty"`
|
||||
|
||||
// Max size of aggregated vdisks in GB
|
||||
// Required: false
|
||||
MaxVDiskCapacity uint64 `url:"maxVDiskCapacity,omitempty" json:"maxVDiskCapacity,omitempty"`
|
||||
MaxVDiskCapacity int64 `url:"maxVDiskCapacity,omitempty" json:"maxVDiskCapacity,omitempty"`
|
||||
|
||||
// Max number of CPU cores
|
||||
// Required: false
|
||||
MaxCPUCapacity uint64 `url:"maxCPUCapacity,omitempty" json:"maxCPUCapacity,omitempty"`
|
||||
MaxCPUCapacity int64 `url:"maxCPUCapacity,omitempty" json:"maxCPUCapacity,omitempty"`
|
||||
|
||||
// Max sent/received network transfer peering
|
||||
// Required: false
|
||||
MaxNetworkPeerTransfer uint64 `url:"maxNetworkPeerTransfer,omitempty" json:"maxNetworkPeerTransfer,omitempty"`
|
||||
MaxNetworkPeerTransfer int64 `url:"maxNetworkPeerTransfer,omitempty" json:"maxNetworkPeerTransfer,omitempty"`
|
||||
|
||||
// Max number of assigned public IPs
|
||||
// Required: false
|
||||
MaxNumPublicIP uint64 `url:"maxNumPublicIP,omitempty" json:"maxNumPublicIP,omitempty"`
|
||||
MaxNumPublicIP int64 `url:"maxNumPublicIP,omitempty" json:"maxNumPublicIP,omitempty"`
|
||||
|
||||
// If true send emails when a user is granted access to resources
|
||||
// Required: false
|
||||
@@ -44,7 +44,7 @@ type UpdateRequest struct {
|
||||
|
||||
// Limit (positive) or disable (0) GPU resources
|
||||
// Required: false
|
||||
GPUUnits uint64 `url:"gpu_units,omitempty" json:"gpu_units,omitempty"`
|
||||
GPUUnits int64 `url:"gpu_units,omitempty" json:"gpu_units,omitempty"`
|
||||
}
|
||||
|
||||
// Update updates an account name and resource types and limits
|
||||
|
||||
@@ -4,7 +4,7 @@ import "testing"
|
||||
|
||||
var computes = ListComputes{
|
||||
ItemCompute{
|
||||
ACL: []interface{}{},
|
||||
ACL: ListACL{},
|
||||
AccountID: 132847,
|
||||
AccountName: "std_2",
|
||||
AffinityLabel: "",
|
||||
@@ -85,7 +85,7 @@ var computes = ListComputes{
|
||||
VirtualImageID: 0,
|
||||
},
|
||||
ItemCompute{
|
||||
ACL: []interface{}{},
|
||||
ACL: ListACL{},
|
||||
AccountID: 132848,
|
||||
AccountName: "std_broker",
|
||||
AffinityLabel: "",
|
||||
@@ -150,92 +150,92 @@ var computes = ListComputes{
|
||||
}
|
||||
|
||||
func TestFilterByID(t *testing.T) {
|
||||
actual := computes.FilterByID(48500).FindOne()
|
||||
actual := computes.FilterByID(48500).FindOne()
|
||||
|
||||
if actual.ID != 48500 {
|
||||
t.Fatal("expected ID 48500, found: ", actual.ID)
|
||||
}
|
||||
if actual.ID != 48500 {
|
||||
t.Fatal("expected ID 48500, found: ", actual.ID)
|
||||
}
|
||||
|
||||
actualEmpty := computes.FilterByID(0)
|
||||
actualEmpty := computes.FilterByID(0)
|
||||
|
||||
if len(actualEmpty) != 0 {
|
||||
t.Fatal("expected empty, actual: ", len(actualEmpty))
|
||||
}
|
||||
if len(actualEmpty) != 0 {
|
||||
t.Fatal("expected empty, actual: ", len(actualEmpty))
|
||||
}
|
||||
}
|
||||
|
||||
func TestFilterByName(t *testing.T) {
|
||||
actual := computes.FilterByName("test").FindOne()
|
||||
actual := computes.FilterByName("test").FindOne()
|
||||
|
||||
if actual.Name != "test" {
|
||||
t.Fatal("expected compute with name 'test', found: ", actual.Name)
|
||||
}
|
||||
if actual.Name != "test" {
|
||||
t.Fatal("expected compute with name 'test', found: ", actual.Name)
|
||||
}
|
||||
}
|
||||
|
||||
func TestFilterByStatus(t *testing.T) {
|
||||
actual := computes.FilterByStatus("ENABLED")
|
||||
actual := computes.FilterByStatus("ENABLED")
|
||||
|
||||
for _, item := range actual {
|
||||
if item.Status != "ENABLED" {
|
||||
t.Fatal("expected ENABLED status, found: ", item.Status)
|
||||
}
|
||||
}
|
||||
for _, item := range actual {
|
||||
if item.Status != "ENABLED" {
|
||||
t.Fatal("expected ENABLED status, found: ", item.Status)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestFilterByTechStatus(t *testing.T) {
|
||||
actual := computes.FilterByTechStatus("STARTED").FindOne()
|
||||
actual := computes.FilterByTechStatus("STARTED").FindOne()
|
||||
|
||||
if actual.ID != 48556 {
|
||||
t.Fatal("expected 48556 with STARTED techStatus, found: ", actual.ID)
|
||||
}
|
||||
if actual.ID != 48556 {
|
||||
t.Fatal("expected 48556 with STARTED techStatus, found: ", actual.ID)
|
||||
}
|
||||
}
|
||||
|
||||
func TestFilterByDiskID(t *testing.T) {
|
||||
actual := computes.FilterByDiskID(65248).FindOne()
|
||||
actual := computes.FilterByDiskID(65248).FindOne()
|
||||
|
||||
if actual.ID != 48556 {
|
||||
t.Fatal("expected 48556 with DiskID 65248, found: ", actual.ID)
|
||||
}
|
||||
if actual.ID != 48556 {
|
||||
t.Fatal("expected 48556 with DiskID 65248, found: ", actual.ID)
|
||||
}
|
||||
}
|
||||
|
||||
func TestFilterFunc(t *testing.T) {
|
||||
actual := computes.FilterFunc(func(ic ItemCompute) bool {
|
||||
return ic.Registered == true
|
||||
})
|
||||
actual := computes.FilterFunc(func(ic ItemCompute) bool {
|
||||
return ic.Registered == true
|
||||
})
|
||||
|
||||
if len(actual) != 2 {
|
||||
t.Fatal("expected 2 elements found, actual: ", len(actual))
|
||||
}
|
||||
if len(actual) != 2 {
|
||||
t.Fatal("expected 2 elements found, actual: ", len(actual))
|
||||
}
|
||||
|
||||
for _, item := range actual {
|
||||
if item.Registered != true {
|
||||
t.Fatal("expected Registered to be true, actual: ", item.Registered)
|
||||
}
|
||||
}
|
||||
for _, item := range actual {
|
||||
if item.Registered != true {
|
||||
t.Fatal("expected Registered to be true, actual: ", item.Registered)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestSortingByCreatedTime(t *testing.T) {
|
||||
actual := computes.SortByCreatedTime(false)
|
||||
actual := computes.SortByCreatedTime(false)
|
||||
|
||||
if actual[0].Name != "test" {
|
||||
t.Fatal("expected 'test', found: ", actual[0].Name)
|
||||
}
|
||||
if actual[0].Name != "test" {
|
||||
t.Fatal("expected 'test', found: ", actual[0].Name)
|
||||
}
|
||||
|
||||
actual = computes.SortByCreatedTime(true)
|
||||
if actual[0].Name != "compute_2" {
|
||||
t.Fatal("expected 'compute_2', found: ", actual[0].Name)
|
||||
}
|
||||
actual = computes.SortByCreatedTime(true)
|
||||
if actual[0].Name != "compute_2" {
|
||||
t.Fatal("expected 'compute_2', found: ", actual[0].Name)
|
||||
}
|
||||
}
|
||||
|
||||
func TestSortingByCPU(t *testing.T) {
|
||||
actual := computes.SortByCPU(false)
|
||||
actual := computes.SortByCPU(false)
|
||||
|
||||
if actual[0].CPU != 4{
|
||||
t.Fatal("expected 4 CPU cores, found: ", actual[0].CPU)
|
||||
}
|
||||
if actual[0].CPU != 4 {
|
||||
t.Fatal("expected 4 CPU cores, found: ", actual[0].CPU)
|
||||
}
|
||||
|
||||
actual = computes.SortByCPU(true)
|
||||
actual = computes.SortByCPU(true)
|
||||
|
||||
if actual[0].CPU != 6 {
|
||||
t.Fatal("expected 6 CPU cores, found: ", actual[0].CPU)
|
||||
}
|
||||
if actual[0].CPU != 6 {
|
||||
t.Fatal("expected 6 CPU cores, found: ", actual[0].CPU)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package compute
|
||||
|
||||
import "strconv"
|
||||
|
||||
// Access Control List
|
||||
type RecordACL struct {
|
||||
// Account ACL list
|
||||
@@ -12,10 +14,27 @@ type RecordACL struct {
|
||||
RGACL ListACL `json:"rgAcl"`
|
||||
}
|
||||
|
||||
type Explicit bool
|
||||
|
||||
func (e *Explicit) UnmarshalJSON(b []byte) error {
|
||||
if b[0] == '"' {
|
||||
b = b[1 : len(b)-1]
|
||||
}
|
||||
|
||||
res, err := strconv.ParseBool(string(b))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
*e = Explicit(res)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// ACL information
|
||||
type ItemACL struct {
|
||||
// Explicit
|
||||
Explicit bool `json:"explicit"`
|
||||
Explicit Explicit `json:"explicit"`
|
||||
|
||||
// GUID
|
||||
GUID string `json:"guid"`
|
||||
@@ -709,8 +728,7 @@ type IOTune struct {
|
||||
// Main information about compute
|
||||
type ItemCompute struct {
|
||||
// Access Control List
|
||||
ACL []interface{} `json:"acl"`
|
||||
|
||||
ACL ListACL `json:"acl"`
|
||||
// Account ID
|
||||
AccountID uint64 `json:"accountId"`
|
||||
|
||||
|
||||
@@ -130,3 +130,62 @@ func (ld ListDisks) FindOne() ItemDisk {
|
||||
|
||||
return ld[0]
|
||||
}
|
||||
|
||||
// FilterByID returns ListDisksUnattached with specified ID.
|
||||
func (lu ListDisksUnattached) FilterByID(id uint64) ListDisksUnattached {
|
||||
predicate := func(idisk ItemDiskUnattached) bool {
|
||||
return idisk.ID == id
|
||||
}
|
||||
|
||||
return lu.FilterFunc(predicate)
|
||||
}
|
||||
|
||||
// FilterByName returns ListDisksUnattached with specified Name.
|
||||
func (lu ListDisksUnattached) FilterByName(name string) ListDisksUnattached {
|
||||
predicate := func(idisk ItemDiskUnattached) bool {
|
||||
return idisk.Name == name
|
||||
}
|
||||
|
||||
return lu.FilterFunc(predicate)
|
||||
}
|
||||
|
||||
// FilterByStatus returns ListDisksUnattached with specified Status.
|
||||
func (lu ListDisksUnattached) FilterByStatus(status string) ListDisksUnattached {
|
||||
predicate := func(idisk ItemDiskUnattached) bool {
|
||||
return idisk.Status == status
|
||||
}
|
||||
|
||||
return lu.FilterFunc(predicate)
|
||||
}
|
||||
|
||||
// FilterByTechStatus returns ListDisksUnattached with specified TechStatus.
|
||||
func (lu ListDisksUnattached) FilterByTechStatus(techStatus string) ListDisksUnattached {
|
||||
predicate := func(idisk ItemDiskUnattached) bool {
|
||||
return idisk.TechStatus == techStatus
|
||||
}
|
||||
|
||||
return lu.FilterFunc(predicate)
|
||||
}
|
||||
|
||||
// FilterFunc allows filtering ListDisksUnattached based on a user-specified predicate.
|
||||
func (lu ListDisksUnattached) FilterFunc(predicate func(ItemDiskUnattached) bool) ListDisksUnattached {
|
||||
var result ListDisksUnattached
|
||||
|
||||
for _, item := range lu {
|
||||
if predicate(item) {
|
||||
result = append(result, item)
|
||||
}
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
// FindOne returns first found ItemDiskUnattached
|
||||
// If none was found, returns an empty struct.
|
||||
func (lu ListDisksUnattached) FindOne() ItemDiskUnattached {
|
||||
if len(lu) == 0 {
|
||||
return ItemDiskUnattached{}
|
||||
}
|
||||
|
||||
return lu[0]
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package disks
|
||||
|
||||
import "testing"
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
var disks = ListDisks{
|
||||
ItemDisk{
|
||||
@@ -175,3 +177,198 @@ func TestSortByCreatedTime(t *testing.T) {
|
||||
t.Fatal("expected ID 65193, found: ", actual[0].ID)
|
||||
}
|
||||
}
|
||||
|
||||
var unattachedDisks = ListDisksUnattached{
|
||||
{
|
||||
CKey: "",
|
||||
Meta: []interface{}{
|
||||
"cloudbroker",
|
||||
"disk",
|
||||
1,
|
||||
},
|
||||
AccountID: 149,
|
||||
AccountName: "test_account1",
|
||||
ACL: map[string]interface{}{},
|
||||
BootPartition: 0,
|
||||
CreatedTime: 1681477547,
|
||||
DeletedTime: 0,
|
||||
Description: "",
|
||||
DestructionTime: 0,
|
||||
DiskPath: "",
|
||||
GID: 2002,
|
||||
GUID: 22636,
|
||||
ID: 22636,
|
||||
ImageID: 0,
|
||||
Images: []uint64{},
|
||||
IOTune: IOTune{
|
||||
TotalIOPSSec: 2000,
|
||||
},
|
||||
IQN: "",
|
||||
Login: "",
|
||||
Milestones: 43834,
|
||||
Name: "test_disk",
|
||||
Order: 0,
|
||||
Params: "",
|
||||
ParentID: 0,
|
||||
Password: "",
|
||||
PCISlot: -1,
|
||||
Pool: "data05",
|
||||
PresentTo: []uint64{},
|
||||
PurgeAttempts: 0,
|
||||
PurgeTime: 0,
|
||||
RealityDeviceNumber: 0,
|
||||
ReferenceID: "",
|
||||
ResID: "79bd3bd8-3424-48d3-963f-1870d506f169",
|
||||
ResName: "volumes/volume_22636",
|
||||
Role: "",
|
||||
SEPID: 1,
|
||||
Shareable: false,
|
||||
SizeMax: 0,
|
||||
SizeUsed: 0,
|
||||
Snapshots: nil,
|
||||
Status: "CREATED",
|
||||
TechStatus: "ALLOCATED",
|
||||
Type: "D",
|
||||
VMID: 0,
|
||||
},
|
||||
{
|
||||
CKey: "",
|
||||
Meta: []interface{}{
|
||||
"cloudbroker",
|
||||
"disk",
|
||||
1,
|
||||
},
|
||||
AccountID: 150,
|
||||
AccountName: "test_account",
|
||||
ACL: map[string]interface{}{},
|
||||
BootPartition: 0,
|
||||
CreatedTime: 1681477558,
|
||||
DeletedTime: 0,
|
||||
Description: "",
|
||||
DestructionTime: 0,
|
||||
DiskPath: "",
|
||||
GID: 2002,
|
||||
GUID: 22637,
|
||||
ID: 22637,
|
||||
ImageID: 0,
|
||||
Images: []uint64{},
|
||||
IOTune: IOTune{
|
||||
TotalIOPSSec: 2000,
|
||||
},
|
||||
IQN: "",
|
||||
Login: "",
|
||||
Milestones: 43834,
|
||||
Name: "test_disk",
|
||||
Order: 0,
|
||||
Params: "",
|
||||
ParentID: 0,
|
||||
Password: "",
|
||||
PCISlot: -1,
|
||||
Pool: "data05",
|
||||
PresentTo: []uint64{
|
||||
27,
|
||||
27,
|
||||
},
|
||||
PurgeAttempts: 0,
|
||||
PurgeTime: 0,
|
||||
RealityDeviceNumber: 0,
|
||||
ReferenceID: "",
|
||||
ResID: "79bd3bd8-3424-48d3-963f-1870d506f169",
|
||||
ResName: "volumes/volume_22637",
|
||||
Role: "",
|
||||
SEPID: 1,
|
||||
Shareable: false,
|
||||
SizeMax: 0,
|
||||
SizeUsed: 0,
|
||||
Snapshots: nil,
|
||||
Status: "CREATED",
|
||||
TechStatus: "ALLOCATED",
|
||||
Type: "B",
|
||||
VMID: 0,
|
||||
},
|
||||
}
|
||||
|
||||
func TestListDisksUnattached_FilterByID(t *testing.T) {
|
||||
actual := unattachedDisks.FilterByID(22636)
|
||||
|
||||
if len(actual) == 0 {
|
||||
t.Fatal("No elements were found")
|
||||
}
|
||||
|
||||
actualItem := actual.FindOne()
|
||||
|
||||
if actualItem.ID != 22636 {
|
||||
t.Fatal("expected ID 22636, found: ", actualItem.ID)
|
||||
}
|
||||
}
|
||||
|
||||
func TestListDisksUnattached_FilterByName(t *testing.T) {
|
||||
actual := unattachedDisks.FilterByName("test_disk")
|
||||
|
||||
if len(actual) != 2 {
|
||||
t.Fatal("expected 2 elements, found: ", len(actual))
|
||||
}
|
||||
|
||||
for _, item := range actual {
|
||||
if item.Name != "test_disk" {
|
||||
t.Fatal("expected 'test_disk' name, found: ", item.Name)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestListDisksUnattached_FilterByStatus(t *testing.T) {
|
||||
actual := unattachedDisks.FilterByStatus("CREATED")
|
||||
|
||||
if len(actual) == 0 {
|
||||
t.Fatal("No elements were found")
|
||||
}
|
||||
|
||||
for _, item := range actual {
|
||||
if item.Status != "CREATED" {
|
||||
t.Fatal("expected 'CREATED' status, found: ", item.Status)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestListDisksUnattached_FilterByTechStatus(t *testing.T) {
|
||||
actual := unattachedDisks.FilterByTechStatus("ALLOCATED")
|
||||
|
||||
if len(actual) == 0 {
|
||||
t.Fatal("No elements were found")
|
||||
}
|
||||
|
||||
for _, item := range actual {
|
||||
if item.TechStatus != "ALLOCATED" {
|
||||
t.Fatal("expected 'ALLOCATED' techStatus, found: ", item.TechStatus)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestListDisksUnattached_FilterFunc(t *testing.T) {
|
||||
actual := unattachedDisks.FilterFunc(func(id ItemDiskUnattached) bool {
|
||||
return len(id.PresentTo) == 2
|
||||
})
|
||||
|
||||
if len(actual) == 0 {
|
||||
t.Fatal("No elements were found")
|
||||
}
|
||||
|
||||
if len(actual[0].PresentTo) != 2 {
|
||||
t.Fatal("expected 2 elements in PresentTo, found: ", len(actual[0].PresentTo))
|
||||
}
|
||||
}
|
||||
|
||||
func TestListDisksUnattached_SortByCreatedTime(t *testing.T) {
|
||||
actual := unattachedDisks.SortByCreatedTime(false)
|
||||
|
||||
if actual[0].ID != 22636 {
|
||||
t.Fatal("expected ID 22636, found: ", actual[0].ID)
|
||||
}
|
||||
|
||||
actual = unattachedDisks.SortByCreatedTime(true)
|
||||
|
||||
if actual[0].ID != 22637 {
|
||||
t.Fatal("expected ID 22637, found: ", actual[0].ID)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ type ListUnattachedRequest struct {
|
||||
}
|
||||
|
||||
// ListUnattached gets list of unattached disks
|
||||
func (d Disks) ListUnattached(ctx context.Context, req ListUnattachedRequest) (ListDisks, error) {
|
||||
func (d Disks) ListUnattached(ctx context.Context, req ListUnattachedRequest) (ListDisksUnattached, error) {
|
||||
url := "/cloudapi/disks/listUnattached"
|
||||
|
||||
res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
@@ -22,7 +22,7 @@ func (d Disks) ListUnattached(ctx context.Context, req ListUnattachedRequest) (L
|
||||
return nil, err
|
||||
}
|
||||
|
||||
list := ListDisks{}
|
||||
list := ListDisksUnattached{}
|
||||
|
||||
err = json.Unmarshal(res, &list)
|
||||
if err != nil {
|
||||
|
||||
@@ -114,9 +114,146 @@ type ItemDisk struct {
|
||||
VMID uint64 `json:"vmid"`
|
||||
}
|
||||
|
||||
type ItemDiskUnattached struct {
|
||||
// CKey
|
||||
CKey string `json:"_ckey"`
|
||||
|
||||
// Meta
|
||||
Meta []interface{} `json:"_meta"`
|
||||
|
||||
// Account ID
|
||||
AccountID uint64 `json:"accountId"`
|
||||
|
||||
// Account name
|
||||
AccountName string `json:"accountName"`
|
||||
|
||||
// Access Control List
|
||||
ACL map[string]interface{} `json:"acl"`
|
||||
|
||||
// Boot Partition
|
||||
BootPartition uint64 `json:"bootPartition"`
|
||||
|
||||
// Created time
|
||||
CreatedTime uint64 `json:"createdTime"`
|
||||
|
||||
// Deleted time
|
||||
DeletedTime uint64 `json:"deletedTime"`
|
||||
|
||||
// Description
|
||||
Description string `json:"desc"`
|
||||
|
||||
// Destruction time
|
||||
DestructionTime uint64 `json:"destructionTime"`
|
||||
|
||||
// Disk path
|
||||
DiskPath string `json:"diskPath"`
|
||||
|
||||
// Grid ID
|
||||
GID uint64 `json:"gid"`
|
||||
|
||||
// GUID
|
||||
GUID uint64 `json:"guid"`
|
||||
|
||||
// ID
|
||||
ID uint64 `json:"id"`
|
||||
|
||||
// Image ID
|
||||
ImageID uint64 `json:"imageId"`
|
||||
|
||||
// Images
|
||||
Images []uint64 `json:"images"`
|
||||
|
||||
// IOTune
|
||||
IOTune IOTune `json:"iotune"`
|
||||
|
||||
// IQN
|
||||
IQN string `json:"iqn"`
|
||||
|
||||
// Login
|
||||
Login string `json:"login"`
|
||||
|
||||
// Milestones
|
||||
Milestones uint64 `json:"milestones"`
|
||||
|
||||
// Name
|
||||
Name string `json:"name"`
|
||||
|
||||
// Order
|
||||
Order uint64 `json:"order"`
|
||||
|
||||
// Params
|
||||
Params string `json:"params"`
|
||||
|
||||
// Parent ID
|
||||
ParentID uint64 `json:"parentId"`
|
||||
|
||||
// Password
|
||||
Password string `json:"passwd"`
|
||||
|
||||
//PCISlot
|
||||
PCISlot int64 `json:"pciSlot"`
|
||||
|
||||
// Pool
|
||||
Pool string `json:"pool"`
|
||||
|
||||
// Present to
|
||||
PresentTo []uint64 `json:"presentTo"`
|
||||
|
||||
// Purge attempts
|
||||
PurgeAttempts uint64 `json:"purgeAttempts"`
|
||||
|
||||
// Purge time
|
||||
PurgeTime uint64 `json:"purgeTime"`
|
||||
|
||||
// Reality device number
|
||||
RealityDeviceNumber uint64 `json:"realityDeviceNumber"`
|
||||
|
||||
// Reference ID
|
||||
ReferenceID string `json:"referenceId"`
|
||||
|
||||
// Resource ID
|
||||
ResID string `json:"resId"`
|
||||
|
||||
// Resource name
|
||||
ResName string `json:"resName"`
|
||||
|
||||
// Role
|
||||
Role string `json:"role"`
|
||||
|
||||
// ID SEP
|
||||
SEPID uint64 `json:"sepId"`
|
||||
|
||||
// Shareable
|
||||
Shareable bool `json:"shareable"`
|
||||
|
||||
// Size max
|
||||
SizeMax uint64 `json:"sizeMax"`
|
||||
|
||||
// Size used
|
||||
SizeUsed float64 `json:"sizeUsed"`
|
||||
|
||||
// List of snapshots
|
||||
Snapshots ListSnapshots `json:"snapshots"`
|
||||
|
||||
// Status
|
||||
Status string `json:"status"`
|
||||
|
||||
// Tech status
|
||||
TechStatus string `json:"techStatus"`
|
||||
|
||||
// Type
|
||||
Type string `json:"type"`
|
||||
|
||||
// Virtual machine ID
|
||||
VMID uint64 `json:"vmid"`
|
||||
}
|
||||
|
||||
// List of disks
|
||||
type ListDisks []ItemDisk
|
||||
|
||||
// List of unattached disks
|
||||
type ListDisksUnattached []ItemDiskUnattached
|
||||
|
||||
// Main information about snapshot
|
||||
type ItemSnapshot struct {
|
||||
// GUID
|
||||
|
||||
@@ -41,3 +41,39 @@ func (idisk ItemDisk) Serialize(params ...string) (serialization.Serialized, err
|
||||
|
||||
return json.Marshal(idisk)
|
||||
}
|
||||
|
||||
// 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 (lu ListDisksUnattached) Serialize(params ...string) (serialization.Serialized, error) {
|
||||
if len(lu) == 0 {
|
||||
return []byte{}, nil
|
||||
}
|
||||
|
||||
if len(params) > 1 {
|
||||
prefix := params[0]
|
||||
indent := params[1]
|
||||
|
||||
return json.MarshalIndent(lu, prefix, indent)
|
||||
}
|
||||
|
||||
return json.Marshal(lu)
|
||||
}
|
||||
|
||||
// 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 (idisk ItemDiskUnattached) Serialize(params ...string) (serialization.Serialized, error) {
|
||||
if len(params) > 1 {
|
||||
prefix := params[0]
|
||||
indent := params[1]
|
||||
|
||||
return json.MarshalIndent(idisk, prefix, indent)
|
||||
}
|
||||
|
||||
return json.Marshal(idisk)
|
||||
}
|
||||
|
||||
@@ -58,3 +58,60 @@ func (ld ListDisks) SortByDeletedTime(inverse bool) ListDisks {
|
||||
|
||||
return ld
|
||||
}
|
||||
|
||||
// SortByCreatedTime sorts ListDisksUnattached by the CreatedTime field in ascending order.
|
||||
//
|
||||
// If inverse param is set to true, the order is reversed.
|
||||
func (lu ListDisksUnattached) SortByCreatedTime(inverse bool) ListDisksUnattached {
|
||||
if len(lu) < 2 {
|
||||
return lu
|
||||
}
|
||||
|
||||
sort.Slice(lu, func(i, j int) bool {
|
||||
if inverse {
|
||||
return lu[i].CreatedTime > lu[j].CreatedTime
|
||||
}
|
||||
|
||||
return lu[i].CreatedTime < lu[j].CreatedTime
|
||||
})
|
||||
|
||||
return lu
|
||||
}
|
||||
|
||||
// SortByDestructionTime sorts ListDisksUnattached by the DestructionTime field in ascending order.
|
||||
//
|
||||
// If inverse param is set to true, the order is reversed.
|
||||
func (lu ListDisksUnattached) SortByDestructionTime(inverse bool) ListDisksUnattached {
|
||||
if len(lu) < 2 {
|
||||
return lu
|
||||
}
|
||||
|
||||
sort.Slice(lu, func(i, j int) bool {
|
||||
if inverse {
|
||||
return lu[i].DestructionTime > lu[j].DestructionTime
|
||||
}
|
||||
|
||||
return lu[i].DestructionTime < lu[j].DestructionTime
|
||||
})
|
||||
|
||||
return lu
|
||||
}
|
||||
|
||||
// SortByDeletedTime sorts ListDisksUnattached by the DeletedTime field in ascending order.
|
||||
//
|
||||
// If inverse param is set to true, the order is reversed.
|
||||
func (lu ListDisksUnattached) SortByDeletedTime(inverse bool) ListDisksUnattached {
|
||||
if len(lu) < 2 {
|
||||
return lu
|
||||
}
|
||||
|
||||
sort.Slice(lu, func(i, j int) bool {
|
||||
if inverse {
|
||||
return lu[i].DeletedTime > lu[j].DeletedTime
|
||||
}
|
||||
|
||||
return lu[i].DeletedTime < lu[j].DeletedTime
|
||||
})
|
||||
|
||||
return lu
|
||||
}
|
||||
|
||||
@@ -107,6 +107,23 @@ type VNFs struct {
|
||||
DHCP uint64 `json:"dhcp"`
|
||||
}
|
||||
|
||||
type Excluded struct {
|
||||
// ClientType
|
||||
ClientType string `json:"clientType"`
|
||||
|
||||
// IP
|
||||
IP string `json:"ip"`
|
||||
|
||||
// MAC
|
||||
MAC string `json:"mac"`
|
||||
|
||||
// Type
|
||||
Type string `json:"type"`
|
||||
|
||||
// VMID
|
||||
VMID uint64 `json:"vmId"`
|
||||
}
|
||||
|
||||
// Detailed information about external network
|
||||
type RecordExtNet struct {
|
||||
// CKey
|
||||
@@ -134,7 +151,7 @@ type RecordExtNet struct {
|
||||
DNS []string `json:"dns"`
|
||||
|
||||
// Excluded
|
||||
Excluded []string `json:"excluded"`
|
||||
Excluded []Excluded `json:"excluded"`
|
||||
|
||||
// Free IPs
|
||||
FreeIPs uint64 `json:"free_ips"`
|
||||
|
||||
@@ -59,11 +59,11 @@ type WorkersGroupAddRequest struct {
|
||||
}
|
||||
|
||||
// WorkersGroupAdd adds workers group to Kubernetes cluster
|
||||
func (k8s K8S) WorkersGroupAdd(ctx context.Context, req WorkersGroupAddRequest) (bool, error) {
|
||||
func (k8s K8S) WorkersGroupAdd(ctx context.Context, req WorkersGroupAddRequest) (uint64, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
for _, validationError := range validators.GetErrors(err) {
|
||||
return false, validators.ValidationError(validationError)
|
||||
return 0, validators.ValidationError(validationError)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,12 +71,12 @@ func (k8s K8S) WorkersGroupAdd(ctx context.Context, req WorkersGroupAddRequest)
|
||||
|
||||
res, err := k8s.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return false, err
|
||||
return 0, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseBool(string(res))
|
||||
result, err := strconv.ParseUint(string(res), 10, 64)
|
||||
if err != nil {
|
||||
return false, err
|
||||
return 0, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
|
||||
@@ -18,6 +18,15 @@ func (ll ListLocations) FilterByName(name string) ListLocations {
|
||||
return ll.FilterFunc(predicate)
|
||||
}
|
||||
|
||||
// FilterByGID returns ListLocations with specified GID.
|
||||
func (ll ListLocations) FilterByGID(gid uint64) ListLocations {
|
||||
predicate := func(il ItemLocation) bool {
|
||||
return il.GID == gid
|
||||
}
|
||||
|
||||
return ll.FilterFunc(predicate)
|
||||
}
|
||||
|
||||
// FilterFunc allows filtering ListLocations based on a user-specified predicate.
|
||||
func (ll ListLocations) FilterFunc(predicate func(ItemLocation) bool) ListLocations {
|
||||
var result ListLocations
|
||||
|
||||
@@ -735,7 +735,10 @@ type RecordResourceUsage struct {
|
||||
CPU uint64 `json:"cpu"`
|
||||
|
||||
// Disk size
|
||||
DiskSize uint64 `json:"disksize"`
|
||||
DiskSize float64 `json:"disksize"`
|
||||
|
||||
// Max disk size
|
||||
DiskSizeMax uint64 `json:"disksizemax"`
|
||||
|
||||
// Number of external IPs
|
||||
ExtIPs uint64 `json:"extips"`
|
||||
@@ -748,4 +751,7 @@ type RecordResourceUsage struct {
|
||||
|
||||
// Number of RAM
|
||||
RAM uint64 `json:"ram"`
|
||||
|
||||
// SEPs
|
||||
SEPs map[string]map[string]DiskUsage `json:"seps"`
|
||||
}
|
||||
|
||||
@@ -24,23 +24,23 @@ type UpdateRequest struct {
|
||||
|
||||
// Max size of memory in MB
|
||||
// Required: false
|
||||
MaxMemoryCapacity uint64 `url:"maxMemoryCapacity,omitempty" json:"maxMemoryCapacity,omitempty"`
|
||||
MaxMemoryCapacity int64 `url:"maxMemoryCapacity,omitempty" json:"maxMemoryCapacity,omitempty"`
|
||||
|
||||
// Max size of aggregated virtual disks in GB
|
||||
// Required: false
|
||||
MaxVDiskCapacity uint64 `url:"maxVDiskCapacity,omitempty" json:"maxVDiskCapacity,omitempty"`
|
||||
MaxVDiskCapacity int64 `url:"maxVDiskCapacity,omitempty" json:"maxVDiskCapacity,omitempty"`
|
||||
|
||||
// Max number of CPU cores
|
||||
// Required: false
|
||||
MaxCPUCapacity uint64 `url:"maxCPUCapacity,omitempty" json:"maxCPUCapacity,omitempty"`
|
||||
MaxCPUCapacity int64 `url:"maxCPUCapacity,omitempty" json:"maxCPUCapacity,omitempty"`
|
||||
|
||||
// Max sent/received network transfer peering
|
||||
// Required: false
|
||||
MaxNetworkPeerTransfer uint64 `url:"maxNetworkPeerTransfer,omitempty" json:"maxNetworkPeerTransfer,omitempty"`
|
||||
MaxNetworkPeerTransfer int64 `url:"maxNetworkPeerTransfer,omitempty" json:"maxNetworkPeerTransfer,omitempty"`
|
||||
|
||||
// Max number of assigned public IPs
|
||||
// Required: false
|
||||
MaxNumPublicIP uint64 `url:"maxNumPublicIP,omitempty" json:"maxNumPublicIP,omitempty"`
|
||||
MaxNumPublicIP int64 `url:"maxNumPublicIP,omitempty" json:"maxNumPublicIP,omitempty"`
|
||||
|
||||
// Register computes in registration system
|
||||
// Required: false
|
||||
|
||||
Reference in New Issue
Block a user