(PDB-658) Move environments endpoint to the query engine

Needed to add support for an empty query to the engine. This was needed
to query for ALL environments.