Skip to content

Tags - Create, delete, info, find content with tag, and view content item tags #345

@schloerke

Description

@schloerke

Currently, all recipes are done using the API. This is green field territory!

View information

from posit import connect
client = connect.Client()

res = client.get("/v1/tags")
>>> import polars as pl
>>> pl.DataFrame(res.json())
shape: (309, 5)
┌─────┬─────────────────────────────────┬───────────┬──────────────────────┬──────────────────────┐
│ id  ┆ name                            ┆ parent_id ┆ created_time         ┆ updated_time         │
│ --- ┆ ---                             ┆ ---       ┆ ---                  ┆ ---                  │
│ str ┆ str                             ┆ str       ┆ str                  ┆ str                  │
╞═════╪═════════════════════════════════╪═══════════╪══════════════════════╪══════════════════════╡
│ 1   ┆ Technology                      ┆ null      ┆ 2017-04-18T19:53:45Z ┆ 2017-05-01T11:29:36Z │
│ 2   ┆ Health                          ┆ null      ┆ 2017-04-18T19:54:05Z ┆ 2017-05-02T13:57:31Z │
│ 4   ┆ Software                        ┆ 1         ┆ 2017-04-18T19:54:24Z ┆ 2017-05-19T18:15:39Z │
│ 5   ┆ Mobile Apps                     ┆ 4         ┆ 2017-04-18T19:54:32Z ┆ 2017-05-03T20:15:27Z │
│ 6   ┆ Version 1.6.0                   ┆ 207       ┆ 2017-05-18T04:53:31Z ┆ 2017-05-18T05:00:20Z │
│ …   ┆ …                               ┆ …         ┆ …                    ┆ …                    │
│ 751 ┆ Artificial Intelligence         ┆ 736       ┆ 2024-06-03T03:26:58Z ┆ 2024-06-03T04:03:24Z │
│ 752 ┆ Machine Learning                ┆ 736       ┆ 2024-06-03T03:27:43Z ┆ 2024-06-03T04:04:04Z │
│ 753 ┆ Deep Learning                   ┆ 736       ┆ 2024-06-03T03:28:12Z ┆ 2024-06-03T04:04:16Z │
└─────┴─────────────────────────────────┴───────────┴──────────────────────┴──────────────────────┘

Create

from posit import connect

TAG_CATEGORY_NAME = "Departments"

client = connect.Client()
response = client.post("/v1/tags", json={
    "name": "Departments",
})

departments = response.json()

# ----------------------------------
# Create w/ parent tag

PARENT_TAG_ID = departments['id']
TAG_NAME = "Administrative"

res = client.post("/v1/tags", json={
    "name": TAG_NAME,
    "parent_id": PARENT_TAG_ID
})

administrative = response.json()

Delete

from posit import connect

TAG_ID = "your-tag-id"

client = connect.Client()

client.delete(f"/v1/tags/{TAG_ID}")

Find content using tag

from posit import connect
client = connect.Client()

TAG_ID = "42"

res = client.get(f"/v1/tags/{TAG_ID}/content")
>>> import polars as pl
>>> pl.DataFrame(res.json())
shape: (24, 45)
┌─────────────────────────────────┬──────────────────────────────┬──────────────────────────────┬──────────────────────────────────────────────────────────────────────────────┐
│ guid                            ┆ name                         ┆ title                        ┆ description                                                                  │
│ ---                             ┆ ---                          ┆ ---                          ┆ ---                                                                          │
│ str                             ┆ str                          ┆ str                          ┆ str                                                                          │
╞═════════════════════════════════╪══════════════════════════════╪══════════════════════════════╪══════════════════════════════════════════════════════════════════════════════╡
│ 5b6f05d1-1fea-480b-b8fa-51aec6… ┆ AI-Overview                  ┆ Introduction to AI           ┆ An introductory overview of Artificial Intelligence and its core concepts.   │
│ 7ec59570-b199-4f16-8fff-86e3c6… ┆ ML-Models                    ┆ Machine Learning Models      ┆ Detailed explanation of various machine learning models and their applicatio │
│ 3f4140dd-5924-4b31-bb2e-2031b2… ┆ DeepLearning-Techniques      ┆ Advanced Deep Learning       ┆ Exploration of advanced techniques in deep learning, including neural network│
│ 62ebbc03-818b-41f2-91fe-4718bb… ┆ Tech-Trends2024              ┆ Technology Trends in 2024    ┆ A look into the upcoming technology trends expected to dominate in 2024.     │
│ 2bd2a699-b46e-4e6a-8eb6-caca49… ┆ Health-Innovations           ┆ Innovations in Healthcare    ┆ Innovations and breakthroughs in the healthcare industry for better outcomes.│
│ …                               ┆ …                            ┆ …                            ┆ …                                                                            │
│ d235306c-7155-4aa3-aac0-a6b587… ┆ Software-Development         ┆ Software Development Basics  ┆ Basics of software development, including best practices and methodologies.  │
│ 3bed9e07-b793-43ea-839a-37e41b… ┆ Mobile-Apps-Trends           ┆ Trends in Mobile Apps        ┆ Current trends in mobile app development and popular frameworks.             │
│ 1d79c2c7-c649-40be-a0b5-3be159… ┆ Stats-Overview               ┆ Overview of Statistics       ┆ Comprehensive overview of statistics and its importance in data analysis.    │
│ 2c67c0c5-3d8b-44c7-a4b3-a80787… ┆ AI-Applications              ┆ Applications of AI           ┆ Various applications of artificial intelligence across different industries. │
│ 2bee37f3-1f44-4ba5-bbdc-092dd0… ┆ Data-Visualization           ┆ Data Visualization Techniques┆ Techniques and tools for effective data visualization and presentation.      │
└─────────────────────────────────┴──────────────────────────────┴──────────────────────────────┴──────────────────────────────────────────────────────────────────────────────┘

View content item's tags

from posit import connect

CONTENT_GUID = "154bd2af-e8fa-4aa4-aab8-dcef701f4af9"

client = connect.Client()

res = client.get(f"/v1/content/{CONTENT_GUID}/tags")
>>> import polars as pl
>>> pl.DataFrame(res.json())
shape: (2, 5)
┌─────┬───────────────────────────┬───────────┬──────────────────────┬──────────────────────┐
│ id  ┆ name                      ┆ parent_id ┆ created_time         ┆ updated_time         │
│ --- ┆ ---                       ┆ ---       ┆ ---                  ┆ ---                  │
│ str ┆ str                       ┆ str       ┆ str                  ┆ str                  │
╞═════╪═══════════════════════════╪═══════════╪══════════════════════╪══════════════════════╡
│ 4   ┆ Software                  ┆ 1         ┆ 2017-04-18T19:54:24Z ┆ 2017-05-19T18:15:39Z │
│ 751 ┆ Artificial Intelligence   ┆ 736       ┆ 2017-04-18T19:54:32Z ┆ 2017-05-03T20:15:27Z │
└─────┴───────────────────────────┴───────────┴──────────────────────┴──────────────────────┘

Metadata

Metadata

Assignees

Labels

enhancementNew feature or requestsdkUsed for automation

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions