mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-06 13:22:48 +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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user