File tree Expand file tree Collapse file tree 2 files changed +23
-1
lines changed
Expand file tree Collapse file tree 2 files changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -136,4 +136,7 @@ gl.find_user(email='user@example.com')
136136
137137project = gl.project(1 )
138138project.find_member(username = ' user' )
139+
140+ # The GitLab API has support for more efficient searching of projects by name:
141+ gl.find_project_by_name(' name_query' ) # Server-side search
139142```
Original file line number Diff line number Diff line change @@ -463,8 +463,27 @@ def wrapped(*args, **kwargs):
463463 project_data = extra_action_fn (* args , ** kwargs )
464464 return gitlab3 .Project (parent , project_data )
465465 return wrapped
466+ class FindProjectByNameAction (ExtraActionDefinition ):
467+ """gl.find_project_by_name(query)"""
468+ url = '/projects/search/:query'
469+ method = _HTTP_GET
470+ optional_params = [
471+ 'per_page' ,
472+ 'page' ,
473+ ]
474+ @staticmethod
475+ def wrapper (extra_action_fn , parent ):
476+ def wrapped (* args , ** kwargs ):
477+ """Return a list of Projects"""
478+ import gitlab3
479+ ret = []
480+ projects = extra_action_fn (* args , ** kwargs )
481+ for project_data in projects :
482+ ret .append (gitlab3 .Project (parent , project_data ))
483+ return ret
484+ return wrapped
466485
467- extra_actions = [ AddProjectForUserAction ]
486+ extra_actions = [ AddProjectForUserAction , FindProjectByNameAction ]
468487
469488 sub_apis = [
470489 CurrentUser ,
You can’t perform that action at this time.
0 commit comments