File: deploy_keys.rst

package info (click to toggle)
python-gitlab 1%3A8.0.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 2,884 kB
  • sloc: python: 25,823; makefile: 171; ruby: 27; javascript: 3
file content (74 lines) | stat: -rw-r--r-- 1,409 bytes parent folder | download
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
###########
Deploy keys
###########

Deploy keys
===========

Reference
---------

* v4 API:

  + :class:`gitlab.v4.objects.DeployKey`
  + :class:`gitlab.v4.objects.DeployKeyManager`
  + :attr:`gitlab.Gitlab.deploykeys`

* GitLab API: https://docs.gitlab.com/api/deploy_keys

Examples
--------

Add an instance-wide deploy key (requires admin access)::

    keys = gl.deploykeys.create({'title': 'instance key', 'key': INSTANCE_KEY})

List all deploy keys::

    keys = gl.deploykeys.list(get_all=True)

Deploy keys for projects
========================

Deploy keys can be managed on a per-project basis.

Reference
---------

* v4 API:

  + :class:`gitlab.v4.objects.ProjectKey`
  + :class:`gitlab.v4.objects.ProjectKeyManager`
  + :attr:`gitlab.v4.objects.Project.keys`

* GitLab API: https://docs.gitlab.com/api/deploy_keys

Examples
--------

List keys for a project::

    keys = project.keys.list(get_all=True)

Get a single deploy key::

    key = project.keys.get(key_id)

Create a deploy key for a project::

    key = project.keys.create({'title': 'jenkins key',
                               'key': open('/home/me/.ssh/id_rsa.pub').read()})

Delete a deploy key for a project::

    key = project.keys.list(key_id, get_all=True)
    # or
    key.delete()

Enable a deploy key for a project::

    project.keys.enable(key_id)

Disable a deploy key for a project::

    project.keys.delete(key_id)