mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-04-10 05:55:13 +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 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import urllib.error as urllib_error
|
||||
from http import HTTPStatus
|
||||
from urllib.parse import urlencode
|
||||
|
||||
from ansible.module_utils.basic import json
|
||||
|
|
@ -93,7 +94,7 @@ def check_zone_domain(data, domain):
|
|||
"""
|
||||
exists = False
|
||||
|
||||
if data.status_code in [201, 200]:
|
||||
if data.status_code in (HTTPStatus.CREATED, HTTPStatus.OK):
|
||||
for zone_domain in data.json():
|
||||
if zone_domain["domain"] == domain:
|
||||
exists = True
|
||||
|
|
@ -108,7 +109,7 @@ def check_zone(data, name):
|
|||
counter = 0
|
||||
exists = False
|
||||
|
||||
if data.status_code in [201, 200]:
|
||||
if data.status_code in (HTTPStatus.CREATED, HTTPStatus.OK):
|
||||
for zone in data.json():
|
||||
if zone["nickname"] == name:
|
||||
counter += 1
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue