Interface AtlanEventHandler


public interface AtlanEventHandler
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
     
  • Method Summary

    Modifier and Type
    Method
    Description
    calculateChanges(Asset currentView, org.slf4j.Logger log)
    Calculate any changes to apply to assets, and return a collection of the minimally-updated form of the assets with those changes applied (in-memory).
    static AtlanEvent
    getAtlanEvent(AtlanClient client, byte[] data)
    Translate the JSON payload into an Atlan event object.
    static AtlanEvent
    Translate the JSON payload into an Atlan event object.
    static Asset
    Retrieve the full asset from Atlan, to ensure we have the latest information about it.
    default Asset
    getCurrentState(AtlanClient client, Asset fromEvent, org.slf4j.Logger log)
    Retrieve the current state of the asset, with minimal required info to handle any logic the event handler requires to make its decisions.
    static Asset
    getCurrentViewOfAsset(AtlanClient client, Asset fromEvent, Collection<String> limitedToAttributes, boolean includeMeanings, boolean includeAtlanTags)
    Retrieve a limited set of information about the asset in Atlan, as up-to-date as is available in the search index, to ensure we have reasonably up-to-date information about it.
    static Asset
    getCurrentViewOfAsset(AtlanClient client, AtlanEvent event, Collection<String> limitedToAttributes, boolean includeMeanings, boolean includeAtlanTags)
    Retrieve a limited set of information about the asset in Atlan, as up-to-date as is available in the search index, to ensure we have reasonably up-to-date information about it.
    static boolean
    Check if the asset has any assigned terms.
    static boolean
    Check if the asset has any Atlan tags.
    default boolean
    hasChanges(Asset current, Asset modified, org.slf4j.Logger log)
    Check the key information this event processing is meant to handle between the original asset and the in-memory-modified asset.
    static boolean
    Check if the asset has either a user-provided or system-provided description.
    static boolean
    Check if the asset has any lineage.
    static boolean
    hasOwner(Asset asset)
    Check if the asset has any individual or group owners.
    static boolean
    Check if the asset has a README assigned (with content).
    static boolean
     
    default void
    saveChanges(AtlanClient client, Collection<Asset> changedAssets, org.slf4j.Logger log)
    Actually send the changed assets to Atlan so that they are persisted.
    default boolean
    validatePrerequisites(AtlanEvent event, org.slf4j.Logger log)
    Validate the prerequisites expected by the event handler.
    static boolean
    validSignature(String expectedSignature, Map<String,String> headers)
    Validate the signing secret provided with a request matches the expected signing secret.
  • Field Details

  • Method Details

    • validatePrerequisites

      default boolean validatePrerequisites(AtlanEvent event, org.slf4j.Logger log) throws AtlanException
      Validate the prerequisites expected by the event handler. These should generally run before trying to do any other actions. This default implementation will only confirm that an event has been received and there are details of an asset embedded within the event.
      Parameters:
      event - the event to be processed
      log - a logger to log anything you want
      Returns:
      true if the prerequisites are met, otherwise false
      Throws:
      AtlanException - optionally throw any errors on unexpected problems
    • getCurrentState

      default Asset getCurrentState(AtlanClient client, Asset fromEvent, org.slf4j.Logger log) throws AtlanException
      Retrieve the current state of the asset, with minimal required info to handle any logic the event handler requires to make its decisions. This default implementation will only really check that the asset still exists in Atlan.
      Parameters:
      client - connectivity to Atlan
      fromEvent - the asset from the event (which could be stale at this point)
      log - a logger to log anything you want
      Returns:
      the current state of the asset, as retrieved from Atlan
      Throws:
      AtlanException - if there are any problems retrieving the current state of the asset from Atlan
    • calculateChanges

      Collection<Asset> calculateChanges(Asset currentView, org.slf4j.Logger log) throws AtlanException
      Calculate any changes to apply to assets, and return a collection of the minimally-updated form of the assets with those changes applied (in-memory). Typically, you will want to call Asset.trimToRequired() on the currentView of each asset before making any changes, to ensure a minimal set of changes are applied to the asset (minimizing the risk of accidentally clobbering any other changes someone may make to the asset between this in-memory set of changes and the subsequent application of those changes to Atlan itself). Also, you should call your hasChanges(Asset, Asset, Logger) method for each asset to determine whether it actually has any changes to include before returning it from this method. NOTE: The returned assets from this method should be ONLY those assets on which updates are actually being applied, or you will risk an infinite loop of events triggering changes, more events, more changes, etc.
      Parameters:
      currentView - the current view / state of the asset in Atlan, as the starting point for any changes
      log - a logger to log anything you want
      Returns:
      a collection of only those assets that have changes to send to Atlan (empty, if there are no changes to send)
      Throws:
      AtlanException - if there are any problems calculating or applying changes (in-memory) to the asset
    • hasChanges

      default boolean hasChanges(Asset current, Asset modified, org.slf4j.Logger log)
      Check the key information this event processing is meant to handle between the original asset and the in-memory-modified asset. Only return true if there is actually a change to be applied to this asset in Atlan - this ensures idempotency, and avoids an infinite loop of making changes repeatedly in Atlan, which triggers a new event, a new change, a new event, and so on. This default implementation only blindly checks for equality. It is likely you would want to check specific attributes' values, rather than the entire object, for equality when determining whether a relevant change has been made (or not) to the asset.
      Parameters:
      current - the current view / state of the asset in Atlan, that was the starting point for any change calculations
      modified - the in-memory-modified asset against which to check if any changes actually need to be sent to Atlan
      log - a logger to log anything you want
      Returns:
      true if the modified asset should be sent on to (updated in) Atlan, or false if there are no actual changes to apply
    • saveChanges

      default void saveChanges(AtlanClient client, Collection<Asset> changedAssets, org.slf4j.Logger log) throws AtlanException
      Actually send the changed assets to Atlan so that they are persisted.
      Parameters:
      client - connectivity to Atlan
      changedAssets - the in-memory-modified assets to send to Atlan
      log - a logger to log anything you want
      Throws:
      AtlanException - if there are any problems actually updating the asset in Atlan
    • isValidationRequest

      static boolean isValidationRequest(String data)
    • validSignature

      static boolean validSignature(String expectedSignature, Map<String,String> headers)
      Validate the signing secret provided with a request matches the expected signing secret.
      Parameters:
      expectedSignature - signature that must be found for a valid request
      headers - that were sent with the request
      Returns:
      true if and only if the headers contain a signing secret that matches the expected signature
    • getAtlanEvent

      static AtlanEvent getAtlanEvent(AtlanClient client, String data) throws IOException
      Translate the JSON payload into an Atlan event object.
      Parameters:
      client - connectivity to Atlan
      data - the JSON payload
      Returns:
      an Atlan event object representation of the payload
      Throws:
      IOException - on any problems deserializing the event details
    • getAtlanEvent

      static AtlanEvent getAtlanEvent(AtlanClient client, byte[] data) throws IOException
      Translate the JSON payload into an Atlan event object.
      Parameters:
      client - connectivity to Atlan
      data - the JSON payload
      Returns:
      an Atlan event object representation of the payload
      Throws:
      IOException - on any problems deserializing the event details
    • getCurrentFullAsset

      static Asset getCurrentFullAsset(AtlanClient client, AtlanEvent event) throws AtlanException
      Retrieve the full asset from Atlan, to ensure we have the latest information about it. Note: this will be slower than getCurrentViewOfAsset, but does not rely on the eventual consistency of the search index so will have the absolute latest information about an asset.
      Parameters:
      client - connectivity to Atlan
      event - containing details about an asset
      Returns:
      the current information about the asset in Atlan, in its entirety
      Throws:
      AtlanException - on any issues communicating with the API
    • getCurrentViewOfAsset

      static Asset getCurrentViewOfAsset(AtlanClient client, AtlanEvent event, Collection<String> limitedToAttributes, boolean includeMeanings, boolean includeAtlanTags) throws AtlanException
      Retrieve a limited set of information about the asset in Atlan, as up-to-date as is available in the search index, to ensure we have reasonably up-to-date information about it. Note: this will be faster than getCurrentFullAsset, but relies on the eventual consistency of the search index so may not have the absolute latest information about an asset.
      Parameters:
      client - connectivity to Atlan
      event - containing details about an asset
      limitedToAttributes - the limited set of attributes to retrieve about the asset
      includeMeanings - if true, include any assigned terms
      includeAtlanTags - if true, include any assigned Atlan tags
      Returns:
      the current information about the asset in Atlan, limited to what was requested
      Throws:
      AtlanException - on any issues communicating with the API
    • getCurrentViewOfAsset

      static Asset getCurrentViewOfAsset(AtlanClient client, Asset fromEvent, Collection<String> limitedToAttributes, boolean includeMeanings, boolean includeAtlanTags) throws AtlanException
      Retrieve a limited set of information about the asset in Atlan, as up-to-date as is available in the search index, to ensure we have reasonably up-to-date information about it. Note: this will be faster than getCurrentFullAsset, but relies on the eventual consistency of the search index so may not have the absolute latest information about an asset.
      Parameters:
      client - connectivity to Atlan
      fromEvent - details of the asset in the event
      limitedToAttributes - the limited set of attributes to retrieve about the asset
      includeMeanings - if true, include any assigned terms
      includeAtlanTags - if true, include any assigned Atlan tags
      Returns:
      the current information about the asset in Atlan, limited to what was requested
      Throws:
      AtlanException - on any issues communicating with the API
    • hasDescription

      static boolean hasDescription(Asset asset)
      Check if the asset has either a user-provided or system-provided description.
      Parameters:
      asset - to check for the presence of a description
      Returns:
      true if there is either a user-provided or system-provided description
    • hasOwner

      static boolean hasOwner(Asset asset)
      Check if the asset has any individual or group owners.
      Parameters:
      asset - to check for the presence of an owner
      Returns:
      true if there is at least one individual or group owner
    • hasAssignedTerms

      static boolean hasAssignedTerms(Asset asset)
      Check if the asset has any assigned terms.
      Parameters:
      asset - to check for the presence of an assigned term
      Returns:
      true if there is at least one assigned term
    • hasAtlanTags

      static boolean hasAtlanTags(Asset asset)
      Check if the asset has any Atlan tags.
      Parameters:
      asset - to check for the presence of an Atlan tag
      Returns:
      true if there is at least one assigned Atlan tag
    • hasLineage

      static boolean hasLineage(Asset asset)
      Check if the asset has any lineage.
      Parameters:
      asset - to check for the presence of lineage
      Returns:
      true if the asset is input to or output from at least one process
    • hasReadme

      static boolean hasReadme(Asset asset)
      Check if the asset has a README assigned (with content).
      Parameters:
      asset - to check for the presence of a README
      Returns:
      true if the asset has a README, and the README is not empty