This repository has been archived by the owner on Jun 28, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
hosts.go
129 lines (118 loc) · 3.46 KB
/
hosts.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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
package scomportal
import "fmt"
// BaremetalHostNetwork ..
type BaremetalHostNetwork struct {
ID uint64
HostIP string `json:"host_ip"`
PoolType string `json:"pool_type"` // drac, private, public
Netmask string
}
// BaremetalHostLocation ..
type BaremetalHostLocation struct {
Name string
Timezone string
}
// BaremetalHosts ..
type BaremetalHosts struct {
Data []struct {
ID uint64
Title string
Conf string
ServiceType uint64 `json:"service_type"`
Networks []BaremetalHostNetwork
Location BaremetalHostLocation
}
}
// GetBaremetalHosts ..
func (api *API) GetBaremetalHosts() (*BaremetalHosts, error) {
var hosts BaremetalHosts
if err := api.getRequest("/hosts", &hosts); err != nil {
return nil, err
}
return &hosts, nil
}
// BaremetalHost ..
type BaremetalHost struct {
Data struct {
ID uint64
Title string
Conf string
Networks []BaremetalHostNetwork
Location BaremetalHostLocation
ScheduledReleaseAt string `json:"scheduled_release_at"`
RackID uint64 `json:"rack_id"`
OsID uint64 `json:"os_id"`
OS struct {
Arch string
Name string
Version string
}
Domain string
OSReinstallation bool `json:"os_reinstallation"`
RescueMode bool `json:"rescue_mode"`
HostClass string `json:"host_class"`
PublicIP string `json:"public_ip"`
DRACIP string `json:"drac_ip"`
HasDRAC bool `json:"has_drac"`
TemporaryDracAccess string `json:"temporary_drac_access"`
}
}
// GetBaremetalHost ..
func (api *API) GetBaremetalHost(id uint64) (*BaremetalHost, error) {
var host BaremetalHost
if err := api.getRequest(fmt.Sprintf("/hosts/%d", id), &host); err != nil {
return nil, err
}
return &host, nil
}
// BaremetalTraficHost ..
type BaremetalTraficHost struct {
Data struct {
Type string
Commit struct {
TotalCommitValue uint `json:"total_commit_value"`
CommitValueForBillingPeriod float64 `json:"commit_value_for_billing_period"`
UsageQuantity string `json:"usage_quantity"`
DateStart string `json:"date_start"`
DateEnd string `json:"date_end"`
}
Overuse struct {
UsageQuantity string `json:"usage_quantity"`
DateStart string `json:"date_start"`
DateEnd string `json:"date_end"`
}
}
}
// GetBaremetalHostTraffic ..
func (api *API) GetBaremetalHostTraffic(id uint64) (*BaremetalTraficHost, error) {
var traffic BaremetalTraficHost
if err := api.getRequest(fmt.Sprintf("/hosts/%d/traffic_summary", id), &traffic); err != nil {
return nil, err
}
return &traffic, nil
}
// BaremetalServices ..
type BaremetalServices struct {
Data []struct {
ID uint64
Type uint64
ParentID uint64 `json:"parent_id"`
Description string
Label string
Comment string
DateStart string `json:"date_start"`
DateEnd string `json:"date_end"`
OriginalCurrency string `json:"original_currency"`
OriginalPrice float64 `json:"original_price"`
Currency string
Price float64
}
}
// GetServices ..
func (api API) GetServices(id uint64) (*BaremetalServices, error) {
var services BaremetalServices
if err := api.getRequest(fmt.Sprintf("/hosts/%d/services", id), &services); err != nil {
return nil, err
}
return &services, nil
}