Class: Hieracles::Puppetdb::Request
- Inherits:
-
Object
- Object
- Hieracles::Puppetdb::Request
- Defined in:
- lib/hieracles/puppetdb/request.rb
Instance Method Summary collapse
-
#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)
Constructor Details
#initialize(options) ⇒ Request
Returns a new instance of Request.
5 6 7 |
# File 'lib/hieracles/puppetdb/request.rb', line 5 def initialize() @client = Hieracles::Puppetdb::Client.new end |
Instance Method Details
#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 32 33 34 35 36 37 |
# File 'lib/hieracles/puppetdb/request.rb', line 27 def node_resources(fqdn, *args) resp = @client.request("nodes/#{fqdn}/resources") field = args.shift resp.data = resp.data.reduce({}) do |a, d| if !field || Regexp.new(field).match(d['title']) a[d['title']] = d end a end resp end |