-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This plugin implements subcommands for listing current login user permissions. JIRA: PDC-1018
- Loading branch information
1 parent
904b791
commit dc147ac
Showing
2 changed files
with
35 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# -*- coding: utf-8 -*- | ||
# | ||
# Copyright (c) 2015 Red Hat | ||
# Licensed under The MIT License (MIT) | ||
# http://opensource.org/licenses/MIT | ||
# | ||
import json | ||
|
||
from pdc_client.plugins import PDCClientPlugin, get_permissions | ||
|
||
|
||
class PermissionPlugin(PDCClientPlugin): | ||
def register(self): | ||
subcmd = self.add_command('list-my-permissions', help='list my permissions') | ||
subcmd.set_defaults(func=self.permission_list) | ||
|
||
def permission_list(self, args): | ||
permissions = get_permissions(self.client.auth['current-user']) | ||
if args.json: | ||
print json.dumps(list(permissions)) | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong. |
||
return | ||
|
||
for permission in sorted(permissions): | ||
print permission | ||
|
||
|
||
PLUGIN_CLASSES = [PermissionPlugin] |
1 comment
on commit dc147ac
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you expect the get_permissions
function to be used in some other place? I think it would make sense to move it the plugin or even inline it.
One more thing: the call to
list
is not required here. The other modules are using it because ofget_paged
, which returns iterable that is not serializable byjson.dumps
.