mirror of
https://github.com/ansible-collections/google.cloud.git
synced 2025-07-27 15:11:33 -07:00
fix gcp_iam_role not updating
gcp_iam_role was not updating previously. The API uses a PATCH and not a PUT. Also fixing an accidental leftover diff from a bad merge. fixes #236.
This commit is contained in:
parent
d063d44b73
commit
2db181d084
6 changed files with 41 additions and 18 deletions
|
@ -107,12 +107,12 @@ class GcpSession(object):
|
|||
kwargs = {'json': body}
|
||||
return self.full_delete(url, **kwargs)
|
||||
|
||||
def put(self, url, body=None):
|
||||
def put(self, url, body=None, params=None):
|
||||
"""
|
||||
This method should be avoided in favor of full_put
|
||||
"""
|
||||
kwargs = {'json': body}
|
||||
return self.full_put(url, **kwargs)
|
||||
return self.full_put(url, **kwargs, params=params)
|
||||
|
||||
def patch(self, url, body=None, **kwargs):
|
||||
"""
|
||||
|
@ -305,7 +305,14 @@ class GcpModule(AnsibleModule):
|
|||
try:
|
||||
response.raise_for_status()
|
||||
except getattr(requests.exceptions, 'RequestException') as inst:
|
||||
self.fail_json(msg="GCP returned error: %s" % response.json())
|
||||
self.fail_json(
|
||||
msg="GCP returned error: %s" % response.json(),
|
||||
request={
|
||||
"url": response.request.url,
|
||||
"body": response.request.body,
|
||||
"method": response.request.method,
|
||||
}
|
||||
)
|
||||
|
||||
def _merge_dictionaries(self, a, b):
|
||||
new = a.copy()
|
||||
|
|
|
@ -255,7 +255,7 @@ def update(module, link, fetch):
|
|||
}
|
||||
request = resource_to_request(module)
|
||||
del request["name"]
|
||||
return return_if_object(module, auth.put(link, request, params=params))
|
||||
return return_if_object(module, auth.patch(link, request, params=params))
|
||||
|
||||
|
||||
def updateMask(request, response):
|
||||
|
|
|
@ -182,7 +182,7 @@ import json
|
|||
|
||||
def main():
|
||||
module = GcpModule(argument_spec=dict(
|
||||
page_size=dict(type='int')
|
||||
page_size=dict(type='int')
|
||||
))
|
||||
|
||||
if not module.params['scopes']:
|
||||
|
@ -200,7 +200,7 @@ def fetch_list(module, link):
|
|||
auth = GcpSession(module, 'resourcemanager')
|
||||
params = {}
|
||||
if "page_size" in module.params:
|
||||
params["pageSize"] = module.params.get("page_size")
|
||||
params["pageSize"] = module.params.get("page_size")
|
||||
return auth.list(link, return_if_object, array_name='projects', params=params)
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue