summaryrefslogtreecommitdiff
path: root/docs/gl_objects/snippets.rst
blob: 34c39fba811e0d00bfa30c7dc44cf3e9f6637b67 (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
########

You can store code snippets in Gitlab. Snippets can be attached to projects
(see :ref:`project_snippets`), but can also be detached.

* Object class: :class:`gitlab.objects.Namespace`
* Manager object: :attr:`gitlab.Gitlab.snippets`

Examples
========

List snippets woned by the current user:

.. literalinclude:: snippets.py
   :start-after: # list
   :end-before: # end list

List the public snippets:

.. literalinclude:: snippets.py
   :start-after: # public list
   :end-before: # end public list

Get a snippet:

.. literalinclude:: snippets.py
   :start-after: # get
   :end-before: # end get

.. warning::

   Blobs are entirely stored in memory unless you use the streaming feature.
   See :ref:`the artifacts example <streaming_example>`.


Create a snippet:

.. literalinclude:: snippets.py
   :start-after: # create
   :end-before: # end create

Update a snippet:

.. literalinclude:: snippets.py
   :start-after: # update
   :end-before: # end update

Delete a snippet:

.. literalinclude:: snippets.py
   :start-after: # delete
   :end-before: # end delete