Rename "Interface" to "Availability".
Interface is what the identity v3 docs call it, but that collides with an
important concept from Go-the-language. Renaming it to "Availability" because
that's more descriptive.
diff --git a/openstack/identity/v3/endpoints/errors.go b/openstack/identity/v3/endpoints/errors.go
index a8b00d4..854957f 100644
--- a/openstack/identity/v3/endpoints/errors.go
+++ b/openstack/identity/v3/endpoints/errors.go
@@ -7,8 +7,8 @@
}
var (
- // ErrInterfaceRequired is reported if an Endpoint is created without an Interface.
- ErrInterfaceRequired = requiredAttribute("an interface")
+ // ErrAvailabilityRequired is reported if an Endpoint is created without an Availability.
+ ErrAvailabilityRequired = requiredAttribute("an availability")
// ErrNameRequired is reported if an Endpoint is created without a Name.
ErrNameRequired = requiredAttribute("a name")
diff --git a/openstack/identity/v3/endpoints/requests.go b/openstack/identity/v3/endpoints/requests.go
index 65d505a..a990049 100644
--- a/openstack/identity/v3/endpoints/requests.go
+++ b/openstack/identity/v3/endpoints/requests.go
@@ -18,11 +18,11 @@
// EndpointOpts contains the subset of Endpoint attributes that should be used to create or update an Endpoint.
type EndpointOpts struct {
- Interface gophercloud.Interface
- Name string
- Region string
- URL string
- ServiceID string
+ Availability gophercloud.Availability
+ Name string
+ Region string
+ URL string
+ ServiceID string
}
// Create inserts a new Endpoint into the service catalog.
@@ -46,8 +46,8 @@
}
// Ensure that EndpointOpts is fully populated.
- if opts.Interface == "" {
- return nil, ErrInterfaceRequired
+ if opts.Availability == "" {
+ return nil, ErrAvailabilityRequired
}
if opts.Name == "" {
return nil, ErrNameRequired
@@ -62,7 +62,7 @@
// Populate the request body.
reqBody := request{
Endpoint: endpoint{
- Interface: string(opts.Interface),
+ Interface: string(opts.Availability),
Name: opts.Name,
URL: opts.URL,
ServiceID: opts.ServiceID,
@@ -87,17 +87,17 @@
// ListOpts allows finer control over the the endpoints returned by a List call.
// All fields are optional.
type ListOpts struct {
- Interface gophercloud.Interface
- ServiceID string
- Page int
- PerPage int
+ Availability gophercloud.Availability
+ ServiceID string
+ Page int
+ PerPage int
}
// List enumerates endpoints in a paginated collection, optionally filtered by ListOpts criteria.
func List(client *gophercloud.ServiceClient, opts ListOpts) (*EndpointList, error) {
q := make(map[string]string)
- if opts.Interface != "" {
- q["interface"] = string(opts.Interface)
+ if opts.Availability != "" {
+ q["interface"] = string(opts.Availability)
}
if opts.ServiceID != "" {
q["service_id"] = opts.ServiceID
@@ -144,7 +144,7 @@
}
reqBody := request{Endpoint: endpoint{}}
- reqBody.Endpoint.Interface = maybeString(string(opts.Interface))
+ reqBody.Endpoint.Interface = maybeString(string(opts.Availability))
reqBody.Endpoint.Name = maybeString(opts.Name)
reqBody.Endpoint.Region = maybeString(opts.Region)
reqBody.Endpoint.URL = maybeString(opts.URL)
diff --git a/openstack/identity/v3/endpoints/requests_test.go b/openstack/identity/v3/endpoints/requests_test.go
index a7088bb..272860e 100644
--- a/openstack/identity/v3/endpoints/requests_test.go
+++ b/openstack/identity/v3/endpoints/requests_test.go
@@ -59,23 +59,23 @@
client := serviceClient()
result, err := Create(client, EndpointOpts{
- Interface: gophercloud.InterfacePublic,
- Name: "the-endiest-of-points",
- Region: "underground",
- URL: "https://1.2.3.4:9000/",
- ServiceID: "asdfasdfasdfasdf",
+ Availability: gophercloud.AvailabilityPublic,
+ Name: "the-endiest-of-points",
+ Region: "underground",
+ URL: "https://1.2.3.4:9000/",
+ ServiceID: "asdfasdfasdfasdf",
})
if err != nil {
t.Fatalf("Unable to create an endpoint: %v", err)
}
expected := &Endpoint{
- ID: "12",
- Interface: gophercloud.InterfacePublic,
- Name: "the-endiest-of-points",
- Region: "underground",
- ServiceID: "asdfasdfasdfasdf",
- URL: "https://1.2.3.4:9000/",
+ ID: "12",
+ Availability: gophercloud.AvailabilityPublic,
+ Name: "the-endiest-of-points",
+ Region: "underground",
+ ServiceID: "asdfasdfasdfasdf",
+ URL: "https://1.2.3.4:9000/",
}
if !reflect.DeepEqual(result, expected) {
@@ -135,20 +135,20 @@
expected := &EndpointList{
Endpoints: []Endpoint{
Endpoint{
- ID: "12",
- Interface: gophercloud.InterfacePublic,
- Name: "the-endiest-of-points",
- Region: "underground",
- ServiceID: "asdfasdfasdfasdf",
- URL: "https://1.2.3.4:9000/",
+ ID: "12",
+ Availability: gophercloud.AvailabilityPublic,
+ Name: "the-endiest-of-points",
+ Region: "underground",
+ ServiceID: "asdfasdfasdfasdf",
+ URL: "https://1.2.3.4:9000/",
},
Endpoint{
- ID: "13",
- Interface: gophercloud.InterfaceInternal,
- Name: "shhhh",
- Region: "underground",
- ServiceID: "asdfasdfasdfasdf",
- URL: "https://1.2.3.4:9001/",
+ ID: "13",
+ Availability: gophercloud.AvailabilityInternal,
+ Name: "shhhh",
+ Region: "underground",
+ ServiceID: "asdfasdfasdfasdf",
+ URL: "https://1.2.3.4:9001/",
},
},
}
@@ -201,12 +201,12 @@
}
expected := &Endpoint{
- ID: "12",
- Interface: gophercloud.InterfacePublic,
- Name: "renamed",
- Region: "somewhere-else",
- ServiceID: "asdfasdfasdfasdf",
- URL: "https://1.2.3.4:9000/",
+ ID: "12",
+ Availability: gophercloud.AvailabilityPublic,
+ Name: "renamed",
+ Region: "somewhere-else",
+ ServiceID: "asdfasdfasdfasdf",
+ URL: "https://1.2.3.4:9000/",
}
if !reflect.DeepEqual(expected, actual) {
t.Errorf("Expected %#v, was %#v", expected, actual)
diff --git a/openstack/identity/v3/endpoints/results.go b/openstack/identity/v3/endpoints/results.go
index 940eebc..bd7a013 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 gophercloud.Interface `json:"interface"`
- Name string `json:"name"`
- Region string `json:"region"`
- ServiceID string `json:"service_id"`
- URL string `json:"url"`
+ ID string `json:"id"`
+ Availability gophercloud.Availability `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.