Change owners
There are actually two fields in Atlan that capture the owners of an asset: ownerUsers and ownerGroups.
The examples below illustrate how to change individual (user) owners. To change group owners, replace ownerUsers with ownerGroups.
Change existing asset
Remember that Atlan matches the provided qualifiedName to determine whether to update or create the asset.
To change owners on an existing asset:
- dbt
- Java
- Python
- Kotlin
- Raw REST API
models:
- name: TOP_BEVERAGE_USERS # (1)
meta:
atlan:
attributes: # (2)
ownerUsers: ["jsmith", "jdoe"] # (3)
-
You must of course give the name of the object.
-
The usernames must be nested within the
meta.atlan.attributesstructure. -
You must provide valid usernames, or email addresses, as a list.
Users must be valid
If the user doesn't exist in Atlan, there will be no updates to the asset. Please verify the usernames or email addresses in Atlan before assigning them to assets. :::
Table table = Table.updater( // (1)
"default/snowflake/1657037873/SAMPLE_DB/FOOD_BEV/TOP_BEVERAGE_USERS", // (2)
"TOP_BEVERAGE_USERS") // (3)
.ownerUsers(List.of("jsmith", "jdoe")) // (4)
.build(); // (5)
AssetMutationResponse response = table.save(client); // (6)
assert response.getUpdatedAssets().size() == 1 // (7)
- Use the
updater()helper method to create the minimal object necessary to do an update. - The
qualifiedNameof the object. - The
nameof the object. - Provide the new owners. Note that this is a list of the usernames of the users.
- Build the updater into an object.
- Send the update to Atlan. Because this operation will persist the asset in Atlan, you must provide it an
AtlanClientthrough which to connect to the tenant. - The response will include that single asset that was updated.
from pyatlan.client.atlan import AtlanClient
from pyatlan.model.assets import Table
client = AtlanClient()
table = Table.updater( # (1)
qualified_name="default/snowflake/1657037873/SAMPLE_DB/FOOD_BEV/TOP_BEVERAGE_USERS",
name="TOP_BEVERAGE_USERS",
)
table.owner_users = ["jsmith", "jdoe"] # (2)
response = client.asset.save(table) # (3)
assert 1 == len(response.assets_updated(asset_type=Table)) # (4)
- Use the
updater()method to create an asset suitable for modification that is, with all the requisite attributes. - Provide the new owners. Note that this is a list of the usernames of the users.
- Send the update to Atlan.
- The response should only include that single asset that was updated.
val table = Table.updater( // (1)
"default/snowflake/1657037873/SAMPLE_DB/FOOD_BEV/TOP_BEVERAGE_USERS", // (2)
"TOP_BEVERAGE_USERS") // (3)
.ownerUsers(listOf("jsmith", "jdoe")) // (4)
.build() // (5)
val response = table.save(client) // (6)
assert(response.updatedAssets.size == 1) // (7)
- Use the
updater()helper method to create the minimal object necessary to do an update. - The
qualifiedNameof the object. - The
nameof the object. - Provide the new owners. Note that this is a list of the usernames of the users.
- Build the updater into an object.
- Send the update to Atlan. Because this operation will persist the asset in Atlan, you must provide it an
AtlanClientthrough which to connect to the tenant. - The response will include that single asset that was updated.
{
"entities": [ // (1)
}
]
}
- All assets must be wrapped in an
entitiesarray. - You must provide the exact type name for the asset (case-sensitive).
- You must provide the exact name of the asset (case-sensitive).
- You must provide the exact
qualifiedNameof the asset (case-sensitive). - Provide the new owners, as a list of usernames of users.
Remove from existing asset
To remove owners from an existing asset:
- dbt
- Java
- Python
- Kotlin
- Raw REST API
models:
- name: TOP_BEVERAGE_USERS # (1)
meta:
atlan:
attributes: # (2)
ownerUsers: [ "jdoe" ] # (3)
-
You must of course give the name of the object.
-
The details for the owners must be nested within the
meta.atlan.attributesstructure. -
Specify only the usernames or email addresses of the users you want to keep as owners. (Compared to the other examples, this would remove
jsmithand keepjdoe.)Users must be valid
If the user doesn't exist in Atlan, there will be no updates to the asset. Please verify the usernames or email addresses in Atlan before assigning them to assets. :::
Table table = Table.removeOwners( // (1)
client, // (2)
"default/snowflake/1657037873/SAMPLE_DB/FOOD_BEV/TOP_BEVERAGE_USERS", // (3)
"TOP_BEVERAGE_USERS"); // (4)
- Use the
removeOwners()helper method, which for most objects requires a minimal set of information. This helper method will construct the necessary request, call the necessary APIs, and return with the result of the removal operation all-in-one. - Because this operation will directly change the asset in Atlan, you must provide it an
AtlanClientthrough which to connect to the tenant. - The
qualifiedNameof the object. - The
nameof the object.
from pyatlan.client.atlan import AtlanClient
from pyatlan.model.assets import Table
client = AtlanClient()
table = Table.updater( # (1)
qualified_name="default/snowflake/1657037873/SAMPLE_DB/FOOD_BEV/TOP_BEVERAGE_USERS",
name="TOP_BEVERAGE_USERS",
)
table.owner_users = None # (2)
response = client.asset.save(table) # (3)
assert 1 == len(response.assets_updated(asset_type=Table)) # (4)
- Use the
updater()method to create an asset suitable for modification that is, with all the requisite attributes. - Set the owners to
None. - Send the update to Atlan.
- The response should only include that single asset that was updated (again, removing owners is an update to the asset—we'ren't deleting the asset itself).
val table = Table.removeOwners( // (1)
client, // (2)
"default/snowflake/1657037873/SAMPLE_DB/FOOD_BEV/TOP_BEVERAGE_USERS", // (3)
"TOP_BEVERAGE_USERS") // (4)
- Use the
removeOwners()helper method, which for most objects requires a minimal set of information. This helper method will construct the necessary request, call the necessary APIs, and return with the result of the removal operation all-in-one. - Because this operation will directly change the asset in Atlan, you must provide it an
AtlanClientthrough which to connect to the tenant. - The
qualifiedNameof the object. - The
nameof the object.
{
"entities": [ // (1)
}
]
}
- All assets must be wrapped in an
entitiesarray. - You must provide the exact type name for the asset (case-sensitive).
- You must provide the exact name of the asset (case-sensitive).
- You must provide the exact
qualifiedNameof the asset (case-sensitive). - You must set the
ownerUsersandownerGroupsto an empty list.
When creating asset
To add owners when creating an asset:
- dbt
- Java
- Python
- Kotlin
- Raw REST API
models:
- name: TOP_BEVERAGE_USERS # (1)
meta:
atlan:
attributes: # (2)
ownerUsers: ["jsmith", "jdoe"] # (3)
-
You must of course give the name of the object.
-
The usernames must be nested within the
meta.atlan.attributesstructure. -
You must provide valid usernames, or email addresses, as a list.
Users must be valid
If the user doesn't exist in Atlan, there will be no updates to the asset. Please verify the usernames or email addresses in Atlan before assigning them to assets. :::
Table table = Table
.creator("TOP_BEVERAGE_USERS", // (1)
"default/snowflake/1657037873/SAMPLE_DB/FOOD_BEV")
.ownerUsers(List.of("jsmith", "jdoe")) // (2)
.build(); // (3)
AssetMutationResponse response = table.save(client); // (4)
assert response.getCreatedAssets().size() == 1 // (5)
- Use the
creator()method to initialize the object with all necessary attributes for creating it](../advanced-examples/create.md#build-minimal-object-needed). - Set the owners that should be added. Note that this is a list of the usernames of the users.
- Call the
build()method to build the enriched object. - Call the
save()method to actually create the asset with these owners. Because this operation will persist the asset in Atlan, you must provide it anAtlanClientthrough which to connect to the tenant. - The response will include that single asset that was created.
from pyatlan.client.atlan import AtlanClient
from pyatlan.model.assets import Table
client = AtlanClient()
table = Table.creator( # (1)
name="TOP_BEVERAGE_USERS",
schema_qualified_name="default/snowflake/1657037873/SAMPLE_DB/FOOD_BEV",
)
table.owner_users = ["jsmith", "jdoe"] # (2)
response = client.asset.save(table) # (3)
assert 1 == len(assets_created := response.assets_created(asset_type=Table)) # (4)
table = assets_created[0] # (5)
- Use the
creator()method to initialize the object with all necessary attributes for creating it. - Set the owners that should be added. Note that this is a list of the usernames of the users.
- Call the
save()method to actually create the asset with these owners. - Since a save can add, update, delete or partially update multiple assets the
assets_created()method can be used to return a list of the assets of the specified type that were added. The assert statement is present to make sure aTableasset was created. - Since only one
Tablehas been created we use an index of 0 to retrieve the newly created table.
val table = Table
.creator("TOP_BEVERAGE_USERS", // (1)
"default/snowflake/1657037873/SAMPLE_DB/FOOD_BEV")
.ownerUsers(listOf("jsmith", "jdoe")) // (2)
.build() // (3)
val response = table.save(client) // (4)
assert(response.createdAssets.size == 1) // (5)
- Use the
creator()method to initialize the object with all necessary attributes for creating it](../advanced-examples/create.md#build-minimal-object-needed). - Set the owners that should be added. Note that this is a list of the usernames of the users.
- Call the
build()method to build the enriched object. - Call the
save()method to actually create the asset with these owners. Because this operation will persist the asset in Atlan, you must provide it anAtlanClientthrough which to connect to the tenant. - The response will include that single asset that was created.
{
"entities": [ // (1)
},
"ownerUsers": [ "jsmith", "jdoe" ] // (6)
}
}
]
}
- All assets must be wrapped in an
entitiesarray. - You must provide the exact type name for the asset (case-sensitive).
- You must provide a name for the asset.
- In the case of a table, the
qualifiedNamemust be the concatenation of the parent schema's qualifiedName and the name of the table. - When creating a table, you must specify the schema to create it within. This is defined by the
atlanSchemaattribute. You must specify both the type (must beSchema) and qualifiedName of the schema within theatlanSchemaattribute—and the schema must already exist. - Provide the owners, as a list of usernames of users.