Extending Atlan's model¶
You can extend the metadata model in Atlan through its typedefs.
Closed beta
This feature is currently provided as a closed beta. Specific policies must be configured in your tenant to have the necessary access to create these extensions; without these operations these will not work.
Further caveats
When extending the Atlan data model, you should be aware of these additional restrictions:
- You can only manage definitions that are not in Atlan's internally-managed namespace, defined by the
serviceTypeof each model. - So if you want to extend an existing model, you should create a new type in your own
serviceTypeand specify the model you want to extend as the supertype of that model. - You should follow a naming convention that prefixes all attributes you define, to avoid potential future conflicts with Atlan-managed attributes.
Create new struct models¶
You can use structs to embed complex structures within other models. If you only intend to use primitive attributes, you do not need to define any structs.
To create a new struct model:
| Create a new struct model | |
|---|---|
1 2 3 4 5 6 7 8 | |
- Begin by defining the list of attribute definitions for the struct model.
- Each attribute definition must have at least a name and a type.
- Define the struct model itself by providing at least a name and the list of attribute definitions.
- (Optional) You can also specify your own namespace for the model using
serviceType. This will default tocustom_extensionif not specified. - Call the
_create()method to actually create the new struct model in Atlan.
Create new entity models¶
Entities define the metadata objects that Atlan can store, update, search, and so on. They can be made up of both primitive and struct-based (complex) attributes. To create a new entity model:
| Create a new entity model | |
|---|---|
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | |
- Begin by defining the list of attribute definitions for the entity model.
- Each attribute definition must have at least a name and a type. If the type is not primitive (in this example a struct), you must also specify the kind of object (struct).
- You can also override the cardinality, in this example we allow multiple embedded complex values against this single attribute.
- (Optional) You can also specify your own namespace for the model using
serviceType. This will default tocustom_extensionif not specified. - Define the entity model itself by providing at least a name and the list of attribute definitions.
- Call the
_create()method to actually create the new entity model in Atlan.
Create new relationship models¶
Relationships define connections between entities. They must always have two entity model endpoints. To create a new relationship model:
| Create a new relationship model | |
|---|---|
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | |
- (Optional) Begin by defining the list of attribute definitions for the relationship model. These are optional for a relationship, but are used to capture any attributes on each instance of the relationship.
- Each attribute definition must have at least a name and a type. If the type is not primitive (in this example a struct), you must also specify the kind of object (struct).
- Define each entity endpoint of the relationship.
- You must give the endpoint a name — this will be the name of the attribute that appears in the entity itself to represent this relationship.
- You must specify the type of entity this relationship exists on (where the attribute name above will appear).
- Specify whether the relationship on this entity "contains" the other entities. For parent-child relationships this should be
trueon the parent entity type, andfalseotherwise. - Specify the cardinality of the relationship: in this example we allow multiple children to be related to the parent type.
- Since every relationship is between exactly two entities, create an endpoint for the other side of the relationship as well.
- As before, you must give the endpoint a name — this will be the name of the attribute that appears in the entity itself to represent this relationship.
- You must specify the type of entity this relationship exists on (where the attribute name above will appear).
- Since this example is the child referring to its parent, the child is not a container.
- Since this example is the child referring to a single parent, this end of the relationship's cardinality is singular.
- Define the relationship model itself by providing at least a name, the two endpoints, and (optionally) the list of attribute definitions.
-
By default, a relationship will be created as an
ASSOCIATION. You can override this with any of:ASSOCIATION: defines a peer-to-peer relationship between the entity endpoints.AGGREGATION: defines a relationship where one endpoint is logically the "parent" of another endpoint. This differs from theCOMPOSITIONby not cascading deletes to related entities.COMPOSITION: defines a relationship where one endpoint is strictly the "parent" of another endpoint. This differs fromAGGREGATIONbecause any removal of the entity at the parent end of the relationship will cascade to removing any of the related children entities as well.
-
(Optional) You can also specify your own namespace for the model using
serviceType. This will default tocustom_extensionif not specified. - Call the
_create()method to actually create the new entity model in Atlan.
Update existing models¶
Treat existing attributes as immutable
You can also update existing entity models. However, in general you should only append (create new) attributes and not remove or attempt to change any existing attributes, or you may lose data from those existing attributes.
To update an existing model, first retrieve it and then apply updates to it:
| Update an existing model | |
|---|---|
48 49 50 51 52 53 54 | |
- Begin by retrieving the existing model's definition.
-
You can convert the immutable object returned into a mutatable builder using the
.toBuilder()method.Remember to assign the value back
Remember to assign the built immutable value back to some variable, and use that variable in the next step. Otherwise the changes you make here will not be applied back.
-
You can then append as many additional attributes as you like.
- You should also update the
typeVersionof the model to the next minor version. - Call the
_update()method to actually update the existing model in Atlan.