def initialize(options={})
@connection_options = options[:connection_options] || {}
auth_version = options[:hp_auth_version] || :v2
options[:hp_service_type] = "hpext:cdn"
if (auth_version == :v2)
credentials = Fog::HP.authenticate_v2(options, @connection_options)
@hp_cdn_uri = credentials[:endpoint_url]
cdn_mgmt_url = @hp_cdn_uri
else
credentials = Fog::HP.authenticate_v1(options, @connection_options)
@hp_cdn_uri = options[:hp_cdn_uri] || "https://region-a.geo-1.cdnmgmt.hpcloudsvc.com/v1.0"
cdn_mgmt_url = "#{@hp_cdn_uri}#{URI.parse(credentials[:cdn_endpoint_url]).path}"
end
@auth_token = credentials[:auth_token]
@enabled = false
@persistent = options[:persistent] || false
if cdn_mgmt_url
uri = URI.parse(cdn_mgmt_url)
@host = uri.host
@path = uri.path.chomp("/")
@port = uri.port
@scheme = uri.scheme
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)
@enabled = true
end
end