Class: Puppet::HTTP::Service::Report
- Inherits:
-
Puppet::HTTP::Service
- Object
- Puppet::HTTP::Service
- Puppet::HTTP::Service::Report
- Defined in:
- lib/puppet/http/service/report.rb
Overview
The Report service is used to submit run reports to the report server.
Constant Summary collapse
- API =
Returns Default API for the report service.
'/puppet/v3'
Constants inherited from Puppet::HTTP::Service
EXCLUDED_FORMATS, SERVICE_NAMES
Instance Attribute Summary
Attributes inherited from Puppet::HTTP::Service
Instance Method Summary collapse
-
#initialize(client, session, server, port) ⇒ Report
constructor
private
Use ‘Puppet::HTTP::Session.route_to(:report)` to create or get an instance of this class.
-
#put_report(name, report, environment:) ⇒ Puppet::HTTP::Response
Submit a report to the report server.
Methods inherited from Puppet::HTTP::Service
#connect, create_service, valid_name?, #with_base_url
Constructor Details
#initialize(client, session, server, port) ⇒ Report
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Use ‘Puppet::HTTP::Session.route_to(:report)` to create or get an instance of this class.
24 25 26 27 |
# File 'lib/puppet/http/service/report.rb', line 24 def initialize(client, session, server, port) url = build_url(API, server || Puppet[:report_server], port || Puppet[:report_port]) super(client, session, url) end |
Instance Method Details
#put_report(name, report, environment:) ⇒ Puppet::HTTP::Response
Submit a report to the report server.
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/puppet/http/service/report.rb', line 39 def put_report(name, report, environment:) formatter = Puppet::Network::FormatHandler.format_for(Puppet[:preferred_serialization_format]) headers = add_puppet_headers( 'Accept' => get_mime_types(Puppet::Transaction::Report).join(', '), 'Content-Type' => formatter.mime ) response = @client.put( with_base_url("/report/#{name}"), serialize(formatter, report), headers: headers, params: { environment: environment } ) # override parent's process_response handling @session.process_response(response) if response.success? response else raise Puppet::HTTP::ResponseError, response end end |