Viewing Content Runtime Settings
Problem
You want to summarize the custom runtime settings of content on your Connect server.
Note
Content with custom runtime settings includes content with RunAsCurrentUser
enabled and content with a custom RunAs
Linux user account.
Solution
Create a table summarizing the usage of custom runtime settings on your Connect server. The table includes totals of the number of content items with RunAsCurrentUser
enabled and for each RunAs
account in use.
from posit import connect
import polars as pl
= connect.Client()
client
= client.content.find()
content = (pl.DataFrame(content, infer_schema_length=None)
content_out # combine RunAsCurrentUser and RunAs into a single column
"run_as_current_user") == "true")
.with_columns(pl.when(pl.col("RunAsCurrentUser"))
.then(pl.lit("run_as")).alias("run_as"))
.otherwise(pl.col(# Remove NULL (content items run as the default account appear as NULL)
filter(pl.col("run_as").is_not_null())
."run_as").count()
.group_by("count", descending=True)
.sort( )
>>> content_out
3, 2)
shape: (
run_as countstr u32
"sa-engineering" 8
"sa-finance" 3
"RunAsCurrentUser" 1
library(connectapi)
library(dplyr)
<- connect()
client
<- get_content(client)
content
<- content |>
content_out # combine RunAsCurrentUser and RunAs into a single column
mutate(run_as = if_else(run_as_current_user, "RunAsCurrentUser", run_as)) |>
# Remove NA (content items run as the default account appear as NA)
filter(!is.na(run_as)) |>
group_by(run_as) |>
summarise(count = n()) |>
arrange(desc(count))
> content_out
run_as count<chr> <int>
2 sa-engineering 8
3 sa-finance 3
4 RunAsCurrentUser 1
Discussion
This may be useful when auditing the server in preparation for a migration, to understand which accounts need to be replicated in the new environment. It is also generally helpful to understand if content on the server has specific run-time requirements.
See also
- Finding Content with Custom Runtime Settings to enumerate all content items with
RunAsCurrentUser
enabled or a customizedRunAs
user.