class Chef::ServerAPI

Public Class Methods

new(url = Chef::Config[:chef_server_url], options = {}) click to toggle source
Calls superclass method Chef::HTTP::new
# File lib/chef/server_api.rb, line 32
def initialize(url = Chef::Config[:chef_server_url], options = {})
  # # If making a change here, also update Chef::Knife::Raw::RawInputServerAPI.
  options[:client_name] ||= Chef::Config[:node_name]
  options[:raw_key] ||= Chef::Config[:client_key_contents]
  options[:signing_key_filename] ||= Chef::Config[:client_key] unless options[:raw_key]
  options[:ssh_agent_signing] ||= Chef::Config[:ssh_agent_signing]
  options[:signing_key_filename] = nil if chef_zero_uri?(url)
  options[:inflate_json_class] = false
  super(url, options)
end

Public Instance Methods

raw_request(method, path, headers = {}, data = false) click to toggle source

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.

# 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(options).handle_request(method, url, headers, data)
  method, url, headers, data = Chef::HTTP::RemoteRequestID.new(options).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?

  if exception.respond_to?(:chef_rest_request=)
    exception.chef_rest_request = rest_request
  end
  raise
end