knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "man/figures/README-",
  out.width = "100%"
)

rscloud

Codecov test coverage Lifecycle: experimental R-CMD-check

API wrappers for the rstudio.cloud service. The initial release includes APIs for managing space memberships, and listing projects within a space.

Getting started

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:

RSCLOUD_CLIENT_ID=xxxxxxx
RSCLOUD_CLIENT_SECRET=zzzzzzz

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)
# clean up
space <- rscloud_space(name = "test-space-1")

members <- space %>% 
  space_member_list() %>% 
  dplyr::filter(email != "rscloud.test.01@gmail.com")
space %>% 
  purrr::safely(space_member_remove)(members, content_action = "leave", ask = FALSE)

space %>% 
  purrr::possibly(space_invitation_list, otherwise = NULL)() %>% 
  purrr::safely(invitation_rescind)()
library(rscloud)
rscloud_space_list()

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

Adding members to a space can be done via space_member_add():

space %>% 
  space_member_add("mine+test1@rstudio.com")

space

You can get a tidy data frame of space members with space_member_list():

space %>% 
  space_member_list()

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

You can also work with outstanding invitations:

invitations <- space %>% 
  space_invitation_list()

invitations

To resend invitations, use the invitation_send() function:

invitations %>% 
  # filter(...) %>% 
  invitation_send()


rstudio/rscloud documentation built on Oct. 8, 2022, 4:24 p.m.