Ash Wilson | 6425a41 | 2014-08-29 12:30:35 -0400 | [diff] [blame] | 1 | package gophercloud |
| 2 | |
| 3 | import "strings" |
| 4 | |
| 5 | // ServiceClient stores details required to interact with a specific service API implemented by a provider. |
| 6 | // Generally, you'll acquire these by calling the appropriate `New` method on a ProviderClient. |
| 7 | type ServiceClient struct { |
Ash Wilson | c6372fe | 2014-09-03 11:24:52 -0400 | [diff] [blame^] | 8 | // Provider is a reference to the provider that implements this service. |
| 9 | Provider *ProviderClient |
Ash Wilson | 6425a41 | 2014-08-29 12:30:35 -0400 | [diff] [blame] | 10 | |
| 11 | // Endpoint is the base URL of the service's API, acquired from a service catalog. |
Ash Wilson | c6372fe | 2014-09-03 11:24:52 -0400 | [diff] [blame^] | 12 | // It should NOT end with a /. |
Ash Wilson | 6425a41 | 2014-08-29 12:30:35 -0400 | [diff] [blame] | 13 | Endpoint string |
| 14 | } |
| 15 | |
| 16 | // ServiceURL constructs a URL for a resource belonging to this provider. |
| 17 | func (client *ServiceClient) ServiceURL(parts ...string) string { |
Ash Wilson | c6372fe | 2014-09-03 11:24:52 -0400 | [diff] [blame^] | 18 | return client.Endpoint + "/" + strings.Join(parts, "/") |
Ash Wilson | 6425a41 | 2014-08-29 12:30:35 -0400 | [diff] [blame] | 19 | } |