Skip to content

Commit

Permalink
SnippetManager: all() -> public()
Browse files Browse the repository at this point in the history
Rename the method to make what it does more explicit.
  • Loading branch information
Gauvain Pocentek committed Dec 26, 2016
1 parent bd7d2f6 commit 7453895
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 15 deletions.
4 changes: 4 additions & 0 deletions docs/gl_objects/snippets.py
Expand Up @@ -2,6 +2,10 @@
snippets = gl.snippets.list()
# end list

# public list
public_snippets = gl.snippets.public()
# nd public list

# get
snippet = gl.snippets.get(snippet_id)
# get the content
Expand Down
8 changes: 7 additions & 1 deletion docs/gl_objects/snippets.rst
Expand Up @@ -11,12 +11,18 @@ You can store code snippets in Gitlab. Snippets can be attached to projects
Examples
========

List snippets:
List snippets woned by the current user:

.. literalinclude:: snippets.py
:start-after: # list
:end-before: # end list

List the public snippets:

.. literalinclude:: snippets.py
:start-after: # public list
:end-before: # end public list

Get a snippet:

.. literalinclude:: snippets.py
Expand Down
16 changes: 2 additions & 14 deletions gitlab/objects.py
Expand Up @@ -1054,8 +1054,8 @@ def content(self, streamed=False, action=None, chunk_size=1024, **kwargs):
class SnippetManager(BaseManager):
obj_cls = Snippet

def all(self, **kwargs):
"""List all the snippets
def public(self, **kwargs):
"""List all the public snippets.
Args:
all (bool): If True, return all the items, without pagination
Expand All @@ -1066,18 +1066,6 @@ def all(self, **kwargs):
"""
return self.gitlab._raw_list("/snippets/public", Snippet, **kwargs)

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


class Namespace(GitlabObject):
_url = '/namespaces'
Expand Down

0 comments on commit 7453895

Please sign in to comment.