Manage Insights assets (Collection, Folder, Query)
In general, these should be:
- Created in top-down order (collection, folder, query)
- Deleted in bottom-up order (query, folder, collection)1
Collection
To create a Collection:
- Java
- Python
- Kotlin
- Raw REST API
AtlanCollection collection = AtlanCollection.creator(client, "MyCollection")
.adminGroup("admins")
.build(); // (1)
AssetMutationResponse response = collection.save(client); // (2)
-
Build the minimum request to create a collection.
- provide an instance of
AtlanClient. - specify a human-readable name for your collection.
- (optional) specify the name of the group that can administer this collection.
You can use also use
adminUsers,viewerUsers,ownerUsers, etc to manage different levels of access control for the collection.
- provide an instance of
-
Actually call Atlan to create the collection. Because this operation will persist the asset in Atlan, you must provide it an
AtlanClientthrough which to connect to the tenant.
from pyatlan.client.atlan import AtlanClient
from pyatlan.model.assets import Collection
client = AtlanClient()
collection = Collection.creator(client=client, name="my-collection") # (1)
collection.admin_groups = ["admins"] # (2)
response = client.asset.save(collection) # (3)
-
Build the minimum request to create a collection
- provide an instance of
AtlanClient. - specify a human-readable name for your collection.
- provide an instance of
-
(optional) Specify the name of the group that can administer this collection. You can use also use
adminUsers,viewerUsers,ownerUsers, etc to manage different levels of access control for the collection. -
Actually call Atlan to create the collection.
val collection = AtlanCollection.creator(client, "MyCollection")
.adminGroup("admins")
.build() // (1)
val response = collection.save(client) // (2)
-
Build the minimum request to create a collection.
- provide an instance of
AtlanClient. - specify a human-readable name for your collection.
- (optional) specify the name of the group that can administer this collection.
You can use also use
adminUsers,viewerUsers,ownerUsers, etc to manage different levels of access control for the collection.
- provide an instance of
-
Actually call Atlan to create the collection. Because this operation will persist the asset in Atlan, you must provide it an
AtlanClientthrough which to connect to the tenant.
{
"entities": [
{
"typeName": "Collection",
"attributes": {
"qualifiedName": "default/collection/service-account-apikey-9468b3e4-d30d-98ba-87d2-f080841a99ef/a08e5dcb-38bd-47d2-b2ea-e439cd0bbe22",
// (1)
"name": "MyCollection", // (2)
"adminGroups": [ // (3)
"admins"
]
}
}
]
}
- When creating a collection through API tokens, make sure your qualified
name follows this convention:
default/collection/<api-token-username-here>/<some-uuid4-string>. - Specify a human-readable name for your collection.
- (optional) Specify the name of the group that can administer this collection.
You can use also use
adminUsers,viewerUsers,ownerUsers, etc to manage different levels of access control for the collection.
Folder
To create a Folder:
- Java
- Python
- Kotlin
- Raw REST API
Folder folder = Folder.creator("MyFolder", collection).build(); // (1)
AssetMutationResponse response = folder.save(client); // (2)
-
Build the minimum request to create a folder.
- specify a human-readable name for your folder.
- provide an instance of
Collection, or if you want to create a sub-folder, provide an instance ofFolder.
-
Actually call Atlan to create the folder. Because this operation will persist the asset in Atlan, you must provide it an
AtlanClientthrough which to connect to the tenant.
from pyatlan.client.atlan import AtlanClient
from pyatlan.model.assets import Folder
client = AtlanClient()
folder = Folder.creator(
name="my-folder",
collection_qualified_name="default/collection/user/abcdxyz",
) # (1)
response = client.asset.save(folder) # (2)
-
Build the minimum request to create a folder.
- specify a human-readable name for your folder.
- provide the
qualifiedNameof theCollection, or if you want to create a sub-folder, provide theparent_folder_qualified_name.
-
Actually call Atlan to create the folder.
val folder = Folder.creator("MyFolder", collection).build() // (1)
val response = folder.save(client) // (2)
-
Build the minimum request to create a folder.
- specify a human-readable name for your folder.
- provide an instance of
Collection, or if you want to create a sub-folder, provide an instance ofFolder.
-
Actually call Atlan to create the folder. Because this operation will persist the asset in Atlan, you must provide it an
AtlanClientthrough which to connect to the tenant.
{
"entities": [
{
"typeName": "Folder",
"attributes": {
"qualifiedName": "default/collection/service-account-apikey-d468b3e4-d30d-48ba-87d2-f080841a59ef/5zNMTC3MUzvfTS4L5QuRi/MyFolder", // (1)
"name": "MyFolder", // (2)
"parentQualifiedName": "default/collection/service-account-apikey-d468b3e4-d30d-48ba-87d2-f080841a59ef/5zNMTC3MUzvfTS4L5QuRi", // (3)
"collectionQualifiedName": "default/collection/service-account-apikey-d468b3e4-d30d-48ba-87d2-f080841a59ef/5zNMTC3MUzvfTS4L5QuRi", // (4)
"parent": {
"typeName": "Collection", // (5)
"uniqueAttributes": {
"qualifiedName": "default/collection/service-account-apikey-d468b3e4-d30d-48ba-87d2-f080841a59ef/5zNMTC3MUzvfTS4L5QuRi"
}
}
}
}
]
}
- When creating a folder through API tokens, make sure your qualified
name follows this convention:
<parent-qualified-name>/<folder-name>. - Specify a human-readable name for your folder.
- In this example, we're creating a folder inside an existing collection;
therefore, we specify the
qualifiedNameof the collection here. If you're creating a sub-folder, you should provide thequalifiedNameof the parentFolder. - Specify the
qualifiedNameof the collection. - In this example, we're creating a folder inside an existing collection;
therefore, we specify the
qualifiedNameof the collection here. If you're creating a sub-folder, you should provide thequalifiedNameof the parentFolder.
Query
To create a Query:
- Java
- Python
- Kotlin
- Raw REST API
String schemaQualifiedName = "default/snowflake/1735591234/DB/SCHEMA";
AtlanQuery query = AtlanQuery.creator("MyQuery", folder) // (1)
.withRawQuery(schemaQualifiedName, "SELECT * FROM CUSTOMERS;") // (2)
.build();
AssetMutationResponse response = query.save(client); // (3)
-
Build the minimum request to create a query.
- specify a human-readable name for your query.
- provide an instance of
Folder, or if you want to create a query inside a collectin, provide an instance ofCollection.
-
In this example, we're creating a query for an existing
Snowflakeschema. -
Actually call Atlan to create the folder. Because this operation will persist the asset in Atlan, you must provide it an
AtlanClientthrough which to connect to the tenant.
from pyatlan.client.atlan import AtlanClient
from pyatlan.model.assets import Query
client = AtlanClient()
schema_qualified_name = "default/snowflake/1735591234/DB/SCHEMA"
query = Query.creator(
name="my-query",
parent_folder_qualified_name="default/collection/user/abc/folder/user/xyz"
) # (1)
query.with_raw_query(
schema_qualified_name=schema_qualified_name,
query="SELECT * FROM CUSTOMERS;"
) # (2)
response = client.asset.save(query) # (3)
-
Build the minimum request to create a query.
- specify a human-readable name for your query.
- provide the qualifedName of the
Folder, or if you want to create a query inside a collection, provide thecollection_qualified_name.
-
In this example, we're creating a query for an existing
Snowflakeschema. -
Actually call Atlan to create the folder.
val schemaQualifiedName = "default/snowflake/1735591234/DB/SCHEMA"
val query = AtlanQuery.creator("MyQuery", folder) // (1)
.withRawQuery(schemaQualifiedName, "SELECT * FROM CUSTOMERS;") // (2)
.build()
val response = query.save(client) // (3)
-
Build the minimum request to create a query.
- specify a human-readable name for your query.
- provide an instance of
Folder, or if you want to create a query inside a collectin, provide an instance ofCollection.
-
In this example, we're creating a query for an existing
Snowflakeschema. -
Actually call Atlan to create the folder. Because this operation will persist the asset in Atlan, you must provide it an
AtlanClientthrough which to connect to the tenant.
{
"entities": [
{
"typeName": "Query",
"attributes": {
"qualifiedName": "default/collection/service-account-apikey-d468b3e4-d30d-48ba-87d2-f080841a59ef/5zNMTC3MUzvfTS4L5QuRi/folder/service-account-apikey-d468b3e4-d30d-48ba-87d2-f080841a59ef/V2ddMTTMJItUy1aV6biSh/MyQuery",
// (1)
"name": "MyQuery", // (2)
"connectionName": "snowflake", // (3)
"connectionQualifiedName": "default/snowflake/1735591234", // (4)
"rawQueryText": "SELECT * FROM CUSTOMERS;", // (5)
"defaultSchemaQualifiedName": "default/snowflake/1735591234/DB/SCHEMA", // (6)
"defaultDatabaseQualifiedName": "default/snowflake/1735591234/DB", // (7)
"variablesSchemaBase64": "eyJjdXN0b212YXJpYWJsZXNEYXRlVGltZUZvcm1hdCI6IHsiZGVmYXVsdERhdGVGb3JtYXQiOiAiWVlZWS1NTS1ERCIsICJkZWZhdWx0VGltZUZvcm1hdCI6ICJISDptbSJ9LCAiY3VzdG9tVmFyaWFibGVzIjogW119",
"parentQualifiedName": "default/collection/service-account-apikey-d468b3e4-d30d-48ba-87d2-f080841a59ef/5zNMTC3MUzvfTS4L5QuRi/folder/service-account-apikey-d468b3e4-d30d-48ba-87d2-f080841a59ef/V2ddMTTMJItUy1aV6biSh", // (8)
"collectionQualifiedName": "default/collection/service-account-apikey-d468b3e4-d30d-48ba-87d2-f080841a59ef/5zNMTC3MUzvfTS4L5QuRi", // (9)
"isVisualQuery": false, // (10)
"parent": {
"typeName": "Folder", // (11)
"uniqueAttributes": {
"qualifiedName": "default/collection/service-account-apikey-d468b3e4-d30d-48ba-87d2-f080841a59ef/5zNMTC3MUzvfTS4L5QuRi/folder/service-account-apikey-d468b3e4-d30d-48ba-87d2-f080841a59ef/V2ddMTTMJItUy1aV6biSh"
}
}
}
}
]
}
- When creating a query through API tokens, make sure that your
qualifiedNamefollows this convention:<parent-qualified-name>/<query-name>. - Specify a human-readable name for your query.
- Since we're creating a query for a
Snowflakeschema. - Provide the
qualifiedNameof theSnowflakeconnection. - Specify the raw SQL query.
- Provide the
qualifiedNameof theSnowflakeschema. - Provide the
qualifiedNameof theSnowflakedatabase. - In this example, we're creating a folder inside an existing collection; therefore, we specify the
qualifiedNameof the collection here. If you're creating a sub-folder, you should provide thequalifiedNameof the parent folder. - Specify the
qualifiedNameof the collection. - Since this is a non-visual query, make sure it's appropriately marked as such.
- In this example, we're creating a query inside an existing folder; therefore, we specify the
qualifiedNameof the folder here. If you're creating a query inside a collection, you should provide thequalifiedNameof the collection.