Module: Cumulus::S3
- Defined in:
- lib/s3/S3.rb,
lib/s3/Commands.rb,
lib/s3/loader/Loader.rb,
lib/s3/manager/Manager.rb,
lib/s3/models/GrantDiff.rb,
lib/s3/models/BucketDiff.rb,
lib/s3/models/GrantConfig.rb,
lib/s3/models/BucketConfig.rb,
lib/s3/models/LifecycleDiff.rb,
lib/s3/models/LoggingConfig.rb,
lib/s3/models/WebsiteConfig.rb,
lib/s3/models/LifecycleConfig.rb,
lib/s3/models/ReplicationDiff.rb,
lib/s3/models/NotificationDiff.rb,
lib/s3/models/ReplicationConfig.rb,
lib/s3/models/NotificationConfig.rb,
lib/s3/models/DefaultEncryptionDiff.rb,
lib/s3/models/DefaultEncryptionConfig.rb
Defined Under Namespace
Modules: BucketChange, DefaultEncryptionChange, GrantChange, LifecycleChange, Loader, NotificationChange, ReplicationChange Classes: BucketConfig, BucketDiff, Commands, DefaultEncryptionConfig, DefaultEncryptionDiff, GrantConfig, GrantDiff, LifecycleConfig, LifecycleDiff, LoggingConfig, Manager, NotificationConfig, NotificationDiff, ReplicationConfig, ReplicationDiff, WebsiteConfig
Constant Summary collapse
- @@zone_ids =
{ "ap-northeast-1" => "Z2M4EHUR26P7ZW", "ap-southeast-1" => "Z3O0J2DXBE1FTB", "ap-southeast-2" => "Z1WCIGYICN2BYD", "eu-central-1" => "Z21DNDUVLTQW6Q", "eu-west-1" => "Z1BKCTXD74EZPE", "sa-east-1" => "Z7KQH4QJS55SO", "us-east-1" => "Z3AQBSTGFYJSTF", "us-gov-west-1" => "Z31GFT0UA1I2HV", "us-west-1" => "Z2F56UZL2M1ACD", "us-west-2" => "Z3BJ6K6RIION7M", }
Class Method Summary collapse
-
.buckets ⇒ Object
Public: Provide a mapping of S3 buckets to their names.
- .client(region = nil) ⇒ Object
-
.full_bucket(bucket_name) ⇒ Object
Public: Get the full data for a bucket.
-
.get_aws(name) ⇒ Object
Public: Static method that will get an S3 bucket from AWS by its name.
-
.refresh! ⇒ Object
Public: Refereshes the bucket list and full_buckets map.
-
.zone_ids ⇒ Object
Public: A mapping of region name to its hosted zone id.
Class Method Details
.buckets ⇒ Object
Public: Provide a mapping of S3 buckets to their names. Lazily loads resources.
Returns the buckets mapped to their names
62 63 64 |
# File 'lib/s3/S3.rb', line 62 def buckets @buckets ||= init_buckets end |
.client(region = nil) ⇒ Object
8 9 10 11 12 |
# File 'lib/s3/S3.rb', line 8 def client(region = nil) @clients ||= {} if !region then region = "us-east-1" end @clients[region] ||= Aws::S3::Client.new(Configuration.instance.client.merge({:force_path_style => true, :region => region})) end |
.full_bucket(bucket_name) ⇒ Object
Public: Get the full data for a bucket. Lazily loads resources only once.
bucket_name - the name of the bucket to get
Returns the full bucket
51 52 53 54 55 56 57 |
# File 'lib/s3/S3.rb', line 51 def full_bucket(bucket_name) @monkey_patched ||= monkey_patch_bucket @full_buckets ||= Hash.new bucket = buckets[bucket_name] @full_buckets[bucket_name] ||= Aws::S3::Bucket.new(name: bucket_name, client: client(bucket.location)) end |
.get_aws(name) ⇒ Object
Public: Static method that will get an S3 bucket from AWS by its name
name - the name of the bucket to get
Returns the Aws::S3::Types::Bucket by that name
39 40 41 42 43 44 |
# File 'lib/s3/S3.rb', line 39 def get_aws(name) buckets.fetch(name) rescue KeyError puts "No S3 bucket named #{name}" exit end |
.refresh! ⇒ Object
Public: Refereshes the bucket list and full_buckets map
67 68 69 70 |
# File 'lib/s3/S3.rb', line 67 def refresh! @buckets = init_buckets @full_buckets = Hash.new end |
.zone_ids ⇒ Object
Public: A mapping of region name to its hosted zone id. This mapping is needed because the S3 API doesn’t expose the hosted ids, you have to get them at docs.aws.amazon.com/general/latest/gr/rande.html#s3_region.
30 31 32 |
# File 'lib/s3/S3.rb', line 30 def zone_ids @@zone_ids end |