Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ __pycache__
*.tar.gz
venv/
changelogs/.plugin-cache.yaml
*.DS_Store*
2 changes: 2 additions & 0 deletions plugins/modules/gcp_compute_backend_bucket.py
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,7 @@
negative_caching_policy=dict(type='list', elements='dict', options=dict(code=dict(type='int'), ttl=dict(type='int'))),
cache_mode=dict(type='str'),
serve_while_stale=dict(type='int'),
bypass_cache_on_request_headers=dict(type='list', elements='dict', options=dict(header_name=dict(type='str'))),

Check warning on line 403 in plugins/modules/gcp_compute_backend_bucket.py

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Replace this constructor call with a literal.

See more on https://sonarcloud.io/project/issues?id=ansible-collections_google.cloud&issues=AZ53aa7j5WQG7-EhqPkM&open=AZ53aa7j5WQG7-EhqPkM&pullRequest=672

Check warning on line 403 in plugins/modules/gcp_compute_backend_bucket.py

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Replace this constructor call with a literal.

See more on https://sonarcloud.io/project/issues?id=ansible-collections_google.cloud&issues=AZ53aa7j5WQG7-EhqPkO&open=AZ53aa7j5WQG7-EhqPkO&pullRequest=672

Check warning on line 403 in plugins/modules/gcp_compute_backend_bucket.py

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Replace this constructor call with a literal.

See more on https://sonarcloud.io/project/issues?id=ansible-collections_google.cloud&issues=AZ53aa7j5WQG7-EhqPkN&open=AZ53aa7j5WQG7-EhqPkN&pullRequest=672
),
),
custom_response_headers=dict(type='list', elements='str'),
Expand Down Expand Up @@ -594,6 +595,7 @@
u'negativeCachingPolicy': BackendBucketNegativecachingpolicyArray(self.request.get('negative_caching_policy', []), self.module).to_request(),
u'cacheMode': self.request.get('cache_mode'),
u'serveWhileStale': self.request.get('serve_while_stale'),
u'bypassCacheOnRequestHeaders': self.request.get('bypass_cache_on_request_headers'),
}
)

