Skip to main content

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:

Retrieve all groups
List<AtlanGroup> groups = AtlanGroup.list(client); // (1)
for (AtlanGroup group : groups)
  1. You can retrieve all groups in Atlan using the AtlanGroup.list() method. Because this operation will retrieve information from Atlan, you must provide it an AtlanClient through which to connect to the tenant.
  2. You can then iterate through the groups to do whatever you like with them.

Retrieve group by name

To retrieve a specific group in Atlan by its name:

Retrieve group by name
List<AtlanGroup> list = AtlanGroup.get(client, "Example"); // (1)
AtlanGroup group = list.get(0); // (2)
  1. 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 an AtlanClient through 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.

Retrieve all users

To retrieve all users in Atlan:

Retrieve all users
List<AtlanUser> users = AtlanUser.list(client); // (1)
for (AtlanUser user : users)
  1. You can retrieve all users in Atlan using the AtlanUser.list() method. Because this operation will retrieve information from Atlan, you must provide it an AtlanClient through which to connect to the tenant.
  2. You can then iterate through the users to do whatever you like with them.

Retrieve user by username

To retrieve a specific user in Atlan by their username:

Retrieve user by username
AtlanUser user = AtlanUser.getByUsername(client, "jdoe"); // (1)
  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 an AtlanClient through which to connect to the tenant.

Retrieve user by email

To retrieve a specific user in Atlan by their email address:

Retrieve user by username
List<AtlanUser> users = AtlanUser.getByEmail(client, "@example.com"); // (1)
AtlanUser user = users.get(0); // (2)
  1. 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 an AtlanClient through 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.

Retrieve multiple users

By usernames

To retrieve multiple users in Atlan by their usernames:

Retrieve users by usernames
List<AtlanUser> users = client.users.getByUsernames(
List.of("john.doe", "jane.doe")
); // (1)
  1. Retrieve users with specified usernames using the users.getByUsernames() method. This method performs an exact match for the provided username in the list.

By emails

To retrieve multiple users in Atlan by their emails:

Retrieve users by emails
List<AtlanUser> users = client.users.getByEmails(
List.of("[email protected]", "[email protected]")
); // (1)
  1. Retrieve users with specified emails using the users.getByEmails() method. This method performs an exact match for the provided email in the list.

Retrieve user group membership

Retrieve groups for user

To retrieve the groups a user is a member of:

Retrieve groups for a user
GroupResponse response = user.fetchGroups(client); // (1)
for (AtlanGroup group : response)
  1. You can retrieve the groups the user is a member of using the fetchGroups() method, after you have an AtlanUser object (for example, by first retrieving it). Because this operation will retrieve information from Atlan, you must provide it an AtlanClient through which to connect to the tenant.
  2. You can then iterate through the groups the user is a member of.

Retrieve users in group

To retrieve the users that are members of a group:

Retrieve users in a group
UserResponse response = group.fetchUsers(client); // (1)
for (AtlanUser user : response)
  1. You can retrieve the users a group has as members using the fetchUsers() method, after you have an AtlanGroup object (for example, by first retrieving it). Because this operation will retrieve information from Atlan, you must provide it an AtlanClient through which to connect to the tenant.
  2. You can then iterate through the users that are members of the group.
Was this page helpful?