Sha256: f89c703ebabc8d7a0c2115f7ffebcf55470900ad08fe9ffd3529380d1cda04d6

Contents?: true

Size: 775 Bytes

Versions: 3

Compression:

Stored size: 775 Bytes

Contents

module S3Secure::Lifecycle
  class Remove < Base
    RULE_ID = Base::RULE_ID

    def run
      show = Show.new(@options)
      unless show.has?(RULE_ID)
        say "Bucket #{@bucket} already does not have the #{RULE_ID} lifecycle rule."
        return
      end

      builder = Builder.new(show.get_lifecycle_rules(@bucket))
      rules = builder.rules_with_removal
      if rules.empty?
        s3.delete_bucket_lifecycle(bucket: @bucket)
      else
        # update config with removal
        s3.put_bucket_lifecycle_configuration(
          bucket: @bucket, # required
          # content_md5: "ContentMD5",
          lifecycle_configuration: {rules: rules}
        )
      end

      say "Removed the #{RULE_ID} lifecycle rule on bucket #{@bucket}"
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
s3-secure-0.7.0 lib/s3_secure/lifecycle/remove.rb
s3-secure-0.6.1 lib/s3_secure/lifecycle/remove.rb
s3-secure-0.6.0 lib/s3_secure/lifecycle/remove.rb