API wrappers for the rstudio.cloud service. The initial release includes APIs for managing space memberships, and listing projects within a space.
To get started, you’ll need to obtain credentials and set the environment variables RSCLOUD_CLIENT_ID
and RSCLOUD_CLIENT_SECRET
. The recommended way to set these is by editing your .Renviron
file. This can be done using the usethis::edit_r_environ()
function. Your .Renviron
file may look something like the following:
To get your credentials log in to RStudio Cloud, click on your name/icon on the right side of the header, and choose “Credentials” from the user panel that appears. That will take you the RStudio User Settings application, where you can create credentials for use with rscloud.
You can install the development version of rscloud as follows:
install.packages("remotes")
remotes::install_github("rstudio/rscloud")
The entry point to most of the functionality is a space. To see the list of spaces you have access to, you can use the rscloud_space_list()
function:
library(rscloud)
rscloud_space_list()
#> # A tibble: 2 × 17
#> space_id name description project_count user_count account_id project_max
#> <int> <chr> <chr> <int> <int> <int> <int>
#> 1 178750 test-space-1 Test space… 2 1 1093053 10000
#> 2 178762 test-space-2 <NA> 0 1 1093053 10000
#> # … with 10 more variables: visibility <chr>, space_role <chr>, access <chr>,
#> # created_time <dttm>, default_project_id <lgl>, default_member_role <chr>,
#> # access_code <lgl>, permissions <list>, updated_time <dttm>, user_max <int>
To create a space object, use the rscloud_space()
function:
space <- rscloud_space(178750)
# you can also use the space name
# space <- rstudio_space(name = "test-space-1")
space
#> RStudio Cloud Space (ID: 178750)
#> <test-space-1>
#> users: 1 | projects: 2
Adding members to a space can be done via space_member_add()
:
space %>%
space_member_add("mine+test1@rstudio.com")
space
#> RStudio Cloud Space (ID: 178750)
#> <test-space-1>
#> users: 2 | projects: 2
You can get a tidy data frame of space members with space_member_list()
:
space %>%
space_member_list()
#> # A tibble: 1 × 22
#> user_id display_name email updated_time created_time last_name
#> <int> <chr> <chr> <dttm> <dttm> <chr>
#> 1 1165199 RStudio Clou… rsclo… 2021-10-05 18:34:36 2021-10-05 18:26:25 Cloud Te…
#> # … with 16 more variables: github_auth_id <lgl>, sso_account_id <lgl>,
#> # github_auth_token <lgl>, first_name <chr>, grant <list>, picture_url <chr>,
#> # login_attempts <int>, lockout_until <lgl>, location <chr>, homepage <chr>,
#> # last_login_attempt <lgl>, google_auth_id <chr>, email_verified <lgl>,
#> # local_auth <lgl>, organization <chr>, referral <lgl>
You can also provide a data frame of user information, which can be useful when working with spreadsheets of class rosters:
roster <- tibble::tribble(
~user_email,
"mine+test2@rstudio.com",
"mine+test3@rstudio.com"
)
space %>%
space_member_add(roster)
space
#> RStudio Cloud Space (ID: 178750)
#> <test-space-1>
#> users: 4 | projects: 2
You can also work with outstanding invitations:
invitations <- space %>%
space_invitation_list()
invitations
#> # A tibble: 3 × 16
#> invitation_id space_id email type accepted expired redirect accepted_by
#> <int> <int> <chr> <chr> <lgl> <lgl> <chr> <lgl>
#> 1 203121 178750 mine+t… space… FALSE FALSE https://rs… NA
#> 2 203122 178750 mine+t… space… FALSE FALSE https://rs… NA
#> 3 203123 178750 mine+t… space… FALSE FALSE https://rs… NA
#> # … with 8 more variables: updated_time <dttm>, sender <list>,
#> # sso_enabled <lgl>, space_role <chr>, link <chr>, branding <chr>,
#> # created_time <dttm>, message <lgl>
To resend invitations, use the invitation_send()
function:
invitations %>%
# filter(...) %>%
invitation_send()