| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 5183069 commit ebf822c
4 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -177,12 +177,23 @@ LDAP group links | |||
| 177 | 177 | ||
| 178 | 178 | Add an LDAP group link to an existing GitLab group:: | |
| 179 | 179 | ||
| 180 | - group.add_ldap_group_link(ldap_group_cn, gitlab.DEVELOPER_ACCESS, 'main') | ||
| 180 | + group.add_ldap_group_link(ldap_group_cn, gitlab.DEVELOPER_ACCESS, 'ldapmain') | ||
| 181 | 181 | ||
| 182 | 182 | Remove a link:: | |
| 183 | 183 | ||
| 184 | - group.delete_ldap_group_link(ldap_group_cn, 'main') | ||
| 184 | + group.delete_ldap_group_link(ldap_group_cn, 'ldapmain') | ||
| 185 | 185 | ||
| 186 | 186 | Sync the LDAP groups:: | |
| 187 | 187 | ||
| 188 | 188 | group.ldap_sync() | |
| 189 | + | ||
| 190 | + You can use the ``ldapgroups`` manager to list available LDAP groups:: | ||
| 191 | + | ||
| 192 | + # listing (supports pagination) | ||
| 193 | + ldap_groups = gl.ldapgroups.list() | ||
| 194 | + | ||
| 195 | + # filter using a group name | ||
| 196 | + ldap_groups = gl.ldapgroups.list(search='foo') | ||
| 197 | + | ||
| 198 | + # list the groups for a specific LDAP provider | ||
| 199 | + ldap_groups = gl.ldapgroups.list(search='foo', provider='ldapmain') | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -111,6 +111,7 @@ def __init__(self, url, private_token=None, oauth_token=None, email=None, | |||
| 111 | 111 | self.groups = objects.GroupManager(self) | |
| 112 | 112 | self.hooks = objects.HookManager(self) | |
| 113 | 113 | self.issues = objects.IssueManager(self) | |
| 114 | + self.ldapgroups = objects.LDAPGroupManager(self) | ||
| 114 | 115 | self.licenses = objects.LicenseManager(self) | |
| 115 | 116 | self.namespaces = objects.NamespaceManager(self) | |
| 116 | 117 | self.notificationsettings = objects.NotificationSettingsManager(self) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -907,6 +907,50 @@ class IssueManager(ListMixin, RESTManager): | |||
| 907 | 907 | _types = {'labels': types.ListAttribute} | |
| 908 | 908 | ||
| 909 | 909 | ||
| 910 | + class LDAPGroup(RESTObject): | ||
| 911 | + _id_attr = None | ||
| 912 | + | ||
| 913 | + | ||
| 914 | + class LDAPGroupManager(RESTManager): | ||
| 915 | + _path = '/ldap/groups' | ||
| 916 | + _obj_cls = LDAPGroup | ||
| 917 | + _list_filters = ('search', 'provider') | ||
| 918 | + | ||
| 919 | + @exc.on_http_error(exc.GitlabListError) | ||
| 920 | + def list(self, **kwargs): | ||
| 921 | + """Retrieve a list of objects. | ||
| 922 | + | ||
| 923 | + Args: | ||
| 924 | + all (bool): If True, return all the items, without pagination | ||
| 925 | + per_page (int): Number of items to retrieve per request | ||
| 926 | + page (int): ID of the page to return (starts with page 1) | ||
| 927 | + as_list (bool): If set to False and no pagination option is | ||
| 928 | + defined, return a generator instead of a list | ||
| 929 | + **kwargs: Extra options to send to the Gitlab server (e.g. sudo) | ||
| 930 | + | ||
| 931 | + Returns: | ||
| 932 | + list: The list of objects, or a generator if `as_list` is False | ||
| 933 | + | ||
| 934 | + Raises: | ||
| 935 | + GitlabAuthenticationError: If authentication is not correct | ||
| 936 | + GitlabListError: If the server cannot perform the request | ||
| 937 | + """ | ||
| 938 | + data = kwargs.copy() | ||
| 939 | + if self.gitlab.per_page: | ||
| 940 | + data.setdefault('per_page', self.gitlab.per_page) | ||
| 941 | + | ||
| 942 | + if 'provider' in data: | ||
| 943 | + path = '/ldap/%s/groups' % data['provider'] | ||
| 944 | + else: | ||
| 945 | + path = self._path | ||
| 946 | + | ||
| 947 | + obj = self.gitlab.http_list(path, **data) | ||
| 948 | + if isinstance(obj, list): | ||
| 949 | + return [self._obj_cls(self, item) for item in obj] | ||
| 950 | + else: | ||
| 951 | + return base.RESTObjectList(self, self._obj_cls, obj) | ||
| 952 | + | ||
| 953 | + | ||
| 910 | 954 | class License(RESTObject): | |
| 911 | 955 | _id_attr = 'key' | |
| 912 | 956 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -77,6 +77,7 @@ def end_log(): | |||
| 77 | 77 | if hasattr(group1, 'ldap_group_links'): | |
| 78 | 78 | for link in group1.ldap_group_links: | |
| 79 | 79 | group1.delete_ldap_group_link(link['cn'], link['provider']) | |
| 80 | + assert(gl.ldapgroups.list()) | ||
| 80 | 81 | group1.add_ldap_group_link(LDAP_CN, 30, LDAP_PROVIDER) | |
| 81 | 82 | group1.ldap_sync() | |
| 82 | 83 | group1.delete_ldap_group_link(LDAP_CN) | |
| Back | FazBrowse Home | New Git URL |
0 commit comments