diff options
author | Dolph Mathews <dolph.mathews@gmail.com> | 2015-05-13 16:38:44 +0000 |
---|---|---|
committer | Brant Knudson <bknudson@us.ibm.com> | 2015-07-19 09:49:04 -0500 |
commit | 98326c72f732481d73f2941827a1dae75c61388b (patch) | |
tree | bd79cf6e11af5b3693cd2c90ef1856615572e690 /keystoneclient/base.py | |
parent | ae066a828fc6698ffe8336bbd0ad9712680823d2 (diff) | |
download | python-keystoneclient-98326c72f732481d73f2941827a1dae75c61388b.tar.gz |
Prevent attempts to "filter" list() calls by globally unique IDs
This use case isn't covered by our current APIs:
GET /entities?id={entity_id}
Because we have a dedicated API for that:
GET /entities/{entity_id}
But our list() methods generally support **kwargs, which are passed as
query parameters to keystone. When an 'id' is passed to keystone as a
query parameter, keystone rightly ignores it and returns an unfiltered
collection.
This change raises a client-side TypeError (as you'd expect when you try
to pass a keyword argument that a function isn't expecting), and
includes a helpful suggestion to try calling get() instead.
Change-Id: I100b69bbf571ad6de49ccc5ad1099c20b877d13d
Closes-Bug: 1452298
Diffstat (limited to 'keystoneclient/base.py')
-rw-r--r-- | keystoneclient/base.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/keystoneclient/base.py b/keystoneclient/base.py index 025362b..eabbdc4 100644 --- a/keystoneclient/base.py +++ b/keystoneclient/base.py @@ -356,6 +356,17 @@ class CrudManager(Manager): @filter_kwargs def list(self, fallback_to_auth=False, **kwargs): + if 'id' in kwargs.keys(): + # Ensure that users are not trying to call things like + # ``domains.list(id='default')`` when they should have used + # ``[domains.get(domain_id='default')]`` instead. Keystone supports + # ``GET /v3/domains/{domain_id}``, not ``GET + # /v3/domains?id={domain_id}``. + raise TypeError( + _("list() got an unexpected keyword argument 'id'. To " + "retrieve a single object using a globally unique " + "identifier, try using get() instead.")) + url = self.build_url(dict_args_in_out=kwargs) try: |