Skip to content

Commit a3f2ab1

Browse files
author
Gauvain Pocentek
committed
Add DeployKey{,Manager} classes
They are the same as Key and KeyManager but the name makes more sense. Fixes python-gitlab#212
1 parent ea0759d commit a3f2ab1

File tree

5 files changed

+40
-8
lines changed

5 files changed

+40
-8
lines changed

RELEASE_NOTES.rst

+11-1
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,15 @@ Changes from 0.19 to 0.20
1515
1616
group.projects.list()
1717
18-
Documentation for ``Group`` objects:
18+
Documentation:
1919
http://python-gitlab.readthedocs.io/en/stable/gl_objects/groups.html#examples
20+
21+
Related issue: https://github.com/gpocentek/python-gitlab/issues/209
22+
23+
* The ``Key`` objects are deprecated in favor of the new ``DeployKey`` objects.
24+
They are exactly the same but the name makes more sense.
25+
26+
Documentation:
27+
http://python-gitlab.readthedocs.io/en/stable/gl_objects/deploy_keys.html
28+
29+
Related issue: https://github.com/gpocentek/python-gitlab/issues/212

docs/gl_objects/deploy_keys.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# global list
2-
keys = gl.keys.list()
2+
keys = gl.deploykeys.list()
33
# end global list
44

55
# global get
6-
key = gl.keys.get(key_id)
6+
key = gl.deploykeys.get(key_id)
77
# end global get
88

99
# list

docs/gl_objects/deploy_keys.rst

+9-5
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@ Deploy keys
55
Deploy keys
66
===========
77

8-
Use :class:`~gitlab.objects.Key` objects to manipulate deploy keys. The
9-
:attr:`gitlab.Gitlab.keys` manager object provides helper functions.
8+
Deploy keys allow read-only access to multiple projects with a single SSH key.
9+
10+
* Object class: :class:`~gitlab.objects.DeployKey`
11+
* Manager object: :attr:`gitlab.Gitlab.deploykeys`
1012

1113
Examples
1214
--------
@@ -26,9 +28,11 @@ Get a single deploy key:
2628
Deploy keys for projects
2729
========================
2830

29-
Use :class:`~gitlab.objects.ProjectKey` objects to manipulate deploy keys for
30-
projects. The :attr:`gitlab.Gitlab.project_keys` and :attr:`Project.keys
31-
<gitlab.objects.Project.keys>` manager objects provide helper functions.
31+
Deploy keys can be managed on a per-project basis.
32+
33+
* Object class: :class:`~gitlab.objects.ProjectKey`
34+
* Manager objects: :attr:`gitlab.Gitlab.project_keys` and :attr:`Project.keys
35+
<gitlab.objects.Project.keys>`
3236

3337
Examples
3438
--------

gitlab/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ def __init__(self, url, private_token=None, email=None, password=None,
9191

9292
self.broadcastmessages = BroadcastMessageManager(self)
9393
self.keys = KeyManager(self)
94+
self.deploykeys = DeployKeyManager(self)
9495
self.gitlabciymls = GitlabciymlManager(self)
9596
self.gitignores = GitignoreManager(self)
9697
self.groups = GroupManager(self)

gitlab/objects.py

+17
Original file line numberDiff line numberDiff line change
@@ -802,11 +802,28 @@ class Key(GitlabObject):
802802
canUpdate = False
803803
canDelete = False
804804

805+
def __init__(self, *args, **kwargs):
806+
warnings.warn("`Key` is deprecated, use `DeployKey` instead",
807+
DeprecationWarning)
808+
super(Key, self).__init__(*args, **kwargs)
809+
805810

806811
class KeyManager(BaseManager):
807812
obj_cls = Key
808813

809814

815+
class DeployKey(GitlabObject):
816+
_url = '/deploy_keys'
817+
canGet = 'from_list'
818+
canCreate = False
819+
canUpdate = False
820+
canDelete = False
821+
822+
823+
class DeployKeyManager(BaseManager):
824+
obj_cls = DeployKey
825+
826+
810827
class NotificationSettings(GitlabObject):
811828
_url = '/notification_settings'
812829
_id_in_update_url = False

0 commit comments

Comments
 (0)