Skip to content

Commit f14682a

Browse files
Jira: Add function epic_issues to Jira module to fetch epic contents. Introduce unittest to Jira (atlassian-api#1007)
Signed-off-by: Martyn Bristow <martyn.bristow@gmail.com> Co-authored-by: Martyn <martyn.bristow@thermofisher.com>
1 parent e8142c6 commit f14682a

10 files changed

Lines changed: 619 additions & 1 deletion

File tree

CONTRIBUTING.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ Getting Started
1212
* Keep it sync_'ed while you are developing
1313
* Install pyenv_
1414
* Install related atlassian product for testing through SDK_ or use the cloud instance
15-
* ``pip install -r requirements-dev.txt``
15+
* `apt install libkrb5-dev`
16+
* Install Kerberos Dependency: `pip install -r requirements-dev.txt`
1617
* Start up related product:
1718
- Standalone product atlas-run-standalone_
1819
- For cloud product, just do registration
@@ -25,6 +26,7 @@ Getting Started
2526
.. _SDK: https://developer.atlassian.com/server/framework/atlassian-sdk/downloads/
2627
.. _atlas-run-standalone: https://developer.atlassian.com/server/framework/atlassian-sdk/atlas-run-standalone/
2728

29+
2830
Mandatory conditions
2931
--------------------
3032

atlassian/jira.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -829,6 +829,23 @@ def get_issue(self, issue_id_or_key, fields=None, properties=None, update_histor
829829

830830
return self.get(url, params=params)
831831

832+
def epic_issues(self, epic, fields="*all", expand=None):
833+
"""
834+
Given an epic return all child issues
835+
By default, all fields are returned in this get-issue resource
836+
Cloud Software API
837+
838+
:param epic: str
839+
:param fields: list of fields, for example: ['priority', 'summary', 'customfield_10007']
840+
:param expand: str: A comma-separated list of the parameters to expand.
841+
:returns: Issues within the epic
842+
:rtype: list
843+
"""
844+
base_url = self.resource_url("epic", api_root="rest/agile", api_version="1.0")
845+
url = "{base_url}/{key}/issue?fields={fields}".format(base_url=base_url, key=epic, fields=fields)
846+
params = {}
847+
return self.get(url, params=params)
848+
832849
def bulk_issue(self, issue_list, fields="*all"):
833850
"""
834851
:param fields:

docs/jira.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,15 @@ Manage issues
254254
# Restore an issue
255255
issue_restore(issue_id_or_key)
256256
257+
Epic Issues
258+
-------------
259+
260+
*Uses the Jira Agile API*
261+
262+
.. code-block:: python
263+
264+
# Issues within an Epic
265+
jira.epic_issues(epic_key)
257266
258267
Manage Boards
259268
-------------

examples/jira/jira_epic_issues.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# coding=utf-8
2+
from atlassian import Jira
3+
4+
jira = Jira(url="http://localhost:8080", username="admin", password="admin")
5+
6+
data = jira.epic_issues("ABC-123")
7+
print(data)

examples/jira/jira_issue.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# coding=utf-8
2+
from atlassian import Jira
3+
4+
jira = Jira(url="http://localhost:8080", username="admin", password="admin")
5+
6+
data = jira.issue("ABC-123")
7+
print(data)
Lines changed: 212 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,212 @@
1+
responses["fields=*all"] = {
2+
"expand": "schema,names",
3+
"startAt": 0,
4+
"maxResults": 50,
5+
"total": 1,
6+
"issues": [
7+
{
8+
"expand": "operations,versionedRepresentations,editmeta,changelog,renderedFields",
9+
"id": "125595",
10+
"self": "https://my.test.server.com/rest/agile/1.0/issue/123",
11+
"key": "BAR-111",
12+
"fields": {
13+
"customfield_18353": null,
14+
"customfield_18111": null,
15+
"resolution": {
16+
"self": "https://my.test.server.com/rest/api/2/resolution/10000",
17+
"id": "10000",
18+
"description": "Work has been completed on this issue.",
19+
"name": "Done",
20+
},
21+
"lastViewed": null,
22+
"aggregatetimeoriginalestimate": null,
23+
"issuelinks": [],
24+
"assignee": {
25+
"self": "https://my.test.server.com/rest/api/2/user?accountId=557058%3A574b2149-9be9-4a05-9515-fca57a297550",
26+
"accountId": "557058:574b2149-9be9-4a05-9515-fca57a297550",
27+
"emailAddress": "some.person@example.com",
28+
"avatarUrls": {
29+
"48x48": "https://avatar-management--avatars.us-west-2.prod.public.atl-paas.net/initials/s-3.png/48",
30+
"24x24": "https://avatar-management--avatars.us-west-2.prod.public.atl-paas.net/initials/s-3.png/24",
31+
"16x16": "https://avatar-management--avatars.us-west-2.prod.public.atl-paas.net/initials/s-3.png/16",
32+
"32x32": "https://avatar-management--avatars.us-west-2.prod.public.atl-paas.net/initials/s-3.png/32",
33+
},
34+
"displayName": "Some Person",
35+
"active": true,
36+
"timeZone": "America/New_York",
37+
"accountType": "atlassian",
38+
},
39+
"subtasks": [],
40+
"votes": {
41+
"self": "https://my.test.server.com/rest/api/2/issue/MIRCOLL-241/votes",
42+
"votes": 0,
43+
"hasVoted": false,
44+
},
45+
"worklog": {"startAt": 0, "maxResults": 20, "total": 0, "worklogs": []},
46+
"issuetype": {
47+
"self": "https://my.test.server.com/rest/api/2/issuetype/3",
48+
"id": "3",
49+
"description": "A small, distinct piece of work.",
50+
"iconUrl": "https://my.test.server.com/rest/api/2/universal_avatar/view/type/issuetype/avatar/12018?size=medium",
51+
"name": "Task",
52+
"subtask": false,
53+
"avatarId": 12018,
54+
"hierarchyLevel": 0,
55+
},
56+
"sprint": {
57+
"id": 1209,
58+
"self": "https://my.test.server.com/rest/agile/1.0/sprint/1209",
59+
"state": "future",
60+
"name": "Garbage Can Sprint",
61+
"originBoardId": 458,
62+
"goal": "This is for items that have been hanging out in the back log for a long time (3+ PIs) and Items that would take more effort to re-work than to start over.",
63+
},
64+
"timetracking": {},
65+
"environment": null,
66+
"duedate": null,
67+
"timeestimate": null,
68+
"status": {
69+
"self": "https://my.test.server.com/rest/api/2/status/10408",
70+
"description": "",
71+
"iconUrl": "https://my.test.server.com/images/icons/statuses/closed.png",
72+
"name": "Done",
73+
"id": "10408",
74+
"statusCategory": {
75+
"self": "https://my.test.server.com/rest/api/2/statuscategory/3",
76+
"id": 3,
77+
"key": "done",
78+
"colorName": "green",
79+
"name": "Done",
80+
},
81+
},
82+
"aggregatetimeestimate": null,
83+
"creator": {
84+
"self": "https://my.test.server.com/rest/api/2/user?accountId=557058%3A574b2149-9be9-4a05-9515-fca57a297550",
85+
"accountId": "557058:574b2149-9be9-4a05-9515-fca57a297550",
86+
"emailAddress": "some.person@example.com",
87+
"avatarUrls": {
88+
"48x48": "https://avatar-management--avatars.us-west-2.prod.public.atl-paas.net/initials/s-3.png/48",
89+
"24x24": "https://avatar-management--avatars.us-west-2.prod.public.atl-paas.net/initials/s-3.png/24",
90+
"16x16": "https://avatar-management--avatars.us-west-2.prod.public.atl-paas.net/initials/s-3.png/16",
91+
"32x32": "https://avatar-management--avatars.us-west-2.prod.public.atl-paas.net/initials/s-3.png/32",
92+
},
93+
"displayName": "Some Person",
94+
"active": true,
95+
"timeZone": "America/New_York",
96+
"accountType": "atlassian",
97+
},
98+
"timespent": null,
99+
"aggregatetimespent": null,
100+
"workratio": -1,
101+
"flagged": false,
102+
"labels": ["test"],
103+
"components": [],
104+
"reporter": {
105+
"self": "https://my.test.server.com/rest/api/2/user?accountId=557058%3A574b2149-9be9-4a05-9515-fca57a297550",
106+
"accountId": "557058:574b2149-9be9-4a05-9515-fca57a297550",
107+
"emailAddress": "some.person@example.com",
108+
"avatarUrls": {
109+
"48x48": "https://avatar-management--avatars.us-west-2.prod.public.atl-paas.net/initials/s-3.png/48",
110+
"24x24": "https://avatar-management--avatars.us-west-2.prod.public.atl-paas.net/initials/s-3.png/24",
111+
"16x16": "https://avatar-management--avatars.us-west-2.prod.public.atl-paas.net/initials/s-3.png/16",
112+
"32x32": "https://avatar-management--avatars.us-west-2.prod.public.atl-paas.net/initials/s-3.png/32",
113+
},
114+
"displayName": "Some Person",
115+
"active": true,
116+
"timeZone": "America/New_York",
117+
"accountType": "atlassian",
118+
},
119+
"progress": {"progress": 0, "total": 0},
120+
"project": {
121+
"self": "https://my.test.server.com/rest/api/2/project/23560",
122+
"id": "23560",
123+
"key": "MIRCOLL",
124+
"name": "miR Scientific Collaboration",
125+
"projectTypeKey": "software",
126+
"simplified": false,
127+
"avatarUrls": {
128+
"48x48": "https://my.test.server.com/rest/api/2/universal_avatar/view/type/project/avatar/24121",
129+
"24x24": "https://my.test.server.com/rest/api/2/universal_avatar/view/type/project/avatar/24121?size=small",
130+
"16x16": "https://my.test.server.com/rest/api/2/universal_avatar/view/type/project/avatar/24121?size=xsmall",
131+
"32x32": "https://my.test.server.com/rest/api/2/universal_avatar/view/type/project/avatar/24121?size=medium",
132+
},
133+
"projectCategory": {
134+
"self": "https://my.test.server.com/rest/api/2/projectCategory/10700",
135+
"id": "10700",
136+
"description": "Projects with active participation by customers",
137+
"name": "Customer Collaboration",
138+
},
139+
},
140+
"resolutiondate": "2022-02-03T11:33:07.230-0500",
141+
"watches": {
142+
"self": "https://my.test.server.com/rest/api/2/issue/MIRCOLL-241/watchers",
143+
"watchCount": 1,
144+
"isWatching": false,
145+
},
146+
"updated": "2022-06-02T10:05:44.150-0400",
147+
"timeoriginalestimate": null,
148+
"description": "Some Description",
149+
"summary": "Sample Story in Epic",
150+
"comment": {
151+
"comments": [],
152+
"self": "https://my.test.server.com/rest/api/2/issue/125595/comment",
153+
"maxResults": 0,
154+
"total": 0,
155+
"startAt": 0,
156+
},
157+
"statuscategorychangedate": "2022-03-23T12:46:25.923-0400",
158+
"fixVersions": [],
159+
"epic": "BAR-22",
160+
"priority": {
161+
"self": "https://my.test.server.com/rest/api/2/priority/5",
162+
"iconUrl": "https://my.test.server.com/images/icons/priorities/trivial.svg",
163+
"name": "Normal",
164+
"id": "5",
165+
},
166+
"versions": [],
167+
"customfield_17883": {
168+
"self": "https://my.test.server.com/rest/api/2/customFieldOption/17583",
169+
"value": "In Progress",
170+
"id": "17583",
171+
},
172+
"aggregateprogress": {"progress": 0, "total": 0},
173+
"issuerestriction": {"issuerestrictions": {}, "shouldDisplay": false},
174+
"created": "2021-06-14T15:22:58.891-0400",
175+
"security": null,
176+
"attachment": [
177+
{
178+
"self": "https://my.test.server.com/rest/api/2/attachment/94281",
179+
"id": "94281",
180+
"filename": "myattachment.pdf",
181+
"author": {
182+
"self": "https://my.test.server.com/rest/api/2/user?accountId=557058%3A574b2149-9be9-4a05-9515-fca57a297550",
183+
"accountId": "557058:574b2149-9be9-4a05-9515-fca57a297550",
184+
"emailAddress": "some.person@example.com",
185+
"avatarUrls": {
186+
"48x48": "https://avatar-management--avatars.us-west-2.prod.public.atl-paas.net/initials/s-3.png/48",
187+
"24x24": "https://avatar-management--avatars.us-west-2.prod.public.atl-paas.net/initials/s-3.png/24",
188+
"16x16": "https://avatar-management--avatars.us-west-2.prod.public.atl-paas.net/initials/s-3.png/16",
189+
"32x32": "https://avatar-management--avatars.us-west-2.prod.public.atl-paas.net/initials/s-3.png/32",
190+
},
191+
"displayName": "Some Person",
192+
"active": true,
193+
"timeZone": "America/New_York",
194+
"accountType": "atlassian",
195+
},
196+
"created": "2021-07-12T18:51:57.106-0400",
197+
"size": 20015,
198+
"mimeType": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
199+
"content": "https://my.test.server.com/rest/api/2/attachment/content/94281",
200+
}
201+
],
202+
"customfield_17950": [
203+
{
204+
"self": "https://my.test.server.com/rest/api/2/customFieldOption/17784",
205+
"value": "(Unassigned)",
206+
"id": "17784",
207+
}
208+
],
209+
},
210+
}
211+
],
212+
}

0 commit comments

Comments
 (0)