archived_remote_object 0.1.4 → 0.1.5
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b0210c27f442830b091c1849865ace9a29e961fea290e953e85e3315458e774a
|
4
|
+
data.tar.gz: 3024af7b02b867cb3a56f752a4cc714a0d457965a6c9737b6edd5dd2cd880be9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eefb9c00c28a82b6f3722f52daa39e0edb6b0aee1fe6d652a3f091c003ccb56de792efd4f7821b901f9e7b41da84c95b905570d29e06529cdfa3ba248f88b1e5
|
7
|
+
data.tar.gz: 33eacea6fee046f83957d2fb8d79dbc0bf4456173a566f4cc062b1f8e789cdcb985f00d19de3e30d34e610e8a2db0e2153fa5a4f0834129f12c7d9545e5b82a1
|
@@ -7,7 +7,7 @@ module ArchivedRemoteObject
|
|
7
7
|
|
8
8
|
def initialize
|
9
9
|
self.s3_client = Aws::S3::Client.new(
|
10
|
-
stub_responses:
|
10
|
+
stub_responses: stub_enabled?,
|
11
11
|
region: ArchivedRemoteObject.configuration.aws_region,
|
12
12
|
credentials: Aws::Credentials.new(
|
13
13
|
ArchivedRemoteObject.configuration.aws_access_key_id,
|
@@ -17,7 +17,7 @@ module ArchivedRemoteObject
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def fetch_object_data(key:, stubbed_response: {})
|
20
|
-
if stubbed?
|
20
|
+
if stub_enabled? && !stubbed?(:head_object)
|
21
21
|
response = {
|
22
22
|
storage_class: "DEEP_ARCHIVE",
|
23
23
|
restore: nil,
|
@@ -29,34 +29,44 @@ module ArchivedRemoteObject
|
|
29
29
|
end
|
30
30
|
|
31
31
|
def restore(key:, duration:)
|
32
|
-
s3_client.stub_responses(:restore_object) if stubbed?
|
32
|
+
s3_client.stub_responses(:restore_object) if stub_enabled? && !stubbed?(:restore_object)
|
33
33
|
s3_client.restore_object(bucket: bucket, key: key, restore_request: { days: duration })
|
34
34
|
end
|
35
35
|
|
36
36
|
def assign_tag(key:, set:)
|
37
|
-
s3_client.stub_responses(:put_object_tagging) if stubbed?
|
37
|
+
s3_client.stub_responses(:put_object_tagging) if stub_enabled? && !stubbed?(:put_object_tagging)
|
38
38
|
s3_client.put_object_tagging(bucket: bucket, key: key, tagging: { tag_set: [{ key: set[0], value: set[1] }] })
|
39
39
|
end
|
40
40
|
|
41
41
|
def assign_storage_class(key:, storage_class:)
|
42
|
-
s3_client.stub_responses(:copy_object) if stubbed?
|
42
|
+
s3_client.stub_responses(:copy_object) if stub_enabled? && !stubbed?(:copy_object)
|
43
43
|
s3_client.copy_object(bucket: bucket, key: key, copy_source: "#{bucket}/#{key}", storage_class: storage_class)
|
44
44
|
end
|
45
45
|
|
46
46
|
def delete(key:)
|
47
|
-
s3_client.stub_responses(:delete_object) if stubbed?
|
47
|
+
s3_client.stub_responses(:delete_object) if stub_enabled? && !stubbed?(:delete_object)
|
48
48
|
s3_client.delete_object(bucket: bucket, key: key)
|
49
49
|
end
|
50
50
|
|
51
|
+
def exists?(key:)
|
52
|
+
!!fetch_object_data(key: key)
|
53
|
+
rescue Aws::S3::Errors::NotFound
|
54
|
+
false
|
55
|
+
end
|
56
|
+
|
51
57
|
private
|
52
58
|
|
53
59
|
def bucket
|
54
60
|
ArchivedRemoteObject.configuration.aws_bucket
|
55
61
|
end
|
56
62
|
|
57
|
-
def
|
63
|
+
def stub_enabled?
|
58
64
|
ArchivedRemoteObject.configuration.stub_client_requests
|
59
65
|
end
|
66
|
+
|
67
|
+
def stubbed?(key)
|
68
|
+
!!s3_client.instance_variable_get('@stubs').fetch(key, nil)
|
69
|
+
end
|
60
70
|
end
|
61
71
|
end
|
62
72
|
end
|