mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
9666c9c7e0
This patch brings models for AWS CDN, including tests and documentation. Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
64 lines
No EOL
1.5 KiB
Ruby
64 lines
No EOL
1.5 KiB
Ruby
require 'fog/core/collection'
|
|
|
|
module Fog
|
|
module CDN
|
|
class AWS
|
|
|
|
module DistributionHelper
|
|
|
|
def destroy
|
|
requires :identity, :etag, :caller_reference
|
|
raise "Distribution must be disabled to be deleted" unless disabled?
|
|
delete_distribution(identity, etag)
|
|
true
|
|
end
|
|
|
|
def enabled?
|
|
requires :identity
|
|
!!enabled and ready?
|
|
end
|
|
|
|
def disabled?
|
|
requires :identity
|
|
not enabled? and ready?
|
|
end
|
|
|
|
def custom_origin?
|
|
requires :identity
|
|
not custom_origin.nil?
|
|
end
|
|
|
|
def ready?
|
|
requires :identity
|
|
status == 'Deployed'
|
|
end
|
|
|
|
def enable
|
|
requires :identity
|
|
reload if etag.nil? or caller_reference.nil?
|
|
unless enabled?
|
|
self.enabled = true
|
|
response = put_distribution_config(identity, etag, attributes_to_options)
|
|
etag = response.headers['ETag']
|
|
merge_attributes(response.body)
|
|
end
|
|
true
|
|
end
|
|
|
|
def disable
|
|
requires :identity
|
|
reload if etag.nil? or caller_reference.nil?
|
|
if enabled?
|
|
self.enabled = false
|
|
response = put_distribution_config(identity, etag, attributes_to_options)
|
|
etag = response.headers['ETag']
|
|
merge_attributes(response.body)
|
|
end
|
|
true
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
end
|
|
end |