Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug fixes for GCP (as of 2019-10-04T06:04:33+00:00) #63153

Merged
merged 1 commit into from
Oct 7, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
53 changes: 53 additions & 0 deletions lib/ansible/modules/cloud/google/gcp_bigquery_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,23 @@
required: false
default: US
type: str
default_encryption_configuration:
description:
- The default encryption key for all tables in the dataset. Once this property
is set, all newly-created partitioned tables in the dataset will have encryption
key set to this value, unless table creation request (or query) overrides the
key.
required: false
type: dict
version_added: '2.10'
suboptions:
kms_key_name:
description:
- Describes the Cloud KMS encryption key that will be used to protect destination
BigQuery table. The BigQuery Service Account associated with your project
requires access to this encryption key.
required: true
type: str
project:
description:
- The Google Cloud Platform project to use.
Expand Down Expand Up @@ -422,6 +439,22 @@
- Changing this forces a new resource to be created.
returned: success
type: str
defaultEncryptionConfiguration:
description:
- The default encryption key for all tables in the dataset. Once this property is
set, all newly-created partitioned tables in the dataset will have encryption
key set to this value, unless table creation request (or query) overrides the
key.
returned: success
type: complex
contains:
kmsKeyName:
description:
- Describes the Cloud KMS encryption key that will be used to protect destination
BigQuery table. The BigQuery Service Account associated with your project
requires access to this encryption key.
returned: success
type: str
'''

################################################################################
Expand Down Expand Up @@ -467,6 +500,7 @@ def main():
friendly_name=dict(type='str'),
labels=dict(type='dict'),
location=dict(default='US', type='str'),
default_encryption_configuration=dict(type='dict', options=dict(kms_key_name=dict(required=True, type='str'))),
)
)

Expand Down Expand Up @@ -528,6 +562,9 @@ def resource_to_request(module):
u'friendlyName': module.params.get('friendly_name'),
u'labels': module.params.get('labels'),
u'location': module.params.get('location'),
u'defaultEncryptionConfiguration': DatasetDefaultencryptionconfiguration(
module.params.get('default_encryption_configuration', {}), module
).to_request(),
}
return_vals = {}
for k, v in request.items():
Expand Down Expand Up @@ -606,6 +643,7 @@ def response_to_hash(module, response):
u'labels': response.get(u'labels'),
u'lastModifiedTime': response.get(u'lastModifiedTime'),
u'location': response.get(u'location'),
u'defaultEncryptionConfiguration': DatasetDefaultencryptionconfiguration(response.get(u'defaultEncryptionConfiguration', {}), module).from_response(),
}


Expand Down Expand Up @@ -688,5 +726,20 @@ def from_response(self):
return remove_nones_from_dict({u'datasetId': self.request.get(u'datasetId'), u'projectId': self.request.get(u'projectId')})


class DatasetDefaultencryptionconfiguration(object):
def __init__(self, request, module):
self.module = module
if request:
self.request = request
else:
self.request = {}

def to_request(self):
return remove_nones_from_dict({u'kmsKeyName': self.request.get('kms_key_name')})

def from_response(self):
return remove_nones_from_dict({u'kmsKeyName': self.request.get(u'kmsKeyName')})


if __name__ == '__main__':
main()
16 changes: 16 additions & 0 deletions lib/ansible/modules/cloud/google/gcp_bigquery_dataset_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,22 @@
- Changing this forces a new resource to be created.
returned: success
type: str
defaultEncryptionConfiguration:
description:
- The default encryption key for all tables in the dataset. Once this property
is set, all newly-created partitioned tables in the dataset will have encryption
key set to this value, unless table creation request (or query) overrides
the key.
returned: success
type: complex
contains:
kmsKeyName:
description:
- Describes the Cloud KMS encryption key that will be used to protect destination
BigQuery table. The BigQuery Service Account associated with your project
requires access to this encryption key.
returned: success
type: str
'''

################################################################################
Expand Down