Skip to content

Retrieving users and groups

You can retrieve users and groups through different helper methods.

Retrieve all groups

2.6.2 1.0.0

For example, to retrieve all groups in Atlan:

Retrieve all groups
1
2
3
4
List<AtlanGroup> groups = AtlanGroup.list(); // (1)
for (AtlanGroup group : groups) { // (2)
    // Do something with the group...
}
  1. You can retrieve all groups in Atlan using the AtlanGroup.list() method.
  2. You can then iterate through the groups to do whatever you like with them.
Retrieve all groups
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
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...
  1. The get_all() method retrieves all groups defined in Atlan. Optional parameters include:

    • (Optional) limit: Specifies the maximum number of results to return. Defaults to 20.
    • (Optional) offset: Indicates the starting point for the results when paging. Defaults to 0.
    • (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"].
  2. You can then iterate through the groups to do whatever you like with them.

Retrieve all groups
1
2
3
4
val groups = AtlanGroup.list() // (1)
for (group in groups) { // (2)
    // Do something with the group...
}
  1. You can retrieve all groups in Atlan using the AtlanGroup.list() method.
  2. You can then iterate through the groups to do whatever you like with them.
GET /api/service/v2/groups?sort=createdAt&imit=10&offset=0&columns=path&columns=roles
1
// (1)
  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

1.3.3 1.0.0

To retrieve a specific group in Atlan by its name:

Retrieve group by name
1
2
List<AtlanGroup> list = AtlanGroup.get("Example"); // (1)
AtlanGroup group = list.get(0); // (2)
  1. You can retrieve a specific group by its name using the AtlanGroup.get() method.

    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 group by name
1
2
3
4
5
from pyatlan.client.atlan import AtlanClient

client = AtlanClient()
groups = client.group.get_by_name("Example") # (1)
group = groups[0] # (2)
  1. You can retrieve a specific group by its name using the group.get_by_name() method.

    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 group by name
1
2
val list = AtlanGroup.get("Example") // (1)
val group = list[0] // (2)
  1. You can retrieve a specific group by its name using the AtlanGroup.get() method.

    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.

GET /api/service/groups?filter=%7B%22%24and%22%3A[%7B%22alias%22%3A%7B%22%24ilike%22%3A%22%25Example%25%22%7D%7D]%7D
1
// (1)
  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

1.3.3 1.0.0

To retrieve all users in Atlan:

Retrieve all users
1
2
3
4
List<AtlanUser> users = AtlanUser.list(); // (1)
for (AtlanUser user : users) { // (2)
    // Do something with the user...
}
  1. You can retrieve all users in Atlan using the AtlanUser.list() method.
  2. You can then iterate through the users to do whatever you like with them.
Retrieve all users
1
2
3
4
5
6
from pyatlan.client.atlan import AtlanClient

client = AtlanClient()
users = client.user.get_all() # (1)
for user in users: # (2)
    # Do something with the user...
  1. You can retrieve all users in Atlan using the get_all() method under the user attribute of the AtlanClient instance.
  2. You can then iterate through the users to do whatever you like with them.
Retrieve all users
1
2
3
4
val users = AtlanUser.list() // (1)
for (user in users) { // (2)
    // Do something with the user...
}
  1. You can retrieve all users in Atlan using the AtlanUser.list() method.
  2. You can then iterate through the users to do whatever you like with them.
GET /api/service/users?sort=username&limit=100&offset=0
1
// (1)
  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

1.3.3 1.0.0

To retrieve a specific user in Atlan by their username:

Retrieve user by username
1
AtlanUser user = AtlanUser.getByUsername("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).
Retrieve user by username
1
2
3
4
from pyatlan.client.atlan import AtlanClient

client = AtlanClient()
user = client.user.get_by_username("jdoe") # (1)
  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).
Retrieve user by username
1
val user = AtlanUser.getByUsername("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).
GET /api/service/users?filter=%7B%22username%22%3A%22jdoe%22%7D
1
// (1)
  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

1.3.3 1.0.0

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

Retrieve user by username
1
2
List<AtlanUser> users = AtlanUser.getByEmail("@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.

    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 user by username
1
2
3
4
5
from pyatlan.client.atlan import AtlanClient

client = AtlanClient()
users = client.user.get_by_email("@example.com") # (1)
user = users[0] # (2)
  1. You can retrieve a specific user by their email address using the user.get_by_email() 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.

Retrieve user by username
1
2
val users = AtlanUser.getByEmail("@example.com") // (1)
val user = users[0] // (2)
  1. You can retrieve a specific user by their email address using the AtlanUser.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.

GET /api/service/users?filter=%7B%22email%22%3A%7B%22%24ilike%22%3A%22%25%40example.com%25%22%7D%7D
1
// (1)
  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

2.0.4 1.10.14

By usernames

To retrieve multiple users in Atlan by their usernames:

Retrieve users by usernames
1
2
3
4
AtlanClient client = Atlan.getDefaultClient();
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.
Retrieve users by usernames
1
2
3
4
from pyatlan.client.atlan import AtlanClient

client = AtlanClient()
users = client.user.get_by_usernames(['john.doe', 'jane.doe']) # (1)
  1. 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.
Retrieve users by usernames
1
2
3
4
val client = Atlan.getDefaultClient();
val users = client.users.getByUsernames(
        listOf("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.
GET /api/service/users?filter={%22username%22:{%22$in%22:[%22john.doe%22,%22jane.doe%22]}}
1
// (1)
  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:

Retrieve users by emails
1
2
3
4
AtlanClient client = Atlan.getDefaultClient();
List<AtlanUser> users = client.users.getByEmails(
        List.of("john@atlan.com", "jane@atlan.com")
    ); // (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 users by emails
1
2
3
4
from pyatlan.client.atlan import AtlanClient

client = AtlanClient()
users = client.user.get_by_emails(['john@atlan.com', 'jane@atlan.com']) # (1)
  1. 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.
Retrieve users by emails
1
2
3
4
val client = Atlan.getDefaultClient();
val users = client.users.getByEmails(
        listOf("john@atlan.com", "jane@atlan.com")
    ); // (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.
GET /api/service/users?filter={%22email%22:{%22$in%22:[%22john@atlan.com%22,%20%22jane@atlan.com%22]}}
1
// (1)
  1. All details are in the URL itself.

    URL-encoded filter

    Note that the filter is URL-encoded. Decoded it would be: {"email":{"$in":["john@atlan.com","jane@atlan.com"]}}

Retrieve user group membership

Retrieve groups for a user

2.0.1 1.10.6

To retrieve the groups a user is a member of:

Retrieve groups for a user
3
4
5
6
GroupResponse response = user.fetchGroups(); // (1)
for (AtlanGroup group : response) { // (2)
    // Do something with each group...
}
  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).
  2. You can then iterate through the groups the user is a member of.
Retrieve groups for a user
 5
 6
 7
 8
 9
10
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...
  1. You can retrieve the groups the user is a member of using the user.get_groups() method, by providing the GUID of the user.
  2. You can then iterate through the groups the user is a member of.
Retrieve groups for a user
3
4
5
6
val response = user.fetchGroups() // (1)
for (group in response) { // (2)
    // Do something with each group...
}
  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).
  2. You can then iterate through the groups the user is a member of.
GET /api/service/users/f06122f4-7279-4e42-b9e0-46f9b470e659/groups
1
// (1)
  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 a group

2.0.1 1.10.6

To retrieve the users that are members of a group:

Retrieve users in a group
3
4
5
6
UserResponse response = group.fetchUsers(); // (1)
for (AtlanUser user : response) { // (2)
    // Do something with each user...
}
  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).
  2. You can then iterate through the users that are members of the group.
Retrieve users in a group
 5
 6
 7
 8
 9
10
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...
  1. You can retrieve the users a group has as members using the group.get_members() method, by providing the GUID of the group.
  2. You can then iterate through the users that are members of the group.
Retrieve users in a group
3
4
5
6
val response = group.fetchUsers() // (1)
for (user in response) { // (2)
    // Do something with each user...
}
  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).
  2. You can then iterate through the users that are members of the group.
GET /api/service/groups/e79cb8eb-2bb6-4821-914c-f8dfd21fedc7/members
1
// (1)
  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.