Liking cljdoc? Tell your friends :D

goog.workspace.drive

Clojure wrapper for the Google Drive API (v3).

Provides idiomatic Clojure functions for managing files, permissions, comments, replies, revisions, and changes in Google Drive.

Auth: use csl/scoped-delegated-credentials or csl/user-credentials with the appropriate scope:

  • DriveScopes/DRIVE (full access)
  • DriveScopes/DRIVE_FILE (files created/opened by the app)
  • DriveScopes/DRIVE_READONLY (read-only access)
  • DriveScopes/DRIVE_METADATA (metadata only)
  • DriveScopes/DRIVE_METADATA_READONLY (metadata read-only)
  • DriveScopes/DRIVE_APPS_READONLY (list-apps only — not covered by any other Drive scope; carved out separately by Google)

All list functions return {:data [...] :next-page-token "..."}; the caller is responsible for pagination by passing :page-token from one call to the next. :next-page-token is absent when there are no further pages.

All functions return {:data ...} on success or {:error ...} on failure.

Clojure wrapper for the Google Drive API (v3).

Provides idiomatic Clojure functions for managing files, permissions,
comments, replies, revisions, and changes in Google Drive.

Auth: use csl/scoped-delegated-credentials or csl/user-credentials with
the appropriate scope:
- DriveScopes/DRIVE                   (full access)
- DriveScopes/DRIVE_FILE              (files created/opened by the app)
- DriveScopes/DRIVE_READONLY          (read-only access)
- DriveScopes/DRIVE_METADATA          (metadata only)
- DriveScopes/DRIVE_METADATA_READONLY (metadata read-only)
- DriveScopes/DRIVE_APPS_READONLY     (list-apps only — not covered by any
                                       other Drive scope; carved out separately
                                       by Google)

All list functions return {:data [...] :next-page-token "..."}; the caller
is responsible for pagination by passing :page-token from one call to the next.
:next-page-token is absent when there are no further pages.

All functions return {:data ...} on success or {:error ...} on failure.
raw docstring

copy-fileclj

(copy-file client file-id metadata & [opts])

Create a copy of a file.

file-id — ID of the file to copy metadata — map of properties for the copy (e.g. {:name "Copy of report"})

opts:

  • :fields — partial response field mask string
  • :ignore-default-visibility — boolean
  • :supports-all-drives — boolean (default false)
Create a copy of a file.

file-id  — ID of the file to copy
metadata — map of properties for the copy (e.g. {:name "Copy of report"})

opts:
- :fields                    — partial response field mask string
- :ignore-default-visibility — boolean
- :supports-all-drives       — boolean (default false)
raw docstring

create-commentclj

(create-comment client file-id comment-data & [opts])

Create a comment on a file.

comment-data — map with kebab-case keys. Required key: :content — the text of the comment

Create a comment on a file.

comment-data — map with kebab-case keys. Required key:
  :content — the text of the comment
raw docstring

create-fileclj

(create-file client metadata & [opts])

Create a new file. For metadata-only creation (e.g. folders), pass only metadata. For upload, also pass :content in opts.

metadata — map of file properties with kebab-case keys: :name — file name :mime-type — MIME type ("application/vnd.google-apps.folder" for folders) :parents — vector of parent folder IDs

opts:

  • :content — file content: java.io.File, InputStream, byte[], or String
  • :mime-type — MIME type of the content (required for InputStream/byte[], defaults for File and String)
  • :fields — partial response field mask string
  • :supports-all-drives — boolean (default false)
Create a new file. For metadata-only creation (e.g. folders), pass only metadata.
For upload, also pass :content in opts.

metadata — map of file properties with kebab-case keys:
  :name      — file name
  :mime-type — MIME type ("application/vnd.google-apps.folder" for folders)
  :parents   — vector of parent folder IDs

opts:
- :content             — file content: java.io.File, InputStream, byte[], or String
- :mime-type           — MIME type of the content (required for InputStream/byte[],
                         defaults for File and String)
- :fields              — partial response field mask string
- :supports-all-drives — boolean (default false)
raw docstring

create-permissionclj

(create-permission client file-id permission & [opts])

Create a permission on a file (share a file).

permission — map with kebab-case keys: :type — :user, :group, :domain, or :anyone :role — :owner, :organizer, :file-organizer, :writer, :commenter, or :reader :email-address — email (required for :user and :group types) :domain — domain (required for :domain type)

