Skip to content

Commit 5df2d32

Browse files
committed
Jira Agile Rest Api methods
1 parent 1430dec commit 5df2d32

File tree

3 files changed

+190
-13
lines changed

3 files changed

+190
-13
lines changed

CONTRIBUTING.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,9 @@ All methods based on docs from: https://developer.atlassian.com/docs/
117117
* Jira
118118
- `Jira Server`_
119119
- `Jira Cloud`_
120+
* Jira Software
121+
- `Jira Software Server`_
122+
- `Jira Software Cloud`_
120123
* Jira Service Desk
121124
- `Jira Service Desk Server`_
122125
- `Jira Service Desk Cloud`_
@@ -154,6 +157,8 @@ All methods based on docs from: https://developer.atlassian.com/docs/
154157

155158
.. _`Jira Server`: https://docs.atlassian.com/software/jira/docs/api/REST/latest
156159
.. _`Jira Cloud`: https://developer.atlassian.com/cloud/jira/platform/rest/v3/
160+
.. _`Jira Software Server`: https://docs.atlassian.com/jira-software/REST/latest/
161+
.. _`Jira Software Cloud`: https://developer.atlassian.com/cloud/jira/software/rest/
157162
.. _`Confluence Server`: https://developer.atlassian.com/server/confluence/confluence-server-rest-api/
158163
.. _`Confluence Cloud`: https://developer.atlassian.com/cloud/confluence/rest/
159164
.. _`Crowd Server`: https://developer.atlassian.com/server/crowd/crowd-rest-apis/

atlassian/jira.py

Lines changed: 149 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4229,9 +4229,17 @@ def tempo_teams_get_memberships_for_member(self, username):
42294229
return self.get("rest/tempo-teams/2/user/{}/memberships".format(username))
42304230

42314231
#######################################################################
4232-
# Agile(Formerly Greenhopper) REST API implements
4232+
# Agile (Formerly Greenhopper) REST API implements
42334233
# Resource: https://docs.atlassian.com/jira-software/REST/7.3.1/
42344234
#######################################################################
4235+
def move_issues_to_backlog(self, issue_keys):
4236+
"""
4237+
Move issues to backlog
4238+
:param issue_keys: list of issues
4239+
:return:
4240+
"""
4241+
return self.add_issues_to_backlog(issues=issue_keys)
4242+
42354243
def add_issues_to_backlog(self, issues):
42364244
"""
42374245
Adding Issue(s) to Backlog
@@ -4291,8 +4299,8 @@ def get_agile_board(self, board_id):
42914299
def create_agile_board(self, name, type, filter_id, location=None):
42924300
"""
42934301
Create an agile board
4294-
:param name: str
4295-
:param type: str, scrum or kanban
4302+
:param name: str: Must be less than 255 characters.
4303+
:param type: str: "scrum" or "kanban"
42964304
:param filter_id: int
42974305
:param location: dict, Optional. Only specify this for Jira Cloud!
42984306
"""
@@ -4302,6 +4310,15 @@ def create_agile_board(self, name, type, filter_id, location=None):
43024310
url = "rest/agile/1.0/board"
43034311
return self.post(url, data=data)
43044312

4313+
def delete_agile_board(self, board_id):
4314+
"""
4315+
Delete agile board by id
4316+
:param board_id:
4317+
:return:
4318+
"""
4319+
url = "rest/agile/1.0/board/{}".format(str(board_id))
4320+
return self.delete(url)
4321+
43054322
def get_agile_board_by_filter_id(self, filter_id):
43064323
"""
43074324
Gets an agile board by the filter id
@@ -4346,7 +4363,11 @@ def get_issues_for_backlog(self, board_id):
43464363

