def _rest_request_to_json(self, address, object_path, service_name, *args, **kwargs):
    '\n        Query the given URL and return the JSON response\n        '
    response_json = None
    service_check_tags = [('url:%s' % self._get_url_base(address))]
    url = address
    if object_path:
        url = self._join_url_dir(url, object_path)
    if args:
        for directory in args:
            url = self._join_url_dir(url, directory)
    self.log.debug(('Attempting to connect to "%s"' % url))
    if kwargs:
        query = '&'.join(['{0}={1}'.format(key, value) for (key, value) in kwargs.iteritems()])
        url = urljoin(url, ('?' + query))
    try:
        response = requests.get(url, timeout=self.default_integration_http_timeout)
        response.raise_for_status()
        response_json = response.json()
    except Timeout as e:
        self.service_check(service_name, AgentCheck.CRITICAL, tags=service_check_tags, message='Request timeout: {0}, {1}'.format(url, e))
        raise
    except (HTTPError, InvalidURL, ConnectionError) as e:
        self.service_check(service_name, AgentCheck.CRITICAL, tags=service_check_tags, message='Request failed: {0}, {1}'.format(url, e))
        raise
    except JSONDecodeError as e:
        self.service_check(service_name, AgentCheck.CRITICAL, tags=service_check_tags, message='JSON Parse failed: {0}, {1}'.format(url, e))
        raise
    except ValueError as e:
        self.service_check(service_name, AgentCheck.CRITICAL, tags=service_check_tags, message=str(e))
        raise
    return response_json
Query the given URL and return the JSON response
def _rest_request_to_json(self, address, object_path, service_name, *args, **kwargs):
    '\n        \n        '
    response_json = None
    service_check_tags = [('url:%s' % self._get_url_base(address))]
    url = address
    if object_path:
        url = self._join_url_dir(url, object_path)
    if args:
        for directory in args:
            url = self._join_url_dir(url, directory)
    self.log.debug(('Attempting to connect to "%s"' % url))
    if kwargs:
        query = '&'.join(['{0}={1}'.format(key, value) for (key, value) in kwargs.iteritems()])
        url = urljoin(url, ('?' + query))
    try:
        response = requests.get(url, timeout=self.default_integration_http_timeout)
        response.raise_for_status()
        response_json = response.json()
    except Timeout as e:
        self.service_check(service_name, AgentCheck.CRITICAL, tags=service_check_tags, message='Request timeout: {0}, {1}'.format(url, e))
        raise
    except (HTTPError, InvalidURL, ConnectionError) as e:
        self.service_check(service_name, AgentCheck.CRITICAL, tags=service_check_tags, message='Request failed: {0}, {1}'.format(url, e))
        raise
    except JSONDecodeError as e:
        self.service_check(service_name, AgentCheck.CRITICAL, tags=service_check_tags, message='JSON Parse failed: {0}, {1}'.format(url, e))
        raise
    except ValueError as e:
        self.service_check(service_name, AgentCheck.CRITICAL, tags=service_check_tags, message=str(e))
        raise
    return response_json