Refactor v3 API to support filtering
Fixes: bug #1175356 Future implementations of keystone API v3 will support server-side filtering using key/value attributes. See additional details: https://github.com/openstack/identity-api/blob/master/openstack-identity-api/src/markdown/identity-api-v3.md#list-entities-filtered-by-attribute To support this functionality **kwargs need to be passed from the v3 API classes to keystoneclient.base.CrudManager.list. This is not fully implemented server-side for all attributes so it's difficult to document exactly which attributes will work. An example of a working attribute is: keystone.users.list(name="someone") Change-Id: I148093fbe37700f890ed44148aa3f63f34ee5ff5
This commit is contained in:
@@ -61,14 +61,20 @@ class EndpointManager(base.CrudManager):
|
||||
return super(EndpointManager, self).get(
|
||||
endpoint_id=base.getid(endpoint))
|
||||
|
||||
def list(self, service=None, name=None, interface=None, region=None,
|
||||
enabled=None):
|
||||
def list(self, service=None, interface=None, region=None,
|
||||
enabled=None, **kwargs):
|
||||
"""List endpoints.
|
||||
|
||||
If ``**kwargs`` are provided, then filter endpoints with
|
||||
attributes matching ``**kwargs``.
|
||||
"""
|
||||
self._validate_interface(interface)
|
||||
return super(EndpointManager, self).list(
|
||||
service_id=base.getid(service),
|
||||
interface=interface,
|
||||
region=region,
|
||||
enabled=enabled)
|
||||
enabled=enabled,
|
||||
**kwargs)
|
||||
|
||||
def update(self, endpoint, service=None, url=None, name=None,
|
||||
interface=None, region=None, enabled=None):
|
||||
|
@@ -55,13 +55,22 @@ class GroupManager(base.CrudManager):
|
||||
domain_id=base.getid(domain),
|
||||
description=description)
|
||||
|
||||
def list(self, user=None):
|
||||
def list(self, user=None, **kwargs):
|
||||
"""List groups.
|
||||
|
||||
If user is provided, then filter groups with
|
||||
that attribute.
|
||||
|
||||
If ``**kwargs`` are provided, then filter groups with
|
||||
attributes matching ``**kwargs``.
|
||||
"""
|
||||
if user:
|
||||
base_url = '/users/%s' % base.getid(user)
|
||||
else:
|
||||
base_url = None
|
||||
return super(GroupManager, self).list(
|
||||
base_url=base_url)
|
||||
base_url=base_url,
|
||||
**kwargs)
|
||||
|
||||
def get(self, group):
|
||||
return super(GroupManager, self).get(
|
||||
|
@@ -58,11 +58,20 @@ class ProjectManager(base.CrudManager):
|
||||
description=description,
|
||||
enabled=enabled)
|
||||
|
||||
def list(self, domain=None, user=None):
|
||||
def list(self, domain=None, user=None, **kwargs):
|
||||
"""List projects.
|
||||
|
||||
If domain or user are provided, then filter projects with
|
||||
those attributes.
|
||||
|
||||
If ``**kwargs`` are provided, then filter projects with
|
||||
attributes matching ``**kwargs``.
|
||||
"""
|
||||
base_url = '/users/%s' % base.getid(user) if user else None
|
||||
return super(ProjectManager, self).list(
|
||||
base_url=base_url,
|
||||
domain_id=base.getid(domain))
|
||||
domain_id=base.getid(domain),
|
||||
**kwargs)
|
||||
|
||||
def get(self, project):
|
||||
return super(ProjectManager, self).get(
|
||||
|
@@ -74,13 +74,16 @@ class RoleManager(base.CrudManager):
|
||||
return super(RoleManager, self).get(
|
||||
role_id=base.getid(role))
|
||||
|
||||
def list(self, user=None, group=None, domain=None, project=None):
|
||||
def list(self, user=None, group=None, domain=None, project=None, **kwargs):
|
||||
"""Lists roles and role grants.
|
||||
|
||||
If no arguments are provided, all roles in the system will be listed.
|
||||
If no arguments are provided, all roles in the system will be
|
||||
listed.
|
||||
|
||||
If a user or group is specified, you must also specify either a
|
||||
domain or project to list role grants on that pair.
|
||||
domain or project to list role grants on that pair. And if
|
||||
``**kwargs`` are provided, then also filter roles with
|
||||
attributes matching ``**kwargs``.
|
||||
"""
|
||||
|
||||
if user or group:
|
||||
@@ -89,7 +92,8 @@ class RoleManager(base.CrudManager):
|
||||
|
||||
return super(RoleManager, self).list(
|
||||
base_url=self._role_grants_base_url(user, group,
|
||||
domain, project))
|
||||
domain, project),
|
||||
**kwargs)
|
||||
|
||||
return super(RoleManager, self).list()
|
||||
|
||||
|
@@ -49,7 +49,15 @@ class UserManager(base.CrudManager):
|
||||
description=description,
|
||||
enabled=enabled)
|
||||
|
||||
def list(self, project=None, domain=None, group=None):
|
||||
def list(self, project=None, domain=None, group=None, **kwargs):
|
||||
"""List users.
|
||||
|
||||
If project, domain or group are provided, then filter
|
||||
users with those attributes.
|
||||
|
||||
If ``**kwargs`` are provided, then filter users with
|
||||
attributes matching ``**kwargs``.
|
||||
"""
|
||||
if group:
|
||||
base_url = '/groups/%s' % base.getid(group)
|
||||
else:
|
||||
@@ -58,7 +66,8 @@ class UserManager(base.CrudManager):
|
||||
return super(UserManager, self).list(
|
||||
base_url=base_url,
|
||||
domain_id=base.getid(domain),
|
||||
project_id=base.getid(project))
|
||||
project_id=base.getid(project),
|
||||
**kwargs)
|
||||
|
||||
def get(self, user):
|
||||
return super(UserManager, self).get(
|
||||
|
Reference in New Issue
Block a user