Class: IBM::CloudSDK
- Inherits:
-
Object
- Object
- IBM::CloudSDK
- Defined in:
- lib/ibm/cloud_sdk.rb
Overview
Holds the SDK pieces.
Instance Attribute Summary collapse
-
#connection ⇒ Object
readonly
Returns the value of attribute connection.
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
-
#token ⇒ Object
readonly
Returns the value of attribute token.
Instance Method Summary collapse
-
#add_proxy(uri) ⇒ Object
Add a proxy to the configuration.
-
#initialize(api_key, logger: nil) ⇒ CloudSDK
constructor
A new instance of CloudSDK.
- #tags ⇒ Object
-
#vpc(region = 'us-east') ⇒ Object
Get an instance of the VPC API.
Constructor Details
#initialize(api_key, logger: nil) ⇒ CloudSDK
12 13 14 15 16 |
# File 'lib/ibm/cloud_sdk.rb', line 12 def initialize(api_key, logger: nil) @logger = logger || Logger.new($stdout, level: :warn) @connection = IBM::Cloud::SDKHTTP::HTTPConnection.new(@logger) @token = IBM::Cloud::SDKHTTP::IAMToken.new(api_key, @connection, logger: @logger) end |
Instance Attribute Details
#connection ⇒ Object (readonly)
Returns the value of attribute connection.
18 19 20 |
# File 'lib/ibm/cloud_sdk.rb', line 18 def connection @connection end |
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
18 19 20 |
# File 'lib/ibm/cloud_sdk.rb', line 18 def logger @logger end |
#token ⇒ Object (readonly)
Returns the value of attribute token.
18 19 20 |
# File 'lib/ibm/cloud_sdk.rb', line 18 def token @token end |
Instance Method Details
#add_proxy(uri) ⇒ Object
Add a proxy to the configuration.
22 23 24 25 26 27 |
# File 'lib/ibm/cloud_sdk.rb', line 22 def add_proxy(uri) raise "URI #{uri} is not set properly. Requires a full url, and optional user & password" if uri.relative? path = "#{uri.scheme}://#{uri.hostname}" @connection.class.http_proxy(path, uri.port, uri.user, uri.password) end |
#tags ⇒ Object
29 30 31 |
# File 'lib/ibm/cloud_sdk.rb', line 29 def ||= IBM::Cloud::SDK::Tags.new(@connection, @token, logger: @logger) end |
#vpc(region = 'us-east') ⇒ Object
Get an instance of the VPC API.
35 36 37 |
# File 'lib/ibm/cloud_sdk.rb', line 35 def vpc(region = 'us-east') @vpc ||= IBM::Cloud::SDK::Vpc.new(region, @connection, @token, logger: @logger) end |