Module: Azure::HttpClient

Included in:
Client
Defined in:
lib/azure/http_client.rb

Instance Method Summary collapse

Instance Method Details

#agents(uri) ⇒ Net::HTTP

Returns the http agent based on uri

Parameters:

  • uri (URI|String)

    the base uri (scheme, host, port) of the http endpoint

Returns:

  • (Net::HTTP)

    http agent for a given uri



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# 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 = {}) ⇒ Object

Creates a new management request for the current configuration

Parameters:

  • method (Symbol)

    the HTTP method

  • path (URI)

    the path to the management resource

  • options_or_body (Hash|Body) (defaults to: {})

    options which can include body



23
24
25
26
27
28
29
30
31
# 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 = {}) ⇒ Object

Creates a new management request for the current configuration

Parameters:

  • method (Symbol)

    the HTTP method

  • path (URI)

    the path to the management resource

  • options_or_body (Hash|Body) (defaults to: {})

    options which can include body



37
38
39
40
41
42
43
44
45
46
# 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