rstudio / connectapi

An R package for interacting with the RStudio Connect Server API
https://pkgs.rstudio.com/connectapi/
Other
43 stars 25 forks source link

New Article - Posit Connect Audit tasks? #187

Open slodge opened 1 year ago

slodge commented 1 year ago

Looking at the articles on Posit support like https://support.posit.co/hc/en-us/articles/360007435274-Counting-Named-Users-in-Posit-Connect-and-Posit-Workbench-RStudio-Server-Pro, it would be useful to us to have connectapi equivalents.

For example:

library(tidyverse)
library(connectapi)

client <- connect(
  host = Sys.getenv("CONNECT_PROD_SERVER"),
  api_key = Sys.getenv("CONNECT_PROD_API")
)

audit <- connectapi::get_audit_logs(client, limit = 1000000)

most_recent_users <-
  audit %>% 
  filter(user_id > 0) %>% # removes e.g. "Obsolete rendering remover" and "Auth Provider"
  group_by(user_id, user_description) %>% 
  summarise(
    MostRecent = max(time)
  ) %>% 
  arrange(desc(MostRecent)) %>% 
  filter(MostRecent > lubridate::today("UTC") - lubridate::years(1)) 

most_recent_users %>% 
  View()

Are the vignettes/pkgdown docs for this package a good place (the right place) for these? If so, we can look at helping with PRs.

colearendt commented 1 year ago

I like it!! vignettes / pkgdown contributions are definitely welcome if you are so inclined!

It's a bit tricky to use, but there is a test Connect deployment that is set up during the pkgdown site generation, so some of this could be generated programmatically.

There are also a bunch of "audit reports" here on our "solutions site," which may be somewhat up your alley. Unfortunately, many of them do not use connectapi IIRC

https://solutions.posit.co/operations/connect-apis/basic-audit-report/