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
Methods
| Name | Description |
|---|---|
| find | Find all child tags that are direct children of a single tag. |
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
ContentItemTags
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
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
delete
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
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
DescendantTags
Methods
| Name | Description |
|---|---|
| find | Find all child tags that descend from a single tag. |
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
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
Removes the tag.
Deletes a tag, including all descendants in its own tag hierarchy.
Examples
update
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
Methods
| Name | Description |
|---|---|
| find | Find all content items that are tagged with this tag. |
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
Tags
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
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
find
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
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. |