diff --git a/keystoneclient/tests/unit/v3/test_endpoints.py b/keystoneclient/tests/unit/v3/test_endpoints.py index 000718a68..96f4f4630 100644 --- a/keystoneclient/tests/unit/v3/test_endpoints.py +++ b/keystoneclient/tests/unit/v3/test_endpoints.py @@ -89,3 +89,16 @@ class EndpointTests(utils.TestCase, utils.CrudTests): expected_path = 'v3/%s?interface=%s' % (self.collection_key, interface) self.assertRaises(exceptions.ValidationError, self.manager.list, expected_path=expected_path, interface=interface) + + def test_list_filtered_by_region(self): + region_id = uuid.uuid4().hex + ref_list = [self.new_ref(region=region_id), + self.new_ref(region=region_id)] + expected_path = 'v3/%s?region_id=%s' % (self.collection_key, region_id) + expected_query = {'region_id': region_id} + + # Validate passing either region or region_id result to the API call. + self.test_list(ref_list=ref_list, expected_path=expected_path, + expected_query=expected_query, region=region_id) + self.test_list(ref_list=ref_list, expected_path=expected_path, + expected_query=expected_query, region_id=region_id) diff --git a/keystoneclient/v3/endpoints.py b/keystoneclient/v3/endpoints.py index eeddc4cd3..56c2d60c6 100644 --- a/keystoneclient/v3/endpoints.py +++ b/keystoneclient/v3/endpoints.py @@ -68,17 +68,20 @@ class EndpointManager(base.CrudManager): @utils.positional(enforcement=utils.positional.WARN) def list(self, service=None, interface=None, region=None, enabled=None, - **kwargs): + region_id=None, **kwargs): """List endpoints. If ``**kwargs`` are provided, then filter endpoints with attributes matching ``**kwargs``. """ + # NOTE(lhcheng): region filter is not supported by keystone, + # region_id should be used instead. Consider removing the + # region argument in the next release. self._validate_interface(interface) return super(EndpointManager, self).list( service_id=base.getid(service), interface=interface, - region=region, + region_id=region_id or base.getid(region), enabled=enabled, **kwargs)