summaryrefslogtreecommitdiff
path: root/gitlab/v4/objects.py
diff options
context:
space:
mode:
authorGauvain Pocentek <gauvain@pocentek.net>2018-06-13 22:01:48 +0200
committerGauvain Pocentek <gauvain@pocentek.net>2018-06-13 22:01:48 +0200
commitebf822cef7e686d8a198dcf419c20b1bfb88dea3 (patch)
treecedd504652d23863f6e7350805cec15cbd75842d /gitlab/v4/objects.py
parent5183069722224914bd6c2d25996163861183415b (diff)
downloadgitlab-ebf822cef7e686d8a198dcf419c20b1bfb88dea3.tar.gz
Add support for the LDAP gorups API
Diffstat (limited to 'gitlab/v4/objects.py')
-rw-r--r--gitlab/v4/objects.py44
1 files changed, 44 insertions, 0 deletions
diff --git a/gitlab/v4/objects.py b/gitlab/v4/objects.py
index d01d32f..4a401df 100644
--- a/gitlab/v4/objects.py
+++ b/gitlab/v4/objects.py
@@ -907,6 +907,50 @@ class IssueManager(ListMixin, RESTManager):
_types = {'labels': types.ListAttribute}
+class LDAPGroup(RESTObject):
+ _id_attr = None
+
+
+class LDAPGroupManager(RESTManager):
+ _path = '/ldap/groups'
+ _obj_cls = LDAPGroup
+ _list_filters = ('search', 'provider')
+
+ @exc.on_http_error(exc.GitlabListError)
+ def list(self, **kwargs):
+ """Retrieve a list of objects.
+
+ Args:
+ all (bool): If True, return all the items, without pagination
+ per_page (int): Number of items to retrieve per request
+ page (int): ID of the page to return (starts with page 1)
+ as_list (bool): If set to False and no pagination option is
+ defined, return a generator instead of a list
+ **kwargs: Extra options to send to the Gitlab server (e.g. sudo)
+
+ Returns:
+ list: The list of objects, or a generator if `as_list` is False
+
+ Raises:
+ GitlabAuthenticationError: If authentication is not correct
+ GitlabListError: If the server cannot perform the request
+ """
+ data = kwargs.copy()
+ if self.gitlab.per_page:
+ data.setdefault('per_page', self.gitlab.per_page)
+
+ if 'provider' in data:
+ path = '/ldap/%s/groups' % data['provider']
+ else:
+ path = self._path
+
+ obj = self.gitlab.http_list(path, **data)
+ if isinstance(obj, list):
+ return [self._obj_cls(self, item) for item in obj]
+ else:
+ return base.RESTObjectList(self, self._obj_cls, obj)
+
+
class License(RESTObject):
_id_attr = 'key'