Class: Classification
- Inherits:
-
Object
- Object
- Classification
- Defined in:
- lib/puppetclassify/classification.rb
Instance Method Summary collapse
- #explain(name) ⇒ Object
- #get(name) ⇒ Object
-
#initialize(nc_api_url, puppet_https) ⇒ Classification
constructor
A new instance of Classification.
Constructor Details
#initialize(nc_api_url, puppet_https) ⇒ Classification
Returns a new instance of Classification.
4 5 6 7 |
# File 'lib/puppetclassify/classification.rb', line 4 def initialize(nc_api_url, puppet_https) @nc_api_url = nc_api_url @puppet_https = puppet_https end |
Instance Method Details
#explain(name) ⇒ Object
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/puppetclassify/classification.rb', line 20 def explain(name) class_res = @puppet_https.post("#{@nc_api_url}/v1/classified/nodes/#{name}/explanation") unless class_res.code.to_i == 200 STDERR.puts "An error occured retreiving the classification explanation of node #{name}: HTTP #{class_res.code} #{class_res.}" STDERR.puts class_res.body else JSON.parse(class_res.body) end end |
#get(name) ⇒ Object
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/puppetclassify/classification.rb', line 9 def get(name) class_res = @puppet_https.post("#{@nc_api_url}/v1/classified/nodes/#{name}") unless class_res.code.to_i == 200 STDERR.puts "An error occured retreiving the classification of node #{name}: HTTP #{class_res.code} #{class_res.}" STDERR.puts class_res.body else JSON.parse(class_res.body) end end |