summaryrefslogtreecommitdiff
path: root/docs/gl_objects/snippets.py
diff options
context:
space:
mode:
Diffstat (limited to 'docs/gl_objects/snippets.py')
-rw-r--r--docs/gl_objects/snippets.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/docs/gl_objects/snippets.py b/docs/gl_objects/snippets.py
new file mode 100644
index 0000000..ca316c2
--- /dev/null
+++ b/docs/gl_objects/snippets.py
@@ -0,0 +1,26 @@
+# list
+snippets = gl.snippets.list()
+# end list
+
+# get
+snippet = gl.snippets.get(snippet_id)
+# get the content
+content = snippet.content()
+# end get
+
+# create
+snippet = gl.snippets.create({'title': 'snippet1',
+ 'file_name': 'snippet1.py',
+ 'content': open('snippet1.py').read()})
+# end create
+
+# update
+snippet.visibility_level = gitlab.VISIBILITY_PUBLIC
+snippet.save()
+# end update
+
+# delete
+gl.snippets.delete(snippet_id)
+# or
+snippet.delete()
+# end delete