class ArchivedRemoteObject::AwsS3::ArchivedObject
Constants
- RestoreResponseChangedError
Attributes
key[RW]
remote_object[RW]
Public Class Methods
new( key:, remote_object: AwsS3::RemoteObject.new(key: key) )
click to toggle source
# File lib/archived_remote_object/aws_s3/archived_object.rb, line 8 def initialize( key:, remote_object: AwsS3::RemoteObject.new(key: key) ) self.key = key self.remote_object = remote_object end
Public Instance Methods
archived?()
click to toggle source
# File lib/archived_remote_object/aws_s3/archived_object.rb, line 16 def archived? remote_object.attributes.storage_class == "DEEP_ARCHIVE" end
debug_state()
click to toggle source
# File lib/archived_remote_object/aws_s3/archived_object.rb, line 45 def debug_state remote_object.debug_state end
restore()
click to toggle source
# File lib/archived_remote_object/aws_s3/archived_object.rb, line 33 def restore remote_object.restore(key: key, duration: restore_duration_days) end
restore_in_progress?()
click to toggle source
# File lib/archived_remote_object/aws_s3/archived_object.rb, line 20 def restore_in_progress? restore_in_progress = parse_restore_status[0] return false unless restore_in_progress restore_in_progress.to_s.downcase == "true" end
restored?()
click to toggle source
# File lib/archived_remote_object/aws_s3/archived_object.rb, line 27 def restored? return false unless expiry_date Time.parse(expiry_date) > Time.now end
stop_archiving_on_duration()
click to toggle source
# File lib/archived_remote_object/aws_s3/archived_object.rb, line 37 def stop_archiving_on_duration remote_object.storage_class = 'STANDARD' end
sync()
click to toggle source
# File lib/archived_remote_object/aws_s3/archived_object.rb, line 41 def sync tap { remote_object.sync } end
Private Instance Methods
expiry_date()
click to toggle source
# File lib/archived_remote_object/aws_s3/archived_object.rb, line 57 def expiry_date parse_restore_status[1] end
parse_restore_status()
click to toggle source
# File lib/archived_remote_object/aws_s3/archived_object.rb, line 61 def parse_restore_status remote_object.attributes.restore =~ /ongoing-request="(.+?)"(, expiry-date="(.+?)")?/ last_match = Regexp.last_match raise RestoreResponseChangedError if !remote_object.attributes.restore.nil? && !last_match last_match&.captures || [] end
restore_duration_days()
click to toggle source
# File lib/archived_remote_object/aws_s3/archived_object.rb, line 53 def restore_duration_days ArchivedRemoteObject.configuration.archive_restore_duration_days end