Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

api/v1: support image creation #39

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions images.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,19 @@ type Image struct {
LicenceName string `json:"licence_name"`
}

type ImageOptions struct {
Arch string `json:"arch"`
CompatibilityMode bool `json:"compatibility_mode"`
Description string `json:"description"`
MinRam int `json:"min_ram"`
Name string `json:"name"`
Public bool `json:"public"`
Username string `json:"username"`
Server string `json:"server,omitempty"`
Volume string `json:"volume,omitempty"`
HTTPURL string `json:"http_url,omitempty"`
}

// Images retrieves a list of all images
func (c *Client) Images() ([]Image, error) {
var images []Image
Expand Down Expand Up @@ -55,3 +68,13 @@ func (c *Client) DestroyImage(identifier string) error {
}
return nil
}

// CreateImage issues a request to create an image
func (c *Client) CreateImage(newImage *ImageOptions) (*Image, error) {
image := new(Image)
if _, err := c.MakeAPIRequest("POST", "/1.0/images", newImage, &image); err != nil {
return nil, err
}

return image, nil
}