From 3c26616909b516d670c8a5038425f51cc000397e Mon Sep 17 00:00:00 2001 From: Martin Adler <1208749+EagleIJoe@users.noreply.github.com> Date: Thu, 30 Aug 2018 04:35:57 +0200 Subject: [PATCH] DNS made easy module: add sandbox parameter to utilize sandbox API (#44639) * added sandbox param to switch between APIs Signed-off-by: Martin Adler <1208749+EagleIJoe@users.noreply.github.com> * Added warning as suggested --- lib/ansible/modules/net_tools/dnsmadeeasy.py | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/lib/ansible/modules/net_tools/dnsmadeeasy.py b/lib/ansible/modules/net_tools/dnsmadeeasy.py index da5f4e7861..48aee7befe 100644 --- a/lib/ansible/modules/net_tools/dnsmadeeasy.py +++ b/lib/ansible/modules/net_tools/dnsmadeeasy.py @@ -37,6 +37,13 @@ options: resolution required: true + sandbox: + description: + - Decides if the sandbox API should be used. Otherwise (default) the production API of DNS Made Easy is used. + type: bool + default: 'no' + version_added: 2.7 + record_name: description: - Record name to get/create/delete/update. If record_name is not specified; all records for the domain will be returned in "result" regardless @@ -368,12 +375,18 @@ from ansible.module_utils.six import string_types class DME2(object): - def __init__(self, apikey, secret, domain, module): + def __init__(self, apikey, secret, domain, sandbox, module): self.module = module self.api = apikey self.secret = secret - self.baseurl = 'https://api.dnsmadeeasy.com/V2.0/' + + if sandbox: + self.baseurl = 'https://api.sandbox.dnsmadeeasy.com/V2.0/' + self.module.warn(warning="Sandbox is enabled. All actions are made against the URL %s" % self.baseurl) + else: + self.baseurl = 'https://api.dnsmadeeasy.com/V2.0/' + self.domain = str(domain) self.domain_map = None # ["domain_name"] => ID self.record_map = None # ["record_name"] => ID @@ -537,6 +550,7 @@ def main(): account_key=dict(required=True), account_secret=dict(required=True, no_log=True), domain=dict(required=True), + sandbox=dict(default='no', type='bool'), state=dict(required=True, choices=['present', 'absent']), record_name=dict(required=False), record_type=dict(required=False, choices=[ @@ -575,7 +589,7 @@ def main(): sensitivities = dict(Low=8, Medium=5, High=3) DME = DME2(module.params["account_key"], module.params[ - "account_secret"], module.params["domain"], module) + "account_secret"], module.params["domain"], module.params["sandbox"], module) state = module.params["state"] record_name = module.params["record_name"] record_type = module.params["record_type"]