-
Notifications
You must be signed in to change notification settings - Fork 1
/
background.go
63 lines (51 loc) · 1.55 KB
/
background.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
package vscale
type BackgroundService interface {
Locations() (*[]Location, *Response, error)
Images() (*[]Image, *Response, error)
}
type BackgroundServiceOp struct {
client *Client
}
var _ BackgroundService = &BackgroundServiceOp{}
type Location struct {
ID string `json:"id,omitempty"`
Active bool `json:"active,omitempty"`
Description string `json:"description,omitempty"`
Rplans []string `json:"rplans,omitempty"`
Templates []string `json:"templates,omitempty"`
PrivateNetworking bool `json:"private_networking,omitempty"`
}
type Image struct {
ID string `json:"id,omitempty"`
Active bool `json:"active,omitempty"`
Description string `json:"description,omitempty"`
Rplans []string `json:"rplans,omitempty"`
Locations []string `json:"locations,omitempty"`
Size int `json:"size,omitempty"`
}
func (s *BackgroundServiceOp) Locations() (*[]Location, *Response, error) {
path := "/v1/locations"
req, err := s.client.NewRequest("GET", path, nil)
if err != nil {
return nil, nil, err
}
locations := &[]Location{}
resp, err := s.client.Do(req, locations)
if err != nil {
return nil, nil, err
}
return locations, resp, err
}
func (s *BackgroundServiceOp) Images() (*[]Image, *Response, error) {
path := "/v1/images"
req, err := s.client.NewRequest("GET", path, nil)
if err != nil {
return nil, nil, err
}
images := &[]Image{}
resp, err := s.client.Do(req, images)
if err != nil {
return nil, nil, err
}
return images, resp, err
}