@@ -4,7 +4,30 @@ Search API
44
55You can search for resources at the top level, in a project or in a group.
66Searches are based on a scope (issues, merge requests, and so on) and a search
7- string.
7+ string. The following constants are provided to represent the possible scopes:
8+
9+
10+ * Shared scopes (global, group and project):
11+
12+ + ``gitlab.SEARCH_SCOPE_PROJECTS ``: ``projects ``
13+ + ``gitlab.SEARCH_SCOPE_ISSUES ``: ``issues ``
14+ + ``gitlab.SEARCH_SCOPE_MERGE_REQUESTS ``: ``merge_requests ``
15+ + ``gitlab.SEARCH_SCOPE_MILESTONES ``: ``milestones ``
16+ + ``gitlab.SEARCH_SCOPE_WIKI_BLOBS ``: ``wiki_blobs ``
17+ + ``gitlab.SEARCH_SCOPE_COMMITS ``: ``commits ``
18+ + ``gitlab.SEARCH_SCOPE_BLOBS ``: ``blobs ``
19+ + ``gitlab.SEARCH_SCOPE_USERS ``: ``users ``
20+
21+
22+ * specific global scope:
23+
24+ + ``gitlab.SEARCH_SCOPE_GLOBAL_SNIPPET_TITLES ``: ``snippet_titles ``
25+
26+
27+ * specific project scope:
28+
29+ + ``gitlab.SEARCH_SCOPE_PROJECT_NOTES ``: ``notes ``
30+
831
932Reference
1033---------
@@ -23,31 +46,32 @@ Examples
2346Search for issues matching a specific string::
2447
2548 # global search
26- gl.search('issues' , 'regression')
49+ gl.search(gitlab.SEARCH_SCOPE_ISSUES , 'regression')
2750
2851 # group search
2952 group = gl.groups.get('mygroup')
30- group.search('issues' , 'regression')
53+ group.search(gitlab.SEARCH_SCOPE_ISSUES , 'regression')
3154
3255 # project search
3356 project = gl.projects.get('myproject')
34- project.search('issues' , 'regression')
57+ project.search(gitlab.SEARCH_SCOPE_ISSUES , 'regression')
3558
3659The ``search() `` methods implement the pagination support::
3760
3861 # get lists of 10 items, and start at page 2
39- gl.search('issues' , search_str, page=2, per_page=10)
62+ gl.search(gitlab.SEARCH_SCOPE_ISSUES , search_str, page=2, per_page=10)
4063
4164 # get a generator that will automatically make required API calls for
4265 # pagination
43- for item in gl.search('issues' , search_str, as_list=False):
66+ for item in gl.search(gitlab.SEARCH_SCOPE_ISSUES , search_str, as_list=False):
4467 do_something(item)
4568
4669The search API doesn't return objects, but dicts. If you need to act on
4770objects, you need to create them explicitly::
4871
49- for item in gl.search('issues' , search_str, as_list=False):
72+ for item in gl.search(gitlab.SEARCH_SCOPE_ISSUES , search_str, as_list=False):
5073 issue_project = gl.projects.get(item['project_id'], lazy=True)
5174 issue = issue_project.issues.get(item['iid'])
5275 issue.state = 'closed'
5376 issue.save()
77+
0 commit comments