mirror of
https://github.com/fog/fog-aws.git
synced 2022-11-09 13:50:52 -05:00
Support NonCurrentVersion[Expiration,Transition] for s3 lifecycle.
This commit is contained in:
parent
de90f98574
commit
8a2066af07
2 changed files with 30 additions and 2 deletions
|
@ -10,11 +10,11 @@ module Fog
|
|||
# * ID [String] Unique identifier for the rule
|
||||
# * Prefix [String] Prefix identifying one or more objects to which the rule applies
|
||||
# * Enabled [Boolean] if rule is currently being applied
|
||||
# * Expiration [Hash] Container for the object expiration rule.
|
||||
# * [NonCurrentVersion]Expiration [Hash] Container for the object expiration rule.
|
||||
# * Days [Integer] lifetime, in days, of the objects that are subject to the rule
|
||||
# * Date [Date] Indicates when the specific rule take effect.
|
||||
# The date value must conform to the ISO 8601 format. The time is always midnight UTC.
|
||||
# * Transition [Hash] Container for the transition rule that describes when objects transition
|
||||
# * [NonCurrentVersion]Transition [Hash] Container for the transition rule that describes when objects transition
|
||||
# to the Glacier storage class
|
||||
# * Days [Integer] lifetime, in days, of the objects that are subject to the rule
|
||||
# * Date [Date] Indicates when the specific rule take effect.
|
||||
|
@ -43,6 +43,19 @@ module Fog
|
|||
Expiration { Date rule['Expiration']['Date'].is_a?(Time) ? rule['Expiration']['Date'].utc.iso8601 : Time.parse(rule['Expiration']['Date']).utc.iso8601 }
|
||||
end
|
||||
end
|
||||
if rule['NonCurrentVersionExpiration']
|
||||
if rule['NonCurrentVersoinExpiration']['Days']
|
||||
NonCurrentVersoinExpiration { Days rule['NonCurrentVersoinExpiration']['Days'] }
|
||||
elsif rule['NonCurrentVersoinExpiration']['Date']
|
||||
NonCurrentVersoinExpiration {
|
||||
if Date rule['NonCurrentVersoinExpiration']['Date'].is_a?(Time)
|
||||
rule['NonCurrentVersoinExpiration']['Date'].utc.iso8601
|
||||
else
|
||||
Time.parse(rule['NonCurrentVersoinExpiration']['Date']).utc.iso8601
|
||||
end
|
||||
}
|
||||
end
|
||||
end
|
||||
if rule['Transition']
|
||||
Transition {
|
||||
if rule['Transition']['Days']
|
||||
|
@ -53,6 +66,16 @@ module Fog
|
|||
StorageClass rule['Transition']['StorageClass'].nil? ? 'GLACIER' : rule['Transition']['StorageClass']
|
||||
}
|
||||
end
|
||||
if rule['NonCurrentVersionTransition']
|
||||
NonCurrentVersionTransition {
|
||||
if rule['NonCurrentVersionTransition']['Days']
|
||||
Days rule['NonCurrentVersionTransition']['Days']
|
||||
elsif rule['NonCurrentVersionTransition']['Date']
|
||||
Date rule['NonCurrentVersionTransition']['Date'].is_a?(Time) ? time.utc.iso8601 : Time.parse(time).utc.iso8601
|
||||
end
|
||||
StorageClass rule['NonCurrentVersionTransition']['StorageClass'].nil? ? 'GLACIER' : rule['NonCurrentVersionTransition']['StorageClass']
|
||||
}
|
||||
end
|
||||
end
|
||||
}
|
||||
end
|
||||
|
|
|
@ -277,6 +277,11 @@ Shindo.tests('Fog::Storage[:aws] | bucket requests', ["aws"]) do
|
|||
Fog::Storage[:aws].put_bucket_lifecycle(@aws_bucket_name, lifecycle)
|
||||
Fog::Storage[:aws].get_bucket_lifecycle(@aws_bucket_name).body
|
||||
end
|
||||
lifecycle = {'Rules' => [{'ID' => 'test rule', 'Prefix' => '/prefix', 'Enabled' => true, 'NonCurrentVersionExpiration' => {'Days' => 42}, 'NonCurrentVersionTransition' => {'Days' => 6, 'StorageClass'=>'GLACIER'}}]}
|
||||
tests('versioned transition').returns(lifecycle) do
|
||||
Fog::Storage[:aws].put_bucket_lifecycle(@aws_bucket_name, lifecycle)
|
||||
Fog::Storage[:aws].get_bucket_lifecycle(@aws_bucket_name).body
|
||||
end
|
||||
lifecycle = {'Rules' => [{'ID' => 'test rule', 'Prefix' => '/prefix', 'Enabled' => true, 'Expiration' => {'Date' => '2012-12-31T00:00:00.000Z'}}]}
|
||||
tests('date').returns(lifecycle) do
|
||||
Fog::Storage[:aws].put_bucket_lifecycle(@aws_bucket_name, lifecycle)
|
||||
|
|
Loading…
Add table
Reference in a new issue