Skip to content

Manage Insights assets (Collection, Folder, Query)

In general, these should be:

erDiagram
  Collection ||--o{ Folder : contains
  Folder ||--o{ Query : contains

Collection

3.1.2 2.0.0

To create a Collection:

Create a collection
1
2
3
4
5
6
7
AtlanClient client = Atlan.getDefaultClient();

AtlanCollection collection = AtlanCollection.creator(client, "MyCollection") 
        .adminGroup("admins")
        .build(); // (1)

AssetMutationResponse response = collection.save(); // (2)
  1. 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.
  2. Actually call Atlan to create the collection.

Create a collection
1
2
3
4
5
6
7
8
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)
  1. Build the minimum request to create a collection

    • provide an instance of AtlanClient.
    • specify a human-readable name for your collection.
  2. (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.

  3. Actually call Atlan to create the collection.

POST /api/meta/entity/bulk
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
{
   "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"
         ]
       }
     }
   ]
}
  1. When creating a collection through API tokens, make sure your qualified name follows this convention: default/collection/<api-token-username-here>/<some-uuid4-string>.
  2. Specify a human-readable name for your collection.
  3. (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

3.1.2 2.0.0

To create a Folder:

Create a folder
1
2
3
Folder folder = Folder.creator("MyFolder", collection).build(); // (1)

AssetMutationResponse response = folder.save(); // (2)
  1. 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 of Folder.
  2. Actually call Atlan to create the folder.

Create a folder
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
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)
  1. Build the minimum request to create a folder.

    • specify a human-readable name for your folder.
    • provide the qualifiedName of the Collection, or if you want to create a sub-folder, provide the parent_folder_qualified_name.
  2. Actually call Atlan to create the folder.

POST /api/meta/entity/bulk
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
{
   "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"
           }
         }
       }
     }
   ]
}
  1. When creating a folder through API tokens, make sure your qualified name follows this convention: <parent-qualified-name>/<folder-name>.
  2. Specify a human-readable name for your folder.
  3. In this example, we're creating a folder inside an existing collection; therefore, we specify the qualifiedName of the collection here. If you're creating a sub-folder, you should provide the qualifiedName of the parent Folder.
  4. Specify the qualifiedName of the collection.
  5. In this example, we're creating a folder inside an existing collection; therefore, we specify the qualifiedName of the collection here. If you're creating a sub-folder, you should provide the qualifiedName of the parent Folder.

Query

3.1.2 2.0.0

To create a Query:

Create a query
1
2
3
4
5
6
7
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(); // (3)
  1. 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 of Collection.
  2. In this example, we're creating a query for an existing Snowflake schema.

  3. Actually call Atlan to create the folder.
Create a query
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
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)
  1. 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 the collection_qualified_name.
  2. In this example, we're creating a query for an existing Snowflake schema.

  3. Actually call Atlan to create the folder.
POST /api/meta/entity/bulk
 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
{
   "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"
           }
         }
       }
     }
   ]
}
  1. When creating a query through API tokens, ensure that your qualifiedName follows this convention: <parent-qualified-name>/<query-name>.
  2. Specify a human-readable name for your query.
  3. Since we're creating a query for a Snowflake schema.
  4. Provide the qualifiedName of the Snowflake connection.
  5. Specify the raw SQL query.
  6. Provide the qualifiedName of the Snowflake schema.
  7. Provide the qualifiedName of the Snowflake database.
  8. In this example, we're creating a folder inside an existing collection; therefore, we specify the qualifiedName of the collection here. If you're creating a sub-folder, you should provide the qualifiedName of the parent folder.
  9. Specify the qualifiedName of the collection.
  10. Since this is a non-visual query, ensure it is appropriately marked as such.
  11. In this example, we're creating a query inside an existing folder; therefore, we specify the qualifiedName of the folder here. If you're creating a query inside a collection, you should provide the qualifiedName of the collection.

  1. Although if you want to delete everything in a connection, your better avenue is the packaged connection delete utility in the UI.