Method: HP::Cloud::RemoteResource#remove

Defined in:
lib/hpcloud/remote_resource.rb

#remove(force, at = nil, after = nil) ⇒ Object



453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
# File 'lib/hpcloud/remote_resource.rb', line 453

def remove(force, at=nil, after=nil)
  begin
    return false unless container_head()
    if at.nil?
      if after.nil?
        @storage.delete_object(@container, @path)
      else
        hsh = { 'X-Delete-After' => after}
        @storage.post_object(@container, @path, hsh)
      end
    else
      hsh = { 'X-Delete-At' => at}
      @storage.post_object(@container, @path, hsh)
    end
  rescue Fog::Storage::HP::NotFound => error
    @cstatus = CliStatus.new("You don't have an object named '#{@fname}'.", :not_found)
    return false
  rescue Excon::Errors::Forbidden => error
    @cstatus = CliStatus.new("Permission denied for '#{@fname}.", :permission_denied)
    return false
  rescue Exception => e
    @cstatus = CliStatus.new("Exception removing '#{@fname}': " + e.to_s, :general_error)
    return false
  end
  return true
end