def _execute(cls, data, config): for web_hook in config: data = cls._pre_execute_web_hook(data=data, config=web_hook) try: if web_hook['method'] == 'POST': safe_request(url=web_hook['url'], method=web_hook['method'], json=data) else: safe_request(url=web_hook['url'], method=web_hook['method'], params=data) except RequestException: logger.warning("Could not send web hook, execption.", exc_info=True)
def _execute(cls, data, config): for web_hook in config: data = cls._pre_execute_web_hook(data=data, config=web_hook) if web_hook['method'] == 'POST': safe_request(url=web_hook['url'], method=web_hook['method'], json=data) else: safe_request(url=web_hook['url'], method=web_hook['method'], params=data)
def exchange_token(self, request, wizard, code): data = self.get_token_params( code=code, redirect_uri=wizard.redirect_url(request=request), ) response = safe_request(self.access_token_url, data=data) content = response.content.decode() if response.headers['Content-Type'].startswith('application/x-www-form-urlencoded'): return dict(parse_qsl(content)) return loads(content)
def run(cls): response = safe_request('', 'GET') status_code = response.status_code if status_code == 200: result = Result() else: result = Result( message='Service is not healthy, response {}'.format( status_code), severity=Result.ERROR) return {'STREAMS': result}