Add the ability to list projects based on a user
Essentially performing GET /users/{user_id}/projects Change-Id: Iae6ddfc86a856fa24fbe293ec4af52ea671390f8 Closes-Bug: #1394793
This commit is contained in:
parent
4b239eea42
commit
5bc768bbc2
@ -79,6 +79,7 @@ List projects
|
||||
|
||||
os project list
|
||||
[--domain <domain>]
|
||||
[--user <user>]
|
||||
[--long]
|
||||
|
||||
.. option:: --domain <domain>
|
||||
@ -87,6 +88,12 @@ List projects
|
||||
|
||||
.. versionadded:: 3
|
||||
|
||||
.. option:: --user <user>
|
||||
|
||||
Filter projects by :option:`\<user\> <--user>` (name or ID)
|
||||
|
||||
.. versionadded:: 3
|
||||
|
||||
.. option:: --long
|
||||
|
||||
List additional fields in output
|
||||
|
@ -162,6 +162,11 @@ class ListProject(lister.Lister):
|
||||
metavar='<domain>',
|
||||
help='Filter projects by <domain> (name or ID)',
|
||||
)
|
||||
parser.add_argument(
|
||||
'--user',
|
||||
metavar='<user>',
|
||||
help='Filter projects by <user> (name or ID)',
|
||||
)
|
||||
parser.add_argument(
|
||||
'--long',
|
||||
action='store_true',
|
||||
@ -178,9 +183,24 @@ class ListProject(lister.Lister):
|
||||
else:
|
||||
columns = ('ID', 'Name')
|
||||
kwargs = {}
|
||||
|
||||
domain_id = None
|
||||
if parsed_args.domain:
|
||||
kwargs['domain'] = common.find_domain(identity_client,
|
||||
parsed_args.domain).id
|
||||
domain_id = common.find_domain(identity_client,
|
||||
parsed_args.domain).id
|
||||
kwargs['domain'] = domain_id
|
||||
|
||||
if parsed_args.user:
|
||||
if parsed_args.domain:
|
||||
user_id = utils.find_resource(identity_client.users,
|
||||
parsed_args.user,
|
||||
domain_id=domain_id).id
|
||||
else:
|
||||
user_id = utils.find_resource(identity_client.users,
|
||||
parsed_args.user).id
|
||||
|
||||
kwargs['user'] = user_id
|
||||
|
||||
data = identity_client.projects.list(**kwargs)
|
||||
return (columns,
|
||||
(utils.get_item_properties(
|
||||
|
Loading…
Reference in New Issue
Block a user