blob: 7c80deafb450b4de7f5f593a03d57a94ee2d5771 [file] [log] [blame]
Ash Wilsonb8401a72014-09-08 17:07:49 -04001package gophercloud
2
3import "errors"
4
5var (
Ash Wilson1cd3e692014-09-09 11:01:47 -04006 // 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 Wilsonb8401a72014-09-08 17:07:49 -04009 // 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 Wilsonefac18b2014-09-10 14:44:42 -040013// Availability describes the accessibility of a specific service endpoint.
14type Availability string
Ash Wilson0747d7e2014-09-09 14:27:35 -040015
16const (
Ash Wilsonefac18b2014-09-10 14:44:42 -040017 // AvailabilityAdmin makes an endpoint only available to administrators.
18 AvailabilityAdmin Availability = "admin"
Ash Wilson0747d7e2014-09-09 14:27:35 -040019
Ash Wilsonefac18b2014-09-10 14:44:42 -040020 // AvailabilityPublic makes an endpoint available to everyone.
21 AvailabilityPublic Availability = "public"
Ash Wilson0747d7e2014-09-09 14:27:35 -040022
Ash Wilsonefac18b2014-09-10 14:44:42 -040023 // AvailabilityInternal makes an endpoint only available within the cluster.
24 AvailabilityInternal Availability = "internal"
Ash Wilson0747d7e2014-09-09 14:27:35 -040025)
26
Ash Wilsonb8401a72014-09-08 17:07:49 -040027// EndpointOpts contains options for finding an endpoint for an Openstack client.
28type 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 Wilson51b4f1c2014-09-09 15:18:43 -040040 // Region must be specified for services that span multiple regions.
Ash Wilsonb8401a72014-09-08 17:07:49 -040041 Region string
42
Ash Wilsonefac18b2014-09-10 14:44:42 -040043 // Availability is the visibility of the endpoint to be returned: AvailabilityPublic, AvailabilityInternal, or AvailabilityAdmin.
44 // Availability is not required, and defaults to InterfacePublic.
45 // Not all providers or services offer all Availability options.
46 Availability Availability
Ash Wilsonb8401a72014-09-08 17:07:49 -040047}
48
49// EndpointLocator is a function that describes how to locate a single endpoint from a service catalog for a specific ProviderClient.
Ash Wilson51b4f1c2014-09-09 15:18:43 -040050// It should be set during ProviderClient authentication and used to discover related ServiceClients.
Ash Wilsonb8401a72014-09-08 17:07:49 -040051type EndpointLocator func(EndpointOpts) (string, error)