Sha256: c54e25afe1b0c1f6d4996fc1633cd6eaac845a54c675d7277fea6846f7750c56

Contents?: true

Size: 1.36 KB

Versions: 1

Compression:

Stored size: 1.36 KB

Contents

module Fog
  module Google
    class Storage
      class Real

        # Delete an object from Google Storage
        #
        # ==== Parameters
        # * bucket_name<~String> - Name of bucket containing object to delete
        # * object_name<~String> - Name of object to delete
        #
        # ==== Returns
        # * response<~Excon::Response>:
        #   * status<~Integer> - 204
        def delete_object(bucket_name, object_name)
          request({
            :expects    => 204,
            :headers    => {},
            :host       => "#{bucket_name}.#{@host}",
            :idempotent => true,
            :method     => 'DELETE',
            :path       => CGI.escape(object_name)
          })
        end

      end

      class Mock

        def delete_object(bucket_name, object_name)
          response = Excon::Response.new
          if bucket = self.data[:buckets][bucket_name]
            if object = bucket[:objects][object_name]
              response.status = 204
              bucket[:objects].delete(object_name)
            else
              response.status = 404
              raise(Excon::Errors.status_error({:expects => 204}, response))
            end
          else
            response.status = 404
            raise(Excon::Errors.status_error({:expects => 204}, response))
          end
          response
        end

      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fog-0.8.2 lib/fog/storage/requests/google/delete_object.rb