-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tags - Create, delete, info, find content with tag, and view content item tags #345
Labels
Comments
Proposals # Get all tags
## Return all tags
client.tags.find() -> list[Tag]
## Return all tags with name and parent
client.tags.find(name="tag_name", parent="parent_tag_guid" | parent_tag | None)
# Create Tag
mytag = client.tags.create(
name="tag_name",
parent="parent_tag_guid" | parent_tag | None
) -> Tag
# Delete Tag
mytag = client.tags.get("tag_guid")
mytag.destroy() -> None
# Find content using tags
mycontentitems = mytag.content.find() -> list[Content]
# Get content item's tags
mycontentitem: Content = mycontentitems[0]
mycontentitem.tags.find() -> list[Tag] |
Update proposals: from posit.connect import Client
from posit.connect.tags import Tag
from posit.connect.content import ContentItem
client = Client()
# Get all tags
## Return all tags
tags: list[Tag] = client.tags.find()
some_tag: Tag = tags[0]
## Return all tags with name and parent
commonnametags: list[Tag] = client.tags.find(name="tag_name")
sibling_tags: list[Tag] = client.tags.find(parent="parent_tag_guid")
sibling_tags: list[Tag] = client.tags.find(parent=some_tag)
unique_tag: Tag = client.tags.find(name="tag_name", parent=some_tag)[0]
# Create Tag
mytag: Tag = client.tags.create(name="tag_name")
mytag: Tag = client.tags.create(name="tag_name", parent="parent_tag_guid")
mytag: Tag = client.tags.create(name="tag_name", parent=some_tag)
# Remove Tag
mytag.destroy()
# Content Item
## Find content using tags
mycontentitems: list[ContentItem] = mytag.content_items.find()
some_contentitem: ContentItem = mycontentitems[0]
## Get content item's tags
tags: list[Tag] = some_contentitem.tags.find()
## Add tag to content item
some_contentitem.tags.add(mytag)
## Remove tag from content item
some_contentitem.tags.delete(mytag)
# Family Tree
## Get parent tag
parent_tag: Tag | None = mytag.parent_tag
## Find all children tags
children_tags: list[Tag] = mytag.children_tags.find()
## Find all descendant tags
descendant_tags: list[Tag] = mytag.descendant_tags.find()
## Find all unique content items for a tag and its descendant tags
content_items_list: list[ContentItem] = []
for tag in [mytag, *mytag.descendant_tags.find()]:
content_items_list.extend(tag.content_items.find())
content_items_list = list(set(content_items_list)) |
Final proposal in #346 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Currently, all recipes are done using the API. This is green field territory!
View information
Create
Delete
Find content using tag
View content item's tags
The text was updated successfully, but these errors were encountered: