blob: 5493db0ac3a3b99553e0edb76f44066e65797921 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
########
Snippets
########
Reference
=========
* v4 API:
+ :class:`gitlab.v4.objects.Snippet`
+ :class:`gitlab.v4.objects.SnipptManager`
+ :attr:`gilab.Gitlab.snippets`
* GitLab API: https://docs.gitlab.com/ce/api/snippets.html
Examples
========
List snippets owned by the current user::
snippets = gl.snippets.list()
List the public snippets::
public_snippets = gl.snippets.public()
Get a snippet::
snippet = gl.snippets.get(snippet_id)
# get the content
content = snippet.content()
.. warning::
Blobs are entirely stored in memory unless you use the streaming feature.
See :ref:`the artifacts example <streaming_example>`.
Create a snippet::
snippet = gl.snippets.create({'title': 'snippet1',
'file_name': 'snippet1.py',
'content': open('snippet1.py').read()})
Update a snippet::
snippet.visibility_level = gitlab.Project.VISIBILITY_PUBLIC
snippet.save()
Delete a snippet::
gl.snippets.delete(snippet_id)
# or
snippet.delete()
|