opts:

  • :send-notification-email — boolean (default true for user/group)
  • :email-message — custom notification email message
  • :transfer-ownership — boolean (default false)
  • :fields — partial response field mask string
  • :supports-all-drives — boolean (default false)
  • :use-domain-admin-access — boolean; issue the request as a domain administrator (caller must hold the Workspace admin role; combine with :supports-all-drives true for effect on Shared Drives)
Create a permission on a file (share a file).

permission — map with kebab-case keys:
  :type          — :user, :group, :domain, or :anyone
  :role          — :owner, :organizer, :file-organizer, :writer,
                   :commenter, or :reader
  :email-address — email (required for :user and :group types)
  :domain        — domain (required for :domain type)

opts:
- :send-notification-email — boolean (default true for user/group)
- :email-message           — custom notification email message
- :transfer-ownership      — boolean (default false)
- :fields                  — partial response field mask string
- :supports-all-drives     — boolean (default false)
- :use-domain-admin-access — boolean; issue the request as a domain
                             administrator (caller must hold the Workspace
                             admin role; combine with :supports-all-drives
                             true for effect on Shared Drives)
raw docstring

create-replyclj

(create-reply client file-id comment-id reply-data & [opts])

Create a reply to a comment.

reply-data — map with kebab-case keys. Required key: :content — the text of the reply

Create a reply to a comment.

reply-data — map with kebab-case keys. Required key:
  :content — the text of the reply
raw docstring

delete-commentclj

(delete-comment client file-id comment-id & [opts])

Delete a comment.

Delete a comment.
raw docstring

delete-fileclj

(delete-file client file-id & [opts])

Permanently delete a file. Does not move to trash. Use (update-file client file-id {:trashed true}) to trash instead.

opts:

  • :supports-all-drives — boolean (default false)
Permanently delete a file. Does not move to trash.
Use (update-file client file-id {:trashed true}) to trash instead.

opts:
- :supports-all-drives — boolean (default false)
raw docstring

delete-permissionclj

(delete-permission client file-id permission-id & [opts])

Remove a permission from a file (unshare).

opts:

  • :supports-all-drives — boolean (default false)
  • :use-domain-admin-access — boolean; issue the request as a domain administrator (caller must hold the Workspace admin role; combine with :supports-all-drives true for effect on Shared Drives)
Remove a permission from a file (unshare).

opts:
- :supports-all-drives     — boolean (default false)
- :use-domain-admin-access — boolean; issue the request as a domain
                             administrator (caller must hold the Workspace
                             admin role; combine with :supports-all-drives
                             true for effect on Shared Drives)
raw docstring

delete-replyclj

(delete-reply client file-id comment-id reply-id & [opts])

Delete a reply.

Delete a reply.
raw docstring

delete-revisionclj

(delete-revision client file-id revision-id & [opts])

Delete a revision. Only applicable to files with binary content in Drive.

Delete a revision. Only applicable to files with binary content in Drive.
raw docstring

download-fileclj

(download-file client file-id & [opts])

Download a file's content as an InputStream. Works for binary files — use export-file for Google Workspace documents (Docs, Sheets, Slides).

The caller is responsible for closing the InputStream.

opts:

  • :acknowledge-abuse — boolean, acknowledge risk of downloading known malware
Download a file's content as an InputStream. Works for binary files — use
export-file for Google Workspace documents (Docs, Sheets, Slides).

The caller is responsible for closing the InputStream.

opts:
- :acknowledge-abuse — boolean, acknowledge risk of downloading known malware
raw docstring

drive-clientclj

(drive-client credentials)
(drive-client credentials opts)

Build an authenticated Drive v3 REST client.

credentials — a com.google.auth.oauth2.GoogleCredentials instance, typically from csl/scoped-delegated-credentials or csl/user-credentials.

opts (optional):

  • :read-timeout-ms per-client default read timeout (default 120000 / 120s)
  • :connect-timeout-ms per-client default connect timeout (default 30000 / 30s)

Per-request opts on individual call sites override the client-level defaults.

Build an authenticated Drive v3 REST client.

credentials — a com.google.auth.oauth2.GoogleCredentials instance, typically
from csl/scoped-delegated-credentials or csl/user-credentials.

opts (optional):
- :read-timeout-ms     per-client default read timeout (default 120000 / 120s)
- :connect-timeout-ms  per-client default connect timeout (default 30000 / 30s)

Per-request opts on individual call sites override the client-level defaults.
raw docstring

empty-trashclj

(empty-trash client & [opts])

Permanently delete all trashed files.

Permanently delete all trashed files.
raw docstring

export-fileclj

(export-file client file-id mime-type & [opts])

Export a Google Workspace document to the given MIME type as an InputStream.

The caller is responsible for closing the InputStream.

Common export MIME types:

  • "application/pdf"
  • "text/plain"
  • "text/csv"
  • "application/vnd.openxmlformats-officedocument.wordprocessingml.document"
  • "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
Export a Google Workspace document to the given MIME type as an InputStream.

The caller is responsible for closing the InputStream.

Common export MIME types:
- "application/pdf"
- "text/plain"
- "text/csv"
- "application/vnd.openxmlformats-officedocument.wordprocessingml.document"
- "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
raw docstring

get-aboutclj

(get-about client & [opts])

Get information about the user, the user's Drive, and system capabilities.

The Drive API requires a fields parameter — this function defaults to "*" (all fields). Pass :fields to request specific fields.

opts:

  • :fields — partial response field mask string (default "*")
Get information about the user, the user's Drive, and system capabilities.

The Drive API requires a fields parameter — this function defaults to
"*" (all fields). Pass :fields to request specific fields.

opts:
- :fields — partial response field mask string (default "*")
raw docstring

get-commentclj

(get-comment client file-id comment-id & [opts])

Get a comment by ID.

opts:

  • :fields — partial response field mask string
  • :include-deleted — boolean (default false)
Get a comment by ID.

opts:
- :fields          — partial response field mask string
- :include-deleted — boolean (default false)
raw docstring

get-fileclj

(get-file client file-id & [opts])

Get a file's metadata by ID.

opts:

  • :fields — partial response field mask string
  • :acknowledge-abuse — boolean, acknowledge risk of downloading known malware
  • :supports-all-drives — boolean (default false)
Get a file's metadata by ID.

opts:
- :fields              — partial response field mask string
- :acknowledge-abuse   — boolean, acknowledge risk of downloading known malware
- :supports-all-drives — boolean (default false)
raw docstring

get-permissionclj

(get-permission client file-id permission-id & [opts])

Get a permission by ID.

opts:

  • :fields — partial response field mask string
  • :supports-all-drives — boolean (default false)
  • :use-domain-admin-access — boolean; issue the request as a domain administrator (caller must hold the Workspace admin role; combine with :supports-all-drives true for effect on Shared Drives)
Get a permission by ID.

opts:
- :fields                  — partial response field mask string
- :supports-all-drives     — boolean (default false)
- :use-domain-admin-access — boolean; issue the request as a domain
                             administrator (caller must hold the Workspace
                             admin role; combine with :supports-all-drives
                             true for effect on Shared Drives)
raw docstring

get-replyclj

(get-reply client file-id comment-id reply-id & [opts])

Get a reply by ID.

opts:

  • :fields — partial response field mask string
  • :include-deleted — boolean (default false)
Get a reply by ID.

opts:
- :fields          — partial response field mask string
- :include-deleted — boolean (default false)
raw docstring

get-revisionclj

(get-revision client file-id revision-id & [opts])

Get a revision by ID.

opts:

  • :fields — partial response field mask string
  • :acknowledge-abuse — boolean
Get a revision by ID.

opts:
- :fields            — partial response field mask string
- :acknowledge-abuse — boolean
raw docstring

get-start-page-tokenclj

(get-start-page-token client & [opts])

Get the starting page token for listing future changes.

opts:

  • :drive-id — ID of shared drive
  • :supports-all-drives — boolean (default false)
Get the starting page token for listing future changes.

opts:
- :drive-id             — ID of shared drive
- :supports-all-drives  — boolean (default false)
raw docstring

list-appsclj

(list-apps client & [opts])

List the Drive-connected Workspace Marketplace apps the caller has authorized. Not paginated in v3 — the response is the full list. The result's :items key holds the App entries.

opts:

  • :app-filter-extensions — comma-separated file extensions to filter the matching apps by
  • :app-filter-mime-types — comma-separated MIME types to filter the matching apps by
  • :language-code — BCP-47 language code; localizes app names
  • :fields — partial response field mask string
