1
0
Fork 0
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:
geemus 2011-06-15 17:32:15 -07:00
parent a50f469778
commit 0ba26b681e
19 changed files with 49 additions and 70 deletions

View file

@ -37,6 +37,7 @@ else
providers = Fog.providers providers = Fog.providers
# FIXME: hacks until we can `include Fog` in bin # FIXME: hacks until we can `include Fog` in bin
CDN = Fog::CDN
DNS = Fog::DNS DNS = Fog::DNS
Storage = Fog::Storage Storage = Fog::Storage

View file

@ -4,7 +4,7 @@ class AWS < Fog::Bin
def class_for(key) def class_for(key)
case key case key
when :cdn when :cdn
Fog::AWS::CDN Fog::CDN::AWS
when :cloud_formation when :cloud_formation
Fog::AWS::CloudFormation Fog::AWS::CloudFormation
when :compute when :compute
@ -35,6 +35,7 @@ class AWS < Fog::Bin
@@connections ||= Hash.new do |hash, key| @@connections ||= Hash.new do |hash, key|
hash[key] = case key hash[key] = case key
when :cdn when :cdn
Formatador.display_line("[yellow][WARN] AWS[:cdn] is deprecated, use CDN[:aws] instead[/]")
Fog::CDN.new(:provider => 'AWS') Fog::CDN.new(:provider => 'AWS')
when :cloud_formation when :cloud_formation
Fog::AWS::CloudFormation.new Fog::AWS::CloudFormation.new

View file

@ -4,7 +4,7 @@ class Rackspace < Fog::Bin
def class_for(key) def class_for(key)
case key case key
when :cdn when :cdn
Fog::Rackspace::CDN Fog::CDN::Rackspace
when :compute when :compute
Fog::Rackspace::Compute Fog::Rackspace::Compute
when :storage when :storage
@ -18,6 +18,7 @@ class Rackspace < Fog::Bin
@@connections ||= Hash.new do |hash, key| @@connections ||= Hash.new do |hash, key|
hash[key] = case key hash[key] = case key
when :cdn when :cdn
Formatador.display_line("[yellow][WARN] Rackspace[:cdn] is deprecated, use CDN[:rackspace] instead[/]")
Fog::CDN.new(:provider => 'Rackspace') Fog::CDN.new(:provider => 'Rackspace')
when :compute when :compute
Fog::Compute.new(:provider => 'Rackspace') Fog::Compute.new(:provider => 'Rackspace')

View file

@ -1,15 +1,19 @@
module Fog module Fog
class CDN class CDN
def self.[](provider)
self.new(:provider => provider)
end
def self.new(attributes) def self.new(attributes)
attributes = attributes.dup # prevent delete from having side effects attributes = attributes.dup # prevent delete from having side effects
case provider = attributes[:provider] # attributes.delete(:provider) case provider = attributes[:provider].to_s.downcase.to_sym
when 'AWS' when :aws
require 'fog/cdn/aws' require 'fog/cdn/aws'
Fog::AWS::CDN.new(attributes) Fog::CDN::AWS.new(attributes)
when 'Rackspace' when :rackspace
require 'fog/cdn/rackspace' require 'fog/cdn/rackspace'
Fog::Rackspace::CDN.new(attributes) Fog::CDN::Rackspace.new(attributes)
else else
raise ArgumentError.new("#{provider} is not a recognized cdn provider") raise ArgumentError.new("#{provider} is not a recognized cdn provider")
end end

View file

@ -1,6 +1,6 @@
module Fog module Fog
module AWS module CDN
class CDN < Fog::Service class AWS < Fog::Service
requires :aws_access_key_id, :aws_secret_access_key requires :aws_access_key_id, :aws_secret_access_key
recognizes :host, :path, :port, :scheme, :version, :persistent recognizes :host, :path, :port, :scheme, :version, :persistent
@ -33,13 +33,6 @@ module Fog
end end
def initialize(options={}) 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' require 'mime/types'
@aws_access_key_id = options[:aws_access_key_id] @aws_access_key_id = options[:aws_access_key_id]
@region = options[:region] @region = options[:region]
@ -79,13 +72,6 @@ module Fog
# ==== Returns # ==== Returns
# * cdn object with connection to aws. # * cdn object with connection to aws.
def initialize(options={}) 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' require 'fog/core/parser'
@aws_access_key_id = options[:aws_access_key_id] @aws_access_key_id = options[:aws_access_key_id]

View file

@ -1,7 +1,7 @@
module Fog module Fog
module Parsers module Parsers
module AWS
module CDN module CDN
module AWS
class Distribution < Fog::Parsers::Base class Distribution < Fog::Parsers::Base

View file

@ -1,7 +1,7 @@
module Fog module Fog
module Parsers module Parsers
module AWS
module CDN module CDN
module AWS
class GetDistributionList < Fog::Parsers::Base class GetDistributionList < Fog::Parsers::Base

View file

@ -1,7 +1,7 @@
module Fog module Fog
module Parsers module Parsers
module AWS
module CDN module CDN
module AWS
class PostInvalidation < Fog::Parsers::Base class PostInvalidation < Fog::Parsers::Base

View file

