Skip to content

Commit

Permalink
Merge pull request #467 from jaredbeck/fix_cdn_dpr_warn
Browse files Browse the repository at this point in the history
Rename CDN::AWS to AWS::CDN
  • Loading branch information
geemus authored Sep 18, 2018
2 parents cafb79c + c4bb9e5 commit d447be8
Show file tree
Hide file tree
Showing 31 changed files with 123 additions and 113 deletions.
5 changes: 1 addition & 4 deletions lib/fog/aws.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@
require File.expand_path('../aws/version', __FILE__)

module Fog
module CDN
autoload :AWS, File.expand_path('../aws/cdn', __FILE__)
end

module AWS
extend Fog::Provider

Expand All @@ -20,6 +16,7 @@ module AWS

# Services
autoload :AutoScaling, File.expand_path('../aws/auto_scaling', __FILE__)
autoload :CDN, File.expand_path('../aws/cdn', __FILE__)
autoload :CloudFormation, File.expand_path('../aws/cloud_formation', __FILE__)
autoload :CloudWatch, File.expand_path('../aws/cloud_watch', __FILE__)
autoload :Compute, File.expand_path('../aws/compute', __FILE__)
Expand Down
17 changes: 15 additions & 2 deletions lib/fog/aws/cdn.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module Fog
module CDN
class AWS < Fog::Service
module AWS
class CDN < Fog::Service
extend Fog::AWS::CredentialFetcher::ServiceMethods

requires :aws_access_key_id, :aws_secret_access_key
Expand Down Expand Up @@ -200,4 +200,17 @@ def signature(params)
end
end
end

# @deprecated
module CDN
# @deprecated
class AWS < Fog::AWS::CDN
# @deprecated
# @overrides Fog::Service.new (from the fog-core gem)
def self.new(*)
Fog::Logger.deprecation 'Fog::CDN::AWS is deprecated, please use Fog::AWS::CDN.'
super
end
end
end
end
8 changes: 4 additions & 4 deletions lib/fog/aws/models/cdn/distribution.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
require 'fog/aws/models/cdn/distribution_helper'

module Fog
module CDN
class AWS
module AWS
class CDN
class Distribution < Fog::Model
include Fog::CDN::AWS::DistributionHelper
include Fog::AWS::CDN::DistributionHelper

identity :id, :aliases => 'Id'

Expand Down Expand Up @@ -33,7 +33,7 @@ def initialize(new_attributes = {})