List the Drive-connected Workspace Marketplace apps the caller has
authorized. Not paginated in v3 — the response is the full list. The
result's `:items` key holds the App entries.

opts:
- :app-filter-extensions — comma-separated file extensions to filter the
                           matching apps by
- :app-filter-mime-types — comma-separated MIME types to filter the
                           matching apps by
- :language-code         — BCP-47 language code; localizes app names
- :fields                — partial response field mask string
raw docstring

list-changesclj

(list-changes client page-token & [opts])

List changes to files and shared drives.

page-token — token from get-start-page-token or a previous list-changes call

Returns {:data [...] :next-page-token "..."} when more pages remain, or {:data [...] :new-start-page-token "..."} on the last page. Save :new-start-page-token for future polling via list-changes.

opts:

  • :page-size — max changes per page
  • :fields — partial response field mask string
  • :spaces — comma-separated list of spaces
  • :supports-all-drives — boolean (default false)
  • :include-items-from-all-drives — boolean (default false)
  • :drive-id — ID of shared drive
List changes to files and shared drives.

page-token — token from get-start-page-token or a previous list-changes call

Returns {:data [...] :next-page-token "..."} when more pages remain, or
{:data [...] :new-start-page-token "..."} on the last page. Save
:new-start-page-token for future polling via list-changes.

opts:
- :page-size                     — max changes per page
- :fields                        — partial response field mask string
- :spaces                        — comma-separated list of spaces
- :supports-all-drives           — boolean (default false)
- :include-items-from-all-drives — boolean (default false)
- :drive-id                      — ID of shared drive
raw docstring

list-commentsclj

(list-comments client file-id & [opts])

List comments on a file.

opts:

  • :page-token — token for pagination
  • :page-size — max comments per page
  • :fields — partial response field mask string
  • :start-modified-time — ISO 8601 timestamp; only comments modified after this
  • :include-deleted — boolean (default false)
List comments on a file.

opts:
- :page-token          — token for pagination
- :page-size           — max comments per page
- :fields              — partial response field mask string
- :start-modified-time — ISO 8601 timestamp; only comments modified after this
- :include-deleted     — boolean (default false)
raw docstring

list-drivesclj

(list-drives client & [opts])

List Shared Drives the caller has access to.

opts:

  • :page-token — token from a previous response
  • :page-size — max drives per page (default 10, max 100)
  • :q — query string (Drive query syntax for drive filtering)
  • :fields — partial response field mask string
  • :use-domain-admin-access — boolean; issue the request as a domain administrator (caller must hold the Workspace admin role)
List Shared Drives the caller has access to.

opts:
- :page-token              — token from a previous response
- :page-size               — max drives per page (default 10, max 100)
- :q                       — query string (Drive query syntax for drive filtering)
- :fields                  — partial response field mask string
- :use-domain-admin-access — boolean; issue the request as a domain
                             administrator (caller must hold the Workspace
                             admin role)
raw docstring

list-filesclj

(list-files client & [opts])

List files in the user's Drive.

opts:

  • :q — query string (Drive query syntax)
  • :page-token — token from a previous response
  • :page-size — max files per page (default 100, max 1000)
  • :fields — partial response field mask string
  • :order-by — comma-separated sort keys
  • :corpora — :user (default), :drive, :domain, :all-drives
  • :drive-id — ID of shared drive (when corpora is :drive)
  • :spaces — comma-separated list of spaces
  • :supports-all-drives — boolean (default false)
  • :include-items-from-all-drives — boolean (default false)
List files in the user's Drive.

opts:
- :q                             — query string (Drive query syntax)
- :page-token                    — token from a previous response
- :page-size                     — max files per page (default 100, max 1000)
- :fields                        — partial response field mask string
- :order-by                      — comma-separated sort keys
- :corpora                       — :user (default), :drive, :domain, :all-drives
- :drive-id                      — ID of shared drive (when corpora is :drive)
- :spaces                        — comma-separated list of spaces
- :supports-all-drives           — boolean (default false)
- :include-items-from-all-drives — boolean (default false)
raw docstring

list-permissionsclj

(list-permissions client file-id & [opts])

List permissions on a file.

