Implement endpoints.List().
Minus pagination and all that.
diff --git a/openstack/identity/v3/endpoints/requests.go b/openstack/identity/v3/endpoints/requests.go
index 574ded3..3f7811a 100644
--- a/openstack/identity/v3/endpoints/requests.go
+++ b/openstack/identity/v3/endpoints/requests.go
@@ -105,7 +105,33 @@
// List enumerates endpoints in a paginated collection, optionally filtered by ListOpts criteria.
func List(client *gophercloud.ServiceClient, opts ListOpts) (*EndpointList, error) {
- return nil, errors.New("Not implemented")
+ q := make(map[string]string)
+ if opts.Interface != "" {
+ q["interface"] = string(opts.Interface)
+ }
+ if opts.ServiceID != "" {
+ q["service_id"] = opts.ServiceID
+ }
+ if opts.Page != 0 {
+ q["page"] = strconv.Itoa(opts.Page)
+ }
+ if opts.PerPage != 0 {
+ q["per_page"] = strconv.Itoa(opts.Page)
+ }
+
+ u := getListURL(client) + utils.BuildQuery(q)
+
+ var respBody []Endpoint
+ _, err := perigee.Request("GET", u, perigee.Options{
+ MoreHeaders: client.Provider.AuthenticatedHeaders(),
+ Results: &respBody,
+ OkCodes: []int{200},
+ })
+ if err != nil {
+ return nil, err
+ }
+
+ return &EndpointList{Endpoints: respBody}, nil
}
// Update changes an existing endpoint with new data.
diff --git a/openstack/identity/v3/endpoints/requests_test.go b/openstack/identity/v3/endpoints/requests_test.go
index 7bd6fcf..ed12c34 100644
--- a/openstack/identity/v3/endpoints/requests_test.go
+++ b/openstack/identity/v3/endpoints/requests_test.go
@@ -126,22 +126,24 @@
t.Fatalf("Unexpected error listing endpoints: %v", err)
}
- expected := []Endpoint{
- Endpoint{
- ID: "12",
- Interface: InterfacePublic,
- Name: "the-endiest-of-points",
- Region: "underground",
- ServiceID: "asdfasdfasdfasdf",
- URL: "https://1.2.3.4:9000/",
- },
- Endpoint{
- ID: "13",
- Interface: InterfaceInternal,
- Name: "shhhh",
- Region: "underground",
- ServiceID: "asdfasdfasdfasdf",
- URL: "https://1.2.3.4:9001/",
+ expected := &EndpointList{
+ Endpoints: []Endpoint{
+ Endpoint{
+ ID: "12",
+ Interface: InterfacePublic,
+ Name: "the-endiest-of-points",
+ Region: "underground",
+ ServiceID: "asdfasdfasdfasdf",
+ URL: "https://1.2.3.4:9000/",
+ },
+ Endpoint{
+ ID: "13",
+ Interface: InterfaceInternal,
+ Name: "shhhh",
+ Region: "underground",
+ ServiceID: "asdfasdfasdfasdf",
+ URL: "https://1.2.3.4:9001/",
+ },
},
}