Skip to content

Commit 26112ff

Browse files
authored
Jira Agile: Add more method about board, properties (#1217)
Co-authored-by: Gonchik Tsymzhitov <[email protected]>
1 parent 749831e commit 26112ff

File tree

4 files changed

+189
-57
lines changed

4 files changed

+189
-57
lines changed

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# PyCharm
12
.idea
23
.sonarlint
34
.pytest_cache
@@ -121,4 +122,4 @@ venv_/
121122
.vscode
122123

123124
Pipfile
124-
Pipfile.lock
125+
Pipfile.lock

atlassian/VERSION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.40.1
1+
3.41.0

atlassian/jira.py

+138-40
Original file line numberDiff line numberDiff line change
@@ -4232,6 +4232,7 @@ def tempo_teams_get_memberships_for_member(self, username):
42324232
# Agile (Formerly Greenhopper) REST API implements
42334233
# Resource: https://docs.atlassian.com/jira-software/REST/7.3.1/
42344234
#######################################################################
4235+
# /rest/agile/1.0/backlog/issue
42354236
def move_issues_to_backlog(self, issue_keys):
42364237
"""
42374238
Move issues to backlog
@@ -4255,6 +4256,29 @@ def add_issues_to_backlog(self, issues):
42554256
data = dict(issues=issues)
42564257
return self.post(url, data=data)
42574258

4259+
def get_agile_board_by_filter_id(self, filter_id):
4260+
"""
4261+
Gets an agile board by the filter id
4262+
:param filter_id: int, str
4263+
"""
4264+
url = "rest/agile/1.0/board/filter/{filter_id}".format(filter_id=filter_id)
4265+
return self.get(url)
4266+
4267+
# /rest/agile/1.0/board
4268+
def create_agile_board(self, name, type, filter_id, location=None):
4269+
"""
4270+
Create an agile board
4271+
:param name: str: Must be less than 255 characters.
4272+
:param type: str: "scrum" or "kanban"
4273+
:param filter_id: int
4274+
:param location: dict, Optional. Only specify this for Jira Cloud!
4275+
"""
4276+
data = {"name": name, "type": type, "filterId": filter_id}
4277+
if location:
4278+
data["location"] = location
4279+
url = "rest/agile/1.0/board"
4280+
return self.post(url, data=data)
4281+
42584282
def get_all_agile_boards(
42594283
self,
42604284
board_name=None,
@@ -4287,44 +4311,35 @@ def get_all_agile_boards(
42874311

42884312
return self.get(url, params=params)
42894313

4290-
def get_agile_board(self, board_id):
4314+
def delete_agile_board(self, board_id):
42914315
"""
4292-
Get agile board info by id
4316+
Delete agile board by id
42934317
:param board_id:
42944318
:return:
42954319
"""
42964320
url = "rest/agile/1.0/board/{}".format(str(board_id))
4297-
return self.get(url)
4298-
4299-
def create_agile_board(self, name, type, filter_id, location=None):
4300-
"""
4301-
Create an agile board
4302-
:param name: str: Must be less than 255 characters.
4303-
:param type: str: "scrum" or "kanban"
4304-
:param filter_id: int
4305-
:param location: dict, Optional. Only specify this for Jira Cloud!
4306-
"""
4307-
data = {"name": name, "type": type, "filterId": filter_id}
4308-
if location:
4309-
data["location"] = location
4310-
url = "rest/agile/1.0/board"
4311-
return self.post(url, data=data)
4321+
return self.delete(url)
43124322

4313-
def delete_agile_board(self, board_id):
4323+
def get_agile_board(self, board_id):
43144324
"""
4315-
Delete agile board by id
4325+
Get agile board info by id
43164326
:param board_id:
43174327
:return:
43184328
"""
43194329
url = "rest/agile/1.0/board/{}".format(str(board_id))
4320-
return self.delete(url)
4330+
return self.get(url)
43214331

4322-
def get_agile_board_by_filter_id(self, filter_id):
4332+
def get_issues_for_backlog(self, board_id):
43234333
"""
4324-
Gets an agile board by the filter id
4325-
:param filter_id: int, str
4334+
Returns all issues from the board's backlog, for the given board ID.
4335+
This only includes issues that the user has permission to view.
4336+
The backlog contains incomplete issues that are not assigned to any future or active sprint.
4337+
Note, if the user does not have permission to view the board, no issues will be returned at all.
4338+
Issues returned from this resource include Agile fields, like sprint, closedSprints, flagged, and epic.
4339+
By default, the returned issues are ordered by rank.
4340+
:param board_id: int, str
43264341
"""
4327-
url = "rest/agile/1.0/board/filter/{filter_id}".format(filter_id=filter_id)
4342+
url = "rest/agile/1.0/board/{board_id}/backlog".format(board_id=board_id)
43284343
return self.get(url)
43294344

43304345
def get_agile_board_configuration(self, board_id):
@@ -4354,13 +4369,6 @@ def get_agile_board_configuration(self, board_id):
43544369
url = "rest/agile/1.0/board/{}/configuration".format(str(board_id))
43554370
return self.get(url)
43564371

4357-
def get_issues_for_backlog(self, board_id):
4358-
"""
4359-
:param board_id: int, str
4360-
"""
4361-
url = "rest/agile/1.0/board/{board_id}/backlog".format(board_id=board_id)
4362-
return self.get(url)
4363-
43644372
def get_issues_for_board(self, board_id, jql, fields="*all", start=0, limit=None, expand=None):
43654373
"""
43664374
Returns all issues from a board, for a given board Id.
@@ -4394,15 +4402,6 @@ def get_issues_for_board(self, board_id, jql, fields="*all", start=0, limit=None
43944402
url = "rest/agile/1.0/board/{board_id}/issue".format(board_id=board_id)
43954403
return self.get(url, params=params)
43964404

4397-
def get_agile_board_properties(self, board_id):
4398-
"""
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-
44064405
# /rest/agile/1.0/board/{boardId}/epic
44074406
def get_epics(
44084407
self,
@@ -4526,6 +4525,105 @@ def get_issues_without_epic(
45264525
params["maxResults"] = limit
45274526
return self.get(url, params=params)
45284527

4528+
# rest/agile/1.0/board/{boardId}/project
4529+
def get_all_projects_associated_with_board(self, board_id, start=0, limit=50):
4530+
"""
4531+
Returns all projects that are associated with the board,
4532+
for the given board ID. A project is associated with a board only
4533+
if the board filter explicitly filters issues by the project and guaranties that
4534+
all issues will come for one of those projects e.g. board's filter with
4535+
"project in (PR-1, PR-1) OR reporter = admin" jql Projects are returned only
4536+
if user can browse all projects that are associated with the board.
4537+
Note, if the user does not have permission to view the board,
4538+
no projects will be returned at all. Returned projects are ordered by the name.
4539+
:param board_id:
4540+
:param start: The starting index of the returned projects.
4541+
Base index: 0.
4542+
See the 'Pagination' section at the top of this page for more details.
4543+
:param limit: The maximum number of projects to return per page.
4544+
Default: 50.
4545+
See the 'Pagination' section at the top of this page for more details
4546+
:return:
4547+
"""
4548+
url = "/rest/agile/1.0/board/{boardId}/project".format(boardId=board_id)
4549+
params = {}
4550+
if start:
4551+
params["startAt"] = start
4552+
if limit:
4553+
params["maxResults"] = limit
4554+
return self.get(url, params=params)
4555+
4556+
# /rest/agile/1.0/board/{boardId}/properties
4557+
def get_agile_board_properties(self, board_id):
4558+
"""
4559+
Returns the keys of all properties for the board identified by the id.
4560+
The user who retrieves the property keys is required to have permissions to view the board.
4561+
:param board_id: int, str
4562+
"""
4563+
url = "rest/agile/1.0/board/{boardId}/properties".format(boardId=board_id)
4564+
return self.get(url)
4565+
4566+
def set_agile_board_property(self, board_id, property_key):
4567+
"""
4568+
Sets the value of the specified board's property.
4569+
You can use this resource to store a custom data
4570+
against the board identified by the id.
4571+
The user who stores the data is required to have permissions to modify the board.
4572+
:param board_id:
4573+
:param property_key:
4574+
:return:
4575+
"""
4576+
url = "/rest/agile/1.0/board/{boardId}/properties/{propertyKey}".format(
4577+
boardId=board_id, propertyKey=property_key
4578+
)
4579+
return self.put(url)
4580+
4581+
def get_agile_board_property(self, board_id, property_key):
4582+
"""
4583+
Returns the value of the property with a given key from the board identified by the provided id.
4584+
The user who retrieves the property is required to have permissions to view the board.
4585+
:param board_id:
4586+
:param property_key:
4587+
:return:
4588+
"""
4589+
url = "/rest/agile/1.0/board/{boardId}/properties/{propertyKey}".format(
4590+
boardId=board_id, propertyKey=property_key
4591+
)
4592+
return self.get(url)
4593+
4594+
def delete_agile_board_property(self, board_id, property_key):
4595+
"""
4596+
Removes the property from the board identified by the id.
4597+
Ths user removing the property is required to have permissions to modify the board.
4598+
:param board_id:
4599+
:param property_key:
4600+
:return:
4601+
"""
4602+
url = "/rest/agile/1.0/board/{boardId}/properties/{propertyKey}".format(
4603+
boardId=board_id, propertyKey=property_key
4604+
)
4605+
return self.delete(url)
4606+
4607+
# /rest/agile/1.0/board/{boardId}/settings
4608+
def get_agile_board_refined_velocity(self, board_id):
4609+
"""
4610+
Returns the estimation statistic settings of the board.
4611+
:param board_id:
4612+
:return:
4613+
"""
4614+
url = "/rest/agile/1.0/board/{boardId}/settings".format(boardId=board_id)
4615+
return self.get(url)
4616+
4617+
def set_agile_board_refined_velocity(self, board_id, data):
4618+
"""
4619+
Sets the estimation statistic settings of the board.
4620+
:param board_id:
4621+
:param data:
4622+
:return:
4623+
"""
4624+
url = "/rest/agile/1.0/board/{boardId}/settings".format(boardId=board_id)
4625+
return self.put(url, data=data)
4626+
45294627
def create_sprint(self, name, board_id, start_date=None, end_date=None, goal=None):
45304628
"""
45314629
Create a sprint within a board.

docs/jira.rst

+48-15
Original file line numberDiff line numberDiff line change
@@ -303,24 +303,42 @@ Epic Issues
303303
# Add issues to backlog
304304
jira.add_issues_to_backlog(issue_keys)
305305
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)
306+
# Get agile board by filter id
307+
jira.get_agile_board_by_filter_id(filter_id)
309308
310-
# Get agile board by id
311-
jira.get_agile_board(board_id)
309+
# Issues within an Epic
310+
jira.epic_issues(epic_key)
311+
312+
# Returns all epics from the board, for the given board Id.
313+
# This only includes epics that the user has permission to view.
314+
# Note, if the user does not have permission to view the board, no epics will be returned at all.
315+
jira.get_epics(board_id, done=False, start=0, limit=50, )
312316
313-
# Create an agile board
317+
# Returns all issues that belong to an epic on the board,
318+
# for the given epic Id and the board Id.
319+
# This only includes issues that the user has permission to view.
320+
# Issues returned from this resource include Agile fields, like sprint, closedSprints, flagged, and epic.
321+
# By default, the returned issues are ordered by rank.
322+
jira.get_issues_for_epic(board_id, epic_id, jql="", validate_query="", fields="*all", expand="", start=0, limit=50, )
323+
324+
Manage Boards
325+
-------------
326+
327+
.. code-block:: python
328+
329+
# Board
330+
# Creates a new board. Board name, type and filter Id is required.
314331
jira.create_agile_board(name, type, filter_id, location=None)
315332
333+
# Returns all boards.
334+
# This only includes boards that the user has permission to view.
335+
jira.get_all_agile_boards(board_name=None, project_key=None, board_type=None, start=0, limit=50)
336+
316337
# Delete agile board by id
317338
jira.delete_agile_board(board_id)
318339
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)
340+
# Get agile board by id
341+
jira.get_agile_board(board_id)
324342
325343
# Get issues for backlog
326344
jira.get_issues_for_board(board_id, start_at=0, max_results=50, jql=None,
@@ -330,14 +348,29 @@ Epic Issues
330348
# Get issues for board
331349
jira.get_issues_for_board(board_id, jql, fields="*all", start=0, limit=None, expand=None)
332350
351+
# Get agile board configuration by board id
352+
jira.get_agile_board_configuration(board_id)
353+
333354
# Gets a list of all the board properties
334355
jira.get_agile_board_properties(board_id)
335356
336-
# Issues within an Epic
337-
jira.epic_issues(epic_key)
357+
# Sets the value of the specified board's property.
358+
jira.set_agile_board_property(board_id, property_key)
338359
339-
Manage Boards
340-
-------------
360+
# Get Agile board property
361+
jira.get_agile_board_property(board_id, property_key)
362+
363+
# Delete Agile board property
364+
jira.delete_agile_board_property(board_id, property_key)
365+
366+
# Get Agile board refined velocity
367+
jira.get_agile_board_refined_velocity(board_id)
368+
369+
# Set Agile board refined velocity
370+
jira.set_agile_board_refined_velocity(board_id, refined_velocity)
371+
372+
Manage Sprints
373+
--------------
341374

342375
.. code-block:: python
343376

0 commit comments

Comments
 (0)