Skip to content

Retrieving assets

I need to do this before I can update an asset, right?

Strictly speaking, no, you do not. And in fact if you ultimately intend to update an asset you should trim it down to only what you intend to change and not send a complete asset. See Updating an asset for more details.

Retrieving an asset uses a slightly different pattern from the other operations. For this you can use static methods provided by the Asset class:

By GUID

2.0.3 1.0.0

To retrieve an asset by its GUID:

Retrieve an asset by its GUID
1
2
Glossary glossary = Glossary
    .get("b4113341-251b-4adc-81fb-2420501c30e6"); // (1)
  1. If no exception is thrown, the returned object will be non-null and of the type requested.

Compile-time type checking

This operation will type-check the asset you are retrieving is of the type requested. If it is not, you will receive a NotFoundException, even if the GUID represents some other asset.

Retrieve an asset by its GUID
1
2
3
4
5
6
7
8
from pyatlan.client.atlan import AtlanClient
from pyatlan.model.assets import AtlasGlossary

client = AtlanClient()
glossary = client.asset.get_by_guid(
    asset_type=AtlasGlossary, # (1)
    guid="b4113341-251b-4adc-81fb-2420501c30e6"
)
  1. Optionally, you can provide the asset type:
    • If no exception is thrown, the returned object will be non-null and of the type requested.

Run-time type checking

This operation will type-check the asset you are retrieving is of the type requested. If it is not, you will receive a NotFoundException, even if the GUID represents some other asset.

Retrieve an asset by its GUID
1
2
val glossary = Glossary
    .get("b4113341-251b-4adc-81fb-2420501c30e6") // (1)
  1. If no exception is thrown, the returned object will be non-null and of the type requested.

Compile-time type checking

This operation will type-check the asset you are retrieving is of the type requested. If it is not, you will receive a NotFoundException, even if the GUID represents some other asset.

GET /api/meta/entity/guid/b4113341-251b-4adc-81fb-2420501c30e6?ignoreRelationships=false&minExtInfo=false
1
// (1)
  1. In the case of retrieving an asset, all necessary information is included in the URL of the request. There is no payload for the body of the request.

By GUID (runtime typing)

2.0.3 1.0.0

To retrieve an asset by GUID, but only resolve the type at runtime:

Retrieve an asset by its GUID
1
2
3
4
5
6
7
8
Asset read = Asset
    .get(Atlan.getDefaultClient(),
        "b4113341-251b-4adc-81fb-2420501c30e6", // (1)
        false);
Glossary glossary;
if (read instanceof Glossary) {
    glossary = (Glossary) read; // (2)
}
  1. Retrieve the asset by its GUID. Since GUIDs are globally unique, you do not need to specify a type. (And this is why the operation returns a generic Asset, since the SDK can only determine the type at runtime, once it has a response back from Atlan.)
  2. Since the operation returns a generic Asset, you need to check and cast it to a more specific type if you want to access the more specific attributes of that type.
Retrieve an asset by its GUID
1
2
3
4
5
6
7
8
9
from pyatlan.client.atlan import AtlanClient
from pyatlan.model.assets import Asset, AtlasGlossary

client = AtlanClient()
asset = client.asset.get_by_guid(
    guid="cad503f4-277c-4417-807a-861493fe1432"
)
if isinstance(asset, AtlasGlossary): # (1) 
    glossary = asset
  1. Since the operation returns a generic Asset, you need to use isinstance() to cast it to a more specific type in the block if you want an IDE to provide more specific type hints.
Retrieve an asset by its GUID
1
2
3
4
5
val read: Asset = Asset
    .get(Atlan.getDefaultClient(),
        "b4113341-251b-4adc-81fb-2420501c30e6", // (1)
        false)
val glossary = if (read is Glossary) read else null // (2)
  1. Retrieve the asset by its GUID. Since GUIDs are globally unique, you do not need to specify a type. (And this is why the operation returns a generic Asset, since the SDK can only determine the type at runtime, once it has a response back from Atlan.)
  2. Since the operation returns a generic Asset, you need to check and cast it to a more specific type if you want to access the more specific attributes of that type.

Does not apply to a raw API request

There is no concept of typing in a raw API request — all responses to the raw API will simply be JSON objects.

By qualifiedName

1.4.0 1.0.0

To retrieve an asset by its qualifiedName:

Retrieve an asset by its qualifiedName
1
2
3
4
Glossary glossary = Glossary
    .get("FzCMyPR2LxkPFgr8eNGrq"); // (1)
