jira
jira copied to clipboard
Epic Resource
Problem trying to solve
I am unable to find an epic using the API.
Possible solution(s)
Implementation of a Resource for an Epic:
https://docs.atlassian.com/jira-software/REST/7.3.1/#agile/1.0/epic https://developer.atlassian.com/cloud/jira/software/rest/api-group-epic/#api-group-epic=
So that I can create an epic programatically and add issues using: https://github.com/pycontribs/jira/blob/39a74e5ec9f47e66f090f5312a6693ec7c05b2ed/jira/client.py#L4852
Alternatives
No response
Additional Context
No response
This is required for us to properly test add_issues_to_epic()
to prevent stuff like #1244 happening
I've also thought about creating a resource for an Epic. I've done many epic interactions via "workarounds" https://github.com/studioj/jira-agile-toolbox/blob/main/jira_agile_toolbox/init.py
@adehad this is not as easy as it seems :-)
for showing the "sub-items" as we dont have access to the search AND the children only appear in the changelog it seems like the Epic resource needs to be getting an extra parameter from the client. Whether that parameter is a sub issue list or a jira client itself... any suggestions?
oho now I see the agile API ... nice diving into that
@adehad this is not as easy as it seems :-) for showing the "sub-items" as we dont have access to the search AND the children only appear in the changelog it seems like the Epic resource needs to be getting an extra parameter from the client. Whether that parameter is a sub issue list or a jira client itself... any suggestions?
@studioj sorry I don't think I understand, could you explain with an example what we don't have access to?
Sorry if the original description wasn't clear, my thoughts was that we would have in the resources.py
an Epic(Resource)
so we could do something like:
my_epic: jira.resources.Epic = jira_client.find_epic("my epic id or something") # or something
my_epic.add_issues(my_list_of_issues)
We could then use the above implementation in the client class as a separate method that might look like
def add_issues_to_epic(epic: Epic, issue_list: Union[List[str], List[Issue]]): ...
The epic in Jira API doesn't have the concept of children... Afaik That would mean to find its children we need to jql search query for epic link...
ah do you mean the issues of the epic?
There is: https://docs.atlassian.com/jira-software/REST/7.3.1/#agile/1.0/epic-getIssuesForEpic
and for Cloud: https://developer.atlassian.com/cloud/jira/software/rest/api-group-epic/#api-rest-agile-1-0-epic-epicidorkey-issue-get
Technically there is the self._session: ResilientSession
in the Resource
class that can be used if we want to make a request to these endpoints?
https://github.com/pycontribs/jira/blob/678903805e34d91c3905d73d20fcc7a3f5c8036c/jira/resources.py#L169
ah but it is a paginated endpoint, so we would want to use the fetch_pages()
, maybe as you say the client should have a method to get the issues from an epic?
jira_client.get_issues_in_epic(my_epic)
seems like the functionality of adding issues to epics is broken anyway https://github.com/pycontribs/jira/issues/1397 maybe we could extend the epic resource with
epic = Epic(...,...,...,...)
epic.add_issues(['proj-001', 'proj-002','proj-003'])
yep makes sense to me
seems like the functionality of adding issues to epics is broken anyway #1397 maybe we could extend the epic resource with
epic = Epic(...,...,...,...) epic.add_issues(['proj-001', 'proj-002','proj-003'])
The workaround in #1244 worked for me: https://github.com/pycontribs/jira/issues/1244#issuecomment-1008990954
I've added in a test_epic.py
in #1450 which has an example of how to create an Epic.
Important to note that it shares some endpoints with Issues, might make it a bit tricky