File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ Reference
9
9
10
10
+ :class: `gitlab.v4.objects.Snippet `
11
11
+ :class: `gitlab.v4.objects.SnipptManager `
12
- + :attr: `gilab .Gitlab.snippets `
12
+ + :attr: `gitlab .Gitlab.snippets `
13
13
14
14
* GitLab API: https://docs.gitlab.com/ce/api/snippets.html
15
15
@@ -42,11 +42,19 @@ Create a snippet::
42
42
'file_name': 'snippet1.py',
43
43
'content': open('snippet1.py').read()})
44
44
45
- Update a snippet::
45
+ Update the snippet attributes ::
46
46
47
47
snippet.visibility_level = gitlab.Project.VISIBILITY_PUBLIC
48
48
snippet.save()
49
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
+
50
58
Delete a snippet::
51
59
52
60
gl.snippets.delete(snippet_id)
You can’t perform that action at this time.
0 commit comments