@@ -33,8 +33,13 @@ camel_re = re.compile('(.)([A-Z])')
33
33
34
34
extra_actions = {
35
35
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' : []}
38
43
},
39
44
}
40
45
@@ -203,6 +208,24 @@ def do_update(cls, d):
203
208
204
209
return o
205
210
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
+
206
229
207
230
ssl_verify = True
208
231
gitlab_id = None
@@ -338,6 +361,27 @@ elif action == "unprotect":
338
361
o = do_get (cls , d )
339
362
o .unprotect ()
340
363
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
+
341
385
else :
342
386
die ("Unknown action: %s. Use \" gitlab %s help\" to get details." % (action , what ))
343
387
0 commit comments