Skip to content

Commit fea54a7

Browse files
committed
api/v1: support image creation
Signed-off-by: Mathieu Tortuyaux <mtortuyaux@microsoft.com>
1 parent 273e31f commit fea54a7

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

images.go

+23
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,19 @@ type Image struct {
2727
LicenceName string `json:"licence_name"`
2828
}
2929

30+
type ImageOptions struct {
31+
Arch string `json:"arch"`
32+
CompatibilityMode bool `json:"compatibility_mode"`
33+
Description string `json:"description"`
34+
MinRam int `json:"min_ram"`
35+
Name string `json:"name"`
36+
Public bool `json:"public"`
37+
Username string `json:"username"`
38+
Server string `json:"server,omitempty"`
39+
Volume string `json:"volume,omitempty"`
40+
HTTPURL string `json:"http_url,omitempty"`
41+
}
42+
3043
// Images retrieves a list of all images
3144
func (c *Client) Images() ([]Image, error) {
3245
var images []Image
@@ -55,3 +68,13 @@ func (c *Client) DestroyImage(identifier string) error {
5568
}
5669
return nil
5770
}
71+
72+
// CreateImage issues a request to create an image
73+
func (c *Client) CreateImage(newImage *ImageOptions) (*Image, error) {
74+
image := new(Image)
75+
_, err := c.MakeAPIRequest("POST", "/1.0/images", newImage, &image)
76+
if err != nil {
77+
return nil, err
78+
}
79+
return image, nil
80+
}

0 commit comments

Comments
 (0)