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
= connect.Client()
client
= "ghcr.io/rstudio/content-pro:r4.1.3-py3.10.4-bionic"
IMAGE_NAME
= [c["guid"] for c in client.content.find() if c["image_name"] == IMAGE_NAME] guids
>>> guids
'c1f789f8-4772-4b87-8b53-eaf863496c79', '875fc38a-121b-40a9-a0f9-eced7aab28af'] [
library(connectapi)
library(dplyr)
<- "ghcr.io/rstudio/content-pro:r4.1.3-py3.10.4-bionic"
IMAGE_NAME
<- connect()
client <- client |>
guids 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
- Viewing Container Image Usage for viewing a list of image names in use and how many content items use each.