mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-03-26 21:33:12 +00:00
fix: remove HTTPStatus constructs introduced in Python 3.11 (#11573)
* fix: remove HTTPStatus constructs introduced in Python 3.11 * add changelog frag
This commit is contained in:
@@ -117,8 +117,7 @@ class UTM:
|
||||
returns the info for an object in utm
|
||||
"""
|
||||
info, result = self._lookup_entry(self.module, self.request_url)
|
||||
_status = HTTPStatus(info["status"])
|
||||
if _status.is_client_error or _status.is_server_error:
|
||||
if info["status"] >= HTTPStatus.BAD_REQUEST: # 4xx and 5xx errors
|
||||
self.module.fail_json(result=json.loads(info))
|
||||
else:
|
||||
if result is None:
|
||||
@@ -135,8 +134,7 @@ class UTM:
|
||||
|
||||
is_changed = False
|
||||
info, result = self._lookup_entry(self.module, self.request_url)
|
||||
_status = HTTPStatus(info["status"])
|
||||
if _status.is_client_error or _status.is_server_error:
|
||||
if info["status"] >= HTTPStatus.BAD_REQUEST: # 4xx and 5xx errors
|
||||
self.module.fail_json(result=json.loads(info))
|
||||
else:
|
||||
data_as_json_string = self.module.jsonify(self.module.params)
|
||||
@@ -144,8 +142,7 @@ class UTM:
|
||||
response, info = fetch_url(
|
||||
self.module, self.request_url, method="POST", headers=combined_headers, data=data_as_json_string
|
||||
)
|
||||
_status = HTTPStatus(info["status"])
|
||||
if _status.is_client_error or _status.is_server_error:
|
||||
if info["status"] >= HTTPStatus.BAD_REQUEST: # 4xx and 5xx errors
|
||||
self.module.fail_json(msg=json.loads(info["body"]))
|
||||
is_changed = True
|
||||
result = self._clean_result(json.loads(response.read()))
|
||||
@@ -158,8 +155,7 @@ class UTM:
|
||||
headers=combined_headers,
|
||||
data=data_as_json_string,
|
||||
)
|
||||
_status = HTTPStatus(info["status"])
|
||||
if _status.is_client_error or _status.is_server_error:
|
||||
if info["status"] >= HTTPStatus.BAD_REQUEST: # 4xx and 5xx errors
|
||||
self.module.fail_json(msg=json.loads(info["body"]))
|
||||
is_changed = True
|
||||
result = self._clean_result(json.loads(response.read()))
|
||||
@@ -192,8 +188,7 @@ class UTM:
|
||||
headers={"Accept": "application/json", "X-Restd-Err-Ack": "all"},
|
||||
data=self.module.jsonify(self.module.params),
|
||||
)
|
||||
_status = HTTPStatus(info["status"])
|
||||
if _status.is_client_error or _status.is_server_error:
|
||||
if info["status"] >= HTTPStatus.BAD_REQUEST: # 4xx and 5xx errors
|
||||
self.module.fail_json(msg=json.loads(info["body"]))
|
||||
else:
|
||||
is_changed = True
|
||||
|
||||
Reference in New Issue
Block a user