Skip to content

Get all assets that are certified, but incomplete

1.4.0 1.1.0

This example finds all assets that are marked as verified, but are missing a description — suggesting they are in fact incomplete.

Get all verified assets that have no description
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
AtlanClient client = Atlan.getDefaultClient(); // (1)
client.assets.select() // (2)
    .where(Asset.CERTIFICATE_STATUS.eq(CertificateStatus.VERIFIED)) // (3)
    .whereNot(Asset.DESCRIPTION.hasAnyValue()) // (4)
    .whereNot(Asset.USER_DESCRIPTION.hasAnyValue())
    .includeOnResults(Asset.OWNER_USERS) // (5)
    .includeOnResults(Asset.OWNER_GROUPS) // (6)
    .stream() // (7)
    .forEach(a -> { // (8)
        log.info("Asset: {}", a);
    });
  1. Start with a client to run the search through. For the default client, you can always use Atlan.getDefaultClient().
  2. To search across all assets, you can use the assets.select() convenience method on a client.
  3. The where() helper method allows us to limit to only assets that meet a a particular condition. In this example, we are looking for values for the certificate status, so use Asset.CERTIFICATE_STATUS. (No need to try to remember or ever even know what the precise string value is for the name of this field — we've provided enums for them in the SDK.)

    Since we only want assets that are verified, we will query where that certificate is set to the CertificateStatus.VERIFIED value. (No need to try to remember or ever even know what the precise string values for the certificates are — we've provided enums for them in the SDK.)

  4. You can use the whereNot() method to do the opposite — define all the conditions the search results must not match. Here we are limiting to only assets that have a description populated.

    The hasAnyValue() predicate method allows us to limit to only assets that have a user-defined description populated. In Atlan you have both description (crawled from source) and userDescription (user-defined or overridden). For this example use case, you probably want to check that both of these are empty.

  5. As part of the search, you may want certain details included in every result. In this use case, you may want to know the asset owner — someone to confirm this should really be certified when there is no description.

  6. In Atlan you have both users and groups that can own assets. For this example use case, you probably want to retrieve both of these for every result.
  7. The search will only run when you call the stream() method, which will then lazily-load each page of results into a stream.
  8. This is the pattern for iterating through all results (across pages) covered in the Searching for assets portion of the SDK documentation.
Get all verified assets that have no description
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
from pyatlan.client.atlan import AtlanClient
from pyatlan.model.assets import Asset
from pyatlan.model.enums import CertificateStatus
from pyatlan.model.fluent_search import FluentSearch

client = AtlanClient()  # (1)
request = (
    FluentSearch()  # (2)
    .where(Asset.CERTIFICATE_STATUS.eq(CertificateStatus.VERIFIED.value))  # (3)
    .where_not(Asset.DESCRIPTION.has_any_value())  # (4)
    .where_not(Asset.USER_DESCRIPTION.has_any_value())
    .include_on_results(Asset.OWNER_USERS)  # (5)
    .include_on_results(Asset.OWNER_GROUPS)  # (6)
).to_request()  # (7)
for result in client.asset.search(request):  # (8)
    print(result)
  1. Start with a client to run the search through. For the default client, you can always use AtlanClient().
  2. To search across all assets, you can use a FluentSearch object.
  3. The .where() method allows you to limit to only assets that have a particular value in a particular field. In this example, we are looking for values for the certificate status, so use Asset.CERTIFICATE_STATUS.

    Since we only want assets that are verified, we will query where that certificate is set to the CertificateStatus.VERIFIED value. (No need to try to remember or ever even know what the precise string values for the certificates are — we've provided enums for them in the SDK.)

  4. You can use the .where_not() method to do the opposite — define all the conditions the search results must not match. Here we are limiting to only assets that have a description populated.

    The has_any_value() predicate method allows us to limit to only assets that have a user-defined description populated. In Atlan you have both description (crawled from source) and userDescription (user-defined or overridden). For this example use case, you probably want to check that both of these are empty.

  5. As part of the search, you may want certain details included in every result. In this use case, you may want to know the asset owner — someone to confirm this should really be certified when there is no description.

  6. In Atlan you have both users and groups that can own assets. For this example use case, you probably want to retrieve both of these for every result.
  7. You can then translate the fluent search into an index search request.
  8. This is the pattern for iterating through all results (across pages) covered in the Searching for assets portion of the SDK documentation.
Get all verified assets that have no description
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
val client = Atlan.getDefaultClient() // (1)
client.assets.select() // (2)
    .where(Asset.CERTIFICATE_STATUS.eq(CertificateStatus.VERIFIED)) // (3)
    .whereNot(Asset.DESCRIPTION.hasAnyValue()) // (4)
    .whereNot(Asset.USER_DESCRIPTION.hasAnyValue())
    .includeOnResults(Asset.OWNER_USERS) // (5)
    .includeOnResults(Asset.OWNER_GROUPS) // (6)
    .stream() // (7)
    .forEach { // (8)
        log.info { "Asset: $it" }
    }
  1. Start with a client to run the search through. For the default client, you can always use Atlan.getDefaultClient().
  2. To search across all assets, you can use the assets.select() convenience method on a client.
  3. The where() helper method allows us to limit to only assets that meet a a particular condition. In this example, we are looking for values for the certificate status, so use Asset.CERTIFICATE_STATUS. (No need to try to remember or ever even know what the precise string value is for the name of this field — we've provided enums for them in the SDK.)

    Since we only want assets that are verified, we will query where that certificate is set to the CertificateStatus.VERIFIED value. (No need to try to remember or ever even know what the precise string values for the certificates are — we've provided enums for them in the SDK.)

  4. You can use the whereNot() method to do the opposite — define all the conditions the search results must not match. Here we are limiting to only assets that have a description populated.

    The hasAnyValue() predicate method allows us to limit to only assets that have a user-defined description populated. In Atlan you have both description (crawled from source) and userDescription (user-defined or overridden). For this example use case, you probably want to check that both of these are empty.

  5. As part of the search, you may want certain details included in every result. In this use case, you may want to know the asset owner — someone to confirm this should really be certified when there is no description.

  6. In Atlan you have both users and groups that can own assets. For this example use case, you probably want to retrieve both of these for every result.
  7. The search will only run when you call the stream() method, which will then lazily-load each page of results into a stream.
  8. This is the pattern for iterating through all results (across pages) covered in the Searching for assets portion of the SDK documentation.
POST /api/meta/search/indexsearch
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
{
  "dsl": { // (1)
    "query": {
      "bool": { // (2)
        "filter": [ // (3)
          {
            "term": {
              "certificateStatus": { // (4)
                "value": "VERIFIED"
              }
            }
          }
        ],
        "must_not": [ // (5)
          {
            "exists": {
              "field": "description"
            }
          },
          {
            "exists": {
              "field": "userDescription"
            }
          }
        ]
      }
    },
    "track_total_hits": true
  },
  "attributes": [
    "ownerUsers", // (6)
    "ownerGroups" // (7)
  ],
  "suppressLogs": true,
  "showSearchScore": false,
  "excludeMeanings": false,
  "excludeClassifications": false
}
  1. Run a search to find the columns.

  2. To start building up a query with multiple conditions, you can use a bool query in Elasticsearch.

  3. You can use the filter criteria to define all the conditions the search results must match in a binary way (either matches or doesn't). This avoids the need to calculate a score for each result.

  4. In this example, you are looking for verified assets. So you can begin by filtering only those assets with a certificateStatus of VERIFIED.

  5. Since you want to find assets that specifically do not have other characteristics, use the must_not criteria to specify these. Specifically, match assets that do not have either a description or userDescription populated.

  6. As part of the search, you may want certain details included in every result. In this use case, you may want to know the asset owner — someone to confirm this should really be certified when there is no description.

    Where did ownerUsers come from?

    The Models section of the site details all the attributes that exist in each different type of asset, and therefore which ones you can retrieve as additional details in each search result, like ownerUsers.

  7. In Atlan you have both users and groups that can own assets. For this example use case, you probably want to retrieve both of these for every result.

    Where did ownerGroups come from?

    The Models section of the site details all the attributes that exist in each different type of asset, and therefore which ones you can retrieve as additional details in each search result, like ownerGroups.