2010-11-01 20:44:14 -04:00
|
|
|
module Fog
|
|
|
|
module Parsers
|
2011-06-15 20:32:15 -04:00
|
|
|
module CDN
|
|
|
|
module AWS
|
2010-11-01 20:44:14 -04:00
|
|
|
|
|
|
|
class Distribution < Fog::Parsers::Base
|
|
|
|
|
|
|
|
def reset
|
|
|
|
@response = { 'DistributionConfig' => { 'CNAME' => [], 'Logging' => {}, 'TrustedSigners' => [] } }
|
|
|
|
end
|
|
|
|
|
2010-11-09 18:49:38 -05:00
|
|
|
def start_element(name, attrs = [])
|
|
|
|
super
|
|
|
|
case name
|
|
|
|
when 'CustomOrigin', 'S3Origin'
|
|
|
|
@origin = name
|
|
|
|
@response['DistributionConfig'][@origin] = {}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2010-11-01 20:44:14 -04:00
|
|
|
def end_element(name)
|
|
|
|
case name
|
|
|
|
when 'AwsAccountNumber'
|
2011-05-12 16:15:13 -04:00
|
|
|
@response['DistributionConfig']['TrustedSigners'] << value
|
2010-11-01 20:44:14 -04:00
|
|
|
when 'Bucket', 'Prefix'
|
2011-05-12 16:15:13 -04:00
|
|
|
@response['DistributionConfig']['Logging'][name] = value
|
2010-11-01 20:44:14 -04:00
|
|
|
when 'CNAME'
|
2011-05-12 16:15:13 -04:00
|
|
|
@response['DistributionConfig']['CNAME'] << value
|
2010-11-09 18:49:38 -05:00
|
|
|
when 'DNSName', 'OriginAccessIdentity', 'OriginProtocolPolicy'
|
2011-05-12 16:15:13 -04:00
|
|
|
@response['DistributionConfig'][@origin][name] = value
|
2010-11-01 20:44:14 -04:00
|
|
|
when 'DomainName', 'Id', 'Status'
|
2011-05-12 16:15:13 -04:00
|
|
|
@response[name] = value
|
2010-11-01 20:44:14 -04:00
|
|
|
when 'CallerReference', 'Comment', 'DefaultRootObject', 'Origin', 'OriginAccessIdentity'
|
2011-05-12 16:15:13 -04:00
|
|
|
@response['DistributionConfig'][name] = value
|
2010-11-01 20:44:14 -04:00
|
|
|
when 'Enabled'
|
2011-05-12 16:15:13 -04:00
|
|
|
if value == 'true'
|
2010-11-01 20:44:14 -04:00
|
|
|
@response['DistributionConfig'][name] = true
|
|
|
|
else
|
|
|
|
@response['DistributionConfig'][name] = false
|
|
|
|
end
|
2010-11-09 18:49:38 -05:00
|
|
|
when 'HTTPPort', 'HTTPSPort'
|
2011-05-12 16:15:13 -04:00
|
|
|
@response['DistributionConfig'][@origin][name] = value.to_i
|
2010-11-09 18:49:38 -05:00
|
|
|
when 'InProgressInvalidationBatches'
|
2011-05-12 16:15:13 -04:00
|
|
|
@response[name] = value.to_i
|
2010-11-01 20:44:14 -04:00
|
|
|
when 'LastModifiedTime'
|
2011-05-12 16:15:13 -04:00
|
|
|
@response[name] = Time.parse(value)
|
2010-11-01 20:44:14 -04:00
|
|
|
when 'Protocol'
|
2011-05-12 16:15:13 -04:00
|
|
|
@response['DistributionConfig']['RequireProtocols'] = value
|
2010-11-01 20:44:14 -04:00
|
|
|
when 'Self'
|
|
|
|
@response['DistributionConfig']['TrustedSigners'] << 'Self'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|