43474364
def get_issues_for_board(self, board_id, jql, fields="*all", start=0, limit=None, expand=None):
43484365
"""
4349-
Get issues for board
4366+
Returns all issues from a board, for a given board Id.
4367+
This only includes issues that the user has permission to view.
4368+
Note, if the user does not have permission to view the board,
4369+
no issues will be returned at all. Issues returned from this resource include Agile fields,
4370+
like sprint, closedSprints, flagged, and epic. By default, the returned issues are ordered by rank.
43504371
:param board_id: int, str
43514372
:param jql:
43524373
:param fields: list of fields, for example: ['priority', 'summary', 'customfield_10007']
@@ -4373,22 +4394,137 @@ def get_issues_for_board(self, board_id, jql, fields="*all", start=0, limit=None
43734394
url = "rest/agile/1.0/board/{board_id}/issue".format(board_id=board_id)
43744395
return self.get(url, params=params)
43754396

4376-
def delete_agile_board(self, board_id):
4397+
def get_agile_board_properties(self, board_id):
43774398
"""
4378-
Delete agile board by id
4399+
Returns the keys of all properties for the board identified by the id.
4400+
The user who retrieves the property keys is required to have permissions to view the board.
4401+
:param board_id: int, str
4402+
"""
4403+
url = "rest/agile/1.0/board/{board_id}/properties".format(board_id=board_id)
4404+
return self.get(url)
4405+
4406+
# /rest/agile/1.0/board/{boardId}/epic
4407+
def get_epics(
4408+
self,
4409+
board_id,
4410+
done=False,
4411+
start=0,
4412+
limit=50,
4413+
):
4414+
"""
4415+
Returns all epics from the board, for the given board Id.
4416+
This only includes epics that the user has permission to view.
4417+
Note, if the user does not have permission to view the board, no epics will be returned at all.
43794418
:param board_id:
4419+
:param done: Filter results to epics that are either done or not done. Valid values: true, false.
4420+
:param start: The starting index of the returned epics. Base index: 0.
4421+
See the 'Pagination' section at the top of this page for more details.
4422+
:param limit: The maximum number of epics to return per page. Default: 50.
4423+
See the 'Pagination' section at the top of this page for more details.
43804424
:return:
43814425
"""
4382-
url = "rest/agile/1.0/board/{}".format(str(board_id))
4383-
return self.delete(url)
4426+
url = "rest/agile/1.0/board/{board_id}/epic".format(board_id=board_id)
4427+
params = {}
4428+
if done:
4429+
params["done"] = done
4430+
if start:
4431+
params["startAt"] = start
4432+
if limit:
4433+
params["maxResults"] = limit
4434+
return self.get(url, params=params)
43844435

4385-
def get_agile_board_properties(self, board_id):
4436+
def get_issues_for_epic(
4437+
self, board_id, epic_id, jql="", validate_query="", fields="*all", expand="", start=0, limit=50
4438+
):
43864439
"""
4387-
Gets a list of all the board properties
4388-
:param board_id: int, str
4440+
Returns all issues that belong to an epic on the board, for the given epic Id and the board Id.
4441+
This only includes issues that the user has permission to view.
4442+
Issues returned from this resource include Agile fields, like sprint, closedSprints, flagged, and epic.
4443+
By default, the returned issues are ordered by rank.
4444+
:param epic_id:
4445+
:param board_id:
4446+
:param jql: Filter results using a JQL query.
4447+
If you define an order in your JQL query,
4448+
it will override the default order of the returned issues.
4449+
:param validate_query: Specifies whether to validate the JQL query or not. Default: true.
4450+
:param fields: The list of fields to return for each issue.
4451+
By default, all navigable and Agile fields are returned.
4452+
:param expand: A comma-separated list of the parameters to expand.
4453+
:param start: The starting index of the returned issues.
4454+
Base index: 0.
4455+
See the 'Pagination' section at the top of this page for more details.
4456+
:param limit: The maximum number of issues to return per page.
4457+
Default: 50.
4458+
See the 'Pagination' section at the top of this page for more details.
4459+
Note, the total number of issues returned is limited
4460+
by the property 'jira.search.views.default.max' in your JIRA instance.
4461+
If you exceed this limit, your results will be truncated.
4462+
:return:
43894463
"""
4390-
url = "rest/agile/1.0/board/{board_id}/properties".format(board_id=board_id)
4391-
return self.get(url)
4464+
url = "/rest/agile/1.0/board/{boardId}/epic/{epicId}/issue".format(epicId=epic_id, boardId=board_id)
4465+
params = {}
4466+
if jql:
4467+
params["jql"] = jql
4468+
if validate_query:
4469+
params["validateQuery"] = validate_query
4470+
if fields:
4471+
params["fields"] = fields
4472+
if expand:
4473+
params["expand"] = expand
4474+
if start:
4475+
params["startAt"] = start
4476+
if limit:
4477+
params["maxResults"] = limit
4478+
return self.get(url, params=params)
4479+
4480+
def get_issues_without_epic(
4481+
self,
4482+
board_id,
4483+
jql="",
4484+
validate_query="",
4485+
fields="*all",
4486+
expand="",
4487+
start=0,
4488+
limit=50,
4489+
):
4490+
"""
4491+
Returns all issues that do not belong to any epic on a board, for a given board Id.
4492+
This only includes issues that the user has permission to view.
4493+
Issues returned from this resource include Agile fields, like sprint, closedSprints, flagged, and epic.
4494+
By default, the returned issues are ordered by rank.
4495+
:param board_id:
4496+
:param jql: Filter results using a JQL query.
4497+
If you define an order in your JQL query,
4498+
it will override the default order of the returned issues.
4499+
:param validate_query: Specifies whether to validate the JQL query or not. Default: true.
4500+
:param fields: The list of fields to return for each issue.
4501+
By default, all navigable and Agile fields are returned.
4502+
:param expand: A comma-separated list of the parameters to expand.
4503+
:param start: The starting index of the returned issues.
4504+
Base index: 0.
4505+
See the 'Pagination' section at the top of this page for more details.
4506+
:param limit: The maximum number of issues to return per page. Default: 50.
4507+
See the 'Pagination' section at the top of this page for more details.
4508+
Note, the total number of issues returned is limited by
4509+
the property 'jira.search.views.default.max' in your JIRA instance.
4510+
If you exceed this limit, your results will be truncated.
4511+
:return:
4512+
"""
4513+
url = "/rest/agile/1.0/board/{boardId}/epic/none/issue".format(boardId=board_id)
4514+
params = {}
4515+
if jql:
4516+
params["jql"] = jql
4517+
if validate_query:
4518+
params["validateQuery"] = validate_query
4519+
if fields:
4520+
params["fields"] = fields
4521+
if expand:
4522+
params["expand"] = expand
4523+
if start:
4524+
params["startAt"] = start
4525+
if limit:
4526+
params["maxResults"] = limit
4527+
return self.get(url, params=params)
43924528

43934529
def create_sprint(self, name, board_id, start_date=None, end_date=None, goal=None):
43944530
"""

