mirror of
https://github.com/ansible-collections/google.cloud.git
synced 2025-04-09 12:20:27 -07:00
Bug fixes for GCP modules (as of 2019-01-22T12:43:52-08:00) (#51244)
This commit is contained in:
parent
6c246c99d6
commit
7dcce92f1c
24 changed files with 776 additions and 813 deletions
|
@ -18,15 +18,14 @@
|
||||||
# ----------------------------------------------------------------------------
|
# ----------------------------------------------------------------------------
|
||||||
|
|
||||||
from __future__ import absolute_import, division, print_function
|
from __future__ import absolute_import, division, print_function
|
||||||
|
|
||||||
__metaclass__ = type
|
__metaclass__ = type
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
# Documentation
|
# Documentation
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
ANSIBLE_METADATA = {'metadata_version': '1.1',
|
ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
|
||||||
'status': ["preview"],
|
|
||||||
'supported_by': 'community'}
|
|
||||||
|
|
||||||
DOCUMENTATION = '''
|
DOCUMENTATION = '''
|
||||||
---
|
---
|
||||||
|
@ -306,27 +305,29 @@ def main():
|
||||||
argument_spec=dict(
|
argument_spec=dict(
|
||||||
state=dict(default='present', choices=['present', 'absent'], type='str'),
|
state=dict(default='present', choices=['present', 'absent'], type='str'),
|
||||||
name=dict(type='str'),
|
name=dict(type='str'),
|
||||||
access=dict(type='list', elements='dict', options=dict(
|
access=dict(
|
||||||
domain=dict(type='str'),
|
type='list',
|
||||||
group_by_email=dict(type='str'),
|
elements='dict',
|
||||||
role=dict(type='str', choices=['READER', 'WRITER', 'OWNER']),
|
options=dict(
|
||||||
special_group=dict(type='str'),
|
domain=dict(type='str'),
|
||||||
user_by_email=dict(type='str'),
|
group_by_email=dict(type='str'),
|
||||||
view=dict(type='dict', options=dict(
|
role=dict(type='str', choices=['READER', 'WRITER', 'OWNER']),
|
||||||
dataset_id=dict(required=True, type='str'),
|
special_group=dict(type='str'),
|
||||||
project_id=dict(required=True, type='str'),
|
user_by_email=dict(type='str'),
|
||||||
table_id=dict(required=True, type='str')
|
view=dict(
|
||||||
))
|
type='dict',
|
||||||
)),
|
options=dict(
|
||||||
dataset_reference=dict(required=True, 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_id=dict(required=True, type='str'),
|
),
|
||||||
project_id=dict(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'),
|
default_table_expiration_ms=dict(type='int'),
|
||||||
description=dict(type='str'),
|
description=dict(type='str'),
|
||||||
friendly_name=dict(type='str'),
|
friendly_name=dict(type='str'),
|
||||||
labels=dict(type='dict'),
|
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'description': module.params.get('description'),
|
||||||
u'friendlyName': module.params.get('friendly_name'),
|
u'friendlyName': module.params.get('friendly_name'),
|
||||||
u'labels': module.params.get('labels'),
|
u'labels': module.params.get('labels'),
|
||||||
u'location': module.params.get('location')
|
u'location': module.params.get('location'),
|
||||||
}
|
}
|
||||||
return_vals = {}
|
return_vals = {}
|
||||||
for k, v in request.items():
|
for k, v in request.items():
|
||||||
|
@ -421,8 +422,8 @@ def return_if_object(module, response, kind, allow_not_found=False):
|
||||||
try:
|
try:
|
||||||
module.raise_for_status(response)
|
module.raise_for_status(response)
|
||||||
result = response.json()
|
result = response.json()
|
||||||
except getattr(json.decoder, 'JSONDecodeError', ValueError) as inst:
|
except getattr(json.decoder, 'JSONDecodeError', ValueError):
|
||||||
module.fail_json(msg="Invalid JSON response with error: %s" % inst)
|
module.fail_json(msg="Invalid JSON response with error: %s" % response.text)
|
||||||
|
|
||||||
if navigate_hash(result, ['error', 'errors']):
|
if navigate_hash(result, ['error', 'errors']):
|
||||||
module.fail_json(msg=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'id': response.get(u'id'),
|
||||||
u'labels': response.get(u'labels'),
|
u'labels': response.get(u'labels'),
|
||||||
u'lastModifiedTime': response.get(u'lastModifiedTime'),
|
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
|
return items
|
||||||
|
|
||||||
def _request_for_item(self, item):
|
def _request_for_item(self, item):
|
||||||
return remove_nones_from_dict({
|
return remove_nones_from_dict(
|
||||||
u'domain': item.get('domain'),
|
{
|
||||||
u'groupByEmail': item.get('group_by_email'),
|
u'domain': item.get('domain'),
|
||||||
u'role': item.get('role'),
|
u'groupByEmail': item.get('group_by_email'),
|
||||||
u'specialGroup': item.get('special_group'),
|
u'role': item.get('role'),
|
||||||
u'userByEmail': item.get('user_by_email'),
|
u'specialGroup': item.get('special_group'),
|
||||||
u'view': DatasetView(item.get('view', {}), self.module).to_request()
|
u'userByEmail': item.get('user_by_email'),
|
||||||
})
|
u'view': DatasetView(item.get('view', {}), self.module).to_request(),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
def _response_from_item(self, item):
|
def _response_from_item(self, item):
|
||||||
return remove_nones_from_dict({
|
return remove_nones_from_dict(
|
||||||
u'domain': item.get(u'domain'),
|
{
|
||||||
u'groupByEmail': item.get(u'groupByEmail'),
|
u'domain': item.get(u'domain'),
|
||||||
u'role': item.get(u'role'),
|
u'groupByEmail': item.get(u'groupByEmail'),
|
||||||
u'specialGroup': item.get(u'specialGroup'),
|
u'role': item.get(u'role'),
|
||||||
u'userByEmail': item.get(u'userByEmail'),
|
u'specialGroup': item.get(u'specialGroup'),
|
||||||
u'view': DatasetView(item.get(u'view', {}), self.module).from_response()
|
u'userByEmail': item.get(u'userByEmail'),
|
||||||
})
|
u'view': DatasetView(item.get(u'view', {}), self.module).from_response(),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class DatasetView(object):
|
class DatasetView(object):
|
||||||
|
@ -516,18 +521,14 @@ class DatasetView(object):
|
||||||
self.request = {}
|
self.request = {}
|
||||||
|
|
||||||
def to_request(self):
|
def to_request(self):
|
||||||
return remove_nones_from_dict({
|
return remove_nones_from_dict(
|
||||||
u'datasetId': self.request.get('dataset_id'),
|
{u'datasetId': self.request.get('dataset_id'), u'projectId': self.request.get('project_id'), u'tableId': self.request.get('table_id')}
|
||||||
u'projectId': self.request.get('project_id'),
|
)
|
||||||
u'tableId': self.request.get('table_id')
|
|
||||||
})
|
|
||||||
|
|
||||||
def from_response(self):
|
def from_response(self):
|
||||||
return remove_nones_from_dict({
|
return remove_nones_from_dict(
|
||||||
u'datasetId': self.request.get(u'datasetId'),
|
{u'datasetId': self.request.get(u'datasetId'), u'projectId': self.request.get(u'projectId'), u'tableId': self.request.get(u'tableId')}
|
||||||
u'projectId': self.request.get(u'projectId'),
|
)
|
||||||
u'tableId': self.request.get(u'tableId')
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
class DatasetDatasetreference(object):
|
class DatasetDatasetreference(object):
|
||||||
|
@ -539,16 +540,10 @@ class DatasetDatasetreference(object):
|
||||||
self.request = {}
|
self.request = {}
|
||||||
|
|
||||||
def to_request(self):
|
def to_request(self):
|
||||||
return remove_nones_from_dict({
|
return remove_nones_from_dict({u'datasetId': self.request.get('dataset_id'), u'projectId': self.request.get('project_id')})
|
||||||
u'datasetId': self.request.get('dataset_id'),
|
|
||||||
u'projectId': self.request.get('project_id')
|
|
||||||
})
|
|
||||||
|
|
||||||
def from_response(self):
|
def from_response(self):
|
||||||
return remove_nones_from_dict({
|
return remove_nones_from_dict({u'datasetId': self.request.get(u'datasetId'), u'projectId': self.request.get(u'projectId')})
|
||||||
u'datasetId': self.request.get(u'datasetId'),
|
|
||||||
u'projectId': self.request.get(u'projectId')
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
|
@ -18,15 +18,14 @@
|
||||||
# ----------------------------------------------------------------------------
|
# ----------------------------------------------------------------------------
|
||||||
|
|
||||||
from __future__ import absolute_import, division, print_function
|
from __future__ import absolute_import, division, print_function
|
||||||
|
|
||||||
__metaclass__ = type
|
__metaclass__ = type
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
# Documentation
|
# Documentation
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
ANSIBLE_METADATA = {'metadata_version': '1.1',
|
ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
|
||||||
'status': ["preview"],
|
|
||||||
'supported_by': 'community'}
|
|
||||||
|
|
||||||
DOCUMENTATION = '''
|
DOCUMENTATION = '''
|
||||||
---
|
---
|
||||||
|
@ -199,10 +198,7 @@ import json
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
module = GcpModule(
|
module = GcpModule(argument_spec=dict())
|
||||||
argument_spec=dict(
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
if not module.params['scopes']:
|
if not module.params['scopes']:
|
||||||
module.params['scopes'] = ['https://www.googleapis.com/auth/bigquery']
|
module.params['scopes'] = ['https://www.googleapis.com/auth/bigquery']
|
||||||
|
@ -212,9 +208,7 @@ def main():
|
||||||
items = items.get('datasets')
|
items = items.get('datasets')
|
||||||
else:
|
else:
|
||||||
items = []
|
items = []
|
||||||
return_value = {
|
return_value = {'items': items}
|
||||||
'items': items
|
|
||||||
}
|
|
||||||
module.exit_json(**return_value)
|
module.exit_json(**return_value)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -18,15 +18,14 @@
|
||||||
# ----------------------------------------------------------------------------
|
# ----------------------------------------------------------------------------
|
||||||
|
|
||||||
from __future__ import absolute_import, division, print_function
|
from __future__ import absolute_import, division, print_function
|
||||||
|
|
||||||
__metaclass__ = type
|
__metaclass__ = type
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
# Documentation
|
# Documentation
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
ANSIBLE_METADATA = {'metadata_version': '1.1',
|
ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
|
||||||
'status': ["preview"],
|
|
||||||
'supported_by': 'community'}
|
|
||||||
|
|
||||||
DOCUMENTATION = '''
|
DOCUMENTATION = '''
|
||||||
---
|
---
|
||||||
|
@ -904,85 +903,107 @@ def main():
|
||||||
module = GcpModule(
|
module = GcpModule(
|
||||||
argument_spec=dict(
|
argument_spec=dict(
|
||||||
state=dict(default='present', choices=['present', 'absent'], type='str'),
|
state=dict(default='present', choices=['present', 'absent'], type='str'),
|
||||||
table_reference=dict(type='dict', options=dict(
|
table_reference=dict(type='dict', options=dict(dataset_id=dict(type='str'), project_id=dict(type='str'), table_id=dict(type='str'))),
|
||||||
dataset_id=dict(type='str'),
|
|
||||||
project_id=dict(type='str'),
|
|
||||||
table_id=dict(type='str')
|
|
||||||
)),
|
|
||||||
description=dict(type='str'),
|
description=dict(type='str'),
|
||||||
friendly_name=dict(type='str'),
|
friendly_name=dict(type='str'),
|
||||||
labels=dict(type='dict'),
|
labels=dict(type='dict'),
|
||||||
name=dict(type='str'),
|
name=dict(type='str'),
|
||||||
view=dict(type='dict', options=dict(
|
view=dict(
|
||||||
use_legacy_sql=dict(type='bool'),
|
type='dict',
|
||||||
user_defined_function_resources=dict(type='list', elements='dict', options=dict(
|
options=dict(
|
||||||
inline_code=dict(type='str'),
|
use_legacy_sql=dict(type='bool'),
|
||||||
resource_uri=dict(type='str')
|
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'])
|
time_partitioning=dict(type='dict', options=dict(expiration_ms=dict(type='int'), type=dict(type='str', choices=['DAY']))),
|
||||||
)),
|
schema=dict(
|
||||||
schema=dict(type='dict', options=dict(
|
type='dict',
|
||||||
fields=dict(type='list', elements='dict', options=dict(
|
options=dict(
|
||||||
description=dict(type='str'),
|
fields=dict(
|
||||||
fields=dict(type='list', elements='str'),
|
type='list',
|
||||||
mode=dict(type='str', choices=['NULLABLE', 'REQUIRED', 'REPEATED']),
|
elements='dict',
|
||||||
name=dict(type='str'),
|
options=dict(
|
||||||
type=dict(type='str', choices=['STRING', 'BYTES', 'INTEGER', 'FLOAT', 'TIMESTAMP', 'DATE', 'TIME', 'DATETIME', 'RECORD'])
|
description=dict(type='str'),
|
||||||
))
|
fields=dict(type='list', elements='str'),
|
||||||
)),
|
mode=dict(type='str', choices=['NULLABLE', 'REQUIRED', 'REPEATED']),
|
||||||
encryption_configuration=dict(type='dict', options=dict(
|
name=dict(type='str'),
|
||||||
kms_key_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'),
|
expiration_time=dict(type='int'),
|
||||||
external_data_configuration=dict(type='dict', options=dict(
|
external_data_configuration=dict(
|
||||||
autodetect=dict(type='bool'),
|
type='dict',
|
||||||
compression=dict(type='str', choices=['GZIP', 'NONE']),
|
options=dict(
|
||||||
ignore_unknown_values=dict(type='bool'),
|
autodetect=dict(type='bool'),
|
||||||
max_bad_records=dict(default=0, type='int'),
|
compression=dict(type='str', choices=['GZIP', 'NONE']),
|
||||||
source_format=dict(type='str', choices=['CSV', 'GOOGLE_SHEETS', 'NEWLINE_DELIMITED_JSON', 'AVRO', 'DATASTORE_BACKUP', 'BIGTABLE']),
|
ignore_unknown_values=dict(type='bool'),
|
||||||
source_uris=dict(type='list', elements='str'),
|
max_bad_records=dict(default=0, type='int'),
|
||||||
schema=dict(type='dict', options=dict(
|
source_format=dict(type='str', choices=['CSV', 'GOOGLE_SHEETS', 'NEWLINE_DELIMITED_JSON', 'AVRO', 'DATASTORE_BACKUP', 'BIGTABLE']),
|
||||||
fields=dict(type='list', elements='dict', options=dict(
|
source_uris=dict(type='list', elements='str'),
|
||||||
description=dict(type='str'),
|
schema=dict(
|
||||||
fields=dict(type='list', elements='str'),
|
type='dict',
|
||||||
mode=dict(type='str', choices=['NULLABLE', 'REQUIRED', 'REPEATED']),
|
options=dict(
|
||||||
name=dict(type='str'),
|
fields=dict(
|
||||||
type=dict(type='str', choices=['STRING', 'BYTES', 'INTEGER', 'FLOAT', 'TIMESTAMP', 'DATE', 'TIME', 'DATETIME', 'RECORD'])
|
type='list',
|
||||||
))
|
elements='dict',
|
||||||
)),
|
options=dict(
|
||||||
google_sheets_options=dict(type='dict', options=dict(
|
description=dict(type='str'),
|
||||||
skip_leading_rows=dict(default=0, type='int')
|
fields=dict(type='list', elements='str'),
|
||||||
)),
|
mode=dict(type='str', choices=['NULLABLE', 'REQUIRED', 'REPEATED']),
|
||||||
csv_options=dict(type='dict', options=dict(
|
name=dict(type='str'),
|
||||||
allow_jagged_rows=dict(type='bool'),
|
type=dict(type='str', choices=['STRING', 'BYTES', 'INTEGER', 'FLOAT', 'TIMESTAMP', 'DATE', 'TIME', 'DATETIME', 'RECORD']),
|
||||||
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')
|
google_sheets_options=dict(type='dict', options=dict(skip_leading_rows=dict(default=0, type='int'))),
|
||||||
)),
|
csv_options=dict(
|
||||||
bigtable_options=dict(type='dict', options=dict(
|
type='dict',
|
||||||
ignore_unspecified_column_families=dict(type='bool'),
|
options=dict(
|
||||||
read_rowkey_as_string=dict(type='bool'),
|
allow_jagged_rows=dict(type='bool'),
|
||||||
column_families=dict(type='list', elements='dict', options=dict(
|
allow_quoted_newlines=dict(type='bool'),
|
||||||
columns=dict(type='list', elements='dict', options=dict(
|
encoding=dict(type='str', choices=['UTF-8', 'ISO-8859-1']),
|
||||||
encoding=dict(type='str', choices=['TEXT', 'BINARY']),
|
field_delimiter=dict(type='str'),
|
||||||
field_name=dict(type='str'),
|
quote=dict(type='str'),
|
||||||
only_read_latest=dict(type='bool'),
|
skip_leading_rows=dict(default=0, type='int'),
|
||||||
qualifier_string=dict(required=True, type='str'),
|
),
|
||||||
type=dict(type='str', choices=['BYTES', 'STRING', 'INTEGER', 'FLOAT', 'BOOLEAN'])
|
),
|
||||||
)),
|
bigtable_options=dict(
|
||||||
encoding=dict(type='str', choices=['TEXT', 'BINARY']),
|
type='dict',
|
||||||
family_id=dict(type='str'),
|
options=dict(
|
||||||
only_read_latest=dict(type='bool'),
|
ignore_unspecified_column_families=dict(type='bool'),
|
||||||
type=dict(type='str', choices=['BYTES', 'STRING', 'INTEGER', 'FLOAT', 'BOOLEAN'])
|
read_rowkey_as_string=dict(type='bool'),
|
||||||
))
|
column_families=dict(
|
||||||
))
|
type='list',
|
||||||
)),
|
elements='dict',
|
||||||
dataset=dict(type='str')
|
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'schema': TableSchema(module.params.get('schema', {}), module).to_request(),
|
||||||
u'encryptionConfiguration': TableEncryptionconfiguration(module.params.get('encryption_configuration', {}), module).to_request(),
|
u'encryptionConfiguration': TableEncryptionconfiguration(module.params.get('encryption_configuration', {}), module).to_request(),
|
||||||
u'expirationTime': module.params.get('expiration_time'),
|
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 = {}
|
return_vals = {}
|
||||||
for k, v in request.items():
|
for k, v in request.items():
|
||||||
|
@ -1080,8 +1101,8 @@ def return_if_object(module, response, kind, allow_not_found=False):
|
||||||
try:
|
try:
|
||||||
module.raise_for_status(response)
|
module.raise_for_status(response)
|
||||||
result = response.json()
|
result = response.json()
|
||||||
except getattr(json.decoder, 'JSONDecodeError', ValueError) as inst:
|
except getattr(json.decoder, 'JSONDecodeError', ValueError):
|
||||||
module.fail_json(msg="Invalid JSON response with error: %s" % inst)
|
module.fail_json(msg="Invalid JSON response with error: %s" % response.text)
|
||||||
|
|
||||||
if navigate_hash(result, ['error', 'errors']):
|
if navigate_hash(result, ['error', 'errors']):
|
||||||
module.fail_json(msg=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'schema': TableSchema(response.get(u'schema', {}), module).from_response(),
|
||||||
u'encryptionConfiguration': TableEncryptionconfiguration(response.get(u'encryptionConfiguration', {}), module).from_response(),
|
u'encryptionConfiguration': TableEncryptionconfiguration(response.get(u'encryptionConfiguration', {}), module).from_response(),
|
||||||
u'expirationTime': response.get(u'expirationTime'),
|
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 = {}
|
self.request = {}
|
||||||
|
|
||||||
def to_request(self):
|
def to_request(self):
|
||||||
return remove_nones_from_dict({
|
return remove_nones_from_dict(
|
||||||
u'datasetId': self.request.get('dataset_id'),
|
{u'datasetId': self.request.get('dataset_id'), u'projectId': self.request.get('project_id'), u'tableId': self.request.get('table_id')}
|
||||||
u'projectId': self.request.get('project_id'),
|
)
|
||||||
u'tableId': self.request.get('table_id')
|
|
||||||
})
|
|
||||||
|
|
||||||
def from_response(self):
|
def from_response(self):
|
||||||
return remove_nones_from_dict({
|
return remove_nones_from_dict(
|
||||||
u'datasetId': self.request.get(u'datasetId'),
|
{u'datasetId': self.request.get(u'datasetId'), u'projectId': self.request.get(u'projectId'), u'tableId': self.request.get(u'tableId')}
|
||||||
u'projectId': self.request.get(u'projectId'),
|
)
|
||||||
u'tableId': self.request.get(u'tableId')
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
class TableView(object):
|
class TableView(object):
|
||||||
|
@ -1166,18 +1183,24 @@ class TableView(object):
|
||||||
self.request = {}
|
self.request = {}
|
||||||
|
|
||||||
def to_request(self):
|
def to_request(self):
|
||||||
return remove_nones_from_dict({
|
return remove_nones_from_dict(
|
||||||
u'useLegacySql': self.request.get('use_legacy_sql'),
|
{
|
||||||
u'userDefinedFunctionResources':
|
u'useLegacySql': self.request.get('use_legacy_sql'),
|
||||||
TableUserdefinedfunctionresourcesArray(self.request.get('user_defined_function_resources', []), self.module).to_request()
|
u'userDefinedFunctionResources': TableUserdefinedfunctionresourcesArray(
|
||||||
})
|
self.request.get('user_defined_function_resources', []), self.module
|
||||||
|
).to_request(),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
def from_response(self):
|
def from_response(self):
|
||||||
return remove_nones_from_dict({
|
return remove_nones_from_dict(
|
||||||
u'useLegacySql': self.request.get(u'useLegacySql'),
|
{
|
||||||
u'userDefinedFunctionResources':
|
u'useLegacySql': self.request.get(u'useLegacySql'),
|
||||||
TableUserdefinedfunctionresourcesArray(self.request.get(u'userDefinedFunctionResources', []), self.module).from_response()
|
u'userDefinedFunctionResources': TableUserdefinedfunctionresourcesArray(
|
||||||
})
|
self.request.get(u'userDefinedFunctionResources', []), self.module
|
||||||
|
).from_response(),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class TableUserdefinedfunctionresourcesArray(object):
|
class TableUserdefinedfunctionresourcesArray(object):
|
||||||
|
@ -1201,16 +1224,10 @@ class TableUserdefinedfunctionresourcesArray(object):
|
||||||
return items
|
return items
|
||||||
|
|
||||||
def _request_for_item(self, item):
|
def _request_for_item(self, item):
|
||||||
return remove_nones_from_dict({
|
return remove_nones_from_dict({u'inlineCode': item.get('inline_code'), u'resourceUri': item.get('resource_uri')})
|
||||||
u'inlineCode': item.get('inline_code'),
|
|
||||||
u'resourceUri': item.get('resource_uri')
|
|
||||||
})
|
|
||||||
|
|
||||||
def _response_from_item(self, item):
|
def _response_from_item(self, item):
|
||||||
return remove_nones_from_dict({
|
return remove_nones_from_dict({u'inlineCode': item.get(u'inlineCode'), u'resourceUri': item.get(u'resourceUri')})
|
||||||
u'inlineCode': item.get(u'inlineCode'),
|
|
||||||
u'resourceUri': item.get(u'resourceUri')
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
class TableTimepartitioning(object):
|
class TableTimepartitioning(object):
|
||||||
|
@ -1222,16 +1239,10 @@ class TableTimepartitioning(object):
|
||||||
self.request = {}
|
self.request = {}
|
||||||
|
|
||||||
def to_request(self):
|
def to_request(self):
|
||||||
return remove_nones_from_dict({
|
return remove_nones_from_dict({u'expirationMs': self.request.get('expiration_ms'), u'type': self.request.get('type')})
|
||||||
u'expirationMs': self.request.get('expiration_ms'),
|
|
||||||
u'type': self.request.get('type')
|
|
||||||
})
|
|
||||||
|
|
||||||
def from_response(self):
|
def from_response(self):
|
||||||
return remove_nones_from_dict({
|
return remove_nones_from_dict({u'expirationMs': self.request.get(u'expirationMs'), u'type': self.request.get(u'type')})
|
||||||
u'expirationMs': self.request.get(u'expirationMs'),
|
|
||||||
u'type': self.request.get(u'type')
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
class TableStreamingbuffer(object):
|
class TableStreamingbuffer(object):
|
||||||
|
@ -1243,18 +1254,22 @@ class TableStreamingbuffer(object):
|
||||||
self.request = {}
|
self.request = {}
|
||||||
|
|
||||||
def to_request(self):
|
def to_request(self):
|
||||||
return remove_nones_from_dict({
|
return remove_nones_from_dict(
|
||||||
u'estimatedBytes': self.request.get('estimated_bytes'),
|
{
|
||||||
u'estimatedRows': self.request.get('estimated_rows'),
|
u'estimatedBytes': self.request.get('estimated_bytes'),
|
||||||
u'oldestEntryTime': self.request.get('oldest_entry_time')
|
u'estimatedRows': self.request.get('estimated_rows'),
|
||||||
})
|
u'oldestEntryTime': self.request.get('oldest_entry_time'),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
def from_response(self):
|
def from_response(self):
|
||||||
return remove_nones_from_dict({
|
return remove_nones_from_dict(
|
||||||
u'estimatedBytes': self.request.get(u'estimatedBytes'),
|
{
|
||||||
u'estimatedRows': self.request.get(u'estimatedRows'),
|
u'estimatedBytes': self.request.get(u'estimatedBytes'),
|
||||||
u'oldestEntryTime': self.request.get(u'oldestEntryTime')
|
u'estimatedRows': self.request.get(u'estimatedRows'),
|
||||||
})
|
u'oldestEntryTime': self.request.get(u'oldestEntryTime'),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class TableSchema(object):
|
class TableSchema(object):
|
||||||
|
@ -1266,14 +1281,10 @@ class TableSchema(object):
|
||||||
self.request = {}
|
self.request = {}
|
||||||
|
|
||||||
def to_request(self):
|
def to_request(self):
|
||||||
return remove_nones_from_dict({
|
return remove_nones_from_dict({u'fields': TableFieldsArray(self.request.get('fields', []), self.module).to_request()})
|
||||||
u'fields': TableFieldsArray(self.request.get('fields', []), self.module).to_request()
|
|
||||||
})
|
|
||||||
|
|
||||||
def from_response(self):
|
def from_response(self):
|
||||||
return remove_nones_from_dict({
|
return remove_nones_from_dict({u'fields': TableFieldsArray(self.request.get(u'fields', []), self.module).from_response()})
|
||||||
u'fields': TableFieldsArray(self.request.get(u'fields', []), self.module).from_response()
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
class TableFieldsArray(object):
|
class TableFieldsArray(object):
|
||||||
|
@ -1297,22 +1308,26 @@ class TableFieldsArray(object):
|
||||||
return items
|
return items
|
||||||
|
|
||||||
def _request_for_item(self, item):
|
def _request_for_item(self, item):
|
||||||
return remove_nones_from_dict({
|
return remove_nones_from_dict(
|
||||||
u'description': item.get('description'),
|
{
|
||||||
u'fields': item.get('fields'),
|
u'description': item.get('description'),
|
||||||
u'mode': item.get('mode'),
|
u'fields': item.get('fields'),
|
||||||
u'name': item.get('name'),
|
u'mode': item.get('mode'),
|
||||||
u'type': item.get('type')
|
u'name': item.get('name'),
|
||||||
})
|
u'type': item.get('type'),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
def _response_from_item(self, item):
|
def _response_from_item(self, item):
|
||||||
return remove_nones_from_dict({
|
return remove_nones_from_dict(
|
||||||
u'description': item.get(u'description'),
|
{
|
||||||
u'fields': item.get(u'fields'),
|
u'description': item.get(u'description'),
|
||||||
u'mode': item.get(u'mode'),
|
u'fields': item.get(u'fields'),
|
||||||
u'name': item.get(u'name'),
|
u'mode': item.get(u'mode'),
|
||||||
u'type': item.get(u'type')
|
u'name': item.get(u'name'),
|
||||||
})
|
u'type': item.get(u'type'),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class TableEncryptionconfiguration(object):
|
class TableEncryptionconfiguration(object):
|
||||||
|
@ -1324,14 +1339,10 @@ class TableEncryptionconfiguration(object):
|
||||||
self.request = {}
|
self.request = {}
|
||||||
|
|
||||||
def to_request(self):
|
def to_request(self):
|
||||||
return remove_nones_from_dict({
|
return remove_nones_from_dict({u'kmsKeyName': self.request.get('kms_key_name')})
|
||||||
u'kmsKeyName': self.request.get('kms_key_name')
|
|
||||||
})
|
|
||||||
|
|
||||||
def from_response(self):
|
def from_response(self):
|
||||||
return remove_nones_from_dict({
|
return remove_nones_from_dict({u'kmsKeyName': self.request.get(u'kmsKeyName')})
|
||||||
u'kmsKeyName': self.request.get(u'kmsKeyName')
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
class TableExternaldataconfiguration(object):
|
class TableExternaldataconfiguration(object):
|
||||||
|
@ -1343,32 +1354,36 @@ class TableExternaldataconfiguration(object):
|
||||||
self.request = {}
|
self.request = {}
|
||||||
|
|
||||||
def to_request(self):
|
def to_request(self):
|
||||||
return remove_nones_from_dict({
|
return remove_nones_from_dict(
|
||||||
u'autodetect': self.request.get('autodetect'),
|
{
|
||||||
u'compression': self.request.get('compression'),
|
u'autodetect': self.request.get('autodetect'),
|
||||||
u'ignoreUnknownValues': self.request.get('ignore_unknown_values'),
|
u'compression': self.request.get('compression'),
|
||||||
u'maxBadRecords': self.request.get('max_bad_records'),
|
u'ignoreUnknownValues': self.request.get('ignore_unknown_values'),
|
||||||
u'sourceFormat': self.request.get('source_format'),
|
u'maxBadRecords': self.request.get('max_bad_records'),
|
||||||
u'sourceUris': self.request.get('source_uris'),
|
u'sourceFormat': self.request.get('source_format'),
|
||||||
u'schema': TableSchema(self.request.get('schema', {}), self.module).to_request(),
|
u'sourceUris': self.request.get('source_uris'),
|
||||||
u'googleSheetsOptions': TableGooglesheetsoptions(self.request.get('google_sheets_options', {}), self.module).to_request(),
|
u'schema': TableSchema(self.request.get('schema', {}), self.module).to_request(),
|
||||||
u'csvOptions': TableCsvoptions(self.request.get('csv_options', {}), self.module).to_request(),
|
u'googleSheetsOptions': TableGooglesheetsoptions(self.request.get('google_sheets_options', {}), self.module).to_request(),
|
||||||
u'bigtableOptions': TableBigtableoptions(self.request.get('bigtable_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):
|
def from_response(self):
|
||||||
return remove_nones_from_dict({
|
return remove_nones_from_dict(
|
||||||
u'autodetect': self.request.get(u'autodetect'),
|
{
|
||||||
u'compression': self.request.get(u'compression'),
|
u'autodetect': self.request.get(u'autodetect'),
|
||||||
u'ignoreUnknownValues': self.request.get(u'ignoreUnknownValues'),
|
u'compression': self.request.get(u'compression'),
|
||||||
u'maxBadRecords': self.request.get(u'maxBadRecords'),
|
u'ignoreUnknownValues': self.request.get(u'ignoreUnknownValues'),
|
||||||
u'sourceFormat': self.request.get(u'sourceFormat'),
|
u'maxBadRecords': self.request.get(u'maxBadRecords'),
|
||||||
u'sourceUris': self.request.get(u'sourceUris'),
|
u'sourceFormat': self.request.get(u'sourceFormat'),
|
||||||
u'schema': TableSchema(self.request.get(u'schema', {}), self.module).from_response(),
|
u'sourceUris': self.request.get(u'sourceUris'),
|
||||||
u'googleSheetsOptions': TableGooglesheetsoptions(self.request.get(u'googleSheetsOptions', {}), self.module).from_response(),
|
u'schema': TableSchema(self.request.get(u'schema', {}), self.module).from_response(),
|
||||||
u'csvOptions': TableCsvoptions(self.request.get(u'csvOptions', {}), self.module).from_response(),
|
u'googleSheetsOptions': TableGooglesheetsoptions(self.request.get(u'googleSheetsOptions', {}), self.module).from_response(),
|
||||||
u'bigtableOptions': TableBigtableoptions(self.request.get(u'bigtableOptions', {}), 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):
|
class TableSchema(object):
|
||||||
|
@ -1380,14 +1395,10 @@ class TableSchema(object):
|
||||||
self.request = {}
|
self.request = {}
|
||||||
|
|
||||||
def to_request(self):
|
def to_request(self):
|
||||||
return remove_nones_from_dict({
|
return remove_nones_from_dict({u'fields': TableFieldsArray(self.request.get('fields', []), self.module).to_request()})
|
||||||
u'fields': TableFieldsArray(self.request.get('fields', []), self.module).to_request()
|
|
||||||
})
|
|
||||||
|
|
||||||
def from_response(self):
|
def from_response(self):
|
||||||
return remove_nones_from_dict({
|
return remove_nones_from_dict({u'fields': TableFieldsArray(self.request.get(u'fields', []), self.module).from_response()})
|
||||||
u'fields': TableFieldsArray(self.request.get(u'fields', []), self.module).from_response()
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
class TableFieldsArray(object):
|
class TableFieldsArray(object):
|
||||||
|
@ -1411,22 +1422,26 @@ class TableFieldsArray(object):
|
||||||
return items
|
return items
|
||||||
|
|
||||||
def _request_for_item(self, item):
|
def _request_for_item(self, item):
|
||||||
return remove_nones_from_dict({
|
return remove_nones_from_dict(
|
||||||
u'description': item.get('description'),
|
{
|
||||||
u'fields': item.get('fields'),
|
u'description': item.get('description'),
|
||||||
u'mode': item.get('mode'),
|
u'fields': item.get('fields'),
|
||||||
u'name': item.get('name'),
|
u'mode': item.get('mode'),
|
||||||
u'type': item.get('type')
|
u'name': item.get('name'),
|
||||||
})
|
u'type': item.get('type'),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
def _response_from_item(self, item):
|
def _response_from_item(self, item):
|
||||||
return remove_nones_from_dict({
|
return remove_nones_from_dict(
|
||||||
u'description': item.get(u'description'),
|
{
|
||||||
u'fields': item.get(u'fields'),
|
u'description': item.get(u'description'),
|
||||||
u'mode': item.get(u'mode'),
|
u'fields': item.get(u'fields'),
|
||||||
u'name': item.get(u'name'),
|
u'mode': item.get(u'mode'),
|
||||||
u'type': item.get(u'type')
|
u'name': item.get(u'name'),
|
||||||
})
|
u'type': item.get(u'type'),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class TableGooglesheetsoptions(object):
|
class TableGooglesheetsoptions(object):
|
||||||
|
@ -1438,14 +1453,10 @@ class TableGooglesheetsoptions(object):
|
||||||
self.request = {}
|
self.request = {}
|
||||||
|
|
||||||
def to_request(self):
|
def to_request(self):
|
||||||
return remove_nones_from_dict({
|
return remove_nones_from_dict({u'skipLeadingRows': self.request.get('skip_leading_rows')})
|
||||||
u'skipLeadingRows': self.request.get('skip_leading_rows')
|
|
||||||
})
|
|
||||||
|
|
||||||
def from_response(self):
|
def from_response(self):
|
||||||
return remove_nones_from_dict({
|
return remove_nones_from_dict({u'skipLeadingRows': self.request.get(u'skipLeadingRows')})
|
||||||
u'skipLeadingRows': self.request.get(u'skipLeadingRows')
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
class TableCsvoptions(object):
|
class TableCsvoptions(object):
|
||||||
|
@ -1457,24 +1468,28 @@ class TableCsvoptions(object):
|
||||||
self.request = {}
|
self.request = {}
|
||||||
|
|
||||||
def to_request(self):
|
def to_request(self):
|
||||||
return remove_nones_from_dict({
|
return remove_nones_from_dict(
|
||||||
u'allowJaggedRows': self.request.get('allow_jagged_rows'),
|
{
|
||||||
u'allowQuotedNewlines': self.request.get('allow_quoted_newlines'),
|
u'allowJaggedRows': self.request.get('allow_jagged_rows'),
|
||||||
u'encoding': self.request.get('encoding'),
|
u'allowQuotedNewlines': self.request.get('allow_quoted_newlines'),
|
||||||
u'fieldDelimiter': self.request.get('field_delimiter'),
|
u'encoding': self.request.get('encoding'),
|
||||||
u'quote': self.request.get('quote'),
|
u'fieldDelimiter': self.request.get('field_delimiter'),
|
||||||
u'skipLeadingRows': self.request.get('skip_leading_rows')
|
u'quote': self.request.get('quote'),
|
||||||
})
|
u'skipLeadingRows': self.request.get('skip_leading_rows'),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
def from_response(self):
|
def from_response(self):
|
||||||
return remove_nones_from_dict({
|
return remove_nones_from_dict(
|
||||||
u'allowJaggedRows': self.request.get(u'allowJaggedRows'),
|
{
|
||||||
u'allowQuotedNewlines': self.request.get(u'allowQuotedNewlines'),
|
u'allowJaggedRows': self.request.get(u'allowJaggedRows'),
|
||||||
u'encoding': self.request.get(u'encoding'),
|
u'allowQuotedNewlines': self.request.get(u'allowQuotedNewlines'),
|
||||||
u'fieldDelimiter': self.request.get(u'fieldDelimiter'),
|
u'encoding': self.request.get(u'encoding'),
|
||||||
u'quote': self.request.get(u'quote'),
|
u'fieldDelimiter': self.request.get(u'fieldDelimiter'),
|
||||||
u'skipLeadingRows': self.request.get(u'skipLeadingRows')
|
u'quote': self.request.get(u'quote'),
|
||||||
})
|
u'skipLeadingRows': self.request.get(u'skipLeadingRows'),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class TableBigtableoptions(object):
|
class TableBigtableoptions(object):
|
||||||
|
@ -1486,18 +1501,22 @@ class TableBigtableoptions(object):
|
||||||
self.request = {}
|
self.request = {}
|
||||||
|
|
||||||
def to_request(self):
|
def to_request(self):
|
||||||
return remove_nones_from_dict({
|
return remove_nones_from_dict(
|
||||||
u'ignoreUnspecifiedColumnFamilies': self.request.get('ignore_unspecified_column_families'),
|
{
|
||||||
u'readRowkeyAsString': self.request.get('read_rowkey_as_string'),
|
u'ignoreUnspecifiedColumnFamilies': self.request.get('ignore_unspecified_column_families'),
|
||||||
u'columnFamilies': TableColumnfamiliesArray(self.request.get('column_families', []), self.module).to_request()
|
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):
|
def from_response(self):
|
||||||
return remove_nones_from_dict({
|
return remove_nones_from_dict(
|
||||||
u'ignoreUnspecifiedColumnFamilies': self.request.get(u'ignoreUnspecifiedColumnFamilies'),
|
{
|
||||||
u'readRowkeyAsString': self.request.get(u'readRowkeyAsString'),
|
u'ignoreUnspecifiedColumnFamilies': self.request.get(u'ignoreUnspecifiedColumnFamilies'),
|
||||||
u'columnFamilies': TableColumnfamiliesArray(self.request.get(u'columnFamilies', []), self.module).from_response()
|
u'readRowkeyAsString': self.request.get(u'readRowkeyAsString'),
|
||||||
})
|
u'columnFamilies': TableColumnfamiliesArray(self.request.get(u'columnFamilies', []), self.module).from_response(),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class TableColumnfamiliesArray(object):
|
class TableColumnfamiliesArray(object):
|
||||||
|
@ -1521,22 +1540,26 @@ class TableColumnfamiliesArray(object):
|
||||||
return items
|
return items
|
||||||
|
|
||||||
def _request_for_item(self, item):
|
def _request_for_item(self, item):
|
||||||
return remove_nones_from_dict({
|
return remove_nones_from_dict(
|
||||||
u'columns': TableColumnsArray(item.get('columns', []), self.module).to_request(),
|
{
|
||||||
u'encoding': item.get('encoding'),
|
u'columns': TableColumnsArray(item.get('columns', []), self.module).to_request(),
|
||||||
u'familyId': item.get('family_id'),
|
u'encoding': item.get('encoding'),
|
||||||
u'onlyReadLatest': item.get('only_read_latest'),
|
u'familyId': item.get('family_id'),
|
||||||
u'type': item.get('type')
|
u'onlyReadLatest': item.get('only_read_latest'),
|
||||||
})
|
u'type': item.get('type'),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
def _response_from_item(self, item):
|
def _response_from_item(self, item):
|
||||||
return remove_nones_from_dict({
|
return remove_nones_from_dict(
|
||||||
u'columns': TableColumnsArray(item.get(u'columns', []), self.module).from_response(),
|
{
|
||||||
u'encoding': item.get(u'encoding'),
|
u'columns': TableColumnsArray(item.get(u'columns', []), self.module).from_response(),
|
||||||
u'familyId': item.get(u'familyId'),
|
u'encoding': item.get(u'encoding'),
|
||||||
u'onlyReadLatest': item.get(u'onlyReadLatest'),
|
u'familyId': item.get(u'familyId'),
|
||||||
u'type': item.get(u'type')
|
u'onlyReadLatest': item.get(u'onlyReadLatest'),
|
||||||
})
|
u'type': item.get(u'type'),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class TableColumnsArray(object):
|
class TableColumnsArray(object):
|
||||||
|
@ -1560,22 +1583,26 @@ class TableColumnsArray(object):
|
||||||
return items
|
return items
|
||||||
|
|
||||||
def _request_for_item(self, item):
|
def _request_for_item(self, item):
|
||||||
return remove_nones_from_dict({
|
return remove_nones_from_dict(
|
||||||
u'encoding': item.get('encoding'),
|
{
|
||||||
u'fieldName': item.get('field_name'),
|
u'encoding': item.get('encoding'),
|
||||||
u'onlyReadLatest': item.get('only_read_latest'),
|
u'fieldName': item.get('field_name'),
|
||||||
u'qualifierString': item.get('qualifier_string'),
|
u'onlyReadLatest': item.get('only_read_latest'),
|
||||||
u'type': item.get('type')
|
u'qualifierString': item.get('qualifier_string'),
|
||||||
})
|
u'type': item.get('type'),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
def _response_from_item(self, item):
|
def _response_from_item(self, item):
|
||||||
return remove_nones_from_dict({
|
return remove_nones_from_dict(
|
||||||
u'encoding': item.get(u'encoding'),
|
{
|
||||||
u'fieldName': item.get(u'fieldName'),
|
u'encoding': item.get(u'encoding'),
|
||||||
u'onlyReadLatest': item.get(u'onlyReadLatest'),
|
u'fieldName': item.get(u'fieldName'),
|
||||||
u'qualifierString': item.get(u'qualifierString'),
|
u'onlyReadLatest': item.get(u'onlyReadLatest'),
|
||||||
u'type': item.get(u'type')
|
u'qualifierString': item.get(u'qualifierString'),
|
||||||
})
|
u'type': item.get(u'type'),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
|
@ -18,15 +18,14 @@
|
||||||
# ----------------------------------------------------------------------------
|
# ----------------------------------------------------------------------------
|
||||||
|
|
||||||
from __future__ import absolute_import, division, print_function
|
from __future__ import absolute_import, division, print_function
|
||||||
|
|
||||||
__metaclass__ = type
|
__metaclass__ = type
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
# Documentation
|
# Documentation
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
ANSIBLE_METADATA = {'metadata_version': '1.1',
|
ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
|
||||||
'status': ["preview"],
|
|
||||||
'supported_by': 'community'}
|
|
||||||
|
|
||||||
DOCUMENTATION = '''
|
DOCUMENTATION = '''
|
||||||
---
|
---
|
||||||
|
@ -513,11 +512,7 @@ import json
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
module = GcpModule(
|
module = GcpModule(argument_spec=dict(dataset=dict(type='str')))
|
||||||
argument_spec=dict(
|
|
||||||
dataset=dict(type='str')
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
if not module.params['scopes']:
|
if not module.params['scopes']:
|
||||||
module.params['scopes'] = ['https://www.googleapis.com/auth/bigquery']
|
module.params['scopes'] = ['https://www.googleapis.com/auth/bigquery']
|
||||||
|
@ -527,9 +522,7 @@ def main():
|
||||||
items = items.get('tables')
|
items = items.get('tables')
|
||||||
else:
|
else:
|
||||||
items = []
|
items = []
|
||||||
return_value = {
|
return_value = {'items': items}
|
||||||
'items': items
|
|
||||||
}
|
|
||||||
module.exit_json(**return_value)
|
module.exit_json(**return_value)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -18,15 +18,14 @@
|
||||||
# ----------------------------------------------------------------------------
|
# ----------------------------------------------------------------------------
|
||||||
|
|
||||||
from __future__ import absolute_import, division, print_function
|
from __future__ import absolute_import, division, print_function
|
||||||
|
|
||||||
__metaclass__ = type
|
__metaclass__ = type
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
# Documentation
|
# Documentation
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
ANSIBLE_METADATA = {'metadata_version': '1.1',
|
ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
|
||||||
'status': ["preview"],
|
|
||||||
'supported_by': 'community'}
|
|
||||||
|
|
||||||
DOCUMENTATION = '''
|
DOCUMENTATION = '''
|
||||||
---
|
---
|
||||||
|
@ -221,7 +220,7 @@ def main():
|
||||||
name=dict(required=True, type='str'),
|
name=dict(required=True, type='str'),
|
||||||
network_tier=dict(type='str', choices=['PREMIUM', 'STANDARD']),
|
network_tier=dict(type='str', choices=['PREMIUM', 'STANDARD']),
|
||||||
subnetwork=dict(),
|
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'description': module.params.get('description'),
|
||||||
u'name': module.params.get('name'),
|
u'name': module.params.get('name'),
|
||||||
u'networkTier': module.params.get('network_tier'),
|
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 = {}
|
return_vals = {}
|
||||||
for k, v in request.items():
|
for k, v in request.items():
|
||||||
|
@ -313,8 +312,8 @@ def return_if_object(module, response, kind, allow_not_found=False):
|
||||||
try:
|
try:
|
||||||
module.raise_for_status(response)
|
module.raise_for_status(response)
|
||||||
result = response.json()
|
result = response.json()
|
||||||
except getattr(json.decoder, 'JSONDecodeError', ValueError) as inst:
|
except getattr(json.decoder, 'JSONDecodeError', ValueError):
|
||||||
module.fail_json(msg="Invalid JSON response with error: %s" % inst)
|
module.fail_json(msg="Invalid JSON response with error: %s" % response.text)
|
||||||
|
|
||||||
if navigate_hash(result, ['error', 'errors']):
|
if navigate_hash(result, ['error', 'errors']):
|
||||||
module.fail_json(msg=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'name': response.get(u'name'),
|
||||||
u'networkTier': response.get(u'networkTier'),
|
u'networkTier': response.get(u'networkTier'),
|
||||||
u'subnetwork': response.get(u'subnetwork'),
|
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_id = navigate_hash(op_result, ['name'])
|
||||||
op_uri = async_op_url(module, {'op_id': op_id})
|
op_uri = async_op_url(module, {'op_id': op_id})
|
||||||
while status != 'DONE':
|
while status != 'DONE':
|
||||||
raise_if_errors(op_result, ['error', 'errors'], 'message')
|
raise_if_errors(op_result, ['error', 'errors'], module)
|
||||||
time.sleep(1.0)
|
time.sleep(1.0)
|
||||||
op_result = fetch_resource(module, op_uri, 'compute#operation')
|
op_result = fetch_resource(module, op_uri, 'compute#operation')
|
||||||
status = navigate_hash(op_result, ['status'])
|
status = navigate_hash(op_result, ['status'])
|
||||||
|
|
|
@ -18,15 +18,14 @@
|
||||||
# ----------------------------------------------------------------------------
|
# ----------------------------------------------------------------------------
|
||||||
|
|
||||||
from __future__ import absolute_import, division, print_function
|
from __future__ import absolute_import, division, print_function
|
||||||
|
|
||||||
__metaclass__ = type
|
__metaclass__ = type
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
# Documentation
|
# Documentation
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
ANSIBLE_METADATA = {'metadata_version': '1.1',
|
ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
|
||||||
'status': ["preview"],
|
|
||||||
'supported_by': 'community'}
|
|
||||||
|
|
||||||
DOCUMENTATION = '''
|
DOCUMENTATION = '''
|
||||||
---
|
---
|
||||||
|
@ -148,12 +147,7 @@ import json
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
module = GcpModule(
|
module = GcpModule(argument_spec=dict(filters=dict(type='list', elements='str'), region=dict(required=True, type='str')))
|
||||||
argument_spec=dict(
|
|
||||||
filters=dict(type='list', elements='str'),
|
|
||||||
region=dict(required=True, type='str')
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
if not module.params['scopes']:
|
if not module.params['scopes']:
|
||||||
module.params['scopes'] = ['https://www.googleapis.com/auth/compute']
|
module.params['scopes'] = ['https://www.googleapis.com/auth/compute']
|
||||||
|
@ -163,9 +157,7 @@ def main():
|
||||||
items = items.get('items')
|
items = items.get('items')
|
||||||
else:
|
else:
|
||||||
items = []
|
items = []
|
||||||
return_value = {
|
return_value = {'items': items}
|
||||||
'items': items
|
|
||||||
}
|
|
||||||
module.exit_json(**return_value)
|
module.exit_json(**return_value)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -18,15 +18,14 @@
|
||||||
# ----------------------------------------------------------------------------
|
# ----------------------------------------------------------------------------
|
||||||
|
|
||||||
from __future__ import absolute_import, division, print_function
|
from __future__ import absolute_import, division, print_function
|
||||||
|
|
||||||
__metaclass__ = type
|
__metaclass__ = type
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
# Documentation
|
# Documentation
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
ANSIBLE_METADATA = {'metadata_version': '1.1',
|
ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
|
||||||
'status': ["preview"],
|
|
||||||
'supported_by': 'community'}
|
|
||||||
|
|
||||||
DOCUMENTATION = '''
|
DOCUMENTATION = '''
|
||||||
---
|
---
|
||||||
|
@ -164,7 +163,7 @@ def main():
|
||||||
bucket_name=dict(required=True, type='str'),
|
bucket_name=dict(required=True, type='str'),
|
||||||
description=dict(type='str'),
|
description=dict(type='str'),
|
||||||
enable_cdn=dict(type='bool'),
|
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'bucketName': module.params.get('bucket_name'),
|
||||||
u'description': module.params.get('description'),
|
u'description': module.params.get('description'),
|
||||||
u'enableCdn': module.params.get('enable_cdn'),
|
u'enableCdn': module.params.get('enable_cdn'),
|
||||||
u'name': module.params.get('name')
|
u'name': module.params.get('name'),
|
||||||
}
|
}
|
||||||
return_vals = {}
|
return_vals = {}
|
||||||
for k, v in request.items():
|
for k, v in request.items():
|
||||||
|
@ -255,8 +254,8 @@ def return_if_object(module, response, kind, allow_not_found=False):
|
||||||
try:
|
try:
|
||||||
module.raise_for_status(response)
|
module.raise_for_status(response)
|
||||||
result = response.json()
|
result = response.json()
|
||||||
except getattr(json.decoder, 'JSONDecodeError', ValueError) as inst:
|
except getattr(json.decoder, 'JSONDecodeError', ValueError):
|
||||||
module.fail_json(msg="Invalid JSON response with error: %s" % inst)
|
module.fail_json(msg="Invalid JSON response with error: %s" % response.text)
|
||||||
|
|
||||||
if navigate_hash(result, ['error', 'errors']):
|
if navigate_hash(result, ['error', 'errors']):
|
||||||
module.fail_json(msg=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'description': response.get(u'description'),
|
||||||
u'enableCdn': response.get(u'enableCdn'),
|
u'enableCdn': response.get(u'enableCdn'),
|
||||||
u'id': response.get(u'id'),
|
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_id = navigate_hash(op_result, ['name'])
|
||||||
op_uri = async_op_url(module, {'op_id': op_id})
|
op_uri = async_op_url(module, {'op_id': op_id})
|
||||||
while status != 'DONE':
|
while status != 'DONE':
|
||||||
raise_if_errors(op_result, ['error', 'errors'], 'message')
|
raise_if_errors(op_result, ['error', 'errors'], module)
|
||||||
time.sleep(1.0)
|
time.sleep(1.0)
|
||||||
op_result = fetch_resource(module, op_uri, 'compute#operation')
|
op_result = fetch_resource(module, op_uri, 'compute#operation')
|
||||||
status = navigate_hash(op_result, ['status'])
|
status = navigate_hash(op_result, ['status'])
|
||||||
|
|
|
@ -18,15 +18,14 @@
|
||||||
# ----------------------------------------------------------------------------
|
# ----------------------------------------------------------------------------
|
||||||
|
|
||||||
from __future__ import absolute_import, division, print_function
|
from __future__ import absolute_import, division, print_function
|
||||||
|
|
||||||
__metaclass__ = type
|
__metaclass__ = type
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
# Documentation
|
# Documentation
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
ANSIBLE_METADATA = {'metadata_version': '1.1',
|
ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
|
||||||
'status': ["preview"],
|
|
||||||
'supported_by': 'community'}
|
|
||||||
|
|
||||||
DOCUMENTATION = '''
|
DOCUMENTATION = '''
|
||||||
---
|
---
|
||||||
|
@ -115,11 +114,7 @@ import json
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
module = GcpModule(
|
module = GcpModule(argument_spec=dict(filters=dict(type='list', elements='str')))
|
||||||
argument_spec=dict(
|
|
||||||
filters=dict(type='list', elements='str')
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
if not module.params['scopes']:
|
if not module.params['scopes']:
|
||||||
module.params['scopes'] = ['https://www.googleapis.com/auth/compute']
|
module.params['scopes'] = ['https://www.googleapis.com/auth/compute']
|
||||||
|
@ -129,9 +124,7 @@ def main():
|
||||||
items = items.get('items')
|
items = items.get('items')
|
||||||
else:
|
else:
|
||||||
items = []
|
items = []
|
||||||
return_value = {
|
return_value = {'items': items}
|
||||||
'items': items
|
|
||||||
}
|
|
||||||
module.exit_json(**return_value)
|
module.exit_json(**return_value)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -18,15 +18,14 @@
|
||||||
# ----------------------------------------------------------------------------
|
# ----------------------------------------------------------------------------
|
||||||
|
|
||||||
from __future__ import absolute_import, division, print_function
|
from __future__ import absolute_import, division, print_function
|
||||||
|
|
||||||
__metaclass__ = type
|
__metaclass__ = type
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
# Documentation
|
# Documentation
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
ANSIBLE_METADATA = {'metadata_version': '1.1',
|
ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
|
||||||
'status': ["preview"],
|
|
||||||
'supported_by': 'community'}
|
|
||||||
|
|
||||||
DOCUMENTATION = '''
|
DOCUMENTATION = '''
|
||||||
---
|
---
|
||||||
|
@ -622,45 +621,56 @@ def main():
|
||||||
argument_spec=dict(
|
argument_spec=dict(
|
||||||
state=dict(default='present', choices=['present', 'absent'], type='str'),
|
state=dict(default='present', choices=['present', 'absent'], type='str'),
|
||||||
affinity_cookie_ttl_sec=dict(type='int'),
|
affinity_cookie_ttl_sec=dict(type='int'),
|
||||||
backends=dict(type='list', elements='dict', options=dict(
|
backends=dict(
|
||||||
balancing_mode=dict(type='str', choices=['UTILIZATION', 'RATE', 'CONNECTION']),
|
type='list',
|
||||||
capacity_scaler=dict(type='str'),
|
elements='dict',
|
||||||
description=dict(type='str'),
|
options=dict(
|
||||||
group=dict(),
|
balancing_mode=dict(type='str', choices=['UTILIZATION', 'RATE', 'CONNECTION']),
|
||||||
max_connections=dict(type='int'),
|
capacity_scaler=dict(type='str'),
|
||||||
max_connections_per_instance=dict(type='int'),
|
description=dict(type='str'),
|
||||||
max_rate=dict(type='int'),
|
group=dict(),
|
||||||
max_rate_per_instance=dict(type='str'),
|
max_connections=dict(type='int'),
|
||||||
max_utilization=dict(type='str')
|
max_connections_per_instance=dict(type='int'),
|
||||||
)),
|
max_rate=dict(type='int'),
|
||||||
cdn_policy=dict(type='dict', options=dict(
|
max_rate_per_instance=dict(type='str'),
|
||||||
cache_key_policy=dict(type='dict', options=dict(
|
max_utilization=dict(type='str'),
|
||||||
include_host=dict(type='bool'),
|
),
|
||||||
include_protocol=dict(type='bool'),
|
),
|
||||||
include_query_string=dict(type='bool'),
|
cdn_policy=dict(
|
||||||
query_string_blacklist=dict(type='list', elements='str'),
|
type='dict',
|
||||||
query_string_whitelist=dict(type='list', elements='str')
|
options=dict(
|
||||||
))
|
cache_key_policy=dict(
|
||||||
)),
|
type='dict',
|
||||||
connection_draining=dict(type='dict', options=dict(
|
options=dict(
|
||||||
draining_timeout_sec=dict(type='int')
|
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'),
|
description=dict(type='str'),
|
||||||
enable_cdn=dict(type='bool'),
|
enable_cdn=dict(type='bool'),
|
||||||
health_checks=dict(type='list', elements='str'),
|
health_checks=dict(type='list', elements='str'),
|
||||||
iap=dict(type='dict', options=dict(
|
iap=dict(
|
||||||
enabled=dict(type='bool'),
|
type='dict',
|
||||||
oauth2_client_id=dict(type='str'),
|
options=dict(
|
||||||
oauth2_client_secret=dict(type='str'),
|
enabled=dict(type='bool'),
|
||||||
oauth2_client_secret_sha256=dict(type='str')
|
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']),
|
load_balancing_scheme=dict(type='str', choices=['INTERNAL', 'EXTERNAL']),
|
||||||
name=dict(type='str'),
|
name=dict(type='str'),
|
||||||
port_name=dict(type='str'),
|
port_name=dict(type='str'),
|
||||||
protocol=dict(type='str', choices=['HTTP', 'HTTPS', 'TCP', 'SSL']),
|
protocol=dict(type='str', choices=['HTTP', 'HTTPS', 'TCP', 'SSL']),
|
||||||
region=dict(type='str'),
|
region=dict(type='str'),
|
||||||
session_affinity=dict(type='str', choices=['NONE', 'CLIENT_IP', 'GENERATED_COOKIE', 'CLIENT_IP_PROTO', 'CLIENT_IP_PORT_PROTO']),
|
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'protocol': module.params.get('protocol'),
|
||||||
u'region': region_selflink(module.params.get('region'), module.params),
|
u'region': region_selflink(module.params.get('region'), module.params),
|
||||||
u'sessionAffinity': module.params.get('session_affinity'),
|
u'sessionAffinity': module.params.get('session_affinity'),
|
||||||
u'timeoutSec': module.params.get('timeout_sec')
|
u'timeoutSec': module.params.get('timeout_sec'),
|
||||||
}
|
}
|
||||||
return_vals = {}
|
return_vals = {}
|
||||||
for k, v in request.items():
|
for k, v in request.items():
|
||||||
|
@ -762,8 +772,8 @@ def return_if_object(module, response, kind, allow_not_found=False):
|
||||||
try:
|
try:
|
||||||
module.raise_for_status(response)
|
module.raise_for_status(response)
|
||||||
result = response.json()
|
result = response.json()
|
||||||
except getattr(json.decoder, 'JSONDecodeError', ValueError) as inst:
|
except getattr(json.decoder, 'JSONDecodeError', ValueError):
|
||||||
module.fail_json(msg="Invalid JSON response with error: %s" % inst)
|
module.fail_json(msg="Invalid JSON response with error: %s" % response.text)
|
||||||
|
|
||||||
if navigate_hash(result, ['error', 'errors']):
|
if navigate_hash(result, ['error', 'errors']):
|
||||||
module.fail_json(msg=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'protocol': response.get(u'protocol'),
|
||||||
u'region': response.get(u'region'),
|
u'region': response.get(u'region'),
|
||||||
u'sessionAffinity': response.get(u'sessionAffinity'),
|
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_id = navigate_hash(op_result, ['name'])
|
||||||
op_uri = async_op_url(module, {'op_id': op_id})
|
op_uri = async_op_url(module, {'op_id': op_id})
|
||||||
while status != 'DONE':
|
while status != 'DONE':
|
||||||
raise_if_errors(op_result, ['error', 'errors'], 'message')
|
raise_if_errors(op_result, ['error', 'errors'], module)
|
||||||
time.sleep(1.0)
|
time.sleep(1.0)
|
||||||
op_result = fetch_resource(module, op_uri, 'compute#operation')
|
op_result = fetch_resource(module, op_uri, 'compute#operation')
|
||||||
status = navigate_hash(op_result, ['status'])
|
status = navigate_hash(op_result, ['status'])
|
||||||
|
@ -878,30 +888,34 @@ class BackendServiceBackendsArray(object):
|
||||||
return items
|
return items
|
||||||
|
|
||||||
def _request_for_item(self, item):
|
def _request_for_item(self, item):
|
||||||
return remove_nones_from_dict({
|
return remove_nones_from_dict(
|
||||||
u'balancingMode': item.get('balancing_mode'),
|
{
|
||||||
u'capacityScaler': item.get('capacity_scaler'),
|
u'balancingMode': item.get('balancing_mode'),
|
||||||
u'description': item.get('description'),
|
u'capacityScaler': item.get('capacity_scaler'),
|
||||||
u'group': replace_resource_dict(item.get(u'group', {}), 'selfLink'),
|
u'description': item.get('description'),
|
||||||
u'maxConnections': item.get('max_connections'),
|
u'group': replace_resource_dict(item.get(u'group', {}), 'selfLink'),
|
||||||
u'maxConnectionsPerInstance': item.get('max_connections_per_instance'),
|
u'maxConnections': item.get('max_connections'),
|
||||||
u'maxRate': item.get('max_rate'),
|
u'maxConnectionsPerInstance': item.get('max_connections_per_instance'),
|
||||||
u'maxRatePerInstance': item.get('max_rate_per_instance'),
|
u'maxRate': item.get('max_rate'),
|
||||||
u'maxUtilization': item.get('max_utilization')
|
u'maxRatePerInstance': item.get('max_rate_per_instance'),
|
||||||
})
|
u'maxUtilization': item.get('max_utilization'),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
def _response_from_item(self, item):
|
def _response_from_item(self, item):
|
||||||
return remove_nones_from_dict({
|
return remove_nones_from_dict(
|
||||||
u'balancingMode': item.get(u'balancingMode'),
|
{
|
||||||
u'capacityScaler': item.get(u'capacityScaler'),
|
u'balancingMode': item.get(u'balancingMode'),
|
||||||
u'description': item.get(u'description'),
|
u'capacityScaler': item.get(u'capacityScaler'),
|
||||||
u'group': item.get(u'group'),
|
u'description': item.get(u'description'),
|
||||||
u'maxConnections': item.get(u'maxConnections'),
|
u'group': item.get(u'group'),
|
||||||
u'maxConnectionsPerInstance': item.get(u'maxConnectionsPerInstance'),
|
u'maxConnections': item.get(u'maxConnections'),
|
||||||
u'maxRate': item.get(u'maxRate'),
|
u'maxConnectionsPerInstance': item.get(u'maxConnectionsPerInstance'),
|
||||||
u'maxRatePerInstance': item.get(u'maxRatePerInstance'),
|
u'maxRate': item.get(u'maxRate'),
|
||||||
u'maxUtilization': item.get(u'maxUtilization')
|
u'maxRatePerInstance': item.get(u'maxRatePerInstance'),
|
||||||
})
|
u'maxUtilization': item.get(u'maxUtilization'),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class BackendServiceCdnpolicy(object):
|
class BackendServiceCdnpolicy(object):
|
||||||
|
@ -913,14 +927,10 @@ class BackendServiceCdnpolicy(object):
|
||||||
self.request = {}
|
self.request = {}
|
||||||
|
|
||||||
def to_request(self):
|
def to_request(self):
|
||||||
return remove_nones_from_dict({
|
return remove_nones_from_dict({u'cacheKeyPolicy': BackendServiceCachekeypolicy(self.request.get('cache_key_policy', {}), self.module).to_request()})
|
||||||
u'cacheKeyPolicy': BackendServiceCachekeypolicy(self.request.get('cache_key_policy', {}), self.module).to_request()
|
|
||||||
})
|
|
||||||
|
|
||||||
def from_response(self):
|
def from_response(self):
|
||||||
return remove_nones_from_dict({
|
return remove_nones_from_dict({u'cacheKeyPolicy': BackendServiceCachekeypolicy(self.request.get(u'cacheKeyPolicy', {}), self.module).from_response()})
|
||||||
u'cacheKeyPolicy': BackendServiceCachekeypolicy(self.request.get(u'cacheKeyPolicy', {}), self.module).from_response()
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
class BackendServiceCachekeypolicy(object):
|
class BackendServiceCachekeypolicy(object):
|
||||||
|
@ -932,22 +942,26 @@ class BackendServiceCachekeypolicy(object):
|
||||||
self.request = {}
|
self.request = {}
|
||||||
|
|
||||||
def to_request(self):
|
def to_request(self):
|
||||||
return remove_nones_from_dict({
|
return remove_nones_from_dict(
|
||||||
u'includeHost': self.request.get('include_host'),
|
{
|
||||||
u'includeProtocol': self.request.get('include_protocol'),
|
u'includeHost': self.request.get('include_host'),
|
||||||
u'includeQueryString': self.request.get('include_query_string'),
|
u'includeProtocol': self.request.get('include_protocol'),
|
||||||
u'queryStringBlacklist': self.request.get('query_string_blacklist'),
|
u'includeQueryString': self.request.get('include_query_string'),
|
||||||
u'queryStringWhitelist': self.request.get('query_string_whitelist')
|
u'queryStringBlacklist': self.request.get('query_string_blacklist'),
|
||||||
})
|
u'queryStringWhitelist': self.request.get('query_string_whitelist'),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
def from_response(self):
|
def from_response(self):
|
||||||
return remove_nones_from_dict({
|
return remove_nones_from_dict(
|
||||||
u'includeHost': self.request.get(u'includeHost'),
|
{
|
||||||
u'includeProtocol': self.request.get(u'includeProtocol'),
|
u'includeHost': self.request.get(u'includeHost'),
|
||||||
u'includeQueryString': self.request.get(u'includeQueryString'),
|
u'includeProtocol': self.request.get(u'includeProtocol'),
|
||||||
u'queryStringBlacklist': self.request.get(u'queryStringBlacklist'),
|
u'includeQueryString': self.request.get(u'includeQueryString'),
|
||||||
u'queryStringWhitelist': self.request.get(u'queryStringWhitelist')
|
u'queryStringBlacklist': self.request.get(u'queryStringBlacklist'),
|
||||||
})
|
u'queryStringWhitelist': self.request.get(u'queryStringWhitelist'),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class BackendServiceConnectiondraining(object):
|
class BackendServiceConnectiondraining(object):
|
||||||
|
@ -959,14 +973,10 @@ class BackendServiceConnectiondraining(object):
|
||||||
self.request = {}
|
self.request = {}
|
||||||
|
|
||||||
def to_request(self):
|
def to_request(self):
|
||||||
return remove_nones_from_dict({
|
return remove_nones_from_dict({u'drainingTimeoutSec': self.request.get('draining_timeout_sec')})
|
||||||
u'drainingTimeoutSec': self.request.get('draining_timeout_sec')
|
|
||||||
})
|
|
||||||
|
|
||||||
def from_response(self):
|
def from_response(self):
|
||||||
return remove_nones_from_dict({
|
return remove_nones_from_dict({u'drainingTimeoutSec': self.request.get(u'drainingTimeoutSec')})
|
||||||
u'drainingTimeoutSec': self.request.get(u'drainingTimeoutSec')
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
class BackendServiceIap(object):
|
class BackendServiceIap(object):
|
||||||
|
@ -978,20 +988,24 @@ class BackendServiceIap(object):
|
||||||
self.request = {}
|
self.request = {}
|
||||||
|
|
||||||
def to_request(self):
|
def to_request(self):
|
||||||
return remove_nones_from_dict({
|
return remove_nones_from_dict(
|
||||||
u'enabled': self.request.get('enabled'),
|
{
|
||||||
u'oauth2ClientId': self.request.get('oauth2_client_id'),
|
u'enabled': self.request.get('enabled'),
|
||||||
u'oauth2ClientSecret': self.request.get('oauth2_client_secret'),
|
u'oauth2ClientId': self.request.get('oauth2_client_id'),
|
||||||
u'oauth2ClientSecretSha256': self.request.get('oauth2_client_secret_sha256')
|
u'oauth2ClientSecret': self.request.get('oauth2_client_secret'),
|
||||||
})
|
u'oauth2ClientSecretSha256': self.request.get('oauth2_client_secret_sha256'),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
def from_response(self):
|
def from_response(self):
|
||||||
return remove_nones_from_dict({
|
return remove_nones_from_dict(
|
||||||
u'enabled': self.request.get(u'enabled'),
|
{
|
||||||
u'oauth2ClientId': self.request.get(u'oauth2ClientId'),
|
u'enabled': self.request.get(u'enabled'),
|
||||||
u'oauth2ClientSecret': self.request.get(u'oauth2ClientSecret'),
|
u'oauth2ClientId': self.request.get(u'oauth2ClientId'),
|
||||||
u'oauth2ClientSecretSha256': self.request.get(u'oauth2ClientSecretSha256')
|
u'oauth2ClientSecret': self.request.get(u'oauth2ClientSecret'),
|
||||||
})
|
u'oauth2ClientSecretSha256': self.request.get(u'oauth2ClientSecretSha256'),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
|
@ -18,15 +18,14 @@
|
||||||
# ----------------------------------------------------------------------------
|
# ----------------------------------------------------------------------------
|
||||||
|
|
||||||
from __future__ import absolute_import, division, print_function
|
from __future__ import absolute_import, division, print_function
|
||||||
|
|
||||||
__metaclass__ = type
|
__metaclass__ = type
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
# Documentation
|
# Documentation
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
ANSIBLE_METADATA = {'metadata_version': '1.1',
|
ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
|
||||||
'status': ["preview"],
|
|
||||||
'supported_by': 'community'}
|
|
||||||
|
|
||||||
DOCUMENTATION = '''
|
DOCUMENTATION = '''
|
||||||
---
|
---
|
||||||
|
@ -341,11 +340,7 @@ import json
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
module = GcpModule(
|
module = GcpModule(argument_spec=dict(filters=dict(type='list', elements='str')))
|
||||||
argument_spec=dict(
|
|
||||||
filters=dict(type='list', elements='str')
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
if not module.params['scopes']:
|
if not module.params['scopes']:
|
||||||
module.params['scopes'] = ['https://www.googleapis.com/auth/compute']
|
module.params['scopes'] = ['https://www.googleapis.com/auth/compute']
|
||||||
|
@ -355,9 +350,7 @@ def main():
|
||||||
items = items.get('items')
|
items = items.get('items')
|
||||||
else:
|
else:
|
||||||
items = []
|
items = []
|
||||||
return_value = {
|
return_value = {'items': items}
|
||||||
'items': items
|
|
||||||
}
|
|
||||||
module.exit_json(**return_value)
|
module.exit_json(**return_value)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -18,15 +18,14 @@
|
||||||
# ----------------------------------------------------------------------------
|
# ----------------------------------------------------------------------------
|
||||||
|
|
||||||
from __future__ import absolute_import, division, print_function
|
from __future__ import absolute_import, division, print_function
|
||||||
|
|
||||||
__metaclass__ = type
|
__metaclass__ = type
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
# Documentation
|
# Documentation
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
ANSIBLE_METADATA = {'metadata_version': '1.1',
|
ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
|
||||||
'status': ["preview"],
|
|
||||||
'supported_by': 'community'}
|
|
||||||
|
|
||||||
DOCUMENTATION = '''
|
DOCUMENTATION = '''
|
||||||
---
|
---
|
||||||
|
@ -130,6 +129,10 @@ options:
|
||||||
- The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption
|
- The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption
|
||||||
key that protects this resource.
|
key that protects this resource.
|
||||||
required: false
|
required: false
|
||||||
|
kms_key_name:
|
||||||
|
description:
|
||||||
|
- The name of the encryption key that is stored in Google Cloud KMS.
|
||||||
|
required: false
|
||||||
disk_encryption_key:
|
disk_encryption_key:
|
||||||
description:
|
description:
|
||||||
- Encrypts the disk using a customer-supplied encryption key.
|
- 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
|
- The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption
|
||||||
key that protects this resource.
|
key that protects this resource.
|
||||||
required: false
|
required: false
|
||||||
|
kms_key_name:
|
||||||
|
description:
|
||||||
|
- The name of the encryption key that is stored in Google Cloud KMS.
|
||||||
|
required: false
|
||||||
source_snapshot:
|
source_snapshot:
|
||||||
description:
|
description:
|
||||||
- The source snapshot used to create this disk. You can provide this as a partial
|
- 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
|
- Specifies a 256-bit customer-supplied encryption key, encoded in RFC 4648
|
||||||
base64 to either encrypt or decrypt this resource.
|
base64 to either encrypt or decrypt this resource.
|
||||||
required: false
|
required: false
|
||||||
|
kms_key_name:
|
||||||
|
description:
|
||||||
|
- The name of the encryption key that is stored in Google Cloud KMS.
|
||||||
|
required: false
|
||||||
sha256:
|
sha256:
|
||||||
description:
|
description:
|
||||||
- The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption
|
- The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption
|
||||||
|
@ -311,6 +322,11 @@ sourceImageEncryptionKey:
|
||||||
key that protects this resource.
|
key that protects this resource.
|
||||||
returned: success
|
returned: success
|
||||||
type: str
|
type: str
|
||||||
|
kmsKeyName:
|
||||||
|
description:
|
||||||
|
- The name of the encryption key that is stored in Google Cloud KMS.
|
||||||
|
returned: success
|
||||||
|
type: str
|
||||||
sourceImageId:
|
sourceImageId:
|
||||||
description:
|
description:
|
||||||
- The ID value of the image used to create this disk. This value identifies the
|
- 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.
|
key that protects this resource.
|
||||||
returned: success
|
returned: success
|
||||||
type: str
|
type: str
|
||||||
|
kmsKeyName:
|
||||||
|
description:
|
||||||
|
- The name of the encryption key that is stored in Google Cloud KMS.
|
||||||
|
returned: success
|
||||||
|
type: str
|
||||||
sourceSnapshot:
|
sourceSnapshot:
|
||||||
description:
|
description:
|
||||||
- The source snapshot used to create this disk. You can provide this as a partial
|
- 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.
|
base64 to either encrypt or decrypt this resource.
|
||||||
returned: success
|
returned: success
|
||||||
type: str
|
type: str
|
||||||
|
kmsKeyName:
|
||||||
|
description:
|
||||||
|
- The name of the encryption key that is stored in Google Cloud KMS.
|
||||||
|
returned: success
|
||||||
|
type: str
|
||||||
sha256:
|
sha256:
|
||||||
description:
|
description:
|
||||||
- The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption
|
- The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption
|
||||||
|
@ -409,19 +435,10 @@ def main():
|
||||||
type=dict(type='str'),
|
type=dict(type='str'),
|
||||||
source_image=dict(type='str'),
|
source_image=dict(type='str'),
|
||||||
zone=dict(required=True, type='str'),
|
zone=dict(required=True, type='str'),
|
||||||
source_image_encryption_key=dict(type='dict', options=dict(
|
source_image_encryption_key=dict(type='dict', options=dict(raw_key=dict(type='str'), sha256=dict(type='str'), kms_key_name=dict(type='str'))),
|
||||||
raw_key=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'))),
|
||||||
sha256=dict(type='str')
|
|
||||||
)),
|
|
||||||
disk_encryption_key=dict(type='dict', options=dict(
|
|
||||||
raw_key=dict(type='str'),
|
|
||||||
sha256=dict(type='str')
|
|
||||||
)),
|
|
||||||
source_snapshot=dict(),
|
source_snapshot=dict(),
|
||||||
source_snapshot_encryption_key=dict(type='dict', options=dict(
|
source_snapshot_encryption_key=dict(type='dict', options=dict(raw_key=dict(type='str'), kms_key_name=dict(type='str'), sha256=dict(type='str'))),
|
||||||
raw_key=dict(type='str'),
|
|
||||||
sha256=dict(type='str')
|
|
||||||
))
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -462,8 +479,7 @@ def create(module, link, kind):
|
||||||
|
|
||||||
|
|
||||||
def update(module, link, kind, fetch):
|
def update(module, link, kind, fetch):
|
||||||
update_fields(module, resource_to_request(module),
|
update_fields(module, resource_to_request(module), response_to_hash(module, fetch))
|
||||||
response_to_hash(module, fetch))
|
|
||||||
return fetch_resource(module, self_link(module), kind)
|
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):
|
def label_fingerprint_update(module, request, response):
|
||||||
auth = GcpSession(module, 'compute')
|
auth = GcpSession(module, 'compute')
|
||||||
auth.post(
|
auth.post(
|
||||||
''.join([
|
''.join(["https://www.googleapis.com/compute/v1/", "projects/{project}/zones/{zone}/disks/{name}/setLabels"]).format(**module.params),
|
||||||
"https://www.googleapis.com/compute/v1/",
|
{u'labelFingerprint': response.get('labelFingerprint'), u'labels': module.params.get('labels')},
|
||||||
"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):
|
def size_gb_update(module, request, response):
|
||||||
auth = GcpSession(module, 'compute')
|
auth = GcpSession(module, 'compute')
|
||||||
auth.post(
|
auth.post(
|
||||||
''.join([
|
''.join(["https://www.googleapis.com/compute/v1/", "projects/{project}/zones/{zone}/disks/{name}/resize"]).format(**module.params),
|
||||||
"https://www.googleapis.com/compute/v1/",
|
{u'sizeGb': module.params.get('size_gb')},
|
||||||
"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'name': module.params.get('name'),
|
||||||
u'sizeGb': module.params.get('size_gb'),
|
u'sizeGb': module.params.get('size_gb'),
|
||||||
u'type': disk_type_selflink(module.params.get('type'), module.params),
|
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 = {}
|
return_vals = {}
|
||||||
for k, v in request.items():
|
for k, v in request.items():
|
||||||
|
@ -553,8 +558,8 @@ def return_if_object(module, response, kind, allow_not_found=False):
|
||||||
try:
|
try:
|
||||||
module.raise_for_status(response)
|
module.raise_for_status(response)
|
||||||
result = response.json()
|
result = response.json()
|
||||||
except getattr(json.decoder, 'JSONDecodeError', ValueError) as inst:
|
except getattr(json.decoder, 'JSONDecodeError', ValueError):
|
||||||
module.fail_json(msg="Invalid JSON response with error: %s" % inst)
|
module.fail_json(msg="Invalid JSON response with error: %s" % response.text)
|
||||||
|
|
||||||
if navigate_hash(result, ['error', 'errors']):
|
if navigate_hash(result, ['error', 'errors']):
|
||||||
module.fail_json(msg=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'sizeGb': response.get(u'sizeGb'),
|
||||||
u'users': response.get(u'users'),
|
u'users': response.get(u'users'),
|
||||||
u'type': response.get(u'type'),
|
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_id = navigate_hash(op_result, ['name'])
|
||||||
op_uri = async_op_url(module, {'op_id': op_id})
|
op_uri = async_op_url(module, {'op_id': op_id})
|
||||||
while status != 'DONE':
|
while status != 'DONE':
|
||||||
raise_if_errors(op_result, ['error', 'errors'], 'message')
|
raise_if_errors(op_result, ['error', 'errors'], module)
|
||||||
time.sleep(1.0)
|
time.sleep(1.0)
|
||||||
op_result = fetch_resource(module, op_uri, 'compute#operation')
|
op_result = fetch_resource(module, op_uri, 'compute#operation')
|
||||||
status = navigate_hash(op_result, ['status'])
|
status = navigate_hash(op_result, ['status'])
|
||||||
|
@ -653,16 +658,14 @@ class DiskSourceimageencryptionkey(object):
|
||||||
self.request = {}
|
self.request = {}
|
||||||
|
|
||||||
def to_request(self):
|
def to_request(self):
|
||||||
return remove_nones_from_dict({
|
return remove_nones_from_dict(
|
||||||
u'rawKey': self.request.get('raw_key'),
|
{u'rawKey': self.request.get('raw_key'), u'sha256': self.request.get('sha256'), u'kmsKeyName': self.request.get('kms_key_name')}
|
||||||
u'sha256': self.request.get('sha256')
|
)
|
||||||
})
|
|
||||||
|
|
||||||
def from_response(self):
|
def from_response(self):
|
||||||
return remove_nones_from_dict({
|
return remove_nones_from_dict(
|
||||||
u'rawKey': self.request.get(u'rawKey'),
|
{u'rawKey': self.request.get(u'rawKey'), u'sha256': self.request.get(u'sha256'), u'kmsKeyName': self.request.get(u'kmsKeyName')}
|
||||||
u'sha256': self.request.get(u'sha256')
|
)
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
class DiskDiskencryptionkey(object):
|
class DiskDiskencryptionkey(object):
|
||||||
|
@ -674,16 +677,14 @@ class DiskDiskencryptionkey(object):
|
||||||
self.request = {}
|
self.request = {}
|
||||||
|
|
||||||
def to_request(self):
|
def to_request(self):
|
||||||
return remove_nones_from_dict({
|
return remove_nones_from_dict(
|
||||||
u'rawKey': self.request.get('raw_key'),
|
{u'rawKey': self.request.get('raw_key'), u'sha256': self.request.get('sha256'), u'kmsKeyName': self.request.get('kms_key_name')}
|
||||||
u'sha256': self.request.get('sha256')
|
)
|
||||||
})
|
|
||||||
|
|
||||||
def from_response(self):
|
def from_response(self):
|
||||||
return remove_nones_from_dict({
|
return remove_nones_from_dict(
|
||||||
u'rawKey': self.request.get(u'rawKey'),
|
{u'rawKey': self.request.get(u'rawKey'), u'sha256': self.request.get(u'sha256'), u'kmsKeyName': self.request.get(u'kmsKeyName')}
|
||||||
u'sha256': self.request.get(u'sha256')
|
)
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
class DiskSourcesnapshotencryptionkey(object):
|
class DiskSourcesnapshotencryptionkey(object):
|
||||||
|
@ -695,16 +696,14 @@ class DiskSourcesnapshotencryptionkey(object):
|
||||||
self.request = {}
|
self.request = {}
|
||||||
|
|
||||||
def to_request(self):
|
def to_request(self):
|
||||||
return remove_nones_from_dict({
|
return remove_nones_from_dict(
|
||||||
u'rawKey': self.request.get('raw_key'),
|
{u'rawKey': self.request.get('raw_key'), u'kmsKeyName': self.request.get('kms_key_name'), u'sha256': self.request.get('sha256')}
|
||||||
u'sha256': self.request.get('sha256')
|
)
|
||||||
})
|
|
||||||
|
|
||||||
def from_response(self):
|
def from_response(self):
|
||||||
return remove_nones_from_dict({
|
return remove_nones_from_dict(
|
||||||
u'rawKey': self.request.get(u'rawKey'),
|
{u'rawKey': self.request.get(u'rawKey'), u'kmsKeyName': self.request.get(u'kmsKeyName'), u'sha256': self.request.get(u'sha256')}
|
||||||
u'sha256': self.request.get(u'sha256')
|
)
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
|
@ -18,15 +18,14 @@
|
||||||
# ----------------------------------------------------------------------------
|
# ----------------------------------------------------------------------------
|
||||||
|
|
||||||
from __future__ import absolute_import, division, print_function
|
from __future__ import absolute_import, division, print_function
|
||||||
|
|
||||||
__metaclass__ = type
|
__metaclass__ = type
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
# Documentation
|
# Documentation
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
ANSIBLE_METADATA = {'metadata_version': '1.1',
|
ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
|
||||||
'status': ["preview"],
|
|
||||||
'supported_by': 'community'}
|
|
||||||
|
|
||||||
DOCUMENTATION = '''
|
DOCUMENTATION = '''
|
||||||
---
|
---
|
||||||
|
@ -184,6 +183,11 @@ items:
|
||||||
key that protects this resource.
|
key that protects this resource.
|
||||||
returned: success
|
returned: success
|
||||||
type: str
|
type: str
|
||||||
|
kmsKeyName:
|
||||||
|
description:
|
||||||
|
- The name of the encryption key that is stored in Google Cloud KMS.
|
||||||
|
returned: success
|
||||||
|
type: str
|
||||||
sourceImageId:
|
sourceImageId:
|
||||||
description:
|
description:
|
||||||
- The ID value of the image used to create this disk. This value identifies
|
- The ID value of the image used to create this disk. This value identifies
|
||||||
|
@ -219,6 +223,11 @@ items:
|
||||||
key that protects this resource.
|
key that protects this resource.
|
||||||
returned: success
|
returned: success
|
||||||
type: str
|
type: str
|
||||||
|
kmsKeyName:
|
||||||
|
description:
|
||||||
|
- The name of the encryption key that is stored in Google Cloud KMS.
|
||||||
|
returned: success
|
||||||
|
type: str
|
||||||
sourceSnapshot:
|
sourceSnapshot:
|
||||||
description:
|
description:
|
||||||
- The source snapshot used to create this disk. You can provide this as a partial
|
- 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.
|
base64 to either encrypt or decrypt this resource.
|
||||||
returned: success
|
returned: success
|
||||||
type: str
|
type: str
|
||||||
|
kmsKeyName:
|
||||||
|
description:
|
||||||
|
- The name of the encryption key that is stored in Google Cloud KMS.
|
||||||
|
returned: success
|
||||||
|
type: str
|
||||||
sha256:
|
sha256:
|
||||||
description:
|
description:
|
||||||
- The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption
|
- The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption
|
||||||
|
@ -267,12 +281,7 @@ import json
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
module = GcpModule(
|
module = GcpModule(argument_spec=dict(filters=dict(type='list', elements='str'), zone=dict(required=True, type='str')))
|
||||||
argument_spec=dict(
|
|
||||||
filters=dict(type='list', elements='str'),
|
|
||||||
zone=dict(required=True, type='str')
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
if not module.params['scopes']:
|
if not module.params['scopes']:
|
||||||
module.params['scopes'] = ['https://www.googleapis.com/auth/compute']
|
module.params['scopes'] = ['https://www.googleapis.com/auth/compute']
|
||||||
|
@ -282,9 +291,7 @@ def main():
|
||||||
items = items.get('items')
|
items = items.get('items')
|
||||||
else:
|
else:
|
||||||
items = []
|
items = []
|
||||||
return_value = {
|
return_value = {'items': items}
|
||||||
'items': items
|
|
||||||
}
|
|
||||||
module.exit_json(**return_value)
|
module.exit_json(**return_value)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -18,15 +18,14 @@
|
||||||
# ----------------------------------------------------------------------------
|
# ----------------------------------------------------------------------------
|
||||||
|
|
||||||
from __future__ import absolute_import, division, print_function
|
from __future__ import absolute_import, division, print_function
|
||||||
|
|
||||||
__metaclass__ = type
|
__metaclass__ = type
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
# Documentation
|
# Documentation
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
ANSIBLE_METADATA = {'metadata_version': '1.1',
|
ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
|
||||||
'status': ["preview"],
|
|
||||||
'supported_by': 'community'}
|
|
||||||
|
|
||||||
DOCUMENTATION = '''
|
DOCUMENTATION = '''
|
||||||
---
|
---
|
||||||
|
@ -427,34 +426,30 @@ def main():
|
||||||
module = GcpModule(
|
module = GcpModule(
|
||||||
argument_spec=dict(
|
argument_spec=dict(
|
||||||
state=dict(default='present', choices=['present', 'absent'], type='str'),
|
state=dict(default='present', choices=['present', 'absent'], type='str'),
|
||||||
allowed=dict(type='list', elements='dict', options=dict(
|
allowed=dict(type='list', elements='dict', options=dict(ip_protocol=dict(required=True, type='str'), ports=dict(type='list', elements='str'))),
|
||||||
ip_protocol=dict(required=True, type='str'),
|
denied=dict(type='list', elements='dict', options=dict(ip_protocol=dict(required=True, type='str'), ports=dict(type='list', elements='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'),
|
description=dict(type='str'),
|
||||||
destination_ranges=dict(type='list', elements='str'),
|
destination_ranges=dict(type='list', elements='str'),
|
||||||
direction=dict(type='str', choices=['INGRESS', 'EGRESS']),
|
direction=dict(type='str', choices=['INGRESS', 'EGRESS']),
|
||||||
disabled=dict(type='bool'),
|
disabled=dict(type='bool'),
|
||||||
name=dict(required=True, type='str'),
|
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'),
|
priority=dict(default=1000, type='int'),
|
||||||
source_ranges=dict(type='list', elements='str'),
|
source_ranges=dict(type='list', elements='str'),
|
||||||
source_service_accounts=dict(type='list', elements='str'),
|
source_service_accounts=dict(type='list', elements='str'),
|
||||||
source_tags=dict(type='list', elements='str'),
|
source_tags=dict(type='list', elements='str'),
|
||||||
target_service_accounts=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'],
|
mutually_exclusive=[
|
||||||
['destination_ranges', 'source_ranges', 'source_tags'],
|
['allowed', 'denied'],
|
||||||
['destination_ranges', 'source_ranges'],
|
['destination_ranges', 'source_ranges', 'source_tags'],
|
||||||
['source_service_accounts', 'source_tags', 'target_tags'],
|
['destination_ranges', 'source_ranges'],
|
||||||
['destination_ranges', 'source_service_accounts', 'source_tags', 'target_service_accounts'],
|
['source_service_accounts', 'source_tags', 'target_tags'],
|
||||||
['source_tags', 'target_service_accounts', 'target_tags'],
|
['destination_ranges', 'source_service_accounts', 'source_tags', 'target_service_accounts'],
|
||||||
['source_service_accounts', 'target_service_accounts', 'target_tags']]
|
['source_tags', 'target_service_accounts', 'target_tags'],
|
||||||
|
['source_service_accounts', 'target_service_accounts', 'target_tags'],
|
||||||
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
if not module.params['scopes']:
|
if not module.params['scopes']:
|
||||||
|
@ -519,7 +514,7 @@ def resource_to_request(module):
|
||||||
u'sourceServiceAccounts': module.params.get('source_service_accounts'),
|
u'sourceServiceAccounts': module.params.get('source_service_accounts'),
|
||||||
u'sourceTags': module.params.get('source_tags'),
|
u'sourceTags': module.params.get('source_tags'),
|
||||||
u'targetServiceAccounts': module.params.get('target_service_accounts'),
|
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)
|
request = encode_request(request, module)
|
||||||
return_vals = {}
|
return_vals = {}
|
||||||
|
@ -555,8 +550,8 @@ def return_if_object(module, response, kind, allow_not_found=False):
|
||||||
try:
|
try:
|
||||||
module.raise_for_status(response)
|
module.raise_for_status(response)
|
||||||
result = response.json()
|
result = response.json()
|
||||||
except getattr(json.decoder, 'JSONDecodeError', ValueError) as inst:
|
except getattr(json.decoder, 'JSONDecodeError', ValueError):
|
||||||
module.fail_json(msg="Invalid JSON response with error: %s" % inst)
|
module.fail_json(msg="Invalid JSON response with error: %s" % response.text)
|
||||||
|
|
||||||
if navigate_hash(result, ['error', 'errors']):
|
if navigate_hash(result, ['error', 'errors']):
|
||||||
module.fail_json(msg=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'sourceServiceAccounts': response.get(u'sourceServiceAccounts'),
|
||||||
u'sourceTags': response.get(u'sourceTags'),
|
u'sourceTags': response.get(u'sourceTags'),
|
||||||
u'targetServiceAccounts': response.get(u'targetServiceAccounts'),
|
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_id = navigate_hash(op_result, ['name'])
|
||||||
op_uri = async_op_url(module, {'op_id': op_id})
|
op_uri = async_op_url(module, {'op_id': op_id})
|
||||||
while status != 'DONE':
|
while status != 'DONE':
|
||||||
raise_if_errors(op_result, ['error', 'errors'], 'message')
|
raise_if_errors(op_result, ['error', 'errors'], module)
|
||||||
time.sleep(1.0)
|
time.sleep(1.0)
|
||||||
op_result = fetch_resource(module, op_uri, 'compute#operation')
|
op_result = fetch_resource(module, op_uri, 'compute#operation')
|
||||||
status = navigate_hash(op_result, ['status'])
|
status = navigate_hash(op_result, ['status'])
|
||||||
|
@ -643,8 +638,9 @@ def raise_if_errors(response, err_path, module):
|
||||||
def encode_request(request, module):
|
def encode_request(request, module):
|
||||||
if 'network' in request and request['network'] is not None:
|
if 'network' in request and request['network'] is not None:
|
||||||
if not re.match(r'https://www.googleapis.com/compute/v1/projects/.*', request['network']):
|
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'],
|
request['network'] = 'https://www.googleapis.com/compute/v1/projects/{project}/{network}'.format(
|
||||||
network=request['network'])
|
project=module.params['project'], network=request['network']
|
||||||
|
)
|
||||||
|
|
||||||
return request
|
return request
|
||||||
|
|
||||||
|
@ -670,16 +666,10 @@ class FirewallAllowedArray(object):
|
||||||
return items
|
return items
|
||||||
|
|
||||||
def _request_for_item(self, item):
|
def _request_for_item(self, item):
|
||||||
return remove_nones_from_dict({
|
return remove_nones_from_dict({u'IPProtocol': item.get('ip_protocol'), u'ports': item.get('ports')})
|
||||||
u'IPProtocol': item.get('ip_protocol'),
|
|
||||||
u'ports': item.get('ports')
|
|
||||||
})
|
|
||||||
|
|
||||||
def _response_from_item(self, item):
|
def _response_from_item(self, item):
|
||||||
return remove_nones_from_dict({
|
return remove_nones_from_dict({u'IPProtocol': item.get(u'ip_protocol'), u'ports': item.get(u'ports')})
|
||||||
u'IPProtocol': item.get(u'ip_protocol'),
|
|
||||||
u'ports': item.get(u'ports')
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
class FirewallDeniedArray(object):
|
class FirewallDeniedArray(object):
|
||||||
|
@ -703,16 +693,10 @@ class FirewallDeniedArray(object):
|
||||||
return items
|
return items
|
||||||
|
|
||||||
def _request_for_item(self, item):
|
def _request_for_item(self, item):
|
||||||
return remove_nones_from_dict({
|
return remove_nones_from_dict({u'IPProtocol': item.get('ip_protocol'), u'ports': item.get('ports')})
|
||||||
u'IPProtocol': item.get('ip_protocol'),
|
|
||||||
u'ports': item.get('ports')
|
|
||||||
})
|
|
||||||
|
|
||||||
def _response_from_item(self, item):
|
def _response_from_item(self, item):
|
||||||
return remove_nones_from_dict({
|
return remove_nones_from_dict({u'IPProtocol': item.get(u'ip_protocol'), u'ports': item.get(u'ports')})
|
||||||
u'IPProtocol': item.get(u'ip_protocol'),
|
|
||||||
u'ports': item.get(u'ports')
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
|
@ -18,15 +18,14 @@
|
||||||
# ----------------------------------------------------------------------------
|
# ----------------------------------------------------------------------------
|
||||||
|
|
||||||
from __future__ import absolute_import, division, print_function
|
from __future__ import absolute_import, division, print_function
|
||||||
|
|
||||||
__metaclass__ = type
|
__metaclass__ = type
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
# Documentation
|
# Documentation
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
ANSIBLE_METADATA = {'metadata_version': '1.1',
|
ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
|
||||||
'status': ["preview"],
|
|
||||||
'supported_by': 'community'}
|
|
||||||
|
|
||||||
DOCUMENTATION = '''
|
DOCUMENTATION = '''
|
||||||
---
|
---
|
||||||
|
@ -248,11 +247,7 @@ import json
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
module = GcpModule(
|
module = GcpModule(argument_spec=dict(filters=dict(type='list', elements='str')))
|
||||||
argument_spec=dict(
|
|
||||||
filters=dict(type='list', elements='str')
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
if not module.params['scopes']:
|
if not module.params['scopes']:
|
||||||
module.params['scopes'] = ['https://www.googleapis.com/auth/compute']
|
module.params['scopes'] = ['https://www.googleapis.com/auth/compute']
|
||||||
|
@ -262,9 +257,7 @@ def main():
|
||||||
items = items.get('items')
|
items = items.get('items')
|
||||||
else:
|
else:
|
||||||
items = []
|
items = []
|
||||||
return_value = {
|
return_value = {'items': items}
|
||||||
'items': items
|
|
||||||
}
|
|
||||||
module.exit_json(**return_value)
|
module.exit_json(**return_value)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -18,15 +18,14 @@
|
||||||
# ----------------------------------------------------------------------------
|
# ----------------------------------------------------------------------------
|
||||||
|
|
||||||
from __future__ import absolute_import, division, print_function
|
from __future__ import absolute_import, division, print_function
|
||||||
|
|
||||||
__metaclass__ = type
|
__metaclass__ = type
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
# Documentation
|
# Documentation
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
ANSIBLE_METADATA = {'metadata_version': '1.1',
|
ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
|
||||||
'status': ["preview"],
|
|
||||||
'supported_by': 'community'}
|
|
||||||
|
|
||||||
DOCUMENTATION = '''
|
DOCUMENTATION = '''
|
||||||
---
|
---
|
||||||
|
@ -422,7 +421,7 @@ def main():
|
||||||
subnetwork=dict(),
|
subnetwork=dict(),
|
||||||
target=dict(),
|
target=dict(),
|
||||||
network_tier=dict(type='str', choices=['PREMIUM', 'STANDARD']),
|
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):
|
def update(module, link, kind, fetch):
|
||||||
update_fields(module, resource_to_request(module),
|
update_fields(module, resource_to_request(module), response_to_hash(module, fetch))
|
||||||
response_to_hash(module, fetch))
|
|
||||||
return fetch_resource(module, self_link(module), kind)
|
return fetch_resource(module, self_link(module), kind)
|
||||||
|
|
||||||
|
|
||||||
|
@ -476,13 +474,8 @@ def update_fields(module, request, response):
|
||||||
def target_update(module, request, response):
|
def target_update(module, request, response):
|
||||||
auth = GcpSession(module, 'compute')
|
auth = GcpSession(module, 'compute')
|
||||||
auth.post(
|
auth.post(
|
||||||
''.join([
|
''.join(["https://www.googleapis.com/compute/v1/", "projects/{project}/regions/{region}/forwardingRules/{name}/setTarget"]).format(**module.params),
|
||||||
"https://www.googleapis.com/compute/v1/",
|
{u'target': replace_resource_dict(module.params.get(u'target', {}), 'selfLink')},
|
||||||
"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'ports': module.params.get('ports'),
|
||||||
u'subnetwork': replace_resource_dict(module.params.get(u'subnetwork', {}), 'selfLink'),
|
u'subnetwork': replace_resource_dict(module.params.get(u'subnetwork', {}), 'selfLink'),
|
||||||
u'target': replace_resource_dict(module.params.get(u'target', {}), '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 = {}
|
return_vals = {}
|
||||||
for k, v in request.items():
|
for k, v in request.items():
|
||||||
|
@ -541,8 +534,8 @@ def return_if_object(module, response, kind, allow_not_found=False):
|
||||||
try:
|
try:
|
||||||
module.raise_for_status(response)
|
module.raise_for_status(response)
|
||||||
result = response.json()
|
result = response.json()
|
||||||
except getattr(json.decoder, 'JSONDecodeError', ValueError) as inst:
|
except getattr(json.decoder, 'JSONDecodeError', ValueError):
|
||||||
module.fail_json(msg="Invalid JSON response with error: %s" % inst)
|
module.fail_json(msg="Invalid JSON response with error: %s" % response.text)
|
||||||
|
|
||||||
if navigate_hash(result, ['error', 'errors']):
|
if navigate_hash(result, ['error', 'errors']):
|
||||||
module.fail_json(msg=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'ports': response.get(u'ports'),
|
||||||
u'subnetwork': response.get(u'subnetwork'),
|
u'subnetwork': response.get(u'subnetwork'),
|
||||||
u'target': response.get(u'target'),
|
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_id = navigate_hash(op_result, ['name'])
|
||||||
op_uri = async_op_url(module, {'op_id': op_id})
|
op_uri = async_op_url(module, {'op_id': op_id})
|
||||||
while status != 'DONE':
|
while status != 'DONE':
|
||||||
raise_if_errors(op_result, ['error', 'errors'], 'message')
|
raise_if_errors(op_result, ['error', 'errors'], module)
|
||||||
time.sleep(1.0)
|
time.sleep(1.0)
|
||||||
op_result = fetch_resource(module, op_uri, 'compute#operation')
|
op_result = fetch_resource(module, op_uri, 'compute#operation')
|
||||||
status = navigate_hash(op_result, ['status'])
|
status = navigate_hash(op_result, ['status'])
|
||||||
|
|
|
@ -18,15 +18,14 @@
|
||||||
# ----------------------------------------------------------------------------
|
# ----------------------------------------------------------------------------
|
||||||
|
|
||||||
from __future__ import absolute_import, division, print_function
|
from __future__ import absolute_import, division, print_function
|
||||||
|
|
||||||
__metaclass__ = type
|
__metaclass__ = type
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
# Documentation
|
# Documentation
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
ANSIBLE_METADATA = {'metadata_version': '1.1',
|
ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
|
||||||
'status': ["preview"],
|
|
||||||
'supported_by': 'community'}
|
|
||||||
|
|
||||||
DOCUMENTATION = '''
|
DOCUMENTATION = '''
|
||||||
---
|
---
|
||||||
|
@ -229,12 +228,7 @@ import json
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
module = GcpModule(
|
module = GcpModule(argument_spec=dict(filters=dict(type='list', elements='str'), region=dict(required=True, type='str')))
|
||||||
argument_spec=dict(
|
|
||||||
filters=dict(type='list', elements='str'),
|
|
||||||
region=dict(required=True, type='str')
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
if not module.params['scopes']:
|
if not module.params['scopes']:
|
||||||
module.params['scopes'] = ['https://www.googleapis.com/auth/compute']
|
module.params['scopes'] = ['https://www.googleapis.com/auth/compute']
|
||||||
|
@ -244,9 +238,7 @@ def main():
|
||||||
items = items.get('items')
|
items = items.get('items')
|
||||||
else:
|
else:
|
||||||
items = []
|
items = []
|
||||||
return_value = {
|
return_value = {'items': items}
|
||||||
'items': items
|
|
||||||
}
|
|
||||||
module.exit_json(**return_value)
|
module.exit_json(**return_value)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -18,15 +18,14 @@
|
||||||
# ----------------------------------------------------------------------------
|
# ----------------------------------------------------------------------------
|
||||||
|
|
||||||
from __future__ import absolute_import, division, print_function
|
from __future__ import absolute_import, division, print_function
|
||||||
|
|
||||||
__metaclass__ = type
|
__metaclass__ = type
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
# Documentation
|
# Documentation
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
ANSIBLE_METADATA = {'metadata_version': '1.1',
|
ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
|
||||||
'status': ["preview"],
|
|
||||||
'supported_by': 'community'}
|
|
||||||
|
|
||||||
DOCUMENTATION = '''
|
DOCUMENTATION = '''
|
||||||
---
|
---
|
||||||
|
@ -179,7 +178,7 @@ def main():
|
||||||
description=dict(type='str'),
|
description=dict(type='str'),
|
||||||
name=dict(required=True, type='str'),
|
name=dict(required=True, type='str'),
|
||||||
ip_version=dict(type='str', choices=['IPV4', 'IPV6']),
|
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'description': module.params.get('description'),
|
||||||
u'name': module.params.get('name'),
|
u'name': module.params.get('name'),
|
||||||
u'ipVersion': module.params.get('ip_version'),
|
u'ipVersion': module.params.get('ip_version'),
|
||||||
u'addressType': module.params.get('address_type')
|
u'addressType': module.params.get('address_type'),
|
||||||
}
|
}
|
||||||
return_vals = {}
|
return_vals = {}
|
||||||
for k, v in request.items():
|
for k, v in request.items():
|
||||||
|
@ -270,8 +269,8 @@ def return_if_object(module, response, kind, allow_not_found=False):
|
||||||
try:
|
try:
|
||||||
module.raise_for_status(response)
|
module.raise_for_status(response)
|
||||||
result = response.json()
|
result = response.json()
|
||||||
except getattr(json.decoder, 'JSONDecodeError', ValueError) as inst:
|
except getattr(json.decoder, 'JSONDecodeError', ValueError):
|
||||||
module.fail_json(msg="Invalid JSON response with error: %s" % inst)
|
module.fail_json(msg="Invalid JSON response with error: %s" % response.text)
|
||||||
|
|
||||||
if navigate_hash(result, ['error', 'errors']):
|
if navigate_hash(result, ['error', 'errors']):
|
||||||
module.fail_json(msg=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'name': response.get(u'name'),
|
||||||
u'ipVersion': response.get(u'ipVersion'),
|
u'ipVersion': response.get(u'ipVersion'),
|
||||||
u'region': response.get(u'region'),
|
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_id = navigate_hash(op_result, ['name'])
|
||||||
op_uri = async_op_url(module, {'op_id': op_id})
|
op_uri = async_op_url(module, {'op_id': op_id})
|
||||||
while status != 'DONE':
|
while status != 'DONE':
|
||||||
raise_if_errors(op_result, ['error', 'errors'], 'message')
|
raise_if_errors(op_result, ['error', 'errors'], module)
|
||||||
time.sleep(1.0)
|
time.sleep(1.0)
|
||||||
op_result = fetch_resource(module, op_uri, 'compute#operation')
|
op_result = fetch_resource(module, op_uri, 'compute#operation')
|
||||||
status = navigate_hash(op_result, ['status'])
|
status = navigate_hash(op_result, ['status'])
|
||||||
|
|
|
@ -18,15 +18,14 @@
|
||||||
# ----------------------------------------------------------------------------
|
# ----------------------------------------------------------------------------
|
||||||
|
|
||||||
from __future__ import absolute_import, division, print_function
|
from __future__ import absolute_import, division, print_function
|
||||||
|
|
||||||
__metaclass__ = type
|
__metaclass__ = type
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
# Documentation
|
# Documentation
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
ANSIBLE_METADATA = {'metadata_version': '1.1',
|
ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
|
||||||
'status': ["preview"],
|
|
||||||
'supported_by': 'community'}
|
|
||||||
|
|
||||||
DOCUMENTATION = '''
|
DOCUMENTATION = '''
|
||||||
---
|
---
|
||||||
|
@ -129,11 +128,7 @@ import json
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
module = GcpModule(
|
module = GcpModule(argument_spec=dict(filters=dict(type='list', elements='str')))
|
||||||
argument_spec=dict(
|
|
||||||
filters=dict(type='list', elements='str')
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
if not module.params['scopes']:
|
if not module.params['scopes']:
|
||||||
module.params['scopes'] = ['https://www.googleapis.com/auth/compute']
|
module.params['scopes'] = ['https://www.googleapis.com/auth/compute']
|
||||||
|
@ -143,9 +138,7 @@ def main():
|
||||||
items = items.get('items')
|
items = items.get('items')
|
||||||
else:
|
else:
|
||||||
items = []
|
items = []
|
||||||
return_value = {
|
return_value = {'items': items}
|
||||||
'items': items
|
|
||||||
}
|
|
||||||
module.exit_json(**return_value)
|
module.exit_json(**return_value)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -18,15 +18,14 @@
|
||||||
# ----------------------------------------------------------------------------
|
# ----------------------------------------------------------------------------
|
||||||
|
|
||||||
from __future__ import absolute_import, division, print_function
|
from __future__ import absolute_import, division, print_function
|
||||||
|
|
||||||
__metaclass__ = type
|
__metaclass__ = type
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
# Documentation
|
# Documentation
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
ANSIBLE_METADATA = {'metadata_version': '1.1',
|
ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
|
||||||
'status': ["preview"],
|
|
||||||
'supported_by': 'community'}
|
|
||||||
|
|
||||||
DOCUMENTATION = '''
|
DOCUMENTATION = '''
|
||||||
---
|
---
|
||||||
|
@ -431,7 +430,7 @@ def main():
|
||||||
port_range=dict(type='str'),
|
port_range=dict(type='str'),
|
||||||
ports=dict(type='list', elements='str'),
|
ports=dict(type='list', elements='str'),
|
||||||
subnetwork=dict(),
|
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'portRange': module.params.get('port_range'),
|
||||||
u'ports': module.params.get('ports'),
|
u'ports': module.params.get('ports'),
|
||||||
u'subnetwork': replace_resource_dict(module.params.get(u'subnetwork', {}), 'selfLink'),
|
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 = {}
|
return_vals = {}
|
||||||
for k, v in request.items():
|
for k, v in request.items():
|
||||||
|
@ -530,8 +529,8 @@ def return_if_object(module, response, kind, allow_not_found=False):
|
||||||
try:
|
try:
|
||||||
module.raise_for_status(response)
|
module.raise_for_status(response)
|
||||||
result = response.json()
|
result = response.json()
|
||||||
except getattr(json.decoder, 'JSONDecodeError', ValueError) as inst:
|
except getattr(json.decoder, 'JSONDecodeError', ValueError):
|
||||||
module.fail_json(msg="Invalid JSON response with error: %s" % inst)
|
module.fail_json(msg="Invalid JSON response with error: %s" % response.text)
|
||||||
|
|
||||||
if navigate_hash(result, ['error', 'errors']):
|
if navigate_hash(result, ['error', 'errors']):
|
||||||
module.fail_json(msg=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'ports': response.get(u'ports'),
|
||||||
u'subnetwork': response.get(u'subnetwork'),
|
u'subnetwork': response.get(u'subnetwork'),
|
||||||
u'region': response.get(u'region'),
|
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_id = navigate_hash(op_result, ['name'])
|
||||||
op_uri = async_op_url(module, {'op_id': op_id})
|
op_uri = async_op_url(module, {'op_id': op_id})
|
||||||
while status != 'DONE':
|
while status != 'DONE':
|
||||||
raise_if_errors(op_result, ['error', 'errors'], 'message')
|
raise_if_errors(op_result, ['error', 'errors'], module)
|
||||||
time.sleep(1.0)
|
time.sleep(1.0)
|
||||||
op_result = fetch_resource(module, op_uri, 'compute#operation')
|
op_result = fetch_resource(module, op_uri, 'compute#operation')
|
||||||
status = navigate_hash(op_result, ['status'])
|
status = navigate_hash(op_result, ['status'])
|
||||||
|
|
|
@ -18,15 +18,14 @@
|
||||||
# ----------------------------------------------------------------------------
|
# ----------------------------------------------------------------------------
|
||||||
|
|
||||||
from __future__ import absolute_import, division, print_function
|
from __future__ import absolute_import, division, print_function
|
||||||
|
|
||||||
__metaclass__ = type
|
__metaclass__ = type
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
# Documentation
|
# Documentation
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
ANSIBLE_METADATA = {'metadata_version': '1.1',
|
ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
|
||||||
'status': ["preview"],
|
|
||||||
'supported_by': 'community'}
|
|
||||||
|
|
||||||
DOCUMENTATION = '''
|
DOCUMENTATION = '''
|
||||||
---
|
---
|
||||||
|
@ -213,11 +212,7 @@ import json
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
module = GcpModule(
|
module = GcpModule(argument_spec=dict(filters=dict(type='list', elements='str')))
|
||||||
argument_spec=dict(
|
|
||||||
filters=dict(type='list', elements='str')
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
if not module.params['scopes']:
|
if not module.params['scopes']:
|
||||||
module.params['scopes'] = ['https://www.googleapis.com/auth/compute']
|
module.params['scopes'] = ['https://www.googleapis.com/auth/compute']
|
||||||
|
@ -227,9 +222,7 @@ def main():
|
||||||
items = items.get('items')
|
items = items.get('items')
|
||||||
else:
|
else:
|
||||||
items = []
|
items = []
|
||||||
return_value = {
|
return_value = {'items': items}
|
||||||
'items': items
|
|
||||||
}
|
|
||||||
module.exit_json(**return_value)
|
module.exit_json(**return_value)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -18,15 +18,14 @@
|
||||||
# ----------------------------------------------------------------------------
|
# ----------------------------------------------------------------------------
|
||||||
|
|
||||||
from __future__ import absolute_import, division, print_function
|
from __future__ import absolute_import, division, print_function
|
||||||
|
|
||||||
__metaclass__ = type
|
__metaclass__ = type
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
# Documentation
|
# Documentation
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
ANSIBLE_METADATA = {'metadata_version': '1.1',
|
ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
|
||||||
'status': ["preview"],
|
|
||||||
'supported_by': 'community'}
|
|
||||||
|
|
||||||
DOCUMENTATION = '''
|
DOCUMENTATION = '''
|
||||||
---
|
---
|
||||||
|
@ -537,38 +536,50 @@ def main():
|
||||||
timeout_sec=dict(default=5, type='int', aliases=['timeout_seconds']),
|
timeout_sec=dict(default=5, type='int', aliases=['timeout_seconds']),
|
||||||
unhealthy_threshold=dict(default=2, type='int'),
|
unhealthy_threshold=dict(default=2, type='int'),
|
||||||
type=dict(type='str', choices=['TCP', 'SSL', 'HTTP', 'HTTPS']),
|
type=dict(type='str', choices=['TCP', 'SSL', 'HTTP', 'HTTPS']),
|
||||||
http_health_check=dict(type='dict', options=dict(
|
http_health_check=dict(
|
||||||
host=dict(type='str'),
|
type='dict',
|
||||||
request_path=dict(default='/', type='str'),
|
options=dict(
|
||||||
response=dict(type='str'),
|
host=dict(type='str'),
|
||||||
port=dict(type='int'),
|
request_path=dict(default='/', type='str'),
|
||||||
port_name=dict(type='str'),
|
response=dict(type='str'),
|
||||||
proxy_header=dict(default='NONE', type='str', choices=['NONE', 'PROXY_V1'])
|
port=dict(type='int'),
|
||||||
)),
|
port_name=dict(type='str'),
|
||||||
https_health_check=dict(type='dict', options=dict(
|
proxy_header=dict(default='NONE', type='str', choices=['NONE', 'PROXY_V1']),
|
||||||
host=dict(type='str'),
|
),
|
||||||
request_path=dict(default='/', type='str'),
|
),
|
||||||
response=dict(type='str'),
|
https_health_check=dict(
|
||||||
port=dict(type='int'),
|
type='dict',
|
||||||
port_name=dict(type='str'),
|
options=dict(
|
||||||
proxy_header=dict(default='NONE', type='str', choices=['NONE', 'PROXY_V1'])
|
host=dict(type='str'),
|
||||||
)),
|
request_path=dict(default='/', type='str'),
|
||||||
tcp_health_check=dict(type='dict', options=dict(
|
response=dict(type='str'),
|
||||||
request=dict(type='str'),
|
port=dict(type='int'),
|
||||||
response=dict(type='str'),
|
port_name=dict(type='str'),
|
||||||
port=dict(type='int'),
|
proxy_header=dict(default='NONE', type='str', choices=['NONE', 'PROXY_V1']),
|
||||||
port_name=dict(type='str'),
|
),
|
||||||
proxy_header=dict(default='NONE', type='str', choices=['NONE', 'PROXY_V1'])
|
),
|
||||||
)),
|
tcp_health_check=dict(
|
||||||
ssl_health_check=dict(type='dict', options=dict(
|
type='dict',
|
||||||
request=dict(type='str'),
|
options=dict(
|
||||||
response=dict(type='str'),
|
request=dict(type='str'),
|
||||||
port=dict(type='int'),
|
response=dict(type='str'),
|
||||||
port_name=dict(type='str'),
|
port=dict(type='int'),
|
||||||
proxy_header=dict(default='NONE', type='str', choices=['NONE', 'PROXY_V1'])
|
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']:
|
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'httpHealthCheck': HealthCheckHttphealthcheck(module.params.get('http_health_check', {}), module).to_request(),
|
||||||
u'httpsHealthCheck': HealthCheckHttpshealthcheck(module.params.get('https_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'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 = {}
|
return_vals = {}
|
||||||
for k, v in request.items():
|
for k, v in request.items():
|
||||||
|
@ -665,8 +676,8 @@ def return_if_object(module, response, kind, allow_not_found=False):
|
||||||
try:
|
try:
|
||||||
module.raise_for_status(response)
|
module.raise_for_status(response)
|
||||||
result = response.json()
|
result = response.json()
|
||||||
except getattr(json.decoder, 'JSONDecodeError', ValueError) as inst:
|
except getattr(json.decoder, 'JSONDecodeError', ValueError):
|
||||||
module.fail_json(msg="Invalid JSON response with error: %s" % inst)
|
module.fail_json(msg="Invalid JSON response with error: %s" % response.text)
|
||||||
|
|
||||||
if navigate_hash(result, ['error', 'errors']):
|
if navigate_hash(result, ['error', 'errors']):
|
||||||
module.fail_json(msg=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'httpHealthCheck': HealthCheckHttphealthcheck(response.get(u'httpHealthCheck', {}), module).from_response(),
|
||||||
u'httpsHealthCheck': HealthCheckHttpshealthcheck(response.get(u'httpsHealthCheck', {}), module).from_response(),
|
u'httpsHealthCheck': HealthCheckHttpshealthcheck(response.get(u'httpsHealthCheck', {}), module).from_response(),
|
||||||
u'tcpHealthCheck': HealthCheckTcphealthcheck(response.get(u'tcpHealthCheck', {}), 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_id = navigate_hash(op_result, ['name'])
|
||||||
op_uri = async_op_url(module, {'op_id': op_id})
|
op_uri = async_op_url(module, {'op_id': op_id})
|
||||||
while status != 'DONE':
|
while status != 'DONE':
|
||||||
raise_if_errors(op_result, ['error', 'errors'], 'message')
|
raise_if_errors(op_result, ['error', 'errors'], module)
|
||||||
time.sleep(1.0)
|
time.sleep(1.0)
|
||||||
op_result = fetch_resource(module, op_uri, 'compute#operation')
|
op_result = fetch_resource(module, op_uri, 'compute#operation')
|
||||||
status = navigate_hash(op_result, ['status'])
|
status = navigate_hash(op_result, ['status'])
|
||||||
|
@ -756,24 +767,28 @@ class HealthCheckHttphealthcheck(object):
|
||||||
self.request = {}
|
self.request = {}
|
||||||
|
|
||||||
def to_request(self):
|
def to_request(self):
|
||||||
return remove_nones_from_dict({
|
return remove_nones_from_dict(
|
||||||
u'host': self.request.get('host'),
|
{
|
||||||
u'requestPath': self.request.get('request_path'),
|
u'host': self.request.get('host'),
|
||||||
u'response': self.request.get('response'),
|
u'requestPath': self.request.get('request_path'),
|
||||||
u'port': self.request.get('port'),
|
u'response': self.request.get('response'),
|
||||||
u'portName': self.request.get('port_name'),
|
u'port': self.request.get('port'),
|
||||||
u'proxyHeader': self.request.get('proxy_header')
|
u'portName': self.request.get('port_name'),
|
||||||
})
|
u'proxyHeader': self.request.get('proxy_header'),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
def from_response(self):
|
def from_response(self):
|
||||||
return remove_nones_from_dict({
|
return remove_nones_from_dict(
|
||||||
u'host': self.request.get(u'host'),
|
{
|
||||||
u'requestPath': self.request.get(u'requestPath'),
|
u'host': self.request.get(u'host'),
|
||||||
u'response': self.request.get(u'response'),
|
u'requestPath': self.request.get(u'requestPath'),
|
||||||
u'port': self.request.get(u'port'),
|
u'response': self.request.get(u'response'),
|
||||||
u'portName': self.request.get(u'portName'),
|
u'port': self.request.get(u'port'),
|
||||||
u'proxyHeader': self.request.get(u'proxyHeader')
|
u'portName': self.request.get(u'portName'),
|
||||||
})
|
u'proxyHeader': self.request.get(u'proxyHeader'),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class HealthCheckHttpshealthcheck(object):
|
class HealthCheckHttpshealthcheck(object):
|
||||||
|
@ -785,24 +800,28 @@ class HealthCheckHttpshealthcheck(object):
|
||||||
self.request = {}
|
self.request = {}
|
||||||
|
|
||||||
def to_request(self):
|
def to_request(self):
|
||||||
return remove_nones_from_dict({
|
return remove_nones_from_dict(
|
||||||
u'host': self.request.get('host'),
|
{
|
||||||
u'requestPath': self.request.get('request_path'),
|
u'host': self.request.get('host'),
|
||||||
u'response': self.request.get('response'),
|
u'requestPath': self.request.get('request_path'),
|
||||||
u'port': self.request.get('port'),
|
u'response': self.request.get('response'),
|
||||||
u'portName': self.request.get('port_name'),
|
u'port': self.request.get('port'),
|
||||||
u'proxyHeader': self.request.get('proxy_header')
|
u'portName': self.request.get('port_name'),
|
||||||
})
|
u'proxyHeader': self.request.get('proxy_header'),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
def from_response(self):
|
def from_response(self):
|
||||||
return remove_nones_from_dict({
|
return remove_nones_from_dict(
|
||||||
u'host': self.request.get(u'host'),
|
{
|
||||||
u'requestPath': self.request.get(u'requestPath'),
|
u'host': self.request.get(u'host'),
|
||||||
u'response': self.request.get(u'response'),
|
u'requestPath': self.request.get(u'requestPath'),
|
||||||
u'port': self.request.get(u'port'),
|
u'response': self.request.get(u'response'),
|
||||||
u'portName': self.request.get(u'portName'),
|
u'port': self.request.get(u'port'),
|
||||||
u'proxyHeader': self.request.get(u'proxyHeader')
|
u'portName': self.request.get(u'portName'),
|
||||||
})
|
u'proxyHeader': self.request.get(u'proxyHeader'),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class HealthCheckTcphealthcheck(object):
|
class HealthCheckTcphealthcheck(object):
|
||||||
|
@ -814,22 +833,26 @@ class HealthCheckTcphealthcheck(object):
|
||||||
self.request = {}
|
self.request = {}
|
||||||
|
|
||||||
def to_request(self):
|
def to_request(self):
|
||||||
return remove_nones_from_dict({
|
return remove_nones_from_dict(
|
||||||
u'request': self.request.get('request'),
|
{
|
||||||
u'response': self.request.get('response'),
|
u'request': self.request.get('request'),
|
||||||
u'port': self.request.get('port'),
|
u'response': self.request.get('response'),
|
||||||
u'portName': self.request.get('port_name'),
|
u'port': self.request.get('port'),
|
||||||
u'proxyHeader': self.request.get('proxy_header')
|
u'portName': self.request.get('port_name'),
|
||||||
})
|
u'proxyHeader': self.request.get('proxy_header'),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
def from_response(self):
|
def from_response(self):
|
||||||
return remove_nones_from_dict({
|
return remove_nones_from_dict(
|
||||||
u'request': self.request.get(u'request'),
|
{
|
||||||
u'response': self.request.get(u'response'),
|
u'request': self.request.get(u'request'),
|
||||||
u'port': self.request.get(u'port'),
|
u'response': self.request.get(u'response'),
|
||||||
u'portName': self.request.get(u'portName'),
|
u'port': self.request.get(u'port'),
|
||||||
u'proxyHeader': self.request.get(u'proxyHeader')
|
u'portName': self.request.get(u'portName'),
|
||||||
})
|
u'proxyHeader': self.request.get(u'proxyHeader'),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class HealthCheckSslhealthcheck(object):
|
class HealthCheckSslhealthcheck(object):
|
||||||
|
@ -841,22 +864,26 @@ class HealthCheckSslhealthcheck(object):
|
||||||
self.request = {}
|
self.request = {}
|
||||||
|
|
||||||
def to_request(self):
|
def to_request(self):
|
||||||
return remove_nones_from_dict({
|
return remove_nones_from_dict(
|
||||||
u'request': self.request.get('request'),
|
{
|
||||||
u'response': self.request.get('response'),
|
u'request': self.request.get('request'),
|
||||||
u'port': self.request.get('port'),
|
u'response': self.request.get('response'),
|
||||||
u'portName': self.request.get('port_name'),
|
u'port': self.request.get('port'),
|
||||||
u'proxyHeader': self.request.get('proxy_header')
|
u'portName': self.request.get('port_name'),
|
||||||
})
|
u'proxyHeader': self.request.get('proxy_header'),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
def from_response(self):
|
def from_response(self):
|
||||||
return remove_nones_from_dict({
|
return remove_nones_from_dict(
|
||||||
u'request': self.request.get(u'request'),
|
{
|
||||||
u'response': self.request.get(u'response'),
|
u'request': self.request.get(u'request'),
|
||||||
u'port': self.request.get(u'port'),
|
u'response': self.request.get(u'response'),
|
||||||
u'portName': self.request.get(u'portName'),
|
u'port': self.request.get(u'port'),
|
||||||
u'proxyHeader': self.request.get(u'proxyHeader')
|
u'portName': self.request.get(u'portName'),
|
||||||
})
|
u'proxyHeader': self.request.get(u'proxyHeader'),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
|
@ -18,15 +18,14 @@
|
||||||
# ----------------------------------------------------------------------------
|
# ----------------------------------------------------------------------------
|
||||||
|
|
||||||
from __future__ import absolute_import, division, print_function
|
from __future__ import absolute_import, division, print_function
|
||||||
|
|
||||||
__metaclass__ = type
|
__metaclass__ = type
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
# Documentation
|
# Documentation
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
ANSIBLE_METADATA = {'metadata_version': '1.1',
|
ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
|
||||||
'status': ["preview"],
|
|
||||||
'supported_by': 'community'}
|
|
||||||
|
|
||||||
DOCUMENTATION = '''
|
DOCUMENTATION = '''
|
||||||
---
|
---
|
||||||
|
@ -303,11 +302,7 @@ import json
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
module = GcpModule(
|
module = GcpModule(argument_spec=dict(filters=dict(type='list', elements='str')))
|
||||||
argument_spec=dict(
|
|
||||||
filters=dict(type='list', elements='str')
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
if not module.params['scopes']:
|
if not module.params['scopes']:
|
||||||
module.params['scopes'] = ['https://www.googleapis.com/auth/compute']
|
module.params['scopes'] = ['https://www.googleapis.com/auth/compute']
|
||||||
|
@ -317,9 +312,7 @@ def main():
|
||||||
items = items.get('items')
|
items = items.get('items')
|
||||||
else:
|
else:
|
||||||
items = []
|
items = []
|
||||||
return_value = {
|
return_value = {'items': items}
|
||||||
'items': items
|
|
||||||
}
|
|
||||||
module.exit_json(**return_value)
|
module.exit_json(**return_value)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -18,15 +18,14 @@
|
||||||
# ----------------------------------------------------------------------------
|
# ----------------------------------------------------------------------------
|
||||||
|
|
||||||
from __future__ import absolute_import, division, print_function
|
from __future__ import absolute_import, division, print_function
|
||||||
|
|
||||||
__metaclass__ = type
|
__metaclass__ = type
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
# Documentation
|
# Documentation
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
ANSIBLE_METADATA = {'metadata_version': '1.1',
|
ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
|
||||||
'status': ["preview"],
|
|
||||||
'supported_by': 'community'}
|
|
||||||
|
|
||||||
DOCUMENTATION = '''
|
DOCUMENTATION = '''
|
||||||
---
|
---
|
||||||
|
@ -223,7 +222,7 @@ def main():
|
||||||
port=dict(type='int'),
|
port=dict(type='int'),
|
||||||
request_path=dict(type='str'),
|
request_path=dict(type='str'),
|
||||||
timeout_sec=dict(type='int', aliases=['timeout_seconds']),
|
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'port': module.params.get('port'),
|
||||||
u'requestPath': module.params.get('request_path'),
|
u'requestPath': module.params.get('request_path'),
|
||||||
u'timeoutSec': module.params.get('timeout_sec'),
|
u'timeoutSec': module.params.get('timeout_sec'),
|
||||||
u'unhealthyThreshold': module.params.get('unhealthy_threshold')
|
u'unhealthyThreshold': module.params.get('unhealthy_threshold'),
|
||||||
}
|
}
|
||||||
return_vals = {}
|
return_vals = {}
|
||||||
for k, v in request.items():
|
for k, v in request.items():
|
||||||
|
@ -319,8 +318,8 @@ def return_if_object(module, response, kind, allow_not_found=False):
|
||||||
try:
|
try:
|
||||||
module.raise_for_status(response)
|
module.raise_for_status(response)
|
||||||
result = response.json()
|
result = response.json()
|
||||||
except getattr(json.decoder, 'JSONDecodeError', ValueError) as inst:
|
except getattr(json.decoder, 'JSONDecodeError', ValueError):
|
||||||
module.fail_json(msg="Invalid JSON response with error: %s" % inst)
|
module.fail_json(msg="Invalid JSON response with error: %s" % response.text)
|
||||||
|
|
||||||
if navigate_hash(result, ['error', 'errors']):
|
if navigate_hash(result, ['error', 'errors']):
|
||||||
module.fail_json(msg=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'port': response.get(u'port'),
|
||||||
u'requestPath': response.get(u'requestPath'),
|
u'requestPath': response.get(u'requestPath'),
|
||||||
u'timeoutSec': response.get(u'timeoutSec'),
|
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_id = navigate_hash(op_result, ['name'])
|
||||||
op_uri = async_op_url(module, {'op_id': op_id})
|
op_uri = async_op_url(module, {'op_id': op_id})
|
||||||
while status != 'DONE':
|
while status != 'DONE':
|
||||||
raise_if_errors(op_result, ['error', 'errors'], 'message')
|
raise_if_errors(op_result, ['error', 'errors'], module)
|
||||||
time.sleep(1.0)
|
time.sleep(1.0)
|
||||||
op_result = fetch_resource(module, op_uri, 'compute#operation')
|
op_result = fetch_resource(module, op_uri, 'compute#operation')
|
||||||
status = navigate_hash(op_result, ['status'])
|
status = navigate_hash(op_result, ['status'])
|
||||||
|
|
|
@ -18,15 +18,14 @@
|
||||||
# ----------------------------------------------------------------------------
|
# ----------------------------------------------------------------------------
|
||||||
|
|
||||||
from __future__ import absolute_import, division, print_function
|
from __future__ import absolute_import, division, print_function
|
||||||
|
|
||||||
__metaclass__ = type
|
__metaclass__ = type
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
# Documentation
|
# Documentation
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
ANSIBLE_METADATA = {'metadata_version': '1.1',
|
ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
|
||||||
'status': ["preview"],
|
|
||||||
'supported_by': 'community'}
|
|
||||||
|
|
||||||
DOCUMENTATION = '''
|
DOCUMENTATION = '''
|
||||||
---
|
---
|
||||||
|
@ -149,11 +148,7 @@ import json
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
module = GcpModule(
|
module = GcpModule(argument_spec=dict(filters=dict(type='list', elements='str')))
|
||||||
argument_spec=dict(
|
|
||||||
filters=dict(type='list', elements='str')
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
if not module.params['scopes']:
|
if not module.params['scopes']:
|
||||||
module.params['scopes'] = ['https://www.googleapis.com/auth/compute']
|
module.params['scopes'] = ['https://www.googleapis.com/auth/compute']
|
||||||
|
@ -163,9 +158,7 @@ def main():
|
||||||
items = items.get('items')
|
items = items.get('items')
|
||||||
else:
|
else:
|
||||||
items = []
|
items = []
|
||||||
return_value = {
|
return_value = {'items': items}
|
||||||
'items': items
|
|
||||||
}
|
|
||||||
module.exit_json(**return_value)
|
module.exit_json(**return_value)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue