Class: Hieracles::Puppetdb::Request
- Inherits:
-
Object
- Object
- Hieracles::Puppetdb::Request
- Defined in:
- lib/hieracles/puppetdb/request.rb
Instance Method Summary collapse
- #events ⇒ Object
- #factnames ⇒ Object
- #facts(label, value) ⇒ Object
-
#initialize(options) ⇒ Request
constructor
A new instance of Request.
- #node_facts(fqdn, regex = //) ⇒ Object (also: #node_fact)
- #node_info(fqdn) ⇒ Object (also: #node_infos)
- #node_resources(fqdn, *args) ⇒ Object (also: #node_res)
- #resources(*args) ⇒ Object (also: #res)
- #same(name, fqdn) ⇒ Object
Constructor Details
Instance Method Details
#events ⇒ Object
59 60 61 |
# File 'lib/hieracles/puppetdb/request.rb', line 59 def events @client.request("events") end |
#factnames ⇒ Object
49 50 51 |
# File 'lib/hieracles/puppetdb/request.rb', line 49 def factnames() @client.request("fact-names") end |
#facts(label, value) ⇒ Object
34 35 36 37 |
# File 'lib/hieracles/puppetdb/request.rb', line 34 def facts(label, value) resp = @client.request("facts/#{label}/#{value}") extract_names resp end |
#node_facts(fqdn, regex = //) ⇒ Object Also known as: node_fact
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/hieracles/puppetdb/request.rb', line 14 def node_facts(fqdn, regex = //) resp = @client.request("nodes/#{fqdn}/facts") filter = Filter.new regex resp.data = resp.data.reduce({}) do |a, d| if filter.match(d['name']) a[d['name'].to_sym] = d['value'] end a end resp end |
#node_info(fqdn) ⇒ Object Also known as: node_infos
9 10 11 |
# File 'lib/hieracles/puppetdb/request.rb', line 9 def node_info(fqdn) @client.request("nodes/#{fqdn}") end |
#node_resources(fqdn, *args) ⇒ Object Also known as: node_res
27 28 29 30 31 |
# File 'lib/hieracles/puppetdb/request.rb', line 27 def node_resources(fqdn, *args) resp = @client.request("nodes/#{fqdn}/resources") field = args.shift make_hashed resp end |
#resources(*args) ⇒ Object Also known as: res
53 54 55 56 |
# File 'lib/hieracles/puppetdb/request.rb', line 53 def resources(*args) query = Query.new args make_hashed @client.request("resources", query.elements) end |
#same(name, fqdn) ⇒ Object
39 40 41 42 43 44 45 46 47 |
# File 'lib/hieracles/puppetdb/request.rb', line 39 def same(name, fqdn) r = @client.request("nodes/#{fqdn}/facts/#{name}") if r.data.length > 0 value = r.data[0]['value'] facts name, value else r end end |