def invalidations
@invalidations ||= begin
Fog::CDN::AWS::Invalidations.new(
Fog::AWS::CDN::Invalidations.new(
:distribution => self,
:service => service
)
Expand Down
4 changes: 2 additions & 2 deletions lib/fog/aws/models/cdn/distribution_helper.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module Fog
module CDN
class AWS
module AWS
class CDN
module DistributionHelper
def destroy
requires :identity, :etag, :caller_reference
Expand Down
8 changes: 4 additions & 4 deletions lib/fog/aws/models/cdn/distributions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
require 'fog/aws/models/cdn/distributions_helper'

module Fog
module CDN
class AWS
module AWS
class CDN
class Distributions < Fog::Collection
include Fog::CDN::AWS::DistributionsHelper
include Fog::AWS::CDN::DistributionsHelper

model Fog::CDN::AWS::Distribution
model Fog::AWS::CDN::Distribution

attribute :marker, :aliases => 'Marker'
attribute :max_items, :aliases => 'MaxItems'
Expand Down
4 changes: 2 additions & 2 deletions lib/fog/aws/models/cdn/distributions_helper.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module Fog
module CDN
class AWS
module AWS
class CDN
module DistributionsHelper

def all(options = {})
Expand Down
4 changes: 2 additions & 2 deletions lib/fog/aws/models/cdn/invalidation.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module Fog
module CDN
class AWS
module AWS
class CDN
class Invalidation < Fog::Model
identity :id, :aliases => 'Id'

Expand Down
6 changes: 3 additions & 3 deletions lib/fog/aws/models/cdn/invalidations.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
require 'fog/aws/models/cdn/invalidation'

module Fog
module CDN
class AWS
module AWS
class CDN
class Invalidations < Fog::Collection
attribute :is_truncated, :aliases => ['IsTruncated']
attribute :max_items, :aliases => ['MaxItems']
Expand All @@ -11,7 +11,7 @@ class Invalidations < Fog::Collection

attribute :distribution

model Fog::CDN::AWS::Invalidation
model Fog::AWS::CDN::Invalidation

def all(options = {})
requires :distribution
Expand Down
6 changes: 3 additions & 3 deletions lib/fog/aws/models/cdn/streaming_distribution.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
require 'fog/aws/models/cdn/distribution_helper'

module Fog
module CDN
class AWS
module AWS
class CDN
class StreamingDistribution < Fog::Model
include Fog::CDN::AWS::DistributionHelper
include Fog::AWS::CDN::DistributionHelper

identity :id, :aliases => 'Id'

Expand Down
8 changes: 4 additions & 4 deletions lib/fog/aws/models/cdn/streaming_distributions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
require 'fog/aws/models/cdn/distributions_helper'

module Fog
module CDN
class AWS
module AWS
class CDN
class StreamingDistributions < Fog::Collection
include Fog::CDN::AWS::DistributionsHelper
include Fog::AWS::CDN::DistributionsHelper

model Fog::CDN::AWS::StreamingDistribution
model Fog::AWS::CDN::StreamingDistribution

attribute :marker, :aliases => 'Marker'
attribute :max_items, :aliases => 'MaxItems'
Expand Down
4 changes: 2 additions & 2 deletions lib/fog/aws/parsers/cdn/distribution.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module Fog
module Parsers
module CDN
module AWS
module AWS
module CDN
class Distribution < Fog::Parsers::Base
def reset
@response = { 'DistributionConfig' => { 'CNAME' => [], 'Logging' => {}, 'TrustedSigners' => [] } }
Expand Down
4 changes: 2 additions & 2 deletions lib/fog/aws/parsers/cdn/get_distribution_list.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module Fog
module Parsers
module CDN
module AWS
module AWS
module CDN
class GetDistributionList < Fog::Parsers::Base
def reset
@distribution_summary = { 'CNAME' => [], 'TrustedSigners' => [] }
Expand Down
4 changes: 2 additions & 2 deletions lib/fog/aws/parsers/cdn/get_invalidation.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module Fog
module Parsers
module CDN
module AWS
module AWS
module CDN
class GetInvalidation < Fog::Parsers::Base
def reset
@response = { 'InvalidationBatch' => { 'Path' => [] } }
Expand Down
4 changes: 2 additions & 2 deletions lib/fog/aws/parsers/cdn/get_invalidation_list.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module Fog
module Parsers
module CDN
module AWS
module AWS
module CDN
class GetInvalidationList < Fog::Parsers::Base
def reset
@invalidation_summary = { }
Expand Down
4 changes: 2 additions & 2 deletions lib/fog/aws/parsers/cdn/get_streaming_distribution_list.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module Fog
module Parsers
module CDN
module AWS
module AWS
module CDN
class GetStreamingDistributionList < Fog::Parsers::Base
def reset
@distribution_summary = { 'CNAME' => [], 'TrustedSigners' => [] }
Expand Down
4 changes: 2 additions & 2 deletions lib/fog/aws/parsers/cdn/post_invalidation.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module Fog
module Parsers
module CDN
module AWS
module AWS
module CDN
class PostInvalidation < Fog::Parsers::Base
def reset
@response = { 'InvalidationBatch' => { 'Path' => [] } }
Expand Down
2 changes: 1 addition & 1 deletion lib/fog/aws/parsers/cdn/streaming_distribution.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module Fog
module Parsers
module AWS
module CDN
module AWS

class StreamingDistribution < Fog::Parsers::Base
def reset
Expand Down
12 changes: 6 additions & 6 deletions lib/fog/aws/requests/cdn/delete_distribution.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module Fog
module CDN
class AWS
module AWS
class CDN
class Real
# Delete a distribution from CloudFront.
#
Expand All @@ -26,13 +26,13 @@ def delete_distribution(distribution_id, etag)

if distribution
if distribution['ETag'] != etag
Fog::CDN::AWS::Mock.error(:invalid_if_match_version)
Fog::AWS::CDN::Mock.error(:invalid_if_match_version)
end
unless distribution['DistributionConfig']['CallerReference']
Fog::CDN::AWS::Mock.error(:illegal_update)
Fog::AWS::CDN::Mock.error(:illegal_update)
end
if distribution['DistributionConfig']['Enabled']
Fog::CDN::AWS::Mock.error(:distribution_not_disabled)
Fog::AWS::CDN::Mock.error(:distribution_not_disabled)
end

self.data[:distributions].delete(distribution_id)
Expand All @@ -43,7 +43,7 @@ def delete_distribution(distribution_id, etag)
response.body = "x-amz-request-id: #{Fog::AWS::Mock.request_id}"
response
else
Fog::CDN::AWS::Mock.error(:no_such_distribution)
Fog::AWS::CDN::Mock.error(:no_such_distribution)
end
end
end
Expand Down
12 changes: 6 additions & 6 deletions lib/fog/aws/requests/cdn/delete_streaming_distribution.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module Fog
module CDN
class AWS
module AWS
class CDN
class Real
# Delete a streaming distribution from CloudFront.
#
Expand All @@ -26,13 +26,13 @@ def delete_streaming_distribution(distribution_id, etag)

if distribution
if distribution['ETag'] != etag
Fog::CDN::AWS::Mock.error(:invalid_if_match_version)
Fog::AWS::CDN::Mock.error(:invalid_if_match_version)
end
unless distribution['StreamingDistributionConfig']['CallerReference']
Fog::CDN::AWS::Mock.error(:illegal_update)
Fog::AWS::CDN::Mock.error(:illegal_update)
end
if distribution['StreamingDistributionConfig']['Enabled']
Fog::CDN::AWS::Mock.error(:distribution_not_disabled)
Fog::AWS::CDN::Mock.error(:distribution_not_disabled)
end

self.data[:streaming_distributions].delete(distribution_id)
Expand All @@ -42,7 +42,7 @@ def delete_streaming_distribution(distribution_id, etag)
response.body = "x-amz-request-id: #{Fog::AWS::Mock.request_id}"
response
else
Fog::CDN::AWS::Mock.error(:no_such_streaming_distribution)
Fog::AWS::CDN::Mock.error(:no_such_streaming_distribution)
end
end
end
Expand Down
10 changes: 5 additions & 5 deletions lib/fog/aws/requests/cdn/get_distribution.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module Fog
module CDN
class AWS
module AWS
class CDN
class Real
require 'fog/aws/parsers/cdn/distribution'

Expand Down Expand Up @@ -42,7 +42,7 @@ def get_distribution(distribution_id)
:expects => 200,
:idempotent => true,
:method => 'GET',
:parser => Fog::Parsers::CDN::AWS::Distribution.new,
:parser => Fog::Parsers::AWS::CDN::Distribution.new,
:path => "/distribution/#{distribution_id}"
})
end
Expand All @@ -54,14 +54,14 @@ def get_distribution(distribution_id)

