lib/topological_inventory/orchestrator/targeted_update/api_load_helpers.rb
def load_credentials_for_upsert
          targets = @targets.select { |target| %i[create update].include?(target[:action]) }

          # Load Endpoint
          api_load_has_one(:source, :endpoint, 'source_id', targets)
          targets = targets.select { |target| target[:endpoint].present? }

          targets.each do |target|
            target[:source].endpoint = target[:endpoint]
          end

          # Load Authentication
          api_load_has_one(:endpoint, :authentication, 'resource_id', targets)
          targets = targets.select { |target| target[:authentication].present? }

          credentials = {}
          targets.each do |target|
            target[:source].authentication = target[:authentication]

            # cache credentials responses
            credentials[target[:authentication]['id']] ||= @api.get_credentials(target[:authentication]['id'], target[:tenant])
            target[:source].credentials = credentials[target[:authentication]['id']]
          end
        end
# API requests: only "create", "update" actions
# - loads missing endpoints (if event was from Application/Source)
# - loads missing authentications (if event was from Application/Source/Endpoint)
# - loads credentials (internal API/authentication)
API requests: only "create", "update" actions
loads missing endpoints (if event was from Application/Source)
loads missing authentications (if event was from Application/Source/Endpoint)
loads credentials (internal API/authentication)
API requests : only " create " " update " actions loads missing endpoints ( if event was from Application / Source ) loads missing authentications ( if event was from Application / Source / Endpoint ) loads credentials ( internal API / authentication )
def load_credentials_for_upsert
          targets = @targets.select { |target| %i[create update].include?(target[:action]) }
          api_load_has_one(:source, :endpoint, 'source_id', targets)
          targets = targets.select { |target| target[:endpoint].present? }
          targets.each do |target|
            target[:source].endpoint = target[:endpoint]
          end
          api_load_has_one(:endpoint, :authentication, 'resource_id', targets)
          targets = targets.select { |target| target[:authentication].present? }
          credentials = {}
          targets.each do |target|
            target[:source].authentication = target[:authentication]
            credentials[target[:authentication]['id']] ||= @api.get_credentials(target[:authentication]['id'], target[:tenant])
            target[:source].credentials = credentials[target[:authentication]['id']]
          end
        end
def load_credentials_for_upsert targets = @targets . select { | target | %i[ create update ] . include? ( target [ :action ] ) } api_load_has_one ( :source , :endpoint , 'source_id' , targets ) targets = targets . select { | target | target [ :endpoint ] . present? } targets . each do | target | target [ :source ] . endpoint = target [ :endpoint ] end api_load_has_one ( :endpoint , :authentication , 'resource_id' , targets ) targets = targets . select { | target | target [ :authentication ] . present? } credentials = { } targets . each do | target | target [ :source ] . authentication = target [ :authentication ] credentials [ target [ :authentication ] [ 'id' ] ] ||= @api . get_credentials ( target [ :authentication ] [ 'id' ] , target [ :tenant ] ) target [ :source ] . credentials = credentials [ target [ :authentication ] [ 'id' ] ] end end
API requests: only "create", "update" actions
 loads missing endpoints (if event was from Application/Source)
 loads missing authentications (if event was from Application/Source/Endpoint)
 loads credentials (internal API/authentication)
API requests : only " create " " update " actions loads missing endpoints ( if event was from Application / Source ) loads missing authentications ( if event was from Application / Source / Endpoint ) loads credentials ( internal API / authentication )
# Load Endpoint # Load Authentication # cache credentials responses