def _rest_request(self, url, object_path, service_name, requests_config, tags, *args, **kwargs):
        """
        Query the given URL and return the response
        """
        service_check_tags = ['url:%s' % self._get_url_base(url)] + tags

        if object_path:
            url = self._join_url_dir(url, object_path)

        # Load SSL configuration, if available.
        # ssl_verify can be a bool or a string
        # (http://docs.python-requests.org/en/latest/user/advanced/#ssl-cert-verification)
        if isinstance(requests_config.ssl_verify, bool) or isinstance(requests_config.ssl_verify, str):
            verify = requests_config.ssl_verify
        else:
            verify = None
        if requests_config.ssl_cert and requests_config.ssl_key:
            cert = (requests_config.ssl_cert, requests_config.ssl_key)
        elif requests_config.ssl_cert:
            cert = requests_config.ssl_cert
        else:
            cert = None

        # Add args to the url
        if args:
            for directory in args:
                url = self._join_url_dir(url, directory)

        # Add kwargs as arguments
        if kwargs:
            query = '&'.join(['{0}={1}'.format(key, value) for key, value in iteritems(kwargs)])
            url = urljoin(url, '?' + query)

        old_keytab_path = None
        if requests_config.kerberos_keytab:
            old_keytab_path = os.getenv('KRB5_CLIENT_KTNAME')
            os.environ['KRB5_CLIENT_KTNAME'] = requests_config.kerberos_keytab

        try:
            self.log.debug('Spark check URL: %s' % url)
            response = requests.get(url, auth=requests_config.auth, verify=verify, cert=cert)

            response.raise_for_status()

        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 ValueError as e:
            self.service_check(service_name, AgentCheck.CRITICAL, tags=service_check_tags, message=str(e))
            raise

        else:
            return response

        finally:
            if old_keytab_path is not None:
                os.environ['KRB5_CLIENT_KTNAME'] = old_keytab_path
Query the given URL and return the response