dalen / puppet-puppetdbquery

Query functions for PuppetDB

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support for the v4 api ?

Ziaunys opened this issue · comments

PuppetDB 3.1 no longer supports the v1, v2, and v3 API versions so I was wondering if there are plans to add support for v4.

Maybe something like this?

      # Logic to support PuppetDB API versions 3 and 4
      # and the associated PuppetDB terminus interfaces
      if Puppet::Util::Puppetdb.config.respond_to?("server_urls")
        uri = URI(Puppet::Util::Puppetdb.config.server_urls.first)
        server = uri.host
        port = uri.port
        endpoint = "/pdb/query/v4/resources"
      else
        server = Puppet::Util::Puppetdb.server
        port = Puppet::Util::Puppetdb.port
        endpoint = "/v3/resources"
      end

Though that won't handle the key name changes.

Will also need to change all instances of select- to select_ as the key names have changed in v4.

https://docs.puppetlabs.com/puppetdb/3.0/api/query/v4/query.html#query-strings

👍 . Is there any plan to support the v4 API in a near future ?

Looks like partial support was added in e20eea8.

I submitted pull request #62

It replaces

Puppet::Util:Puppetdb.server
Puppet::Util:Puppetdb.port

with

uri = URI(Puppet::Util::Puppetdb.config.server_urls.first)
uri.host
uri.port

I just pushed the release of 2.0.0 now. And it actually has full support for structured facts as well :)
Hope it works well (it does in my testing). But report any bugs you find.