diff --git a/lib/fog/openstack/models/storage/file.rb b/lib/fog/openstack/models/storage/file.rb index 2427be68b..474302dcb 100644 --- a/lib/fog/openstack/models/storage/file.rb +++ b/lib/fog/openstack/models/storage/file.rb @@ -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) diff --git a/tests/openstack/models/storage/file_tests.rb b/tests/openstack/models/storage/file_tests.rb index b4b9361e1..02d36624e 100644 --- a/tests/openstack/models/storage/file_tests.rb +++ b/tests/openstack/models/storage/file_tests.rb @@ -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