Move the Interface type and its consts.
diff --git a/openstack/client.go b/openstack/client.go
index 7e9b628..3bbff12 100644
--- a/openstack/client.go
+++ b/openstack/client.go
@@ -153,13 +153,13 @@
// Extract the appropriate URL from the matching Endpoint.
for _, endpoint := range endpoints {
- switch opts.URLType {
- case "public", "":
+ switch opts.Interface {
+ case gophercloud.InterfacePublic:
return endpoint.PublicURL, nil
- case "private":
+ case gophercloud.InterfaceInternal:
return endpoint.InternalURL, nil
default:
- return "", fmt.Errorf("Unexpected URLType in endpoint query: %s", opts.URLType)
+ return "", fmt.Errorf("Unexpected interface in endpoint query: %s", opts.Interface)
}
}
@@ -195,17 +195,9 @@
}
func v3endpointLocator(v3Client *gophercloud.ServiceClient, opts gophercloud.EndpointOpts) (string, error) {
- // Transform URLType into an Interface.
- var endpointInterface = endpoints3.InterfacePublic
- switch opts.URLType {
- case "", "public":
- endpointInterface = endpoints3.InterfacePublic
- case "internal":
- endpointInterface = endpoints3.InterfaceInternal
- case "admin":
- endpointInterface = endpoints3.InterfaceAdmin
- default:
- return "", fmt.Errorf("Unrecognized URLType: %s", opts.URLType)
+ // Default Interface to InterfacePublic, if it isn't provided.
+ if opts.Interface == "" {
+ opts.Interface = gophercloud.InterfacePublic
}
// Discover the service we're interested in.
@@ -241,7 +233,7 @@
// Enumerate the endpoints available for this service.
endpointResults, err := endpoints3.List(v3Client, endpoints3.ListOpts{
- Interface: endpointInterface,
+ Interface: opts.Interface,
ServiceID: service.ID,
})
if err != nil {
diff --git a/openstack/identity/v3/endpoints/requests.go b/openstack/identity/v3/endpoints/requests.go
index 97cc3cf..65d505a 100644
--- a/openstack/identity/v3/endpoints/requests.go
+++ b/openstack/identity/v3/endpoints/requests.go
@@ -8,20 +8,6 @@
"github.com/rackspace/gophercloud/openstack/utils"
)
-// Interface describes the availability of a specific service endpoint.
-type Interface string
-
-const (
- // InterfaceAdmin makes an endpoint only available to administrators.
- InterfaceAdmin Interface = "admin"
-
- // InterfacePublic makes an endpoint available to everyone.
- InterfacePublic Interface = "public"
-
- // InterfaceInternal makes an endpoint only available within the cluster.
- InterfaceInternal Interface = "internal"
-)
-
// maybeString returns nil for empty strings and nil for empty.
func maybeString(original string) *string {
if original != "" {
@@ -32,7 +18,7 @@
// EndpointOpts contains the subset of Endpoint attributes that should be used to create or update an Endpoint.
type EndpointOpts struct {
- Interface Interface
+ Interface gophercloud.Interface
Name string
Region string
URL string
@@ -101,7 +87,7 @@
// ListOpts allows finer control over the the endpoints returned by a List call.
// All fields are optional.
type ListOpts struct {
- Interface Interface
+ Interface gophercloud.Interface
ServiceID string
Page int
PerPage int
diff --git a/openstack/identity/v3/endpoints/requests_test.go b/openstack/identity/v3/endpoints/requests_test.go
index f5705a0..a7088bb 100644
--- a/openstack/identity/v3/endpoints/requests_test.go
+++ b/openstack/identity/v3/endpoints/requests_test.go
@@ -59,7 +59,7 @@
client := serviceClient()
result, err := Create(client, EndpointOpts{
- Interface: InterfacePublic,
+ Interface: gophercloud.InterfacePublic,
Name: "the-endiest-of-points",
Region: "underground",
URL: "https://1.2.3.4:9000/",
@@ -71,7 +71,7 @@
expected := &Endpoint{
ID: "12",
- Interface: InterfacePublic,
+ Interface: gophercloud.InterfacePublic,
Name: "the-endiest-of-points",
Region: "underground",
ServiceID: "asdfasdfasdfasdf",
@@ -136,7 +136,7 @@
Endpoints: []Endpoint{
Endpoint{
ID: "12",
- Interface: InterfacePublic,
+ Interface: gophercloud.InterfacePublic,
Name: "the-endiest-of-points",
Region: "underground",
ServiceID: "asdfasdfasdfasdf",
@@ -144,7 +144,7 @@
},
Endpoint{
ID: "13",
- Interface: InterfaceInternal,
+ Interface: gophercloud.InterfaceInternal,
Name: "shhhh",
Region: "underground",
ServiceID: "asdfasdfasdfasdf",
@@ -202,7 +202,7 @@
expected := &Endpoint{
ID: "12",
- Interface: InterfacePublic,
+ Interface: gophercloud.InterfacePublic,
Name: "renamed",
Region: "somewhere-else",
ServiceID: "asdfasdfasdfasdf",
diff --git a/openstack/identity/v3/endpoints/results.go b/openstack/identity/v3/endpoints/results.go
index e972404..940eebc 100644
--- a/openstack/identity/v3/endpoints/results.go
+++ b/openstack/identity/v3/endpoints/results.go
@@ -9,12 +9,12 @@
// Endpoint describes the entry point for another service's API.
type Endpoint struct {
- ID string `json:"id"`
- Interface Interface `json:"interface"`
- Name string `json:"name"`
- Region string `json:"region"`
- ServiceID string `json:"service_id"`
- URL string `json:"url"`
+ ID string `json:"id"`
+ Interface gophercloud.Interface `json:"interface"`
+ Name string `json:"name"`
+ Region string `json:"region"`
+ ServiceID string `json:"service_id"`
+ URL string `json:"url"`
}
// EndpointList contains a page of Endpoint results.