Class: IBM::Cloud::SDKHTTP::BaseInstance
- Inherits:
-
Object
- Object
- IBM::Cloud::SDKHTTP::BaseInstance
- Extended by:
- Forwardable
- Includes:
- BaseHTTPMixin
- Defined in:
- lib/ibm/cloud/sdk_http/base_instance.rb
Overview
Container that encapsulates the VPC API.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#connection ⇒ Object
readonly
Returns the value of attribute connection.
-
#endpoint ⇒ Object
readonly
Returns the value of attribute endpoint.
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
-
#token ⇒ Object
readonly
Returns the value of attribute token.
Instance Method Summary collapse
-
#details ⇒ SDKResponse
Fetch the instance details for this resource.
-
#initialize(parent, data: {}, id_key: 'id', endpoint: nil) ⇒ BaseInstance
constructor
A new instance of BaseInstance.
-
#refresh ⇒ BaseInstance
Fetch the instance details from the server.
-
#remove ⇒ Object
Send a delete request to the server for this resource.
-
#update(payload) ⇒ Object
Send an update to the server for this resource.
Methods included from BaseHTTPMixin
#adhoc, #delete, #get, #metadata, #patch, #post, #put, #unchecked_response, #url
Constructor Details
#initialize(parent, data: {}, id_key: 'id', endpoint: nil) ⇒ BaseInstance
Returns a new instance of BaseInstance.
15 16 17 18 19 20 21 22 23 |
# File 'lib/ibm/cloud/sdk_http/base_instance.rb', line 15 def initialize(parent, data: {}, id_key: 'id', endpoint: nil) @data = data endpoint ||= data[id_key.to_sym] @connection = parent.connection @token = parent.token @endpoint = parent.url(endpoint) @logger = parent.logger end |
Instance Attribute Details
#connection ⇒ Object (readonly)
Returns the value of attribute connection.
25 26 27 |
# File 'lib/ibm/cloud/sdk_http/base_instance.rb', line 25 def connection @connection end |
#endpoint ⇒ Object (readonly)
Returns the value of attribute endpoint.
25 26 27 |
# File 'lib/ibm/cloud/sdk_http/base_instance.rb', line 25 def endpoint @endpoint end |
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
25 26 27 |
# File 'lib/ibm/cloud/sdk_http/base_instance.rb', line 25 def logger @logger end |
#token ⇒ Object (readonly)
Returns the value of attribute token.
25 26 27 |
# File 'lib/ibm/cloud/sdk_http/base_instance.rb', line 25 def token @token end |
Instance Method Details
#details ⇒ SDKResponse
Fetch the instance details for this resource.
29 30 31 |
# File 'lib/ibm/cloud/sdk_http/base_instance.rb', line 29 def details get.hash_response end |
#refresh ⇒ BaseInstance
Fetch the instance details from the server. Clear current data and save the results.
35 36 37 38 |
# File 'lib/ibm/cloud/sdk_http/base_instance.rb', line 35 def refresh @data.replace(details) self end |
#remove ⇒ Object
Send a delete request to the server for this resource.
46 47 48 |
# File 'lib/ibm/cloud/sdk_http/base_instance.rb', line 46 def remove delete end |
#update(payload) ⇒ Object
Send an update to the server for this resource.
41 42 43 |
# File 'lib/ibm/cloud/sdk_http/base_instance.rb', line 41 def update(payload) patch(payload: payload) end |