Viewing Group Information

Problem

You want to view group information.

Solution

Use the groups attribute. Use the prefix argument to filter based on group name.

from posit import connect

PREFIX = "data scientists"

client = connect.Client()
group = client.groups.find_one(prefix=PREFIX)
>>> import json
>>> print(json.dumps(group, indent=4))
{
    "guid": "54ed1e9d-4bee-4797-97a3-f22e990bccfe",
    "owner_guid": "6ca57cef-186f-4897-9875-d692f97edd5a"
    "name": "Data Scientists",
}

Use the get_groups() function. This returns a table that you can filter to find details about a specific group.

library(connectapi)
library(dplyr)

GROUP_NAME = "Data Scientists"

client <- connect()

all_groups <- get_groups(client)
group <- filter(groups, name == GROUP_NAME)
> group
# A tibble: 1 × 3
  guid                                 name            owner_guid                          
  <chr>                                <chr>           <chr>                               
1 54ed1e9d-4bee-4797-97a3-f22e990bccfe Data Scientists 6ca57cef-186f-4897-9875-d692f97edd5a

Discussion

The groups object contains guid, owner_guid, and name field. The guid is a globally unique identifier for the group. The owner_guid is a reference to the user that created the group. The name field is a human readable description of the group.