Updating users and groups
You can update basic properties of both users and groups, again using the builder pattern.
Update group
For example, to update a group:
- Java
- Python
- Kotlin
- Go
- Raw REST API
AtlanGroup group = AtlanGroup.updater( // (1)
"e79cb8eb-2bb6-4821-914c-f8dfd21fedc7", // (2)
"/example_group") // (3)
.attributes(AtlanGroup.GroupAttributes.builder() // (4)
.description(List.of("Now with a description!")) // (5)
.build()) // (6)
.build(); // (7)
group.update(client); // (8)
- To update a group, start a builder using the
updater()method. - You must provide the GUID of the group...
- ...and the
pathof the group you want to update. (Note that the path is different from the name—you're best retrieving a group first and then getting the path from that retrieved object if you are unsure.) - You can then specify anything you want to update. In the case of a group, most of the properties are in an embedded
attributesobject that can be built-up through its own builder. - For example, you can add or change the description of the group. (Note that all objects in the attributes of a group are lists, even when they only have a single value.)
- Like other builder patterns, you need to build the attributes object.
- Like other builder patterns, you need to build the updated group object itself.
- Finally, you can call the
update()method on the built-up group object to actually update the group in Atlan. Note that this method doesn't return anything. Because this operation will persist the group in Atlan, you must provide it anAtlanClientthrough which to connect to the tenant.
from pyatlan.model.group import AtlanGroup
from pyatlan.client.atlan import AtlanClient
client = AtlanClient()
group = AtlanGroup.create_for_modification( # (1)
guid="e79cb8eb-2bb6-4821-914c-f8dfd21fedc7", # (2)
path="/example_group" # (3)
)
group.attributes = AtlanGroup.Attributes( # (4)
description=["Now with a description!"] # (5)
)
client.group.update(group) # (6)
- To update a group, you could start by retrieving the group. Alternatively, you can use
AtlanGroup.create_for_modification()to start building a minimal update request. - You must provide the GUID of the group...
- ...and the
pathof the group you want to update. (Note that the path is different from the name—you're best retrieving a group first and then getting the path from that retrieved object if you are unsure.) - You can then specify anything you want to update. In the case of a group, most of the properties are in an embedded
Attributesclass that can be built-up. - For example, you can add or change the description of the group. (Note that all objects in the attributes of a group are lists, even when they only have a single value.)
- Finally, you can call the
group.update()method with the built-up group object to actually update the group in Atlan. Note that this method doesn't return anything.
val group = AtlanGroup.updater( // (1)
"e79cb8eb-2bb6-4821-914c-f8dfd21fedc7", // (2)
"/example_group") // (3)
.attributes(AtlanGroup.GroupAttributes.builder() // (4)
.description(listOf("Now with a description!")) // (5)
.build()) // (6)
.build() // (7)
group.update(client) // (8)
- To update a group, start a builder using the
updater()method. - You must provide the GUID of the group...
- ...and the
pathof the group you want to update. (Note that the path is different from the name—you're best retrieving a group first and then getting the path from that retrieved object if you are unsure.) - You can then specify anything you want to update. In the case of a group, most of the properties are in an embedded
attributesobject that can be built-up through its own builder. - For example, you can add or change the description of the group. (Note that all objects in the attributes of a group are lists, even when they only have a single value.)
- Like other builder patterns, you need to build the attributes object.
- Like other builder patterns, you need to build the updated group object itself.
- Finally, you can call the
update()method on the built-up group object to actually update the group in Atlan. Note that this method doesn't return anything. Because this operation will persist the group in Atlan, you must provide it anAtlanClientthrough which to connect to the tenant.
AtlanGroup := assets.AtlanGroup{}
group, atlanErr := AtlanGroup.Updater( // (1)
"e79cb8eb-2bb6-4821-914c-f8dfd21fedc7", // (2)
"/example_group", // (3)
)
description := []string{"Now with a description!"}
group.Attributes.Description = description // (4)
ctx.GroupClient.Update(group) // (5)
- To update a group, you could start by retrieving the group. Alternatively, you can use
AtlanGroup.Updater()to start building a minimal update request. - You must provide the GUID of the group...
- ...and the
pathof the group you want to update. (Note that the path is different from the name—you're best retrieving a group first and then getting the path from that retrieved object if you are unsure.) - You can then specify anything you want to update. In the case of a group, most of the properties are in an embedded
Attributesclass that can be built-up. For example, you can add or change the description of the group. (Note that all objects in the attributes of a group are lists, even when they only have a single value.) - Finally, you can call the
GroupClient.Update()method with the built-up group object to actually update the group in Atlan. Note that this method doesn't return anything.
{
"id": "e79cb8eb-2bb6-4821-914c-f8dfd21fedc7", // (1)
"path": "/example_group", // (2)
"attributes": { // (3)
"description": [
"Now with a description!"
],
"isDefault": [
"false"
]
}
}
-
You must provide the GUID of the group within the request payload.
-
You must provide the internal name of the group, prefixed by
/, as thepath. -
You can provide any attributes to update on the group in the
attributesobject.Values are all arrays of strings
Note that every value for an attribute is an array of strings, even when there is only a single value. :::
Remove users from group
To remove one or more users from a group:
- Java
- Python
- Kotlin
- Go
- Raw REST API
AtlanGroup group = AtlanGroup.updater( // (1)
"e79cb8eb-2bb6-4821-914c-f8dfd21fedc7", // (2)
"/example_group") // (3)
.build(); // (4)
group.removeUsers(client, List.of("da213751-95de-4f96-8bee-a2c73e2ef8c8")); // (5)
- To update group membership, start a builder using the
updater()method. - You must provide the GUID of the group...
- ...and the
pathof the group you want to update. (Note that the path is different from the name—you're best retrieving a group first and then getting the path from that retrieved object if you are unsure.) - Like other builder patterns, you need to build the updated group object itself.
- Use the
removeUsers()method to remove one or more users from the group. Specify the GUID of each user you want to remove as a member of the group. Because this operation will persist the group in Atlan, you must provide it anAtlanClientthrough which to connect to the tenant.
from pyatlan.client.atlan import AtlanClient
client = AtlanClient()
client.group.remove_users( # (1)
guid="e79cb8eb-2bb6-4821-914c-f8dfd21fedc7", # (2)
user_ids=["da213751-95de-4f96-8bee-a2c73e2ef8c8"] # (3)
)
- Use the
group.remove_users()method to remove one or more users from the group. - Specify the GUID of the group from which you want to remove users.
- Specify the GUID of each user you want to remove as a member of the group.
val group = AtlanGroup.updater( // (1)
"e79cb8eb-2bb6-4821-914c-f8dfd21fedc7", // (2)
"/example_group") // (3)
.build() // (4)
group.removeUsers(client, listOf("da213751-95de-4f96-8bee-a2c73e2ef8c8")) // (5)
- To update group membership, start a builder using the
updater()method. - You must provide the GUID of the group...
- ...and the
pathof the group you want to update. (Note that the path is different from the name—you're best retrieving a group first and then getting the path from that retrieved object if you are unsure.) - Like other builder patterns, you need to build the updated group object itself.
- Use the
removeUsers()method to remove one or more users from the group. Specify the GUID of each user you want to remove as a member of the group. Because this operation will persist the group in Atlan, you must provide it anAtlanClientthrough which to connect to the tenant.
ctx.GroupClient.RemoveUsers( // (1)
"a99f50bc-46bf-4d08-a987-3411ef5cfc33", // (2)
[]string{"b060a754-4d16-4e13-b5a8-ba42f10aee39"}, // (3)
)
- Use the
GroupClient.RemoveUsers()method to remove one or more users from the group. - Specify the GUID of the group from which you want to remove users.
- Specify the GUID of each user you want to remove as a member of the group.
{
"users": [ // (1)
"da213751-95de-4f96-8bee-a2c73e2ef8c8" // (2)
]
}
- You must provide the list of users to remove from the group in a
usersarray. - Specify each user by its unique ID (GUID).
Update user
To update a user, begin by building the minimal update object:
- Java
- Python
- Kotlin
- Go
- Raw REST API
AtlanUser user = AtlanUser.updater( // (1)
"da213751-95de-4f96-8bee-a2c73e2ef8c8") // (2)
.build(); // (3)
- To update a user, start a builder using the
updater()method. - You must provide the GUID of the user.
- Like other builder patterns, you need to build the updated user object itself.
The specific operations for updating a user are all listed below - there is no update object to build in the Python SDK.
val user = AtlanUser.updater( // (1)
"da213751-95de-4f96-8bee-a2c73e2ef8c8") // (2)
.build() // (3)
- To update a user, start a builder using the
updater()method. - You must provide the GUID of the user.
- Like other builder patterns, you need to build the updated user object itself.
The specific operations for updating a user are all listed below - there is no update object to build in the Go SDK.
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.
Add user to groups
Once you have the update object, to add a user to one or more groups:
- Java
- Python
- Kotlin
- Go
- Raw REST API
user.addToGroups(client, List.of("e79cb8eb-2bb6-4821-914c-f8dfd21fedc7")); // (1)
- Use the
addToGroups()method to add the user to one or more groups. Specify the GUID of each group you want to make the user a member of. Because this operation will persist the user in Atlan, you must provide it anAtlanClientthrough which to connect to the tenant.
from pyatlan.client.atlan import AtlanClient
client = AtlanClient()
client.user.add_to_groups( # (1)
guid="da213751-95de-4f96-8bee-a2c73e2ef8c8", # (2)
group_ids=["e79cb8eb-2bb6-4821-914c-f8dfd21fedc7"] # (3)
)
- Use the
user.add_to_groups()method to add the user to one or more groups. - Specify the GUID of the user you want to add to one or more groups.
- Specify the GUID of each group you want to make the user a member of.
user.addToGroups(client, listOf("e79cb8eb-2bb6-4821-914c-f8dfd21fedc7")) // (1)
- Use the
addToGroups()method to add the user to one or more groups. Specify the GUID of each group you want to make the user a member of. Because this operation will persist the user in Atlan, you must provide it anAtlanClientthrough which to connect to the tenant.
ctx.UserClient.AddUserToGroups( // (1)
"b060a754-4d16-4e13-b5a8-ba42f10aee39", // (2)
[]string{"a99f50bc-46bf-4d08-a987-3411ef5cfc33"}, // (3)
)
- Use the
UserClient.AddUserToGroups()method to add the user to one or more groups. - Specify the GUID of the user you want to add to one or more groups.
- Specify the GUID of each group you want to make the user a member of.
{
"groups": [ // (1)
"e79cb8eb-2bb6-4821-914c-f8dfd21fedc7" // (2)
]
}
- You must provide the list of groups to remove the user from in a
groupsarray. - Specify each group by its unique ID (GUID).
Change role of user
Once you have the update object, to change the role of a user:
- Java
- Python
- Kotlin
- Go
- Raw REST API
user.changeRole(client, client.getRoleCache().getIdForName("$guest")); // (1)
-
Use the
changeRole()method to change the role of a user. Because this operation will persist the user in Atlan, you must provide it anAtlanClientthrough which to connect to the tenant.Use theRoleCacheto find the right GUID
The changeRole() method requires the GUID of the role you want to move the user to. In order to find that GUID, you can use the RoleCache.getIdForName() and provide the name of the role.
:::
from pyatlan.client.atlan import AtlanClient
client = AtlanClient()
client.user.change_role( # (1)
guid="da213751-95de-4f96-8bee-a2c73e2ef8c8", # (2)
role_id=client.role_cache.get_id_for_name("$guest") # (3)
)
-
Use the
user.change_role()method to change the role of a user. -
Specify the GUID of the user whose role you want to change.
-
Specify the GUID of the role you want to change the user to.
Use theRoleCacheto find the right GUID
The user.change_role() method requires the GUID of the role you want to move the user to. In order to find that GUID, you can use the RoleCache.get_id_for_name() and provide the name of the role.
:::
user.changeRole(client, client.roleCache.getIdForName("\$guest")) // (1)
-
Use the
changeRole()method to change the role of a user. Because this operation will persist the user in Atlan, you must provide it anAtlanClientthrough which to connect to the tenant.Use theRoleCacheto find the right GUID
The changeRole() method requires the GUID of the role you want to move the user to. In order to find that GUID, you can use the RoleCache.getIdForName() and provide the name of the role.
:::
roleID, atlanErr := assets.GetRoleIDForRoleName("$guest")
ctx.UserClient.ChangeUserRole( // (1)
"b060a754-4d16-4e13-b5a8-ba42f10aee39", // (2)
roleID, // (3)
)
-
Use the
UserClient.ChangeUserRole()method to change the role of a user. -
Specify the GUID of the user whose role you want to change.
-
Specify the GUID of the role you want to change the user to.
Use theRoleCacheto find the right GUID
The UserClient.ChangeUserRole() method requires the GUID of the role you want to move the user to. In order to find that GUID, you can use the assets.GetRoleIDForRoleName() and provide the name of the role.
:::
{
"roleId": "0d1c39de-7323-4490-98d9-43240307eea7" // (1)
}
-
You must provide the unique ID (GUID) of the new role for the user.
You probably need to look this up first
When using the raw API, you will need to lookup the role GUID yourself. You can GET /api/service/roles, and the GUID will be the id field in the response for each role.
:::
Deactivate user
You can only deactivate users as an Admin user (via the UI), API tokens don't have access to deactivate users.
Reactivate user
You can only reactivate users as an Admin user (via the UI), API tokens don't have access to reactivate users.