mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
[cdn] refactor provider/service namespacing
This commit is contained in:
parent
a50f469778
commit
0ba26b681e
19 changed files with 49 additions and 70 deletions
1
bin/fog
1
bin/fog
|
@ -37,6 +37,7 @@ else
|
|||
providers = Fog.providers
|
||||
|
||||
# FIXME: hacks until we can `include Fog` in bin
|
||||
CDN = Fog::CDN
|
||||
DNS = Fog::DNS
|
||||
Storage = Fog::Storage
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ class AWS < Fog::Bin
|
|||
def class_for(key)
|
||||
case key
|
||||
when :cdn
|
||||
Fog::AWS::CDN
|
||||
Fog::CDN::AWS
|
||||
when :cloud_formation
|
||||
Fog::AWS::CloudFormation
|
||||
when :compute
|
||||
|
@ -35,6 +35,7 @@ class AWS < Fog::Bin
|
|||
@@connections ||= Hash.new do |hash, key|
|
||||
hash[key] = case key
|
||||
when :cdn
|
||||
Formatador.display_line("[yellow][WARN] AWS[:cdn] is deprecated, use CDN[:aws] instead[/]")
|
||||
Fog::CDN.new(:provider => 'AWS')
|
||||
when :cloud_formation
|
||||
Fog::AWS::CloudFormation.new
|
||||
|
|
|
@ -4,7 +4,7 @@ class Rackspace < Fog::Bin
|
|||
def class_for(key)
|
||||
case key
|
||||
when :cdn
|
||||
Fog::Rackspace::CDN
|
||||
Fog::CDN::Rackspace
|
||||
when :compute
|
||||
Fog::Rackspace::Compute
|
||||
when :storage
|
||||
|
@ -18,6 +18,7 @@ class Rackspace < Fog::Bin
|
|||
@@connections ||= Hash.new do |hash, key|
|
||||
hash[key] = case key
|
||||
when :cdn
|
||||
Formatador.display_line("[yellow][WARN] Rackspace[:cdn] is deprecated, use CDN[:rackspace] instead[/]")
|
||||
Fog::CDN.new(:provider => 'Rackspace')
|
||||
when :compute
|
||||
Fog::Compute.new(:provider => 'Rackspace')
|
||||
|
|
|
@ -1,15 +1,19 @@
|
|||
module Fog
|
||||
class CDN
|
||||
|
||||
def self.[](provider)
|
||||
self.new(:provider => provider)
|
||||
end
|
||||
|
||||
def self.new(attributes)
|
||||
attributes = attributes.dup # prevent delete from having side effects
|
||||
case provider = attributes[:provider] # attributes.delete(:provider)
|
||||
when 'AWS'
|
||||
case provider = attributes[:provider].to_s.downcase.to_sym
|
||||
when :aws
|
||||
require 'fog/cdn/aws'
|
||||
Fog::AWS::CDN.new(attributes)
|
||||
when 'Rackspace'
|
||||
Fog::CDN::AWS.new(attributes)
|
||||
when :rackspace
|
||||
require 'fog/cdn/rackspace'
|
||||
Fog::Rackspace::CDN.new(attributes)
|
||||
Fog::CDN::Rackspace.new(attributes)
|
||||
else
|
||||
raise ArgumentError.new("#{provider} is not a recognized cdn provider")
|
||||
end
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
module Fog
|
||||
module AWS
|
||||
class CDN < Fog::Service
|
||||
module CDN
|
||||
class AWS < Fog::Service
|
||||
|
||||
requires :aws_access_key_id, :aws_secret_access_key
|
||||
recognizes :host, :path, :port, :scheme, :version, :persistent
|
||||
|
@ -33,13 +33,6 @@ module Fog
|
|||
end
|
||||
|
||||
def initialize(options={})
|
||||
unless options.delete(:provider)
|
||||
location = caller.first
|
||||
warning = "[yellow][WARN] Fog::AWS::CDN.new is deprecated, use Fog::CDN.new(:provider => 'AWS') instead[/]"
|
||||
warning << " [light_black](" << location << ")[/] "
|
||||
Formatador.display_line(warning)
|
||||
end
|
||||
|
||||
require 'mime/types'
|
||||
@aws_access_key_id = options[:aws_access_key_id]
|
||||
@region = options[:region]
|
||||
|
@ -79,13 +72,6 @@ module Fog
|
|||
# ==== Returns
|
||||
# * cdn object with connection to aws.
|
||||
def initialize(options={})
|
||||
unless options.delete(:provider)
|
||||
location = caller.first
|
||||
warning = "[yellow][WARN] Fog::AWS::CDN.new is deprecated, use Fog::CDN.new(:provider => 'AWS') instead[/]"
|
||||
warning << " [light_black](" << location << ")[/] "
|
||||
Formatador.display_line(warning)
|
||||
end
|
||||
|
||||
require 'fog/core/parser'
|
||||
|
||||
@aws_access_key_id = options[:aws_access_key_id]
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
module Fog
|
||||
module Parsers
|
||||
module AWS
|
||||
module CDN
|
||||
module CDN
|
||||
module AWS
|
||||
|
||||
class Distribution < Fog::Parsers::Base
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
module Fog
|
||||
module Parsers
|
||||
module AWS
|
||||
module CDN
|
||||
module CDN
|
||||
module AWS
|
||||
|
||||
class GetDistributionList < Fog::Parsers::Base
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
module Fog
|
||||
module Parsers
|
||||
module AWS
|
||||
module CDN
|
||||
module CDN
|
||||
module AWS
|
||||
|
||||
class PostInvalidation < Fog::Parsers::Base
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
module Fog
|
||||
module Rackspace
|
||||
class CDN < Fog::Service
|
||||
module CDN
|
||||
class Rackspace < Fog::Service
|
||||
|
||||
requires :rackspace_api_key, :rackspace_username
|
||||
recognizes :rackspace_auth_url, :persistent
|
||||
|
@ -27,13 +27,6 @@ module Fog
|
|||
end
|
||||
|
||||
def initialize(options={})
|
||||
unless options.delete(:provider)
|
||||
location = caller.first
|
||||
warning = "[yellow][WARN] Fog::Rackspace::CDN.new is deprecated, use Fog::CDN.new(:provider => 'Rackspace') instead[/]"
|
||||
warning << " [light_black](" << location << ")[/] "
|
||||
Formatador.display_line(warning)
|
||||
end
|
||||
|
||||
@rackspace_username = options[:rackspace_username]
|
||||
end
|
||||
|
||||
|
@ -50,13 +43,6 @@ module Fog
|
|||
class Real
|
||||
|
||||
def initialize(options={})
|
||||
unless options.delete(:provider)
|
||||
location = caller.first
|
||||
warning = "[yellow][WARN] Fog::Rackspace::CDN.new is deprecated, use Fog::CDN.new(:provider => 'Rackspace') instead[/]"
|
||||
warning << " [light_black](" << location << ")[/] "
|
||||
Formatador.display_line(warning)
|
||||
end
|
||||
|
||||
require 'json'
|
||||
credentials = Fog::Rackspace.authenticate(options)
|
||||
@auth_token = credentials['X-Auth-Token']
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
module Fog
|
||||
module AWS
|
||||
class CDN
|
||||
module CDN
|
||||
class AWS
|
||||
class Real
|
||||
|
||||
# Delete a distribution from CloudFront
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
module Fog
|
||||
module AWS
|
||||
class CDN
|
||||
module CDN
|
||||
class AWS
|
||||
class Real
|
||||
|
||||
require 'fog/cdn/parsers/aws/distribution'
|
||||
|
@ -46,7 +46,7 @@ module Fog
|
|||
:expects => 200,
|
||||
:idempotent => true,
|
||||
:method => 'GET',
|
||||
:parser => Fog::Parsers::AWS::CDN::Distribution.new,
|
||||
:parser => Fog::Parsers::CDN::AWS::Distribution.new,
|
||||
:path => "/distribution/#{distribution_id}"
|
||||
})
|
||||
end
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
module Fog
|
||||
module AWS
|
||||
class CDN
|
||||
module CDN
|
||||
class AWS
|
||||
class Real
|
||||
|
||||
require 'fog/cdn/parsers/aws/get_distribution_list'
|
||||
|
@ -47,7 +47,7 @@ module Fog
|
|||
:expects => 200,
|
||||
:idempotent => true,
|
||||
:method => 'GET',
|
||||
:parser => Fog::Parsers::AWS::CDN::GetDistributionList.new,
|
||||
:parser => Fog::Parsers::CDN::AWS::GetDistributionList.new,
|
||||
:path => "/distribution",
|
||||
:query => options
|
||||
})
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
module Fog
|
||||
module AWS
|
||||
class CDN
|
||||
module CDN
|
||||
class AWS
|
||||
class Real
|
||||
|
||||
require 'fog/cdn/parsers/aws/distribution'
|
||||
|
@ -80,7 +80,7 @@ module Fog
|
|||
:headers => { 'Content-Type' => 'text/xml' },
|
||||
:idempotent => true,
|
||||
:method => 'POST',
|
||||
:parser => Fog::Parsers::AWS::CDN::Distribution.new,
|
||||
:parser => Fog::Parsers::CDN::AWS::Distribution.new,
|
||||
:path => "/distribution"
|
||||
})
|
||||
end
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
module Fog
|
||||
module AWS
|
||||
class CDN
|
||||
module CDN
|
||||
class AWS
|
||||
class Real
|
||||
|
||||
require 'fog/cdn/parsers/aws/post_invalidation'
|
||||
|
@ -40,7 +40,7 @@ module Fog
|
|||
:headers => {'Content-Type' => 'text/xml'},
|
||||
:idempotent => true,
|
||||
:method => 'POST',
|
||||
:parser => Fog::Parsers::AWS::CDN::PostInvalidation.new,
|
||||
:parser => Fog::Parsers::CDN::AWS::PostInvalidation.new,
|
||||
:path => "/distribution/#{distribution_id}/invalidation"
|
||||
})
|
||||
end
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
module Fog
|
||||
module AWS
|
||||
class CDN
|
||||
module CDN
|
||||
class AWS
|
||||
class Real
|
||||
|
||||
require 'fog/cdn/parsers/aws/distribution'
|
||||
|
@ -83,7 +83,7 @@ module Fog
|
|||
},
|
||||
:idempotent => true,
|
||||
:method => 'PUT',
|
||||
:parser => Fog::Parsers::AWS::CDN::Distribution.new,
|
||||
:parser => Fog::Parsers::CDN::AWS::Distribution.new,
|
||||
:path => "/distribution/#{distribution_id}/config"
|
||||
})
|
||||
end
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
module Fog
|
||||
module Rackspace
|
||||
class CDN
|
||||
module CDN
|
||||
class Rackspace
|
||||
class Real
|
||||
|
||||
# List existing cdn-enabled storage containers
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
module Fog
|
||||
module Rackspace
|
||||
class CDN
|
||||
module CDN
|
||||
class Rackspace
|
||||
class Real
|
||||
|
||||
# List cdn properties for a container
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
module Fog
|
||||
module Rackspace
|
||||
class CDN
|
||||
module CDN
|
||||
class Rackspace
|
||||
class Real
|
||||
|
||||
# modify CDN properties for a container
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
module Fog
|
||||
module Rackspace
|
||||
class CDN
|
||||
module CDN
|
||||
class Rackspace
|
||||
class Real
|
||||
|
||||
# enable CDN for a container
|
||||
|
|
Loading…
Reference in a new issue