connectapi icon indicating copy to clipboard operation
connectapi copied to clipboard

add optional filters to get_* functions

Open kmasiello opened this issue 3 years ago • 1 comments

Many Connect API endpoints have optional filters for queries. Simplify connectapi queries by implementing these filters.

get_groups

  • https://docs.rstudio.com/connect/api/#get-/v1/groups
  • parameter prefix: Filters groups by prefix (group name).

non-existent get_instrumentation (aka get_shiny and get_content)

  • https://docs.rstudio.com/connect/api/#tag--Instrumentation
  • parameter content_guid: Filter results by content GUID.

get_users

  • https://docs.rstudio.com/connect/api/#get-/v1/users
  • parameter prefix: Filters users by prefix (username, first name, or last name).
  • parameter user_role: Filters by user role.
  • parameter account_status: Filter by account status.

kmasiello avatar Aug 10 '21 17:08 kmasiello

+1

I came across a use case today where I needed to get the details of a specific user (e.g. this endpoint: /v1/users/{guid}).

The only working solution I found was to call the API directly:

library(connectapi)
library(glue)
library(httr)

client <- connect()
user_guid <- user_guid_from_username(client, "sam.edwardes")
api_key <- Sys.getenv("CONNECT_API_KEY")
response <- GET(
    glue("{client$server}/__api__/v1/users/{user_guid}"),
    add_headers(Authorization = glue("Key {api_key}"))
)
user_data <- content(response)
user_data$email

SamEdwardes avatar Nov 03 '22 20:11 SamEdwardes