Skip to content

Add pagelen to bitbucket cloud repositories and branches each functions #1506

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Mar 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions atlassian/bitbucket/cloud/repositories/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class Repositories(RepositoriesBase):
def __init__(self, url, *args, **kwargs):
super(Repositories, self).__init__(url, *args, **kwargs)

def each(self, after=None, role=None, q=None, sort=None):
def each(self, after=None, role=None, q=None, sort=None, pagelen=None):
"""
Get all repositories matching the criteria.

Expand All @@ -47,7 +47,9 @@ def each(self, after=None, role=None, q=None, sort=None):
See https://developer.atlassian.com/bitbucket/api/2/reference/meta/filtering for details.
:param sort: string: Name of a response property to sort results.
See https://developer.atlassian.com/bitbucket/api/2/reference/meta/filtering for details.

:param pagelen: int: Name of a response property to change page size.
See https://developer.atlassian.com/cloud/bitbucket/rest/intro/#pagination for details.

:return: A generator for the repository objects

API docs: https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories#get
Expand All @@ -64,6 +66,8 @@ def each(self, after=None, role=None, q=None, sort=None):
params["q"] = q
if sort is not None:
params["sort"] = sort
if pagelen is not None:
params["pagelen"] = pagelen
for repository in self._get_paged(None, params):
yield self._get_object(repository)

Expand Down
8 changes: 6 additions & 2 deletions atlassian/bitbucket/cloud/repositories/refs.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,22 +32,26 @@ def create(

return self._get_object(self.post(None, data))

def each(self, q=None, sort=None):
def each(self, q=None, sort=None, pagelen=None):
"""
Returns the list of refs in this repository.

:param q: string: Query string to narrow down the response.
See https://developer.atlassian.com/bitbucket/api/2/reference/meta/filtering for details.
:param sort: string: Name of a response property to sort results.
See https://developer.atlassian.com/bitbucket/api/2/reference/meta/filtering for details.

:param pagelen: int: Name of a response property to change page size.
See https://developer.atlassian.com/cloud/bitbucket/rest/intro/#pagination for details.

:return: A generator for the Ref objects
"""
params = {}
if sort is not None:
params["sort"] = sort
if q is not None:
params["q"] = q
if pagelen is not None:
params["pagelen"] = pagelen
for ref in self._get_paged(None, trailing=True, params=params):
yield self._get_object(super(Refs, self).get(ref.get("name")))

Expand Down
Loading