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 | 0747d7e | 2014-09-09 14:27:35 -0400 | [diff] [blame] | 13 | // Interface describes the accessibility of a specific service endpoint. |
| 14 | type Interface string |
| 15 | |
| 16 | const ( |
| 17 | // InterfaceAdmin makes an endpoint only available to administrators. |
| 18 | InterfaceAdmin Interface = "admin" |
| 19 | |
| 20 | // InterfacePublic makes an endpoint available to everyone. |
| 21 | InterfacePublic Interface = "public" |
| 22 | |
| 23 | // InterfaceInternal makes an endpoint only available within the cluster. |
| 24 | InterfaceInternal Interface = "internal" |
| 25 | ) |
| 26 | |
Ash Wilson | b8401a7 | 2014-09-08 17:07:49 -0400 | [diff] [blame] | 27 | // EndpointOpts contains options for finding an endpoint for an Openstack client. |
| 28 | type EndpointOpts struct { |
| 29 | |
| 30 | // Type is the service type for the client (e.g., "compute", "object-store"). |
| 31 | // Type is a required field. |
| 32 | Type string |
| 33 | |
| 34 | // Name is the service name for the client (e.g., "nova"). |
| 35 | // Name is not a required field, but it is used if present. |
| 36 | // Services can have the same Type but a different Name, which is one example of when both Type and Name are needed. |
| 37 | Name string |
| 38 | |
| 39 | // Region is the region in which the service resides. |
Ash Wilson | 51b4f1c | 2014-09-09 15:18:43 -0400 | [diff] [blame^] | 40 | // Region must be specified for services that span multiple regions. |
Ash Wilson | b8401a7 | 2014-09-08 17:07:49 -0400 | [diff] [blame] | 41 | Region string |
| 42 | |
Ash Wilson | 51b4f1c | 2014-09-09 15:18:43 -0400 | [diff] [blame^] | 43 | // Interface is the visibility of the endpoint to be returned: InterfacePublic, InterfaceInternal, or InterfaceAdmin |
Ash Wilson | 0747d7e | 2014-09-09 14:27:35 -0400 | [diff] [blame] | 44 | // Interface is not required, and defaults to InterfacePublic. |
| 45 | // Not all interface types are accepted by all providers or identity services. |
| 46 | Interface Interface |
Ash Wilson | b8401a7 | 2014-09-08 17:07:49 -0400 | [diff] [blame] | 47 | } |
| 48 | |
| 49 | // 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^] | 50 | // 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] | 51 | type EndpointLocator func(EndpointOpts) (string, error) |