Bug fixes for gcp_compute_address (#42704)

This commit is contained in:
Alex Stephen 2018-08-13 07:50:04 -07:00 committed by Ryan Brown
parent aac668ee1f
commit 4ecdf11aaa
4 changed files with 130 additions and 93 deletions

View file

@ -95,6 +95,13 @@ class GcpSession(object):
except getattr(requests.exceptions, 'RequestException') as inst:
self.module.fail_json(msg=inst.message)
def patch(self, url, body=None, **kwargs):
kwargs.update({'json': body, 'headers': self._headers()})
try:
return self.session().patch(url, **kwargs)
except getattr(requests.exceptions, 'RequestException') as inst:
self.module.fail_json(msg=inst.message)
def session(self):
return AuthorizedSession(
self._credentials().with_scopes(self.module.params['scopes']))
@ -106,9 +113,6 @@ class GcpSession(object):
if not HAS_GOOGLE_LIBRARIES:
self.module.fail_json(msg="Please install the google-auth library")
if 'auth_kind' not in self.module.params:
self.module.fail_json(msg="Auth kind parameter is missing")
if self.module.params.get('service_account_email') is not None and self.module.params['auth_kind'] != 'machineaccount':
self.module.fail_json(
msg="Service Acccount Email only works with Machine Account-based authentication"