mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
cloudflare_dns: minor code improvments
Tweaked some things on top of the well done PR #1768 - json import - fix expetion handling - fix indentation
This commit is contained in:
parent
68fc8e75f6
commit
39ece09e86
1 changed files with 13 additions and 6 deletions
|
@ -18,7 +18,14 @@
|
|||
# You should have received a copy of the GNU General Public License
|
||||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import json
|
||||
try:
|
||||
import json
|
||||
except ImportError:
|
||||
try:
|
||||
import simplejson as json
|
||||
except ImportError:
|
||||
# Let snippet from module_utils/basic.py return a proper error in this case
|
||||
pass
|
||||
import urllib
|
||||
|
||||
DOCUMENTATION = '''
|
||||
|
@ -263,7 +270,7 @@ class CloudflareAPI(object):
|
|||
result = json.loads(content)
|
||||
except AttributeError:
|
||||
error_msg += "; The API response was empty"
|
||||
except JSONDecodeError:
|
||||
except json.JSONDecodeError:
|
||||
error_msg += "; Failed to parse API response: {0}".format(content)
|
||||
|
||||
# received an error status but no data with details on what failed
|
||||
|
@ -358,10 +365,10 @@ class CloudflareAPI(object):
|
|||
def delete_dns_records(self,**kwargs):
|
||||
params = {}
|
||||
for param in ['port','proto','service','solo','type','record','value','weight','zone']:
|
||||
if param in kwargs:
|
||||
params[param] = kwargs[param]
|
||||
else:
|
||||
params[param] = getattr(self,param)
|
||||
if param in kwargs:
|
||||
params[param] = kwargs[param]
|
||||
else:
|
||||
params[param] = getattr(self,param)
|
||||
|
||||
records = []
|
||||
search_value = params['value']
|
||||
|
|
Loading…
Reference in a new issue