summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGauvain Pocentek <gauvain@pocentek.net>2018-07-03 13:17:20 +0200
committerGauvain Pocentek <gauvain@pocentek.net>2018-07-03 13:17:20 +0200
commitbdbec678b1df23fd57b2e3c538e3eeac8d236690 (patch)
tree9e880d369f34102220f60365d375d0c301eab981
parent9751ab69ab4e492fadde015de922457e6a1c60ae (diff)
downloadgitlab-bdbec678b1df23fd57b2e3c538e3eeac8d236690.tar.gz
Improve the snippets examples
closes #543
-rw-r--r--docs/gl_objects/snippets.rst12
1 files changed, 10 insertions, 2 deletions
diff --git a/docs/gl_objects/snippets.rst b/docs/gl_objects/snippets.rst
index 9ab4ab2..5e09768 100644
--- a/docs/gl_objects/snippets.rst
+++ b/docs/gl_objects/snippets.rst
@@ -9,7 +9,7 @@ Reference
+ :class:`gitlab.v4.objects.Snippet`
+ :class:`gitlab.v4.objects.SnipptManager`
- + :attr:`gilab.Gitlab.snippets`
+ + :attr:`gitlab.Gitlab.snippets`
* GitLab API: https://docs.gitlab.com/ce/api/snippets.html
@@ -42,11 +42,19 @@ Create a snippet::
'file_name': 'snippet1.py',
'content': open('snippet1.py').read()})
-Update a snippet::
+Update the snippet attributes::
snippet.visibility_level = gitlab.Project.VISIBILITY_PUBLIC
snippet.save()
+To update a snippet code you need to create a ``ProjectSnippet`` object:
+
+ snippet = gl.snippets.get(snippet_id)
+ project = gl.projects.get(snippet.projec_id, lazy=True)
+ editable_snippet = project.snippets.get(snippet.id)
+ editable_snippet.code = new_snippet_content
+ editable_snippet.save()
+
Delete a snippet::
gl.snippets.delete(snippet_id)