-
Notifications
You must be signed in to change notification settings - Fork 0
/
datacenters.go
94 lines (75 loc) · 2.06 KB
/
datacenters.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
package goarubacloud
const virtualDatacenterPath = "GetVirtualDatacenter"
const activeJobsPath = "GetJobs"
type DataCentersService interface {
GetVirtualDatacenter() (*VirtualDatacenter, *Response, error)
GetJobs() ([]ActiveJob, *Response, error)
}
type DataCentersServiceOp struct {
client *Client
}
var _ DataCentersService = &DataCentersServiceOp{}
type VirtualDatacenter struct {
CustomProductEntities []interface{}
DatacenterRegion DataCenterRegion `json:"DatacenterId"`
FTP interface{}
IpAddresses []interface{}
LoadBalancers []interface{}
PleskLicenses []interface{}
PrivateCloudEntities []interface{}
PublicIpAddresses []interface{}
Servers []CloudServerDetails
SharedStorages []interface{}
VLans []interface{}
}
type virtualDataCenterRoot struct {
VirtualDatacenter *VirtualDatacenter `json:"Value"`
}
type activeJobsRoot struct {
ActiveJobs []ActiveJob `json:"Value"`
}
type DataCenterRegion int
const (
Italy_1 DataCenterRegion = 1 + iota
Italy_2
Czech_Republic
France
Germany
UK
)
var datacenter_regions = [...]string{
"Italy 1",
"Italy 2",
"Czech Republic",
"France",
"Germany",
"UK",
}
// String returns the name of the Datacenter.
func (m DataCenterRegion) String() string { return datacenter_regions[m-1] }
// Get info about used services in the datacenter
func (s *DataCentersServiceOp) GetVirtualDatacenter() (*VirtualDatacenter, *Response, error) {
req, err := s.client.NewRequest(virtualDatacenterPath, nil)
if err != nil {
return nil, nil, err
}
root := new(virtualDataCenterRoot)
resp, err := s.client.Do(req, root)
if err != nil {
return nil, resp, err
}
return root.VirtualDatacenter, resp, err
}
// Get active jobs
func (s *DataCentersServiceOp) GetJobs() ([]ActiveJob, *Response, error) {
req, err := s.client.NewRequest(activeJobsPath, nil)
if err != nil {
return nil, nil, err
}
root := new(activeJobsRoot)
resp, err := s.client.Do(req, root)
if err != nil {
return nil, resp, err
}
return root.ActiveJobs, resp, err
}