From 1969abb3bbb61c4cbb8499496be9f48bd74cf558 Mon Sep 17 00:00:00 2001 From: Gauvain Pocentek Date: Thu, 26 Dec 2013 13:21:12 +0100 Subject: [PATCH] add a Key() method for User objects --- AUTHORS | 1 + ChangeLog | 4 ++++ gitlab.py | 21 +++++++++++++-------- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/AUTHORS b/AUTHORS index 635ddd8d0..1ef4b2ba5 100644 --- a/AUTHORS +++ b/AUTHORS @@ -9,3 +9,4 @@ Contributors Daniel Kimsey Erik Weatherwax Andrew Austin +Koen Smets diff --git a/ChangeLog b/ChangeLog index 9da1715be..ec1229974 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Version 0.5 + + * Add SSH key for user + Version 0.4 * Fix strings encoding (Closes #6) diff --git a/gitlab.py b/gitlab.py index 368e9097a..1bd6aff18 100644 --- a/gitlab.py +++ b/gitlab.py @@ -541,14 +541,6 @@ def json(self): return json.dumps(self.__dict__, cls=jsonEncoder) -class User(GitlabObject): - _url = '/users' - shortPrintAttr = 'username' - requiredCreateAttrs = ['email', 'password', 'username', 'name'] - optionalCreateAttrs = ['skype', 'linkedin', 'twitter', 'projects_limit', - 'extern_uid', 'provider', 'bio'] - - class UserKey(GitlabObject): _url = '/users/%(user_id)s/keys' canGet = False @@ -558,6 +550,19 @@ class UserKey(GitlabObject): requiredCreateAttrs = ['user_id', 'title', 'key'] +class User(GitlabObject): + _url = '/users' + shortPrintAttr = 'username' + requiredCreateAttrs = ['email', 'password', 'username', 'name'] + optionalCreateAttrs = ['skype', 'linkedin', 'twitter', 'projects_limit', + 'extern_uid', 'provider', 'bio'] + + def Key(self, id=None, **kwargs): + return self._getListOrObject(UserKey, id, + user_id=self.id, + **kwargs) + + class CurrentUserKey(GitlabObject): _url = '/user/keys' canUpdate = False