Skip to content

Commit fb2178f

Browse files
committed
Add links to API
1 parent be8b666 commit fb2178f

File tree

2 files changed

+86
-2
lines changed

2 files changed

+86
-2
lines changed

src/posit/connect/groups.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,10 @@ def add(self, *args: User, user_guid: Optional[str] = None) -> None:
108108
# Add a user to the group by GUID
109109
group.members.add(user_guid="USER_GUID_HERE")
110110
```
111+
112+
See Also
113+
--------
114+
* https://docs.posit.co/connect/api/#post-/v1/groups/-group_guid-/members
111115
"""
112116
if len(args) > 0:
113117
from .users import User
@@ -168,6 +172,9 @@ def delete(self, *args: User, user_guid: Optional[str] = None) -> None:
168172
group.members.delete(user_guid="USER_GUID_HERE")
169173
```
170174
175+
See Also
176+
--------
177+
* https://docs.posit.co/connect/api/#delete-/v1/groups/-group_guid-/members/-user_guid-
171178
"""
172179
if len(args) > 0:
173180
from .users import User
@@ -212,6 +219,10 @@ def find(self) -> list[User]:
212219
# Find all users in the group
213220
group_users = group.members.find()
214221
```
222+
223+
See Also
224+
--------
225+
* https://docs.posit.co/connect/api/#get-/v1/groups/-group_guid-/members
215226
"""
216227
# Avoid circular import
217228
from .users import User
@@ -244,6 +255,10 @@ def count(self) -> int:
244255
# Get count of group members
245256
group_user_count = group.members.count()
246257
```
258+
259+
See Also
260+
--------
261+
* https://docs.posit.co/connect/api/#get-/v1/groups/-group_guid-/members
247262
"""
248263
path = f"v1/groups/{self._group_guid}/members"
249264
url = self._ctx.url + path
@@ -271,6 +286,10 @@ def create(self, *, name: str, unique_id: str | None) -> Group:
271286
Returns
272287
-------
273288
Group
289+
290+
See Also
291+
--------
292+
* https://docs.posit.co/connect/api/#post-/v1/groups
274293
"""
275294

276295
@overload
@@ -320,6 +339,10 @@ def find(self, **kwargs):
320339
Returns
321340
-------
322341
List[Group]
342+
343+
See Also
344+
--------
345+
* https://docs.posit.co/connect/api/#get-/v1/groups
323346
"""
324347
path = "v1/groups"
325348
url = self._ctx.url + path
@@ -354,6 +377,10 @@ def find_one(self, **kwargs) -> Group | None:
354377
Returns
355378
-------
356379
Group | None
380+
381+
See Also
382+
--------
383+
* https://docs.posit.co/connect/api/#get-/v1/groups
357384
"""
358385
path = "v1/groups"
359386
url = self._ctx.url + path
@@ -379,6 +406,10 @@ def get(self, guid: str) -> Group:
379406
Returns
380407
-------
381408
Group
409+
410+
See Also
411+
--------
412+
* https://docs.posit.co/connect/api/#get-/v1/groups
382413
"""
383414
url = self._ctx.url + f"v1/groups/{guid}"
384415
response = self._ctx.session.get(url)
@@ -393,6 +424,10 @@ def count(self) -> int:
393424
Returns
394425
-------
395426
int
427+
428+
See Also
429+
--------
430+
* https://docs.posit.co/connect/api/#get-/v1/groups
396431
"""
397432
path = "v1/groups"
398433
url = self._ctx.url + path

src/posit/connect/users.py

Lines changed: 51 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ def lock(self, *, force: bool = False):
5050
Attempt to lock your own account (will raise `RuntimeError` unless `force` is set to `True`):
5151
5252
>>> user.lock(force=True)
53+
54+
See Also
55+
--------
56+
* https://docs.posit.co/connect/api/#post-/v1/users/-guid-/lock
5357
"""
5458
_me = me.get(self._ctx)
5559
if _me["guid"] == self["guid"] and not force:
@@ -76,6 +80,10 @@ def unlock(self):
7680
Unlock a user's account:
7781
7882
>>> user.unlock()
83+
84+
See Also
85+
--------
86+
* https://docs.posit.co/connect/api/#post-/v1/users/-guid-/lock
7987
"""
8088
url = self._ctx.url + f"v1/users/{self['guid']}/lock"
8189
body = {"locked": False}
@@ -124,6 +132,10 @@ def update(
124132
Update the user's first and last name:
125133
126134
>>> user.update(first_name="Jane", last_name="Smith")
135+
136+
See Also
137+
--------
138+
* https://docs.posit.co/connect/api/#put-/v1/users/-guid-
127139
"""
128140
url = self._ctx.url + f"v1/users/{self['guid']}"
129141
response = self._ctx.session.put(url, json=kwargs)
@@ -204,6 +216,10 @@ def add(
204216
# Add the user to a group by GUID
205217
user.groups.add(group_guid="GROUP_GUID_HERE")
206218
```
219+
220+
See Also
221+
--------
222+
* https://docs.posit.co/connect/api/#post-/v1/groups/-group_guid-/members
207223
"""
208224
if len(args) > 0:
209225
from .groups import Group
@@ -272,6 +288,10 @@ def delete(
272288
# Remove the user from a group by GUID
273289
user.groups.delete(group_guid="GROUP_GUID_HERE")
274290
```
291+
292+
See Also
293+
--------
294+
* https://docs.posit.co/connect/api/#delete-/v1/groups/-group_guid-/members/-user_guid-
275295
"""
276296
if len(args) > 0:
277297
from .groups import Group
@@ -307,9 +327,18 @@ def find(self) -> List[Group]:
307327
308328
Examples
309329
--------
310-
Retrieve the groups to which the user belongs:
330+
```python
331+
from posit.connect import Client
332+
333+
client = Client("https://posit.example.com", "API_KEY")
311334
312-
>>> groups = user.groups()
335+
user = client.users.get("USER_GUID_HERE")
336+
groups = user.groups.find()
337+
```
338+
339+
See Also
340+
--------
341+
* https://docs.posit.co/connect/api/#get-/v1/groups/-group_guid-/members
313342
"""
314343
self_groups: list[Group] = []
315344
for group in self._ctx.client.groups.find():
@@ -396,6 +425,10 @@ def create(self, **attributes: Unpack[CreateUser]) -> User:
396425
... user_must_set_password=True,
397426
... user_role="viewer",
398427
... )
428+
429+
See Also
430+
--------
431+
* https://docs.posit.co/connect/api/#post-/v1/users
399432
"""
400433
# todo - use the 'context' module to inspect the 'authentication' object and route to POST (local) or PUT (remote).
401434
url = self._ctx.url + "v1/users"
@@ -440,6 +473,10 @@ def find(self, **conditions: Unpack[FindUser]) -> List[User]:
440473
Find all users who are locked or licensed:
441474
442475
>>> users = client.find(account_status="locked|licensed")
476+
477+
See Also
478+
--------
479+
* https://docs.posit.co/connect/api/#get-/v1/users
443480
"""
444481
url = self._ctx.url + "v1/users"
445482
paginator = Paginator(self._ctx.session, url, params={**conditions})
@@ -483,6 +520,10 @@ def find_one(self, **conditions: Unpack[FindUser]) -> User | None:
483520
Find a user who is locked or licensed:
484521
485522
>>> user = client.find_one(account_status="locked|licensed")
523+
524+
See Also
525+
--------
526+
* https://docs.posit.co/connect/api/#get-/v1/users
486527
"""
487528
url = self._ctx.url + "v1/users"
488529
paginator = Paginator(self._ctx.session, url, params={**conditions})
@@ -513,6 +554,10 @@ def get(self, uid: str) -> User:
513554
Examples
514555
--------
515556
>>> user = client.get("123e4567-e89b-12d3-a456-426614174000")
557+
558+
See Also
559+
--------
560+
* https://docs.posit.co/connect/api/#get-/v1/users
516561
"""
517562
url = self._ctx.url + f"v1/users/{uid}"
518563
response = self._ctx.session.get(url)
@@ -528,6 +573,10 @@ def count(self) -> int:
528573
Returns
529574
-------
530575
int
576+
577+
See Also
578+
--------
579+
* https://docs.posit.co/connect/api/#get-/v1/users
531580
"""
532581
url = self._ctx.url + "v1/users"
533582
response = self._ctx.session.get(url, params={"page_size": 1})

0 commit comments

Comments
 (0)