distribution = self.data[:distributions][distribution_id]
unless distribution
Fog::CDN::AWS::Mock.error(:no_such_distribution)
Fog::AWS::CDN::Mock.error(:no_such_distribution)
end

if distribution['Status'] == 'InProgress' && (Time.now - Time.parse(distribution['LastModifiedTime']) >= Fog::Mock.delay * 2)
distribution['Status'] = 'Deployed'
end

etag = Fog::CDN::AWS::Mock.generic_id
etag = Fog::AWS::CDN::Mock.generic_id
response.status = 200
response.body = {
'InProgressInvalidationBatches' => 0,
Expand Down
6 changes: 3 additions & 3 deletions lib/fog/aws/requests/cdn/get_distribution_list.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module Fog
module CDN
class AWS
module AWS
class CDN
class Real
require 'fog/aws/parsers/cdn/get_distribution_list'

Expand Down Expand Up @@ -42,7 +42,7 @@ def get_distribution_list(options = {})
:expects => 200,
:idempotent => true,
:method => 'GET',
:parser => Fog::Parsers::CDN::AWS::GetDistributionList.new,
:parser => Fog::Parsers::AWS::CDN::GetDistributionList.new,
:path => "/distribution",
:query => options
})
Expand Down
10 changes: 5 additions & 5 deletions lib/fog/aws/requests/cdn/get_invalidation.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module Fog
module CDN
class AWS
module AWS
class CDN
class Real
require 'fog/aws/parsers/cdn/get_invalidation'

Expand All @@ -24,7 +24,7 @@ def get_invalidation(distribution_id, invalidation_id)
:expects => 200,
:idempotent => true,
:method => 'GET',
:parser => Fog::Parsers::CDN::AWS::GetInvalidation.new,
:parser => Fog::Parsers::AWS::CDN::GetInvalidation.new,
:path => "/distribution/#{distribution_id}/invalidation/#{invalidation_id}"
})
end
Expand All @@ -34,12 +34,12 @@ class Mock
def get_invalidation(distribution_id, invalidation_id)
distribution = self.data[:distributions][distribution_id]
unless distribution
Fog::CDN::AWS::Mock.error(:no_such_distribution)
Fog::AWS::CDN::Mock.error(:no_such_distribution)
end

invalidation = self.data[:invalidations][distribution_id][invalidation_id]
unless invalidation
Fog::CDN::AWS::Mock.error(:no_such_invalidation)
Fog::AWS::CDN::Mock.error(:no_such_invalidation)
end

if invalidation['Status'] == 'InProgress' && (Time.now - Time.parse(invalidation['CreateTime']) >= Fog::Mock.delay * 2)
Expand Down
Loading

0 comments on commit d447be8

Please sign in to comment.