pycontribs / jira

Python Jira library. Development chat available on https://matrix.to/#/#pycontribs:matrix.org
https://jira.readthedocs.io
BSD 2-Clause "Simplified" License
1.95k stars 863 forks source link

Let people add issues to Epics via the issue key of the Epic, not only by the Epic ID #899

Open vwyz opened 4 years ago

vwyz commented 4 years ago

Is your feature request related to a problem? Please describe. Currently, if you want to use the Jira Python API to add issues to an Epic, you would use JIRA.add_issues_to_epic(...). And in this function, you have to provide the Epic ID for the Epic. You can't just point to the Epic's issue key. So you need to manually look up the Epic ID first before you try to link the issues, and that's kind of annoying, especially since you can't find it in the UI alone.

Describe the solution you'd like I'd like to update the Epic-linking function so that you can just hand it the issue key of the Epic, and it'll look up the Epic ID itself.

Describe alternatives you've considered I considered two options: (1) Update the existing add_issues_to_epic function so it can also have an Epics referred to by its issue key (not just its Epic ID). (2) Create a new function that does the same thing as add_issues_to_epic, but have this one take the Epic's issue key instead of its Epic ID.

I chose the first option because of how I discovered this problem in the first place: I tried to use the add_issues_to_epic function by referring to the issue key of the Epic, and it didn't work. I'd like other people who try this in the future to have it just work without any problems.

Other notes I'm planning to submit a PR to make this change.

MuqadderIqbal commented 4 years ago

I got around this by getting an Issue resource object based on the issue key I knew already and then passing its ID attribute to the method like this:

SSUPPORT_QUEUE_EPIC = jr.issue("MYTEST-7") # this is our example production support Epic
SUPPORT_QUEUE_EPIC_ID =  int(SUPPORT_QUEUE_EPIC.id) # integer ID of the example support epic

add_to_epic_response = jr.add_issues_to_epic(SUPPORT_QUEUE_EPIC_ID, [new_issue.key])  

I agree that having the ability to directly pass in an epic id will be more preferable.