Finding All Content Using an Image

Problem

You want to find all content items using a particular image for off-host execution.

Solution

Get data on all content items on the server, then filter on the image_name column for the image name you want to learn about.

from posit import connect

client = connect.Client()

IMAGE_NAME = "ghcr.io/rstudio/content-pro:r4.1.3-py3.10.4-bionic"

guids = [c.guid for c in client.content.find() if c.image_name == IMAGE_NAME]
>>> guids
['c1f789f8-4772-4b87-8b53-eaf863496c79', '875fc38a-121b-40a9-a0f9-eced7aab28af']
library(connectapi)
library(dplyr)

IMAGE_NAME <- "ghcr.io/rstudio/content-pro:r4.1.3-py3.10.4-bionic"

client <- connect()
guids <- client |>
  get_content() |>
  filter(image_name == IMAGE_NAME) |>
  pull(guid)
> guids
[1] "c1f789f8-4772-4b87-8b53-eaf863496c79"
[2] "875fc38a-121b-40a9-a0f9-eced7aab28af"

Discussion

In this recipe we output a list of content identifiers (GUIDs), which can be used as inputs for other workflows. You can also simply filter the tables returned by the SDKs to see more data on the matching content.

See also