Class: ChefHandlerLrc::LrcUploader
- Inherits:
-
Object
- Object
- ChefHandlerLrc::LrcUploader
- Defined in:
- lib/lbn_report_chef/lrc_uploader.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
-
#initialize(opts) ⇒ LrcUploader
constructor
A new instance of LrcUploader.
- #lrc_request(path, body, method = 'post') ⇒ Object
Constructor Details
#initialize(opts) ⇒ LrcUploader
Returns a new instance of LrcUploader.
8 9 10 |
# File 'lib/lbn_report_chef/lrc_uploader.rb', line 8 def initialize(opts) = opts end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
6 7 8 |
# File 'lib/lbn_report_chef/lrc_uploader.rb', line 6 def end |
Instance Method Details
#lrc_request(path, body, method = 'post') ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/lbn_report_chef/lrc_uploader.rb', line 12 def lrc_request(path, body, method = 'post') uri = URI.parse([: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 |