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
pull/44878/head
Martin Adler 6 years ago committed by René Moser
parent 1dcf52c8fe
commit 3c26616909

@ -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"]

Loading…
Cancel
Save