Skip to content

Commit

Permalink
[BitBucket] Add get_groups method (atlassian-api#1356)
Browse files Browse the repository at this point in the history
Co-authored-by: Stéphane BILQUÉ <[email protected]>
  • Loading branch information
sbilque and sbilque authored Mar 27, 2024
1 parent c190157 commit d4ef596
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
20 changes: 20 additions & 0 deletions atlassian/bitbucket/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,26 @@ def markup_preview(self, data):
def _url_admin(self, api_version=None):
return self.resource_url("admin", api_version=api_version)

def get_groups(self, group_filter=None, limit=25, start=0):
"""
Get list of bitbucket groups.
Use 'group_filter' for get specific group or get all group if necessary.
:param group_filter: str - groupname
:param limit: int - paginated limit to retrieve
:param start: int - paginated point to start retrieving
:return: The collection as JSON with all relevant information about the group
"""
url = self.resource_url("groups", api_version="1.0")
params = {}
if group_filter:
params["filter"] = group_filter
if limit:
params["limit"] = limit
if start:
params["start"] = start
return self._get_paged(url, params=params)

def group_members(self, group, start=0, limit=None):
"""
Get group of members
Expand Down
3 changes: 3 additions & 0 deletions docs/bitbucket.rst
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,9 @@ Groups and admins

.. code-block:: python
# Get groups. Use 'group_filter' parameter to get specific groups.
bitbucket.groups(group_filter="group", limit=99999)
# Get group of members
bitbucket.group_members(group, limit=99999)
Expand Down
7 changes: 7 additions & 0 deletions examples/bitbucket/bitbucket_groups.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# coding=utf-8
from atlassian import Bitbucket

bitbucket = Bitbucket(url="http://localhost:7990", username="admin", password="admin")

data = bitbucket.get_groups(group_filter="group")
print(data)

0 comments on commit d4ef596

Please sign in to comment.