1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Bug fixes for GCP modules (as of 2019-01-22T12:43:52-08:00) (#51244)

This commit is contained in:
Alex Stephen 2019-01-23 13:45:52 -08:00 committed by ansibot
parent 47ce9ecd2e
commit 708e4440c9
24 changed files with 776 additions and 813 deletions

View file

@ -18,15 +18,14 @@
# ----------------------------------------------------------------------------
from __future__ import absolute_import, division, print_function
__metaclass__ = type
################################################################################
# Documentation
################################################################################
ANSIBLE_METADATA = {'metadata_version': '1.1',
'status': ["preview"],
'supported_by': 'community'}
ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
DOCUMENTATION = '''
---
@ -306,27 +305,29 @@ def main():
argument_spec=dict(
state=dict(default='present', choices=['present', 'absent'], type='str'),
name=dict(type='str'),
access=dict(type='list', elements='dict', options=dict(
domain=dict(type='str'),
group_by_email=dict(type='str'),
role=dict(type='str', choices=['READER', 'WRITER', 'OWNER']),
special_group=dict(type='str'),
user_by_email=dict(type='str'),
view=dict(type='dict', options=dict(
dataset_id=dict(required=True, type='str'),
project_id=dict(required=True, type='str'),
table_id=dict(required=True, type='str')
))
)),
dataset_reference=dict(required=True, type='dict', options=dict(
dataset_id=dict(required=True, type='str'),
project_id=dict(type='str')
)),
access=dict(
type='list',
elements='dict',
options=dict(
domain=dict(type='str'),
group_by_email=dict(type='str'),
role=dict(type='str', choices=['READER', 'WRITER', 'OWNER']),
special_group=dict(type='str'),
user_by_email=dict(type='str'),
view=dict(
type='dict',
options=dict(
dataset_id=dict(required=True, type='str'), project_id=dict(required=True, type='str'), table_id=dict(required=True, type='str')
),
),
),
),
dataset_reference=dict(required=True, type='dict', options=dict(dataset_id=dict(required=True, type='str'), project_id=dict(type='str'))),
default_table_expiration_ms=dict(type='int'),
description=dict(type='str'),
friendly_name=dict(type='str'),
labels=dict(type='dict'),
location=dict(default='US', type='str')
location=dict(default='US', type='str'),
)
)
@ -386,7 +387,7 @@ def resource_to_request(module):
u'description': module.params.get('description'),
u'friendlyName': module.params.get('friendly_name'),
u'labels': module.params.get('labels'),
u'location': module.params.get('location')
u'location': module.params.get('location'),
}
return_vals = {}
for k, v in request.items():
@ -421,8 +422,8 @@ def return_if_object(module, response, kind, allow_not_found=False):
try:
module.raise_for_status(response)
result = response.json()
except getattr(json.decoder, 'JSONDecodeError', ValueError) as inst:
module.fail_json(msg="Invalid JSON response with error: %s" % inst)
except getattr(json.decoder, 'JSONDecodeError', ValueError):
module.fail_json(msg="Invalid JSON response with error: %s" % response.text)
if navigate_hash(result, ['error', 'errors']):
module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
@ -462,7 +463,7 @@ def response_to_hash(module, response):
u'id': response.get(u'id'),
u'labels': response.get(u'labels'),
u'lastModifiedTime': response.get(u'lastModifiedTime'),
u'location': response.get(u'location')
u'location': response.get(u'location'),
}
@ -487,24 +488,28 @@ class DatasetAccessArray(object):
return items
def _request_for_item(self, item):
return remove_nones_from_dict({
u'domain': item.get('domain'),
u'groupByEmail': item.get('group_by_email'),
u'role': item.get('role'),
u'specialGroup': item.get('special_group'),
u'userByEmail': item.get('user_by_email'),
u'view': DatasetView(item.get('view', {}), self.module).to_request()
})
return remove_nones_from_dict(
{
u'domain': item.get('domain'),
u'groupByEmail': item.get('group_by_email'),
u'role': item.get('role'),
u'specialGroup': item.get('special_group'),
u'userByEmail': item.get('user_by_email'),
u'view': DatasetView(item.get('view', {}), self.module).to_request(),
}
)
def _response_from_item(self, item):
return remove_nones_from_dict({
u'domain': item.get(u'domain'),
u'groupByEmail': item.get(u'groupByEmail'),
u'role': item.get(u'role'),
u'specialGroup': item.get(u'specialGroup'),
u'userByEmail': item.get(u'userByEmail'),
u'view': DatasetView(item.get(u'view', {}), self.module).from_response()
})
return remove_nones_from_dict(
{
u'domain': item.get(u'domain'),
u'groupByEmail': item.get(u'groupByEmail'),
u'role': item.get(u'role'),
u'specialGroup': item.get(u'specialGroup'),
u'userByEmail': item.get(u'userByEmail'),
u'view': DatasetView(item.get(u'view', {}), self.module).from_response(),
}
)
class DatasetView(object):
@ -516,18 +521,14 @@ class DatasetView(object):
self.request = {}
def to_request(self):
return remove_nones_from_dict({
u'datasetId': self.request.get('dataset_id'),
u'projectId': self.request.get('project_id'),
u'tableId': self.request.get('table_id')
})
return remove_nones_from_dict(
{u'datasetId': self.request.get('dataset_id'), u'projectId': self.request.get('project_id'), u'tableId': self.request.get('table_id')}
)
def from_response(self):
return remove_nones_from_dict({
u'datasetId': self.request.get(u'datasetId'),
u'projectId': self.request.get(u'projectId'),
u'tableId': self.request.get(u'tableId')
})
return remove_nones_from_dict(
{u'datasetId': self.request.get(u'datasetId'), u'projectId': self.request.get(u'projectId'), u'tableId': self.request.get(u'tableId')}
)
class DatasetDatasetreference(object):
@ -539,16 +540,10 @@ class DatasetDatasetreference(object):
self.request = {}
def to_request(self):
return remove_nones_from_dict({
u'datasetId': self.request.get('dataset_id'),
u'projectId': self.request.get('project_id')
})
return remove_nones_from_dict({u'datasetId': self.request.get('dataset_id'), u'projectId': self.request.get('project_id')})
def from_response(self):
return remove_nones_from_dict({
u'datasetId': self.request.get(u'datasetId'),
u'projectId': self.request.get(u'projectId')
})
return remove_nones_from_dict({u'datasetId': self.request.get(u'datasetId'), u'projectId': self.request.get(u'projectId')})
if __name__ == '__main__':

View file

@ -18,15 +18,14 @@
# ----------------------------------------------------------------------------
from __future__ import absolute_import, division, print_function
__metaclass__ = type
################################################################################
# Documentation
################################################################################
ANSIBLE_METADATA = {'metadata_version': '1.1',
'status': ["preview"],
'supported_by': 'community'}
ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
DOCUMENTATION = '''
---
@ -199,10 +198,7 @@ import json
def main():
module = GcpModule(
argument_spec=dict(
)
)
module = GcpModule(argument_spec=dict())
if not module.params['scopes']:
module.params['scopes'] = ['https://www.googleapis.com/auth/bigquery']
@ -212,9 +208,7 @@ def main():
items = items.get('datasets')
else:
items = []
return_value = {
'items': items
}
return_value = {'items': items}
module.exit_json(**return_value)

View file

@ -18,15 +18,14 @@
# ----------------------------------------------------------------------------
from __future__ import absolute_import, division, print_function
__metaclass__ = type
################################################################################
# Documentation
################################################################################
ANSIBLE_METADATA = {'metadata_version': '1.1',
'status': ["preview"],
'supported_by': 'community'}
ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
DOCUMENTATION = '''
---
@ -904,85 +903,107 @@ def main():
module = GcpModule(
argument_spec=dict(
state=dict(default='present', choices=['present', 'absent'], type='str'),
table_reference=dict(type='dict', options=dict(
dataset_id=dict(type='str'),
project_id=dict(type='str'),
table_id=dict(type='str')
)),
table_reference=dict(type='dict', options=dict(dataset_id=dict(type='str'), project_id=dict(type='str'), table_id=dict(type='str'))),
description=dict(type='str'),
friendly_name=dict(type='str'),
labels=dict(type='dict'),
name=dict(type='str'),
view=dict(type='dict', options=dict(
use_legacy_sql=dict(type='bool'),
user_defined_function_resources=dict(type='list', elements='dict', options=dict(
inline_code=dict(type='str'),
resource_uri=dict(type='str')
))
)),
time_partitioning=dict(type='dict', options=dict(
expiration_ms=dict(type='int'),
type=dict(type='str', choices=['DAY'])
)),
schema=dict(type='dict', options=dict(
fields=dict(type='list', elements='dict', options=dict(
description=dict(type='str'),
fields=dict(type='list', elements='str'),
mode=dict(type='str', choices=['NULLABLE', 'REQUIRED', 'REPEATED']),
name=dict(type='str'),
type=dict(type='str', choices=['STRING', 'BYTES', 'INTEGER', 'FLOAT', 'TIMESTAMP', 'DATE', 'TIME', 'DATETIME', 'RECORD'])
))
)),
encryption_configuration=dict(type='dict', options=dict(
kms_key_name=dict(type='str')
)),
view=dict(
type='dict',
options=dict(
use_legacy_sql=dict(type='bool'),
user_defined_function_resources=dict(
type='list', elements='dict', options=dict(inline_code=dict(type='str'), resource_uri=dict(type='str'))
),
),
),
time_partitioning=dict(type='dict', options=dict(expiration_ms=dict(type='int'), type=dict(type='str', choices=['DAY']))),
schema=dict(
type='dict',
options=dict(
fields=dict(
type='list',
elements='dict',
options=dict(
description=dict(type='str'),
fields=dict(type='list', elements='str'),
mode=dict(type='str', choices=['NULLABLE', 'REQUIRED', 'REPEATED']),
name=dict(type='str'),
type=dict(type='str', choices=['STRING', 'BYTES', 'INTEGER', 'FLOAT', 'TIMESTAMP', 'DATE', 'TIME', 'DATETIME', 'RECORD']),
),
)
),
),
encryption_configuration=dict(type='dict', options=dict(kms_key_name=dict(type='str'))),
expiration_time=dict(type='int'),
external_data_configuration=dict(type='dict', options=dict(
autodetect=dict(type='bool'),
compression=dict(type='str', choices=['GZIP', 'NONE']),
ignore_unknown_values=dict(type='bool'),
max_bad_records=dict(default=0, type='int'),
source_format=dict(type='str', choices=['CSV', 'GOOGLE_SHEETS', 'NEWLINE_DELIMITED_JSON', 'AVRO', 'DATASTORE_BACKUP', 'BIGTABLE']),
source_uris=dict(type='list', elements='str'),
schema=dict(type='dict', options=dict(
fields=dict(type='list', elements='dict', options=dict(
description=dict(type='str'),
fields=dict(type='list', elements='str'),
mode=dict(type='str', choices=['NULLABLE', 'REQUIRED', 'REPEATED']),
name=dict(type='str'),
type=dict(type='str', choices=['STRING', 'BYTES', 'INTEGER', 'FLOAT', 'TIMESTAMP', 'DATE', 'TIME', 'DATETIME', 'RECORD'])
))
)),
google_sheets_options=dict(type='dict', options=dict(
skip_leading_rows=dict(default=0, type='int')
)),
csv_options=dict(type='dict', options=dict(
allow_jagged_rows=dict(type='bool'),
allow_quoted_newlines=dict(type='bool'),
encoding=dict(type='str', choices=['UTF-8', 'ISO-8859-1']),
field_delimiter=dict(type='str'),
quote=dict(type='str'),
skip_leading_rows=dict(default=0, type='int')
)),
bigtable_options=dict(type='dict', options=dict(
ignore_unspecified_column_families=dict(type='bool'),
read_rowkey_as_string=dict(type='bool'),
column_families=dict(type='list', elements='dict', options=dict(
columns=dict(type='list', elements='dict', options=dict(
encoding=dict(type='str', choices=['TEXT', 'BINARY']),
field_name=dict(type='str'),
only_read_latest=dict(type='bool'),
qualifier_string=dict(required=True, type='str'),
type=dict(type='str', choices=['BYTES', 'STRING', 'INTEGER', 'FLOAT', 'BOOLEAN'])
)),
encoding=dict(type='str', choices=['TEXT', 'BINARY']),
family_id=dict(type='str'),
only_read_latest=dict(type='bool'),
type=dict(type='str', choices=['BYTES', 'STRING', 'INTEGER', 'FLOAT', 'BOOLEAN'])
))
))
)),
dataset=dict(type='str')
external_data_configuration=dict(
type='dict',
options=dict(
autodetect=dict(type='bool'),
compression=dict(type='str', choices=['GZIP', 'NONE']),
ignore_unknown_values=dict(type='bool'),
max_bad_records=dict(default=0, type='int'),
source_format=dict(type='str', choices=['CSV', 'GOOGLE_SHEETS', 'NEWLINE_DELIMITED_JSON', 'AVRO', 'DATASTORE_BACKUP', 'BIGTABLE']),
source_uris=dict(type='list', elements='str'),
schema=dict(
type='dict',
options=dict(
fields=dict(
type='list',
elements='dict',
options=dict(
description=dict(type='str'),
fields=dict(type='list', elements='str'),
mode=dict(type='str', choices=['NULLABLE', 'REQUIRED', 'REPEATED']),
name=dict(type='str'),
type=dict(type='str', choices=['STRING', 'BYTES', 'INTEGER', 'FLOAT', 'TIMESTAMP', 'DATE', 'TIME', 'DATETIME', 'RECORD']),
),
)
),
),
google_sheets_options=dict(type='dict', options=dict(skip_leading_rows=dict(default=0, type='int'))),
csv_options=dict(
type='dict',
options=dict(
allow_jagged_rows=dict(type='bool'),
allow_quoted_newlines=dict(type='bool'),
encoding=dict(type='str', choices=['UTF-8', 'ISO-8859-1']),
field_delimiter=dict(type='str'),
quote=dict(type='str'),
skip_leading_rows=dict(default=0, type='int'),
),
),
bigtable_options=dict(
type='dict',
options=dict(
ignore_unspecified_column_families=dict(type='bool'),
read_rowkey_as_string=dict(type='bool'),
column_families=dict(
type='list',
elements='dict',
options=dict(
columns=dict(
type='list',
elements='dict',
options=dict(
encoding=dict(type='str', choices=['TEXT', 'BINARY']),
field_name=dict(type='str'),
only_read_latest=dict(type='bool'),
qualifier_string=dict(required=True, type='str'),
type=dict(type='str', choices=['BYTES', 'STRING', 'INTEGER', 'FLOAT', 'BOOLEAN']),
),
),
encoding=dict(type='str', choices=['TEXT', 'BINARY']),
family_id=dict(type='str'),
only_read_latest=dict(type='bool'),
type=dict(type='str', choices=['BYTES', 'STRING', 'INTEGER', 'FLOAT', 'BOOLEAN']),
),
),
),
),
),
),
dataset=dict(type='str'),
)
)
@ -1045,7 +1066,7 @@ def resource_to_request(module):
u'schema': TableSchema(module.params.get('schema', {}), module).to_request(),
u'encryptionConfiguration': TableEncryptionconfiguration(module.params.get('encryption_configuration', {}), module).to_request(),
u'expirationTime': module.params.get('expiration_time'),
u'externalDataConfiguration': TableExternaldataconfiguration(module.params.get('external_data_configuration', {}), module).to_request()
u'externalDataConfiguration': TableExternaldataconfiguration(module.params.get('external_data_configuration', {}), module).to_request(),
}
return_vals = {}
for k, v in request.items():
@ -1080,8 +1101,8 @@ def return_if_object(module, response, kind, allow_not_found=False):
try:
module.raise_for_status(response)
result = response.json()
except getattr(json.decoder, 'JSONDecodeError', ValueError) as inst:
module.fail_json(msg="Invalid JSON response with error: %s" % inst)
except getattr(json.decoder, 'JSONDecodeError', ValueError):
module.fail_json(msg="Invalid JSON response with error: %s" % response.text)
if navigate_hash(result, ['error', 'errors']):
module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
@ -1130,7 +1151,7 @@ def response_to_hash(module, response):
u'schema': TableSchema(response.get(u'schema', {}), module).from_response(),
u'encryptionConfiguration': TableEncryptionconfiguration(response.get(u'encryptionConfiguration', {}), module).from_response(),
u'expirationTime': response.get(u'expirationTime'),
u'externalDataConfiguration': TableExternaldataconfiguration(response.get(u'externalDataConfiguration', {}), module).from_response()
u'externalDataConfiguration': TableExternaldataconfiguration(response.get(u'externalDataConfiguration', {}), module).from_response(),
}
@ -1143,18 +1164,14 @@ class TableTablereference(object):
self.request = {}
def to_request(self):
return remove_nones_from_dict({
u'datasetId': self.request.get('dataset_id'),
u'projectId': self.request.get('project_id'),
u'tableId': self.request.get('table_id')
})
return remove_nones_from_dict(
{u'datasetId': self.request.get('dataset_id'), u'projectId': self.request.get('project_id'), u'tableId': self.request.get('table_id')}
)
def from_response(self):
return remove_nones_from_dict({
u'datasetId': self.request.get(u'datasetId'),
u'projectId': self.request.get(u'projectId'),
u'tableId': self.request.get(u'tableId')
})
return remove_nones_from_dict(
{u'datasetId': self.request.get(u'datasetId'), u'projectId': self.request.get(u'projectId'), u'tableId': self.request.get(u'tableId')}
)
class TableView(object):
@ -1166,18 +1183,24 @@ class TableView(object):
self.request = {}
def to_request(self):
return remove_nones_from_dict({
u'useLegacySql': self.request.get('use_legacy_sql'),
u'userDefinedFunctionResources':
TableUserdefinedfunctionresourcesArray(self.request.get('user_defined_function_resources', []), self.module).to_request()
})
return remove_nones_from_dict(
{
u'useLegacySql': self.request.get('use_legacy_sql'),
u'userDefinedFunctionResources': TableUserdefinedfunctionresourcesArray(
self.request.get('user_defined_function_resources', []), self.module
).to_request(),
}
)
def from_response(self):
return remove_nones_from_dict({
u'useLegacySql': self.request.get(u'useLegacySql'),
u'userDefinedFunctionResources':
TableUserdefinedfunctionresourcesArray(self.request.get(u'userDefinedFunctionResources', []), self.module).from_response()
})
return remove_nones_from_dict(
{
u'useLegacySql': self.request.get(u'useLegacySql'),
u'userDefinedFunctionResources': TableUserdefinedfunctionresourcesArray(
self.request.get(u'userDefinedFunctionResources', []), self.module
).from_response(),
}
)
class TableUserdefinedfunctionresourcesArray(object):
@ -1201,16 +1224,10 @@ class TableUserdefinedfunctionresourcesArray(object):
return items
def _request_for_item(self, item):
return remove_nones_from_dict({
u'inlineCode': item.get('inline_code'),
u'resourceUri': item.get('resource_uri')
})
return remove_nones_from_dict({u'inlineCode': item.get('inline_code'), u'resourceUri': item.get('resource_uri')})
def _response_from_item(self, item):
return remove_nones_from_dict({
u'inlineCode': item.get(u'inlineCode'),
u'resourceUri': item.get(u'resourceUri')
})
return remove_nones_from_dict({u'inlineCode': item.get(u'inlineCode'), u'resourceUri': item.get(u'resourceUri')})
class TableTimepartitioning(object):
@ -1222,16 +1239,10 @@ class TableTimepartitioning(object):
self.request = {}
def to_request(self):
return remove_nones_from_dict({
u'expirationMs': self.request.get('expiration_ms'),
u'type': self.request.get('type')
})
return remove_nones_from_dict({u'expirationMs': self.request.get('expiration_ms'), u'type': self.request.get('type')})
def from_response(self):
return remove_nones_from_dict({
u'expirationMs': self.request.get(u'expirationMs'),
u'type': self.request.get(u'type')
})
return remove_nones_from_dict({u'expirationMs': self.request.get(u'expirationMs'), u'type': self.request.get(u'type')})
class TableStreamingbuffer(object):
@ -1243,18 +1254,22 @@ class TableStreamingbuffer(object):
self.request = {}
def to_request(self):
return remove_nones_from_dict({
u'estimatedBytes': self.request.get('estimated_bytes'),
u'estimatedRows': self.request.get('estimated_rows'),
u'oldestEntryTime': self.request.get('oldest_entry_time')
})
return remove_nones_from_dict(
{
u'estimatedBytes': self.request.get('estimated_bytes'),
u'estimatedRows': self.request.get('estimated_rows'),
u'oldestEntryTime': self.request.get('oldest_entry_time'),
}
)
def from_response(self):
return remove_nones_from_dict({
u'estimatedBytes': self.request.get(u'estimatedBytes'),
u'estimatedRows': self.request.get(u'estimatedRows'),
u'oldestEntryTime': self.request.get(u'oldestEntryTime')
})
return remove_nones_from_dict(
{
u'estimatedBytes': self.request.get(u'estimatedBytes'),
u'estimatedRows': self.request.get(u'estimatedRows'),
u'oldestEntryTime': self.request.get(u'oldestEntryTime'),
}
)
class TableSchema(object):
@ -1266,14 +1281,10 @@ class TableSchema(object):
self.request = {}
def to_request(self):
return remove_nones_from_dict({
u'fields': TableFieldsArray(self.request.get('fields', []), self.module).to_request()
})
return remove_nones_from_dict({u'fields': TableFieldsArray(self.request.get('fields', []), self.module).to_request()})
def from_response(self):
return remove_nones_from_dict({
u'fields': TableFieldsArray(self.request.get(u'fields', []), self.module).from_response()
})
return remove_nones_from_dict({u'fields': TableFieldsArray(self.request.get(u'fields', []), self.module).from_response()})
class TableFieldsArray(object):
@ -1297,22 +1308,26 @@ class TableFieldsArray(object):
return items
def _request_for_item(self, item):
return remove_nones_from_dict({
u'description': item.get('description'),
u'fields': item.get('fields'),
u'mode': item.get('mode'),
u'name': item.get('name'),
u'type': item.get('type')
})
return remove_nones_from_dict(
{
u'description': item.get('description'),
u'fields': item.get('fields'),
u'mode': item.get('mode'),
u'name': item.get('name'),
u'type': item.get('type'),
}
)
def _response_from_item(self, item):
return remove_nones_from_dict({
u'description': item.get(u'description'),
u'fields': item.get(u'fields'),
u'mode': item.get(u'mode'),
u'name': item.get(u'name'),
u'type': item.get(u'type')
})
return remove_nones_from_dict(
{
u'description': item.get(u'description'),
u'fields': item.get(u'fields'),
u'mode': item.get(u'mode'),
u'name': item.get(u'name'),
u'type': item.get(u'type'),
}
)
class TableEncryptionconfiguration(object):
@ -1324,14 +1339,10 @@ class TableEncryptionconfiguration(object):
self.request = {}
def to_request(self):
return remove_nones_from_dict({
u'kmsKeyName': self.request.get('kms_key_name')
})
return remove_nones_from_dict({u'kmsKeyName': self.request.get('kms_key_name')})
def from_response(self):
return remove_nones_from_dict({
u'kmsKeyName': self.request.get(u'kmsKeyName')
})
return remove_nones_from_dict({u'kmsKeyName': self.request.get(u'kmsKeyName')})
class TableExternaldataconfiguration(object):
@ -1343,32 +1354,36 @@ class TableExternaldataconfiguration(object):
self.request = {}
def to_request(self):
return remove_nones_from_dict({
u'autodetect': self.request.get('autodetect'),
u'compression': self.request.get('compression'),
u'ignoreUnknownValues': self.request.get('ignore_unknown_values'),
u'maxBadRecords': self.request.get('max_bad_records'),
u'sourceFormat': self.request.get('source_format'),
u'sourceUris': self.request.get('source_uris'),
u'schema': TableSchema(self.request.get('schema', {}), self.module).to_request(),
u'googleSheetsOptions': TableGooglesheetsoptions(self.request.get('google_sheets_options', {}), self.module).to_request(),
u'csvOptions': TableCsvoptions(self.request.get('csv_options', {}), self.module).to_request(),
u'bigtableOptions': TableBigtableoptions(self.request.get('bigtable_options', {}), self.module).to_request()
})
return remove_nones_from_dict(
{
u'autodetect': self.request.get('autodetect'),
u'compression': self.request.get('compression'),
u'ignoreUnknownValues': self.request.get('ignore_unknown_values'),
u'maxBadRecords': self.request.get('max_bad_records'),
u'sourceFormat': self.request.get('source_format'),
u'sourceUris': self.request.get('source_uris'),
u'schema': TableSchema(self.request.get('schema', {}), self.module).to_request(),
u'googleSheetsOptions': TableGooglesheetsoptions(self.request.get('google_sheets_options', {}), self.module).to_request(),
u'csvOptions': TableCsvoptions(self.request.get('csv_options', {}), self.module).to_request(),
u'bigtableOptions': TableBigtableoptions(self.request.get('bigtable_options', {}), self.module).to_request(),
}
)
def from_response(self):
return remove_nones_from_dict({
u'autodetect': self.request.get(u'autodetect'),
u'compression': self.request.get(u'compression'),
u'ignoreUnknownValues': self.request.get(u'ignoreUnknownValues'),
u'maxBadRecords': self.request.get(u'maxBadRecords'),
u'sourceFormat': self.request.get(u'sourceFormat'),
u'sourceUris': self.request.get(u'sourceUris'),
u'schema': TableSchema(self.request.get(u'schema', {}), self.module).from_response(),
u'googleSheetsOptions': TableGooglesheetsoptions(self.request.get(u'googleSheetsOptions', {}), self.module).from_response(),
u'csvOptions': TableCsvoptions(self.request.get(u'csvOptions', {}), self.module).from_response(),
u'bigtableOptions': TableBigtableoptions(self.request.get(u'bigtableOptions', {}), self.module).from_response()
})
return remove_nones_from_dict(
{
u'autodetect': self.request.get(u'autodetect'),
u'compression': self.request.get(u'compression'),
u'ignoreUnknownValues': self.request.get(u'ignoreUnknownValues'),
u'maxBadRecords': self.request.get(u'maxBadRecords'),
u'sourceFormat': self.request.get(u'sourceFormat'),
u'sourceUris': self.request.get(u'sourceUris'),
u'schema': TableSchema(self.request.get(u'schema', {}), self.module).from_response(),
u'googleSheetsOptions': TableGooglesheetsoptions(self.request.get(u'googleSheetsOptions', {}), self.module).from_response(),
u'csvOptions': TableCsvoptions(self.request.get(u'csvOptions', {}), self.module).from_response(),
u'bigtableOptions': TableBigtableoptions(self.request.get(u'bigtableOptions', {}), self.module).from_response(),
}
)
class TableSchema(object):
@ -1380,14 +1395,10 @@ class TableSchema(object):
self.request = {}
def to_request(self):
return remove_nones_from_dict({
u'fields': TableFieldsArray(self.request.get('fields', []), self.module).to_request()
})
return remove_nones_from_dict({u'fields': TableFieldsArray(self.request.get('fields', []), self.module).to_request()})
def from_response(self):
return remove_nones_from_dict({
u'fields': TableFieldsArray(self.request.get(u'fields', []), self.module).from_response()
})
return remove_nones_from_dict({u'fields': TableFieldsArray(self.request.get(u'fields', []), self.module).from_response()})
class TableFieldsArray(object):
@ -1411,22 +1422,26 @@ class TableFieldsArray(object):
return items
def _request_for_item(self, item):
return remove_nones_from_dict({
u'description': item.get('description'),
u'fields': item.get('fields'),
u'mode': item.get('mode'),
u'name': item.get('name'),
u'type': item.get('type')
})
return remove_nones_from_dict(
{
u'description': item.get('description'),
u'fields': item.get('fields'),
u'mode': item.get('mode'),
u'name': item.get('name'),
u'type': item.get('type'),
}
)
def _response_from_item(self, item):
return remove_nones_from_dict({
u'description': item.get(u'description'),
u'fields': item.get(u'fields'),
u'mode': item.get(u'mode'),
u'name': item.get(u'name'),
u'type': item.get(u'type')
})
return remove_nones_from_dict(
{
u'description': item.get(u'description'),
u'fields': item.get(u'fields'),
u'mode': item.get(u'mode'),
u'name': item.get(u'name'),
u'type': item.get(u'type'),
}
)
class TableGooglesheetsoptions(object):
@ -1438,14 +1453,10 @@ class TableGooglesheetsoptions(object):
self.request = {}
def to_request(self):
return remove_nones_from_dict({
u'skipLeadingRows': self.request.get('skip_leading_rows')
})
return remove_nones_from_dict({u'skipLeadingRows': self.request.get('skip_leading_rows')})
def from_response(self):
return remove_nones_from_dict({
u'skipLeadingRows': self.request.get(u'skipLeadingRows')
})
return remove_nones_from_dict({u'skipLeadingRows': self.request.get(u'skipLeadingRows')})
class TableCsvoptions(object):
@ -1457,24 +1468,28 @@ class TableCsvoptions(object):
self.request = {}
def to_request(self):
return remove_nones_from_dict({
u'allowJaggedRows': self.request.get('allow_jagged_rows'),
u'allowQuotedNewlines': self.request.get('allow_quoted_newlines'),
u'encoding': self.request.get('encoding'),
u'fieldDelimiter': self.request.get('field_delimiter'),
u'quote': self.request.get('quote'),
u'skipLeadingRows': self.request.get('skip_leading_rows')
})
return remove_nones_from_dict(
{
u'allowJaggedRows': self.request.get('allow_jagged_rows'),
u'allowQuotedNewlines': self.request.get('allow_quoted_newlines'),
u'encoding': self.request.get('encoding'),
u'fieldDelimiter': self.request.get('field_delimiter'),
u'quote': self.request.get('quote'),
u'skipLeadingRows': self.request.get('skip_leading_rows'),
}
)
def from_response(self):
return remove_nones_from_dict({
u'allowJaggedRows': self.request.get(u'allowJaggedRows'),
u'allowQuotedNewlines': self.request.get(u'allowQuotedNewlines'),
u'encoding': self.request.get(u'encoding'),
u'fieldDelimiter': self.request.get(u'fieldDelimiter'),
u'quote': self.request.get(u'quote'),
u'skipLeadingRows': self.request.get(u'skipLeadingRows')
})
return remove_nones_from_dict(
{
u'allowJaggedRows': self.request.get(u'allowJaggedRows'),
u'allowQuotedNewlines': self.request.get(u'allowQuotedNewlines'),
u'encoding': self.request.get(u'encoding'),
u'fieldDelimiter': self.request.get(u'fieldDelimiter'),
u'quote': self.request.get(u'quote'),
u'skipLeadingRows': self.request.get(u'skipLeadingRows'),
}
)
class TableBigtableoptions(object):
@ -1486,18 +1501,22 @@ class TableBigtableoptions(object):
self.request = {}
def to_request(self):
return remove_nones_from_dict({
u'ignoreUnspecifiedColumnFamilies': self.request.get('ignore_unspecified_column_families'),
u'readRowkeyAsString': self.request.get('read_rowkey_as_string'),
u'columnFamilies': TableColumnfamiliesArray(self.request.get('column_families', []), self.module).to_request()
})
return remove_nones_from_dict(
{
u'ignoreUnspecifiedColumnFamilies': self.request.get('ignore_unspecified_column_families'),
u'readRowkeyAsString': self.request.get('read_rowkey_as_string'),
u'columnFamilies': TableColumnfamiliesArray(self.request.get('column_families', []), self.module).to_request(),
}
)
def from_response(self):
return remove_nones_from_dict({
u'ignoreUnspecifiedColumnFamilies': self.request.get(u'ignoreUnspecifiedColumnFamilies'),
u'readRowkeyAsString': self.request.get(u'readRowkeyAsString'),
u'columnFamilies': TableColumnfamiliesArray(self.request.get(u'columnFamilies', []), self.module).from_response()
})
return remove_nones_from_dict(
{
u'ignoreUnspecifiedColumnFamilies': self.request.get(u'ignoreUnspecifiedColumnFamilies'),
u'readRowkeyAsString': self.request.get(u'readRowkeyAsString'),
u'columnFamilies': TableColumnfamiliesArray(self.request.get(u'columnFamilies', []), self.module).from_response(),
}
)
class TableColumnfamiliesArray(object):
@ -1521,22 +1540,26 @@ class TableColumnfamiliesArray(object):
return items
def _request_for_item(self, item):
return remove_nones_from_dict({
u'columns': TableColumnsArray(item.get('columns', []), self.module).to_request(),
u'encoding': item.get('encoding'),
u'familyId': item.get('family_id'),
u'onlyReadLatest': item.get('only_read_latest'),
u'type': item.get('type')
})
return remove_nones_from_dict(
{
u'columns': TableColumnsArray(item.get('columns', []), self.module).to_request(),
u'encoding': item.get('encoding'),
u'familyId': item.get('family_id'),
u'onlyReadLatest': item.get('only_read_latest'),
u'type': item.get('type'),
}
)
def _response_from_item(self, item):
return remove_nones_from_dict({
u'columns': TableColumnsArray(item.get(u'columns', []), self.module).from_response(),
u'encoding': item.get(u'encoding'),
u'familyId': item.get(u'familyId'),
u'onlyReadLatest': item.get(u'onlyReadLatest'),
u'type': item.get(u'type')
})
return remove_nones_from_dict(
{
u'columns': TableColumnsArray(item.get(u'columns', []), self.module).from_response(),
u'encoding': item.get(u'encoding'),
u'familyId': item.get(u'familyId'),
u'onlyReadLatest': item.get(u'onlyReadLatest'),
u'type': item.get(u'type'),
}
)
class TableColumnsArray(object):
@ -1560,22 +1583,26 @@ class TableColumnsArray(object):
return items
def _request_for_item(self, item):
return remove_nones_from_dict({
u'encoding': item.get('encoding'),
u'fieldName': item.get('field_name'),
u'onlyReadLatest': item.get('only_read_latest'),
u'qualifierString': item.get('qualifier_string'),
u'type': item.get('type')
})
return remove_nones_from_dict(
{
u'encoding': item.get('encoding'),
u'fieldName': item.get('field_name'),
u'onlyReadLatest': item.get('only_read_latest'),
u'qualifierString': item.get('qualifier_string'),
u'type': item.get('type'),
}
)
def _response_from_item(self, item):
return remove_nones_from_dict({
u'encoding': item.get(u'encoding'),
u'fieldName': item.get(u'fieldName'),
u'onlyReadLatest': item.get(u'onlyReadLatest'),
u'qualifierString': item.get(u'qualifierString'),
u'type': item.get(u'type')
})
return remove_nones_from_dict(
{
u'encoding': item.get(u'encoding'),
u'fieldName': item.get(u'fieldName'),
u'onlyReadLatest': item.get(u'onlyReadLatest'),
u'qualifierString': item.get(u'qualifierString'),
u'type': item.get(u'type'),
}
)
if __name__ == '__main__':

View file

@ -18,15 +18,14 @@
# ----------------------------------------------------------------------------
from __future__ import absolute_import, division, print_function
__metaclass__ = type
################################################################################
# Documentation
################################################################################
ANSIBLE_METADATA = {'metadata_version': '1.1',
'status': ["preview"],
'supported_by': 'community'}
ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
DOCUMENTATION = '''
---
@ -513,11 +512,7 @@ import json
def main():
module = GcpModule(
argument_spec=dict(
dataset=dict(type='str')
)
)
module = GcpModule(argument_spec=dict(dataset=dict(type='str')))
if not module.params['scopes']:
module.params['scopes'] = ['https://www.googleapis.com/auth/bigquery']
@ -527,9 +522,7 @@ def main():
items = items.get('tables')
else:
items = []
return_value = {
'items': items
}
return_value = {'items': items}
module.exit_json(**return_value)

View file

@ -18,15 +18,14 @@
# ----------------------------------------------------------------------------
from __future__ import absolute_import, division, print_function
__metaclass__ = type
################################################################################
# Documentation
################################################################################
ANSIBLE_METADATA = {'metadata_version': '1.1',
'status': ["preview"],
'supported_by': 'community'}
ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
DOCUMENTATION = '''
---
@ -221,7 +220,7 @@ def main():
name=dict(required=True, type='str'),
network_tier=dict(type='str', choices=['PREMIUM', 'STANDARD']),
subnetwork=dict(),
region=dict(required=True, type='str')
region=dict(required=True, type='str'),
)
)
@ -278,7 +277,7 @@ def resource_to_request(module):
u'description': module.params.get('description'),
u'name': module.params.get('name'),
u'networkTier': module.params.get('network_tier'),
u'subnetwork': replace_resource_dict(module.params.get(u'subnetwork', {}), 'selfLink')
u'subnetwork': replace_resource_dict(module.params.get(u'subnetwork', {}), 'selfLink'),
}
return_vals = {}
for k, v in request.items():
@ -313,8 +312,8 @@ def return_if_object(module, response, kind, allow_not_found=False):
try:
module.raise_for_status(response)
result = response.json()
except getattr(json.decoder, 'JSONDecodeError', ValueError) as inst:
module.fail_json(msg="Invalid JSON response with error: %s" % inst)
except getattr(json.decoder, 'JSONDecodeError', ValueError):
module.fail_json(msg="Invalid JSON response with error: %s" % response.text)
if navigate_hash(result, ['error', 'errors']):
module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
@ -352,7 +351,7 @@ def response_to_hash(module, response):
u'name': response.get(u'name'),
u'networkTier': response.get(u'networkTier'),
u'subnetwork': response.get(u'subnetwork'),
u'users': response.get(u'users')
u'users': response.get(u'users'),
}
@ -378,7 +377,7 @@ def wait_for_completion(status, op_result, module):
op_id = navigate_hash(op_result, ['name'])
op_uri = async_op_url(module, {'op_id': op_id})
while status != 'DONE':
raise_if_errors(op_result, ['error', 'errors'], 'message')
raise_if_errors(op_result, ['error', 'errors'], module)
time.sleep(1.0)
op_result = fetch_resource(module, op_uri, 'compute#operation')
status = navigate_hash(op_result, ['status'])

View file

@ -18,15 +18,14 @@
# ----------------------------------------------------------------------------
from __future__ import absolute_import, division, print_function
__metaclass__ = type
################################################################################
# Documentation
################################################################################
ANSIBLE_METADATA = {'metadata_version': '1.1',
'status': ["preview"],
'supported_by': 'community'}
ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
DOCUMENTATION = '''
---
@ -148,12 +147,7 @@ import json
def main():
module = GcpModule(
argument_spec=dict(
filters=dict(type='list', elements='str'),
region=dict(required=True, type='str')
)
)
module = GcpModule(argument_spec=dict(filters=dict(type='list', elements='str'), region=dict(required=True, type='str')))
if not module.params['scopes']:
module.params['scopes'] = ['https://www.googleapis.com/auth/compute']
@ -163,9 +157,7 @@ def main():
items = items.get('items')
else:
items = []
return_value = {
'items': items
}
return_value = {'items': items}
module.exit_json(**return_value)

View file

@ -18,15 +18,14 @@
# ----------------------------------------------------------------------------
from __future__ import absolute_import, division, print_function
__metaclass__ = type
################################################################################
# Documentation
################################################################################
ANSIBLE_METADATA = {'metadata_version': '1.1',
'status': ["preview"],
'supported_by': 'community'}
ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
DOCUMENTATION = '''
---
@ -164,7 +163,7 @@ def main():
bucket_name=dict(required=True, type='str'),
description=dict(type='str'),
enable_cdn=dict(type='bool'),
name=dict(required=True, type='str')
name=dict(required=True, type='str'),
)
)
@ -220,7 +219,7 @@ def resource_to_request(module):
u'bucketName': module.params.get('bucket_name'),
u'description': module.params.get('description'),
u'enableCdn': module.params.get('enable_cdn'),
u'name': module.params.get('name')
u'name': module.params.get('name'),
}
return_vals = {}
for k, v in request.items():
@ -255,8 +254,8 @@ def return_if_object(module, response, kind, allow_not_found=False):
try:
module.raise_for_status(response)
result = response.json()
except getattr(json.decoder, 'JSONDecodeError', ValueError) as inst:
module.fail_json(msg="Invalid JSON response with error: %s" % inst)
except getattr(json.decoder, 'JSONDecodeError', ValueError):
module.fail_json(msg="Invalid JSON response with error: %s" % response.text)
if navigate_hash(result, ['error', 'errors']):
module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
@ -291,7 +290,7 @@ def response_to_hash(module, response):
u'description': response.get(u'description'),
u'enableCdn': response.get(u'enableCdn'),
u'id': response.get(u'id'),
u'name': module.params.get('name')
u'name': module.params.get('name'),
}
@ -317,7 +316,7 @@ def wait_for_completion(status, op_result, module):
op_id = navigate_hash(op_result, ['name'])
op_uri = async_op_url(module, {'op_id': op_id})
while status != 'DONE':
raise_if_errors(op_result, ['error', 'errors'], 'message')
raise_if_errors(op_result, ['error', 'errors'], module)
time.sleep(1.0)
op_result = fetch_resource(module, op_uri, 'compute#operation')
status = navigate_hash(op_result, ['status'])

View file

@ -18,15 +18,14 @@
# ----------------------------------------------------------------------------
from __future__ import absolute_import, division, print_function
__metaclass__ = type
################################################################################
# Documentation
################################################################################
ANSIBLE_METADATA = {'metadata_version': '1.1',
'status': ["preview"],
'supported_by': 'community'}
ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
DOCUMENTATION = '''
---
@ -115,11 +114,7 @@ import json
def main():
module = GcpModule(
argument_spec=dict(
filters=dict(type='list', elements='str')
)
)
module = GcpModule(argument_spec=dict(filters=dict(type='list', elements='str')))
if not module.params['scopes']:
module.params['scopes'] = ['https://www.googleapis.com/auth/compute']
@ -129,9 +124,7 @@ def main():
items = items.get('items')
else:
items = []
return_value = {
'items': items
}
return_value = {'items': items}
module.exit_json(**return_value)

View file

@ -18,15 +18,14 @@
# ----------------------------------------------------------------------------
from __future__ import absolute_import, division, print_function
__metaclass__ = type
################################################################################
# Documentation
################################################################################
ANSIBLE_METADATA = {'metadata_version': '1.1',
'status': ["preview"],
'supported_by': 'community'}
ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
DOCUMENTATION = '''
---
@ -622,45 +621,56 @@ def main():
argument_spec=dict(
state=dict(default='present', choices=['present', 'absent'], type='str'),
affinity_cookie_ttl_sec=dict(type='int'),
backends=dict(type='list', elements='dict', options=dict(
balancing_mode=dict(type='str', choices=['UTILIZATION', 'RATE', 'CONNECTION']),
capacity_scaler=dict(type='str'),
description=dict(type='str'),
group=dict(),
max_connections=dict(type='int'),
max_connections_per_instance=dict(type='int'),
max_rate=dict(type='int'),
max_rate_per_instance=dict(type='str'),
max_utilization=dict(type='str')
)),
cdn_policy=dict(type='dict', options=dict(
cache_key_policy=dict(type='dict', options=dict(
include_host=dict(type='bool'),
include_protocol=dict(type='bool'),
include_query_string=dict(type='bool'),
query_string_blacklist=dict(type='list', elements='str'),
query_string_whitelist=dict(type='list', elements='str')
))
)),
connection_draining=dict(type='dict', options=dict(
draining_timeout_sec=dict(type='int')
)),
backends=dict(
type='list',
elements='dict',
options=dict(
balancing_mode=dict(type='str', choices=['UTILIZATION', 'RATE', 'CONNECTION']),
capacity_scaler=dict(type='str'),
description=dict(type='str'),
group=dict(),
max_connections=dict(type='int'),
max_connections_per_instance=dict(type='int'),
max_rate=dict(type='int'),
max_rate_per_instance=dict(type='str'),
max_utilization=dict(type='str'),
),
),
cdn_policy=dict(
type='dict',
options=dict(
cache_key_policy=dict(
type='dict',
options=dict(
include_host=dict(type='bool'),
include_protocol=dict(type='bool'),
include_query_string=dict(type='bool'),
query_string_blacklist=dict(type='list', elements='str'),
query_string_whitelist=dict(type='list', elements='str'),
),
)
),
),
connection_draining=dict(type='dict', options=dict(draining_timeout_sec=dict(type='int'))),
description=dict(type='str'),
enable_cdn=dict(type='bool'),
health_checks=dict(type='list', elements='str'),
iap=dict(type='dict', options=dict(
enabled=dict(type='bool'),
oauth2_client_id=dict(type='str'),
oauth2_client_secret=dict(type='str'),
oauth2_client_secret_sha256=dict(type='str')
)),
iap=dict(
type='dict',
options=dict(
enabled=dict(type='bool'),
oauth2_client_id=dict(type='str'),
oauth2_client_secret=dict(type='str'),
oauth2_client_secret_sha256=dict(type='str'),
),
),
load_balancing_scheme=dict(type='str', choices=['INTERNAL', 'EXTERNAL']),
name=dict(type='str'),
port_name=dict(type='str'),
protocol=dict(type='str', choices=['HTTP', 'HTTPS', 'TCP', 'SSL']),
region=dict(type='str'),
session_affinity=dict(type='str', choices=['NONE', 'CLIENT_IP', 'GENERATED_COOKIE', 'CLIENT_IP_PROTO', 'CLIENT_IP_PORT_PROTO']),
timeout_sec=dict(type='int', aliases=['timeout_seconds'])
timeout_sec=dict(type='int', aliases=['timeout_seconds']),
)
)
@ -727,7 +737,7 @@ def resource_to_request(module):
u'protocol': module.params.get('protocol'),
u'region': region_selflink(module.params.get('region'), module.params),
u'sessionAffinity': module.params.get('session_affinity'),
u'timeoutSec': module.params.get('timeout_sec')
u'timeoutSec': module.params.get('timeout_sec'),
}
return_vals = {}
for k, v in request.items():
@ -762,8 +772,8 @@ def return_if_object(module, response, kind, allow_not_found=False):
try:
module.raise_for_status(response)
result = response.json()
except getattr(json.decoder, 'JSONDecodeError', ValueError) as inst:
module.fail_json(msg="Invalid JSON response with error: %s" % inst)
except getattr(json.decoder, 'JSONDecodeError', ValueError):
module.fail_json(msg="Invalid JSON response with error: %s" % response.text)
if navigate_hash(result, ['error', 'errors']):
module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
@ -809,7 +819,7 @@ def response_to_hash(module, response):
u'protocol': response.get(u'protocol'),
u'region': response.get(u'region'),
u'sessionAffinity': response.get(u'sessionAffinity'),
u'timeoutSec': response.get(u'timeoutSec')
u'timeoutSec': response.get(u'timeoutSec'),
}
@ -844,7 +854,7 @@ def wait_for_completion(status, op_result, module):
op_id = navigate_hash(op_result, ['name'])
op_uri = async_op_url(module, {'op_id': op_id})
while status != 'DONE':
raise_if_errors(op_result, ['error', 'errors'], 'message')
raise_if_errors(op_result, ['error', 'errors'], module)
time.sleep(1.0)
op_result = fetch_resource(module, op_uri, 'compute#operation')
status = navigate_hash(op_result, ['status'])
@ -878,30 +888,34 @@ class BackendServiceBackendsArray(object):
return items
def _request_for_item(self, item):
return remove_nones_from_dict({
u'balancingMode': item.get('balancing_mode'),
u'capacityScaler': item.get('capacity_scaler'),
u'description': item.get('description'),
u'group': replace_resource_dict(item.get(u'group', {}), 'selfLink'),
u'maxConnections': item.get('max_connections'),
u'maxConnectionsPerInstance': item.get('max_connections_per_instance'),
u'maxRate': item.get('max_rate'),
u'maxRatePerInstance': item.get('max_rate_per_instance'),
u'maxUtilization': item.get('max_utilization')
})
return remove_nones_from_dict(
{
u'balancingMode': item.get('balancing_mode'),
u'capacityScaler': item.get('capacity_scaler'),
u'description': item.get('description'),
u'group': replace_resource_dict(item.get(u'group', {}), 'selfLink'),
u'maxConnections': item.get('max_connections'),
u'maxConnectionsPerInstance': item.get('max_connections_per_instance'),
u'maxRate': item.get('max_rate'),
u'maxRatePerInstance': item.get('max_rate_per_instance'),
u'maxUtilization': item.get('max_utilization'),
}
)
def _response_from_item(self, item):
return remove_nones_from_dict({
u'balancingMode': item.get(u'balancingMode'),
u'capacityScaler': item.get(u'capacityScaler'),
u'description': item.get(u'description'),
u'group': item.get(u'group'),
u'maxConnections': item.get(u'maxConnections'),
u'maxConnectionsPerInstance': item.get(u'maxConnectionsPerInstance'),
u'maxRate': item.get(u'maxRate'),
u'maxRatePerInstance': item.get(u'maxRatePerInstance'),
u'maxUtilization': item.get(u'maxUtilization')
})
return remove_nones_from_dict(
{
u'balancingMode': item.get(u'balancingMode'),
u'capacityScaler': item.get(u'capacityScaler'),
u'description': item.get(u'description'),
u'group': item.get(u'group'),
u'maxConnections': item.get(u'maxConnections'),
u'maxConnectionsPerInstance': item.get(u'maxConnectionsPerInstance'),
u'maxRate': item.get(u'maxRate'),
u'maxRatePerInstance': item.get(u'maxRatePerInstance'),
u'maxUtilization': item.get(u'maxUtilization'),
}
)
class BackendServiceCdnpolicy(object):
@ -913,14 +927,10 @@ class BackendServiceCdnpolicy(object):
self.request = {}
def to_request(self):
return remove_nones_from_dict({
u'cacheKeyPolicy': BackendServiceCachekeypolicy(self.request.get('cache_key_policy', {}), self.module).to_request()
})
return remove_nones_from_dict({u'cacheKeyPolicy': BackendServiceCachekeypolicy(self.request.get('cache_key_policy', {}), self.module).to_request()})
def from_response(self):
return remove_nones_from_dict({
u'cacheKeyPolicy': BackendServiceCachekeypolicy(self.request.get(u'cacheKeyPolicy', {}), self.module).from_response()
})
return remove_nones_from_dict({u'cacheKeyPolicy': BackendServiceCachekeypolicy(self.request.get(u'cacheKeyPolicy', {}), self.module).from_response()})
class BackendServiceCachekeypolicy(object):
@ -932,22 +942,26 @@ class BackendServiceCachekeypolicy(object):
self.request = {}
def to_request(self):
return remove_nones_from_dict({
u'includeHost': self.request.get('include_host'),
u'includeProtocol': self.request.get('include_protocol'),
u'includeQueryString': self.request.get('include_query_string'),
u'queryStringBlacklist': self.request.get('query_string_blacklist'),
u'queryStringWhitelist': self.request.get('query_string_whitelist')
})
return remove_nones_from_dict(
{
u'includeHost': self.request.get('include_host'),
u'includeProtocol': self.request.get('include_protocol'),
u'includeQueryString': self.request.get('include_query_string'),
u'queryStringBlacklist': self.request.get('query_string_blacklist'),
u'queryStringWhitelist': self.request.get('query_string_whitelist'),
}
)
def from_response(self):
return remove_nones_from_dict({
u'includeHost': self.request.get(u'includeHost'),
u'includeProtocol': self.request.get(u'includeProtocol'),
u'includeQueryString': self.request.get(u'includeQueryString'),
u'queryStringBlacklist': self.request.get(u'queryStringBlacklist'),
u'queryStringWhitelist': self.request.get(u'queryStringWhitelist')
})
return remove_nones_from_dict(
{
u'includeHost': self.request.get(u'includeHost'),
u'includeProtocol': self.request.get(u'includeProtocol'),
u'includeQueryString': self.request.get(u'includeQueryString'),
u'queryStringBlacklist': self.request.get(u'queryStringBlacklist'),
u'queryStringWhitelist': self.request.get(u'queryStringWhitelist'),
}
)
class BackendServiceConnectiondraining(object):
@ -959,14 +973,10 @@ class BackendServiceConnectiondraining(object):
self.request = {}
def to_request(self):
return remove_nones_from_dict({
u'drainingTimeoutSec': self.request.get('draining_timeout_sec')
})
return remove_nones_from_dict({u'drainingTimeoutSec': self.request.get('draining_timeout_sec')})
def from_response(self):
return remove_nones_from_dict({
u'drainingTimeoutSec': self.request.get(u'drainingTimeoutSec')
})
return remove_nones_from_dict({u'drainingTimeoutSec': self.request.get(u'drainingTimeoutSec')})
class BackendServiceIap(object):
@ -978,20 +988,24 @@ class BackendServiceIap(object):
self.request = {}
def to_request(self):
return remove_nones_from_dict({
u'enabled': self.request.get('enabled'),
u'oauth2ClientId': self.request.get('oauth2_client_id'),
u'oauth2ClientSecret': self.request.get('oauth2_client_secret'),
u'oauth2ClientSecretSha256': self.request.get('oauth2_client_secret_sha256')
})
return remove_nones_from_dict(
{
u'enabled': self.request.get('enabled'),
u'oauth2ClientId': self.request.get('oauth2_client_id'),
u'oauth2ClientSecret': self.request.get('oauth2_client_secret'),
u'oauth2ClientSecretSha256': self.request.get('oauth2_client_secret_sha256'),
}
)
def from_response(self):
return remove_nones_from_dict({
u'enabled': self.request.get(u'enabled'),
u'oauth2ClientId': self.request.get(u'oauth2ClientId'),
u'oauth2ClientSecret': self.request.get(u'oauth2ClientSecret'),
u'oauth2ClientSecretSha256': self.request.get(u'oauth2ClientSecretSha256')
})
return remove_nones_from_dict(
{
u'enabled': self.request.get(u'enabled'),
u'oauth2ClientId': self.request.get(u'oauth2ClientId'),
u'oauth2ClientSecret': self.request.get(u'oauth2ClientSecret'),
u'oauth2ClientSecretSha256': self.request.get(u'oauth2ClientSecretSha256'),
}
)
if __name__ == '__main__':

View file

@ -18,15 +18,14 @@
# ----------------------------------------------------------------------------
from __future__ import absolute_import, division, print_function
__metaclass__ = type
################################################################################
# Documentation
################################################################################
ANSIBLE_METADATA = {'metadata_version': '1.1',
'status': ["preview"],
'supported_by': 'community'}
ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
DOCUMENTATION = '''
---
@ -341,11 +340,7 @@ import json
def main():
module = GcpModule(
argument_spec=dict(
filters=dict(type='list', elements='str')
)
)
module = GcpModule(argument_spec=dict(filters=dict(type='list', elements='str')))
if not module.params['scopes']:
module.params['scopes'] = ['https://www.googleapis.com/auth/compute']
@ -355,9 +350,7 @@ def main():
items = items.get('items')
else:
items = []
return_value = {
'items': items
}
return_value = {'items': items}
module.exit_json(**return_value)

View file

@ -18,15 +18,14 @@
# ----------------------------------------------------------------------------
from __future__ import absolute_import, division, print_function
__metaclass__ = type
################################################################################
# Documentation
################################################################################
ANSIBLE_METADATA = {'metadata_version': '1.1',
'status': ["preview"],
'supported_by': 'community'}
ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
DOCUMENTATION = '''
---
@ -130,6 +129,10 @@ options:
- The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption
key that protects this resource.
required: false
kms_key_name:
description:
- The name of the encryption key that is stored in Google Cloud KMS.
required: false
disk_encryption_key:
description:
- Encrypts the disk using a customer-supplied encryption key.
@ -152,6 +155,10 @@ options:
- The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption
key that protects this resource.
required: false
kms_key_name:
description:
- The name of the encryption key that is stored in Google Cloud KMS.
required: false
source_snapshot:
description:
- The source snapshot used to create this disk. You can provide this as a partial
@ -172,6 +179,10 @@ options:
- Specifies a 256-bit customer-supplied encryption key, encoded in RFC 4648
base64 to either encrypt or decrypt this resource.
required: false
kms_key_name:
description:
- The name of the encryption key that is stored in Google Cloud KMS.
required: false
sha256:
description:
- The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption
@ -311,6 +322,11 @@ sourceImageEncryptionKey:
key that protects this resource.
returned: success
type: str
kmsKeyName:
description:
- The name of the encryption key that is stored in Google Cloud KMS.
returned: success
type: str
sourceImageId:
description:
- The ID value of the image used to create this disk. This value identifies the
@ -345,6 +361,11 @@ diskEncryptionKey:
key that protects this resource.
returned: success
type: str
kmsKeyName:
description:
- The name of the encryption key that is stored in Google Cloud KMS.
returned: success
type: str
sourceSnapshot:
description:
- The source snapshot used to create this disk. You can provide this as a partial
@ -364,6 +385,11 @@ sourceSnapshotEncryptionKey:
base64 to either encrypt or decrypt this resource.
returned: success
type: str
kmsKeyName:
description:
- The name of the encryption key that is stored in Google Cloud KMS.
returned: success
type: str
sha256:
description:
- The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption
@ -409,19 +435,10 @@ def main():
type=dict(type='str'),
source_image=dict(type='str'),
zone=dict(required=True, type='str'),
source_image_encryption_key=dict(type='dict', options=dict(
raw_key=dict(type='str'),
sha256=dict(type='str')
)),
disk_encryption_key=dict(type='dict', options=dict(
raw_key=dict(type='str'),
sha256=dict(type='str')
)),
source_image_encryption_key=dict(type='dict', options=dict(raw_key=dict(type='str'), sha256=dict(type='str'), kms_key_name=dict(type='str'))),
disk_encryption_key=dict(type='dict', options=dict(raw_key=dict(type='str'), sha256=dict(type='str'), kms_key_name=dict(type='str'))),
source_snapshot=dict(),
source_snapshot_encryption_key=dict(type='dict', options=dict(
raw_key=dict(type='str'),
sha256=dict(type='str')
))
source_snapshot_encryption_key=dict(type='dict', options=dict(raw_key=dict(type='str'), kms_key_name=dict(type='str'), sha256=dict(type='str'))),
)
)
@ -462,8 +479,7 @@ def create(module, link, kind):
def update(module, link, kind, fetch):
update_fields(module, resource_to_request(module),
response_to_hash(module, fetch))
update_fields(module, resource_to_request(module), response_to_hash(module, fetch))
return fetch_resource(module, self_link(module), kind)
@ -477,27 +493,16 @@ def update_fields(module, request, response):
def label_fingerprint_update(module, request, response):
auth = GcpSession(module, 'compute')
auth.post(
''.join([
"https://www.googleapis.com/compute/v1/",
"projects/{project}/zones/{zone}/disks/{name}/setLabels"
]).format(**module.params),
{
u'labelFingerprint': response.get('labelFingerprint'),
u'labels': module.params.get('labels')
}
''.join(["https://www.googleapis.com/compute/v1/", "projects/{project}/zones/{zone}/disks/{name}/setLabels"]).format(**module.params),
{u'labelFingerprint': response.get('labelFingerprint'), u'labels': module.params.get('labels')},
)
def size_gb_update(module, request, response):
auth = GcpSession(module, 'compute')
auth.post(
''.join([
"https://www.googleapis.com/compute/v1/",
"projects/{project}/zones/{zone}/disks/{name}/resize"
]).format(**module.params),
{
u'sizeGb': module.params.get('size_gb')
}
''.join(["https://www.googleapis.com/compute/v1/", "projects/{project}/zones/{zone}/disks/{name}/resize"]).format(**module.params),
{u'sizeGb': module.params.get('size_gb')},
)
@ -518,7 +523,7 @@ def resource_to_request(module):
u'name': module.params.get('name'),
u'sizeGb': module.params.get('size_gb'),
u'type': disk_type_selflink(module.params.get('type'), module.params),
u'sourceImage': module.params.get('source_image')
u'sourceImage': module.params.get('source_image'),
}
return_vals = {}
for k, v in request.items():
@ -553,8 +558,8 @@ def return_if_object(module, response, kind, allow_not_found=False):
try:
module.raise_for_status(response)
result = response.json()
except getattr(json.decoder, 'JSONDecodeError', ValueError) as inst:
module.fail_json(msg="Invalid JSON response with error: %s" % inst)
except getattr(json.decoder, 'JSONDecodeError', ValueError):
module.fail_json(msg="Invalid JSON response with error: %s" % response.text)
if navigate_hash(result, ['error', 'errors']):
module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
@ -596,7 +601,7 @@ def response_to_hash(module, response):
u'sizeGb': response.get(u'sizeGb'),
u'users': response.get(u'users'),
u'type': response.get(u'type'),
u'sourceImage': module.params.get('source_image')
u'sourceImage': module.params.get('source_image'),
}
@ -631,7 +636,7 @@ def wait_for_completion(status, op_result, module):
op_id = navigate_hash(op_result, ['name'])
op_uri = async_op_url(module, {'op_id': op_id})
while status != 'DONE':
raise_if_errors(op_result, ['error', 'errors'], 'message')
raise_if_errors(op_result, ['error', 'errors'], module)
time.sleep(1.0)
op_result = fetch_resource(module, op_uri, 'compute#operation')
status = navigate_hash(op_result, ['status'])
@ -653,16 +658,14 @@ class DiskSourceimageencryptionkey(object):
self.request = {}
def to_request(self):
return remove_nones_from_dict({
u'rawKey': self.request.get('raw_key'),
u'sha256': self.request.get('sha256')
})
return remove_nones_from_dict(
{u'rawKey': self.request.get('raw_key'), u'sha256': self.request.get('sha256'), u'kmsKeyName': self.request.get('kms_key_name')}
)
def from_response(self):
return remove_nones_from_dict({
u'rawKey': self.request.get(u'rawKey'),
u'sha256': self.request.get(u'sha256')
})
return remove_nones_from_dict(
{u'rawKey': self.request.get(u'rawKey'), u'sha256': self.request.get(u'sha256'), u'kmsKeyName': self.request.get(u'kmsKeyName')}
)
class DiskDiskencryptionkey(object):
@ -674,16 +677,14 @@ class DiskDiskencryptionkey(object):
self.request = {}
def to_request(self):
return remove_nones_from_dict({
u'rawKey': self.request.get('raw_key'),
u'sha256': self.request.get('sha256')
})
return remove_nones_from_dict(
{u'rawKey': self.request.get('raw_key'), u'sha256': self.request.get('sha256'), u'kmsKeyName': self.request.get('kms_key_name')}
)
def from_response(self):
return remove_nones_from_dict({
u'rawKey': self.request.get(u'rawKey'),
u'sha256': self.request.get(u'sha256')
})
return remove_nones_from_dict(
{u'rawKey': self.request.get(u'rawKey'), u'sha256': self.request.get(u'sha256'), u'kmsKeyName': self.request.get(u'kmsKeyName')}
)
class DiskSourcesnapshotencryptionkey(object):
@ -695,16 +696,14 @@ class DiskSourcesnapshotencryptionkey(object):
self.request = {}
def to_request(self):
return remove_nones_from_dict({
u'rawKey': self.request.get('raw_key'),
u'sha256': self.request.get('sha256')
})
return remove_nones_from_dict(
{u'rawKey': self.request.get('raw_key'), u'kmsKeyName': self.request.get('kms_key_name'), u'sha256': self.request.get('sha256')}
)
def from_response(self):
return remove_nones_from_dict({
u'rawKey': self.request.get(u'rawKey'),
u'sha256': self.request.get(u'sha256')
})
return remove_nones_from_dict(
{u'rawKey': self.request.get(u'rawKey'), u'kmsKeyName': self.request.get(u'kmsKeyName'), u'sha256': self.request.get(u'sha256')}
)
if __name__ == '__main__':

View file

@ -18,15 +18,14 @@
# ----------------------------------------------------------------------------
from __future__ import absolute_import, division, print_function
__metaclass__ = type
################################################################################
# Documentation
################################################################################
ANSIBLE_METADATA = {'metadata_version': '1.1',
'status': ["preview"],
'supported_by': 'community'}
ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
DOCUMENTATION = '''
---
@ -184,6 +183,11 @@ items:
key that protects this resource.
returned: success
type: str
kmsKeyName:
description:
- The name of the encryption key that is stored in Google Cloud KMS.
returned: success
type: str
sourceImageId:
description:
- The ID value of the image used to create this disk. This value identifies
@ -219,6 +223,11 @@ items:
key that protects this resource.
returned: success
type: str
kmsKeyName:
description:
- The name of the encryption key that is stored in Google Cloud KMS.
returned: success
type: str
sourceSnapshot:
description:
- The source snapshot used to create this disk. You can provide this as a partial
@ -238,6 +247,11 @@ items:
base64 to either encrypt or decrypt this resource.
returned: success
type: str
kmsKeyName:
description:
- The name of the encryption key that is stored in Google Cloud KMS.
returned: success
type: str
sha256:
description:
- The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption
@ -267,12 +281,7 @@ import json
def main():
module = GcpModule(
argument_spec=dict(
filters=dict(type='list', elements='str'),
zone=dict(required=True, type='str')
)
)
module = GcpModule(argument_spec=dict(filters=dict(type='list', elements='str'), zone=dict(required=True, type='str')))
if not module.params['scopes']:
module.params['scopes'] = ['https://www.googleapis.com/auth/compute']
@ -282,9 +291,7 @@ def main():
items = items.get('items')
else:
items = []
return_value = {
'items': items
}
return_value = {'items': items}
module.exit_json(**return_value)

View file

@ -18,15 +18,14 @@
# ----------------------------------------------------------------------------
from __future__ import absolute_import, division, print_function
__metaclass__ = type
################################################################################
# Documentation
################################################################################
ANSIBLE_METADATA = {'metadata_version': '1.1',
'status': ["preview"],
'supported_by': 'community'}
ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
DOCUMENTATION = '''
---
@ -427,34 +426,30 @@ def main():
module = GcpModule(
argument_spec=dict(
state=dict(default='present', choices=['present', 'absent'], type='str'),
allowed=dict(type='list', elements='dict', options=dict(
ip_protocol=dict(required=True, type='str'),
ports=dict(type='list', elements='str')
)),
denied=dict(type='list', elements='dict', options=dict(
ip_protocol=dict(required=True, type='str'),
ports=dict(type='list', elements='str')
)),
allowed=dict(type='list', elements='dict', options=dict(ip_protocol=dict(required=True, type='str'), ports=dict(type='list', elements='str'))),
denied=dict(type='list', elements='dict', options=dict(ip_protocol=dict(required=True, type='str'), ports=dict(type='list', elements='str'))),
description=dict(type='str'),
destination_ranges=dict(type='list', elements='str'),
direction=dict(type='str', choices=['INGRESS', 'EGRESS']),
disabled=dict(type='bool'),
name=dict(required=True, type='str'),
network=dict(default={'selfLink': 'global/networks/default'}),
network=dict(default=dict(selfLink='global/networks/default')),
priority=dict(default=1000, type='int'),
source_ranges=dict(type='list', elements='str'),
source_service_accounts=dict(type='list', elements='str'),
source_tags=dict(type='list', elements='str'),
target_service_accounts=dict(type='list', elements='str'),
target_tags=dict(type='list', elements='str')
target_tags=dict(type='list', elements='str'),
),
mutually_exclusive=[['allowed', 'denied'],
['destination_ranges', 'source_ranges', 'source_tags'],
['destination_ranges', 'source_ranges'],
['source_service_accounts', 'source_tags', 'target_tags'],
['destination_ranges', 'source_service_accounts', 'source_tags', 'target_service_accounts'],
['source_tags', 'target_service_accounts', 'target_tags'],
['source_service_accounts', 'target_service_accounts', 'target_tags']]
mutually_exclusive=[
['allowed', 'denied'],
['destination_ranges', 'source_ranges', 'source_tags'],
['destination_ranges', 'source_ranges'],
['source_service_accounts', 'source_tags', 'target_tags'],
['destination_ranges', 'source_service_accounts', 'source_tags', 'target_service_accounts'],
['source_tags', 'target_service_accounts', 'target_tags'],
['source_service_accounts', 'target_service_accounts', 'target_tags'],
],
)
if not module.params['scopes']:
@ -519,7 +514,7 @@ def resource_to_request(module):
u'sourceServiceAccounts': module.params.get('source_service_accounts'),
u'sourceTags': module.params.get('source_tags'),
u'targetServiceAccounts': module.params.get('target_service_accounts'),
u'targetTags': module.params.get('target_tags')
u'targetTags': module.params.get('target_tags'),
}
request = encode_request(request, module)
return_vals = {}
@ -555,8 +550,8 @@ def return_if_object(module, response, kind, allow_not_found=False):
try:
module.raise_for_status(response)
result = response.json()
except getattr(json.decoder, 'JSONDecodeError', ValueError) as inst:
module.fail_json(msg="Invalid JSON response with error: %s" % inst)
except getattr(json.decoder, 'JSONDecodeError', ValueError):
module.fail_json(msg="Invalid JSON response with error: %s" % response.text)
if navigate_hash(result, ['error', 'errors']):
module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
@ -601,7 +596,7 @@ def response_to_hash(module, response):
u'sourceServiceAccounts': response.get(u'sourceServiceAccounts'),
u'sourceTags': response.get(u'sourceTags'),
u'targetServiceAccounts': response.get(u'targetServiceAccounts'),
u'targetTags': response.get(u'targetTags')
u'targetTags': response.get(u'targetTags'),
}
@ -627,7 +622,7 @@ def wait_for_completion(status, op_result, module):
op_id = navigate_hash(op_result, ['name'])
op_uri = async_op_url(module, {'op_id': op_id})
while status != 'DONE':
raise_if_errors(op_result, ['error', 'errors'], 'message')
raise_if_errors(op_result, ['error', 'errors'], module)
time.sleep(1.0)
op_result = fetch_resource(module, op_uri, 'compute#operation')
status = navigate_hash(op_result, ['status'])
@ -643,8 +638,9 @@ def raise_if_errors(response, err_path, module):
def encode_request(request, module):
if 'network' in request and request['network'] is not None:
if not re.match(r'https://www.googleapis.com/compute/v1/projects/.*', request['network']):
request['network'] = 'https://www.googleapis.com/compute/v1/projects/{project}/{network}'.format(project=module.params['project'],
network=request['network'])
request['network'] = 'https://www.googleapis.com/compute/v1/projects/{project}/{network}'.format(
project=module.params['project'], network=request['network']
)
return request
@ -670,16 +666,10 @@ class FirewallAllowedArray(object):
return items
def _request_for_item(self, item):
return remove_nones_from_dict({
u'IPProtocol': item.get('ip_protocol'),
u'ports': item.get('ports')
})
return remove_nones_from_dict({u'IPProtocol': item.get('ip_protocol'), u'ports': item.get('ports')})
def _response_from_item(self, item):
return remove_nones_from_dict({
u'IPProtocol': item.get(u'ip_protocol'),
u'ports': item.get(u'ports')
})
return remove_nones_from_dict({u'IPProtocol': item.get(u'ip_protocol'), u'ports': item.get(u'ports')})
class FirewallDeniedArray(object):
@ -703,16 +693,10 @@ class FirewallDeniedArray(object):
return items
def _request_for_item(self, item):
return remove_nones_from_dict({
u'IPProtocol': item.get('ip_protocol'),
u'ports': item.get('ports')
})
return remove_nones_from_dict({u'IPProtocol': item.get('ip_protocol'), u'ports': item.get('ports')})
def _response_from_item(self, item):
return remove_nones_from_dict({
u'IPProtocol': item.get(u'ip_protocol'),
u'ports': item.get(u'ports')
})
return remove_nones_from_dict({u'IPProtocol': item.get(u'ip_protocol'), u'ports': item.get(u'ports')})
if __name__ == '__main__':

View file

@ -18,15 +18,14 @@
# ----------------------------------------------------------------------------
from __future__ import absolute_import, division, print_function
__metaclass__ = type
################################################################################
# Documentation
################################################################################
ANSIBLE_METADATA = {'metadata_version': '1.1',
'status': ["preview"],
'supported_by': 'community'}
ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
DOCUMENTATION = '''
---
@ -248,11 +247,7 @@ import json
def main():
module = GcpModule(
argument_spec=dict(
filters=dict(type='list', elements='str')
)
)
module = GcpModule(argument_spec=dict(filters=dict(type='list', elements='str')))
if not module.params['scopes']:
module.params['scopes'] = ['https://www.googleapis.com/auth/compute']
@ -262,9 +257,7 @@ def main():
items = items.get('items')
else:
items = []
return_value = {
'items': items
}
return_value = {'items': items}
module.exit_json(**return_value)

View file

@ -18,15 +18,14 @@
# ----------------------------------------------------------------------------
from __future__ import absolute_import, division, print_function
__metaclass__ = type
################################################################################
# Documentation
################################################################################
ANSIBLE_METADATA = {'metadata_version': '1.1',
'status': ["preview"],
'supported_by': 'community'}
ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
DOCUMENTATION = '''
---
@ -422,7 +421,7 @@ def main():
subnetwork=dict(),
target=dict(),
network_tier=dict(type='str', choices=['PREMIUM', 'STANDARD']),
region=dict(required=True, type='str')
region=dict(required=True, type='str'),
)
)
@ -463,8 +462,7 @@ def create(module, link, kind):
def update(module, link, kind, fetch):
update_fields(module, resource_to_request(module),
response_to_hash(module, fetch))
update_fields(module, resource_to_request(module), response_to_hash(module, fetch))
return fetch_resource(module, self_link(module), kind)
@ -476,13 +474,8 @@ def update_fields(module, request, response):
def target_update(module, request, response):
auth = GcpSession(module, 'compute')
auth.post(
''.join([
"https://www.googleapis.com/compute/v1/",
"projects/{project}/regions/{region}/forwardingRules/{name}/setTarget"
]).format(**module.params),
{
u'target': replace_resource_dict(module.params.get(u'target', {}), 'selfLink')
}
''.join(["https://www.googleapis.com/compute/v1/", "projects/{project}/regions/{region}/forwardingRules/{name}/setTarget"]).format(**module.params),
{u'target': replace_resource_dict(module.params.get(u'target', {}), 'selfLink')},
)
@ -506,7 +499,7 @@ def resource_to_request(module):
u'ports': module.params.get('ports'),
u'subnetwork': replace_resource_dict(module.params.get(u'subnetwork', {}), 'selfLink'),
u'target': replace_resource_dict(module.params.get(u'target', {}), 'selfLink'),
u'networkTier': module.params.get('network_tier')
u'networkTier': module.params.get('network_tier'),
}
return_vals = {}
for k, v in request.items():
@ -541,8 +534,8 @@ def return_if_object(module, response, kind, allow_not_found=False):
try:
module.raise_for_status(response)
result = response.json()
except getattr(json.decoder, 'JSONDecodeError', ValueError) as inst:
module.fail_json(msg="Invalid JSON response with error: %s" % inst)
except getattr(json.decoder, 'JSONDecodeError', ValueError):
module.fail_json(msg="Invalid JSON response with error: %s" % response.text)
if navigate_hash(result, ['error', 'errors']):
module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
@ -586,7 +579,7 @@ def response_to_hash(module, response):
u'ports': response.get(u'ports'),
u'subnetwork': response.get(u'subnetwork'),
u'target': response.get(u'target'),
u'networkTier': module.params.get('network_tier')
u'networkTier': module.params.get('network_tier'),
}
@ -612,7 +605,7 @@ def wait_for_completion(status, op_result, module):
op_id = navigate_hash(op_result, ['name'])
op_uri = async_op_url(module, {'op_id': op_id})
while status != 'DONE':
raise_if_errors(op_result, ['error', 'errors'], 'message')
raise_if_errors(op_result, ['error', 'errors'], module)
time.sleep(1.0)
op_result = fetch_resource(module, op_uri, 'compute#operation')
status = navigate_hash(op_result, ['status'])

View file

@ -18,15 +18,14 @@
# ----------------------------------------------------------------------------
from __future__ import absolute_import, division, print_function
__metaclass__ = type
################################################################################
# Documentation
################################################################################
ANSIBLE_METADATA = {'metadata_version': '1.1',
'status': ["preview"],
'supported_by': 'community'}
ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
DOCUMENTATION = '''
---
@ -229,12 +228,7 @@ import json
def main():
module = GcpModule(
argument_spec=dict(
filters=dict(type='list', elements='str'),
region=dict(required=True, type='str')
)
)
module = GcpModule(argument_spec=dict(filters=dict(type='list', elements='str'), region=dict(required=True, type='str')))
if not module.params['scopes']:
module.params['scopes'] = ['https://www.googleapis.com/auth/compute']
@ -244,9 +238,7 @@ def main():
items = items.get('items')
else:
items = []
return_value = {
'items': items
}
return_value = {'items': items}
module.exit_json(**return_value)

View file

@ -18,15 +18,14 @@
# ----------------------------------------------------------------------------
from __future__ import absolute_import, division, print_function
__metaclass__ = type
################################################################################
# Documentation
################################################################################
ANSIBLE_METADATA = {'metadata_version': '1.1',
'status': ["preview"],
'supported_by': 'community'}
ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
DOCUMENTATION = '''
---
@ -179,7 +178,7 @@ def main():
description=dict(type='str'),
name=dict(required=True, type='str'),
ip_version=dict(type='str', choices=['IPV4', 'IPV6']),
address_type=dict(default='EXTERNAL', type='str', choices=['EXTERNAL', 'INTERNAL'])
address_type=dict(default='EXTERNAL', type='str', choices=['EXTERNAL', 'INTERNAL']),
)
)
@ -235,7 +234,7 @@ def resource_to_request(module):
u'description': module.params.get('description'),
u'name': module.params.get('name'),
u'ipVersion': module.params.get('ip_version'),
u'addressType': module.params.get('address_type')
u'addressType': module.params.get('address_type'),
}
return_vals = {}
for k, v in request.items():
@ -270,8 +269,8 @@ def return_if_object(module, response, kind, allow_not_found=False):
try:
module.raise_for_status(response)
result = response.json()
except getattr(json.decoder, 'JSONDecodeError', ValueError) as inst:
module.fail_json(msg="Invalid JSON response with error: %s" % inst)
except getattr(json.decoder, 'JSONDecodeError', ValueError):
module.fail_json(msg="Invalid JSON response with error: %s" % response.text)
if navigate_hash(result, ['error', 'errors']):
module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
@ -308,7 +307,7 @@ def response_to_hash(module, response):
u'name': response.get(u'name'),
u'ipVersion': response.get(u'ipVersion'),
u'region': response.get(u'region'),
u'addressType': response.get(u'addressType')
u'addressType': response.get(u'addressType'),
}
@ -343,7 +342,7 @@ def wait_for_completion(status, op_result, module):
op_id = navigate_hash(op_result, ['name'])
op_uri = async_op_url(module, {'op_id': op_id})
while status != 'DONE':
raise_if_errors(op_result, ['error', 'errors'], 'message')
raise_if_errors(op_result, ['error', 'errors'], module)
time.sleep(1.0)
op_result = fetch_resource(module, op_uri, 'compute#operation')
status = navigate_hash(op_result, ['status'])

View file

@ -18,15 +18,14 @@
# ----------------------------------------------------------------------------
from __future__ import absolute_import, division, print_function
__metaclass__ = type
################################################################################
# Documentation
################################################################################
ANSIBLE_METADATA = {'metadata_version': '1.1',
'status': ["preview"],
'supported_by': 'community'}
ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
DOCUMENTATION = '''
---
@ -129,11 +128,7 @@ import json
def main():
module = GcpModule(
argument_spec=dict(
filters=dict(type='list', elements='str')
)
)
module = GcpModule(argument_spec=dict(filters=dict(type='list', elements='str')))
if not module.params['scopes']:
module.params['scopes'] = ['https://www.googleapis.com/auth/compute']
@ -143,9 +138,7 @@ def main():
items = items.get('items')
else:
items = []
return_value = {
'items': items
}
return_value = {'items': items}
module.exit_json(**return_value)

View file

@ -18,15 +18,14 @@
# ----------------------------------------------------------------------------
from __future__ import absolute_import, division, print_function
__metaclass__ = type
################################################################################
# Documentation
################################################################################
ANSIBLE_METADATA = {'metadata_version': '1.1',
'status': ["preview"],
'supported_by': 'community'}
ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
DOCUMENTATION = '''
---
@ -431,7 +430,7 @@ def main():
port_range=dict(type='str'),
ports=dict(type='list', elements='str'),
subnetwork=dict(),
target=dict(type='str')
target=dict(type='str'),
)
)
@ -495,7 +494,7 @@ def resource_to_request(module):
u'portRange': module.params.get('port_range'),
u'ports': module.params.get('ports'),
u'subnetwork': replace_resource_dict(module.params.get(u'subnetwork', {}), 'selfLink'),
u'target': module.params.get('target')
u'target': module.params.get('target'),
}
return_vals = {}
for k, v in request.items():
@ -530,8 +529,8 @@ def return_if_object(module, response, kind, allow_not_found=False):
try:
module.raise_for_status(response)
result = response.json()
except getattr(json.decoder, 'JSONDecodeError', ValueError) as inst:
module.fail_json(msg="Invalid JSON response with error: %s" % inst)
except getattr(json.decoder, 'JSONDecodeError', ValueError):
module.fail_json(msg="Invalid JSON response with error: %s" % response.text)
if navigate_hash(result, ['error', 'errors']):
module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
@ -575,7 +574,7 @@ def response_to_hash(module, response):
u'ports': response.get(u'ports'),
u'subnetwork': response.get(u'subnetwork'),
u'region': response.get(u'region'),
u'target': response.get(u'target')
u'target': response.get(u'target'),
}
@ -601,7 +600,7 @@ def wait_for_completion(status, op_result, module):
op_id = navigate_hash(op_result, ['name'])
op_uri = async_op_url(module, {'op_id': op_id})
while status != 'DONE':
raise_if_errors(op_result, ['error', 'errors'], 'message')
raise_if_errors(op_result, ['error', 'errors'], module)
time.sleep(1.0)
op_result = fetch_resource(module, op_uri, 'compute#operation')
status = navigate_hash(op_result, ['status'])

View file

@ -18,15 +18,14 @@
# ----------------------------------------------------------------------------
from __future__ import absolute_import, division, print_function
__metaclass__ = type
################################################################################
# Documentation
################################################################################
ANSIBLE_METADATA = {'metadata_version': '1.1',
'status': ["preview"],
'supported_by': 'community'}
ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
DOCUMENTATION = '''
---
@ -213,11 +212,7 @@ import json
def main():
module = GcpModule(
argument_spec=dict(
filters=dict(type='list', elements='str')
)
)
module = GcpModule(argument_spec=dict(filters=dict(type='list', elements='str')))
if not module.params['scopes']:
module.params['scopes'] = ['https://www.googleapis.com/auth/compute']
@ -227,9 +222,7 @@ def main():
items = items.get('items')
else:
items = []
return_value = {
'items': items
}
return_value = {'items': items}
module.exit_json(**return_value)

View file

@ -18,15 +18,14 @@
# ----------------------------------------------------------------------------
from __future__ import absolute_import, division, print_function
__metaclass__ = type
################################################################################
# Documentation
################################################################################
ANSIBLE_METADATA = {'metadata_version': '1.1',
'status': ["preview"],
'supported_by': 'community'}
ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
DOCUMENTATION = '''
---
@ -537,38 +536,50 @@ def main():
timeout_sec=dict(default=5, type='int', aliases=['timeout_seconds']),
unhealthy_threshold=dict(default=2, type='int'),
type=dict(type='str', choices=['TCP', 'SSL', 'HTTP', 'HTTPS']),
http_health_check=dict(type='dict', options=dict(
host=dict(type='str'),
request_path=dict(default='/', type='str'),
response=dict(type='str'),
port=dict(type='int'),
port_name=dict(type='str'),
proxy_header=dict(default='NONE', type='str', choices=['NONE', 'PROXY_V1'])
)),
https_health_check=dict(type='dict', options=dict(
host=dict(type='str'),
request_path=dict(default='/', type='str'),
response=dict(type='str'),
port=dict(type='int'),
port_name=dict(type='str'),
proxy_header=dict(default='NONE', type='str', choices=['NONE', 'PROXY_V1'])
)),
tcp_health_check=dict(type='dict', options=dict(
request=dict(type='str'),
response=dict(type='str'),
port=dict(type='int'),
port_name=dict(type='str'),
proxy_header=dict(default='NONE', type='str', choices=['NONE', 'PROXY_V1'])
)),
ssl_health_check=dict(type='dict', options=dict(
request=dict(type='str'),
response=dict(type='str'),
port=dict(type='int'),
port_name=dict(type='str'),
proxy_header=dict(default='NONE', type='str', choices=['NONE', 'PROXY_V1'])
))
http_health_check=dict(
type='dict',
options=dict(
host=dict(type='str'),
request_path=dict(default='/', type='str'),
response=dict(type='str'),
port=dict(type='int'),
port_name=dict(type='str'),
proxy_header=dict(default='NONE', type='str', choices=['NONE', 'PROXY_V1']),
),
),
https_health_check=dict(
type='dict',
options=dict(
host=dict(type='str'),
request_path=dict(default='/', type='str'),
response=dict(type='str'),
port=dict(type='int'),
port_name=dict(type='str'),
proxy_header=dict(default='NONE', type='str', choices=['NONE', 'PROXY_V1']),
),
),
tcp_health_check=dict(
type='dict',
options=dict(
request=dict(type='str'),
response=dict(type='str'),
port=dict(type='int'),
port_name=dict(type='str'),
proxy_header=dict(default='NONE', type='str', choices=['NONE', 'PROXY_V1']),
),
),
ssl_health_check=dict(
type='dict',
options=dict(
request=dict(type='str'),
response=dict(type='str'),
port=dict(type='int'),
port_name=dict(type='str'),
proxy_header=dict(default='NONE', type='str', choices=['NONE', 'PROXY_V1']),
),
),
),
mutually_exclusive=[['http_health_check', 'https_health_check', 'ssl_health_check', 'tcp_health_check']]
mutually_exclusive=[['http_health_check', 'https_health_check', 'ssl_health_check', 'tcp_health_check']],
)
if not module.params['scopes']:
@ -630,7 +641,7 @@ def resource_to_request(module):
u'httpHealthCheck': HealthCheckHttphealthcheck(module.params.get('http_health_check', {}), module).to_request(),
u'httpsHealthCheck': HealthCheckHttpshealthcheck(module.params.get('https_health_check', {}), module).to_request(),
u'tcpHealthCheck': HealthCheckTcphealthcheck(module.params.get('tcp_health_check', {}), module).to_request(),
u'sslHealthCheck': HealthCheckSslhealthcheck(module.params.get('ssl_health_check', {}), module).to_request()
u'sslHealthCheck': HealthCheckSslhealthcheck(module.params.get('ssl_health_check', {}), module).to_request(),
}
return_vals = {}
for k, v in request.items():
@ -665,8 +676,8 @@ def return_if_object(module, response, kind, allow_not_found=False):
try:
module.raise_for_status(response)
result = response.json()
except getattr(json.decoder, 'JSONDecodeError', ValueError) as inst:
module.fail_json(msg="Invalid JSON response with error: %s" % inst)
except getattr(json.decoder, 'JSONDecodeError', ValueError):
module.fail_json(msg="Invalid JSON response with error: %s" % response.text)
if navigate_hash(result, ['error', 'errors']):
module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
@ -708,7 +719,7 @@ def response_to_hash(module, response):
u'httpHealthCheck': HealthCheckHttphealthcheck(response.get(u'httpHealthCheck', {}), module).from_response(),
u'httpsHealthCheck': HealthCheckHttpshealthcheck(response.get(u'httpsHealthCheck', {}), module).from_response(),
u'tcpHealthCheck': HealthCheckTcphealthcheck(response.get(u'tcpHealthCheck', {}), module).from_response(),
u'sslHealthCheck': HealthCheckSslhealthcheck(response.get(u'sslHealthCheck', {}), module).from_response()
u'sslHealthCheck': HealthCheckSslhealthcheck(response.get(u'sslHealthCheck', {}), module).from_response(),
}
@ -734,7 +745,7 @@ def wait_for_completion(status, op_result, module):
op_id = navigate_hash(op_result, ['name'])
op_uri = async_op_url(module, {'op_id': op_id})
while status != 'DONE':
raise_if_errors(op_result, ['error', 'errors'], 'message')
raise_if_errors(op_result, ['error', 'errors'], module)
time.sleep(1.0)
op_result = fetch_resource(module, op_uri, 'compute#operation')
status = navigate_hash(op_result, ['status'])
@ -756,24 +767,28 @@ class HealthCheckHttphealthcheck(object):
self.request = {}
def to_request(self):
return remove_nones_from_dict({
u'host': self.request.get('host'),
u'requestPath': self.request.get('request_path'),
u'response': self.request.get('response'),
u'port': self.request.get('port'),
u'portName': self.request.get('port_name'),
u'proxyHeader': self.request.get('proxy_header')
})
return remove_nones_from_dict(
{
u'host': self.request.get('host'),
u'requestPath': self.request.get('request_path'),
u'response': self.request.get('response'),
u'port': self.request.get('port'),
u'portName': self.request.get('port_name'),
u'proxyHeader': self.request.get('proxy_header'),
}
)
def from_response(self):
return remove_nones_from_dict({
u'host': self.request.get(u'host'),
u'requestPath': self.request.get(u'requestPath'),
u'response': self.request.get(u'response'),
u'port': self.request.get(u'port'),
u'portName': self.request.get(u'portName'),
u'proxyHeader': self.request.get(u'proxyHeader')
})
return remove_nones_from_dict(
{
u'host': self.request.get(u'host'),
u'requestPath': self.request.get(u'requestPath'),
u'response': self.request.get(u'response'),
u'port': self.request.get(u'port'),
u'portName': self.request.get(u'portName'),
u'proxyHeader': self.request.get(u'proxyHeader'),
}
)
class HealthCheckHttpshealthcheck(object):
@ -785,24 +800,28 @@ class HealthCheckHttpshealthcheck(object):
self.request = {}
def to_request(self):
return remove_nones_from_dict({
u'host': self.request.get('host'),
u'requestPath': self.request.get('request_path'),
u'response': self.request.get('response'),
u'port': self.request.get('port'),
u'portName': self.request.get('port_name'),
u'proxyHeader': self.request.get('proxy_header')
})
return remove_nones_from_dict(
{
u'host': self.request.get('host'),
u'requestPath': self.request.get('request_path'),
u'response': self.request.get('response'),
u'port': self.request.get('port'),
u'portName': self.request.get('port_name'),
u'proxyHeader': self.request.get('proxy_header'),
}
)
def from_response(self):
return remove_nones_from_dict({
u'host': self.request.get(u'host'),
u'requestPath': self.request.get(u'requestPath'),
u'response': self.request.get(u'response'),
u'port': self.request.get(u'port'),
u'portName': self.request.get(u'portName'),
u'proxyHeader': self.request.get(u'proxyHeader')
})
return remove_nones_from_dict(
{
u'host': self.request.get(u'host'),
u'requestPath': self.request.get(u'requestPath'),
u'response': self.request.get(u'response'),
u'port': self.request.get(u'port'),
u'portName': self.request.get(u'portName'),
u'proxyHeader': self.request.get(u'proxyHeader'),
}
)
class HealthCheckTcphealthcheck(object):
@ -814,22 +833,26 @@ class HealthCheckTcphealthcheck(object):
self.request = {}
def to_request(self):
return remove_nones_from_dict({
u'request': self.request.get('request'),
u'response': self.request.get('response'),
u'port': self.request.get('port'),
u'portName': self.request.get('port_name'),
u'proxyHeader': self.request.get('proxy_header')
})
return remove_nones_from_dict(
{
u'request': self.request.get('request'),
u'response': self.request.get('response'),
u'port': self.request.get('port'),
u'portName': self.request.get('port_name'),
u'proxyHeader': self.request.get('proxy_header'),
}
)
def from_response(self):
return remove_nones_from_dict({
u'request': self.request.get(u'request'),
u'response': self.request.get(u'response'),
u'port': self.request.get(u'port'),
u'portName': self.request.get(u'portName'),
u'proxyHeader': self.request.get(u'proxyHeader')
})
return remove_nones_from_dict(
{
u'request': self.request.get(u'request'),
u'response': self.request.get(u'response'),
u'port': self.request.get(u'port'),
u'portName': self.request.get(u'portName'),
u'proxyHeader': self.request.get(u'proxyHeader'),
}
)
class HealthCheckSslhealthcheck(object):
@ -841,22 +864,26 @@ class HealthCheckSslhealthcheck(object):
self.request = {}
def to_request(self):
return remove_nones_from_dict({
u'request': self.request.get('request'),
u'response': self.request.get('response'),
u'port': self.request.get('port'),
u'portName': self.request.get('port_name'),
u'proxyHeader': self.request.get('proxy_header')
})
return remove_nones_from_dict(
{
u'request': self.request.get('request'),
u'response': self.request.get('response'),
u'port': self.request.get('port'),
u'portName': self.request.get('port_name'),
u'proxyHeader': self.request.get('proxy_header'),
}
)
def from_response(self):
return remove_nones_from_dict({
u'request': self.request.get(u'request'),
u'response': self.request.get(u'response'),
u'port': self.request.get(u'port'),
u'portName': self.request.get(u'portName'),
u'proxyHeader': self.request.get(u'proxyHeader')
})
return remove_nones_from_dict(
{
u'request': self.request.get(u'request'),
u'response': self.request.get(u'response'),
u'port': self.request.get(u'port'),
u'portName': self.request.get(u'portName'),
u'proxyHeader': self.request.get(u'proxyHeader'),
}
)
if __name__ == '__main__':

View file

@ -18,15 +18,14 @@
# ----------------------------------------------------------------------------
from __future__ import absolute_import, division, print_function
__metaclass__ = type
################################################################################
# Documentation
################################################################################
ANSIBLE_METADATA = {'metadata_version': '1.1',
'status': ["preview"],
'supported_by': 'community'}
ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
DOCUMENTATION = '''
---
@ -303,11 +302,7 @@ import json
def main():
module = GcpModule(
argument_spec=dict(
filters=dict(type='list', elements='str')
)
)
module = GcpModule(argument_spec=dict(filters=dict(type='list', elements='str')))
if not module.params['scopes']:
module.params['scopes'] = ['https://www.googleapis.com/auth/compute']
@ -317,9 +312,7 @@ def main():
items = items.get('items')
else:
items = []
return_value = {
'items': items
}
return_value = {'items': items}
module.exit_json(**return_value)

View file

@ -18,15 +18,14 @@
# ----------------------------------------------------------------------------
from __future__ import absolute_import, division, print_function
__metaclass__ = type
################################################################################
# Documentation
################################################################################
ANSIBLE_METADATA = {'metadata_version': '1.1',
'status': ["preview"],
'supported_by': 'community'}
ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
DOCUMENTATION = '''
---
@ -223,7 +222,7 @@ def main():
port=dict(type='int'),
request_path=dict(type='str'),
timeout_sec=dict(type='int', aliases=['timeout_seconds']),
unhealthy_threshold=dict(type='int')
unhealthy_threshold=dict(type='int'),
)
)
@ -284,7 +283,7 @@ def resource_to_request(module):
u'port': module.params.get('port'),
u'requestPath': module.params.get('request_path'),
u'timeoutSec': module.params.get('timeout_sec'),
u'unhealthyThreshold': module.params.get('unhealthy_threshold')
u'unhealthyThreshold': module.params.get('unhealthy_threshold'),
}
return_vals = {}
for k, v in request.items():
@ -319,8 +318,8 @@ def return_if_object(module, response, kind, allow_not_found=False):
try:
module.raise_for_status(response)
result = response.json()
except getattr(json.decoder, 'JSONDecodeError', ValueError) as inst:
module.fail_json(msg="Invalid JSON response with error: %s" % inst)
except getattr(json.decoder, 'JSONDecodeError', ValueError):
module.fail_json(msg="Invalid JSON response with error: %s" % response.text)
if navigate_hash(result, ['error', 'errors']):
module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
@ -360,7 +359,7 @@ def response_to_hash(module, response):
u'port': response.get(u'port'),
u'requestPath': response.get(u'requestPath'),
u'timeoutSec': response.get(u'timeoutSec'),
u'unhealthyThreshold': response.get(u'unhealthyThreshold')
u'unhealthyThreshold': response.get(u'unhealthyThreshold'),
}
@ -386,7 +385,7 @@ def wait_for_completion(status, op_result, module):
op_id = navigate_hash(op_result, ['name'])
op_uri = async_op_url(module, {'op_id': op_id})
while status != 'DONE':
raise_if_errors(op_result, ['error', 'errors'], 'message')
raise_if_errors(op_result, ['error', 'errors'], module)
time.sleep(1.0)
op_result = fetch_resource(module, op_uri, 'compute#operation')
status = navigate_hash(op_result, ['status'])

View file

@ -18,15 +18,14 @@
# ----------------------------------------------------------------------------
from __future__ import absolute_import, division, print_function
__metaclass__ = type
################################################################################
# Documentation
################################################################################
ANSIBLE_METADATA = {'metadata_version': '1.1',
'status': ["preview"],
'supported_by': 'community'}
ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
DOCUMENTATION = '''
---
@ -149,11 +148,7 @@ import json
def main():
module = GcpModule(
argument_spec=dict(
filters=dict(type='list', elements='str')
)
)
module = GcpModule(argument_spec=dict(filters=dict(type='list', elements='str')))
if not module.params['scopes']:
module.params['scopes'] = ['https://www.googleapis.com/auth/compute']
@ -163,9 +158,7 @@ def main():
items = items.get('items')
else:
items = []
return_value = {
'items': items
}
return_value = {'items': items}
module.exit_json(**return_value)