summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--api-ref/source/v3-ext/ep-filter.inc12
-rw-r--r--api-ref/source/v3-ext/parameters.yaml7
-rw-r--r--keystone/api/os_ep_filter.py9
-rw-r--r--keystone/catalog/backends/base.py2
-rw-r--r--keystone/catalog/backends/sql.py5
-rw-r--r--keystone/catalog/backends/templated.py2
-rw-r--r--keystone/tests/unit/test_associate_project_endpoint_extension.py23
-rw-r--r--releasenotes/notes/bug1828565-0790c4c60ba34100.yaml6
8 files changed, 58 insertions, 8 deletions
diff --git a/api-ref/source/v3-ext/ep-filter.inc b/api-ref/source/v3-ext/ep-filter.inc
index 176e5a5b6..97dd39ead 100644
--- a/api-ref/source/v3-ext/ep-filter.inc
+++ b/api-ref/source/v3-ext/ep-filter.inc
@@ -266,6 +266,16 @@ List all available endpoint groups.
Relationship: ``https://docs.openstack.org/api/openstack-identity/3/ext/OS-EP-FILTER/1.0/rel/endpoint_groups``
+Request
+-------
+
+Parameters
+~~~~~~~~~~
+
+.. rest_parameters:: parameters.yaml
+
+ - name: request_endpoint_group_name_query_not_required
+
Response
--------
@@ -782,4 +792,4 @@ Example
Status: 200 OK
.. literalinclude:: samples/OS-EP-FILTER/endpoint-groups-response.json
- :language: javascript \ No newline at end of file
+ :language: javascript
diff --git a/api-ref/source/v3-ext/parameters.yaml b/api-ref/source/v3-ext/parameters.yaml
index 65145a6e9..2937fb676 100644
--- a/api-ref/source/v3-ext/parameters.yaml
+++ b/api-ref/source/v3-ext/parameters.yaml
@@ -93,6 +93,13 @@ user_id_path:
type: string
# variables in query
+request_endpoint_group_name_query_not_required:
+ description: |
+ Filters the response by an endpoint group name.
+ in: query
+ required: false
+ type: string
+
since_query:
description: |
A timestamp used to limit the list of results to events
diff --git a/keystone/api/os_ep_filter.py b/keystone/api/os_ep_filter.py
index 06e573fb6..9645496e7 100644
--- a/keystone/api/os_ep_filter.py
+++ b/keystone/api/os_ep_filter.py
@@ -66,9 +66,12 @@ class EndpointGroupsResource(ks_flask.ResourceBase):
PROVIDERS.catalog_api.get_endpoint_group(endpoint_group_id))
def _list_endpoint_groups(self):
- ENFORCER.enforce_call(action='identity:list_endpoint_groups')
- return self.wrap_collection(
- PROVIDERS.catalog_api.list_endpoint_groups())
+ filters = ('name')
+ ENFORCER.enforce_call(action='identity:list_endpoint_groups',
+ filters=filters)
+ hints = self.build_driver_hints(filters)
+ refs = PROVIDERS.catalog_api.list_endpoint_groups(hints)
+ return self.wrap_collection(refs, hints=hints)
def get(self, endpoint_group_id=None):
if endpoint_group_id is not None:
diff --git a/keystone/catalog/backends/base.py b/keystone/catalog/backends/base.py
index 5b86f383b..57e29f997 100644
--- a/keystone/catalog/backends/base.py
+++ b/keystone/catalog/backends/base.py
@@ -441,7 +441,7 @@ class CatalogDriverBase(provider_api.ProviderAPIMixin, object):
raise exception.NotImplemented() # pragma: no cover
@abc.abstractmethod
- def list_endpoint_groups(self):
+ def list_endpoint_groups(self, hints):
"""List all endpoint groups.
:returns: None.
diff --git a/keystone/catalog/backends/sql.py b/keystone/catalog/backends/sql.py
index 77a718516..27516315a 100644
--- a/keystone/catalog/backends/sql.py
+++ b/keystone/catalog/backends/sql.py
@@ -548,10 +548,11 @@ class Catalog(base.CatalogDriverBase):
else:
return endpoint_group_project_ref
- def list_endpoint_groups(self):
+ def list_endpoint_groups(self, hints):
with sql.session_for_read() as session:
query = session.query(EndpointGroup)
- endpoint_group_refs = query.all()
+ endpoint_group_refs = sql.filter_limit_query(
+ EndpointGroup, query, hints)
return [e.to_dict() for e in endpoint_group_refs]
def list_endpoint_groups_for_project(self, project_id):
diff --git a/keystone/catalog/backends/templated.py b/keystone/catalog/backends/templated.py
index 44a394895..8e1fbbfd2 100644
--- a/keystone/catalog/backends/templated.py
+++ b/keystone/catalog/backends/templated.py
@@ -326,7 +326,7 @@ class Catalog(base.CatalogDriverBase):
def get_endpoint_group_in_project(self, endpoint_group_id, project_id):
raise exception.NotImplemented()
- def list_endpoint_groups(self):
+ def list_endpoint_groups(self, hints):
raise exception.NotImplemented()
def list_endpoint_groups_for_project(self, project_id):
diff --git a/keystone/tests/unit/test_associate_project_endpoint_extension.py b/keystone/tests/unit/test_associate_project_endpoint_extension.py
index 37c3a5d0b..3b783a8d2 100644
--- a/keystone/tests/unit/test_associate_project_endpoint_extension.py
+++ b/keystone/tests/unit/test_associate_project_endpoint_extension.py
@@ -1046,6 +1046,29 @@ class EndpointGroupCRUDTestCase(EndpointFilterTestCase):
self.head(url, expected_status=http_client.OK)
+ def test_list_endpoint_groups_by_name(self):
+ """GET & HEAD /OS-EP-FILTER/endpoint_groups."""
+ # create an endpoint group to work with
+ endpoint_group_id = self._create_valid_endpoint_group(
+ self.DEFAULT_ENDPOINT_GROUP_URL, self.DEFAULT_ENDPOINT_GROUP_BODY)
+
+ # retrieve the single endpointgroup by name
+ url = ('/OS-EP-FILTER/endpoint_groups?name=%(name)s' %
+ {'name': 'endpoint_group_name'})
+ r = self.get(url, expected_status=http_client.OK)
+ self.assertNotEmpty(r.result['endpoint_groups'])
+ self.assertEqual(1, len(r.result['endpoint_groups']))
+ self.assertEqual(endpoint_group_id,
+ r.result['endpoint_groups'][0].get('id'))
+
+ self.head(url, expected_status=http_client.OK)
+
+ # try to retrieve a non existant one
+ url = ('/OS-EP-FILTER/endpoint_groups?name=%(name)s' %
+ {'name': 'fake'})
+ r = self.get(url, expected_status=http_client.OK)
+ self.assertEqual(0, len(r.result['endpoint_groups']))
+
def test_list_projects_associated_with_endpoint_group(self):
"""GET & HEAD /OS-EP-FILTER/endpoint_groups/{endpoint_group}/projects.
diff --git a/releasenotes/notes/bug1828565-0790c4c60ba34100.yaml b/releasenotes/notes/bug1828565-0790c4c60ba34100.yaml
new file mode 100644
index 000000000..3f89c08cd
--- /dev/null
+++ b/releasenotes/notes/bug1828565-0790c4c60ba34100.yaml
@@ -0,0 +1,6 @@
+---
+fixes:
+ - |
+ [`bug 1828565 <https://bugs.launchpad.net/keystone/+bug/1828565>`_]
+ Fixes endpoint group listing by name. This allows the openstackclient
+ command to search endpoint groups by name.