Class: DefraRuby::Aws::Bucket
- Inherits:
-
Object
- Object
- DefraRuby::Aws::Bucket
- Defined in:
- lib/defra_ruby/aws/bucket.rb
Instance Attribute Summary collapse
-
#bucket_name ⇒ Object
readonly
Returns the value of attribute bucket_name.
-
#credentials ⇒ Object
readonly
Returns the value of attribute credentials.
-
#encrypt_with_kms ⇒ Object
readonly
Returns the value of attribute encrypt_with_kms.
-
#region ⇒ Object
readonly
Returns the value of attribute region.
Instance Method Summary collapse
- #access_key_id ⇒ Object
- #delete(file_name) ⇒ Object
- #encryption_type ⇒ Object
-
#initialize(configs) ⇒ Bucket
constructor
A new instance of Bucket.
- #load(file) ⇒ Object
- #presigned_url(file_name) ⇒ Object
- #secret_access_key ⇒ Object
Constructor Details
#initialize(configs) ⇒ Bucket
Returns a new instance of Bucket.
8 9 10 11 12 13 14 15 |
# File 'lib/defra_ruby/aws/bucket.rb', line 8 def initialize(configs) @credentials = configs[:credentials] @bucket_name = configs[:name] @region = setup_region(configs[:region]) @encrypt_with_kms = setup_encrypt_with_kms(configs[:encrypt_with_kms]) validate! end |
Instance Attribute Details
#bucket_name ⇒ Object (readonly)
Returns the value of attribute bucket_name.
6 7 8 |
# File 'lib/defra_ruby/aws/bucket.rb', line 6 def bucket_name @bucket_name end |
#credentials ⇒ Object (readonly)
Returns the value of attribute credentials.
6 7 8 |
# File 'lib/defra_ruby/aws/bucket.rb', line 6 def credentials @credentials end |
#encrypt_with_kms ⇒ Object (readonly)
Returns the value of attribute encrypt_with_kms.
6 7 8 |
# File 'lib/defra_ruby/aws/bucket.rb', line 6 def encrypt_with_kms @encrypt_with_kms end |
#region ⇒ Object
Returns the value of attribute region.
6 7 8 |
# File 'lib/defra_ruby/aws/bucket.rb', line 6 def region @region end |
Instance Method Details
#access_key_id ⇒ Object
17 18 19 |
# File 'lib/defra_ruby/aws/bucket.rb', line 17 def access_key_id credentials[:access_key_id] end |
#delete(file_name) ⇒ Object
37 38 39 |
# File 'lib/defra_ruby/aws/bucket.rb', line 37 def delete(file_name) DeleteFileFromBucketService.run(self, file_name) end |
#encryption_type ⇒ Object
25 26 27 |
# File 'lib/defra_ruby/aws/bucket.rb', line 25 def encryption_type @_encryption_type ||= @encrypt_with_kms ? "aws:kms" : :AES256 end |
#load(file) ⇒ Object
29 30 31 |
# File 'lib/defra_ruby/aws/bucket.rb', line 29 def load(file) BucketLoaderService.run(self, file) end |
#presigned_url(file_name) ⇒ Object
33 34 35 |
# File 'lib/defra_ruby/aws/bucket.rb', line 33 def presigned_url(file_name) PresignedUrlService.run(self, file_name) end |
#secret_access_key ⇒ Object
21 22 23 |
# File 'lib/defra_ruby/aws/bucket.rb', line 21 def secret_access_key credentials[:secret_access_key] end |