class OctocatalogDiff::CatalogUtil::ENC::PE::V1
Support the Puppet Enterprise classification API
. Documentation: docs.puppet.com/pe/latest/nc_index.html This is version 1 of the API
Public Class Methods
new(options)
click to toggle source
Constructor @param options [Hash] All input options
# File lib/octocatalog-diff/catalog-util/enc/pe/v1.rb, line 19 def initialize(options) @options = options end
Public Instance Methods
body()
click to toggle source
POST body @return [String] POST body data
# File lib/octocatalog-diff/catalog-util/enc/pe/v1.rb, line 42 def body raise ":facts required (got #{@options[:facts].class})" unless @options[:facts].is_a?(OctocatalogDiff::Facts) { 'fact' => @options[:facts].facts }.to_json end
headers()
click to toggle source
Headers @return [Hash] Headers for request
# File lib/octocatalog-diff/catalog-util/enc/pe/v1.rb, line 31 def headers result = { 'Accept' => 'application/json', 'Content-Type' => 'application/json' } result['X-Authentication'] = @options[:pe_enc_token] if @options[:pe_enc_token] result end
result(parsed, logger)
click to toggle source
Parse response from ENC
and return the final ENC
data @param parsed [Parsed response] Parsed response from ENC
@param logger [Logger] Logger.object @return [String] ENC
data as text
# File lib/octocatalog-diff/catalog-util/enc/pe/v1.rb, line 51 def result(parsed, logger) %w(classes parameters).each do |required_key| next if parsed[required_key] logger.debug parsed.keys.inspect raise OctocatalogDiff::Errors::PEClassificationError, "Response missing: #{required_key}" end obj = { 'classes' => parsed['classes'], 'parameters' => parsed['parameters'] } obj.to_yaml end