Creating an asset¶
All objects in the SDK that you can create within Atlan implement the builder pattern. This allows you to progressively build-up the object you want to create. In addition, each object provides a method that takes the minimal set of required fields to create that asset.
Each type of asset has a different containment hierarchy
Every asset in Atlan can have slightly different parent objects in which they exist. For example, a GlossaryTerm
cannot exist outside a Glossary
. A Column
cannot exist outside a Table
, View
or MaterializedView
; these cannot exist outside a Schema
; which cannot exist outside a Database
; which cannot exist outside a Connection
.
The minimal required fields for each asset type will therefore be slightly different.
Creation order is important
As a result of this containment, creation order is important. Parent objects must be created (exist) before child objects can be created.
Build minimal object needed¶
For example, to create a glossary term you need to provide the name of the term and either the GUID or qualifiedName
of the glossary in which to create the term:
Build minimal asset necessary for creation | |
---|---|
1 2 3 |
|
- A name for the new term.
- The GUID or
qualifiedName
of the glossary in which to create the term.
Build minimal asset necessary for creation | |
---|---|
1 2 3 4 5 6 7 8 |
|
- A name for the new term.
- The GUID of the glossary in which to create the term.
Build minimal asset necessary for creation | |
---|---|
1 2 3 4 5 |
|
- A name for the new term.
- The GUID or
qualifiedName
of the glossary in which to create the term.
Implicit in the API calls below
There is nothing specific to do for this step when using the raw APIs — constructing the object is simply what you place in the payload of the API calls in the steps below.
Create the asset from the object¶
This term
object will have the minimal required information for Atlan to create it. You must then actually persist the object in Atlan1:
Create the asset | |
---|---|
5 6 7 8 9 10 11 12 13 14 15 |
|
- Before you can take actions on the builder object you've been interacting with, you need to
build()
it into a full object. -
Then you can do operations, like
save()
, which will either:- create a new asset, if Atlan does not have a term with the same name in the same glossary
- update an existing asset, if Atlan already has a term with the same name in the same glossary
Because this operation will persist the asset in Atlan, you must provide it an
AtlanClient
through which to connect to the tenant. -
You can distinguish what was created or updated:
getCreatedAssets()
lists assets that were createdgetUpdatedAssets()
lists assets that were updated
Note that the
save()
method always returns objects of typeAsset
, though. -
The
Asset
class is a superclass of all assets. So you need to cast to more specific types (likeGlossaryTerm
) after verifying the object that was actually returned. -
In this example, creating the
GlossaryTerm
actually also updates the parentGlossary
. This is why theresponse
contains genericAsset
objects rather than specific types — any operation could side-effect a number of different assets. -
Like with the
GlossaryTerm
, you can check and cast the genericAsset
returned by the response into its more specific type (Glossary
).
Create the asset | |
---|---|
9 10 11 12 13 14 15 |
|
-
Call the
save
method which will create or update the asset in atlan. -
You can distinguish what was created or updated:
assets_created(asset_type=AtlasGlossaryTerm)
returns a lists assets of the specified type that were created.assets_updated(asset_type=AtlasGlossaryTerm)
returns a lists assets of the specified type that were updated.
-
Check if the list is empty to determine if an
AtlasGlossaryTerm
was created. -
Get the new
AtlasGlossaryTerm
that was created. -
In this example, creating the
AtlasGlossaryTerm
actually also updates the parentAtlasGlossary
. This is why theresponse
contains anAtlasGlossary
. -
Check if the list is empty to determine if an
AtlasGlossary
was updated. -
Get the
AtlasGlossary
that was updated.
Create the asset | |
---|---|
6 7 8 9 10 11 12 13 |
|
- Before you can take actions on the builder object you've been interacting with, you need to
build()
it into a full object. -
Then you can do operations, like
save()
, which will either:- create a new asset, if Atlan does not have a term with the same name in the same glossary
- update an existing asset, if Atlan already has a term with the same name in the same glossary
Because this operation will persist the asset in Atlan, you must provide it an
AtlanClient
through which to connect to the tenant. -
You can distinguish what was created or updated:
getCreatedAssets()
lists assets that were createdgetUpdatedAssets()
lists assets that were updated
Note that the
save()
method always returns objects of typeAsset
, though. -
The
Asset
class is a superclass of all assets. So you need to cast to more specific types (likeGlossaryTerm
) after verifying the object that was actually returned. -
In this example, creating the
GlossaryTerm
actually also updates the parentGlossary
. This is why theresponse
contains genericAsset
objects rather than specific types — any operation could side-effect a number of different assets. -
Like with the
GlossaryTerm
, you can check and cast the genericAsset
returned by the response into its more specific type (Glossary
).
POST /api/meta/entity/bulk | |
---|---|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
|
- All assets must be wrapped in an
entities
array. - You must provide the exact type name for the asset (case-sensitive). For a term, this is
AtlasGlossaryTerm
. - You must provide the exact name of the asset (case-sensitive).
- You must provide a
qualifiedName
of the asset (case-sensitive). In the case of glossary objects (like terms), this will actually be replaced in the back-end with a generatedqualifiedName
, but you must provide some value when creating the object. - You must also specify the parent object in which this object is contained (if any). In the case of a term, it can only exist within a glossary. So here we specify the details of the parent glossary through the
anchor
relationship (specific to glossary assets).
(Optional) Enrich before creating¶
If you want to further enrich the asset before creating it, you can do this using the builder pattern:
Alternatively, further enrich the asset before creating it | |
---|---|
5 6 7 8 9 10 11 |
|
- We'll create an object you can take actions on from this creator.
- In this example, you're adding a certificate and announcement to the object.
- To persist the enrichment back to the object, you must
build()
the builder. - You can call the
save()
operation against this enriched object, the same as shown earlier. Because this operation will persist the asset in Atlan, you must provide it anAtlanClient
through which to connect to the tenant.
Assign the result back
Remember to assign the result of the build()
operation back to a variable! (In the example above this happens on line 5 with GlossaryTerm term =
.)
Alternatively, further enrich the asset before creating it | |
---|---|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
|
- You can call the
save()
operation against this enriched object, the same as shown earlier.
Alternatively, further enrich the asset before creating it | |
---|---|
6 7 8 9 10 11 12 |
|
- We'll create an object you can take actions on from this creator.
- In this example, you're adding a certificate and announcement to the object.
- To persist the enrichment back to the object, you must
build()
the builder. - You can call the
save()
operation against this enriched object, the same as shown earlier. Because this operation will persist the asset in Atlan, you must provide it anAtlanClient
through which to connect to the tenant.
Assign the result back
Remember to assign the result of the build()
operation back to a variable! (In the example above this happens on line 6 with val term =
.)
POST /api/meta/entity/bulk | |
---|---|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
|
- You would still create the asset by wrapping it within the
entities
array. - But you can also extend the information you store on the asset. In this example, you're adding a certificate and announcement to the object when it is created.
-
Why no distinction between creation and update? This has to do with how Atlan detects changes — see the Importance of identifiers for a more detailed explanation. ↩