Class: Chef::ServerAPI
Instance Attribute Summary
Attributes inherited from HTTP
#keepalives, #middlewares, #nethttp_opts, #options, #redirect_limit, #sign_on_redirect, #url
Instance Method Summary collapse
-
#initialize(url = Chef::Config[:chef_server_url], options = {}) ⇒ ServerAPI
constructor
A new instance of ServerAPI.
-
#raw_request(method, path, headers = {}, data = false) ⇒ Object
Makes an HTTP request to
path
with the givenmethod
,headers
, anddata
(if applicable).
Methods inherited from HTTP
#delete, #get, #head, #http_client, #last_response, middlewares, #post, #put, #request, #streaming_request, #streaming_request_with_progress, use
Constructor Details
#initialize(url = Chef::Config[:chef_server_url], options = {}) ⇒ ServerAPI
Returns a new instance of ServerAPI.
32 33 34 35 36 37 38 39 40 41 |
# File 'lib/chef/server_api.rb', line 32 def initialize(url = Chef::Config[:chef_server_url], = {}) # # If making a change here, also update Chef::Knife::Raw::RawInputServerAPI. [:client_name] ||= Chef::Config[:node_name] [:raw_key] ||= Chef::Config[:client_key_contents] [:signing_key_filename] ||= Chef::Config[:client_key] unless [:raw_key] [:ssh_agent_signing] ||= Chef::Config[:ssh_agent_signing] [:signing_key_filename] = nil if chef_zero_uri?(url) [:inflate_json_class] = false super(url, ) end |
Instance Method Details
#raw_request(method, path, headers = {}, data = false) ⇒ Object
Makes an HTTP request to path
with the given method
, headers
, and data
(if applicable). Does not apply any middleware, besides that needed for Authentication.
65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/chef/server_api.rb', line 65 def raw_request(method, path, headers = {}, data = false) url = create_url(path) method, url, headers, data = Chef::HTTP::Authenticator.new().handle_request(method, url, headers, data) method, url, headers, data = Chef::HTTP::RemoteRequestID.new().handle_request(method, url, headers, data) response, rest_request, return_value = send_http_request(method, url, headers, data) response.error! unless success_response?(response) return_value rescue Exception => exception log_failed_request(response, return_value) unless response.nil? raise end |