Skip to content
This repository was archived by the owner on Nov 4, 2020. It is now read-only.

Commit 57ed9c9

Browse files
committed
Moved over missed method
1 parent f7f8917 commit 57ed9c9

File tree

2 files changed

+20
-19
lines changed

2 files changed

+20
-19
lines changed

gitlab/__init__.py

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -57,22 +57,6 @@ def getsshkeys(self):
5757
else:
5858
return False
5959

60-
def getsshkey(self, key_id):
61-
"""
62-
Get a single ssh key identified by key_id
63-
64-
:param key_id: the id of the key
65-
:return: the key itself
66-
"""
67-
request = requests.get(
68-
'{0}/{1}'.format(self.keys_url, key_id),
69-
headers=self.headers, verify=self.verify_ssl, auth=self.auth, timeout=self.timeout)
70-
71-
if request.status_code == 200:
72-
return request.json()
73-
else:
74-
return False
75-
7660
def addsshkey(self, title, key):
7761
"""
7862
Add a new ssh key for the current user

gitlab/keys.py

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
from gitlab.base import Base
2+
from gitlab.helper import deprecated
23

34

45
class Keys(Base):
5-
def keys(self, id):
6+
def keys(self, key_id):
67
"""
78
Get SSH key with user by ID of an SSH key. Note only administrators can lookup SSH key with user by ID of an
89
SSH key.
@@ -11,7 +12,23 @@ def keys(self, id):
1112
>>> gitlab.login(user='root', password='5iveL!fe')
1213
>>> gitlab.keys(1)
1314
14-
:param id: The ID of an SSH key
15+
:param key_id: The ID of an SSH key
1516
:return: Dictionary containing Key data
1617
"""
17-
return self.get('/keys/{id}'.format(id=id), default_response={})
18+
return self.get('/keys/{key_id}'.format(key_id=key_id), default_response={})
19+
20+
@deprecated
21+
def getsshkey(self, key_id):
22+
"""
23+
Get a single ssh key identified by key_id
24+
25+
.. warning:: Warning this is being deprecated please use :func:`gitlab.Gitlab.keys`
26+
27+
>>> gitlab = Gitlab(host='http://localhost:10080', verify_ssl=False)
28+
>>> gitlab.login(user='root', password='5iveL!fe')
29+
>>> gitlab.getsshkeys(1)
30+
31+
:param key_id: The ID of an SSH key
32+
:return: Dictionary containing Key data
33+
"""
34+
return self.keys(key_id)

0 commit comments

Comments
 (0)