Module: TopologicalInventory::Providers::Common::Mixins::SourcesApi
- Included in:
- Operations::Source
- Defined in:
- lib/topological_inventory/providers/common/mixins/sources_api.rb
Constant Summary collapse
- AUTH_NOT_NECESSARY =
"n/a".freeze
Instance Method Summary collapse
- #application ⇒ Object
- #authentication ⇒ Object
- #endpoint ⇒ Object
- #full_hostname(endpoint) ⇒ Object
- #on_premise? ⇒ Boolean
- #sources_api ⇒ Object
- #verify_ssl_mode ⇒ Object
Instance Method Details
#application ⇒ Object
34 35 36 37 38 39 40 |
# File 'lib/topological_inventory/providers/common/mixins/sources_api.rb', line 34 def application @application ||= sources_api.fetch_application(source_id) rescue => e metrics&.record_error(:sources_api) logger.error_ext(operation, "Failed to fetch Application for Source #{source_id}: #{e.message}") nil end |
#authentication ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/topological_inventory/providers/common/mixins/sources_api.rb', line 22 def authentication @authentication ||= if endpoint.receptor_node.present? AUTH_NOT_NECESSARY else sources_api.fetch_authentication(source_id, endpoint) end rescue => e metrics&.record_error(:sources_api) logger.error_ext(operation, "Failed to fetch Authentication for Source #{source_id}: #{e.message}") nil end |
#endpoint ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/topological_inventory/providers/common/mixins/sources_api.rb', line 14 def endpoint @endpoint ||= sources_api.fetch_default_endpoint(source_id) rescue => e metrics&.record_error(:sources_api) logger.error_ext(operation, "Failed to fetch Endpoint for Source #{source_id}: #{e.message}") nil end |
#full_hostname(endpoint) ⇒ Object
50 51 52 53 54 55 56 |
# File 'lib/topological_inventory/providers/common/mixins/sources_api.rb', line 50 def full_hostname(endpoint) if on_premise? "receptor://#{endpoint.receptor_node}" else endpoint.host.tap { |host| host << ":#{endpoint.port}" if endpoint.port } end end |
#on_premise? ⇒ Boolean
42 43 44 |
# File 'lib/topological_inventory/providers/common/mixins/sources_api.rb', line 42 def on_premise? @on_premise ||= endpoint&.receptor_node.to_s.strip.present? end |
#sources_api ⇒ Object
10 11 12 |
# File 'lib/topological_inventory/providers/common/mixins/sources_api.rb', line 10 def sources_api @sources_api ||= TopologicalInventory::Providers::Common::SourcesApiClient.new(identity) end |
#verify_ssl_mode ⇒ Object
46 47 48 |
# File 'lib/topological_inventory/providers/common/mixins/sources_api.rb', line 46 def verify_ssl_mode endpoint&.verify_ssl ? OpenSSL::SSL::VERIFY_PEER : OpenSSL::SSL::VERIFY_NONE end |