mirror of
https://github.com/ansible-collections/google.cloud.git
synced 2025-04-25 12:21:25 -07:00
GCP MagicModules bug fixes (#47285)
Closes: #46930 #46929 #46928 #46927 #46926 #46925 #46924 #46923 #46922 #46921 #46920 #46919 #46918 #46917 #46916 #46915 #46914 #46913 #46912 #46911 #46910 #46909 #46908 #46907 #46906 #46905 #46903 #46902 #46901 #46900 #46899 #46898 #46897 #46896 #46895 #46894 #46893 #46892 #46891 #46890 #46889 #46888 #46887 #46886 #46885 #46884 #46883 #46882 #46881 #46880 #46879 #46878 #46877 #46876 #46875 #46874 #46873 #46872 #46871 #46870 #46869 #46868 #46867 #46866 #46865 #46864 #46863 #46862 #46861 #46860 #46859 #46858 #46857 #46856 #46855 #46854 #46853 #46852
This commit is contained in:
parent
84f0e2c5b2
commit
5c97cc1da0
78 changed files with 2531 additions and 1137 deletions
|
@ -99,7 +99,7 @@ EXAMPLES = '''
|
|||
cost_center: ti-1700004
|
||||
config: regional-us-central1
|
||||
project: "test_project"
|
||||
auth_kind: "service_account"
|
||||
auth_kind: "serviceaccount"
|
||||
service_account_file: "/tmp/auth.pem"
|
||||
state: present
|
||||
'''
|
||||
|
@ -117,13 +117,13 @@ RETURN = '''
|
|||
- A reference to the instance configuration.
|
||||
returned: success
|
||||
type: str
|
||||
display_name:
|
||||
displayName:
|
||||
description:
|
||||
- The descriptive name for this instance as it appears in UIs. Must be unique per
|
||||
project and between 4 and 30 characters in length.
|
||||
returned: success
|
||||
type: str
|
||||
node_count:
|
||||
nodeCount:
|
||||
description:
|
||||
- The number of nodes allocated to this instance.
|
||||
returned: success
|
||||
|
@ -189,7 +189,8 @@ def main():
|
|||
if fetch:
|
||||
if state == 'present':
|
||||
if is_different(module, fetch):
|
||||
fetch = update(module, self_link(module))
|
||||
update(module, self_link(module))
|
||||
fetch = fetch_resource(module, self_link(module))
|
||||
changed = True
|
||||
else:
|
||||
delete(module, self_link(module))
|
||||
|
@ -238,9 +239,9 @@ def resource_to_request(module):
|
|||
return return_vals
|
||||
|
||||
|
||||
def fetch_resource(module, link):
|
||||
def fetch_resource(module, link, allow_not_found=True):
|
||||
auth = GcpSession(module, 'spanner')
|
||||
return return_if_object(module, auth.get(link))
|
||||
return return_if_object(module, auth.get(link), allow_not_found)
|
||||
|
||||
|
||||
def self_link(module):
|
||||
|
@ -251,9 +252,9 @@ def collection(module):
|
|||
return "https://spanner.googleapis.com/v1/projects/{project}/instances".format(**module.params)
|
||||
|
||||
|
||||
def return_if_object(module, response):
|
||||
def return_if_object(module, response, allow_not_found=False):
|
||||
# If not found, return nothing.
|
||||
if response.status_code == 404:
|
||||
if allow_not_found and response.status_code == 404:
|
||||
return None
|
||||
|
||||
# If no content, return nothing.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue