Class: Brightbox::Config::ApiClient
- Inherits:
-
Object
- Object
- Brightbox::Config::ApiClient
- Defined in:
- lib/brightbox-cli/config/api_client.rb
Constant Summary collapse
- NON_BLANK_KEYS =
%w[api_url client_id secret].freeze
Instance Attribute Summary collapse
-
#client_name ⇒ Object
Returns the value of attribute client_name.
-
#selected_config ⇒ Object
Returns the value of attribute selected_config.
Instance Method Summary collapse
-
#initialize(incoming_config, client_name) ⇒ ApiClient
constructor
A new instance of ApiClient.
- #to_fog ⇒ Object
- #valid? ⇒ Boolean
Constructor Details
#initialize(incoming_config, client_name) ⇒ ApiClient
Returns a new instance of ApiClient.
8 9 10 11 |
# File 'lib/brightbox-cli/config/api_client.rb', line 8 def initialize(incoming_config, client_name) @selected_config = incoming_config @client_name = client_name end |
Instance Attribute Details
#client_name ⇒ Object
Returns the value of attribute client_name.
6 7 8 |
# File 'lib/brightbox-cli/config/api_client.rb', line 6 def client_name @client_name end |
#selected_config ⇒ Object
Returns the value of attribute selected_config.
6 7 8 |
# File 'lib/brightbox-cli/config/api_client.rb', line 6 def selected_config @selected_config end |
Instance Method Details
#to_fog ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/brightbox-cli/config/api_client.rb', line 13 def to_fog check_required_params { :provider => "Brightbox", :brightbox_api_url => selected_config["api_url"], :brightbox_auth_url => selected_config["auth_url"] || selected_config["api_url"], :brightbox_client_id => selected_config["client_id"], :brightbox_secret => selected_config["secret"], :persistent => persistent? } end |
#valid? ⇒ Boolean
25 26 27 28 29 |
# File 'lib/brightbox-cli/config/api_client.rb', line 25 def valid? NON_BLANK_KEYS.all? do |key| selected_config.key?(key) && !selected_config[key].to_s.empty? end end |