Class: Stax::Aws::S3

Inherits:
Sdk
  • Object
show all
Defined in:
lib/stax/aws/s3.rb

Constant Summary

Constants inherited from Sdk

Stax::Aws::Sdk::RETRY_LIMIT

Class Method Summary collapse

Methods inherited from Sdk

paginate

Class Method Details

.bucket_region(bucket) ⇒ Object



27
28
29
# File 'lib/stax/aws/s3.rb', line 27

def bucket_region(bucket)
  client.get_bucket_location(bucket: bucket).location_constraint
end

.bucket_tags(bucket) ⇒ Object



17
18
19
20
21
22
23
24
25
# File 'lib/stax/aws/s3.rb', line 17

def bucket_tags(bucket)
  client.get_bucket_tagging(bucket: bucket).tag_set
rescue ::Aws::Errors::NoSuchEndpointError
  warn("socket error for #{bucket}, retrying")
  sleep 1
  retry
rescue ::Aws::S3::Errors::NoSuchTagSet
  []
end

.clientObject



9
10
11
# File 'lib/stax/aws/s3.rb', line 9

def client
  @_client ||= ::Aws::S3::Client.new
end

.get_lifecycle(bucket) ⇒ Object



41
42
43
# File 'lib/stax/aws/s3.rb', line 41

def get_lifecycle(bucket)
  client.get_bucket_lifecycle_configuration(bucket: bucket).rules
end

.list_bucketsObject



13
14
15
# File 'lib/stax/aws/s3.rb', line 13

def list_buckets
  client.list_buckets.buckets
end

.location(bucket) ⇒ Object

get region, return us-east-1 if empty



32
33
34
35
# File 'lib/stax/aws/s3.rb', line 32

def location(bucket)
  l = client.get_bucket_location(bucket: bucket).location_constraint
  l.empty? ? 'us-east-1' : l
end

.put(opt) ⇒ Object



37
38
39
# File 'lib/stax/aws/s3.rb', line 37

def put(opt)
  client.put_object(opt)
end

.put_lifecycle(bucket, cfg) ⇒ Object



45
46
47
# File 'lib/stax/aws/s3.rb', line 45

def put_lifecycle(bucket, cfg)
  client.put_bucket_lifecycle_configuration(bucket: bucket, lifecycle_configuration: cfg)
end