Skip to content

Commit 50b5c71

Browse files
committed
Remove duplicated method
1 parent 38685ec commit 50b5c71

File tree

6 files changed

+13
-66
lines changed

6 files changed

+13
-66
lines changed

atlassian/confluence.py

-15
Original file line numberDiff line numberDiff line change
@@ -2666,18 +2666,3 @@ def clean_jira_metadata_cache(self, global_id):
26662666
url = "rest/jira-metadata/1.0/metadata/cache"
26672667
params = {"globalId": global_id}
26682668
return self.delete(url, params=params)
2669-
2670-
def raise_for_status(self, response):
2671-
"""
2672-
Checks the response for an error status and raises an exception with the error message provided by the server
2673-
:param response:
2674-
:return:
2675-
"""
2676-
if 400 <= response.status_code < 600:
2677-
try:
2678-
j = response.json()
2679-
error_msg = j["message"]
2680-
except Exception:
2681-
response.raise_for_status()
2682-
else:
2683-
raise HTTPError(error_msg, response=response)

atlassian/jira.py

-15
Original file line numberDiff line numberDiff line change
@@ -4028,18 +4028,3 @@ def health_check(self):
40284028
# check as support tools
40294029
response = self.get("rest/supportHealthCheck/1.0/check/")
40304030
return response
4031-
4032-
def raise_for_status(self, response):
4033-
"""
4034-
Checks the response for an error status and raises an exception with the error message provided by the server
4035-
:param response:
4036-
:return:
4037-
"""
4038-
if 400 <= response.status_code < 600:
4039-
try:
4040-
j = response.json()
4041-
error_msg = "\n".join(j["errorMessages"] + [k + ": " + v for k, v in j["errors"].items()])
4042-
except Exception:
4043-
response.raise_for_status()
4044-
else:
4045-
raise HTTPError(error_msg, response=response)

atlassian/rest_client.py

+9-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from oauthlib.oauth1 import SIGNATURE_RSA
77
from requests_oauthlib import OAuth1, OAuth2
88
from six.moves.urllib.parse import urlencode
9-
9+
from requests import HTTPError
1010
from atlassian.request_utils import get_default_logger
1111

1212
log = get_default_logger(__name__)
@@ -389,4 +389,11 @@ def raise_for_status(self, response):
389389
:param response:
390390
:return:
391391
"""
392-
response.raise_for_status()
392+
if 400 <= response.status_code < 600:
393+
try:
394+
j = response.json()
395+
error_msg = "\n".join(j["errorMessages"] + [k + ": " + v for k, v in j["errors"].items()])
396+
except Exception:
397+
response.raise_for_status()
398+
else:
399+
raise HTTPError(error_msg, response=response)

atlassian/service_desk.py

-18
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
# coding=utf-8
22
import logging
33

4-
from requests import HTTPError
5-
64
from .rest_client import AtlassianRestAPI
75

86
log = logging.getLogger(__name__)
@@ -763,20 +761,4 @@ def create_request_type(
763761
}
764762

765763
url = "rest/servicedeskapi/servicedesk/{}/requesttype".format(service_desk_id)
766-
767764
return self.post(url, headers=self.experimental_headers, data=data)
768-
769-
def raise_for_status(self, response):
770-
"""
771-
Checks the response for an error status and raises an exception with the error message provided by the server
772-
:param response:
773-
:return:
774-
"""
775-
if 400 <= response.status_code < 600:
776-
try:
777-
j = response.json()
778-
error_msg = j["errorMessage"]
779-
except Exception:
780-
response.raise_for_status()
781-
else:
782-
raise HTTPError(error_msg, response=response)

atlassian/xray.py

-14
Original file line numberDiff line numberDiff line change
@@ -565,17 +565,3 @@ def update_test_repo_folder_tests(self, project_key, folder_id, add=None, remove
565565
data = {"add": add, "remove": remove}
566566
url = "rest/raven/1.0/api/testrepository/{0}/folders/{1}/tests".format(project_key, folder_id)
567567
return self.put(url, data=data)
568-
569-
def raise_for_status(self, response):
570-
"""
571-
Checks the response for an error status and raises an exception with the error message provided by the server
572-
:param response:
573-
:return:
574-
"""
575-
if 400 <= response.status_code < 600:
576-
try:
577-
error_msg = response.text
578-
except Exception:
579-
response.raise_for_status()
580-
else:
581-
raise HTTPError(error_msg, response=response)

docs/jira.rst

+4-2
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,10 @@ Manage projects
113113
# Get last project issuekey
114114
jira.get_project_issuekey_last(project)
115115
116-
# Get all project issue keys.
117-
# JIRA Cloud API can return up to 100 results in one API call. If your project has more than 100 issues see following community disussion: https://community.atlassian.com/t5/Jira-Software-questions/Is-there-a-limit-to-the-number-of-quot-items-quot-returned-from/qaq-p/1317195
116+
# Get all project issue keys.
117+
# JIRA Cloud API can return up to 100 results in one API call.
118+
# If your project has more than 100 issues see following community discussion:
119+
# https://community.atlassian.com/t5/Jira-Software-questions/Is-there-a-limit-to-the-number-of-quot-items-quot-returned-from/qaq-p/1317195
118120
jira.get_project_issuekey_all(project)
119121
120122
# Get project issues count

0 commit comments

Comments
 (0)