@@ -43,75 +43,22 @@ def setsudo(self, user=None):
43
43
else :
44
44
self .headers ['SUDO' ] = user
45
45
46
- def getsshkeys (self ):
46
+ def getsshkey (self , key_id ):
47
47
"""
48
- Gets all the ssh keys for the current user
48
+ Get a single ssh key identified by key_id
49
49
50
- :return: a dictionary with the lists
50
+ :param key_id: the id of the key
51
+ :return: the key itself
51
52
"""
52
53
request = requests .get (
53
- self .keys_url , headers = self .headers , verify = self .verify_ssl , auth = self .auth , timeout = self .timeout )
54
+ '{0}/{1}' .format (self .keys_url , key_id ),
55
+ headers = self .headers , verify = self .verify_ssl , auth = self .auth , timeout = self .timeout )
54
56
55
57
if request .status_code == 200 :
56
58
return request .json ()
57
59
else :
58
60
return False
59
61
60
- def addsshkey (self , title , key ):
61
- """
62
- Add a new ssh key for the current user
63
-
64
- :param title: title of the new key
65
- :param key: the key itself
66
- :return: true if added, false if it didn't add it (it could be because the name or key already exists)
67
- """
68
- data = {'title' : title , 'key' : key }
69
-
70
- request = requests .post (
71
- self .keys_url , headers = self .headers , data = data ,
72
- verify = self .verify_ssl , auth = self .auth , timeout = self .timeout )
73
-
74
- if request .status_code == 201 :
75
- return True
76
- else :
77
- return False
78
-
79
- def addsshkeyuser (self , user_id , title , key ):
80
- """
81
- Add a new ssh key for the user identified by id
82
-
83
- :param user_id: id of the user to add the key to
84
- :param title: title of the new key
85
- :param key: the key itself
86
- :return: true if added, false if it didn't add it (it could be because the name or key already exists)
87
- """
88
- data = {'title' : title , 'key' : key }
89
-
90
- request = requests .post (
91
- '{0}/{1}/keys' .format (self .users_url , user_id ), headers = self .headers ,
92
- data = data , verify = self .verify_ssl , auth = self .auth , timeout = self .timeout )
93
-
94
- if request .status_code == 201 :
95
- return True
96
- else :
97
- return False
98
-
99
- def deletesshkey (self , key_id ):
100
- """
101
- Deletes an sshkey for the current user identified by id
102
-
103
- :param key_id: the id of the key
104
- :return: False if it didn't delete it, True if it was deleted
105
- """
106
- request = requests .delete (
107
- '{0}/{1}' .format (self .keys_url , key_id ), headers = self .headers ,
108
- verify = self .verify_ssl , auth = self .auth , timeout = self .timeout )
109
-
110
- if request .content == b'null' :
111
- return False
112
- else :
113
- return True
114
-
115
62
def getprojectsowned (self , page = 1 , per_page = 20 ):
116
63
"""
117
64
Returns a dictionary of all the projects for the current user
0 commit comments