1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

netcup_dnsapi: Add timeout paramter (#5301)

* netcup_dnsapi: Add timeout paramter

* add changelog fragment

* Apply suggestions from code review

Co-authored-by: Felix Fontein <felix@fontein.de>

* remove unnecessary newline

Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
Marc Leuser 2022-09-22 07:17:45 +02:00 committed by GitHub
parent cfecbd6763
commit a6c8078ccf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 1 deletions

View file

@ -0,0 +1,2 @@
minor_changes:
- netcup_dnsapi - add ``timeout`` parameter (https://github.com/ansible-collections/community.general/pull/5301).

View file

@ -72,6 +72,12 @@ options:
default: present
choices: [ 'present', 'absent' ]
type: str
timeout:
description:
- HTTP(S) connection timeout in seconds.
default: 5
type: int
version_added: 5.7.0
requirements:
- "nc-dnsapi >= 0.1.3"
author: "Nicolai Buchwitz (@nbuchwitz)"
@ -129,6 +135,18 @@ EXAMPLES = '''
type: "AAAA"
value: "::1"
solo: true
- name: Increase the connection timeout to avoid problems with an unstable connection
community.general.netcup_dns:
api_key: "..."
api_password: "..."
customer_id: "..."
domain: "example.com"
name: "mail"
type: "A"
value: "127.0.0.1"
timeout: 30
'''
RETURN = '''
@ -193,6 +211,7 @@ def main():
priority=dict(required=False, type='int'),
solo=dict(required=False, type='bool', default=False),
state=dict(required=False, choices=['present', 'absent'], default='present'),
timeout=dict(required=False, type='int', default=5),
),
supports_check_mode=True
@ -211,6 +230,7 @@ def main():
priority = module.params.get('priority')
solo = module.params.get('solo')
state = module.params.get('state')
timeout = module.params.get('timeout')
if record_type == 'MX' and not priority:
module.fail_json(msg="record type MX required the 'priority' argument")
@ -218,7 +238,7 @@ def main():
has_changed = False
all_records = []
try:
with nc_dnsapi.Client(customer_id, api_key, api_password) as api:
with nc_dnsapi.Client(customer_id, api_key, api_password, timeout) as api:
all_records = api.dns_records(domain)
record = DNSRecord(record, record_type, value, priority=priority)