Finding Users
Problem
You want to find users.
Solution
Use the users.find
method to find users.
from posit import connect
= connect.Client()
client = client.users.find() users
>>> pl.DataFrame(users)
1, 11)
shape: (
┌─────────────────────────────────┬──────────┬─────────────────┬────────────┬───┬──────────────────────┬──────────────────────┬───────────┬────────┐
│ guid ┆ username ┆ email ┆ first_name ┆ … ┆ updated_time ┆ active_time ┆ confirmed ┆ locked │--- ┆ --- ┆ --- ┆ --- ┆ ┆ --- ┆ --- ┆ --- ┆ --- │
│ str ┆ str ┆ str ┆ str ┆ ┆ str ┆ str ┆ bool ┆ bool │
│
╞═════════════════════════════════╪══════════╪═════════════════╪════════════╪═══╪══════════════════════╪══════════════════════╪═══════════╪════════╡-15d0-4343-b3c8-18755c… ┆ admin ┆ admin@posit.co ┆ John ┆ … ┆ 2018-07-10T21:26:57Z ┆ 2018-07-17T15:18:26Z ┆ true ┆ false │
│ c6440668-274f-4981-a6d3-677cc3… ┆ hadley ┆ hadley@posit.co ┆ Hadley ┆ … ┆ 2024-06-18T13:25:27Z ┆ 2024-06-18T13:25:27Z ┆ true ┆ false │
│ afeb15e7 └─────────────────────────────────┴──────────┴─────────────────┴────────────┴───┴──────────────────────┴──────────────────────┴───────────┴────────┘
library(connectapi)
<- connect()
client
<- get_users(client) users
> users
1,]
users[# A tibble: 2 × 11
email username first_name last_name user_role created_time<chr> <chr> <chr> <chr> <chr> <dttm>
1 admin@rstudio.com admin John Admin admin 2018-07-10 04:52:04
2 hadley@posit.co hadley Hadley Wickham publisher 2015-05-20 19:44:37
# ℹ 5 more variables: updated_time <dttm>, active_time <dttm>, confirmed <lgl>,
# locked
Discussion
These methods provide an effective way to search for users when you do not know the users unique identifier (guid).
There are additional parameters that you can use to filter the resulting users set.
You can use the prefix
parameter to find users by username, first name, or last name.
= "h"
PREFIX
=PREFIX) client.users.find(prefix
= 'h'
PREFIX
get_users(client, prefix = PREFIX)