archived_remote_object 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6a23d5372acad1ed18a22290fa96896f087af0a44a845aaa3b0bad2286548f6e
4
- data.tar.gz: 67df0189bc73dc809acf27cbccff73bfd40e67aed2dfb5f0bbd5ed9a08821ead
3
+ metadata.gz: b8fd27ad3b07bda906169814dea5a5e305174715de286d749c9825dfdd5f2d98
4
+ data.tar.gz: e67315f5d0825f5c66cef22667424b1a5d90f04e060ec91801cd3a00e376131e
5
5
  SHA512:
6
- metadata.gz: 832ba8691bc45707ee395dd262c4775b1f8c665bf6fd547f5bd0ddff2636e46ebec96ab5bb272e829b7de475c0c318e53dac1a551304731f638ad434cef194a5
7
- data.tar.gz: a581302350ca3880e276b68db2d158f8be63f61481fd79066e2b3f73e78fdac35eb8362390c5b3614a136507684fd8fc9e6d8e7b00d1a935dd703c717e0ff301
6
+ metadata.gz: daa4996fb18897a4ec59844e858d997e581fbfba067374243d5f02f649913642b3a22b1f056868dad3e7dde84b51d4918031312b8c83774ee115523c4243060e
7
+ data.tar.gz: 55b449a47b42b1a36bb2f1f17c893421f9628b5a96ccc53d3dbeffdc2f2a5375c9538048932775434bd75077ecd9ef0940d7da9da7bcea014a42620dfacfbb4b
@@ -4,6 +4,7 @@ module ArchivedRemoteObject
4
4
  module Archive
5
5
  class ArchivedObject
6
6
  CantBeRestoredError = Class.new(StandardError)
7
+ CantStopArchivingOnDurationError = Class.new(StandardError)
7
8
 
8
9
  def initialize(
9
10
  key:,
@@ -34,6 +35,12 @@ module ArchivedRemoteObject
34
35
  remote_object.restore
35
36
  end
36
37
 
38
+ def stop_archiving_on_duration
39
+ raise CantStopArchivingOnDurationError if !restored? || restore_in_progress?
40
+
41
+ remote_object.stop_archiving_on_duration
42
+ end
43
+
37
44
  def available?
38
45
  !archived? || restored?
39
46
  end
@@ -34,6 +34,10 @@ module ArchivedRemoteObject
34
34
  remote_object.restore(key: key, duration: restore_duration_days)
35
35
  end
36
36
 
37
+ def stop_archiving_on_duration
38
+ remote_object.storage_class = 'STANDARD'
39
+ end
40
+
37
41
  def sync
38
42
  tap { remote_object.sync }
39
43
  end
@@ -33,6 +33,11 @@ module ArchivedRemoteObject
33
33
  s3_client.restore_object(bucket: bucket, key: key, restore_request: { days: duration })
34
34
  end
35
35
 
36
+ def assign_storage_class(key:, storage_class:)
37
+ s3_client.stub_responses(:copy_object) if stubbed?
38
+ s3_client.copy_object(bucket: bucket, key: key, copy_source: "#{bucket}/#{key}", storage_class: storage_class)
39
+ end
40
+
36
41
  private
37
42
 
38
43
  def bucket
@@ -23,6 +23,11 @@ module ArchivedRemoteObject
23
23
  remote_client.restore(**args)
24
24
  end
25
25
 
26
+ def storage_class=(storage_class)
27
+ # accepts STANDARD, STANDARD_IA, ONEZONE_IA, GLACIER, INTELLIGENT_TIERING, DEEP_ARCHIVE
28
+ remote_client.assign_storage_class(key: key, storage_class: storage_class)
29
+ end
30
+
26
31
  def sync
27
32
  tap { fetch_attributes }
28
33
  end
@@ -1,3 +1,3 @@
1
1
  module ArchivedRemoteObject
2
- VERSION = "0.1.1".freeze
2
+ VERSION = "0.1.2".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: archived_remote_object
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aleksey Strizhak
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-02-07 00:00:00.000000000 Z
11
+ date: 2021-05-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk
@@ -104,7 +104,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
104
104
  - !ruby/object:Gem::Version
105
105
  version: '0'
106
106
  requirements: []
107
- rubygems_version: 3.0.3
107
+ rubygems_version: 3.2.16
108
108
  signing_key:
109
109
  specification_version: 4
110
110
  summary: Get archived remote object with delayed restore