Class: CFRuntime::AWSS3Client
- Inherits:
-
Object
- Object
- CFRuntime::AWSS3Client
- Defined in:
- lib/cf-runtime/aws_s3.rb
Class Method Summary collapse
-
.create(options = {}) ⇒ Object
Creates and returns an AWS-S3
Client
instance. -
.create_from_svc(service_name, options = {}) ⇒ Object
Creates and returns a AWS-S3
Client
instance connected to a blob service with the specified name. -
.options_for_svc(service_name, options = {}) ⇒ Object
Merges provided options with connection options for specified blob service.
Class Method Details
.create(options = {}) ⇒ Object
Creates and returns an AWS-S3 Client
instance. Passes optional Hash of non-connection-related options to AWS::S3::Base.establish_connection!
. Raises ArgumentError
If zero or multiple blob services are found.
9 10 11 12 13 14 15 16 17 |
# File 'lib/cf-runtime/aws_s3.rb', line 9 def self.create(={}) service_names = CloudApp.service_names_of_type('blob') if service_names.length != 1 raise ArgumentError.new("Expected 1 service of blob type, " + "but found #{service_names.length}. " + "Consider using create_from_svc(service_name) instead.") end create_from_svc(service_names[0],) end |
.create_from_svc(service_name, options = {}) ⇒ Object
Creates and returns a AWS-S3 Client
instance connected to a blob service with the specified name. Passes optional Hash of non-connection-related options to AWS::S3::Base.establish_connection!
. Raises ArgumentError
If specified blob service is not found.
23 24 25 |
# File 'lib/cf-runtime/aws_s3.rb', line 23 def self.create_from_svc(service_name, ={}) AWS::S3::Base.establish_connection!((service_name,)) end |
.options_for_svc(service_name, options = {}) ⇒ Object
Merges provided options with connection options for specified blob service. Returns merged Hash containing (:access_key_id, :secret_access_key, :server, :port). Raises ArgumentError
If specified blob service is not found.
30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/cf-runtime/aws_s3.rb', line 30 def self.(service_name,={}) service_props = CFRuntime::CloudApp.service_props(service_name) if service_props.nil? raise ArgumentError.new("Service with name #{service_name} not found") end = [:server] = service_props[:host] [:port] = service_props[:port] [:access_key_id ] = service_props[:username] [:secret_access_key] = service_props[:password] end |