Skip to main content

revisions

Creates, updates, deletes, gets or lists a revisions resource.

Overview

Namerevisions
TypeResource
Idgoogleworkspace.drivev2.revisions

Fields

The following fields are returned by SELECT queries:

NameDatatypeDescription
idstringOutput only. The ID of the revision.
downloadUrlstringOutput only. Short term download URL for the file. This will only be populated on files with content stored in Drive.
etagstringOutput only. The ETag of the revision.
exportLinksobjectOutput only. Links for exporting Docs Editors files to specific formats.
fileSizestring (int64)Output only. The size of the revision in bytes. This will only be populated on files with content stored in Drive.
kindstringOutput only. This is always drive#revision. (default: drive#revision)
lastModifyingUserobjectInformation about a Drive user. (id: User)
lastModifyingUserNamestringOutput only. Name of the last user to modify this revision.
md5ChecksumstringOutput only. An MD5 checksum for the content of this revision. This will only be populated on files with content stored in Drive.
mimeTypestringOutput only. The MIME type of the revision.
modifiedDatestring (date-time)Last time this revision was modified (formatted RFC 3339 timestamp).
originalFilenamestringOutput only. The original filename when this revision was created. This will only be populated on files with content stored in Drive.
pinnedbooleanWhether this revision is pinned to prevent automatic purging. If not set, the revision is automatically purged 30 days after newer content is uploaded. This field can only be modified on files with content stored in Drive, excluding Docs Editors files. Revisions can also be pinned when they are created through the drive.files.insert/update/copy by using the pinned query parameter. Pinned revisions are stored indefinitely using additional storage quota, up to a maximum of 200 revisions.
publishAutobooleanWhether subsequent revisions will be automatically republished. This is only populated and can only be modified for Docs Editors files.
publishedbooleanWhether this revision is published. This is only populated and can only be modified for Docs Editors files.
publishedLinkstringOutput only. A link to the published revision. This is only populated for Docs Editors files.
publishedOutsideDomainbooleanWhether this revision is published outside the domain. This is only populated and can only be modified for Docs Editors files.
selfLinkstringOutput only. A link back to this revision.

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
getselectfileId, revisionIdGets a specific revision.
listselectfileIdmaxResults, pageTokenLists a file's revisions.
patchupdatefileId, revisionIdUpdates a revision.
updatereplacefileId, revisionIdUpdates a revision.
deletedeletefileId, revisionIdPermanently deletes a file version. You can only delete revisions for files with binary content, like images or videos. Revisions for other files, like Google Docs or Sheets, and the last remaining file version can't be deleted.

Parameters

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
fileIdstring
revisionIdstring
maxResultsinteger (int32)
pageTokenstring

SELECT examples

Gets a specific revision.

SELECT
id,
downloadUrl,
etag,
exportLinks,
fileSize,
kind,
lastModifyingUser,
lastModifyingUserName,
md5Checksum,
mimeType,
modifiedDate,
originalFilename,
pinned,
publishAuto,
published,
publishedLink,
publishedOutsideDomain,
selfLink
FROM googleworkspace.drivev2.revisions
WHERE fileId = '{{ fileId }}' -- required
AND revisionId = '{{ revisionId }}' -- required
;

UPDATE examples

Updates a revision.

UPDATE googleworkspace.drivev2.revisions
SET
data__id = '{{ id }}',
data__mimeType = '{{ mimeType }}',
data__kind = '{{ kind }}',
data__published = {{ published }},
data__etag = '{{ etag }}',
data__exportLinks = '{{ exportLinks }}',
data__pinned = {{ pinned }},
data__md5Checksum = '{{ md5Checksum }}',
data__modifiedDate = '{{ modifiedDate }}',
data__lastModifyingUserName = '{{ lastModifyingUserName }}',
data__downloadUrl = '{{ downloadUrl }}',
data__publishAuto = {{ publishAuto }},
data__publishedOutsideDomain = {{ publishedOutsideDomain }},
data__publishedLink = '{{ publishedLink }}',
data__fileSize = '{{ fileSize }}',
data__originalFilename = '{{ originalFilename }}',
data__lastModifyingUser = '{{ lastModifyingUser }}',
data__selfLink = '{{ selfLink }}'
WHERE
fileId = '{{ fileId }}' --required
AND revisionId = '{{ revisionId }}' --required
RETURNING
id,
downloadUrl,
etag,
exportLinks,
fileSize,
kind,
lastModifyingUser,
lastModifyingUserName,
md5Checksum,
mimeType,
modifiedDate,
originalFilename,
pinned,
publishAuto,
published,
publishedLink,
publishedOutsideDomain,
selfLink;

REPLACE examples

Updates a revision.

REPLACE googleworkspace.drivev2.revisions
SET
data__id = '{{ id }}',
data__mimeType = '{{ mimeType }}',
data__kind = '{{ kind }}',
data__published = {{ published }},
data__etag = '{{ etag }}',
data__exportLinks = '{{ exportLinks }}',
data__pinned = {{ pinned }},
data__md5Checksum = '{{ md5Checksum }}',
data__modifiedDate = '{{ modifiedDate }}',
data__lastModifyingUserName = '{{ lastModifyingUserName }}',
data__downloadUrl = '{{ downloadUrl }}',
data__publishAuto = {{ publishAuto }},
data__publishedOutsideDomain = {{ publishedOutsideDomain }},
data__publishedLink = '{{ publishedLink }}',
data__fileSize = '{{ fileSize }}',
data__originalFilename = '{{ originalFilename }}',
data__lastModifyingUser = '{{ lastModifyingUser }}',
data__selfLink = '{{ selfLink }}'
WHERE
fileId = '{{ fileId }}' --required
AND revisionId = '{{ revisionId }}' --required
RETURNING
id,
downloadUrl,
etag,
exportLinks,
fileSize,
kind,
lastModifyingUser,
lastModifyingUserName,
md5Checksum,
mimeType,
modifiedDate,
originalFilename,
pinned,
publishAuto,
published,
publishedLink,
publishedOutsideDomain,
selfLink;

DELETE examples

Permanently deletes a file version. You can only delete revisions for files with binary content, like images or videos. Revisions for other files, like Google Docs or Sheets, and the last remaining file version can't be deleted.

DELETE FROM googleworkspace.drivev2.revisions
WHERE fileId = '{{ fileId }}' --required
AND revisionId = '{{ revisionId }}' --required
;