docs/jira.rst

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,42 @@ Epic Issues
297297

298298
.. code-block:: python
299299
300+
# Move issues to backlog
301+
jira.move_issues_to_backlog(issue_keys)
302+
303+
# Add issues to backlog
304+
jira.add_issues_to_backlog(issue_keys)
305+
306+
# Returns all boards.
307+
# This only includes boards that the user has permission to view.
308+
jira.get_all_agile_boards(board_name=None, project_key=None, board_type=None, start=0, limit=50)
309+
310+
# Get agile board by id
311+
jira.get_agile_board(board_id)
312+
313+
# Create an agile board
314+
jira.create_agile_board(name, type, filter_id, location=None)
315+
316+
# Delete agile board by id
317+
jira.delete_agile_board(board_id)
318+
319+
# Get agile board by filter id
320+
jira.get_agile_board_by_filter_id(filter_id)
321+
322+
# Get agile board configuration by board id
323+
jira.get_agile_board_configuration(board_id)
324+
325+
# Get issues for backlog
326+
jira.get_issues_for_board(board_id, start_at=0, max_results=50, jql=None,
327+
validate_query=True, fields=None, expand=None,
328+
override_screen_security=None, override_editable_flag=None)
329+
330+
# Get issues for board
331+
jira.get_issues_for_board(board_id, jql, fields="*all", start=0, limit=None, expand=None)
332+
333+
# Gets a list of all the board properties
334+
jira.get_agile_board_properties(board_id)
335+
300336
# Issues within an Epic
301337
jira.epic_issues(epic_key)
302338

0 commit comments

Comments
 (0)