-
Notifications
You must be signed in to change notification settings - Fork 2
/
images.go
57 lines (52 loc) · 1.45 KB
/
images.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
package gobrightbox
import (
"time"
)
// Image represents a Machine Image
// https://api.gb1.brightbox.com/1.0/#image
type Image struct {
ID string
Name string
Username string
Status string
Locked bool
Description string
Source string
Arch string
CreatedAt time.Time `json:"created_at"`
Official bool
Public bool
Owner string
SourceType string `json:"source_type"`
VirtualSize int `json:"virtual_size"`
DiskSize int `json:"disk_size"`
CompatibilityMode bool `json:"compatibility_mode"`
AncestorID string `json:"ancestor_id"`
LicenceName string `json:"licence_name"`
}
// Images retrieves a list of all images
func (c *Client) Images() ([]Image, error) {
var images []Image
_, err := c.MakeAPIRequest("GET", "/1.0/images", nil, &images)
if err != nil {
return nil, err
}
return images, err
}
// Image retrieves a detailed view of one image
func (c *Client) Image(identifier string) (*Image, error) {
image := new(Image)
_, err := c.MakeAPIRequest("GET", "/1.0/images/"+identifier, nil, image)
if err != nil {
return nil, err
}
return image, err
}
// DestroyImage issues a request to destroy the image
func (c *Client) DestroyImage(identifier string) error {
_, err := c.MakeAPIRequest("DELETE", "/1.0/images/"+identifier, nil, nil)
if err != nil {
return err
}
return nil
}