mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
Merge pull request #3652 from razorinc/openstack/delete_at
[openstack][Storage] Added the delete_at and delete_after flags
This commit is contained in:
commit
b2f62a86c7
2 changed files with 39 additions and 0 deletions
|
@ -14,6 +14,17 @@ module Fog
|
|||
attribute :last_modified, :aliases => ['last_modified', 'Last-Modified'], :type => :time
|
||||
attribute :metadata
|
||||
attribute :origin, :aliases => ['Origin']
|
||||
# @!attribute [rw] delete_at
|
||||
# A Unix Epoch Timestamp, in integer form, representing the time when this object will be automatically deleted.
|
||||
# @return [Integer] the unix epoch timestamp of when this object will be automatically deleted
|
||||
# @see http://docs.openstack.org/developer/swift/overview_expiring_objects.html
|
||||
attribute :delete_at, :aliases => ['X-Delete-At']
|
||||
|
||||
# @!attribute [rw] delete_after
|
||||
# A number of seconds representing how long from now this object will be automatically deleted.
|
||||
# @return [Integer] the number of seconds until this object will be automatically deleted
|
||||
# @see http://docs.openstack.org/developer/swift/overview_expiring_objects.html
|
||||
attribute :delete_after, :aliases => ['X-Delete-After']
|
||||
|
||||
def body
|
||||
attributes[:body] ||= if last_modified
|
||||
|
@ -88,6 +99,8 @@ module Fog
|
|||
options['Content-Disposition'] = content_disposition if content_disposition
|
||||
options['Access-Control-Allow-Origin'] = access_control_allow_origin if access_control_allow_origin
|
||||
options['Origin'] = origin if origin
|
||||
options['X-Delete-At'] = delete_at if delete_at
|
||||
options['X-Delete-After'] = delete_after if delete_after
|
||||
options.merge!(metadata_to_headers)
|
||||
|
||||
data = service.put_object(directory.key, key, body, options)
|
||||
|
|
|
@ -156,6 +156,32 @@ Shindo.tests('Fog::OpenStack::Storage | file', ['openstack']) do
|
|||
|
||||
end
|
||||
|
||||
tests("#delete_at") do
|
||||
@delete_at_time = (Time.now + 300).to_i
|
||||
|
||||
tests("#delete_at should default to nil").returns(nil) do
|
||||
@instance.delete_at
|
||||
end
|
||||
|
||||
@instance.delete_at = @delete_at_time
|
||||
@instance.save
|
||||
tests("#delete_at should return delete_at attribute").returns(@delete_at_time) do
|
||||
@instance.delete_at
|
||||
end
|
||||
|
||||
@instance.delete_at = @delete_at_time
|
||||
@instance.save
|
||||
tests("#delete_at= should update delete_at").returns(@delete_at_time + 100) do
|
||||
@instance.delete_at = @delete_at_time + 100
|
||||
@instance.save
|
||||
@instance.delete_at
|
||||
end
|
||||
|
||||
tests("#delete_at= should not blow up on nil") do
|
||||
@instance.delete_at = nil
|
||||
@instance.save
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
model_tests(@directory.files, file_attributes, Fog.mocking?) do
|
||||
|
|
Loading…
Reference in a new issue