Skip to content

Commit deecf17

Browse files
author
Gauvain Pocentek
committed
[v4] Update project search API
* projects.search() is not implemented in v4 * add the 'search' attribute to projects.list()
1 parent c02dabd commit deecf17

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

docs/gl_objects/projects.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
projects = gl.projects.all()
1717

1818
# Search projects
19-
projects = gl.projects.list(search='query')
19+
projects = gl.projects.list(search='keyword')
2020
# end list
2121

2222
# get

gitlab/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,10 @@ def __init__(self, url, private_token=None, email=None, password=None,
126126
manager = cls(self)
127127
setattr(self, var_name, manager)
128128

129+
@property
130+
def api_version(self):
131+
return self._api_version
132+
129133
def _cls_to_manager_prefix(self, cls):
130134
# Manage bad naming decisions
131135
camel_case = (cls.__name__

gitlab/objects.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2278,6 +2278,7 @@ class Project(GitlabObject):
22782278
_constructorTypes = {'owner': 'User', 'namespace': 'Group'}
22792279
optionalListAttrs = ['search']
22802280
requiredCreateAttrs = ['name']
2281+
optionalListAttrs = ['search']
22812282
optionalCreateAttrs = ['path', 'namespace_id', 'description',
22822283
'issues_enabled', 'merge_requests_enabled',
22832284
'builds_enabled', 'wiki_enabled',
@@ -2678,6 +2679,8 @@ class ProjectManager(BaseManager):
26782679
def search(self, query, **kwargs):
26792680
"""Search projects by name.
26802681
2682+
API v3 only.
2683+
26812684
.. note::
26822685
26832686
The search is only performed on the project name (not on the
@@ -2696,6 +2699,9 @@ def search(self, query, **kwargs):
26962699
Returns:
26972700
list(gitlab.Gitlab.Project): A list of matching projects.
26982701
"""
2702+
if self.gitlab.api_version == '4':
2703+
raise NotImplementedError("Not supported by v4 API")
2704+
26992705
return self.gitlab._raw_list("/projects/search/" + query, Project,
27002706
**kwargs)
27012707

0 commit comments

Comments
 (0)