cloudflare_dns: Rename account_api_token parameter (#62707)

Name change triggered by the new parameter _api_token_ (8cabf1c) being
a bit too similar to the old name _account_api_token_. At the same
time _account_api_key_ is actually a better name for the original
parameter, in it mapping closer to the terminology used by Cloudflare.

Keeping _account_api_token_ as an alias for backward compatibility.
This commit is contained in:
Andreas Olsson 2019-09-21 23:03:23 +02:00 committed by René Moser
parent 8cabf1c1d8
commit fc6a37fe54

View file

@ -31,13 +31,14 @@ options:
type: str type: str
required: false required: false
version_added: '2.10' version_added: '2.10'
account_api_token: account_api_key:
description: description:
- Account API key. - Account API key.
- Required for api keys authentication. - Required for api keys authentication.
- "You can obtain your API key from the bottom of the Cloudflare 'My Account' page, found here: U(https://dash.cloudflare.com/)" - "You can obtain your API key from the bottom of the Cloudflare 'My Account' page, found here: U(https://dash.cloudflare.com/)"
type: str type: str
required: false required: false
aliases: [ account_api_token ]
account_email: account_email:
description: description:
- Account email. Required for api keys authentication. - Account email. Required for api keys authentication.
@ -168,7 +169,7 @@ EXAMPLES = r'''
type: A type: A
value: 127.0.0.1 value: 127.0.0.1
account_email: test@example.com account_email: test@example.com
account_api_token: dummyapitoken account_api_key: dummyapitoken
register: record register: record
- name: Create a record using api token - name: Create a record using api token
@ -185,7 +186,7 @@ EXAMPLES = r'''
type: CNAME type: CNAME
value: example.com value: example.com
account_email: test@example.com account_email: test@example.com
account_api_token: dummyapitoken account_api_key: dummyapitoken
state: present state: present
- name: Change its TTL - name: Change its TTL
@ -195,7 +196,7 @@ EXAMPLES = r'''
value: example.com value: example.com
ttl: 600 ttl: 600
account_email: test@example.com account_email: test@example.com
account_api_token: dummyapitoken account_api_key: dummyapitoken
state: present state: present
- name: Delete the record - name: Delete the record
@ -204,7 +205,7 @@ EXAMPLES = r'''
type: CNAME type: CNAME
value: example.com value: example.com
account_email: test@example.com account_email: test@example.com
account_api_token: dummyapitoken account_api_key: dummyapitoken
state: absent state: absent
- name: create a my.com CNAME record to example.com and proxy through Cloudflare's network - name: create a my.com CNAME record to example.com and proxy through Cloudflare's network
@ -214,7 +215,7 @@ EXAMPLES = r'''
value: example.com value: example.com
proxied: yes proxied: yes
account_email: test@example.com account_email: test@example.com
account_api_token: dummyapitoken account_api_key: dummyapitoken
state: present state: present
# This deletes all other TXT records named "test.my.com" # This deletes all other TXT records named "test.my.com"
@ -226,7 +227,7 @@ EXAMPLES = r'''
value: unique value value: unique value
solo: true solo: true
account_email: test@example.com account_email: test@example.com
account_api_token: dummyapitoken account_api_key: dummyapitoken
state: present state: present
- name: Create an SRV record _foo._tcp.my.com - name: Create an SRV record _foo._tcp.my.com
@ -385,7 +386,7 @@ class CloudflareAPI(object):
def __init__(self, module): def __init__(self, module):
self.module = module self.module = module
self.api_token = module.params['api_token'] self.api_token = module.params['api_token']
self.account_api_token = module.params['account_api_token'] self.account_api_key = module.params['account_api_key']
self.account_email = module.params['account_email'] self.account_email = module.params['account_email']
self.algorithm = module.params['algorithm'] self.algorithm = module.params['algorithm']
self.cert_usage = module.params['cert_usage'] self.cert_usage = module.params['cert_usage']
@ -444,7 +445,7 @@ class CloudflareAPI(object):
else: else:
headers = { headers = {
'X-Auth-Email': self.account_email, 'X-Auth-Email': self.account_email,
'X-Auth-Key': self.account_api_token, 'X-Auth-Key': self.account_api_key,
'Content-Type': 'application/json', 'Content-Type': 'application/json',
} }
data = None data = None
@ -793,7 +794,7 @@ def main():
module = AnsibleModule( module = AnsibleModule(
argument_spec=dict( argument_spec=dict(
api_token=dict(type='str', required=False, no_log=True), api_token=dict(type='str', required=False, no_log=True),
account_api_token=dict(type='str', required=False, no_log=True), account_api_key=dict(type='str', required=False, no_log=True, aliases=['account_api_token']),
account_email=dict(type='str', required=False), account_email=dict(type='str', required=False),
algorithm=dict(type='int'), algorithm=dict(type='int'),
cert_usage=dict(type='int', choices=[0, 1, 2, 3]), cert_usage=dict(type='int', choices=[0, 1, 2, 3]),
@ -824,8 +825,8 @@ def main():
], ],
) )
if not module.params['api_token'] and not (module.params['account_api_token'] and module.params['account_email']): if not module.params['api_token'] and not (module.params['account_api_key'] and module.params['account_email']):
module.fail_json(msg="Either api_token or account_api_token and account_email params are required.") module.fail_json(msg="Either api_token or account_api_key and account_email params are required.")
if module.params['type'] == 'SRV': if module.params['type'] == 'SRV':
if not ((module.params['weight'] is not None and module.params['port'] is not None if not ((module.params['weight'] is not None and module.params['port'] is not None
and not (module.params['value'] is None or module.params['value'] == '')) and not (module.params['value'] is None or module.params['value'] == ''))