diff --git a/plugins/modules/gcp_spanner_database.py b/plugins/modules/gcp_spanner_database.py index eabbc4a..b633a4d 100644 --- a/plugins/modules/gcp_spanner_database.py +++ b/plugins/modules/gcp_spanner_database.py @@ -50,9 +50,8 @@ options: name: description: - A unique identifier for the database, which cannot be changed after the instance - is created. Values are of the form projects//instances/[a-z][-a-z0-9]*[a-z0-9]. - The final segment of the name must be between 6 and 30 characters in length. - required: false + is created. Values are of the form [a-z][-a-z0-9]*[a-z0-9]. + required: true extra_statements: description: - 'An optional list of DDL statements to run inside the newly created database. @@ -103,8 +102,7 @@ RETURN = ''' name: description: - A unique identifier for the database, which cannot be changed after the instance - is created. Values are of the form projects//instances/[a-z][-a-z0-9]*[a-z0-9]. - The final segment of the name must be between 6 and 30 characters in length. + is created. Values are of the form [a-z][-a-z0-9]*[a-z0-9]. returned: success type: str extraStatements: @@ -182,8 +180,7 @@ def create(module, link): def update(module, link): - delete(module, self_link(module)) - create(module, collection(module)) + module.fail_json(msg="Database cannot be edited") def delete(module, link): @@ -192,7 +189,11 @@ def delete(module, link): def resource_to_request(module): - request = {u'name': module.params.get('name'), u'extraStatements': module.params.get('extra_statements')} + request = { + u'instance': replace_resource_dict(module.params.get(u'instance', {}), 'name'), + u'name': module.params.get('name'), + u'extraStatements': module.params.get('extra_statements'), + } request = encode_request(request, module) return_vals = {} for k, v in request.items(): @@ -262,7 +263,7 @@ def is_different(module, response): # Remove unnecessary properties from the response. # This is for doing comparisons with Ansible's current parameters. def response_to_hash(module, response): - return {u'name': response.get(u'name'), u'extraStatements': module.params.get('extra_statements')} + return {u'name': module.params.get('name'), u'extraStatements': module.params.get('extra_statements')} def decode_response(response, module): diff --git a/plugins/modules/gcp_spanner_database_facts.py b/plugins/modules/gcp_spanner_database_facts.py index 6f901df..07deedf 100644 --- a/plugins/modules/gcp_spanner_database_facts.py +++ b/plugins/modules/gcp_spanner_database_facts.py @@ -69,8 +69,7 @@ items: name: description: - A unique identifier for the database, which cannot be changed after the instance - is created. Values are of the form projects//instances/[a-z][-a-z0-9]*[a-z0-9]. - The final segment of the name must be between 6 and 30 characters in length. + is created. Values are of the form [a-z][-a-z0-9]*[a-z0-9]. returned: success type: str extraStatements: