module Azure::HttpClient

Public Instance Methods

agents(uri) click to toggle source

Returns the http agent based on uri @param uri [URI|String] the base uri (scheme, host, port) of the http endpoint @return [Net::HTTP] http agent for a given uri

# File lib/azure/http_client.rb, line 51
def agents(uri)
  ssl_options = {}
  uri = URI.parse(uri) if uri.is_a?(String)
  if uri.scheme.downcase == 'https'
    ssl_options[:ca_file] = self.ca_file if self.ca_file
    ssl_options[:verify] = true
  end

  proxy_options = if ENV['HTTP_PROXY'] || ENV['HTTPS_PROXY']
                    ENV['HTTP_PROXY'] ? URI::parse(ENV['HTTP_PROXY']) : URI::parse(ENV['HTTPS_PROXY'])
                  end || nil

  Faraday.new(uri, ssl: ssl_options, proxy: proxy_options) do |conn|
    conn.use FaradayMiddleware::FollowRedirects
    conn.adapter Faraday.default_adapter
  end
end
management_request(method, path, options_or_body = {}) click to toggle source

Creates a new management request for the current configuration @param method [Symbol] the HTTP method @param path [URI] the path to the management resource @param options_or_body [Hash|Body] options which can include body

# File lib/azure/http_client.rb, line 23
def management_request(method, path, options_or_body = {})
  options_or_body ||= {}
  options = if options_or_body.is_a?(Hash)
              options_or_body
            else
              {body: options_or_body}
            end
  BaseManagement::ManagementHttpRequest.new(method, path, {client: self}.merge(options))
end
sql_management_request(method, path, options_or_body = {}) click to toggle source

Creates a new management request for the current configuration @param method [Symbol] the HTTP method @param path [URI] the path to the management resource @param options_or_body [Hash|Body] options which can include body

# File lib/azure/http_client.rb, line 37
def sql_management_request(method, path, options_or_body = {})
  options_or_body ||= {}
  options = if options_or_body.is_a?(Hash)
              options_or_body
            else
              {body: options_or_body}
            end
  puts [method, path, options]
  BaseManagement::SqlManagementHttpRequest.new(method, path, {client: self}.merge(options))
end