Exemplo n.º 1
0
 def _execute(cls, data: Dict, config: List[Dict]) -> None:
     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)
Exemplo n.º 2
0
 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)
Exemplo n.º 3
0
    def run(cls) -> Dict:
        response = safe_request('{}/healthz'.format(get_local_stream()), '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}
Exemplo n.º 4
0
    def run(cls) -> Dict:
        response = safe_request('{}/_health'.format(get_settings_ws_api_url()),
                                '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}