@ -1,6 +1,6 @@
module Fog module Fog
module Rackspace module CDN
class CDN < Fog::Service class Rackspace < Fog::Service
requires :rackspace_api_key, :rackspace_username requires :rackspace_api_key, :rackspace_username
recognizes :rackspace_auth_url, :persistent recognizes :rackspace_auth_url, :persistent
@ -27,13 +27,6 @@ module Fog
end end
def initialize(options={}) 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] @rackspace_username = options[:rackspace_username]
end end
@ -50,13 +43,6 @@ module Fog
class Real class Real
def initialize(options={}) 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' require 'json'
credentials = Fog::Rackspace.authenticate(options) credentials = Fog::Rackspace.authenticate(options)
@auth_token = credentials['X-Auth-Token'] @auth_token = credentials['X-Auth-Token']

View file

@ -1,6 +1,6 @@
module Fog module Fog
module AWS module CDN
class CDN class AWS
class Real class Real
# Delete a distribution from CloudFront # Delete a distribution from CloudFront

View file

@ -1,6 +1,6 @@
module Fog module Fog
module AWS module CDN
class CDN class AWS
class Real class Real
require 'fog/cdn/parsers/aws/distribution' require 'fog/cdn/parsers/aws/distribution'
@ -46,7 +46,7 @@ module Fog
:expects => 200, :expects => 200,
:idempotent => true, :idempotent => true,
:method => 'GET', :method => 'GET',
:parser => Fog::Parsers::AWS::CDN::Distribution.new, :parser => Fog::Parsers::CDN::AWS::Distribution.new,
:path => "/distribution/#{distribution_id}" :path => "/distribution/#{distribution_id}"
}) })
end end

View file

@ -1,6 +1,6 @@
module Fog module Fog
module AWS module CDN
class CDN class AWS
class Real class Real
require 'fog/cdn/parsers/aws/get_distribution_list' require 'fog/cdn/parsers/aws/get_distribution_list'
@ -47,7 +47,7 @@ module Fog
:expects => 200, :expects => 200,
:idempotent => true, :idempotent => true,
:method => 'GET', :method => 'GET',
:parser => Fog::Parsers::AWS::CDN::GetDistributionList.new, :parser => Fog::Parsers::CDN::AWS::GetDistributionList.new,
:path => "/distribution", :path => "/distribution",
:query => options :query => options
}) })

View file

@ -1,6 +1,6 @@
module Fog module Fog
module AWS module CDN
class CDN class AWS
class Real class Real
require 'fog/cdn/parsers/aws/distribution' require 'fog/cdn/parsers/aws/distribution'
@ -80,7 +80,7 @@ module Fog
:headers => { 'Content-Type' => 'text/xml' }, :headers => { 'Content-Type' => 'text/xml' },
:idempotent => true, :idempotent => true,
:method => 'POST', :method => 'POST',
:parser => Fog::Parsers::AWS::CDN::Distribution.new, :parser => Fog::Parsers::CDN::AWS::Distribution.new,
:path => "/distribution" :path => "/distribution"
}) })
end end

View file

@ -1,6 +1,6 @@
module Fog module Fog
module AWS module CDN
class CDN class AWS
class Real class Real
require 'fog/cdn/parsers/aws/post_invalidation' require 'fog/cdn/parsers/aws/post_invalidation'
@ -40,7 +40,7 @@ module Fog
:headers => {'Content-Type' => 'text/xml'}, :headers => {'Content-Type' => 'text/xml'},
:idempotent => true, :idempotent => true,
:method => 'POST', :method => 'POST',
:parser => Fog::Parsers::AWS::CDN::PostInvalidation.new, :parser => Fog::Parsers::CDN::AWS::PostInvalidation.new,
:path => "/distribution/#{distribution_id}/invalidation" :path => "/distribution/#{distribution_id}/invalidation"
}) })
end end

View file

@ -1,6 +1,6 @@
module Fog module Fog
module AWS module CDN
class CDN class AWS
class Real class Real
require 'fog/cdn/parsers/aws/distribution' require 'fog/cdn/parsers/aws/distribution'
@ -83,7 +83,7 @@ module Fog
}, },
:idempotent => true, :idempotent => true,
:method => 'PUT', :method => 'PUT',
:parser => Fog::Parsers::AWS::CDN::Distribution.new, :parser => Fog::Parsers::CDN::AWS::Distribution.new,
:path => "/distribution/#{distribution_id}/config" :path => "/distribution/#{distribution_id}/config"
}) })
end end

View file

@ -1,6 +1,6 @@
module Fog module Fog
module Rackspace module CDN
class CDN class Rackspace
class Real class Real
# List existing cdn-enabled storage containers # List existing cdn-enabled storage containers

View file

@ -1,6 +1,6 @@
module Fog module Fog
module Rackspace module CDN
class CDN class Rackspace
class Real class Real
# List cdn properties for a container # List cdn properties for a container

View file

@ -1,6 +1,6 @@
module Fog module Fog
module Rackspace module CDN
class CDN class Rackspace
class Real class Real
# modify CDN properties for a container # modify CDN properties for a container

View file

@ -1,6 +1,6 @@
module Fog module Fog
module Rackspace module CDN
class CDN class Rackspace
class Real class Real
# enable CDN for a container # enable CDN for a container