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

client = connect.Client()

vanities = client.vanities.all()

Let’s use polars to look at the vanities object.

>>> import polars as pl
>>> pl.DataFrame(vanities)
shape: (2, 3)
┌─────────────────────────────────┬───────────────────────────┬──────────────────────┐
│ content_guid                    ┆ path                      ┆ created_time         │
---------
strstrstr
╞═════════════════════════════════╪═══════════════════════════╪══════════════════════╡
│ dd9a4ddc-d1d7-4141-918c-de5e7e… ┆ /my-dashboard/2024-08-01T20:44:58Z
578af693-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)
client <- connect()

response <- client$GET("v1/vanities")
results_df <- map_dfr(response, ~.x)

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