Class: Akamai::Connection

Inherits:
Object
  • Object
show all
Defined in:
lib/akamai/connection.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ Connection

Returns a new instance of Connection.



7
8
9
# File 'lib/akamai/connection.rb', line 7

def initialize(args = {})
  @config = args.kind_of?(Configuration) ? args : Configuration.new(args)
end

Instance Attribute Details

#configObject

Returns the value of attribute config.



5
6
7
# File 'lib/akamai/connection.rb', line 5

def config
  @config
end

Instance Method Details

#driverObject



11
12
13
14
15
16
17
18
# File 'lib/akamai/connection.rb', line 11

def driver
  return @driver if @driver

  @driver = SOAP::WSDLDriverFactory.new(config.wsdl_url).create_rpc_driver
  @driver.options['protocol.http.ssl_config.verify_mode'] = OpenSSL::SSL::VERIFY_NONE
  @driver.options["protocol.http.basic_auth"] << [config.wsdl_url, config.cachecontrol_username, config.cachecontrol_password]
  @driver
end

#purge(*urls) ⇒ Object

Raises:



20
21
22
23
24
25
26
# File 'lib/akamai/connection.rb', line 20

def purge(*urls)
  opts = ["domain=#{config.cachecontrol_domain}", "action=#{config.cachecontrol_purge_action}"]
  opts << "email-notification=#{config.cachecontrol_email_notification}" if config.cachecontrol_email_notification
  result = driver.purgeRequest(config.cachecontrol_username, config.cachecontrol_password, '', opts, urls)
  raise PurgeError, result.inspect unless result.resultCode == '100'
  true
end