Sha256: 6329a49dcc0b80570b6591d3884bd8351b2114a392eac3d5114d2cac7a423c55

Contents?: true

Size: 1.85 KB

Versions: 15

Compression:

Stored size: 1.85 KB

Contents

module Fog
  module Rackspace
    class Files

      def self.reload
        load "fog/rackspace/requests/files/get_containers.rb"
      end

      def initialize(options={})
        credentials = Fog::Rackspace.authenticate(options)
        @auth_token = credentials['X-Auth-Token']
        cdn_uri = URI.parse(credentials['X-CDN-Management-Url'])
        @cdn_host   = cdn_uri.host
        @cdn_path   = cdn_uri.path
        @cdn_port   = cdn_uri.port
        @cdn_scheme = cdn_uri.scheme
        storage_uri = URI.parse(credentials['X-Storage-Url'])
        @storage_host   = storage_uri.host
        @storage_path   = storage_uri.path
        @storage_port   = storage_uri.port
        @storage_scheme = storage_uri.scheme
        @connection = Fog::Connection.new("#{@storage_scheme}://#{@storage_host}:#{@storage_port}")
      end

      def cdn_request(params)
        response = @connection.request({
          :body     => params[:body],
          :expects  => params[:expects],
          :headers  => {
            'X-Auth-Token' => @auth_token
          },
          :host     => @cdn_host,
          :method   => params[:method],
          :path     => "#{@cdn_path}/#{params[:path]}"
        })
        unless response.status == 204
          response.body = JSON.parse(response.body)
        end
        response
      end

      def storage_request(params)
        response = @connection.request({
          :body     => params[:body],
          :expects  => params[:expects],
          :headers  => {
            'X-Auth-Token' => @auth_token
          },
          :host     => @storage_host,
          :method   => params[:method],
          :path     => "#{@storage_path}/#{params[:path]}"
        })
        unless response.status == 204
          response.body = JSON.parse(response.body)
        end
        response
      end

    end
  end
end
Fog::Rackspace::Files.reload

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
fog-0.0.29 lib/fog/rackspace/files.rb
fog-0.0.28 lib/fog/rackspace/files.rb
fog-0.0.27 lib/fog/rackspace/files.rb
fog-0.0.26 lib/fog/rackspace/files.rb
fog-0.0.25 lib/fog/rackspace/files.rb
fog-0.0.24 lib/fog/rackspace/files.rb
fog-0.0.23 lib/fog/rackspace/files.rb
fog-0.0.22 lib/fog/rackspace/files.rb
fog-0.0.21 lib/fog/rackspace/files.rb
fog-0.0.20 lib/fog/rackspace/files.rb
fog-0.0.19 lib/fog/rackspace/files.rb
fog-0.0.18 lib/fog/rackspace/files.rb
fog-0.0.17 lib/fog/rackspace/files.rb
fog-0.0.16 lib/fog/rackspace/files.rb
fog-0.0.15 lib/fog/rackspace/files.rb