Skip to content

Commit 1969abb

Browse files
author
Gauvain Pocentek
committed
add a Key() method for User objects
1 parent e31bb9e commit 1969abb

File tree

3 files changed

+18
-8
lines changed

3 files changed

+18
-8
lines changed

AUTHORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ Contributors
99
Daniel Kimsey <dekimsey@ufl.edu>
1010
Erik Weatherwax <erik.weatherwax@xls.xerox.com>
1111
Andrew Austin <aaustin@terremark.com>
12+
Koen Smets <koen.smets@gmail.com>

ChangeLog

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
Version 0.5
2+
3+
* Add SSH key for user
4+
15
Version 0.4
26

37
* Fix strings encoding (Closes #6)

gitlab.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -541,14 +541,6 @@ def json(self):
541541
return json.dumps(self.__dict__, cls=jsonEncoder)
542542

543543

544-
class User(GitlabObject):
545-
_url = '/users'
546-
shortPrintAttr = 'username'
547-
requiredCreateAttrs = ['email', 'password', 'username', 'name']
548-
optionalCreateAttrs = ['skype', 'linkedin', 'twitter', 'projects_limit',
549-
'extern_uid', 'provider', 'bio']
550-
551-
552544
class UserKey(GitlabObject):
553545
_url = '/users/%(user_id)s/keys'
554546
canGet = False
@@ -558,6 +550,19 @@ class UserKey(GitlabObject):
558550
requiredCreateAttrs = ['user_id', 'title', 'key']
559551

560552

553+
class User(GitlabObject):
554+
_url = '/users'
555+
shortPrintAttr = 'username'
556+
requiredCreateAttrs = ['email', 'password', 'username', 'name']
557+
optionalCreateAttrs = ['skype', 'linkedin', 'twitter', 'projects_limit',
558+
'extern_uid', 'provider', 'bio']
559+
560+
def Key(self, id=None, **kwargs):
561+
return self._getListOrObject(UserKey, id,
562+
user_id=self.id,
563+
**kwargs)
564+
565+
561566
class CurrentUserKey(GitlabObject):
562567
_url = '/user/keys'
563568
canUpdate = False

0 commit comments

Comments
 (0)