def _query(self, endpoint, path=None, query=None,<EOL>order_by=None, limit=None, offset=None, include_total=False,<EOL>summarize_by=None, count_by=None, count_filter=None,<EOL>request_method='<STR_LIT:GET>'):
log.debug('<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'.format(endpoint, path, query, limit,<EOL>offset, summarize_by, count_by,<EOL>count_filter))<EOL>url = self._url(endpoint, path=path)<EOL>payload = {}<EOL>if query is not None:<EOL><INDENT>payload['<STR_LIT>'] = query<EOL><DEDENT>if order_by is not None:<EOL><INDENT>payload[PARAMETERS['<STR_LIT>']] = order_by<EOL><DEDENT>if limit is not None:<EOL><INDENT>payload['<STR_LIT>'] = limit<EOL><DEDENT>if include_total is True:<EOL><INDENT>payload[PARAMETERS['<STR_LIT>']] =json.dumps(include_total)<EOL><DEDENT>if offset is not None:<EOL><INDENT>payload['<STR_LIT>'] = offset<EOL><DEDENT>if summarize_by is not None:<EOL><INDENT>payload[PARAMETERS['<STR_LIT>']] = summarize_by<EOL><DEDENT>if count_by is not None:<EOL><INDENT>payload[PARAMETERS['<STR_LIT>']] = count_by<EOL><DEDENT>if count_filter is not None:<EOL><INDENT>payload[PARAMETERS['<STR_LIT>']] = count_filter<EOL><DEDENT>if not (payload):<EOL><INDENT>payload = None<EOL><DEDENT>if not self.token:<EOL><INDENT>auth = (self.username, self.password)<EOL><DEDENT>else:<EOL><INDENT>auth = None<EOL><DEDENT>try:<EOL><INDENT>if request_method.upper() == '<STR_LIT:GET>':<EOL><INDENT>r = self._session.get(url, params=payload,<EOL>verify=self.ssl_verify,<EOL>cert=(self.ssl_cert, self.ssl_key),<EOL>timeout=self.timeout,<EOL>auth=auth)<EOL><DEDENT>elif request_method.upper() == '<STR_LIT:POST>':<EOL><INDENT>r = self._session.post(url,<EOL>data=json.dumps(payload, default=str),<EOL>verify=self.ssl_verify,<EOL>cert=(self.ssl_cert, self.ssl_key),<EOL>timeout=self.timeout,<EOL>auth=auth)<EOL><DEDENT>else:<EOL><INDENT>log.error("<STR_LIT>".format(<EOL>request_method))<EOL>raise APIError<EOL><DEDENT>r.raise_for_status()<EOL>if '<STR_LIT>' in r.headers:<EOL><INDENT>self.last_total = r.headers['<STR_LIT>']<EOL><DEDENT>else:<EOL><INDENT>self.last_total = None<EOL><DEDENT>json_body = r.json()<EOL>if json_body is not None:<EOL><INDENT>return json_body<EOL><DEDENT>else:<EOL><INDENT>del json_body<EOL>raise EmptyResponseError<EOL><DEDENT><DEDENT>except requests.exceptions.Timeout:<EOL><INDENT>log.error("<STR_LIT>".format(ERROR_STRINGS['<STR_LIT>'],<EOL>self.host, self.port,<EOL>self.protocol.upper()))<EOL>raise<EOL><DEDENT>except requests.exceptions.ConnectionError:<EOL><INDENT>log.error("<STR_LIT>".format(ERROR_STRINGS['<STR_LIT>'],<EOL>self.host, self.port,<EOL>self.protocol.upper()))<EOL>raise<EOL><DEDENT>except requests.exceptions.HTTPError as err:<EOL><INDENT>log.error("<STR_LIT>".format(err.response.text,<EOL>self.host, self.port,<EOL>self.protocol.upper()))<EOL>raise<EOL><DEDENT>
This method actually querries PuppetDB. Provided an endpoint and an
        optional path and/or query it will fire a request at PuppetDB. If
        PuppetDB can be reached and answers within the timeout we'll decode
        the response and give it back or raise for the HTTP Status Code
        PuppetDB gave back.

        :param endpoint: The PuppetDB API endpoint we want to query.
        :type endpoint: :obj:`string`
        :param path: An additional path if we don't wish to query the\
                bare endpoint.
        :type path: :obj:`string`
        :param query: (optional) A query to further narrow down the resultset.
        :type query: :obj:`string`
        :param order_by: (optional) Set the order parameters for the resultset.
        :type order_by: :obj:`string`
        :param limit: (optional) Tell PuppetDB to limit it's response to this\
                number of objects.
        :type limit: :obj:`int`
        :param offset: (optional) Tell PuppetDB to start it's response from\
                the given offset. This is useful for implementing pagination\
                but is not supported just yet.
        :type offset: :obj:`string`
        :param include_total: (optional) Include the total number of results
        :type order_by: :obj:`bool`
        :param summarize_by: (optional) Specify what type of object you'd like\
                to see counts at the event-counts and aggregate-event-counts \
                endpoints
        :type summarize_by: :obj:`string`
        :param count_by: (optional) Specify what type of object is counted
        :type count_by: :obj:`string`
        :param count_filter: (optional) Specify a filter for the results
        :type count_filter: :obj:`string`

        :raises: :class:`~pypuppetdb.errors.EmptyResponseError`

        :returns: The decoded response from PuppetDB
        :rtype: :obj:`dict` or :obj:`list`