Class: ArchivedRemoteObject::AwsS3::ArchivedObject

Inherits:
Object
  • Object
show all
Defined in:
lib/archived_remote_object/aws_s3/archived_object.rb

Constant Summary collapse

RestoreResponseChangedError =
Class.new(StandardError)

Instance Method Summary collapse

Constructor Details

#initialize(key:, remote_object: AwsS3::RemoteObject.new(key: key)) ⇒ ArchivedObject

Returns a new instance of ArchivedObject.



8
9
10
11
12
13
14
# 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

Instance Method Details

#archived?Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/archived_remote_object/aws_s3/archived_object.rb', line 16

def archived?
  remote_object.attributes.storage_class == "DEEP_ARCHIVE"
end

#debug_stateObject



45
46
47
# File 'lib/archived_remote_object/aws_s3/archived_object.rb', line 45

def debug_state
  remote_object.debug_state
end

#restoreObject



33
34
35
# 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?Boolean

Returns:

  • (Boolean)


20
21
22
23
24
25
# 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?Boolean

Returns:

  • (Boolean)


27
28
29
30
31
# 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_durationObject



37
38
39
# File 'lib/archived_remote_object/aws_s3/archived_object.rb', line 37

def stop_archiving_on_duration
  remote_object.storage_class = 'STANDARD'
end

#syncObject



41
42
43
# File 'lib/archived_remote_object/aws_s3/archived_object.rb', line 41

def sync
  tap { remote_object.sync }
end