mirror of
https://github.com/ansible-collections/google.cloud.git
synced 2025-04-06 10:50:28 -07:00
Native Update Mask support (#176)
<!-- This change is generated by MagicModules. --> /cc @rambleraptor
This commit is contained in:
parent
d75a53e0e1
commit
3a8363cfa7
1 changed files with 20 additions and 3 deletions
|
@ -296,7 +296,7 @@ def main():
|
|||
if fetch:
|
||||
if state == 'present':
|
||||
if is_different(module, fetch):
|
||||
update(module, self_link(module))
|
||||
update(module, self_link(module), fetch)
|
||||
fetch = fetch_resource(module, self_link(module))
|
||||
changed = True
|
||||
else:
|
||||
|
@ -320,8 +320,25 @@ def create(module, link):
|
|||
return wait_for_operation(module, auth.post(link, resource_to_request(module)))
|
||||
|
||||
|
||||
def update(module, link):
|
||||
module.fail_json(msg="Instance cannot be edited")
|
||||
def update(module, link, fetch):
|
||||
auth = GcpSession(module, 'redis')
|
||||
params = {'updateMask': updateMask(resource_to_request(module), response_to_hash(module, fetch))}
|
||||
request = resource_to_request(module)
|
||||
del request['name']
|
||||
return wait_for_operation(module, auth.patch(link, request, params=params))
|
||||
|
||||
|
||||
def updateMask(request, response):
|
||||
update_mask = []
|
||||
if request.get('displayName') != response.get('displayName'):
|
||||
update_mask.append('displayName')
|
||||
if request.get('labels') != response.get('labels'):
|
||||
update_mask.append('labels')
|
||||
if request.get('redisConfigs') != response.get('redisConfigs'):
|
||||
update_mask.append('redisConfigs')
|
||||
if request.get('memorySizeGb') != response.get('memorySizeGb'):
|
||||
update_mask.append('memorySizeGb')
|
||||
return ','.join(update_mask)
|
||||
|
||||
|
||||
def delete(module, link):
|
||||
|
|
Loading…
Add table
Reference in a new issue