Skip to content

Commit

Permalink
netcup_dnsapi: Add timeout paramter (#5301)
Browse files Browse the repository at this point in the history
* netcup_dnsapi: Add timeout paramter

* add changelog fragment

* Apply suggestions from code review

Co-authored-by: Felix Fontein <[email protected]>

* remove unnecessary newline

Co-authored-by: Felix Fontein <[email protected]>
(cherry picked from commit a6c8078)
  • Loading branch information
marcquark authored and patchback[bot] committed Sep 22, 2022
1 parent baec510 commit c26974b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
2 changes: 2 additions & 0 deletions changelogs/fragments/5301-netcup_dnsapi-timeout.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
minor_changes:
- netcup_dnsapi - add ``timeout`` parameter (https://github.com/ansible-collections/community.general/pull/5301).
22 changes: 21 additions & 1 deletion plugins/modules/net_tools/netcup_dns.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,12 @@
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)"
Expand Down Expand Up @@ -129,6 +135,18 @@
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 = '''
Expand Down Expand Up @@ -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
Expand All @@ -211,14 +230,15 @@ 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")

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)

Expand Down

0 comments on commit c26974b

Please sign in to comment.