def _get(self, scheme, host, port, path, assert_key=None):
        """
        Execute a ES API call. Convert response into JSON and
        optionally assert its structure.
        """
        url = '%s://%s:%i/%s' % (scheme, host, port, path)
        try:
            request = urllib2.Request(url)
            if self.config['user'] and self.config['password']:
                base64string = base64.standard_b64encode(
                    '%s:%s' % (self.config['user'], self.config['password']))
                request.add_header("Authorization", "Basic %s" % base64string)
            response = urllib2.urlopen(request)
        except Exception as err:
            self.log.error("%s: %s" % (url, err))
            return False

        try:
            doc = json.load(response)
        except (TypeError, ValueError):
            self.log.error("Unable to parse response from elasticsearch as a" +
                           " json object")
            return False

        if assert_key and assert_key not in doc:
            self.log.error("Bad response from elasticsearch, expected key "
                           "'%s' was missing for %s" % (assert_key, url))
            return False
        return doc

        Execute a ES API call. Convert response into JSON and
        optionally assert its structure.
        
src/collectors/elasticsearch/elasticsearch.py