summaryrefslogtreecommitdiff
path: root/gitlab
diff options
context:
space:
mode:
Diffstat (limited to 'gitlab')
-rw-r--r--gitlab/__init__.py2
-rw-r--r--gitlab/objects.py33
2 files changed, 33 insertions, 2 deletions
diff --git a/gitlab/__init__.py b/gitlab/__init__.py
index 836aaea..3ef5dff 100644
--- a/gitlab/__init__.py
+++ b/gitlab/__init__.py
@@ -65,6 +65,7 @@ class Gitlab(object):
http_username: (str): Username for HTTP authentication
http_password: (str): Password for HTTP authentication
Attributes:
+ user_emails (UserEmailManager): Manager for GitLab users' emails.
user_keys (UserKeyManager): Manager for GitLab users' SSH keys.
users (UserManager): Manager for GitLab users
group_projects (GroupProjectManager): Manager for GitLab group projects
@@ -136,6 +137,7 @@ class Gitlab(object):
self.session = requests.Session()
self.settings = ApplicationSettingsManager(self)
+ self.user_emails = UserEmailManager(self)
self.user_keys = UserKeyManager(self)
self.users = UserManager(self)
self.group_projects = GroupProjectManager(self)
diff --git a/gitlab/objects.py b/gitlab/objects.py
index 9ff8231..1827595 100644
--- a/gitlab/objects.py
+++ b/gitlab/objects.py
@@ -494,6 +494,18 @@ class GitlabObject(object):
return not self.__eq__(other)
+class UserEmail(GitlabObject):
+ _url = '/users/%(user_id)s/emails'
+ canUpdate = False
+ shortPrintAttr = 'email'
+ requiredUrlAttrs = ['user_id']
+ requiredCreateAttrs = ['email']
+
+
+class UserEmailManager(BaseManager):
+ obj_cls = UserEmail
+
+
class UserKey(GitlabObject):
_url = '/users/%(user_id)s/keys'
canGet = 'from_list'
@@ -519,7 +531,10 @@ class User(GitlabObject):
'projects_limit', 'extern_uid', 'provider', 'bio',
'admin', 'can_create_group', 'website_url',
'confirm', 'external']
- managers = [('keys', UserKeyManager, [('user_id', 'id')])]
+ managers = [
+ ('emails', UserEmailManager, [('user_id', 'id')]),
+ ('keys', UserKeyManager, [('user_id', 'id')])
+ ]
def _data_for_gitlab(self, extra_parameters={}, update=False):
if hasattr(self, 'confirm'):
@@ -601,6 +616,17 @@ class UserManager(BaseManager):
raise GitlabGetError('no such user: ' + username)
+class CurrentUserEmail(GitlabObject):
+ _url = '/user/emails'
+ canUpdate = False
+ shortPrintAttr = 'email'
+ requiredCreateAttrs = ['email']
+
+
+class CurrentUserEmailManager(BaseManager):
+ obj_cls = CurrentUserEmail
+
+
class CurrentUserKey(GitlabObject):
_url = '/user/keys'
canUpdate = False
@@ -619,7 +645,10 @@ class CurrentUser(GitlabObject):
canUpdate = False
canDelete = False
shortPrintAttr = 'username'
- managers = [('keys', CurrentUserKeyManager, [('user_id', 'id')])]
+ managers = [
+ ('emails', CurrentUserEmailManager, [('user_id', 'id')]),
+ ('keys', CurrentUserKeyManager, [('user_id', 'id')])
+ ]
def Key(self, id=None, **kwargs):
warnings.warn("`Key` is deprecated, use `keys` instead",