Skip to content

Commit d4ef596

Browse files
authored
[BitBucket] Add get_groups method (#1356)
Co-authored-by: Stéphane BILQUÉ <Stephane.Bilque@caissedesdepots.fr>
1 parent c190157 commit d4ef596

File tree

3 files changed

+30
-0
lines changed

3 files changed

+30
-0
lines changed

atlassian/bitbucket/__init__.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,26 @@ def markup_preview(self, data):
3939
def _url_admin(self, api_version=None):
4040
return self.resource_url("admin", api_version=api_version)
4141

42+
def get_groups(self, group_filter=None, limit=25, start=0):
43+
"""
44+
Get list of bitbucket groups.
45+
Use 'group_filter' for get specific group or get all group if necessary.
46+
47+
:param group_filter: str - groupname
48+
:param limit: int - paginated limit to retrieve
49+
:param start: int - paginated point to start retrieving
50+
:return: The collection as JSON with all relevant information about the group
51+
"""
52+
url = self.resource_url("groups", api_version="1.0")
53+
params = {}
54+
if group_filter:
55+
params["filter"] = group_filter
56+
if limit:
57+
params["limit"] = limit
58+
if start:
59+
params["start"] = start
60+
return self._get_paged(url, params=params)
61+
4262
def group_members(self, group, start=0, limit=None):
4363
"""
4464
Get group of members

docs/bitbucket.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,9 @@ Groups and admins
160160

161161
.. code-block:: python
162162
163+
# Get groups. Use 'group_filter' parameter to get specific groups.
164+
bitbucket.groups(group_filter="group", limit=99999)
165+
163166
# Get group of members
164167
bitbucket.group_members(group, limit=99999)
165168
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# coding=utf-8
2+
from atlassian import Bitbucket
3+
4+
bitbucket = Bitbucket(url="http://localhost:7990", username="admin", password="admin")
5+
6+
data = bitbucket.get_groups(group_filter="group")
7+
print(data)

0 commit comments

Comments
 (0)