blob: 6322b9cca4550eb4669591db4fd495069ea8d7bc [file] [log] [blame]
Samuel A. Falvo II17ae5652014-02-12 20:47:43 -08001package images
2
3import (
Ash Wilson2ebb21c2014-09-08 15:01:32 -04004 "github.com/rackspace/gophercloud"
Jon Perritt5eb55b12014-08-18 14:48:23 -05005 identity "github.com/rackspace/gophercloud/openstack/identity/v2"
Samuel A. Falvo II17ae5652014-02-12 20:47:43 -08006)
7
8type Client struct {
Samuel A. Falvo IIe246ac02014-02-13 23:20:09 -08009 endpoint string
Samuel A. Falvo II17ae5652014-02-12 20:47:43 -080010 authority identity.AuthResults
Ash Wilson2ebb21c2014-09-08 15:01:32 -040011 options gophercloud.AuthOptions
Samuel A. Falvo II17ae5652014-02-12 20:47:43 -080012}
13
Ash Wilson2ebb21c2014-09-08 15:01:32 -040014func NewClient(e string, a identity.AuthResults, ao gophercloud.AuthOptions) *Client {
Samuel A. Falvo II17ae5652014-02-12 20:47:43 -080015 return &Client{
Samuel A. Falvo IIe246ac02014-02-13 23:20:09 -080016 endpoint: e,
Samuel A. Falvo II17ae5652014-02-12 20:47:43 -080017 authority: a,
Samuel A. Falvo IIe246ac02014-02-13 23:20:09 -080018 options: ao,
Samuel A. Falvo II17ae5652014-02-12 20:47:43 -080019 }
20}
21
22func (c *Client) getListUrl() string {
23 return c.endpoint + "/images/detail"
24}
25
26func (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 Wilson2ebb21c2014-09-08 15:01:32 -040033 "X-Auth-Token": t.ID,
Samuel A. Falvo II17ae5652014-02-12 20:47:43 -080034 }, nil
35}