Class: Sndacs::Service
- Inherits:
-
Object
- Object
- Sndacs::Service
- Includes:
- Proxies, Parser
- Defined in:
- lib/sndacs/service.rb
Instance Attribute Summary collapse
-
#access_key_id ⇒ Object
readonly
Returns the value of attribute access_key_id.
-
#proxy ⇒ Object
readonly
Returns the value of attribute proxy.
-
#secret_access_key ⇒ Object
readonly
Returns the value of attribute secret_access_key.
-
#use_ssl ⇒ Object
readonly
Returns the value of attribute use_ssl.
Instance Method Summary collapse
-
#==(other) ⇒ Object
Compares service to other, by
access_key_id
andsecret_access_key
. -
#bucket(name, region = nil) ⇒ Object
Returns the bucket with the given name and region.
-
#buckets ⇒ Object
Returns all buckets in the service and caches the result (see
reload
). -
#initialize(options = {}) ⇒ Service
constructor
Creates new service.
-
#inspect ⇒ Object
:nodoc:.
-
#port ⇒ Object
Returns 443 or 80, depends on
:use_ssl
value from initializer. -
#protocol ⇒ Object
Returns “http://” or “https://”, depends on
:use_ssl
value from initializer.
Methods included from Parser
#parse_all_buckets_result, #parse_all_objects_result, #parse_copy_object_result, #parse_error, #parse_is_truncated, #parse_location_constraint, #rexml_document
Constructor Details
#initialize(options = {}) ⇒ Service
Creates new service.
Options
-
:access_key_id
- Access key id (REQUIRED) -
:secret_access_key
- Secret access key (REQUIRED) -
:use_ssl
- Use https or http protocol (false by default) -
:debug
- Display debug information on the STDOUT (false by default) -
:timeout
- Timeout to use by the Net::HTTP object (60 by default)
34 35 36 37 38 39 40 41 42 43 |
# File 'lib/sndacs/service.rb', line 34 def initialize( = {}) @access_key_id = .fetch(:access_key_id, Config.access_key_id) @secret_access_key = .fetch(:secret_access_key, Config.secret_access_key) @proxy = .fetch(:proxy, Config.proxy) @timeout = .fetch(:timeout, Config.timeout) @use_ssl = .fetch(:use_ssl, Config.use_ssl) @debug = .fetch(:debug, Config.debug) raise ArgumentError, "Wrong proxy settings. Must specify at least :host option." if @proxy && !@proxy[:host] end |
Instance Attribute Details
#access_key_id ⇒ Object (readonly)
Returns the value of attribute access_key_id.
15 16 17 |
# File 'lib/sndacs/service.rb', line 15 def access_key_id @access_key_id end |
#proxy ⇒ Object (readonly)
Returns the value of attribute proxy.
15 16 17 |
# File 'lib/sndacs/service.rb', line 15 def proxy @proxy end |
#secret_access_key ⇒ Object (readonly)
Returns the value of attribute secret_access_key.
15 16 17 |
# File 'lib/sndacs/service.rb', line 15 def secret_access_key @secret_access_key end |
#use_ssl ⇒ Object (readonly)
Returns the value of attribute use_ssl.
15 16 17 |
# File 'lib/sndacs/service.rb', line 15 def use_ssl @use_ssl end |
Instance Method Details
#==(other) ⇒ Object
Compares service to other, by access_key_id
and secret_access_key
19 20 21 |
# File 'lib/sndacs/service.rb', line 19 def ==(other) self.access_key_id == other.access_key_id and self.secret_access_key == other.secret_access_key end |
#bucket(name, region = nil) ⇒ Object
Returns the bucket with the given name and region. Does not check whether the bucket exists. But also does not issue any HTTP requests, so it’s much faster than buckets.find
54 55 56 |
# File 'lib/sndacs/service.rb', line 54 def bucket(name, region = nil) Bucket.send(:new, self, name, region || REGION_DEFAULT) end |
#buckets ⇒ Object
Returns all buckets in the service and caches the result (see reload
)
47 48 49 |
# File 'lib/sndacs/service.rb', line 47 def buckets Proxy.new(lambda { buckets_all }, :owner => self, :extend => BucketsExtension) end |
#inspect ⇒ Object
:nodoc:
70 71 72 |
# File 'lib/sndacs/service.rb', line 70 def inspect #:nodoc: "#<#{self.class}:#@access_key_id>" end |
#port ⇒ Object
Returns 443 or 80, depends on :use_ssl
value from initializer
66 67 68 |
# File 'lib/sndacs/service.rb', line 66 def port use_ssl ? 443 : 80 end |
#protocol ⇒ Object
Returns “http://” or “https://”, depends on :use_ssl
value from initializer
60 61 62 |
# File 'lib/sndacs/service.rb', line 60 def protocol use_ssl ? "https://" : "http://" end |