summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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)