connect.tags

connect.tags

Tag resources.

Classes

Name Description
ChildTags
ContentItemTags Content item tags resource.
DescendantTags
Tag Tag resource.
TagContentItems
Tags Content item tags resource.

ChildTags

connect.tags.ChildTags(self, ctx, path, /, *, parent_tag)

Methods

Name Description
find Find all child tags that are direct children of a single tag.
find
connect.tags.ChildTags.find()

Find all child tags that are direct children of a single tag.

Returns
Name Type Description
list[Tag] List of child tags. (Does not include the parent tag.)
Examples
import posit

client = posit.connect.Client()
mytag = client.tags.get("TAG_ID_HERE")

child_tags = mytag.child_tags.find()

ContentItemTags

connect.tags.ContentItemTags(self, ctx, path, /, *, tags_path, content_guid)

Content item tags resource.

Methods

Name Description
add Add the specified tag to an individual content item.
delete Remove the specified tag from an individual content item.
find Find all tags that are associated with a single content item.
add
connect.tags.ContentItemTags.add(tag)

Add the specified tag to an individual content item.

When adding a tag, all tags above the specified tag in the tag tree are also added to the content item.

Parameters
Name Type Description Default
tag str | Tag The tag id or tag object to add to the content item. required
Examples
import posit

client = posit.connect.Client()

content_item = client.content.find_one()
tag = client.tags.find()[0]

# Add a tag
content_item.tags.add(tag)
delete
connect.tags.ContentItemTags.delete(tag)

Remove the specified tag from an individual content item.

When removing a tag, all tags above the specified tag in the tag tree are also removed from the content item.

Parameters
Name Type Description Default
tag str | Tag The tag id or tag object to remove from the content item. required
Examples
import posit

client = posit.connect.Client()

content_item = client.content.find_one()
content_item_first_tag = content_item.tags.find()[0]

# Remove a tag
content_item.tags.delete(content_item_first_tag)
find
connect.tags.ContentItemTags.find()

Find all tags that are associated with a single content item.

Returns
Name Type Description
list[Tag] List of tags associated with the content item.
Examples
import posit

client = posit.connect.Client()
content_item = client.content.find_one()

# Find all tags associated with the content item
content_item_tags = content_item.tags.find()

DescendantTags

connect.tags.DescendantTags(self, ctx, /, *, parent_tag)

Methods

Name Description
find Find all child tags that descend from a single tag.
find
connect.tags.DescendantTags.find()

Find all child tags that descend from a single tag.

Returns
Name Type Description
list[Tag] List of tags that descend from the parent tag.

Tag

connect.tags.Tag(self, ctx, path, /, **kwargs)

Tag resource.

Attributes

Name Description
child_tags Find all child tags that are direct children of this tag.
content_items Find all content items that are tagged with this tag.
descendant_tags Find all tags that descend from this tag.
parent_tag

Methods

Name Description
destroy Removes the tag.
update Update the tag.
destroy
connect.tags.Tag.destroy()

Removes the tag.

Deletes a tag, including all descendants in its own tag hierarchy.

Examples
import posit

client = posit.connect.Client()
first_tag = client.tags.find()[0]

# Remove the tag
first_tag.destroy()
update
connect.tags.Tag.update(**kwargs)

Update the tag.

Parameters
Name Type Description Default
name str The name of the tag. required
parent Tag | None The parent Tag object. If there is no parent, the tag is a top-level tag. To remove the parent tag, set the value to None. Only one of parent or parent_id can be provided. required
parent_id str | None The identifier for the parent tag. If there is no parent, the tag is a top-level tag. To remove the parent tag, set the value to None. required
Returns
Name Type Description
Tag Updated tag object.
Examples
import posit

client = posit.connect.Client()
last_tag = client.tags.find()[-1]

# Update the tag's name
updated_tag = last_tag.update(name="new_name")

# Remove the tag's parent
updated_tag = last_tag.update(parent=None)
updated_tag = last_tag.update(parent_id=None)

# Update the tag's parent
parent_tag = client.tags.find()[0]
updated_tag = last_tag.update(parent=parent_tag)
updated_tag = last_tag.update(parent_id=parent_tag["id"])

TagContentItems

connect.tags.TagContentItems(self, ctx, path)

Methods

Name Description
find Find all content items that are tagged with this tag.
find
connect.tags.TagContentItems.find()

Find all content items that are tagged with this tag.

Returns
Name Type Description
list[ContentItem] List of content items that are tagged with this tag.
Examples
import posit

client = posit.connect.Client()
first_tag = client.tags.find()[0]

first_tag_content_items = first_tag.content_items.find()

Tags

connect.tags.Tags(self, ctx, path)

Content item tags resource.

Methods

Name Description
create Create a tag.
find Find tags by name and/or parent.
get Get a single tag by its identifier.
create
connect.tags.Tags.create(**kwargs)

Create a tag.

Parameters
Name Type Description Default
name str The name of the tag. required
parent Tag The parent Tag object. If there is no parent, the tag is a top-level tag. Only one of parent or parent_id can be provided. required
parent_id str The identifier for the parent tag. If there is no parent, the tag is a top-level tag. required
Returns
Name Type Description
Tag Newly created tag object.
Examples
import posit

client = posit.connect.Client()

category_tag = client.tags.create(name="category_name")
tag = client.tags.create(name="tag_name", parent=category_tag)
find
connect.tags.Tags.find(**kwargs)

Find tags by name and/or parent.

Note: tag names are only unique within the scope of a parent, which means that it is possible to have multiple results when querying by name; However, querying by both name and parent ensures a single result.

Parameters
Name Type Description Default
name str The name of the tag. required
parent Tag The parent Tag object. If there is no parent, the tag is a top-level tag. Only one of parent or parent_id can be provided. required
parent_id str The identifier for the parent tag. If there is no parent, the tag is a top-level tag. required
Returns
Name Type Description
list[Tag] List of tags that match the query. Defaults to all Tags.
Examples
import posit

client = posit.connect.Client()

# Find all tags
all_tags = client.tags.find()

# Find all tags with the name
mytag = client.tags.find(name="tag_name")

# Find all tags with the name and parent
subtags = client.tags.find(name="sub_name", parent=mytag)
subtags = client.tags.find(name="sub_name", parent=mytag["id"])
get
connect.tags.Tags.get(tag_id)

Get a single tag by its identifier.

Parameters
Name Type Description Default
tag_id str The identifier for the tag. required
Returns
Name Type Description
Tag The tag object.
Examples
import posit

client = posit.connect.Client()
mytag = client.tags.get("TAG_ID_HERE")