aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Sokolovsky <paul.sokolovsky@linaro.org>2013-12-15 14:51:11 +0200
committerPaul Sokolovsky <paul.sokolovsky@linaro.org>2013-12-15 14:51:11 +0200
commit936dac6f9bccb8618f57dadcd03decd86f1aa00e (patch)
tree2b77ff601e36da0d9baade6832b057c372a1fd47
parentd11c300a4cbd903d910b70e4bfb7484b6aa14b88 (diff)
downloadcrowd-tool-936dac6f9bccb8618f57dadcd03decd86f1aa00e.tar.gz
Add "users" and "groups" commands.
-rwxr-xr-xcrowd-tool15
1 files changed, 14 insertions, 1 deletions
diff --git a/crowd-tool b/crowd-tool
index ee13c78..bc4fe7e 100755
--- a/crowd-tool
+++ b/crowd-tool
@@ -48,7 +48,7 @@ def rest(uri, params):
if __name__ == "__main__":
logging.basicConfig()
- optparser = optparse.OptionParser(usage="%prog user|alises|group|usergroups|ismember|groupusers|groupgroups|members")
+ optparser = optparse.OptionParser(usage="%prog users|groups|user|alises|group|usergroups|ismember|groupusers|groupgroups|members")
optparser.add_option("-u", "--user", default="rest-test", help="Crowd username")
optparser.add_option("-p", "--passwd", help="Crowd password")
optparser.add_option("-P", "--ask-passwd", action="store_true", help="Ask Crowd password")
@@ -72,6 +72,19 @@ if __name__ == "__main__":
elif args[0] == "group":
pprint(rest("/group.json", {"groupname": args[1], "expand": "attributes"}))
+ elif args[0] in ["users", "groups"]:
+ entity = args[0]
+ params = {"entity-type": entity[:-1]}
+ if len(args) > 1:
+ params["restriction"] = args[1]
+ data = rest("/search.json", params)
+ if options.raw:
+ pprint(data)
+ else:
+ names = sorted([x["name"] for x in data[entity]])
+ for n in names:
+ print n
+
elif args[0] == "usergroups":
url = "/user/group/nested.json" if options.nested else "/user/group/direct.json"
data = rest(url, {"username": args[1]})