def post_resource(self, api_path, data, **kwargs):
"""
Helper method for HTTP POST API requests.
Args:
api_path(str): REST API path
data: JSON data for POST request
Keyword Args:
kwargs: keyword args used for replacing items in the API path
"""
post_headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
**self.headers
}
url = self.build_api_url(
api_path.format(
tenant=self.tenant,
controllerId=self.controller_id,
**kwargs))
self.logger.debug('POST {}'.format(url))
with aiohttp.Timeout(self.timeout):
async with self.session.post(url, headers=post_headers,
data=json.dumps(data)) as resp:
await self.check_http_status(resp)
评论列表
文章目录