Class: IBM::Cloud::SDK::VPC::Connection
- Inherits:
-
Object
- Object
- IBM::Cloud::SDK::VPC::Connection
- Defined in:
- lib/ibm/cloud/sdk/vpc/helpers/connection.rb
Overview
The Connection object to be used for all HTTP requests.
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
Instance Method Summary collapse
-
#adhoc(verb, uri, opts = {}) ⇒ IBM::Cloud::SDK::VPC::Response
Send a HTTP request.
-
#authorization_header ⇒ Object
Get bearer token string for clients not using the adhoc method.
-
#initialize(api_key, logger: nil, client: nil) ⇒ Connection
constructor
A new instance of Connection.
-
#unverified_request(verb, uri, opts = {}) ⇒ Object
Send a HTTP request.
Constructor Details
#initialize(api_key, logger: nil, client: nil) ⇒ Connection
Returns a new instance of Connection.
16 17 18 19 20 21 |
# File 'lib/ibm/cloud/sdk/vpc/helpers/connection.rb', line 16 def initialize(api_key, logger: nil, client: nil) @api_key = api_key @logger = logger @client = client @token = Token.new(api_key, logger: logger, client: client) end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
23 24 25 |
# File 'lib/ibm/cloud/sdk/vpc/helpers/connection.rb', line 23 def client @client end |
Instance Method Details
#adhoc(verb, uri, opts = {}) ⇒ IBM::Cloud::SDK::VPC::Response
Send a HTTP request. Checks the validity of the response.
34 35 36 |
# File 'lib/ibm/cloud/sdk/vpc/helpers/connection.rb', line 34 def adhoc(verb, uri, opts = {}) unverified_request(verb, uri, opts).raise_for_status? end |
#authorization_header ⇒ Object
Get bearer token string for clients not using the adhoc method.
46 47 48 |
# File 'lib/ibm/cloud/sdk/vpc/helpers/connection.rb', line 46 def @token. end |
#unverified_request(verb, uri, opts = {}) ⇒ Object
Send a HTTP request. Don’t do any validation checks.
40 41 42 43 |
# File 'lib/ibm/cloud/sdk/vpc/helpers/connection.rb', line 40 def unverified_request(verb, uri, opts = {}) response = @client.auth(@token.).request(verb.to_s.downcase.to_sym, uri, opts) Response.new(response) end |