Skip to content
This repository has been archived by the owner on Sep 13, 2024. It is now read-only.

feat: adds finding groups #93

Merged
merged 8 commits into from
Jun 28, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions 03-groups/01-viewing-group-information/index.qmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
---
title: 3.1 Viewing Group Information
---

## Problem

You want to view group information.

## Solution

:::{.panel-tabset group="language"}

## Python

Use the `groups` attribute.

```{.python}
from posit import connect

client = connect.Client()
group = client.groups.find_one()
```

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

## R


```{.r}
# TODO
```

:::

## 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.
63 changes: 63 additions & 0 deletions 03-groups/02-finding-groups/index.qmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
---
title: 3.2 Finding Groups
---

## Problem

You want to find a subset of groups.

## Solution

:::{.panel-tabset group="language"}

## Python

Use the `groups` attribute and use the `prefix` parameter to filter groups by group name. The prefix is case insensitive (.e.g, 'PoSiT' is logically equivalent to 'pOsIt').
tdstein marked this conversation as resolved.
Show resolved Hide resolved

```{.python}
from posit import connect

client = connect.Client()
groups = client.groups.find(prefix='data')
tdstein marked this conversation as resolved.
Show resolved Hide resolved
```

The groups object is a list of groups with a name field that matches the prefix parameter. In this example, the prefix is *data*, which matches the groups name *Data Scientists* and *Data Engineers*.
tdstein marked this conversation as resolved.
Show resolved Hide resolved

```{.python}
>>> import polars as pl
>>> pl.DataFrame(groups)
shape: (2, 3)
┌─────────────────────────────────┬─────────────────────────────────┬─────────────────┐
│ guid ┆ owner_guid ┆ name │
│ --- ┆ --- ┆ --- │
│ object ┆ object ┆ str │
╞═════════════════════════════════╪═════════════════════════════════╪═════════════════╡
│ 6d77fcab-92b0-48a2-94fd-f80c6b… ┆ 867f6d6f-53b4-4ee6-8f37-37ce5d… ┆ Data Scientists │
│ 85d1ddff-bb05-4d3b-9f5b-37bb20… ┆ fd7b011b-7d07-4b92-8c7a-69279a… ┆ Data Engineers │
└─────────────────────────────────┴─────────────────────────────────┴─────────────────┘
```

## R

```{.r}
# TODO
```

:::

## Discussion

You can also use the prefix parameter to find a specific group by name if you do not know the group *guid*. Beware that multiple groups can exists with the same prefix. Please verify the group information is correct before performing additional actions.
tdstein marked this conversation as resolved.
Show resolved Hide resolved

:::{.panel-tabset group="language"}

## Python

```python
from posit import connect

client = connect.Client()
group = client.groups.find_one(prefix='Data Scientists')
tdstein marked this conversation as resolved.
Show resolved Hide resolved
```

:::
11 changes: 11 additions & 0 deletions 03-groups/index.qmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
title: Groups
---

## Introduction

Groups are a way to organize users into collections for easier management and access control. Groups can be created by administrators or synced from external identity providers like LDAP or Active Directory.
tdstein marked this conversation as resolved.
Show resolved Hide resolved

3.1 [Viewing Group Information](./01-viewing-group-information/)

3.2 [Finding Groups](./02-finding-groups/)