Class: Aws::S3::Resource
- Inherits:
-
Object
- Object
- Aws::S3::Resource
- Defined in:
- lib/aws-sdk-s3/resource.rb
Overview
This class provides a resource oriented interface for S3. To create a resource object:
resource = Aws::S3::Resource.new(region: 'us-west-2')
You can supply a client object with custom configuration that will be used for all resource operations. If you do not pass ‘:client`, a default client will be constructed.
client = Aws::S3::Client.new(region: 'us-west-2')
resource = Aws::S3::Resource.new(client: client)
Actions collapse
Associations collapse
Instance Method Summary collapse
- #client ⇒ Client
-
#initialize(options = {}) ⇒ Resource
constructor
A new instance of Resource.
Constructor Details
#initialize(options = {}) ⇒ Resource
Returns a new instance of Resource.
27 28 29 |
# File 'lib/aws-sdk-s3/resource.rb', line 27 def initialize( = {}) @client = [:client] || Client.new() end |
Instance Method Details
#bucket(name) ⇒ Bucket
182 183 184 185 186 187 |
# File 'lib/aws-sdk-s3/resource.rb', line 182 def bucket(name) Bucket.new( name: name, client: @client ) end |
#buckets(options = {}) ⇒ Bucket::Collection
194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 |
# File 'lib/aws-sdk-s3/resource.rb', line 194 def buckets( = {}) batches = Enumerator.new do |y| resp = Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do @client.list_buckets() end resp.each_page do |page| batch = [] page.data.buckets.each do |b| batch << Bucket.new( name: b.name, data: b, client: @client ) end y.yield(batch) end end Bucket::Collection.new(batches) end |
#create_bucket(options = {}) ⇒ Bucket
168 169 170 171 172 173 174 175 176 |
# File 'lib/aws-sdk-s3/resource.rb', line 168 def create_bucket( = {}) Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do @client.create_bucket() end Bucket.new( name: [:bucket], client: @client ) end |