googledrive/ 0000755 0001762 0000144 00000000000 14441420300 012550 5 ustar ligges users googledrive/NAMESPACE 0000644 0001762 0000144 00000007625 14441250555 014016 0 ustar ligges users # Generated by roxygen2: do not edit by hand
S3method("[",dribble)
S3method("names<-",dribble)
S3method(as_dribble,"NULL")
S3method(as_dribble,character)
S3method(as_dribble,data.frame)
S3method(as_dribble,default)
S3method(as_dribble,drive_id)
S3method(as_dribble,list)
S3method(as_id,"NULL")
S3method(as_id,character)
S3method(as_id,data.frame)
S3method(as_id,default)
S3method(as_id,dribble)
S3method(as_id,drive_id)
S3method(as_shared_drive,"NULL")
S3method(as_shared_drive,character)
S3method(as_shared_drive,data.frame)
S3method(as_shared_drive,default)
S3method(as_shared_drive,dribble)
S3method(as_shared_drive,drive_id)
S3method(as_shared_drive,list)
S3method(as_tibble,dribble)
S3method(format,drive_user)
S3method(gargle_map_cli,dribble)
S3method(gargle_map_cli,drive_id)
S3method(pillar_shaft,drive_id)
S3method(print,drive_user)
S3method(tbl_sum,dribble)
S3method(vec_cast,character.drive_id)
S3method(vec_cast,data.frame.dribble)
S3method(vec_cast,dribble.data.frame)
S3method(vec_cast,dribble.dribble)
S3method(vec_cast,dribble.tbl_df)
S3method(vec_cast,drive_id.character)
S3method(vec_cast,drive_id.drive_id)
S3method(vec_cast,tbl_df.dribble)
S3method(vec_ptype2,character.drive_id)
S3method(vec_ptype2,data.frame.dribble)
S3method(vec_ptype2,dribble.data.frame)
S3method(vec_ptype2,dribble.dribble)
S3method(vec_ptype2,dribble.tbl_df)
S3method(vec_ptype2,drive_id.character)
S3method(vec_ptype2,drive_id.drive_id)
S3method(vec_ptype2,tbl_df.dribble)
S3method(vec_ptype_abbr,drive_id)
S3method(vec_restore,dribble)
export("%>%")
export(as_dribble)
export(as_id)
export(as_shared_drive)
export(as_team_drive)
export(confirm_dribble)
export(confirm_single_file)
export(confirm_some_files)
export(do_paginated_request)
export(do_request)
export(drive_about)
export(drive_api_key)
export(drive_auth)
export(drive_auth_config)
export(drive_auth_configure)
export(drive_browse)
export(drive_cp)
export(drive_create)
export(drive_deauth)
export(drive_download)
export(drive_empty_trash)
export(drive_endpoint)
export(drive_endpoints)
export(drive_example)
export(drive_example_local)
export(drive_example_remote)
export(drive_examples_local)
export(drive_examples_remote)
export(drive_extension)
export(drive_fields)
export(drive_find)
export(drive_get)
export(drive_has_token)
export(drive_link)
export(drive_ls)
export(drive_mime_type)
export(drive_mkdir)
export(drive_mv)
export(drive_oauth_app)
export(drive_oauth_client)
export(drive_publish)
export(drive_put)
export(drive_read_raw)
export(drive_read_string)
export(drive_rename)
export(drive_reveal)
export(drive_rm)
export(drive_scopes)
export(drive_share)
export(drive_share_anyone)
export(drive_token)
export(drive_trash)
export(drive_unpublish)
export(drive_untrash)
export(drive_update)
export(drive_upload)
export(drive_user)
export(expose)
export(is_dribble)
export(is_folder)
export(is_folder_shortcut)
export(is_mine)
export(is_native)
export(is_parental)
export(is_shared_drive)
export(is_shortcut)
export(is_team_drive)
export(local_drive_quiet)
export(no_file)
export(prep_fields)
export(request_generate)
export(request_make)
export(shared_drive_create)
export(shared_drive_find)
export(shared_drive_get)
export(shared_drive_rm)
export(shared_drive_update)
export(shortcut_create)
export(shortcut_resolve)
export(single_file)
export(some_files)
export(team_drive_create)
export(team_drive_find)
export(team_drive_get)
export(team_drive_rm)
export(team_drive_update)
export(with_drive_quiet)
import(rlang)
import(vctrs)
importFrom(gargle,bulletize)
importFrom(gargle,gargle_map_cli)
importFrom(glue,glue)
importFrom(glue,glue_collapse)
importFrom(glue,glue_data)
importFrom(lifecycle,deprecated)
importFrom(magrittr,"%>%")
importFrom(pillar,pillar_shaft)
importFrom(purrr,map)
importFrom(purrr,map2)
importFrom(purrr,map_chr)
importFrom(purrr,map_if)
importFrom(purrr,map_int)
importFrom(purrr,map_lgl)
importFrom(purrr,pluck)
importFrom(tibble,as_tibble)
importFrom(tibble,tbl_sum)
importFrom(tibble,tibble)
googledrive/LICENSE 0000644 0001762 0000144 00000000061 14413426163 013566 0 ustar ligges users YEAR: 2023
COPYRIGHT HOLDER: googledrive authors
googledrive/README.md 0000644 0001762 0000144 00000005307 14440426453 014052 0 ustar ligges users
# googledrive
[](https://CRAN.R-project.org/package=googledrive)
[](https://github.com/tidyverse/googledrive/actions/workflows/R-CMD-check.yaml)
[](https://app.codecov.io/gh/tidyverse/googledrive?branch=main)
## Overview
googledrive allows you to interact with files on Google Drive from R.
## Installation
Install the CRAN version:
``` r
install.packages("googledrive")
```
Or install the development version from GitHub:
``` r
# install.packages("pak")
pak::pak("tidyverse/googledrive")
```
## Usage
Please see the package website:
Here’s a teaser that uses googledrive to view some of the files you see
on (up to `n_max = 25`, in this case):
``` r
library("googledrive")
drive_find(n_max = 25)
#> # A dribble: 25 × 3
#> name id drive_resource
#>
#> 1 2021-09-16_r_logo.jpg 1dandXB0QZpjeGQq_56wTXKNwaqgsOa9D
#> 2 2021-09-16_r_about.html 1XfCI_orH4oNUZh06C4w6vXtno-BT_zmZ
#> 3 2021-09-16_imdb_latin1.csv 163YPvqYmGuqQiEwEFLg2s1URq4EnpkBw
#> 4 2021-09-16_chicken.txt 1axJz8GSmecSnaYBx0Sb3Gb-SXVaTzKw7
#> 5 2021-09-16_chicken.pdf 14Hd6_VQAeEgcwBBJamc-FUlnXhp117T2
#> 6 2021-09-16_chicken.jpg 1aslW1T-B8UKzAEotDWpmRFaMyMux5-it
#> 7 2021-09-16_chicken.csv 1Mj--zJYZJSMKsNVjk2tYFef5LnCsNoDT
#> 8 pqr 143iq-CswFTwJTjVfKkcFMDW0jYqDeUj2
#> 9 mno 1gcUTnFbsF6uioJrLCsVQ78_F1wEzyNtI
#> 10 jkl 17T40phn99w0hY-B_Ev0deTvVg9fmUSnt
#> # ℹ 15 more rows
```
## Contributing
If you’d like to contribute to the development of googledrive, please
read [these
guidelines](https://googledrive.tidyverse.org/CONTRIBUTING.html).
Please note that the googledrive project is released with a [Contributor
Code of
Conduct](https://googledrive.tidyverse.org/CODE_OF_CONDUCT.html). By
contributing to this project, you agree to abide by its terms.
## Privacy
[Privacy policy](https://www.tidyverse.org/google_privacy_policy)
googledrive/man/ 0000755 0001762 0000144 00000000000 14441250555 013340 5 ustar ligges users googledrive/man/shared_drive_get.Rd 0000644 0001762 0000144 00000003211 14070147664 017126 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/shared_drive_get.R
\name{shared_drive_get}
\alias{shared_drive_get}
\title{Get shared drives by name or id}
\usage{
shared_drive_get(name = NULL, id = NULL)
}
\arguments{
\item{name}{Character vector of names. A character vector marked with
\code{\link[=as_id]{as_id()}} is treated as if it was provided via the \code{id} argument.}
\item{id}{Character vector of shared drive ids or URLs (it is first processed
with \code{\link[=as_id]{as_id()}}). If both \code{name} and \code{id} are non-\code{NULL}, \code{id} is silently
ignored.}
}
\value{
An object of class \code{\link{dribble}}, a tibble with one row per shared drive.
}
\description{
Retrieve metadata for shared drives specified by name or id. Note that Google
Drive does NOT behave like your local file system:
\itemize{
\item You can get zero, one, or more shared drives back for each name! Shared
drive names need not be unique.
}
A shared drive supports files owned by an organization rather than an
individual user. Shared drives follow different sharing and ownership models
from a specific user's "My Drive". Shared drives are the successors to the
earlier concept of Team Drives. Learn more about \link[=shared_drives]{shared drives}.
}
\examples{
\dontrun{
shared_drive_get("my-awesome-shared-drive")
shared_drive_get(c("apple", "orange", "banana"))
shared_drive_get(as_id("KCmiHLXUk9PVA-0AJNG"))
shared_drive_get(as_id("https://drive.google.com/drive/u/0/folders/KCmiHLXUk9PVA-0AJNG"))
shared_drive_get(id = "KCmiHLXUk9PVA-0AJNG")
shared_drive_get(id = "https://drive.google.com/drive/u/0/folders/KCmiHLXUk9PVA-0AJNG")
}
}
googledrive/man/drive_empty_trash.Rd 0000644 0001762 0000144 00000001575 14070147664 017373 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/drive_trash.R
\name{drive_empty_trash}
\alias{drive_empty_trash}
\title{Empty Drive Trash}
\usage{
drive_empty_trash(verbose = deprecated())
}
\arguments{
\item{verbose}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} This logical argument to
individual googledrive functions is deprecated. To globally suppress
googledrive messaging, use \code{options(googledrive_quiet = TRUE)} (the default
behaviour is to emit informational messages). To suppress messaging in a
more limited way, use the helpers \code{\link[=local_drive_quiet]{local_drive_quiet()}} or
\code{\link[=with_drive_quiet]{with_drive_quiet()}}.}
}
\description{
Caution, this will permanently delete files in your Drive trash.
}
googledrive/man/shared_drive_find.Rd 0000644 0001762 0000144 00000002703 14070147664 017274 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/shared_drive_find.R
\name{shared_drive_find}
\alias{shared_drive_find}
\title{Find shared drives}
\usage{
shared_drive_find(pattern = NULL, n_max = Inf, ...)
}
\arguments{
\item{pattern}{Character. If provided, only the items whose names match this
regular expression are returned. This is implemented locally on the results
returned by the API.}
\item{n_max}{Integer. An upper bound on the number of items to return. This
applies to the results requested from the API, which may be further
filtered locally, via the \code{pattern} argument.}
\item{...}{Other parameters to pass along in the request, such as \code{pageSize}
or \code{useDomainAdminAccess}.}
}
\value{
An object of class \code{\link{dribble}}, a tibble with one row per shared drive.
}
\description{
This is the closest googledrive function to what you get from
visiting \url{https://drive.google.com} and clicking "Shared drives".
A shared drive supports files owned by an organization rather than an
individual user. Shared drives follow different sharing and ownership models
from a specific user's "My Drive". Shared drives are the successors to the
earlier concept of Team Drives. Learn more about \link[=shared_drives]{shared drives}.
}
\examples{
\dontrun{
shared_drive_find()
}
}
\seealso{
Wraps the \code{drives.list} endpoint:
\itemize{
\item \url{https://developers.google.com/drive/api/v3/reference/drives/list}
}
}
googledrive/man/drive_get.Rd 0000644 0001762 0000144 00000015321 14413426163 015600 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/drive_get.R
\name{drive_get}
\alias{drive_get}
\title{Get Drive files by path or id}
\usage{
drive_get(
path = NULL,
id = NULL,
shared_drive = NULL,
corpus = NULL,
verbose = deprecated(),
team_drive = deprecated()
)
}
\arguments{
\item{path}{Character vector of path(s) to get. Use a trailing slash to
indicate explicitly that a path is a folder, which can disambiguate if
there is a file of the same name (yes this is possible on Drive!). If
\code{path} appears to contain Drive URLs or is explicitly marked with
\code{\link[=as_id]{as_id()}}, it is treated as if it was provided via the \code{id} argument.}
\item{id}{Character vector of Drive file ids or URLs (it is first processed
with \code{\link[=as_id]{as_id()}}). If both \code{path} and \code{id} are non-\code{NULL}, \code{id} is silently
ignored.}
\item{shared_drive}{Anything that identifies one specific shared drive: its
name, its id or URL marked with \code{\link[=as_id]{as_id()}}, or a \code{\link{dribble}}. The value
provided to \code{shared_drive} is pre-processed with \code{\link[=as_shared_drive]{as_shared_drive()}}. Read
more about \link[=shared_drives]{shared drives}.}
\item{corpus}{Character, specifying which collections of items to search.
Relevant to those who work with shared drives and/or Google Workspace
domains. If specified, must be one of \code{"user"}, \code{"drive"} (requires that
\code{shared_drive} also be specified), \code{"allDrives"}, or \code{"domain"}. Read more
about \link[=shared_drives]{shared drives}.}
\item{verbose}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} This logical argument to
individual googledrive functions is deprecated. To globally suppress
googledrive messaging, use \code{options(googledrive_quiet = TRUE)} (the default
behaviour is to emit informational messages). To suppress messaging in a
more limited way, use the helpers \code{\link[=local_drive_quiet]{local_drive_quiet()}} or
\code{\link[=with_drive_quiet]{with_drive_quiet()}}.}
\item{team_drive}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} Google Drive and the
Drive API have replaced Team Drives with shared drives.}
}
\value{
An object of class \code{\link{dribble}}, a tibble with one row per file.
If the target files were specified via \code{path},
there will be a \code{path} column.
}
\description{
Retrieves metadata for files specified via \code{path} or via file \code{id}. This
function is quite straightforward if you specify files by \code{id}. But there are
some important considerations when you specify your target files by \code{path}.
See below for more. If the target files are specified via \code{path}, the
returned \code{\link{dribble}} will include a \code{path} column.
}
\section{Getting by \code{path}}{
Google Drive does NOT behave like your local file system! File and folder
names need not be unique, even at a given level of the hierarchy. This
means that a single path can describe multiple files (or 0 or exactly 1).
A single file can also be compatible with multiple paths, i.e. one path
could be more specific than the other. A file located at \verb{~/alfa/bravo} can
be found as \code{bravo}, \code{alfa/bravo}, and \verb{~/alfa/bravo}. If all 3 of those
were included in the input \code{path}, they would be represented by a
\strong{single} row in the output.
It's best to think of \code{drive_get()} as a setwise operation when using file
paths. Do not assume that the \code{i}-th input path corresponds to row \code{i} in
the output (although it often does!). If there's not a 1-to-1 relationship
between the input and output, this will be announced in a message.
\code{drive_get()} performs just enough path resolution to uniquely identify a
file compatible with each input \code{path}, for all \code{path}s at once. If you
absolutely want the full canonical path, run the output of \code{drive_get()}
through \code{\link[=drive_reveal]{drive_reveal(d, "path")}}`.
}
\section{Files that you don't own}{
If you want to get a file via \code{path} and it's not necessarily on your My
Drive, you may need to specify the \code{shared_drive} or \code{corpus} arguments to
search other collections of items. Read more about \link[=shared_drives]{shared drives}.
}
\examples{
\dontshow{if (drive_has_token()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf}
# get info about your "My Drive" root folder
drive_get("~/")
# the API reserves the file id "root" for your root folder
drive_get(id = "root")
drive_get(id = "root") \%>\% drive_reveal("path")
# set up some files to get by path
alfalfa <- drive_mkdir("alfalfa")
broccoli <- drive_upload(
drive_example_local("chicken.txt"),
name = "broccoli", path = alfalfa
)
drive_get("broccoli")
drive_get("alfalfa/broccoli")
drive_get("~/alfalfa/broccoli")
drive_get(c("broccoli", "alfalfa/", "~/alfalfa/broccoli"))
# Clean up
drive_rm(alfalfa)
\dontrun{
# The examples below are indicative of correct syntax.
# But note these will generally result in an error or a
# 0-row dribble, unless you replace the inputs with paths
# or file ids that exist in your Drive.
# multiple names
drive_get(c("abc", "def"))
# multiple names, one of which must be a folder
drive_get(c("abc", "def/"))
# query by file id(s)
drive_get(id = "abcdefgeh123456789")
drive_get(as_id("abcdefgeh123456789"))
drive_get(id = c("abcdefgh123456789", "jklmnopq123456789"))
# apply to a browser URL for, e.g., a Google Sheet
my_url <- "https://docs.google.com/spreadsheets/d/FILE_ID/edit#gid=SHEET_ID"
drive_get(my_url)
drive_get(as_id(my_url))
drive_get(id = my_url)
# access the shared drive named "foo"
# shared_drive params must be specified if getting by path
foo <- shared_drive_get("foo")
drive_get(c("this.jpg", "that-file"), shared_drive = foo)
# shared_drive params are not necessary if getting by id
drive_get(as_id("123456789"))
# search all shared drives and other files user has accessed
drive_get(c("this.jpg", "that-file"), corpus = "allDrives")
}
\dontshow{\}) # examplesIf}
}
\seealso{
To add path information to any \code{\link{dribble}} that lacks it, use
\code{\link[=drive_reveal]{drive_reveal(d, "path")}}. To list the contents of a
folder, use \code{\link[=drive_ls]{drive_ls()}}. For general searching, use \code{\link[=drive_find]{drive_find()}}.
Wraps the \code{files.get} endpoint and, if you specify files by name or
path, also calls \code{files.list}:
\itemize{
\item \url{https://developers.google.com/drive/api/v3/reference/files/get}
\item \url{https://developers.google.com/drive/api/v3/reference/files/list}
}
}
googledrive/man/drive_auth_configure.Rd 0000644 0001762 0000144 00000006112 14441250555 020022 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/drive_auth.R
\name{drive_auth_configure}
\alias{drive_auth_configure}
\alias{drive_api_key}
\alias{drive_oauth_client}
\title{Edit and view auth configuration}
\usage{
drive_auth_configure(client, path, api_key, app = deprecated())
drive_api_key()
drive_oauth_client()
}
\arguments{
\item{client}{A Google OAuth client, presumably constructed via
\code{\link[gargle:gargle_oauth_client_from_json]{gargle::gargle_oauth_client_from_json()}}. Note, however, that it is
preferred to specify the client with JSON, using the \code{path} argument.}
\item{path}{JSON downloaded from \href{https://console.cloud.google.com}{Google Cloud Console}, containing a client id and
secret, in one of the forms supported for the \code{txt} argument of
\code{\link[jsonlite:fromJSON]{jsonlite::fromJSON()}} (typically, a file path or JSON string).}
\item{api_key}{API key.}
\item{app}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} Replaced by the \code{client}
argument.}
}
\value{
\itemize{
\item \code{drive_auth_configure()}: An object of R6 class
\link[gargle:AuthState-class]{gargle::AuthState}, invisibly.
\item \code{drive_oauth_client()}: the current user-configured OAuth client.
\item \code{drive_api_key()}: the current user-configured API key.
}
}
\description{
These functions give more control over and visibility into the auth
configuration than \code{\link[=drive_auth]{drive_auth()}} does. \code{drive_auth_configure()}
lets the user specify their own:
\itemize{
\item OAuth client, which is used when obtaining a user token.
\item API key. If googledrive is de-authorized via \code{\link[=drive_deauth]{drive_deauth()}}, all
requests are sent with an API key in lieu of a token.
}
See the \code{vignette("get-api-credentials", package = "gargle")}
for more.
If the user does not configure these settings, internal defaults
are used.
\code{drive_oauth_client()} and \code{drive_api_key()} retrieve the
currently configured OAuth client and API key, respectively.
}
\examples{
# see and store the current user-configured OAuth client (probaby `NULL`)
(original_client <- drive_oauth_client())
# see and store the current user-configured API key (probaby `NULL`)
(original_api_key <- drive_api_key())
# the preferred way to configure your own client is via a JSON file
# downloaded from Google Developers Console
# this example JSON is indicative, but fake
path_to_json <- system.file(
"extdata", "client_secret_installed.googleusercontent.com.json",
package = "gargle"
)
drive_auth_configure(path = path_to_json)
# this is also obviously a fake API key
drive_auth_configure(api_key = "the_key_I_got_for_a_google_API")
# confirm the changes
drive_oauth_client()
drive_api_key()
# restore original auth config
drive_auth_configure(client = original_client, api_key = original_api_key)
}
\seealso{
Other auth functions:
\code{\link{drive_auth}()},
\code{\link{drive_deauth}()},
\code{\link{drive_scopes}()}
}
\concept{auth functions}
googledrive/man/googledrive-configuration.Rd 0000644 0001762 0000144 00000005650 14413426163 021007 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/googledrive-package.R, R/utils-ui.R
\name{googledrive-configuration}
\alias{googledrive-configuration}
\alias{local_drive_quiet}
\alias{with_drive_quiet}
\title{googledrive configuration}
\usage{
local_drive_quiet(env = parent.frame())
with_drive_quiet(code)
}
\arguments{
\item{env}{The environment to use for scoping}
\item{code}{Code to execute quietly}
}
\description{
Some aspects of googledrive behaviour can be controlled via an option.
}
\section{Auth}{
Read about googledrive's main auth function, \code{\link[=drive_auth]{drive_auth()}}. It is powered
by the gargle package, which consults several options:
\itemize{
\item Default Google user or, more precisely, \code{email}: see
\code{\link[gargle:gargle_options]{gargle::gargle_oauth_email()}}
\item Whether or where to cache OAuth tokens: see
\code{\link[gargle:gargle_options]{gargle::gargle_oauth_cache()}}
\item Whether to prefer "out-of-band" auth: see
\code{\link[gargle:gargle_options]{gargle::gargle_oob_default()}}
\item Application Default Credentials: see \code{\link[gargle:credentials_app_default]{gargle::credentials_app_default()}}
}
}
\section{Messages}{
The \code{googledrive_quiet} option can be used to suppress messages from
googledrive. By default, googledrive always messages, i.e. it is \emph{not}
quiet.
Set \code{googledrive_quiet} to \code{TRUE} to suppress messages, by one of these
means, in order of decreasing scope:
\itemize{
\item Put \code{options(googledrive_quiet = TRUE)} in a start-up file, such as
\code{.Rprofile}, or at the top of your R script
\item Use \code{local_drive_quiet()} to silence googledrive in a specific scope
\if{html}{\out{
}}
}
\code{local_drive_quiet()} and \code{with_drive_quiet()} follow the conventions of the
the withr package (\url{https://withr.r-lib.org}).
}
\examples{
\dontshow{if (drive_has_token()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf}
# message: "Created Drive file"
(x <- drive_create("drive-quiet-demo", type = "document"))
# message: "File updated"
x <- drive_update(x, starred = TRUE)
drive_reveal(x, "starred")
# suppress messages for a small amount of code
with_drive_quiet(
x <- drive_update(x, name = "drive-quiet-works")
)
x$name
# message: "File updated"
x <- drive_update(x, media = drive_example_local("chicken.txt"))
# suppress messages within a specific scope, e.g. function
unstar <- function(y) {
local_drive_quiet()
drive_update(y, starred = FALSE)
}
x <- unstar(x)
drive_reveal(x, "starred")
# Clean up
drive_rm(x)
\dontshow{\}) # examplesIf}
}
googledrive/man/drive_download.Rd 0000644 0001762 0000144 00000006162 14405753133 016634 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/drive_download.R
\name{drive_download}
\alias{drive_download}
\title{Download a Drive file}
\usage{
drive_download(
file,
path = NULL,
type = NULL,
overwrite = FALSE,
verbose = deprecated()
)
}
\arguments{
\item{file}{Something that identifies the file of interest on your Google
Drive. Can be a name or path, a file id or URL marked with \code{\link[=as_id]{as_id()}}, or a
\code{\link{dribble}}.}
\item{path}{Character. Path for output file. If absent, the default file name
is the file's name on Google Drive and the default location is working
directory, possibly with an added file extension.}
\item{type}{Character. Only consulted if \code{file} is a native Google file.
Specifies the desired type of the exported file. Will be processed via
\code{\link[=drive_mime_type]{drive_mime_type()}}, so either a file extension like \code{"pdf"} or a full MIME
type like \code{"application/pdf"} is acceptable.}
\item{overwrite}{A logical scalar. If local \code{path} already exists, do you
want to overwrite it?}
\item{verbose}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} This logical argument to
individual googledrive functions is deprecated. To globally suppress
googledrive messaging, use \code{options(googledrive_quiet = TRUE)} (the default
behaviour is to emit informational messages). To suppress messaging in a
more limited way, use the helpers \code{\link[=local_drive_quiet]{local_drive_quiet()}} or
\code{\link[=with_drive_quiet]{with_drive_quiet()}}.}
}
\value{
An object of class \code{\link{dribble}}, a tibble with one row per file.
}
\description{
This function downloads a file from Google Drive. Native Google
file types, such as Google Docs, Google Sheets, and Google Slides, must be
exported to a conventional local file type. This can be specified:
\itemize{
\item explicitly via \code{type}
\item implicitly via the file extension of \code{path}
\item not at all, i.e. rely on the built-in default
}
To see what export file types are even possible, see the \href{https://developers.google.com/drive/api/v3/ref-export-formats}{Drive API documentation}
or the result of \code{drive_about()$exportFormats}. The returned dribble
includes a \code{local_path} column.
}
\examples{
\dontshow{if (drive_has_token()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf}
# Target one of the official example files
(src_file <- drive_example_remote("chicken_sheet"))
# Download Sheet as csv, explicit type
downloaded_file <- drive_download(src_file, type = "csv")
# See local path to new file
downloaded_file$local_path
# Download as csv, type implicit in file extension
drive_download(src_file, path = "my_csv_file.csv")
# Download with default name and type (xlsx)
drive_download(src_file)
# Clean up
unlink(c("chicken_sheet.csv", "chicken_sheet.xlsx", "my_csv_file.csv"))
\dontshow{\}) # examplesIf}
}
\seealso{
\href{https://developers.google.com/drive/api/v3/manage-downloads}{Download files}, in the
Drive API documentation.
}
googledrive/man/drive_extension.Rd 0000644 0001762 0000144 00000001363 13200256167 017034 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/drive_mime_type.R
\name{drive_extension}
\alias{drive_extension}
\title{Lookup extension from MIME type}
\usage{
drive_extension(type = NULL)
}
\arguments{
\item{type}{Character. MIME type or file extension.}
}
\value{
Character. File extension.
}
\description{
This is a helper to determinine which extension should be used
for a file. Two types of input are acceptable:
\itemize{
\item MIME types accepted by Google Drive.
\item File extensions, such as "pdf", "csv", etc. (these are simply passed through).
}
}
\examples{
## get the extension for mime type image/jpeg
drive_extension("image/jpeg")
## it's vectorized
drive_extension(c("text/plain", "pdf", "image/gif"))
}
googledrive/man/drive_read_string.Rd 0000644 0001762 0000144 00000004464 14405753133 017331 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/drive_read.R
\name{drive_read_string}
\alias{drive_read_string}
\alias{drive_read_raw}
\title{Read the content of a Drive file}
\usage{
drive_read_string(file, type = NULL, encoding = NULL)
drive_read_raw(file, type = NULL)
}
\arguments{
\item{file}{Something that identifies the file of interest on your Google
Drive. Can be a name or path, a file id or URL marked with \code{\link[=as_id]{as_id()}}, or a
\code{\link{dribble}}.}
\item{type}{Character. Only consulted if \code{file} is a native Google file.
Specifies the desired type of the exported file. Will be processed via
\code{\link[=drive_mime_type]{drive_mime_type()}}, so either a file extension like \code{"pdf"} or a full MIME
type like \code{"application/pdf"} is acceptable.}
\item{encoding}{Passed along to \code{\link[httr:content]{httr::content()}}. Describes the encoding of
the \emph{input} \code{file}.}
}
\value{
\itemize{
\item \code{read_drive_string()}: a UTF-8 encoded string
\item \code{read_drive_raw()}: a \code{\link[=raw]{raw()}} vector
}
}
\description{
These functions return the content of a Drive file as either a
string or raw bytes. You will likely need to do additional work to parse
the content into a useful R object.
\code{\link[=drive_download]{drive_download()}} is the more generally useful function, but for certain
file types, such as comma-separated values (MIME type \code{text/csv}), it can
be handy to read data directly from Google Drive and avoid writing to disk.
Just as for \code{\link[=drive_download]{drive_download()}}, native Google file types, such as Google
Sheets or Docs, must be exported as a conventional MIME type. See the help
for \code{\link[=drive_download]{drive_download()}} for more.
}
\examples{
\dontshow{if (drive_has_token()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf}
# comma-separated values --> data.frame or tibble
(chicken_csv <- drive_example_remote("chicken.csv"))
chicken_csv \%>\%
drive_read_string() \%>\%
read.csv(text = .)
# Google Doc --> character vector
(chicken_doc <- drive_example_remote("chicken_doc"))
chicken_doc \%>\%
# NOTE: we must specify an export MIME type
drive_read_string(type = "text/plain") \%>\%
strsplit(split = "(\r\n|\r|\n)") \%>\%
.[[1]]
\dontshow{\}) # examplesIf}
}
googledrive/man/drive_share.Rd 0000644 0001762 0000144 00000007116 14405753133 016127 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/drive_share.R
\name{drive_share}
\alias{drive_share}
\alias{drive_share_anyone}
\title{Share Drive files}
\usage{
drive_share(
file,
role = c("reader", "commenter", "writer", "fileOrganizer", "owner", "organizer"),
type = c("user", "group", "domain", "anyone"),
...,
verbose = deprecated()
)
drive_share_anyone(file, verbose = deprecated())
}
\arguments{
\item{file}{Something that identifies the file(s) of interest on your Google
Drive. Can be a character vector of names/paths, a character vector of file
ids or URLs marked with \code{\link[=as_id]{as_id()}}, or a \code{\link{dribble}}.}
\item{role}{Character. The role to grant. Must be one of:
\itemize{
\item owner (not allowed in shared drives)
\item organizer (applies to shared drives)
\item fileOrganizer (applies to shared drives)
\item writer
\item commenter
\item reader
}}
\item{type}{Character. Describes the grantee. Must be one of:
\itemize{
\item user
\item group
\item domain
\item anyone
}}
\item{...}{Name-value pairs to add to the API request. This is where you
provide additional information, such as the \code{emailAddress} (when grantee
\code{type} is \code{"group"} or \code{"user"}) or the \code{domain} (when grantee type is
\code{"domain"}). Read the API docs linked below for more details.}
\item{verbose}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} This logical argument to
individual googledrive functions is deprecated. To globally suppress
googledrive messaging, use \code{options(googledrive_quiet = TRUE)} (the default
behaviour is to emit informational messages). To suppress messaging in a
more limited way, use the helpers \code{\link[=local_drive_quiet]{local_drive_quiet()}} or
\code{\link[=with_drive_quiet]{with_drive_quiet()}}.}
}
\value{
An object of class \code{\link{dribble}}, a tibble with one row per file.
There will be extra columns, \code{shared} and
\code{permissions_resource}.
}
\description{
Grant individuals or other groups access to files, including permission to
read, comment, or edit. The returned \code{\link{dribble}} will have extra columns,
\code{shared} and \code{permissions_resource}. Read more in \code{\link[=drive_reveal]{drive_reveal()}}.
\code{drive_share_anyone()} is a convenience wrapper for a common special case:
"make this \code{file} readable by 'anyone with a link'".
}
\examples{
\dontshow{if (drive_has_token()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf}
# Create a file to share
file <- drive_example_remote("chicken_doc") \%>\%
drive_cp(name = "chicken-share.txt")
# Let a specific person comment
file <- file \%>\%
drive_share(
role = "commenter",
type = "user",
emailAddress = "susan@example.com"
)
# Let a different specific person edit and customize the email notification
file <- file \%>\%
drive_share(
role = "writer",
type = "user",
emailAddress = "carol@example.com",
emailMessage = "Would appreciate your feedback on this!"
)
# Let anyone read the file
file <- file \%>\%
drive_share(role = "reader", type = "anyone")
# Single-purpose wrapper function for this
drive_share_anyone(file)
# Clean up
drive_rm(file)
\dontshow{\}) # examplesIf}
}
\seealso{
Wraps the \code{permissions.create} endpoint:
\itemize{
\item \url{https://developers.google.com/drive/api/v3/reference/permissions/create}
}
Drive roles and permissions are described here:
\itemize{
\item \url{https://developers.google.com/drive/api/v3/ref-roles}
}
}
googledrive/man/drive_fields.Rd 0000644 0001762 0000144 00000003531 14405753133 016270 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/drive_fields.R
\name{drive_fields}
\alias{drive_fields}
\alias{prep_fields}
\title{Request partial resources}
\usage{
drive_fields(fields = NULL, resource = "files")
prep_fields(fields, resource = "files")
}
\arguments{
\item{fields}{Character vector of field names. If \code{resource = "files"}, they
are checked for validity. Otherwise, they are passed through.}
\item{resource}{Character, naming the API resource of interest. Currently,
only the Files resource is anticipated.}
}
\value{
\code{drive_fields()}: Character vector of field names. \code{prep_fields()}: a
string.
}
\description{
You may be able to improve the performance of your API calls by
requesting only the metadata that you actually need. This function is
primarily for internal use and is currently focused on the \href{https://developers.google.com/drive/api/v3/reference/files}{Files resource}. Note
that high-level googledrive functions assume that the \code{name}, \code{id}, and
\code{kind} fields are included, at a bare minimum. Assuming that \code{resource = "files"} (the default), input provided via \code{fields} is checked for validity
against the known field names and the validated fields are returned. To see
a tibble containing all possible fields and a short description of each,
call \code{drive_fields(expose())}.
\code{prep_fields()} prepares fields for inclusion as query
parameters.
}
\examples{
# get a tibble of all fields for the Files resource + indicator of defaults
drive_fields(expose())
# invalid fields are removed and throw warning
drive_fields(c("name", "parents", "ownedByMe", "pancakes!"))
# prepare fields for query
prep_fields(c("name", "parents", "kind"))
}
\seealso{
\href{https://developers.google.com/drive/api/v3/performance}{Improve performance}, in
the Drive API documentation.
}
googledrive/man/drive_reveal.Rd 0000644 0001762 0000144 00000013760 14413426163 016304 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/drive_reveal.R
\name{drive_reveal}
\alias{drive_reveal}
\title{Add a new column of Drive file information}
\usage{
drive_reveal(file, what = c("path", "permissions", "published", "parent"))
}
\arguments{
\item{file}{Something that identifies the file(s) of interest on your Google
Drive. Can be a character vector of names/paths, a character vector of file
ids or URLs marked with \code{\link[=as_id]{as_id()}}, or a \code{\link{dribble}}.}
\item{what}{Character, describing the type of info you want to add. These
values get special handling (more details below):
\itemize{
\item \code{path}
\item \code{permissions}
\item \code{published}
\item \code{parent}
}
You can also request any property in the \code{drive_resource} column by name.
The request can be in \code{camelCase} or \code{snake_case}, but the new column name
will always be \code{snake_case}. Some examples of \code{what}:
\itemize{
\item \code{mime_type} (or \code{mimeType})
\item \code{trashed}
\item \code{starred}
\item \code{description}
\item \code{version}
\item \code{web_view_link} (or \code{webViewLink})
\item \code{modified_time} (or \code{modifiedTime})
\item \code{created_time} (or \code{createdTime})
\item \code{owned_by_me} (or \code{ownedByMe})
\item \code{size}
\item \code{quota_bytes_used} (or \code{quotaBytesUsed})
}}
}
\value{
An object of class \code{\link{dribble}}, a tibble with one row per file.
The additional info requested via \code{what}
appears in one (or more) extra columns.
}
\description{
\code{drive_reveal()} adds extra information about your Drive files that is not
readily available in the default \code{\link{dribble}} produced by googledrive. Why is
this info not always included in the default \code{dribble}?
\itemize{
\item You don't always care about it. There is a lot of esoteric information in
the \code{drive_resource} that has little value for most users.
\item It might be "expensive" to get this information and put it into a usable
form. For example, revealing a file's \code{"path"}, \code{"permissions"}, or
\code{"published"} status all require additional API calls.
}
\code{drive_reveal()} can also \strong{hoist} any property out of the \code{drive_resource}
list-column, when the property's name is passed as the \code{what} argument. The
resulting new column is simplified if it is easy to do so, e.g., if the
individual elements are all string or logical. If \code{what} extracts a
date-time, we return \code{\link[=DateTimeClasses]{POSIXct}}. Otherwise, you'll get a
list-column. If this makes you sad, consider using \code{tidyr::hoist()} instead.
It is more powerful due to a richer "plucking specification" and its \code{ptype}
and \code{transform} arguments. Another useful function is
\code{tidyr::unnest_wider()}.
}
\section{File path}{
When \code{what = "path"} the \code{\link{dribble}} gains a character column holding each
file's path. This can be \emph{very slow}, so use with caution.
The example path \verb{~/a/b/} illustrates two conventions used in googledrive:
\itemize{
\item The leading \verb{~/} means that the folder \code{a} is located in the current
user's "My Drive" root folder.
\item The trailing \code{/} means that \code{b}, located in \code{a}, is \emph{a folder or a folder
shortcut}.
}
}
\section{Permissions}{
When \code{what = "permissions"} the \code{\link{dribble}} gains a logical column \code{shared}
that indicates whether a file is shared and a new list-column
\code{permissions_resource} containing lists of
\href{https://developers.google.com/drive/api/v3/reference/permissions}{Permissions resources}.
}
\section{Publishing}{
When \code{what = "published"} the \code{\link{dribble}} gains a logical column
\code{published} that indicates whether a file is published and a new list-column
\code{revision_resource} containing lists of
\href{https://developers.google.com/drive/api/v3/reference/revisions}{Revisions resources}.
}
\section{Parent}{
When \code{what = "parent"} the \code{\link{dribble}} gains a character column \code{id_parent}
that is the file id of this item's parent folder. This information is
available in the \code{drive_resource}, but can't just be hoisted out:
\itemize{
\item Google Drive used to allow files to have multiple parents, but this is no
longer supported and googledrive now assumes this is impossible. However,
we have seen (very old) files that still have >1 parent folder. If we see
this we message about it and drop all but the first parent.
\item The \code{parents} property in \code{drive_resource} has an "extra" layer of nesting
and needs to be flattened.
}
If you really want the raw \code{parents} property, call \code{drive_reveal(what = "parents")}.
}
\examples{
\dontshow{if (drive_has_token()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf}
# Get a few of your files
files <- drive_find(n_max = 10, trashed = NA)
# the "special" cases that require additional API calls and can be slow
drive_reveal(files, "path")
drive_reveal(files, "permissions")
drive_reveal(files, "published")
# a "special" case of digging info out of `drive_resource`, then processing
# a bit
drive_reveal(files, "parent")
# the "simple" cases of digging info out of `drive_resource`
drive_reveal(files, "trashed")
drive_reveal(files, "mime_type")
drive_reveal(files, "starred")
drive_reveal(files, "description")
drive_reveal(files, "version")
drive_reveal(files, "web_view_link")
drive_reveal(files, "modified_time")
drive_reveal(files, "created_time")
drive_reveal(files, "owned_by_me")
drive_reveal(files, "size")
drive_reveal(files, "quota_bytes_used")
# 'root' is a special file id that represents your My Drive root folder
drive_get(id = "root") \%>\%
drive_reveal("path")
\dontshow{\}) # examplesIf}
}
\seealso{
To learn more about the properties present in the metadata of a
Drive file (which is what's in the \code{drive_resource} list-column of a
\code{\link{dribble}}), see the API docs:
\itemize{
\item \url{https://developers.google.com/drive/api/v3/reference/files#resource-representations}
}
}
googledrive/man/drive_examples.Rd 0000644 0001762 0000144 00000003173 14413426163 016641 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/drive_examples.R
\name{drive_examples}
\alias{drive_examples}
\alias{drive_examples_local}
\alias{drive_examples_remote}
\alias{drive_example_local}
\alias{drive_example_remote}
\title{Example files}
\usage{
drive_examples_local(matches)
drive_examples_remote(matches)
drive_example_local(matches)
drive_example_remote(matches)
}
\arguments{
\item{matches}{A regular expression that matches the name of the desired
example file(s). This argument is optional for the plural forms
(\code{drive_examples_local()} and \code{drive_examples_remote()}) and, if provided,
multiple matches are allowed. The single forms (\code{drive_example_local()} and
\code{drive_example_remote()}) require this argument and require that there is
exactly one match.}
}
\value{
\itemize{
\item For \code{drive_example_local()} and \code{drive_examples_local()}, one or more local
filepaths.
\item For \code{drive_example_remote()} and \code{drive_examples_remote()}, a \code{dribble}.
}
}
\description{
googledrive makes a variety of example files -- both local and remote --
available for use in examples and reprexes. These functions help you access
the example files. See \code{vignette("example-files", package = "googledrive")}
for more.
}
\examples{
drive_examples_local() \%>\% basename()
drive_examples_local("chicken") \%>\% basename()
drive_example_local("imdb")
\dontshow{if (drive_has_token()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf}
drive_examples_remote()
drive_examples_remote("chicken")
drive_example_remote("chicken_doc")
\dontshow{\}) # examplesIf}
}
googledrive/man/drive_rename.Rd 0000644 0001762 0000144 00000005672 14413426163 016300 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/drive_rename.R
\name{drive_rename}
\alias{drive_rename}
\title{Rename a Drive file}
\usage{
drive_rename(file, name = NULL, overwrite = NA, verbose = deprecated())
}
\arguments{
\item{file}{Something that identifies the file of interest on your Google
Drive. Can be a name or path, a file id or URL marked with \code{\link[=as_id]{as_id()}}, or a
\code{\link{dribble}}.}
\item{name}{Character. Name you would like the file to have.}
\item{overwrite}{Logical, indicating whether to check for a pre-existing file
at the targetted "filepath". The quotes around "filepath" refer to the fact
that Drive does not impose a 1-to-1 relationship between filepaths and files,
like a typical file system; read more about that in \code{\link[=drive_get]{drive_get()}}.
\itemize{
\item \code{NA} (default): Just do the operation, even if it results in multiple
files with the same filepath.
\item \code{TRUE}: Check for a pre-existing file at the filepath. If there is
zero or one, move a pre-existing file to the trash, then carry on. Note
that the new file does not inherit any properties from the old one, such
as sharing or publishing settings. It will have a new file ID. An error is
thrown if two or more pre-existing files are found.
\item \code{FALSE}: Error if there is any pre-existing file at the filepath.
}
Note that existence checks, based on filepath, are expensive operations, i.e.
they require additional API calls.}
\item{verbose}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} This logical argument to
individual googledrive functions is deprecated. To globally suppress
googledrive messaging, use \code{options(googledrive_quiet = TRUE)} (the default
behaviour is to emit informational messages). To suppress messaging in a
more limited way, use the helpers \code{\link[=local_drive_quiet]{local_drive_quiet()}} or
\code{\link[=with_drive_quiet]{with_drive_quiet()}}.}
}
\value{
An object of class \code{\link{dribble}}, a tibble with one row per file.
}
\description{
This is a wrapper for \code{\link[=drive_mv]{drive_mv()}} that only renames a file.
If you would like to rename AND move the file, see \code{\link[=drive_mv]{drive_mv()}}.
}
\examples{
\dontshow{if (drive_has_token()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf}
# Create a file to rename
file <- drive_create("file-to-rename")
# Rename it
file <- drive_rename(file, name = "renamed-file")
# `overwrite = FALSE` errors if something already exists at target filepath
# THIS WILL ERROR!
drive_create("name-squatter-rename")
drive_rename(file, name = "name-squatter-rename", overwrite = FALSE)
# `overwrite = TRUE` moves the existing item to trash, then proceeds
file <- drive_rename(file, name = "name-squatter-rename", overwrite = TRUE)
# Clean up
drive_rm(file)
\dontshow{\}) # examplesIf}
}
googledrive/man/dribble.Rd 0000644 0001762 0000144 00000002721 14070147664 015240 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/dribble.R
\name{dribble}
\alias{dribble}
\title{dribble object}
\description{
googledrive stores the metadata for one or more Drive files or
shared drives as a \code{dribble}. It is a "Drive
\link[tibble:tibble-package]{tibble}" with one row per file or shared drive
and, at a minimum, these columns:
\itemize{
\item \code{name}: a character column containing file or shared drive names
\item \code{id}: a character column of file or shared drive ids
\item \code{drive_resource}: a list-column, each element of which is either a
\href{https://developers.google.com/drive/api/v3/reference/files#resource-representations}{Files resource}
or a \href{https://developers.google.com/drive/api/v3/reference/drives#resource-representations}{Drives resource}
object. Note there is no guarantee that all documented fields are always
present. We do check if the \code{kind} field is present and equal to one of
\code{drive#file} or \code{drive#drive}.
}
The \code{dribble} format is handy because it exposes the file name,
which is good for humans, but keeps it bundled with the file's unique id
and other metadata, which are needed for API calls.
In general, the \code{dribble} class will be retained even after
manipulation, as long as the required variables are present and of the
correct type. This works best for manipulations via the dplyr and vctrs
packages.
}
\seealso{
\code{\link[=as_dribble]{as_dribble()}}
}
googledrive/man/shared_drive_update.Rd 0000644 0001762 0000144 00000003324 14413426163 017631 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/shared_drive_update.R
\name{shared_drive_update}
\alias{shared_drive_update}
\title{Update a shared drive}
\usage{
shared_drive_update(shared_drive, ...)
}
\arguments{
\item{shared_drive}{Anything that identifies one specific shared drive: its
name, its id or URL marked with \code{\link[=as_id]{as_id()}}, or a \code{\link{dribble}}. The value
provided to \code{shared_drive} is pre-processed with \code{\link[=as_shared_drive]{as_shared_drive()}}. Read
more about \link[=shared_drives]{shared drives}.}
\item{...}{Properties to set in \code{name = value} form. See the "Request
body" section of the Drive API docs for this endpoint.}
}
\value{
An object of class \code{\link{dribble}}, a tibble with one row per shared drive.
}
\description{
Update the metadata of an existing shared drive, e.g. its background image or
theme.
A shared drive supports files owned by an organization rather than an
individual user. Shared drives follow different sharing and ownership models
from a specific user's "My Drive". Shared drives are the successors to the
earlier concept of Team Drives. Learn more about \link[=shared_drives]{shared drives}.
}
\examples{
\dontrun{
# create a shared drive
sd <- shared_drive_create("I love themes!")
# see the themes available to you
themes <- drive_about()$driveThemes
purrr::map_chr(themes, "id")
# cycle through various themes for this shared drive
sd <- shared_drive_update(sd, themeId = "bok_choy")
sd <- shared_drive_update(sd, themeId = "cocktails")
# Clean up
shared_drive_rm(sd)
}
}
\seealso{
Wraps the \code{drives.update} endpoint:
\itemize{
\item \url{https://developers.google.com/drive/api/v3/reference/drives/update}
}
}
googledrive/man/dribble-checks.Rd 0000644 0001762 0000144 00000002712 14070147664 016476 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/dribble.R
\name{dribble-checks}
\alias{dribble-checks}
\alias{is_dribble}
\alias{no_file}
\alias{single_file}
\alias{some_files}
\alias{confirm_dribble}
\alias{confirm_single_file}
\alias{confirm_some_files}
\alias{is_folder}
\alias{is_shortcut}
\alias{is_folder_shortcut}
\alias{is_native}
\alias{is_parental}
\alias{is_mine}
\alias{is_shared_drive}
\title{Check facts about a dribble}
\usage{
is_dribble(d)
no_file(d)
single_file(d)
some_files(d)
confirm_dribble(d)
confirm_single_file(d)
confirm_some_files(d)
is_folder(d)
is_shortcut(d)
is_folder_shortcut(d)
is_native(d)
is_parental(d)
is_mine(d)
is_shared_drive(d)
}
\arguments{
\item{d}{A \code{\link{dribble}}.}
}
\description{
Sometimes you need to check things about a \code{\link{dribble}}` or about the files it
represents, such as:
\itemize{
\item Is it even a dribble?
\item Size: Does the dribble hold exactly one file? At least one file? No file?
\item File type: Is this file a folder?
\item File ownership and access: Is it mine? Published? Shared?
}
}
\examples{
\dontshow{if (drive_has_token()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf}
## most of us have multiple files or folders on Google Drive
d <- drive_find()
is_dribble(d)
no_file(d)
single_file(d)
some_files(d)
# this will error
# confirm_single_file(d)
confirm_some_files(d)
is_folder(d)
is_mine(d)
\dontshow{\}) # examplesIf}
}
googledrive/man/drive_token.Rd 0000644 0001762 0000144 00000002347 14070147664 016152 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/drive_auth.R
\name{drive_token}
\alias{drive_token}
\title{Produce configured token}
\usage{
drive_token()
}
\value{
A \code{request} object (an S3 class provided by \link[httr:httr-package]{httr}).
}
\description{
For internal use or for those programming around the Drive API.
Returns a token pre-processed with \code{\link[httr:config]{httr::config()}}. Most users
do not need to handle tokens "by hand" or, even if they need some
control, \code{\link[=drive_auth]{drive_auth()}} is what they need. If there is no current
token, \code{\link[=drive_auth]{drive_auth()}} is called to either load from cache or
initiate OAuth2.0 flow.
If auth has been deactivated via \code{\link[=drive_deauth]{drive_deauth()}}, \code{drive_token()}
returns \code{NULL}.
}
\examples{
\dontshow{if (drive_has_token()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf}
req <- request_generate(
"drive.files.get",
list(fileId = "abc"),
token = drive_token()
)
req
\dontshow{\}) # examplesIf}
}
\seealso{
Other low-level API functions:
\code{\link{drive_has_token}()},
\code{\link{request_generate}()},
\code{\link{request_make}()}
}
\concept{low-level API functions}
googledrive/man/shortcut_create.Rd 0000644 0001762 0000144 00000007416 14405753133 017035 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/shortcut.R
\name{shortcut_create}
\alias{shortcut_create}
\title{Create a shortcut to a Drive file}
\usage{
shortcut_create(file, path = NULL, name = NULL, overwrite = NA)
}
\arguments{
\item{file}{Something that identifies the file of interest on your Google
Drive. Can be a name or path, a file id or URL marked with \code{\link[=as_id]{as_id()}}, or a
\code{\link{dribble}}.}
\item{path}{Target destination for the new shortcut, i.e. a folder or a
shared drive. Can be given as an actual path (character), a file id or URL
marked with \code{\link[=as_id]{as_id()}}, or a \code{\link{dribble}}. Defaults to your "My Drive" root
folder. If \code{path} is a shortcut to a folder, it is automatically resolved
to its target folder.}
\item{name}{Character, new shortcut name if not specified as part of
\code{path}. This will force \code{path} to be interpreted as a folder, even if it
is character and lacks a trailing slash. By default, the shortcut starts out with the same name as
the target \code{file}. As a consequence, if you want to use
\code{overwrite = TRUE} or \code{overwrite = FALSE}, you \strong{must} explicitly
specify the shortcut's \code{name}.}
\item{overwrite}{Logical, indicating whether to check for a pre-existing file
at the targetted "filepath". The quotes around "filepath" refer to the fact
that Drive does not impose a 1-to-1 relationship between filepaths and files,
like a typical file system; read more about that in \code{\link[=drive_get]{drive_get()}}.
\itemize{
\item \code{NA} (default): Just do the operation, even if it results in multiple
files with the same filepath.
\item \code{TRUE}: Check for a pre-existing file at the filepath. If there is
zero or one, move a pre-existing file to the trash, then carry on. Note
that the new file does not inherit any properties from the old one, such
as sharing or publishing settings. It will have a new file ID. An error is
thrown if two or more pre-existing files are found.
\item \code{FALSE}: Error if there is any pre-existing file at the filepath.
}
Note that existence checks, based on filepath, are expensive operations, i.e.
they require additional API calls.}
}
\value{
An object of class \code{\link{dribble}}, a tibble with one row per file.
}
\description{
Creates a shortcut to the target Drive \code{file}, which could be a folder. A
Drive shortcut functions like a symbolic or "soft" link and is primarily
useful for creating a specific Drive user experience in the browser, i.e. to
make a Drive file or folder appear in more than 1 place. Shortcuts are a
relatively new feature in Drive; they were introduced when Drive stopped
allowing a file to have more than 1 parent folder.
}
\examples{
\dontshow{if (drive_has_token()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf}
# Target one of the official example files
(src_file <- drive_example_remote("chicken_sheet"))
# Create a shortcut in the default location with the default name
sc1 <- shortcut_create(src_file)
# This shortcut could now be moved, renamed, etc.
# Create a shortcut in the default location with a custom name
sc2 <- src_file \%>\%
shortcut_create(name = "chicken_sheet_second_shortcut")
# Create a folder, then put a shortcut there, with default name
folder <- drive_mkdir("chicken_sheet_shortcut_folder")
sc3 <- src_file \%>\%
shortcut_create(folder)
# Look at all these shortcuts
(dat <- drive_find("chicken_sheet", type = "shortcut"))
# Confirm the shortcuts all target the original file
dat <- dat \%>\%
drive_reveal("shortcut_details")
purrr::map_chr(dat$shortcut_details, "targetId")
as_id(src_file)
# Clean up
drive_rm(sc1, sc2, sc3, folder)
\dontshow{\}) # examplesIf}
}
\seealso{
\itemize{
\item \url{https://developers.google.com/drive/api/v3/shortcuts}
}
}
googledrive/man/shared_drives.Rd 0000644 0001762 0000144 00000012661 14413426163 016456 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/shared_drives.R
\name{shared_drives}
\alias{shared_drives}
\title{Access shared drives}
\description{
A shared drive supports files owned by an organization rather than an
individual user. Shared drives follow different sharing and ownership models
from a specific user's "My Drive". Shared drives are the successors to the
earlier concept of Team Drives.
How to capture a shared drive or files/folders that live on a
shared drive for downstream use:
\itemize{
\item \code{\link[=shared_drive_find]{shared_drive_find()}} and \code{\link[=shared_drive_get]{shared_drive_get()}} return a \code{\link{dribble}} with
metadata on shared drives themselves. You will need this in order to use a
shared drive in certain file operations. For example, you can specify a
shared drive as the parent folder via the \code{path} argument for upload, move,
copy, etc. In that context, the id of a shared drive functions like the id of
its top-level or root folder.
\item \code{\link[=drive_find]{drive_find()}} and \code{\link[=drive_get]{drive_get()}} return a \code{\link{dribble}} with metadata on
files, including folders. Both can be directed to search for files on shared
drives using the optional arguments \code{shared_drive} or \code{corpus} (documented
below).
}
Regard the functions mentioned above as the official "port of
entry" for working with shared drives. Use these functions to capture your
target(s) in a \code{\link{dribble}} to pass along to other googledrive functions.
The flexibility to refer to files by name or path does not apply as broadly
to shared drives. While it's always a good idea to get things into a
\code{\link{dribble}} early, for shared drives it's often required.
}
\section{Specific shared drive}{
To search one specific shared drive, pass its name, marked id, or
\code{\link{dribble}} to \code{shared_drive} somewhere in the call, like so:
\if{html}{\out{
}}
The value provided to \code{shared_drive} is pre-processed with
\code{\link[=as_shared_drive]{as_shared_drive()}}.
}
\section{Other collections}{
To search other collections, pass the \code{corpus} parameter somewhere in the
call, like so:
\if{html}{\out{
}}\preformatted{drive_find(..., corpus = "user")
drive_find(..., corpus = "allDrives")
drive_find(..., corpus = "domain")
}\if{html}{\out{
}}
Possible values of \code{corpus} and what they mean:
\itemize{
\item \code{"user"}: Queries files that the user has accessed, including both shared
drive and My Drive files.
\item \code{"drive"}: Queries all items in the shared drive specified via
\code{shared_drive}. googledrive automatically fills this in whenever
\code{shared_drive} is not \code{NULL}.
\item \code{"allDrives"}: Queries files that the user has accessed and all shared
drives in which they are a member. Note that the response may include
\code{incompleteSearch : true}, indicating that some corpora were not searched
for this request (currently, googledrive does not surface this). Prefer
\code{"user"} or \code{"drive"} to \code{"allDrives"} for efficiency.
\item \code{"domain"}: Queries files that are shared to the domain, including both
shared drive and My Drive files.
}
}
\section{Google blogs and docs}{
Here is some of the best official Google reading about shared drives:
\itemize{
\item \href{https://workspaceupdates.googleblog.com/2019/04/shared-drives.html}{Team Drives is being renamed to shared drives} from Google Workspace blog
\item \href{https://cloud.google.com/blog/products/application-development/upcoming-changes-to-the-google-drive-api-and-google-picker-api}{Upcoming changes to the Google Drive API and Google Picker API} from the Google Cloud blog
\item \url{https://developers.google.com/drive/api/v3/about-shareddrives}
\item \url{https://developers.google.com/drive/api/v3/shared-drives-diffs}
\item Get started with shared drives: \verb{https://support.google.com/a/users/answer/9310351} from Google Workspace Learning Center
\item Best practices for shared drives: \verb{https://support.google.com/a/users/answer/9310156} from Google Workspace Learning Center
}
}
\section{API docs}{
googledrive implements shared drive support as outlined here:
\itemize{
\item \url{https://developers.google.com/drive/api/v3/enable-shareddrives}
}
Users shouldn't need to know any of this, but here are details for the
curious. The extra information needed to search shared drives consists of the
following query parameters:
\itemize{
\item \code{corpora}: Where to search? Formed from googledrive's \code{corpus} argument.
\item \code{driveId}: The id of a specific shared drive. Only allowed -- and also
absolutely required -- when \code{corpora = "drive"}. When user specifies a
\code{shared_drive}, googledrive sends its id and also infers that \code{corpora}
should be set to \code{"drive"}.
\item \code{includeItemsFromAllDrives}: Do you want to see shared drive items?
Obviously, this should be \code{TRUE} and googledrive sends this whenever shared
drive parameters are detected.
\item \code{supportsAllDrives}: Does the sending application (googledrive, in this
case) know about shared drive? Obviously, this should be \code{TRUE} and
googledrive sends it for all applicable endpoints, all the time.
}
}
googledrive/man/as_dribble.Rd 0000644 0001762 0000144 00000005012 14413426163 015712 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/dribble.R
\name{as_dribble}
\alias{as_dribble}
\title{Coerce to a \code{dribble}}
\usage{
as_dribble(x, ...)
}
\arguments{
\item{x}{A vector of Drive file paths, a vector of file ids marked
with \code{\link[=as_id]{as_id()}}, a list of Files Resource objects, or a suitable data
frame.}
\item{...}{Other arguments passed down to methods. (Not used.)}
}
\description{
Converts various representations of Google Drive files into a \code{\link{dribble}},
the object used by googledrive to hold Drive file metadata. Files can be
specified via:
\itemize{
\item File path. File name is an important special case.
\item File id. Mark with \code{\link[=as_id]{as_id()}} to distinguish from file path.
\item Data frame or \code{\link{dribble}}. Once you've successfully used googledrive to
identify the files of interest, you'll have a \code{\link{dribble}}. Pass it into
downstream functions.
\item List representing \href{https://developers.google.com/drive/api/v3/reference/files}{Files resource}
objects. Mostly for internal use.
}
This is a generic function.
For maximum clarity, get your files into a \code{\link{dribble}} (or capture file id)
as early as possible. When specifying via path, it's best to include the
trailing slash when you're targeting a folder. If you want the folder \code{foo},
say \verb{foo/}, not \code{foo}.
Some functions, such as \code{\link[=drive_cp]{drive_cp()}}, \code{\link[=drive_mkdir]{drive_mkdir()}}, \code{\link[=drive_mv]{drive_mv()}}, and
\code{\link[=drive_upload]{drive_upload()}}, can accept the new file or folder name as the last part of
\code{path}, when \code{name} is not given. But if you say \code{a/b/c} (no trailing slash)
and a folder \verb{a/b/c/} already exists, it's unclear what you want. A file
named \code{c} in \verb{a/b/} or a file with default name in \verb{a/b/c/}? You get an
error and must make your intent clear.
}
\examples{
\dontshow{if (drive_has_token()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf}
# create some files for us to re-discover by name or filepath
alfa <- drive_create("alfa", type = "folder")
bravo <- drive_create("bravo", path = alfa)
# as_dribble() can work with file names or paths
as_dribble("alfa")
as_dribble("bravo")
as_dribble("alfa/bravo")
as_dribble(c("alfa", "alfa/bravo"))
# specify the file id (substitute a real file id of your own!)
# as_dribble(as_id("0B0Gh-SuuA2nTOGZVTXZTREgwZ2M"))
# Clean up
drive_find("alfa") \%>\% drive_rm()
\dontshow{\}) # examplesIf}
}
googledrive/man/drive_rm.Rd 0000644 0001762 0000144 00000004124 14405753133 015437 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/drive_rm.R
\name{drive_rm}
\alias{drive_rm}
\title{Delete files from Drive}
\usage{
drive_rm(..., verbose = deprecated())
}
\arguments{
\item{...}{One or more Drive files, specified in any valid way, i.e. as a
\code{\link{dribble}}, by name or path, or by file id or URL marked with \code{\link[=as_id]{as_id()}}. Or
any combination thereof. Elements are processed with \code{\link[=as_dribble]{as_dribble()}} and
row-bound prior to deletion.}
\item{verbose}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} This logical argument to
individual googledrive functions is deprecated. To globally suppress
googledrive messaging, use \code{options(googledrive_quiet = TRUE)} (the default
behaviour is to emit informational messages). To suppress messaging in a
more limited way, use the helpers \code{\link[=local_drive_quiet]{local_drive_quiet()}} or
\code{\link[=with_drive_quiet]{with_drive_quiet()}}.}
}
\value{
Logical vector, indicating whether the delete succeeded.
}
\description{
Caution: this will permanently delete your files! For a safer, reversible
option, see \code{\link[=drive_trash]{drive_trash()}}.
}
\examples{
\dontshow{if (drive_has_token()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf}
# Target one of the official example files to copy (then remove)
(src_file <- drive_example_remote("chicken.txt"))
# Create a copy, then remove it by name
src_file \%>\%
drive_cp(name = "chicken-rm.txt")
drive_rm("chicken-rm.txt")
# Create several more copies
x1 <- src_file \%>\%
drive_cp(name = "chicken-abc.txt")
drive_cp(src_file, name = "chicken-def.txt")
x2 <- src_file \%>\%
drive_cp(name = "chicken-ghi.txt")
# Remove the copies all at once, specified in different ways
drive_rm(x1, "chicken-def.txt", as_id(x2))
\dontshow{\}) # examplesIf}
}
\seealso{
Wraps the \code{files.delete} endpoint:
\itemize{
\item \url{https://developers.google.com/drive/api/v3/reference/files/delete}
}
}
googledrive/man/drive_find.Rd 0000644 0001762 0000144 00000016371 14413426163 015747 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/drive_find.R
\name{drive_find}
\alias{drive_find}
\title{Find files on Google Drive}
\usage{
drive_find(
pattern = NULL,
trashed = FALSE,
type = NULL,
n_max = Inf,
shared_drive = NULL,
corpus = NULL,
...,
verbose = deprecated(),
team_drive = deprecated()
)
}
\arguments{
\item{pattern}{Character. If provided, only the items whose names match this
regular expression are returned. This is implemented locally on the results
returned by the API.}
\item{trashed}{Logical. Whether to search files that are not in the trash
(\code{trashed = FALSE}, the default), only files that are in the trash
(\code{trashed = TRUE}), or to search regardless of trashed status (\code{trashed = NA}).}
\item{type}{Character. If provided, only files of this type will be returned.
Can be anything that \code{\link[=drive_mime_type]{drive_mime_type()}} knows how to handle. This is
processed by googledrive and sent as a query parameter.}
\item{n_max}{Integer. An upper bound on the number of items to return. This
applies to the results requested from the API, which may be further
filtered locally, via the \code{pattern} argument.}
\item{shared_drive}{Anything that identifies one specific shared drive: its
name, its id or URL marked with \code{\link[=as_id]{as_id()}}, or a \code{\link{dribble}}. The value
provided to \code{shared_drive} is pre-processed with \code{\link[=as_shared_drive]{as_shared_drive()}}. Read
more about \link[=shared_drives]{shared drives}.}
\item{corpus}{Character, specifying which collections of items to search.
Relevant to those who work with shared drives and/or Google Workspace
domains. If specified, must be one of \code{"user"}, \code{"drive"} (requires that
\code{shared_drive} also be specified), \code{"allDrives"}, or \code{"domain"}. Read more
about \link[=shared_drives]{shared drives}.}
\item{...}{Other parameters to pass along in the request. The most likely
candidate is \code{q}. See below and the API's
\href{https://developers.google.com/drive/api/v3/search-files}{Search for files and folders guide}.}
\item{verbose}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} This logical argument to
individual googledrive functions is deprecated. To globally suppress
googledrive messaging, use \code{options(googledrive_quiet = TRUE)} (the default
behaviour is to emit informational messages). To suppress messaging in a
more limited way, use the helpers \code{\link[=local_drive_quiet]{local_drive_quiet()}} or
\code{\link[=with_drive_quiet]{with_drive_quiet()}}.}
\item{team_drive}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} Google Drive and the
Drive API have replaced Team Drives with shared drives.}
}
\value{
An object of class \code{\link{dribble}}, a tibble with one row per file.
}
\description{
This is the closest googledrive function to what you can do at
\url{https://drive.google.com}: by default, you just get a listing of your files.
You can also search in various ways, e.g., filter by file type or ownership
or work with \link[=shared_drives]{shared drives}. This is a very powerful
function. Together with the more specific \code{\link[=drive_get]{drive_get()}}, this is the main way
to identify files to target for downstream work. If you know you want to
search within a specific folder or shared drive, use \code{\link[=drive_ls]{drive_ls()}}.
}
\section{File type}{
The \code{type} argument is pre-processed with \code{\link[=drive_mime_type]{drive_mime_type()}}, so you can
use a few shortcuts and file extensions, in addition to full-blown MIME
types. googledrive forms a search clause to pass to \code{q}.
}
\section{Search parameters}{
Do advanced search on file properties by providing search clauses to the
\code{q} parameter that is passed to the API via \code{...}. Multiple \code{q} clauses or
vector-valued \code{q} are combined via 'and'.
}
\section{Trash}{
By default, \code{drive_find()} sets \code{trashed = FALSE} and does not include
files in the trash. Literally, it adds \code{q = "trashed = false"} to the
query. To search \emph{only} the trash, set \code{trashed = TRUE}. To see files
regardless of trash status, set \code{trashed = NA}, which adds
\code{q = "(trashed = true or trashed = false)"} to the query.
}
\section{Sort order}{
By default, \code{drive_find()} sends \code{orderBy = "recency desc"}, so the top
files in your result have high "recency" (whatever that means). To suppress
sending \code{orderBy} at all, do \code{drive_find(orderBy = NULL)}. The \code{orderBy}
parameter accepts sort keys in addition to \code{recency}, which are documented
in the \href{https://developers.google.com/drive/api/v3/reference/files/list}{\code{files.list} endpoint}.
googledrive translates a snake_case specification of \code{order_by} into the
lowerCamel form, \code{orderBy}.
}
\section{Shared drives and domains}{
If you work with shared drives and/or Google Workspace, you can apply your
search query to collections of items beyond those associated with "My
Drive". Use the \code{shared_drive} or \code{corpus} arguments to control this.
Read more about \link[=shared_drives]{shared drives}.
}
\examples{
\dontrun{
# list "My Drive" w/o regard for folder hierarchy
drive_find()
# filter for folders, the easy way and the hard way
drive_find(type = "folder")
drive_find(q = "mimeType = 'application/vnd.google-apps.folder'")
# filter for Google Sheets, the easy way and the hard way
drive_find(type = "spreadsheet")
drive_find(q = "mimeType='application/vnd.google-apps.spreadsheet'")
# files whose names match a regex
# the local, general, sometimes-slow-to-execute version
drive_find(pattern = "ick")
# the server-side, executes-faster version
# NOTE: works only for a pattern at the beginning of file name
drive_find(q = "name contains 'chick'")
# search for files located directly in your root folder
drive_find(q = "'root' in parents")
# FYI: this is equivalent to
drive_ls("~/")
# control page size or cap the number of files returned
drive_find(pageSize = 50)
# all params passed through `...` can be camelCase or snake_case
drive_find(page_size = 50)
drive_find(n_max = 58)
drive_find(page_size = 5, n_max = 15)
# various ways to specify q search clauses
# multiple q's
drive_find(
q = "name contains 'TEST'",
q = "modifiedTime > '2020-07-21T12:00:00'"
)
# vector q
drive_find(q = c("starred = true", "visibility = 'anyoneWithLink'"))
# default `trashed = FALSE` excludes files in the trash
# `trashed = TRUE` consults ONLY file in the trash
drive_find(trashed = TRUE)
# `trashed = NA` disregards trash status completely
drive_find(trashed = NA)
# suppress the default sorting on recency
drive_find(order_by = NULL, n_max = 5)
# sort on various keys
drive_find(order_by = "modifiedByMeTime", n_max = 5)
# request descending order
drive_find(order_by = "quotaBytesUsed desc", n_max = 5)
}
}
\seealso{
Wraps the \code{files.list} endpoint:
\itemize{
\item \url{https://developers.google.com/drive/api/v3/reference/files/list}
}
Helpful resource for forming your own queries:
\itemize{
\item \url{https://developers.google.com/drive/api/v3/search-files}
}
}
googledrive/man/drive_browse.Rd 0000644 0001762 0000144 00000001453 14070147664 016330 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/drive_browse.R
\name{drive_browse}
\alias{drive_browse}
\title{Visit Drive file in browser}
\usage{
drive_browse(file = .Last.value)
}
\arguments{
\item{file}{Something that identifies the file of interest on your Google
Drive. Can be a name or path, a file id or URL marked with \code{\link[=as_id]{as_id()}}, or a
\code{\link{dribble}}.}
}
\value{
Character vector of file hyperlinks, from \code{\link[=drive_link]{drive_link()}}, invisibly.
}
\description{
Visits a file on Google Drive in your default browser.
}
\examples{
\dontshow{if (drive_has_token() && rlang::is_interactive()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf}
drive_find(n_max = 1) \%>\% drive_browse()
\dontshow{\}) # examplesIf}
}
googledrive/man/drive_mv.Rd 0000644 0001762 0000144 00000010527 14413426163 015446 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/drive_mv.R
\name{drive_mv}
\alias{drive_mv}
\title{Move a Drive file}
\usage{
drive_mv(
file,
path = NULL,
name = NULL,
overwrite = NA,
verbose = deprecated()
)
}
\arguments{
\item{file}{Something that identifies the file of interest on your Google
Drive. Can be a name or path, a file id or URL marked with \code{\link[=as_id]{as_id()}}, or a
\code{\link{dribble}}.}
\item{path}{Specifies target destination for the file on Google
Drive. Can be an actual path (character), a file id marked with
\code{\link[=as_id]{as_id()}}, or a \code{\link{dribble}}.
If \code{path} is a shortcut to a folder, it is automatically resolved to its
target folder.
If \code{path} is given as a path (as opposed to a \code{dribble} or an id), it is
best to explicitly indicate if it's a folder by including a trailing
slash, since it cannot always be worked out from the context of the call.
By default, the file stays in its current folder.}
\item{name}{Character, new file name if not specified as part of
\code{path}. This will force \code{path} to be interpreted as a folder, even if it
is character and lacks a trailing slash. By default, the file keeps its current name.}
\item{overwrite}{Logical, indicating whether to check for a pre-existing file
at the targetted "filepath". The quotes around "filepath" refer to the fact
that Drive does not impose a 1-to-1 relationship between filepaths and files,
like a typical file system; read more about that in \code{\link[=drive_get]{drive_get()}}.
\itemize{
\item \code{NA} (default): Just do the operation, even if it results in multiple
files with the same filepath.
\item \code{TRUE}: Check for a pre-existing file at the filepath. If there is
zero or one, move a pre-existing file to the trash, then carry on. Note
that the new file does not inherit any properties from the old one, such
as sharing or publishing settings. It will have a new file ID. An error is
thrown if two or more pre-existing files are found.
\item \code{FALSE}: Error if there is any pre-existing file at the filepath.
}
Note that existence checks, based on filepath, are expensive operations, i.e.
they require additional API calls.}
\item{verbose}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} This logical argument to
individual googledrive functions is deprecated. To globally suppress
googledrive messaging, use \code{options(googledrive_quiet = TRUE)} (the default
behaviour is to emit informational messages). To suppress messaging in a
more limited way, use the helpers \code{\link[=local_drive_quiet]{local_drive_quiet()}} or
\code{\link[=with_drive_quiet]{with_drive_quiet()}}.}
}
\value{
An object of class \code{\link{dribble}}, a tibble with one row per file.
}
\description{
Move a Drive file to a different folder, give it a different name, or both.
}
\examples{
\dontshow{if (drive_has_token()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf}
# create a file to move
file <- drive_example_remote("chicken.txt") \%>\%
drive_cp("chicken-mv.txt")
# rename it, but leave in current folder (root folder, in this case)
file <- drive_mv(file, "chicken-mv-renamed.txt")
# create a folder to move the file into
folder <- drive_mkdir("mv-folder")
# move the file and rename it again,
# specify destination as a dribble
file <- drive_mv(file, path = folder, name = "chicken-mv-re-renamed.txt")
# verify renamed file is now in the folder
drive_ls(folder)
# move the file back to root folder
file <- drive_mv(file, "~/")
# move it again
# specify destination as path with trailing slash
# to ensure we get a move vs. renaming it to "mv-folder"
file <- drive_mv(file, "mv-folder/")
# `overwrite = FALSE` errors if something already exists at target filepath
# THIS WILL ERROR!
drive_create("name-squatter-mv", path = "~/")
drive_mv(file, path = "~/", name = "name-squatter-mv", overwrite = FALSE)
# `overwrite = TRUE` moves the existing item to trash, then proceeds
drive_mv(file, path = "~/", name = "name-squatter-mv", overwrite = TRUE)
# Clean up
drive_rm(file, folder)
\dontshow{\}) # examplesIf}
}
\seealso{
Makes a metadata-only request to the \code{files.update} endpoint:
\itemize{
\item \url{https://developers.google.com/drive/api/v3/reference/files/update}
}
}
googledrive/man/drive_update.Rd 0000644 0001762 0000144 00000005304 14405753133 016304 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/drive_update.R
\name{drive_update}
\alias{drive_update}
\title{Update an existing Drive file}
\usage{
drive_update(file, media = NULL, ..., verbose = deprecated())
}
\arguments{
\item{file}{Something that identifies the file of interest on your Google
Drive. Can be a name or path, a file id or URL marked with \code{\link[=as_id]{as_id()}}, or a
\code{\link{dribble}}.}
\item{media}{Character, path to the local file to upload.}
\item{...}{Named parameters to pass along to the Drive API. Has \link[rlang:dyn-dots]{dynamic dots} semantics. You can affect the metadata of the target file by
specifying properties of the Files resource via \code{...}. Read the "Request
body" section of the Drive API docs for the associated endpoint to learn
about relevant parameters.}
\item{verbose}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} This logical argument to
individual googledrive functions is deprecated. To globally suppress
googledrive messaging, use \code{options(googledrive_quiet = TRUE)} (the default
behaviour is to emit informational messages). To suppress messaging in a
more limited way, use the helpers \code{\link[=local_drive_quiet]{local_drive_quiet()}} or
\code{\link[=with_drive_quiet]{with_drive_quiet()}}.}
}
\value{
An object of class \code{\link{dribble}}, a tibble with one row per file.
}
\description{
Update an existing Drive file id with new content ("media" in Drive
API-speak), new metadata, or both. To create a new file or update existing,
depending on whether the Drive file already exists, see \code{\link[=drive_put]{drive_put()}}.
}
\examples{
\dontshow{if (drive_has_token()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf}
# Create a new file, so we can update it
x <- drive_example_remote("chicken.csv") \%>\%
drive_cp()
# Update the file with new media
x <- x \%>\%
drive_update(drive_example_local("chicken.txt"))
# Update the file with new metadata.
# Notice here `name` is not an argument of `drive_update()`, we are passing
# this to the API via the `...``
x <- x \%>\%
drive_update(name = "CHICKENS!")
# Update the file with new media AND new metadata
x <- x \%>\%
drive_update(
drive_example_local("chicken.txt"),
name = "chicken-poem-again.txt"
)
# Clean up
drive_rm(x)
\dontshow{\}) # examplesIf}
}
\seealso{
Wraps the \code{files.update} endpoint:
\itemize{
\item \url{https://developers.google.com/drive/api/v3/reference/files/update}
}
This function supports media upload:
\itemize{
\item \url{https://developers.google.com/drive/api/v3/manage-uploads}
}
}
googledrive/man/drive_deauth.Rd 0000644 0001762 0000144 00000002525 14441250555 016276 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/drive_auth.R
\name{drive_deauth}
\alias{drive_deauth}
\title{Suspend authorization}
\usage{
drive_deauth()
}
\description{
Put googledrive into a de-authorized state. Instead of sending a token,
googledrive will send an API key. This can be used to access public
resources for which no Google sign-in is required. This is handy for using
googledrive in a non-interactive setting to make requests that do not
require a token. It will prevent the attempt to obtain a token
interactively in the browser. The user can configure their own API key
via \code{\link[=drive_auth_configure]{drive_auth_configure()}} and retrieve that key via
\code{\link[=drive_api_key]{drive_api_key()}}.
In the absence of a user-configured key, a built-in default key is used.
}
\examples{
\dontshow{if (rlang::is_interactive()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf}
drive_deauth()
drive_user()
# in a deauth'ed state, we can still get metadata on a world-readable file
public_file <- drive_example_remote("chicken.csv")
public_file
# we can still download it too
drive_download(public_file)
\dontshow{\}) # examplesIf}
}
\seealso{
Other auth functions:
\code{\link{drive_auth_configure}()},
\code{\link{drive_auth}()},
\code{\link{drive_scopes}()}
}
\concept{auth functions}
googledrive/man/figures/ 0000755 0001762 0000144 00000000000 14413426163 015003 5 ustar ligges users googledrive/man/figures/lifecycle-defunct.svg 0000644 0001762 0000144 00000002424 14413426163 021113 0 ustar ligges users
googledrive/man/figures/lifecycle-maturing.svg 0000644 0001762 0000144 00000002430 14413426163 021306 0 ustar ligges users
googledrive/man/figures/logo.png 0000644 0001762 0000144 00000050262 14413426163 016456 0 ustar ligges users PNG
IHDR ޫh gAMA a cHRM z&