Bug fixes for GCP modules (#55977)

This commit is contained in:
The Magician 2019-05-20 11:43:38 -07:00 committed by ansibot
parent b37ae35ba0
commit e598eeeebe
8 changed files with 32 additions and 44 deletions

View file

@ -43,11 +43,6 @@ options:
instance:
description:
- The name of the Cloud SQL instance. This does not include the project ID.
- 'This field represents a link to a Instance resource in GCP. It can be specified
in two ways. First, you can place a dictionary with key ''name'' and value of
your resource''s name Alternatively, you can add `register: name-of-resource`
to a gcp_sql_instance task and then set this instance field to "{{ name-of-resource
}}"'
required: true
extends_documentation_fragment: gcp
'''
@ -63,8 +58,8 @@ EXAMPLES = '''
'''
RETURN = '''
items:
description: List of items
resources:
description: List of resources
returned: always
type: complex
contains:
@ -88,13 +83,13 @@ items:
description:
- The name of the Cloud SQL instance. This does not include the project ID.
returned: success
type: dict
type: str
'''
################################################################################
# Imports
################################################################################
from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest, replace_resource_dict
from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest
import json
################################################################################
@ -103,7 +98,7 @@ import json
def main():
module = GcpModule(argument_spec=dict(instance=dict(required=True, type='dict')))
module = GcpModule(argument_spec=dict(instance=dict(required=True, type='str')))
if not module.params['scopes']:
module.params['scopes'] = ['https://www.googleapis.com/auth/sqlservice.admin']
@ -113,13 +108,12 @@ def main():
items = items.get('items')
else:
items = []
return_value = {'items': items}
return_value = {'resources': items}
module.exit_json(**return_value)
def collection(module):
res = {'project': module.params['project'], 'instance': replace_resource_dict(module.params['instance'], 'name')}
return "https://www.googleapis.com/sql/v1beta4/projects/{project}/instances/{instance}/databases".format(**res)
return "https://www.googleapis.com/sql/v1beta4/projects/{project}/instances/{instance}/databases".format(**module.params)
def fetch_list(module, link):