[Jira] Fix get method data retrieval failures when advanced mode is on #1449
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Relevant to #1137, #501
Background
A couple methods in Jira use chained method calls to retrieve data immediately after querying the API. For example, the
get_issue_link_types
method returns the data with the following line:atlassian-python-api/atlassian/jira.py
Line 3184 in e9520ab
With advanced mode off, this is no problem because the first
.get
call returns a dictionary upon which the next.get
operates. However, with advanced mode on, the result of the first.get
is arequests.Response
object. This class has no.get
method, leading to the following error:Changes
This PR adds a helper method in the underlying
AtlassianRestAPI
object,_get_response_content
to help with retrieving API data regardless of the status ofadvanced_mode
. This method takes the same arguments asAtlassianRestAPI.get
with one additional requirement:fields
. This is a list of tuples of the format(<field name>, <default value>)
. These fields are used for getting the data out of the API JSON. Note that including a default value is optional.You can pass in multiple fields and they will be sequentially queried. E.g. if the response looked like the following:
you could query it with
self._get_response_content(url, fields=[("field1",), ("field2",), ("field3",)])
and return"A"
The following methods have been updated to use this new method:
get_issue_link_types
get_issue_labels
get_issue_status
get_issue_status_id
get_project_actors_for_role_project
get_status_id_from_name
get_issue_link_types
get_all_permissionschemes
get_issue_security_schemes
get_issue_security_scheme