Ryan Brown 2018-10-18 10:55:42 -04:00 committed by Alex Stephen
commit 5c97cc1da0
78 changed files with 2531 additions and 1137 deletions

View file

@ -77,7 +77,7 @@ EXAMPLES = '''
dns_name: test.somewild2.example.com.
description: test zone
project: "test_project"
auth_kind: "service_account"
auth_kind: "serviceaccount"
service_account_file: "/tmp/auth.pem"
state: present
'''
@ -89,7 +89,7 @@ RETURN = '''
user's convenience. Has no effect on the managed zone's function.
returned: success
type: str
dns_name:
dnsName:
description:
- The DNS name of this managed zone, for instance "example.com.".
returned: success
@ -105,20 +105,20 @@ RETURN = '''
- Must be unique within the project.
returned: success
type: str
name_servers:
nameServers:
description:
- Delegate your managed_zone to these virtual name servers; defined by the server
.
returned: success
type: list
name_server_set:
nameServerSet:
description:
- Optionally specifies the NameServerSet for this ManagedZone. A NameServerSet is
a set of DNS name servers that all host the same ManagedZones. Most users will leave
this field unset.
returned: success
type: list
creation_time:
creationTime:
description:
- The time that this resource was created on the server.
- This is in RFC3339 text format.
@ -163,7 +163,8 @@ def main():
if fetch:
if state == 'present':
if is_different(module, fetch):
fetch = update(module, self_link(module), kind)
update(module, self_link(module), kind)
fetch = fetch_resource(module, self_link(module), kind)
changed = True
else:
delete(module, self_link(module), kind)
@ -211,9 +212,9 @@ def resource_to_request(module):
return return_vals
def fetch_resource(module, link, kind):
def fetch_resource(module, link, kind, allow_not_found=True):
auth = GcpSession(module, 'dns')
return return_if_object(module, auth.get(link), kind)
return return_if_object(module, auth.get(link), kind, allow_not_found)
def self_link(module):
@ -224,9 +225,9 @@ def collection(module):
return "https://www.googleapis.com/dns/v1/projects/{project}/managedZones".format(**module.params)
def return_if_object(module, response, kind):
def return_if_object(module, response, kind, allow_not_found=False):
# If not found, return nothing.
if response.status_code == 404:
if allow_not_found and response.status_code == 404:
return None
# If no content, return nothing.
@ -241,8 +242,6 @@ def return_if_object(module, response, kind):
if navigate_hash(result, ['error', 'errors']):
module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
if result['kind'] != kind:
module.fail_json(msg="Incorrect result: {kind}".format(**result))
return result