Skip to content

Commit 110eae6

Browse files
committed
Add Examples
1 parent e5cd39c commit 110eae6

File tree

1 file changed

+40
-9
lines changed

1 file changed

+40
-9
lines changed

src/posit/connect/tags.py

Lines changed: 40 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -558,8 +558,8 @@ def create(self, /, **kwargs) -> Tag:
558558
559559
client = posit.connect.Client()
560560
561-
mytag = client.tags.create(name="tag_name")
562-
subtag = client.tags.create(name="subtag_name", parent=mytag)
561+
category_tag = client.tags.create(name="category_name")
562+
tag = client.tags.create(name="tag_name", parent=category_tag)
563563
```
564564
"""
565565
updated_kwargs = self._update_parent_kwargs(
@@ -585,7 +585,6 @@ def __init__(self, ctx: Context, path: str, /, *, tags_path: str, content_guid:
585585

586586
self._content_guid = content_guid
587587

588-
# TODO-barret; Example
589588
def find(self) -> list[Tag]:
590589
"""
591590
Find all tags that are associated with a single content item.
@@ -594,6 +593,18 @@ def find(self) -> list[Tag]:
594593
-------
595594
list[Tag]
596595
List of tags associated with the content item.
596+
597+
Examples
598+
--------
599+
```python
600+
import posit
601+
602+
client = posit.connect.Client()
603+
content_item = client.content.find_one()
604+
605+
# Find all tags associated with the content item
606+
content_item_tags = content_item.tags.find()
607+
```
597608
"""
598609
url = self._ctx.url + self._path
599610
response = self._ctx.session.get(url)
@@ -639,9 +650,19 @@ def add(self, tag: str | Tag) -> None:
639650
tag : str | Tag
640651
The tag id or tag object to add to the content item.
641652
642-
Returns
643-
-------
644-
None
653+
Examples
654+
--------
655+
```python
656+
import posit
657+
658+
client = posit.connect.Client()
659+
660+
content_item = client.content.find_one()
661+
tag = client.tags.find()[0]
662+
663+
# Add a tag
664+
content_item.tags.add(tag)
665+
```
645666
"""
646667
tag_id = self._to_tag_id(tag)
647668

@@ -660,9 +681,19 @@ def delete(self, tag: str | Tag) -> None:
660681
tag : str | Tag
661682
The tag id or tag object to remove from the content item.
662683
663-
Returns
664-
-------
665-
None
684+
Examples
685+
--------
686+
```python
687+
import posit
688+
689+
client = posit.connect.Client()
690+
691+
content_item = client.content.find_one()
692+
content_item_first_tag = content_item.tags.find()[0]
693+
694+
# Remove a tag
695+
content_item.tags.delete(content_item_first_tag)
696+
```
666697
"""
667698
tag_id = self._to_tag_id(tag)
668699

0 commit comments

Comments
 (0)