Skip to content

Bitbucket Server: Add API to get dashboard pull requests #1212

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 1 commit into from
Aug 6, 2023
Merged
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
64 changes: 64 additions & 0 deletions atlassian/bitbucket/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1829,6 +1829,70 @@ def get_pull_requests_participants(
params["limit"] = limit
return self._get_paged(url, params)

def get_dashboard_pull_requests(
self,
start=0,
limit=None,
closed_since=None,
role=None,
participant_status=None,
state=None,
order=None,
):
"""
Get all pull requests where the current authenticated user is
involved as either a reviewer, author or a participant
:param start:
:param limit:
:param closed_since: OPTIONAL, defaults to returning pull
requests regardless of closed since date. Permits
returning only pull requests with a closed timestamp set more
recently that (now - closedSince). Units are in seconds. So
for example if closed since 86400 is set only pull requests
closed in the previous 24 hours will be returned.
:param role: OPTIONAL, defaults to returning pull requests for
any role. If a role is supplied only pull requests where the
authenticated user is a participant in the given role will be
returned. Either REVIEWER, AUTHOR or PARTICIPANT.
:param participant_status: OPTIONAL, defaults to returning
pull requests with any participant status. A comma separated
list of participant status. That is, one or more of
UNAPPROVED, NEEDS_WORK, or APPROVED.
:param state: OPTIONAL, defaults to returning pull requests in
any state. If a state is supplied only pull requests in the
specified state will be returned. Either OPEN, DECLINED or
MERGED. Omit this parameter to return pull request in any
state.

:param order: OPTIONAL, defaults to NEWEST, the order to
return pull requests in, either OLDEST (as in: "oldest
first"), NEWEST, PARTICIPANT_STATUS, or CLOSED_DATE. Where
CLOSED_DATE is specified and the result set includes pull
requests that are not in the closed state, these pull requests
will appear first in the result set, followed by most recently
closed pull requests.
:return:
"""
if self.cloud:
raise Exception("Not supported in Bitbucket Cloud")
url = self.resource_url("dashboard/pull-requests")
params = {}
if start:
params["start"] = start
if limit is not None:
params["limit"] = limit
if closed_since is not None:
params["closedSince"] = closed_since
if role is not None:
params["role"] = role
if participant_status is not None:
params["participantStatus"] = participant_status
if state is not None:
params["state"] = state
if order is not None:
params["order"] = order
return self._get_paged(url, params=params)

def change_reviewed_status(self, project_key, repository_slug, pull_request_id, status, user_slug):
"""
Change the current user's status for a pull request.
Expand Down