From 37419fd91c9e7b9303585a803436a4a1ce16ce8d Mon Sep 17 00:00:00 2001 From: Sammy Larbi Date: Sat, 18 Jan 2014 13:42:37 -0600 Subject: [PATCH] Add support for Rackspace's Extract Archive API call See http://docs.rackspace.com/files/api/v1/cf-devguide/content/Extract_Archive-d1e2338.html for documentation on the API call --- .../requests/storage/extract_archive.rb | 39 +++++++++++++++++++ lib/fog/rackspace/storage.rb | 1 + 2 files changed, 40 insertions(+) create mode 100644 lib/fog/rackspace/requests/storage/extract_archive.rb diff --git a/lib/fog/rackspace/requests/storage/extract_archive.rb b/lib/fog/rackspace/requests/storage/extract_archive.rb new file mode 100644 index 000000000..eea48e1d7 --- /dev/null +++ b/lib/fog/rackspace/requests/storage/extract_archive.rb @@ -0,0 +1,39 @@ +require 'fog' +module Fog + module Storage + class Rackspace + class Real + + # Extract Archive + # + # See http://docs.rackspace.com/files/api/v1/cf-devguide/content/Extract_Archive-d1e2338.html + # + # ==== Parameters + # * container<~String> - Name for container, should be < 256 bytes and must not contain '/' + # * data<~String|File> - file to upload + # * archive_format<~String> - "tar", "tar.gz", or "tar.bz2" + + # @raise [Fog::Storage::Rackspace::NotFound] - HTTP 404 + # @raise [Fog::Storage::Rackspace::BadRequest] - HTTP 400 + # @raise [Fog::Storage::Rackspace::InternalServerError] - HTTP 500 + # @raise [Fog::Storage::Rackspace::ServiceError] + def extract_archive(container, data, archive_format) + data = Fog::Storage.parse_data(data) + headers = data[:headers] + + params = { :body => data[:body], :query => {"extract-archive" => archive_format} } + + params.merge!( + :expects => 200, + :idempotent => true, + :headers => headers, + :method => 'PUT', + :path => "#{Fog::Rackspace.escape(container.to_s)}" + ) + + request(params) + end + end + end + end +end \ No newline at end of file diff --git a/lib/fog/rackspace/storage.rb b/lib/fog/rackspace/storage.rb index 9ecf13079..937bec6f3 100644 --- a/lib/fog/rackspace/storage.rb +++ b/lib/fog/rackspace/storage.rb @@ -41,6 +41,7 @@ module Fog request :put_dynamic_obj_manifest request :put_static_obj_manifest request :post_set_meta_temp_url_key + request :extract_archive module Common def apply_options(options)