Expand Down
36 changes: 32 additions & 4 deletions plugins/modules/gcp_compute_ssl_certificate.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
- The certificate in PEM format.
- The certificate chain must be no greater than 5 certs long.
- The chain must include at least one intermediate cert.
required: true
required: false
type: str
description:
description:
Expand All @@ -71,10 +71,23 @@
which cannot be a dash.
required: false
type: str
managed:
description:
- The configuration and status of a managed SSL certificate.
required: false
type: dict
type:
description:
- Specifies the type of SSL certificate, either "SELF_MANAGED" or "MANAGED". If not specified,
the certificate is self-managed and the fields certificate and privateKey are used.
choices:
- MANAGED
- SELF_MANAGED
type: str
private_key:
description:
- The write-only private key in PEM format.
required: true
required: false
type: str
project:
description:
Expand Down Expand Up @@ -209,6 +222,17 @@
- The write-only private key in PEM format.
returned: success
type: str
managed:
description:
- The configuration and status of a managed SSL certificate.
returned: success
type: dict
type:
description:
- Specifies the type of SSL certificate, either "SELF_MANAGED" or "MANAGED". If not specified,
the certificate is self-managed and the fields certificate and privateKey are used.
returned: success
type: str
'''

################################################################################
Expand All @@ -230,10 +254,12 @@
module = GcpModule(
argument_spec=dict(
state=dict(default='present', choices=['present', 'absent'], type='str'),
certificate=dict(required=True, type='str'),
certificate=dict(required=False, type='str'),

Check warning on line 257 in plugins/modules/gcp_compute_ssl_certificate.py

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Replace this constructor call with a literal.

See more on https://sonarcloud.io/project/issues?id=ansible-collections_google.cloud&issues=AZ53aa5W5WQG7-EhqPkI&open=AZ53aa5W5WQG7-EhqPkI&pullRequest=672
description=dict(type='str'),
name=dict(type='str'),
private_key=dict(required=True, type='str', no_log=True),
private_key=dict(required=False, type='str', no_log=True),

Check warning on line 260 in plugins/modules/gcp_compute_ssl_certificate.py

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Replace this constructor call with a literal.

See more on https://sonarcloud.io/project/issues?id=ansible-collections_google.cloud&issues=AZ53aa5W5WQG7-EhqPkJ&open=AZ53aa5W5WQG7-EhqPkJ&pullRequest=672
managed=dict(required=False, type='dict'),

Check warning on line 261 in plugins/modules/gcp_compute_ssl_certificate.py

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Replace this constructor call with a literal.

See more on https://sonarcloud.io/project/issues?id=ansible-collections_google.cloud&issues=AZ53aa5W5WQG7-EhqPkK&open=AZ53aa5W5WQG7-EhqPkK&pullRequest=672
type=dict(required=False, type='str'),

Check warning on line 262 in plugins/modules/gcp_compute_ssl_certificate.py

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Replace this constructor call with a literal.

See more on https://sonarcloud.io/project/issues?id=ansible-collections_google.cloud&issues=AZ53aa5W5WQG7-EhqPkL&open=AZ53aa5W5WQG7-EhqPkL&pullRequest=672
)
)

Expand Down Expand Up @@ -290,6 +316,8 @@
u'description': module.params.get('description'),
u'name': module.params.get('name'),
u'privateKey': module.params.get('private_key'),
u'managed': module.params.get('managed'),
u'type': module.params.get('type'),
}
return_vals = {}
for k, v in request.items():
Expand Down
54 changes: 51 additions & 3 deletions plugins/modules/gcp_sql_instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -843,6 +843,7 @@
backend_type=dict(type='str'),
connection_name=dict(type='str'),
database_version=dict(type='str'),
root_password=dict(type='str'),

Check warning on line 846 in plugins/modules/gcp_sql_instance.py

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Replace this constructor call with a literal.

See more on https://sonarcloud.io/project/issues?id=ansible-collections_google.cloud&issues=AZ53aa755WQG7-EhqPkP&open=AZ53aa755WQG7-EhqPkP&pullRequest=672
failover_replica=dict(type='dict', options=dict(name=dict(type='str'))),
instance_type=dict(type='str'),
ipv6_address=dict(type='str'),
Expand Down Expand Up @@ -890,9 +891,12 @@
),
),
tier=dict(type='str'),
edition=dict(type='str', choices=['ENTERPRISE', 'ENTERPRISE_PLUS']),

Check warning on line 894 in plugins/modules/gcp_sql_instance.py

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Replace this constructor call with a literal.

See more on https://sonarcloud.io/project/issues?id=ansible-collections_google.cloud&issues=AZ53aa755WQG7-EhqPkQ&open=AZ53aa755WQG7-EhqPkQ&pullRequest=672
deletion_protection_enabled=dict(type='bool'),
availability_type=dict(type='str'),
location_preference=dict(type='dict', options=dict(follow_gae_apps=dict(type='string'), zone=dict(type='str'), secondary_zone=dict(type='str'), kind=dict(type='str'))),

Check warning on line 897 in plugins/modules/gcp_sql_instance.py

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Replace this constructor call with a literal.

See more on https://sonarcloud.io/project/issues?id=ansible-collections_google.cloud&issues=AZ53aa755WQG7-EhqPkV&open=AZ53aa755WQG7-EhqPkV&pullRequest=672

Check warning on line 897 in plugins/modules/gcp_sql_instance.py

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Replace this constructor call with a literal.

See more on https://sonarcloud.io/project/issues?id=ansible-collections_google.cloud&issues=AZ53aa755WQG7-EhqPkS&open=AZ53aa755WQG7-EhqPkS&pullRequest=672

Check warning on line 897 in plugins/modules/gcp_sql_instance.py

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Replace this constructor call with a literal.

See more on https://sonarcloud.io/project/issues?id=ansible-collections_google.cloud&issues=AZ53aa755WQG7-EhqPkR&open=AZ53aa755WQG7-EhqPkR&pullRequest=672

Check warning on line 897 in plugins/modules/gcp_sql_instance.py

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Replace this constructor call with a literal.

See more on https://sonarcloud.io/project/issues?id=ansible-collections_google.cloud&issues=AZ53aa755WQG7-EhqPkU&open=AZ53aa755WQG7-EhqPkU&pullRequest=672

Check warning on line 897 in plugins/modules/gcp_sql_instance.py

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Replace this constructor call with a literal.

See more on https://sonarcloud.io/project/issues?id=ansible-collections_google.cloud&issues=AZ53aa755WQG7-EhqPkT&open=AZ53aa755WQG7-EhqPkT&pullRequest=672

Check warning on line 897 in plugins/modules/gcp_sql_instance.py

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Replace this constructor call with a literal.

See more on https://sonarcloud.io/project/issues?id=ansible-collections_google.cloud&issues=AZ53aa755WQG7-EhqPkW&open=AZ53aa755WQG7-EhqPkW&pullRequest=672
backup_configuration=dict(
type='dict', options=dict(enabled=dict(type='bool'), binary_log_enabled=dict(type='bool'), start_time=dict(type='str'))
type='dict', options=dict(enabled=dict(type='bool'), binary_log_enabled=dict(type='bool'), start_time=dict(type='str'), point_in_time_recovery_enabled=dict(type='bool'))

Check warning on line 899 in plugins/modules/gcp_sql_instance.py

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Replace this constructor call with a literal.

See more on https://sonarcloud.io/project/issues?id=ansible-collections_google.cloud&issues=AZ53aa755WQG7-EhqPka&open=AZ53aa755WQG7-EhqPka&pullRequest=672

Check warning on line 899 in plugins/modules/gcp_sql_instance.py

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Replace this constructor call with a literal.

See more on https://sonarcloud.io/project/issues?id=ansible-collections_google.cloud&issues=AZ53aa755WQG7-EhqPkb&open=AZ53aa755WQG7-EhqPkb&pullRequest=672

Check warning on line 899 in plugins/modules/gcp_sql_instance.py

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Replace this constructor call with a literal.

See more on https://sonarcloud.io/project/issues?id=ansible-collections_google.cloud&issues=AZ53aa755WQG7-EhqPkX&open=AZ53aa755WQG7-EhqPkX&pullRequest=672

Check warning on line 899 in plugins/modules/gcp_sql_instance.py

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Replace this constructor call with a literal.

See more on https://sonarcloud.io/project/issues?id=ansible-collections_google.cloud&issues=AZ53aa755WQG7-EhqPkY&open=AZ53aa755WQG7-EhqPkY&pullRequest=672

Check warning on line 899 in plugins/modules/gcp_sql_instance.py

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Replace this constructor call with a literal.

See more on https://sonarcloud.io/project/issues?id=ansible-collections_google.cloud&issues=AZ53aa755WQG7-EhqPkZ&open=AZ53aa755WQG7-EhqPkZ&pullRequest=672
),
user_labels=dict(type='dict'),
),
Expand Down Expand Up @@ -953,6 +957,7 @@
u'backendType': module.params.get('backend_type'),
u'connectionName': module.params.get('connection_name'),
u'databaseVersion': module.params.get('database_version'),
u'rootPassword': module.params.get('root_password'),
u'failoverReplica': InstanceFailoverreplica(module.params.get('failover_replica', {}), module).to_request(),
u'instanceType': module.params.get('instance_type'),
u'ipv6Address': module.params.get('ipv6_address'),
Expand Down Expand Up @@ -1216,9 +1221,12 @@
u'databaseFlags': InstanceDatabaseflagsArray(self.request.get('database_flags', []), self.module).to_request(),
u'ipConfiguration': InstanceIpconfiguration(self.request.get('ip_configuration', {}), self.module).to_request(),
u'tier': self.request.get('tier'),
u'edition': self.request.get('edition'),
u'deletionProtectionEnabled': self.request.get('deletion_protection_enabled'),
u'availabilityType': self.request.get('availability_type'),
u'backupConfiguration': InstanceBackupconfiguration(self.request.get('backup_configuration', {}), self.module).to_request(),
u'userLabels': self.request.get('user_labels'),
u'locationPreference': InstanceLocationPreference(self.request.get('location_preference', {}), self.module).to_request(),
}
)

Expand All @@ -1228,9 +1236,12 @@
u'databaseFlags': InstanceDatabaseflagsArray(self.request.get(u'databaseFlags', []), self.module).from_response(),
u'ipConfiguration': InstanceIpconfiguration(self.request.get(u'ipConfiguration', {}), self.module).from_response(),
u'tier': self.request.get(u'tier'),
u'edition': self.request.get('edition'),
u'deletionProtectionEnabled': self.request.get('deletion_protection_enabled'),
u'availabilityType': self.request.get(u'availabilityType'),
u'backupConfiguration': InstanceBackupconfiguration(self.request.get(u'backupConfiguration', {}), self.module).from_response(),
u'userLabels': self.request.get(u'userLabels'),
u'locationPreference': InstanceLocationPreference(self.request.get('location_preference', {}), self.module).from_response(),
}
)

Expand Down Expand Up @@ -1330,12 +1341,22 @@

def to_request(self):
return remove_nones_from_dict(
{u'enabled': self.request.get('enabled'), u'binaryLogEnabled': self.request.get('binary_log_enabled'), u'startTime': self.request.get('start_time')}
{
u'enabled': self.request.get('enabled'),
u'binaryLogEnabled': self.request.get('binary_log_enabled'),
u'startTime': self.request.get('start_time'),
u'pointInTimeRecoveryEnabled': self.request.get('binary_log_enabled'),
}
)

def from_response(self):
return remove_nones_from_dict(
{u'enabled': self.request.get(u'enabled'), u'binaryLogEnabled': self.request.get(u'binaryLogEnabled'), u'startTime': self.request.get(u'startTime')}
{
u'enabled': self.request.get(u'enabled'),
u'binaryLogEnabled': self.request.get(u'binaryLogEnabled'),
u'startTime': self.request.get('start_time'),
u'pointInTimeRecoveryEnabled': self.request.get('binary_log_enabled'),
}
)


Expand Down Expand Up @@ -1401,6 +1422,33 @@
}
)

class InstanceLocationPreference(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'followGaeApplication': self.request.get('follow_gae_application'),
u'zone': self.request.get('zone'),
u'secondaryZone': self.request.get('secondary_zone'),
u'kind': self.request.get('kind'),
}
)

def from_response(self):

Check warning on line 1443 in plugins/modules/gcp_sql_instance.py

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Update this function so that its implementation is not identical to to_request on line 1433.

See more on https://sonarcloud.io/project/issues?id=ansible-collections_google.cloud&issues=AZ53aa755WQG7-EhqPkc&open=AZ53aa755WQG7-EhqPkc&pullRequest=672
return remove_nones_from_dict(
{
u'followGaeApplication': self.request.get('follow_gae_application'),
u'zone': self.request.get('zone'),
u'secondaryZone': self.request.get('secondary_zone'),
u'kind': self.request.get('kind'),
}
)

if __name__ == '__main__':
main()