@@ -33,8 +33,13 @@ camel_re = re.compile('(.)([A-Z])')
3333
3434extra_actions = {
3535 gitlab .ProjectBranch : {
36- 'protect' : { 'requiredAttrs' : ['id' , 'project-id' ] },
37- 'unprotect' : { 'requiredAttrs' : ['id' , 'project-id' ] }
36+ 'protect' : {'requiredAttrs' : ['id' , 'project-id' ]},
37+ 'unprotect' : {'requiredAttrs' : ['id' , 'project-id' ]}
38+ },
39+ gitlab .Project : {
40+ 'search' : {'requiredAttrs' : ['query' ]},
41+ 'owned' : {'requiredAttrs' : []},
42+ 'all' : {'requiredAttrs' : []}
3843 },
3944}
4045
@@ -203,6 +208,24 @@ def do_update(cls, d):
203208
204209 return o
205210
211+ def do_project_search (d ):
212+ try :
213+ return gl .search_projects (d ['query' ])
214+ except :
215+ die ("Impossible to search projects (%s)" % str (e ))
216+
217+ def do_project_all ():
218+ try :
219+ return gl .all_projects ()
220+ except Exception as e :
221+ die ("Impossible to list all projects (%s)" % str (e ))
222+
223+ def do_project_owned ():
224+ try :
225+ return gl .owned_projects ()
226+ except :
227+ die ("Impossible to list owned projects (%s)" % str (e ))
228+
206229
207230ssl_verify = True
208231gitlab_id = None
@@ -338,6 +361,27 @@ elif action == "unprotect":
338361 o = do_get (cls , d )
339362 o .unprotect ()
340363
364+ elif action == "search" :
365+ if cls != gitlab .Project :
366+ die ("%s objects don't support this request" % what )
367+
368+ for o in do_project_search (d ):
369+ o .display (verbose )
370+
371+ elif action == "owned" :
372+ if cls != gitlab .Project :
373+ die ("%s objects don't support this request" % what )
374+
375+ for o in do_project_owned ():
376+ o .display (verbose )
377+
378+ elif action == "all" :
379+ if cls != gitlab .Project :
380+ die ("%s objects don't support this request" % what )
381+
382+ for o in do_project_all ():
383+ o .display (verbose )
384+
341385else :
342386 die ("Unknown action: %s. Use \" gitlab %s help\" to get details." % (action , what ))
343387
0 commit comments