Merge pull request #654 from lsieradzki/bugfix/issue-653

https://github.com/ansible-collections/google.cloud/issues/653
This commit is contained in:
Chris Hawk 2024-11-07 11:38:21 -08:00 committed by GitHub
commit e23c44c612
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 9 additions and 4 deletions

View file

@ -0,0 +1,2 @@
bugfixes:
- gcp_pubsub_subscription - improper subscription uprade PATCH request

View file

@ -634,8 +634,9 @@ def create(module, link):
def update(module, link, fetch):
auth = GcpSession(module, 'pubsub')
params = {'updateMask': updateMask(resource_to_request(module), response_to_hash(module, fetch))}
request = resource_to_request(module)
del request['name']
subscription = resource_to_request(module)
del subscription['name']
request = {'subscription': subscription}
return return_if_object(module, auth.patch(link, request, params=params))
@ -651,7 +652,7 @@ def updateMask(request, response):
update_mask.append('messageRetentionDuration')
if request.get('retainAckedMessages') != response.get('retainAckedMessages'):
update_mask.append('retainAckedMessages')
if request.get('expirationPolicy') != response.get('expirationPolicy'):
if request.get('expirationPolicy') and request.get('expirationPolicy') != response.get('expirationPolicy'):
update_mask.append('expirationPolicy')
if request.get('deadLetterPolicy') != response.get('deadLetterPolicy'):
update_mask.append('deadLetterPolicy')
@ -838,7 +839,9 @@ class SubscriptionExpirationpolicy(object):
self.request = {}
def to_request(self):
return remove_nones_from_dict({u'ttl': self.request.get('ttl')})
ttl = self.request.get('ttl')
ttl = None if ttl == "" else ttl
return remove_nones_from_dict({u'ttl': ttl})
def from_response(self):
return remove_nones_from_dict({u'ttl': self.request.get(u'ttl')})