Skip to content

Commit

Permalink
[v4] Add projects.list() attributes
Browse files Browse the repository at this point in the history
All the ProjectManager filter methods can now be handled by
projects.list().
  • Loading branch information
Gauvain Pocentek committed May 23, 2017
1 parent 6684c13 commit e789cee
Showing 1 changed file with 3 additions and 37 deletions.
40 changes: 3 additions & 37 deletions gitlab/v4/objects.py
Expand Up @@ -1776,7 +1776,9 @@ class Project(GitlabObject):
_constructorTypes = {'owner': 'User', 'namespace': 'Group'}
optionalListAttrs = ['search']
requiredCreateAttrs = ['name']
optionalListAttrs = ['search']
optionalListAttrs = ['search', 'owned', 'starred', 'archived',
'visibility', 'order_by', 'sort', 'simple',
'membership', 'statistics']
optionalCreateAttrs = ['path', 'namespace_id', 'description',
'issues_enabled', 'merge_requests_enabled',
'builds_enabled', 'wiki_enabled',
Expand Down Expand Up @@ -2167,42 +2169,6 @@ def delete_all(self, **kwargs):
class ProjectManager(BaseManager):
obj_cls = Project

def all(self, **kwargs):
"""List all the projects (need admin rights).
Args:
all (bool): If True, return all the items, without pagination
**kwargs: Additional arguments to send to GitLab.
Returns:
list(gitlab.Gitlab.Project): The list of projects.
"""
return self.gitlab._raw_list("/projects/all", Project, **kwargs)

def owned(self, **kwargs):
"""List owned projects.
Args:
all (bool): If True, return all the items, without pagination
**kwargs: Additional arguments to send to GitLab.
Returns:
list(gitlab.Gitlab.Project): The list of owned projects.
"""
return self.gitlab._raw_list("/projects/owned", Project, **kwargs)

def starred(self, **kwargs):
"""List starred projects.
Args:
all (bool): If True, return all the items, without pagination
**kwargs: Additional arguments to send to GitLab.
Returns:
list(gitlab.Gitlab.Project): The list of starred projects.
"""
return self.gitlab._raw_list("/projects/starred", Project, **kwargs)


class GroupProject(Project):
_url = '/groups/%(group_id)s/projects'
Expand Down

0 comments on commit e789cee

Please sign in to comment.