Samuel A. Falvo II | 17ae565 | 2014-02-12 20:47:43 -0800 | [diff] [blame] | 1 | package images |
| 2 | |
| 3 | import ( |
Ash Wilson | 2ebb21c | 2014-09-08 15:01:32 -0400 | [diff] [blame] | 4 | "github.com/rackspace/gophercloud" |
Jon Perritt | 5eb55b1 | 2014-08-18 14:48:23 -0500 | [diff] [blame] | 5 | identity "github.com/rackspace/gophercloud/openstack/identity/v2" |
Samuel A. Falvo II | 17ae565 | 2014-02-12 20:47:43 -0800 | [diff] [blame] | 6 | ) |
| 7 | |
| 8 | type Client struct { |
Samuel A. Falvo II | e246ac0 | 2014-02-13 23:20:09 -0800 | [diff] [blame] | 9 | endpoint string |
Samuel A. Falvo II | 17ae565 | 2014-02-12 20:47:43 -0800 | [diff] [blame] | 10 | authority identity.AuthResults |
Ash Wilson | 2ebb21c | 2014-09-08 15:01:32 -0400 | [diff] [blame] | 11 | options gophercloud.AuthOptions |
Samuel A. Falvo II | 17ae565 | 2014-02-12 20:47:43 -0800 | [diff] [blame] | 12 | } |
| 13 | |
Ash Wilson | 2ebb21c | 2014-09-08 15:01:32 -0400 | [diff] [blame] | 14 | func NewClient(e string, a identity.AuthResults, ao gophercloud.AuthOptions) *Client { |
Samuel A. Falvo II | 17ae565 | 2014-02-12 20:47:43 -0800 | [diff] [blame] | 15 | return &Client{ |
Samuel A. Falvo II | e246ac0 | 2014-02-13 23:20:09 -0800 | [diff] [blame] | 16 | endpoint: e, |
Samuel A. Falvo II | 17ae565 | 2014-02-12 20:47:43 -0800 | [diff] [blame] | 17 | authority: a, |
Samuel A. Falvo II | e246ac0 | 2014-02-13 23:20:09 -0800 | [diff] [blame] | 18 | options: ao, |
Samuel A. Falvo II | 17ae565 | 2014-02-12 20:47:43 -0800 | [diff] [blame] | 19 | } |
| 20 | } |
| 21 | |
| 22 | func (c *Client) getListUrl() string { |
| 23 | return c.endpoint + "/images/detail" |
| 24 | } |
| 25 | |
| 26 | func (c *Client) getListHeaders() (map[string]string, error) { |
| 27 | t, err := identity.GetToken(c.authority) |
| 28 | if err != nil { |
| 29 | return map[string]string{}, err |
| 30 | } |
| 31 | |
| 32 | return map[string]string{ |
Ash Wilson | 2ebb21c | 2014-09-08 15:01:32 -0400 | [diff] [blame] | 33 | "X-Auth-Token": t.ID, |
Samuel A. Falvo II | 17ae565 | 2014-02-12 20:47:43 -0800 | [diff] [blame] | 34 | }, nil |
| 35 | } |