mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-04-22 03:39:08 +00:00
[PR #11561/7436c0c9 backport][stable-12] replace literal HTTP codes with http.HTTPStatus (#11568)
replace literal HTTP codes with `http.HTTPStatus` (#11561)
* replace literal HTTP codes with http.HTTPStatus
* add changelog frag
(cherry picked from commit 7436c0c9ba)
Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com>
This commit is contained in:
parent
b3782a76e0
commit
25c475a7ef
18 changed files with 135 additions and 78 deletions
|
|
@ -12,6 +12,7 @@ import sys
|
|||
import time
|
||||
import traceback
|
||||
import typing as t
|
||||
from http import HTTPStatus
|
||||
from urllib.parse import urlencode
|
||||
|
||||
from ansible.module_utils.basic import env_fallback, missing_required_lib
|
||||
|
|
@ -199,7 +200,12 @@ class Response:
|
|||
|
||||
@property
|
||||
def ok(self):
|
||||
return self.status_code in (200, 201, 202, 204)
|
||||
return self.status_code in (
|
||||
HTTPStatus.OK,
|
||||
HTTPStatus.CREATED,
|
||||
HTTPStatus.ACCEPTED,
|
||||
HTTPStatus.NO_CONTENT,
|
||||
)
|
||||
|
||||
|
||||
class Scaleway:
|
||||
|
|
@ -302,7 +308,7 @@ class Scaleway:
|
|||
self.module.debug(f"fetch_state of resource: {resource['id']}")
|
||||
response = self.get(path=f"{self.api_path}/{resource['id']}")
|
||||
|
||||
if response.status_code == 404:
|
||||
if response.status_code == HTTPStatus.NOT_FOUND:
|
||||
return "absent"
|
||||
|
||||
if not response.ok:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue