blob: a887cc6976c0d512f232efc25987e4d5c3b74b3b [file] [log] [blame]
Samuel A. Falvo II17ae5652014-02-12 20:47:43 -08001package images
2
3import (
Ash Wilson7ddf0362014-09-17 10:59:09 -04004 "github.com/racker/perigee"
Ash Wilson9ccf9b62014-09-17 10:07:52 -04005 "github.com/rackspace/gophercloud"
6 "github.com/rackspace/gophercloud/pagination"
Samuel A. Falvo II17ae5652014-02-12 20:47:43 -08007)
8
Ash Wilson9ccf9b62014-09-17 10:07:52 -04009// List enumerates the available images.
10func List(client *gophercloud.ServiceClient) pagination.Pager {
11 createPage := func(r pagination.LastHTTPResponse) pagination.Page {
Ash Wilson501b4f32014-09-25 15:16:02 -040012 return ImagePage{pagination.LinkedPageBase{LastHTTPResponse: r}}
Samuel A. Falvo II17ae5652014-02-12 20:47:43 -080013 }
14
Ash Wilson31f6bde2014-09-25 14:52:12 -040015 return pagination.NewPager(client, listURL(client), createPage)
Samuel A. Falvo II17ae5652014-02-12 20:47:43 -080016}
Ash Wilson7ddf0362014-09-17 10:59:09 -040017
18// Get acquires additional detail about a specific image by ID.
19// Use ExtractImage() to intepret the result as an openstack Image.
Ash Wilsond2f87032014-09-25 11:34:41 -040020func Get(client *gophercloud.ServiceClient, id string) GetResult {
Ash Wilson7ddf0362014-09-17 10:59:09 -040021 var result GetResult
Ash Wilson31f6bde2014-09-25 14:52:12 -040022 _, result.Err = perigee.Request("GET", imageURL(client, id), perigee.Options{
Ash Wilson7ddf0362014-09-17 10:59:09 -040023 MoreHeaders: client.Provider.AuthenticatedHeaders(),
Ash Wilsond2f87032014-09-25 11:34:41 -040024 Results: &result.Resp,
Ash Wilson7ddf0362014-09-17 10:59:09 -040025 OkCodes: []int{200},
26 })
Ash Wilsond2f87032014-09-25 11:34:41 -040027 return result
Ash Wilson7ddf0362014-09-17 10:59:09 -040028}