class Axl::Client

Public Class Methods

new(endpoint: nil, api_version: '10.5', username: nil, password: nil) click to toggle source
# File lib/axl/client.rb, line 12
def initialize(endpoint: nil, api_version: '10.5', username: nil, password: nil)
  wsdl_path = wsdl_path(api_version.to_s)

  if endpoint.class == String && endpoint[-1] != '/'
    # Cisco AXL API doesn't like it if you don't add a trailing slash
    endpoint << '/'
  end

  # Notice how we're disabling SSL verification. This library is meant
  # to be used within a data center. If you are worried about a MITM
  # attack happening while using this library, you have bigger problems
  # to deal with than this library's SSL strategy.
  @client = Savon.client(endpoint:        endpoint,
                         wsdl:            wsdl_path,
                         ssl_verify_mode: :none,
                         basic_auth:      [username, password],
                         namespace:       "http://www.cisco.com/AXL/API/#{api_version}")
end

Private Instance Methods

wsdl_path(version) click to toggle source
# File lib/axl/client.rb, line 33
def wsdl_path(version)
  path = ['~', 'axlsqltoolkit', 'schema', version, 'AXLAPI.wsdl']
  File.expand_path(File.join(*path))
end