Skip to content

Commit 41bf268

Browse files
authored
Bitbucket Server: Add API to get dashboard pull requests (atlassian-api#1212)
Retrieve a page of pull requests where the current authenticated user is involved as either a reviewer, author or a participant. The request may be filtered by pull request state, role or participant status. https://developer.atlassian.com/server/bitbucket/rest/v811/api-group-dashboard/#api-api-latest-dashboard-pull-requests-get
1 parent 119cc21 commit 41bf268

File tree

1 file changed

+64
-0
lines changed

1 file changed

+64
-0
lines changed

atlassian/bitbucket/__init__.py

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1829,6 +1829,70 @@ def get_pull_requests_participants(
18291829
params["limit"] = limit
18301830
return self._get_paged(url, params)
18311831

1832+
def get_dashboard_pull_requests(
1833+
self,
1834+
start=0,
1835+
limit=None,
1836+
closed_since=None,
1837+
role=None,
1838+
participant_status=None,
1839+
state=None,
1840+
order=None,
1841+
):
1842+
"""
1843+
Get all pull requests where the current authenticated user is
1844+
involved as either a reviewer, author or a participant
1845+
:param start:
1846+
:param limit:
1847+
:param closed_since: OPTIONAL, defaults to returning pull
1848+
requests regardless of closed since date. Permits
1849+
returning only pull requests with a closed timestamp set more
1850+
recently that (now - closedSince). Units are in seconds. So
1851+
for example if closed since 86400 is set only pull requests
1852+
closed in the previous 24 hours will be returned.
1853+
:param role: OPTIONAL, defaults to returning pull requests for
1854+
any role. If a role is supplied only pull requests where the
1855+
authenticated user is a participant in the given role will be
1856+
returned. Either REVIEWER, AUTHOR or PARTICIPANT.
1857+
:param participant_status: OPTIONAL, defaults to returning
1858+
pull requests with any participant status. A comma separated
1859+
list of participant status. That is, one or more of
1860+
UNAPPROVED, NEEDS_WORK, or APPROVED.
1861+
:param state: OPTIONAL, defaults to returning pull requests in
1862+
any state. If a state is supplied only pull requests in the
1863+
specified state will be returned. Either OPEN, DECLINED or
1864+
MERGED. Omit this parameter to return pull request in any
1865+
state.
1866+
1867+
:param order: OPTIONAL, defaults to NEWEST, the order to
1868+
return pull requests in, either OLDEST (as in: "oldest
1869+
first"), NEWEST, PARTICIPANT_STATUS, or CLOSED_DATE. Where
1870+
CLOSED_DATE is specified and the result set includes pull
1871+
requests that are not in the closed state, these pull requests
1872+
will appear first in the result set, followed by most recently
1873+
closed pull requests.
1874+
:return:
1875+
"""
1876+
if self.cloud:
1877+
raise Exception("Not supported in Bitbucket Cloud")
1878+
url = self.resource_url("dashboard/pull-requests")
1879+
params = {}
1880+
if start:
1881+
params["start"] = start
1882+
if limit is not None:
1883+
params["limit"] = limit
1884+
if closed_since is not None:
1885+
params["closedSince"] = closed_since
1886+
if role is not None:
1887+
params["role"] = role
1888+
if participant_status is not None:
1889+
params["participantStatus"] = participant_status
1890+
if state is not None:
1891+
params["state"] = state
1892+
if order is not None:
1893+
params["order"] = order
1894+
return self._get_paged(url, params=params)
1895+
18321896
def change_reviewed_status(self, project_key, repository_slug, pull_request_id, status, user_slug):
18331897
"""
18341898
Change the current user's status for a pull request.

0 commit comments

Comments
 (0)