We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see ourdocumentation.
There was an error while loading.Please reload this page.
1 parent9751ab6 commitbdbec67Copy full SHA for bdbec67
docs/gl_objects/snippets.rst
@@ -9,7 +9,7 @@ Reference
9
10
+:class:`gitlab.v4.objects.Snippet`
11
+:class:`gitlab.v4.objects.SnipptManager`
12
- +:attr:`gilab.Gitlab.snippets`
+ +:attr:`gitlab.Gitlab.snippets`
13
14
* GitLab API: https://docs.gitlab.com/ce/api/snippets.html
15
@@ -42,11 +42,19 @@ Create a snippet::
42
'file_name': 'snippet1.py',
43
'content': open('snippet1.py').read()})
44
45
-Updatea snippet::
+Updatethe snippet attributes::
46
47
snippet.visibility_level = gitlab.Project.VISIBILITY_PUBLIC
48
snippet.save()
49
50
+To update a snippet code you need to create a ``ProjectSnippet`` object:
51
+
52
+ snippet = gl.snippets.get(snippet_id)
53
+ project = gl.projects.get(snippet.projec_id, lazy=True)
54
+ editable_snippet = project.snippets.get(snippet.id)
55
+ editable_snippet.code = new_snippet_content
56
+ editable_snippet.save()
57
58
Delete a snippet::
59
60
gl.snippets.delete(snippet_id)