Listing Vanity URLs
Problem
You want to list all Vanity URLs on your Connect server.
Solution
Note
Requires posit-sdk>=0.6.0
Note
This action requires administrator privileges.
Call the vanities.all
method to retrieve a list of all Vanity URLs on your Connect server.
from posit import connect
= connect.Client()
client
= client.vanities.all() vanities
Let’s use polars
to look at the vanities
object.
>>> import polars as pl
>>> pl.DataFrame(vanities)
2, 3)
shape: (
┌─────────────────────────────────┬───────────────────────────┬──────────────────────┐
│ content_guid ┆ path ┆ created_time │--- ┆ --- ┆ --- │
│ str ┆ str ┆ str │
│
╞═════════════════════════════════╪═══════════════════════════╪══════════════════════╡-d1d7-4141-918c-de5e7e… ┆ /my-dashboard/ ┆ 2024-08-01T20:44:58Z │
│ dd9a4ddc578af693-e561-49e3-9943-d9350f… ┆ /my-report/ ┆ 2023-06-29T21:27:32Z │
│ └─────────────────────────────────┴───────────────────────────┴──────────────────────┘
Use the GET v1/vanities
API endpoint to create a data frame of Vanity URLs.
library(connectapi)
library(purrr)
<- connect()
client
<- client$GET("v1/vanities")
response <- map_dfr(response, ~.x) results_df
Example output
> results_df
# A tibble: 1,120 × 3
content_guid path created_time<chr> <chr> <chr>
1 2f022b6b-c6e7-4500-8574-d1fb4cc611db /my_great_vanity_url/ 2023-08-24T18:00:46Z
2 578af693-e561-49e3-9943-d9350f2f7f93 /vanity-2/ 2023-06-29T21:27:32Z