pypuppetdb/api.py: POST query in body of request
pypuppetdb/api.py: POST query in body of request

PuppetDB will ignore query and filter specifications if the
request is sent using POST and the query is sent in the
querystring of the URI. Sending a POST request to PuppetDB
with a query requires sending it in the body of the request.

This is not specifically documented that we have found, but
is implied by the examples on the puppetdb documentation. It
has been emperically tested, and our testing has shown this
to be the case.

As an example, take a request to puppetdb for a specific
node:
  `db.nodes(query='["=", "certname", "vm1.broker.dev"]')`

If this request is sent as a POST, but not specifying that
the query should be in the body, then the request will form
encode the query in the URI, and PuppetDB will return the
list of all nodes, rather than the specific node.

If this request is sent as a POST, and we specify the query
should be in the body, then the PuppetDB will return only
the node that matches the certname.

In order to send a POST request with the query in the body,
requests requires that the parameters be JSON encoded and
the JSON data passed as the `data` paramter to the post()
method.

Co-authored-by: Bill Ward <c692d6a10598e0a801576fdd4ecf3c37e45bfbc4@admintome.com>

voxpupuli/pypuppetdb,puppet-community/pypuppetdb