summaryrefslogtreecommitdiff
path: root/gitlab
diff options
context:
space:
mode:
authorGauvain Pocentek <gauvain@pocentek.net>2013-12-26 14:56:33 +0100
committerGauvain Pocentek <gauvain@pocentek.net>2013-12-26 14:56:33 +0100
commitbd6b4aca6dea4b533c4ab15ee649be7b9aabd761 (patch)
tree6a220908c6bcb4673afe23d3fc011d9bee3d7bc0 /gitlab
parent2b4924e2fb5ddf32f7ed5e4d9dc055e57612f9c2 (diff)
downloadgitlab-bd6b4aca6dea4b533c4ab15ee649be7b9aabd761.tar.gz
support projects listing: search, all, owned
Diffstat (limited to 'gitlab')
-rwxr-xr-xgitlab48
1 files changed, 46 insertions, 2 deletions
diff --git a/gitlab b/gitlab
index 370cef1..4c8fb19 100755
--- a/gitlab
+++ b/gitlab
@@ -33,8 +33,13 @@ camel_re = re.compile('(.)([A-Z])')
extra_actions = {
gitlab.ProjectBranch: {
- 'protect': { 'requiredAttrs': ['id', 'project-id'] },
- 'unprotect': { 'requiredAttrs': ['id', 'project-id'] }
+ 'protect': {'requiredAttrs': ['id', 'project-id']},
+ 'unprotect': {'requiredAttrs': ['id', 'project-id']}
+ },
+ gitlab.Project: {
+ 'search': {'requiredAttrs': ['query']},
+ 'owned': {'requiredAttrs': []},
+ 'all': {'requiredAttrs': []}
},
}
@@ -203,6 +208,24 @@ def do_update(cls, d):
return o
+def do_project_search(d):
+ try:
+ return gl.search_projects(d['query'])
+ except:
+ die("Impossible to search projects (%s)" % str(e))
+
+def do_project_all():
+ try:
+ return gl.all_projects()
+ except Exception as e:
+ die("Impossible to list all projects (%s)" % str(e))
+
+def do_project_owned():
+ try:
+ return gl.owned_projects()
+ except:
+ die("Impossible to list owned projects (%s)" % str(e))
+
ssl_verify = True
gitlab_id = None
@@ -338,6 +361,27 @@ elif action == "unprotect":
o = do_get(cls, d)
o.unprotect()
+elif action == "search":
+ if cls != gitlab.Project:
+ die("%s objects don't support this request" % what)
+
+ for o in do_project_search(d):
+ o.display(verbose)
+
+elif action == "owned":
+ if cls != gitlab.Project:
+ die("%s objects don't support this request" % what)
+
+ for o in do_project_owned():
+ o.display(verbose)
+
+elif action == "all":
+ if cls != gitlab.Project:
+ die("%s objects don't support this request" % what)
+
+ for o in do_project_all():
+ o.display(verbose)
+
else:
die("Unknown action: %s. Use \"gitlab %s help\" to get details." % (action, what))