blob: 0f26e53a20c6da6a1ea57c94ea0a238ea3391d13 [file] [log] [blame]
Ash Wilson89466cc2014-08-29 11:27:39 -04001package gophercloud
2
3import "strings"
4
5// ProviderClient stores details that are required to interact with any services within a specific provider's API.
6//
7// Generally, you acquire a ProviderClient by calling the `NewClient()` method in the appropriate provider's child package,
8// providing whatever authentication credentials are required.
9type ProviderClient struct {
10 // Authority caches results of the most recent authentication.
11 Authority AuthResults
12
13 // Options remembers the original authentication parameters, if reauthentication is enabled.
14 Options AuthOptions
15
16 // Endpoint is the base URL of the relevant API.
17 Endpoint string
18
19 // TokenID is the most recently valid token issued.
20 TokenID string
21}
22
23// ServiceURL constructs a URL for a resource belonging to this client.
24func (client *ProviderClient) ServiceURL(parts ...string) string {
25 return client.Endpoint + strings.Join(parts, "/")
26}
27
28// AuthenticatedHeaders returns a map of HTTP headers that are common for all authenticated service
29// requests.
30func (client *ProviderClient) AuthenticatedHeaders() map[string]string {
31 return map[string]string{"X-Auth-Token": client.TokenID}
32}