[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_typesmethod 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
.getcall returns a dictionary upon which the next.getoperates. However, with advanced mode on, the result of the first.getis arequests.Responseobject. This class has no.getmethod, leading to the following error:Changes
This PR adds a helper method in the underlying
AtlassianRestAPIobject,_get_response_contentto help with retrieving API data regardless of the status ofadvanced_mode. This method takes the same arguments asAtlassianRestAPI.getwith 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:
{ "field1": { "field2": { "field3": "A" } } }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_typesget_issue_labelsget_issue_statusget_issue_status_idget_project_actors_for_role_projectget_status_id_from_nameget_issue_link_typesget_all_permissionschemesget_issue_security_schemesget_issue_security_scheme