Retrieving users and groups
You can retrieve users and groups through different helper methods.
Retrieve all groups
For example, to retrieve all groups in Atlan:
- Java
- Python
- Kotlin
- Go
- Raw REST API
List<AtlanGroup> groups = AtlanGroup.list(client); // (1)
for (AtlanGroup group : groups)
- You can retrieve all groups in Atlan using the
AtlanGroup.list()method. Because this operation will retrieve information from Atlan, you must provide it anAtlanClientthrough which to connect to the tenant. - You can then iterate through the groups to do whatever you like with them.
from pyatlan.client.atlan import AtlanClient
client = AtlanClient()
groups = client.group.get_all( # (1)
limit=10,
offset=1,
sort="createdAt",
columns=["roles", "path"])
for group in groups: # (2)
# Do something with the group...
-
The
get_all()method retrieves all groups defined in Atlan. Returns a GroupResponse object. Optional parameters include:- (Optional)
limit: Specifies the maximum number of results to return. Defaults to20. - (Optional)
offset: Indicates the starting point for the results when paging. Defaults to0. - (Optional)
sort: Allows sorting by a specific property, such as"createdAt". - (Optional)
columns: Restricts the fields returned for each group, providing column projection support. Example:["roles", "path"].
- (Optional)
-
This is the pattern for iterating through all results (across pages) covered in the Searching for assets portion of the SDK documentation.
val groups = AtlanGroup.list(client) // (1)
for (group in groups)
- You can retrieve all groups in Atlan using the
AtlanGroup.list()method. Because this operation will retrieve information from Atlan, you must provide it anAtlanClientthrough which to connect to the tenant. - You can then iterate through the groups to do whatever you like with them.
groups, atlanErr := ctx.GroupClient.GetAll( // (1)
10,
1,
"createdAt",
)
for _, group := range groups { // (2)
// Do Something with the group...
}
-
The
GetAll()method retrieves all groups defined in Atlan. Optional parameters include:- (Optional)
limit: Specifies the maximum number of results to return. Defaults to20. - (Optional)
offset: Indicates the starting point for the results when paging. Defaults to0. - (Optional)
sort: Allows sorting by a specific property, such as"createdAt".
- (Optional)
-
You can then iterate through the groups to do whatever you like with them.
// (1)
-
All details are in the URL itself.
Paging results
Note that you have a limit to control page size, and an offset to control where to start a page.
:::
Retrieve group by name
To retrieve a specific group in Atlan by its name:
- Java
- Python
- Kotlin
- Go
- Raw REST API
List<AtlanGroup> list = AtlanGroup.get(client, "Example"); // (1)
AtlanGroup group = list.get(0); // (2)
-
You can retrieve a specific group by its name using the
AtlanGroup.get()method. Because this operation will retrieve information from Atlan, you must provide it anAtlanClientthrough which to connect to the tenant.Still returns a list
Note that this still returns a list of groups, as it actually runs a contains search for the specified name. You could therefore use this same method to retrieve many groups that all follow the same naming convention, for example.
:::
2. If you were expecting only a single group to match, however, you can still retrieve that from the list directly, of course.
from pyatlan.client.atlan import AtlanClient
client = AtlanClient()
groups = client.group.get_by_name("Example") # (1)
group = groups.records[0] # (2)
-
You can retrieve a specific group by its name using the
group.get_by_name()method. Returns a GroupResponse object.Still returns a list
Note that this still returns a list of groups, as it actually runs a contains search for the specified name. You could therefore use this same method to retrieve many groups that all follow the same naming convention, for example.
:::
2. If you were expecting only a single group to match, however, you can still retrieve that from the list directly, of course.
val list = AtlanGroup.get(client, "Example") // (1)
val group = list[0] // (2)
-
You can retrieve a specific group by its name using the
AtlanGroup.get()method. Because this operation will retrieve information from Atlan, you must provide it anAtlanClientthrough which to connect to the tenant.Still returns a list
Note that this still returns a list of groups, as it actually runs a contains search for the specified name. You could therefore use this same method to retrieve many groups that all follow the same naming convention, for example.
:::
2. If you were expecting only a single group to match, however, you can still retrieve that from the list directly, of course.
groups, atlanErr := ctx.GroupClient.GetByName("Example", 20, 0) // (1)
group := groups[0] // (2)
-
You can retrieve a specific group by its name using the
GroupClient.GetByName()method. You can also set the limit (default is 20) and offset (default is 0).Still returns a list
Note that this still returns a list of groups, as it actually runs a contains search for the specified name. You could therefore use this same method to retrieve many groups that all follow the same naming convention, for example.
:::
2. If you were expecting only a single group to match, however, you can still retrieve that from the list directly, of course.
// (1)
-
All details are in the URL itself.
URL-encoded filter
Note that the filter is URL-encoded. Decoded it would be: {"$and":[{"alias":{"$ilike":"%Example%"}}]}
:::
Retrieve all users
To retrieve all users in Atlan:
- Java
- Python
- Kotlin
- Go
- Raw REST API
List<AtlanUser> users = AtlanUser.list(client); // (1)
for (AtlanUser user : users)
- You can retrieve all users in Atlan using the
AtlanUser.list()method. Because this operation will retrieve information from Atlan, you must provide it anAtlanClientthrough which to connect to the tenant. - You can then iterate through the users to do whatever you like with them.
from pyatlan.client.atlan import AtlanClient
client = AtlanClient()
users = client.user.get_all() # (1)
for user in users: # (2)
# Do something with the user...
- You can retrieve all users in Atlan using the
get_all()method under theuserattribute of the AtlanClient instance. Returns a UserResponse object. - This is the pattern for iterating through all results (across pages) covered in the Searching for assets portion of the SDK documentation.
val users = AtlanUser.list(client) // (1)
for (user in users)
- You can retrieve all users in Atlan using the
AtlanUser.list()method. Because this operation will retrieve information from Atlan, you must provide it anAtlanClientthrough which to connect to the tenant. - You can then iterate through the users to do whatever you like with them.
users, atlanErr := ctx.UserClient.GetAll(20, 0, "") // (1)
for _, user := range users { // (2)
// Do something with the user...
}
- You can retrieve all users in Atlan using the
GetAll()method under theuserattribute of the AtlanClient instance. You can also set the limit (default is 20), offset (default is 0) and sort (default is by username). - You can then iterate through the users to do whatever you like with them.
// (1)
-
All details are in the URL itself.
Paging results
Note that you have a limit to control page size, and an offset to control where to start a page.
:::
Retrieve user by username
To retrieve a specific user in Atlan by their username:
- Java
- Python
- Kotlin
- Go
- Raw REST API
AtlanUser user = AtlanUser.getByUsername(client, "jdoe"); // (1)
- You can retrieve a specific user by their username using the
AtlanUser.getByUsername()method. This runs an exact match for the provided username, so only returns a single user (if found). Because this operation will retrieve information from Atlan, you must provide it anAtlanClientthrough which to connect to the tenant.
from pyatlan.client.atlan import AtlanClient
client = AtlanClient()
user = client.user.get_by_username("jdoe") # (1)
- You can retrieve a specific user by their username using the
user.get_by_username()method. This runs an exact match for the provided username, so only returns a single user (if found).
val user = AtlanUser.getByUsername(client, "jdoe") // (1)
- You can retrieve a specific user by their username using the
AtlanUser.getByUsername()method. This runs an exact match for the provided username, so only returns a single user (if found). Because this operation will retrieve information from Atlan, you must provide it anAtlanClientthrough which to connect to the tenant.
users, atlanErr := ctx.UserClient.GetByUsername("jdoe") // (1)
- You can retrieve a specific user by their username using the
UserClient.GetByUsername()method. This runs an exact match for the provided username, so only returns a single user (if found).
// (1)
-
All details are in the URL itself.
URL-encoded filter
Note that the filter is URL-encoded. Decoded it would be: {"username":"jdoe"}
:::
Retrieve user by email
To retrieve a specific user in Atlan by their email address:
- Java
- Python
- Kotlin
- Go
- Raw REST API
List<AtlanUser> users = AtlanUser.getByEmail(client, "@example.com"); // (1)
AtlanUser user = users.get(0); // (2)
-
You can retrieve a specific user by their email address using the
AtlanUser.getByEmail()method. Because this operation will retrieve information from Atlan, you must provide it anAtlanClientthrough which to connect to the tenant.Still returns a list
Note that this still returns a list of users, as it actually runs a contains search for the specified email address. You could therefore use this same method to retrieve many users that all have the same email domain, for example.
:::
2. If you were expecting only a single user to match, however, you can still retrieve that from the list directly, of course.
from pyatlan.client.atlan import AtlanClient
client = AtlanClient()
users = client.user.get_by_email("@example.com") # (1)
user = users.records[0] # (2)
-
You can retrieve a specific user by their email address using the
user.get_by_email()method. Returns a UserResponse object.Still returns a list
Note that this still returns a list of users, as it actually runs a contains search for the specified email address. You could therefore use this same method to retrieve many users that all have the same email domain, for example.
:::
2. If you were expecting only a single user to match, however, you can still retrieve that from the list directly, of course.
val users = AtlanUser.getByEmail(client, "@example.com") // (1)
val user = users[0] // (2)
-
You can retrieve a specific user by their email address using the
AtlanUser.getByEmail()method. Because this operation will retrieve information from Atlan, you must provide it anAtlanClientthrough which to connect to the tenant.Still returns a list
Note that this still returns a list of users, as it actually runs a contains search for the specified email address. You could therefore use this same method to retrieve many users that all have the same email domain, for example.
:::
2. If you were expecting only a single user to match, however, you can still retrieve that from the list directly, of course.
users, atlanErr := ctx.UserClient.GetByEmail("@example.com", 20, 0) // (1)
user := users[0] // (2)
-
You can retrieve a specific user by their email address using the
UserClient.GetByEmail()method.Still returns a list
Note that this still returns a list of users, as it actually runs a contains search for the specified email address. You could therefore use this same method to retrieve many users that all have the same email domain, for example.
:::
2. If you were expecting only a single user to match, however, you can still retrieve that from the list directly, of course.
// (1)
-
All details are in the URL itself.
URL-encoded filter
Note that the filter is URL-encoded. Decoded it would be: {"email":{"$ilike":"%@example.com%"}}
:::
Retrieve multiple users
By usernames
To retrieve multiple users in Atlan by their usernames:
- Java
- Python
- Kotlin
- Go
- Raw REST API
List<AtlanUser> users = client.users.getByUsernames(
List.of("john.doe", "jane.doe")
); // (1)
- Retrieve users with specified usernames using the
users.getByUsernames()method. This method performs an exact match for the provided username in the list.
from pyatlan.client.atlan import AtlanClient
client = AtlanClient()
users = client.user.get_by_usernames(['john.doe', 'jane.doe']) # (1)
for user in users: # (2)
# Do something with the user...
- Retrieve users with specified usernames using the
user.get_by_usernames()method. This method performs an exact match for the provided username in the list. Returns a UserResponse object. - This is the pattern for iterating through all results (across pages) covered in the Searching for assets portion of the SDK documentation.
val users = client.users.getByUsernames(
listOf("john.doe", "jane.doe")
); // (1)
- Retrieve users with specified usernames using the
users.getByUsernames()method. This method performs an exact match for the provided username in the list.
users, atlanErr := ctx.UserClient.GetByUsernames([]string{"john.doe", "jane.doe"}, 20, 0) // (1)
- Retrieve users with specified usernames using the
UserClient.GetByUsernames()method. This method performs an exact match for the provided username in the list.
// (1)
-
All details are in the URL itself.
URL-encoded filter
Note that the filter is URL-encoded. Decoded it
would be: {"username":{"$in":["john.doe","jane.doe"]}}
:::
By emails
To retrieve multiple users in Atlan by their emails:
- Java
- Python
- Kotlin
- Go
- Raw REST API
List<AtlanUser> users = client.users.getByEmails(
List.of("[email protected]", "[email protected]")
); // (1)
- Retrieve users with specified emails using the
users.getByEmails()method. This method performs an exact match for the provided email in the list.
from pyatlan.client.atlan import AtlanClient
client = AtlanClient()
users = client.user.get_by_emails(['[email protected]', '[email protected]']) # (1)
for user in users: # (2)
# Do something with the user...
- Retrieve users with specified emails using the
user.get_by_emails()method. This method performs an exact match for the provided email in the list. Returns a UserResponse object. - This is the pattern for iterating through all results (across pages) covered in the Searching for assets portion of the SDK documentation.
val users = client.users.getByEmails(
listOf("[email protected]", "[email protected]")
); // (1)
- Retrieve users with specified emails using the
users.getByEmails()method. This method performs an exact match for the provided email in the list.
users, atlanErr := ctx.UserClient.GetByEmails([]string{"[email protected]", "[email protected]"}, 20, 0) // (1)
- Retrieve users with specified emails using the
UserClient.GetByEmails()method. This method performs an exact match for the provided email in the list.
// (1)
-
All details are in the URL itself.
URL-encoded filter
Note that the filter is URL-encoded. Decoded it
would be: {"email":{"$in":["[email protected]","[email protected]"]}}
:::
Retrieve user group membership
Retrieve groups for user
To retrieve the groups a user is a member of:
- Java
- Python
- Kotlin
- Go
- Raw REST API
GroupResponse response = user.fetchGroups(client); // (1)
for (AtlanGroup group : response)
- You can retrieve the groups the user is a member of using the
fetchGroups()method, after you have anAtlanUserobject (for example, by first retrieving it). Because this operation will retrieve information from Atlan, you must provide it anAtlanClientthrough which to connect to the tenant. - You can then iterate through the groups the user is a member of.
from pyatlan.client.atlan import AtlanClient
client = AtlanClient()
response = client.user.get_groups(user.id) # (1)
for group in response: # (2)
# Do something with each group...
- You can retrieve the groups the user is a member of using the
user.get_groups()method, by providing the GUID of the user. - You can then iterate through the groups the user is a member of.
val response = user.fetchGroups(client) // (1)
for (group in response)
- You can retrieve the groups the user is a member of using the
fetchGroups()method, after you have anAtlanUserobject (for example, by first retrieving it). Because this operation will retrieve information from Atlan, you must provide it anAtlanClientthrough which to connect to the tenant. - You can then iterate through the groups the user is a member of.
response, atlanErr := ctx.UserClient.GetGroups(user.ID, nil) // (1)
for _, group := range response { // (2)
// Do something with each group...
}
- You can retrieve the groups the user is a member of using the
UserClient.GetGroups()method, by providing the GUID of the user. - You can then iterate through the groups the user is a member of.
// (1)
-
All details are in the URL itself.
User ID in the URL
Note that you must provide the unique ID (GUID) of the user to retrieve its associated groups. :::
Retrieve users in group
To retrieve the users that are members of a group:
- Java
- Python
- Kotlin
- Go
- Raw REST API
UserResponse response = group.fetchUsers(client); // (1)
for (AtlanUser user : response)
- You can retrieve the users a group has as members using the
fetchUsers()method, after you have anAtlanGroupobject (for example, by first retrieving it). Because this operation will retrieve information from Atlan, you must provide it anAtlanClientthrough which to connect to the tenant. - You can then iterate through the users that are members of the group.
from pyatlan.client.atlan import AtlanClient
client = AtlanClient()
response = client.group.get_members(group.id) # (1)
for user in response: # (2)
# Do something with each user...
- You can retrieve the users a group has as members using the
group.get_members()method, by providing the GUID of the group. - You can then iterate through the users that are members of the group.
val response = group.fetchUsers(client) // (1)
for (user in response)
- You can retrieve the users a group has as members using the
fetchUsers()method, after you have anAtlanGroupobject (for example, by first retrieving it). Because this operation will retrieve information from Atlan, you must provide it anAtlanClientthrough which to connect to the tenant. - You can then iterate through the users that are members of the group.
response, atlanErr := ctx.GroupClient.GetMembers(group.ID, nil)
for _, user := range response {
// Do something with each user
}
- You can retrieve the users a group has as members using the
GroupClient.GetMembers()method, by providing the GUID of the group. - You can then iterate through the users that are members of the group.
// (1)
-
All details are in the URL itself.
Group ID in the URL
Note that you must provide the unique ID (GUID) of the group to retrieve its associated members. :::