Table table = Table
    .get("default/snowflake/1657037873/SAMPLE_DB/FOOD_BEV/TOP_BEVERAGE_USERS"); // (2)
  1. If no exception is thrown, the returned object will be non-null and of the type requested.

    Qualified name, not name

    You must provide the qualifiedName for glossary objects (glossaries, categories, terms) to use this method. If you only know the name, you should instead use the findByName() operations.

  2. For most objects, you can probably build-up the qualifiedName in your code directly.

    Finding the connection portion

    The one exception is likely to be the connection portion of the name (default/snowflake/1657037873 in this example). To find this portion, see Find connections.

Retrieve an asset by its qualifiedName
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
from pyatlan.client.atlan import AtlanClient
from pyatlan.model.assets import AtlasGlossary, Table

client = AtlanClient()
glossary = client.asset.get_by_qualified_name(
    asset_type=AtlasGlossary,  # (1)
    qualified_name="pXkf3RUvsIOIG8xnn0W3O"
)
table = client.asset.get_by_qualified_name(
    asset_type=Table,
    qualified_name="default/snowflake/1657037873/SAMPLE_DB/FOOD_BEV/TOP_BEVERAGE_USERS" # (2)
)
  1. If no exception is thrown, the returned object will be non-null and of the type requested.
  2. For most objects, you can probably build-up the qualified_name in your code directly.

    Finding the connection portion

    The one exception is likely to be the connection portion of the name (default/snowflake/1657037873 in this example). To find this portion, see Find connections.

Retrieve an asset by its qualifiedName
1
2
3
4
val glossary = Glossary
    .get("FzCMyPR2LxkPFgr8eNGrq") // (1)
val table = Table
    .get("default/snowflake/1657037873/SAMPLE_DB/FOOD_BEV/TOP_BEVERAGE_USERS") // (2)
  1. If no exception is thrown, the returned object will be non-null and of the type requested.

    Qualified name, not name

    You must provide the qualifiedName for glossary objects (glossaries, categories, terms) to use this method. If you only know the name, you should instead use the findByName() operations.

  2. For most objects, you can probably build-up the qualifiedName in your code directly.

    Finding the connection portion

    The one exception is likely to be the connection portion of the name (default/snowflake/1657037873 in this example). To find this portion, see Find connections.

GET /api/meta/entity/uniqueAttribute/type/Glossary/attr:qualifiedName=FzCMyPR2LxkPFgr8eNGrq&ignoreRelationships=false&minExtInfo=false
1
// (1)
  1. In the case of retrieving an asset, all necessary information is included in the URL of the request. There is no payload for the body of the request.

    URL encoding may be needed

    Note that depending on the qualifiedName, you may need to URL-encode its value before sending. This is to replace any parts of the name that could be misinterpreted as actual URL components (like / or spaces).

Full vs minimal assets

2.0.3 1.0.0

The examples above illustrate how to retrieve an asset with all of its relationships (a complete asset). You can also retrieve a "minimal" asset that includes only the non-relationship values for the asset:

Retrieve an asset by its GUID
1
2
3
4
Glossary glossary = Glossary
    .get(Atlan.getDefaultClient(),
        "b4113341-251b-4adc-81fb-2420501c30e6",
        false); // (1)
  1. Retrieve the minimal asset by its GUID. The last (optional) parameter being false indicates you want to retrieve the asset without its relationships (a minimal asset). Similar variations exist on every asset as well as on the dynamically-typed Asset static methods.
Retrieve an asset by its GUID
1
2
3
4
5
6
7
8
from pyatlan.client.atlan import AtlanClient
from pyatlan.model.assets import AtlasGlossary

client = AtlanClient()
glossary = client.asset.retrieve_minimal(
    asset_type=AtlasGlossary, # (1)
    guid="b4113341-251b-4adc-81fb-2420501c30e6"
)
  1. Optionally, you can provide the asset type:
    • If no exception is thrown, the returned object will be non-null and of the type requested.
Retrieve an asset by its GUID
1
2
3
4
val glossary = Glossary
    .get(Atlan.getDefaultClient(),
        "b4113341-251b-4adc-81fb-2420501c30e6",
        false) // (1)
  1. Retrieve the minimal asset by its GUID. The last (optional) parameter being false indicates you want to retrieve the asset without its relationships (a minimal asset). Similar variations exist on every asset as well as on the dynamically-typed Asset static methods.
GET /api/meta/entity/guid/b4113341-251b-4adc-81fb-2420501c30e6?ignoreRelationships=true&minExtInfo=true
1
// (1)
  1. In the case of retrieving an asset, all necessary information is included in the URL of the request. Retrieving a minimal asset is a matter of setting the query parameters ignoreRelationships and minExtInfo to true.

Retrieve minimal assets where possible

You should retrieve minimal assets for better performance in cases where you do not need all of the relationships of the asset.

Keep in mind that although the relationships will not be visible in the object after retrieving a minimal asset, this does not mean that there are no relationships on that asset (in Atlan).