mirror of
https://github.com/ansible-collections/google.cloud.git
synced 2025-04-19 01:11:21 -07:00
Ansible Storage Upload/Download
This commit is contained in:
parent
daaccb8079
commit
72cc27fec1
2 changed files with 19 additions and 27 deletions
|
@ -87,25 +87,16 @@ class GcpSession(object):
|
|||
except getattr(requests.exceptions, 'RequestException') as inst:
|
||||
self.module.fail_json(msg=inst.message)
|
||||
|
||||
def post(self, url, body=None, headers=None, **kwargs):
|
||||
if headers:
|
||||
headers = self.merge_dictionaries(headers, self._headers())
|
||||
else:
|
||||
headers = self._headers()
|
||||
|
||||
def post(self, url, body=None, headers={}, **kwargs):
|
||||
kwargs.update({'json': body, 'headers': self._merge_dictionaries(headers, self._headers())})
|
||||
try:
|
||||
return self.session().post(url, json=body, headers=headers)
|
||||
return self.session().post(url, data=file_contents, headers=headers)
|
||||
except getattr(requests.exceptions, 'RequestException') as inst:
|
||||
self.module.fail_json(msg=inst.message)
|
||||
|
||||
def post_contents(self, url, file_contents=None, headers=None, **kwargs):
|
||||
if headers:
|
||||
headers = self.merge_dictionaries(headers, self._headers())
|
||||
else:
|
||||
headers = self._headers()
|
||||
|
||||
def post_contents(self, url, file_contents=None, headers={}, **kwargs):
|
||||
try:
|
||||
return self.session().post(url, data=file_contents, headers=headers)
|
||||
return self.session().post(url, data=file_contents, headers=self._headers())
|
||||
except getattr(requests.exceptions, 'RequestException') as inst:
|
||||
self.module.fail_json(msg=inst.message)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue