Class: TopologicalInventory::Providers::Common::TopologyApiClient
- Inherits:
-
TopologicalInventoryApiClient::ApiClient
- Object
- TopologicalInventoryApiClient::ApiClient
- TopologicalInventory::Providers::Common::TopologyApiClient
- Defined in:
- lib/topological_inventory/providers/common/topology_api_client.rb
Instance Attribute Summary collapse
-
#api ⇒ Object
Returns the value of attribute api.
Instance Method Summary collapse
- #init_default_api ⇒ Object
-
#initialize(identity = nil) ⇒ TopologyApiClient
constructor
A new instance of TopologyApiClient.
- #svc_instance_url(service_instance) ⇒ Object
- #update_task(task_id, source_id: nil, state:, status:, target_type: nil, target_source_ref: nil, context: nil) ⇒ Object
Constructor Details
#initialize(identity = nil) ⇒ TopologyApiClient
Returns a new instance of TopologyApiClient.
9 10 11 12 13 14 |
# File 'lib/topological_inventory/providers/common/topology_api_client.rb', line 9 def initialize(identity = nil) super(::TopologicalInventoryApiClient::Configuration.default) self.identity = identity self.api = init_default_api end |
Instance Attribute Details
#api ⇒ Object
Returns the value of attribute api.
7 8 9 |
# File 'lib/topological_inventory/providers/common/topology_api_client.rb', line 7 def api @api end |
Instance Method Details
#init_default_api ⇒ Object
16 17 18 19 |
# File 'lib/topological_inventory/providers/common/topology_api_client.rb', line 16 def init_default_api default_headers.merge!(identity) if identity.present? ::TopologicalInventoryApiClient::DefaultApi.new(self) end |
#svc_instance_url(service_instance) ⇒ Object
32 33 34 35 |
# File 'lib/topological_inventory/providers/common/topology_api_client.rb', line 32 def svc_instance_url(service_instance) rest_api_path = '/service_instances/{id}'.sub('{' + 'id' + '}', service_instance&.id.to_s) build_request(:GET, rest_api_path).url end |
#update_task(task_id, source_id: nil, state:, status:, target_type: nil, target_source_ref: nil, context: nil) ⇒ Object
21 22 23 24 25 26 27 28 29 30 |
# File 'lib/topological_inventory/providers/common/topology_api_client.rb', line 21 def update_task(task_id, source_id: nil, state:, status:, target_type: nil, target_source_ref: nil, context: nil) params = {'state' => state, 'status' => status} params['context'] = context if context params['source_id'] = source_id if source_id params['target_type'] = target_type if target_type params['target_source_ref'] = target_source_ref if target_source_ref task = TopologicalInventoryApiClient::Task.new(params) api.update_task(task_id, task) end |