Ash Wilson | b8401a7 | 2014-09-08 17:07:49 -0400 | [diff] [blame] | 1 | package gophercloud |
| 2 | |
| 3 | import "errors" |
| 4 | |
| 5 | var ( |
Ash Wilson | 1cd3e69 | 2014-09-09 11:01:47 -0400 | [diff] [blame] | 6 | // ErrServiceNotFound is returned when no service matches the EndpointOpts. |
| 7 | ErrServiceNotFound = errors.New("No suitable service could be found in the service catalog.") |
| 8 | |
Ash Wilson | b8401a7 | 2014-09-08 17:07:49 -0400 | [diff] [blame] | 9 | // ErrEndpointNotFound is returned when no available endpoints match the provided EndpointOpts. |
| 10 | ErrEndpointNotFound = errors.New("No suitable endpoint could be found in the service catalog.") |
| 11 | ) |
| 12 | |
Ash Wilson | efac18b | 2014-09-10 14:44:42 -0400 | [diff] [blame] | 13 | // Availability describes the accessibility of a specific service endpoint. |
Ash Wilson | 83f60cc | 2014-09-10 16:34:44 -0400 | [diff] [blame^] | 14 | // Identity v2 lists these as different kinds of URLs ("adminURL", "internalURL", and "publicURL"), while |
| 15 | // v3 lists them as "Interfaces". |
Ash Wilson | efac18b | 2014-09-10 14:44:42 -0400 | [diff] [blame] | 16 | type Availability string |
Ash Wilson | 0747d7e | 2014-09-09 14:27:35 -0400 | [diff] [blame] | 17 | |
| 18 | const ( |
Ash Wilson | efac18b | 2014-09-10 14:44:42 -0400 | [diff] [blame] | 19 | // AvailabilityAdmin makes an endpoint only available to administrators. |
| 20 | AvailabilityAdmin Availability = "admin" |
Ash Wilson | 0747d7e | 2014-09-09 14:27:35 -0400 | [diff] [blame] | 21 | |
Ash Wilson | efac18b | 2014-09-10 14:44:42 -0400 | [diff] [blame] | 22 | // AvailabilityPublic makes an endpoint available to everyone. |
| 23 | AvailabilityPublic Availability = "public" |
Ash Wilson | 0747d7e | 2014-09-09 14:27:35 -0400 | [diff] [blame] | 24 | |
Ash Wilson | efac18b | 2014-09-10 14:44:42 -0400 | [diff] [blame] | 25 | // AvailabilityInternal makes an endpoint only available within the cluster. |
| 26 | AvailabilityInternal Availability = "internal" |
Ash Wilson | 0747d7e | 2014-09-09 14:27:35 -0400 | [diff] [blame] | 27 | ) |
| 28 | |
Ash Wilson | b8401a7 | 2014-09-08 17:07:49 -0400 | [diff] [blame] | 29 | // EndpointOpts contains options for finding an endpoint for an Openstack client. |
| 30 | type EndpointOpts struct { |
| 31 | |
| 32 | // Type is the service type for the client (e.g., "compute", "object-store"). |
| 33 | // Type is a required field. |
| 34 | Type string |
| 35 | |
| 36 | // Name is the service name for the client (e.g., "nova"). |
| 37 | // Name is not a required field, but it is used if present. |
| 38 | // Services can have the same Type but a different Name, which is one example of when both Type and Name are needed. |
| 39 | Name string |
| 40 | |
| 41 | // Region is the region in which the service resides. |
Ash Wilson | 51b4f1c | 2014-09-09 15:18:43 -0400 | [diff] [blame] | 42 | // Region must be specified for services that span multiple regions. |
Ash Wilson | b8401a7 | 2014-09-08 17:07:49 -0400 | [diff] [blame] | 43 | Region string |
| 44 | |
Ash Wilson | efac18b | 2014-09-10 14:44:42 -0400 | [diff] [blame] | 45 | // Availability is the visibility of the endpoint to be returned: AvailabilityPublic, AvailabilityInternal, or AvailabilityAdmin. |
| 46 | // Availability is not required, and defaults to InterfacePublic. |
| 47 | // Not all providers or services offer all Availability options. |
| 48 | Availability Availability |
Ash Wilson | b8401a7 | 2014-09-08 17:07:49 -0400 | [diff] [blame] | 49 | } |
| 50 | |
| 51 | // EndpointLocator is a function that describes how to locate a single endpoint from a service catalog for a specific ProviderClient. |
Ash Wilson | 51b4f1c | 2014-09-09 15:18:43 -0400 | [diff] [blame] | 52 | // It should be set during ProviderClient authentication and used to discover related ServiceClients. |
Ash Wilson | b8401a7 | 2014-09-08 17:07:49 -0400 | [diff] [blame] | 53 | type EndpointLocator func(EndpointOpts) (string, error) |