class ChefHandlerLrc::LrcUploader
Attributes
options[R]
Public Class Methods
new(opts)
click to toggle source
# File lib/lbn_report_chef/lrc_uploader.rb, line 8 def initialize(opts) @options = opts end
Public Instance Methods
lrc_request(path, body, method = 'post')
click to toggle source
# File lib/lbn_report_chef/lrc_uploader.rb, line 12 def lrc_request(path, body, method = 'post') uri = URI.parse(options[:url]) http = Net::HTTP.new(uri.host, uri.port) http.use_ssl = true http.verify_mode = OpenSSL::SSL::VERIFY_PEER req = Net::HTTP.const_get(method.capitalize).new("#{uri}#{path}") req.add_field('Accept', 'application/json') req.add_field('Content-Type', 'application/json') req.body = body.to_json response = http.request(req) Chef::Log.info("The report API has return: #{response.inspect} from #{uri}#{path}") Chef::Log.debug("Report Content: #{body.to_json}") end