Big refactor of the PuppetDB API, part 2