Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DNS made easy module: add sandbox parameter to utilize sandbox API #44639

Merged
merged 2 commits into from
Aug 30, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 17 additions & 3 deletions lib/ansible/modules/net_tools/dnsmadeeasy.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@
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
Expand Down Expand Up @@ -368,12 +375,18 @@

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/'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest to also warn a bit about so users won't "forget" they are using the sandbox url

self.module.warn(warning="Sandbox is enabled. All actions are made against the URL %s" % self.baseurl)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the suggestion. I will include this verbatim.

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
Expand Down Expand Up @@ -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=[
Expand Down Expand Up @@ -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"]
Expand Down