Class: TopologicalInventory::Providers::Common::Operations::Source
- Inherits:
-
Object
- Object
- TopologicalInventory::Providers::Common::Operations::Source
- Includes:
- Logging, Mixins::SourcesApi, Mixins::Statuses, Mixins::XRhHeaders
- Defined in:
- lib/topological_inventory/providers/common/operations/source.rb
Constant Summary collapse
- EVENT_AVAILABILITY_STATUS =
"availability_status".freeze
- SERVICE_NAME =
"platform.sources.status".freeze
- ERROR_MESSAGES =
{ :authentication_not_found => "Authentication not found in Sources API", :endpoint_or_application_not_found => "Endpoint or Application not found in Sources API", }.freeze
- LAST_CHECKED_AT_THRESHOLD =
5.minutes.freeze
- AUTH_NOT_NECESSARY =
"n/a".freeze
Instance Attribute Summary collapse
-
#account_number ⇒ Object
Returns the value of attribute account_number.
-
#identity ⇒ Object
Returns the value of attribute identity.
-
#operation ⇒ Object
Returns the value of attribute operation.
-
#params ⇒ Object
Returns the value of attribute params.
-
#request_context ⇒ Object
Returns the value of attribute request_context.
-
#source_id ⇒ Object
Returns the value of attribute source_id.
Instance Method Summary collapse
- #availability_check ⇒ Object
-
#initialize(params = {}, request_context = nil, metrics = nil) ⇒ Source
constructor
A new instance of Source.
Methods included from Mixins::Statuses
Methods included from Mixins::XRhHeaders
#account_number_by_identity, #identity_by_account_number
Methods included from Mixins::SourcesApi
#application, #authentication, #endpoint, #full_hostname, #on_premise?, #sources_api, #verify_ssl_mode
Methods included from Logging
Constructor Details
#initialize(params = {}, request_context = nil, metrics = nil) ⇒ Source
Returns a new instance of Source.
32 33 34 35 36 37 38 39 40 41 |
# File 'lib/topological_inventory/providers/common/operations/source.rb', line 32 def initialize(params = {}, request_context = nil, metrics = nil) self.metrics = metrics self.operation = 'Source' self.params = params self.request_context = request_context self.source_id = params['source_id'] self.account_number = params['external_tenant'] self.updates_via_kafka = ENV['UPDATE_SOURCES_VIA_API'].blank? self.identity = identity_by_account_number(account_number) end |
Instance Attribute Details
#account_number ⇒ Object
Returns the value of attribute account_number.
30 31 32 |
# File 'lib/topological_inventory/providers/common/operations/source.rb', line 30 def account_number @account_number end |
#identity ⇒ Object
Returns the value of attribute identity.
30 31 32 |
# File 'lib/topological_inventory/providers/common/operations/source.rb', line 30 def identity @identity end |
#operation ⇒ Object
Returns the value of attribute operation.
30 31 32 |
# File 'lib/topological_inventory/providers/common/operations/source.rb', line 30 def operation @operation end |
#params ⇒ Object
Returns the value of attribute params.
30 31 32 |
# File 'lib/topological_inventory/providers/common/operations/source.rb', line 30 def params @params end |
#request_context ⇒ Object
Returns the value of attribute request_context.
30 31 32 |
# File 'lib/topological_inventory/providers/common/operations/source.rb', line 30 def request_context @request_context end |
#source_id ⇒ Object
Returns the value of attribute source_id.
30 31 32 |
# File 'lib/topological_inventory/providers/common/operations/source.rb', line 30 def source_id @source_id end |
Instance Method Details
#availability_check ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/topological_inventory/providers/common/operations/source.rb', line 43 def availability_check self.operation += '#availability_check' return operation_status[:error] if params_missing? return operation_status[:skipped] if checked_recently? status, = connection_status update_source_and_subresources(status, ) logger.availability_check("Completed: Source #{source_id} is #{status}") operation_status[:success] end |