Add `com.puppetlabs.time` namespace, time utility functions

This commit adds a new namespace containing some time-related utility
functions.

In particular, it adds a function `parse-period` which,
given a (semi-) human-readable string representation of a duration
of time, will parse the string and return an instance of joda time's
`Period` class.  (so, e.g., `(parse-period "2d")` returns a joda time
`Period` representing 2 days).

It also adds some helper functions that will convert `Period`
instances to other units of time.
Add some docs, preconds, and postconds
Merge pull request #363 from cprice-puppet/feature/master/time-util-fns

Add `com.puppetlabs.time` namespace, time utility functions
Add HTTP endpoint for /facts/:name/:value

This will let you collect all the facts across a population that have a
particular name and value, like "give me all the facts you know about
with a name of 'operatingsystem' and a value of 'Debian'". It's an easy
way to find all the hosts with that fact, without having to do a big
query.

Signed-off-by: Deepak Giridharagopal <deepak@puppetlabs.com>
Merge pull request #366 from grimradical/fact-name-rest

Add HTTP endpoint for /facts/:name/:value
Explicitly fail when trying to make a subquery against /v1/nodes

This lets the user know that their query isn't necessarily invalid, but
is just being run against the wrong version of the API.

Also quoted the operator in a few error messages ("Operator in is not
supported" is confusing) and fixed a keyword vs. string issue from a
mass find/replace.
Add subquery support for nodes

This works exactly as for facts and resources. There is no
"select-nodes" operator, however, as "extract" provides effectively the
same functionality.

Also, the v2 node query API now supports queries on "name", referring to
the name of the node.
Improve unknown field error message for resources
Add support for regexp comparison to /v2/nodes
Document the new v2 nodes query API
Fix json parsing for auto-deactivation of nodes during db gc

The command submission for "deactivate node" in the database
garbage collection loop was not json-serializing the node
name quite as many times as all of the other uses of that
command, so it was failing.

This commit adds in the extra JSON serialization and should
get things working again.  We might at some point want to
remove all of these seemingly redundant serializations
from all of the uses of this command, but this seemed like
the lower-impact change for the time being.
Merge pull request #365 from nicklewis/node-subquery

Add subquery support for nodes
Merge pull request #367 from cprice-puppet/bug/master/fix-auto-deactivation-during-db-gc

Fix json parsing for auto-deactivation of nodes during db gc
Garbage collection for reports

This commit does the following:

* Introduces a function for deleting reports that
  are older than a specified number of days.
* Adds a `report-ttl` config param
* Adds a `node-ttl` config param and documents it as the preferred
  setting, while maintaining backward compatibility with the
  `node-ttl-days` setting
* Calls report cleanup from the `sweep-database` function so that
  reports will be cleaned up periodically.
* Adds unit tests, acceptance tests, and docs to all of the above.
New time functions for converting time intervals to readable strings

This commit adds some additional functions to the new `time`
namespace; these functions are for converting a `Period` to
a normalized, human-readable String.
Improve log message for stale report/node sweep

Prior to this commit, we were converting the TTL values to days
before logging them during the node/report cleanup.  Now that
we are accepting finer-grained intervals for configuring these
fields, we may as well log them in a more readable format.
Decrease default report-ttl from 30 days to 7 days
Change `delete-reports-older-than!` to accept a datetime

Instead of accepting a number of seconds and then calculating a
date/time based on that value, the `delete-reports-older-than!`
function now accepts a date/time instance directly.  This allows
the callers to calculate the date/time based on whatever criteria
they see fit.
Reorganize report/event test namespaces

This commit creates some namespaces inside of `testutils` to hold
test utility functions for reports and events.  This allows us to
get rid of some duplicated utility functions and to put the actual
tests in the right places; prior to this there were a few tests that
should have been in the `storage` namespace that were not, simply
because they relied on some utility functions that they couldn't
easily access.
Fix typo in docstring