Class: RedHatSupportLib::Brokers::Problem
- Defined in:
- lib/brokers/problem.rb
Instance Attribute Summary
Attributes inherited from Broker
Instance Method Summary collapse
- #diagnose_file(file_path) ⇒ Object
- #diagnose_string(input) ⇒ Object
-
#initialize(connection) ⇒ Problem
constructor
A new instance of Problem.
Methods inherited from Broker
Constructor Details
#initialize(connection) ⇒ Problem
Returns a new instance of Problem.
4 5 6 |
# File 'lib/brokers/problem.rb', line 4 def initialize(connection) super end |
Instance Method Details
#diagnose_file(file_path) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/brokers/problem.rb', line 25 def diagnose_file(file_path) File.open(file_path) do |file| headers = {:content_type => 'application/octet-stream', :accept => :json} result = @connection.post("/rs/problems", file, headers) response = result['source_or_link_or_problem'][2]['source_or_link'] if response response.each do |resp| id = {:solution_id => get_solution_id(resp)} resp.merge! id end end end end |
#diagnose_string(input) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/brokers/problem.rb', line 8 def diagnose_string(input) #rs/problems #TODO encode input and error handling #payload = input #headers = {"Content-Type" => "application/json",'Accept' => 'application/vnd.redhat.json.suggestions'} headers = {:content_type => 'text/plain', :accept => :json} result = @connection.post("/rs/problems", input, headers) response = result['source_or_link_or_problem'][2]['source_or_link'] if response response.each do |resp| id = {:solution_id => get_solution_id(resp)} resp.merge! id end end end |