opts:

  • :page-token — token for pagination
  • :page-size — max permissions per page
  • :fields — partial response field mask string
  • :supports-all-drives — boolean (default false)
  • :use-domain-admin-access — boolean; issue the request as a domain administrator (caller must hold the Workspace admin role; combine with :supports-all-drives true for effect on Shared Drives)
List permissions on a file.

opts:
- :page-token              — token for pagination
- :page-size               — max permissions per page
- :fields                  — partial response field mask string
- :supports-all-drives     — boolean (default false)
- :use-domain-admin-access — boolean; issue the request as a domain
                             administrator (caller must hold the Workspace
                             admin role; combine with :supports-all-drives
                             true for effect on Shared Drives)
raw docstring

list-repliesclj

(list-replies client file-id comment-id & [opts])

List replies to a comment.

opts:

  • :page-token — token for pagination
  • :page-size — max replies per page
  • :fields — partial response field mask string
  • :include-deleted — boolean (default false)
List replies to a comment.

opts:
- :page-token      — token for pagination
- :page-size       — max replies per page
- :fields          — partial response field mask string
- :include-deleted — boolean (default false)
raw docstring

list-revisionsclj

(list-revisions client file-id & [opts])

List revisions of a file.

opts:

  • :page-token — token for pagination
  • :page-size — max revisions per page
  • :fields — partial response field mask string
List revisions of a file.

opts:
- :page-token — token for pagination
- :page-size  — max revisions per page
- :fields     — partial response field mask string
raw docstring

update-commentclj

(update-comment client file-id comment-id comment-data & [opts])

Update a comment.

comment-data — map with kebab-case keys for fields to update (e.g. {:content "edited"})

Update a comment.

comment-data — map with kebab-case keys for fields to update (e.g. {:content "edited"})
raw docstring

update-fileclj

(update-file client file-id metadata & [opts])

Update a file's metadata and/or content.

file-id — ID of the file to update metadata — map of file properties to update (kebab-case keys), or nil for content-only

opts:

  • :content — new file content: java.io.File, InputStream, byte[], or String
  • :mime-type — MIME type of the content
  • :fields — partial response field mask string
  • :add-parents — comma-separated list of parent IDs to add
  • :remove-parents — comma-separated list of parent IDs to remove
  • :supports-all-drives — boolean (default false)
Update a file's metadata and/or content.

file-id  — ID of the file to update
metadata — map of file properties to update (kebab-case keys), or nil for content-only

opts:
- :content             — new file content: java.io.File, InputStream, byte[], or String
- :mime-type           — MIME type of the content
- :fields              — partial response field mask string
- :add-parents         — comma-separated list of parent IDs to add
- :remove-parents      — comma-separated list of parent IDs to remove
- :supports-all-drives — boolean (default false)
raw docstring

update-permissionclj

(update-permission client file-id permission-id permission & [opts])

Update a permission on a file.

permission — map with kebab-case keys for fields to update (e.g. {:role :writer})

opts:

  • :remove-expiration — boolean
  • :transfer-ownership — boolean
  • :fields — partial response field mask string
  • :supports-all-drives — boolean (default false)
  • :use-domain-admin-access — boolean; issue the request as a domain administrator (caller must hold the Workspace admin role; combine with :supports-all-drives true for effect on Shared Drives)
Update a permission on a file.

permission — map with kebab-case keys for fields to update (e.g. {:role :writer})

opts:
- :remove-expiration       — boolean
- :transfer-ownership      — boolean
- :fields                  — partial response field mask string
- :supports-all-drives     — boolean (default false)
- :use-domain-admin-access — boolean; issue the request as a domain
                             administrator (caller must hold the Workspace
                             admin role; combine with :supports-all-drives
                             true for effect on Shared Drives)
raw docstring

update-replyclj

(update-reply client file-id comment-id reply-id reply-data & [opts])

Update a reply.

reply-data — map with kebab-case keys for fields to update (e.g. {:content "edited"})

Update a reply.

reply-data — map with kebab-case keys for fields to update (e.g. {:content "edited"})
raw docstring

update-revisionclj

(update-revision client file-id revision-id revision-data & [opts])

Update a revision's metadata.

revision-data — map with kebab-case keys: :keep-forever — boolean, pin this revision :publish-auto — boolean :published — boolean

Update a revision's metadata.

revision-data — map with kebab-case keys:
  :keep-forever — boolean, pin this revision
  :publish-auto — boolean
  :published    — boolean
raw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close