blob: 150da6016afa02442211f547365aa217e07e2a0b [file] [log] [blame]
Ash Wilson70dfe0c2014-08-28 13:57:09 -04001package gophercloud
2
3import (
4 "strings"
5)
6
7// ServiceClient stores details about a specific service that are necessary for further interactions
8// with that service API, as well as utility methods for service implementation.
9//
10// Generally, you will acquire a ServiceClient by calling the NewClient() function in the
11// appropriate service package.
12type ServiceClient struct {
13 authority AuthResults
14 options AuthOptions
15 endpoint string
16 tokenID string
17}
18
19// ServiceURL constructs a URL for a resource belonging to this client.
20func (client *ServiceClient) ServiceURL(parts ...string) string {
21 return client.endpoint + strings.Join(parts, "/")
22}
23
24// AuthenticatedHeaders returns a map of HTTP headers that are common for all authenticated service
25// requests.
26func (client *ServiceClient) AuthenticatedHeaders() map[string]string {
27 return map[string]string{"X-Auth-Token": client.tokenID}
28}