Class: Fog::Brightbox::Config
- Inherits:
-
Object
- Object
- Fog::Brightbox::Config
- Defined in:
- lib/fog/brightbox/config.rb
Overview
The Config class is designed to encapsulate a group of settings for reuse between Brightbox services. The same config can be used for any service.
The config also holds the latest set of access tokens which when shared means when one service is told a token has expired then another will not retry it.
Instance Method Summary collapse
-
#account ⇒ String
The configured account identifier to scope API requests by.
-
#auth_url ⇒ URI::HTTPS
A URI object for the authentication endpoint.
- #cached_access_token ⇒ Object
- #cached_refresh_token ⇒ Object
-
#client_id ⇒ String
The configured identifier of the API client or user application.
-
#client_secret ⇒ String
The configured secret to use to identify the client.
-
#compute_url ⇒ URI::HTTPS
(also: #api_url)
A URI object for the main API/compute service endpoint.
-
#config_service? ⇒ true
Can this be used to configure services? Yes, yes it can.
- #connection_options ⇒ Object
- #connection_persistent? ⇒ Boolean
- #default_image_id ⇒ Object
-
#initialize(options = {}) ⇒ Config
constructor
Creates a new set of configuration settings based on the options provided.
- #managed_tokens? ⇒ Boolean
-
#password ⇒ String
The configured password to use to identify the user.
- #to_hash ⇒ Object
-
#username ⇒ String
The configured email or user identified to use when accessing the API.
Constructor Details
#initialize(options = {}) ⇒ Config
Creates a new set of configuration settings based on the options provided.
48 49 50 |
# File 'lib/fog/brightbox/config.rb', line 48 def initialize( = {}) @options = end |
Instance Method Details
#account ⇒ String
Returns The configured account identifier to scope API requests by.
95 96 97 |
# File 'lib/fog/brightbox/config.rb', line 95 def account @options[:brightbox_account] end |
#auth_url ⇒ URI::HTTPS
Returns A URI object for the authentication endpoint.
64 65 66 |
# File 'lib/fog/brightbox/config.rb', line 64 def auth_url URI.parse(@options.fetch(:brightbox_auth_url, "https://api.gb1.brightbox.com")) end |
#cached_access_token ⇒ Object
108 109 110 |
# File 'lib/fog/brightbox/config.rb', line 108 def cached_access_token @options[:brightbox_access_token] end |
#cached_refresh_token ⇒ Object
112 113 114 |
# File 'lib/fog/brightbox/config.rb', line 112 def cached_refresh_token @options[:brightbox_refresh_token] end |
#client_id ⇒ String
Returns The configured identifier of the API client or user application.
75 76 77 |
# File 'lib/fog/brightbox/config.rb', line 75 def client_id @options[:brightbox_client_id] end |
#client_secret ⇒ String
Returns The configured secret to use to identify the client.
80 81 82 |
# File 'lib/fog/brightbox/config.rb', line 80 def client_secret @options[:brightbox_secret] end |
#compute_url ⇒ URI::HTTPS Also known as: api_url
Returns A URI object for the main API/compute service endpoint.
69 70 71 |
# File 'lib/fog/brightbox/config.rb', line 69 def compute_url URI.parse(@options.fetch(:brightbox_api_url, "https://api.gb1.brightbox.com")) end |
#config_service? ⇒ true
Can this be used to configure services? Yes, yes it can.
55 56 57 |
# File 'lib/fog/brightbox/config.rb', line 55 def config_service? true end |
#connection_options ⇒ Object
99 100 101 102 |
# File 'lib/fog/brightbox/config.rb', line 99 def # These are pretty much passed through to the requests as is. @options.fetch(:connection_options, {}) end |
#connection_persistent? ⇒ Boolean
104 105 106 |
# File 'lib/fog/brightbox/config.rb', line 104 def connection_persistent? @options.fetch(:persistent, false) end |
#default_image_id ⇒ Object
120 121 122 |
# File 'lib/fog/brightbox/config.rb', line 120 def default_image_id @options.fetch(:brightbox_default_image, nil) end |
#managed_tokens? ⇒ Boolean
116 117 118 |
# File 'lib/fog/brightbox/config.rb', line 116 def managed_tokens? @options.fetch(:brightbox_token_management, true) end |
#password ⇒ String
Returns The configured password to use to identify the user.
90 91 92 |
# File 'lib/fog/brightbox/config.rb', line 90 def password @options[:brightbox_password] end |
#to_hash ⇒ Object
59 60 61 |
# File 'lib/fog/brightbox/config.rb', line 59 def to_hash @options end |
#username ⇒ String
Returns The configured email or user identified to use when accessing the API.
85 86 87 |
# File 'lib/fog/brightbox/config.rb', line 85 def username @options[:brightbox_username] end |