Class: IBM::CloudSDK

Inherits:
Object
  • Object
show all
Defined in:
lib/ibm/cloud/sdk/vpc/cloud_sdk.rb

Overview

Holds the SDK pieces.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_key, logger: nil, options: {}) ⇒ CloudSDK

Returns a new instance of CloudSDK.



10
11
12
13
14
15
16
# File 'lib/ibm/cloud/sdk/vpc/cloud_sdk.rb', line 10

def initialize(api_key, logger: nil, options: {})
  @logger = logger
  @logger ||= Logger.new($stdout, level: :warn)

  @client = HTTP.use(http_options(options))
  @connection = IBM::Cloud::SDK::VPC::Connection.new(api_key, logger: @logger, client: @client)
end

Instance Attribute Details

#connectionObject (readonly)

Returns the value of attribute connection.



27
28
29
# File 'lib/ibm/cloud/sdk/vpc/cloud_sdk.rb', line 27

def connection
  @connection
end

#loggerObject (readonly)

Returns the value of attribute logger.



27
28
29
# File 'lib/ibm/cloud/sdk/vpc/cloud_sdk.rb', line 27

def logger
  @logger
end

Instance Method Details

#http_options(options = {}) ⇒ Object



18
19
20
21
22
23
24
25
# File 'lib/ibm/cloud/sdk/vpc/cloud_sdk.rb', line 18

def http_options(options = {})
  options.merge(
    {
      logging: { logger: @logger },
      auto_deflate: {}
    }
  )
end

#vpc(region = 'us-east') ⇒ Object



29
30
31
# File 'lib/ibm/cloud/sdk/vpc/cloud_sdk.rb', line 29

def vpc(region = 'us-east')
  IBM::Cloud::SDK::Vpc.new(region, @connection, logger: @logger)
end