Skip to content

Commit 9327850

Browse files
author
Gonchik Tsymzhitov
committed
Jira: review headers variables and aggregate into rest_client
1 parent 044e0be commit 9327850

File tree

2 files changed

+5
-9
lines changed

2 files changed

+5
-9
lines changed

atlassian/jira.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -638,11 +638,10 @@ def add_attachment(self, issue_key, filename):
638638
:param filename: str, name, if file in current directory or full path to file
639639
"""
640640
log.warning('Adding attachment...')
641-
headers = {'X-Atlassian-Token': 'no-check'}
642641
url = 'rest/api/2/issue/{}/attachments'.format(issue_key)
643642
with open(filename, 'rb') as attachment:
644643
files = {'file': attachment}
645-
return self.post(url, headers=headers, files=files)
644+
return self.post(url, headers=self.no_check_headers, files=files)
646645

647646
def get_server_info(self, do_health_check=False):
648647
"""
@@ -872,7 +871,6 @@ def user_disable_throw_rest_endpoint(self, username, url='rest/scriptrunner/late
872871
def user_get_websudo(self):
873872
""" Get web sudo cookies using normal http request"""
874873
url = 'secure/admin/WebSudoAuthenticate.jspa'
875-
headers = self.form_token_headers
876874
data = {
877875
'webSudoPassword': self.password,
878876
'webSudoIsPost': 'false',
@@ -886,7 +884,7 @@ def user_get_websudo(self):
886884
if atl_token:
887885
data['atl_token'] = atl_token
888886

889-
return self.post(path=url, data=data, headers=headers)
887+
return self.post(path=url, data=data, headers=self.form_token_headers)
890888

891889
def invalidate_websudo(self):
892890
"""
@@ -1843,12 +1841,8 @@ def delete_plugin(self, plugin_key):
18431841
return self.delete(url)
18441842

18451843
def check_plugin_manager_status(self):
1846-
headers = {
1847-
'X-Atlassian-Token': 'nocheck',
1848-
'Content-Type': 'application/vnd.atl.plugins.safe.mode.flag+json'
1849-
}
18501844
url = 'rest/plugins/latest/safe-mode'
1851-
return self.request(method='GET', path=url, headers=headers)
1845+
return self.request(method='GET', path=url, headers=self.safe_mode_headers)
18521846

18531847
def get_all_permissionschemes(self, expand=None):
18541848
"""

atlassian/rest_client.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ class AtlassianRestAPI(object):
1818
form_token_headers = {'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
1919
'X-Atlassian-Token': 'no-check'}
2020
no_check_headers = {'X-Atlassian-Token': 'no-check'}
21+
safe_mode_headers = {'X-Atlassian-Token': 'nocheck',
22+
'Content-Type': 'application/vnd.atl.plugins.safe.mode.flag+json'}
2123
experimental_headers_general = {'X-Atlassian-Token': 'no-check', 'X-ExperimentalApi': 'opt-in'}
2224
response = None
2325

0 commit comments

Comments
 (0)