Drive API . revisions

Instance Methods

delete(fileId=*, revisionId=*)

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

get(fileId=*, revisionId=*, acknowledgeAbuse=None)

Gets a revision's metadata or content by ID.

get_media(fileId=*, revisionId=*, acknowledgeAbuse=None)

Gets a revision's metadata or content by ID.

list(fileId=*, pageToken=None, pageSize=None)

Lists a file's revisions.

list_next(previous_request=*, previous_response=*)

Retrieves the next page of results.

update(fileId=*, revisionId=*, body=None)

Updates a revision with patch semantics.

Method Details

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

Args:
  fileId: string, The ID of the file. (required)
  revisionId: string, The ID of the revision. (required)
get(fileId=*, revisionId=*, acknowledgeAbuse=None)
Gets a revision's metadata or content by ID.

Args:
  fileId: string, The ID of the file. (required)
  revisionId: string, The ID of the revision. (required)
  acknowledgeAbuse: boolean, Whether the user is acknowledging the risk of downloading known malware or other abusive files. This is only applicable when alt=media.

Returns:
  An object of the form:

    { # The metadata for a revision to a file.
    "mimeType": "A String", # The MIME type of the revision.
    "kind": "drive#revision", # Identifies what kind of resource this is. Value: the fixed string "drive#revision".
    "modifiedTime": "A String", # The last time the revision was modified (RFC 3339 date-time).
    "lastModifyingUser": { # Information about a Drive user. # The last user to modify this revision.
      "me": True or False, # Whether this user is the requesting user.
      "kind": "drive#user", # Identifies what kind of resource this is. Value: the fixed string "drive#user".
      "displayName": "A String", # A plain text displayable name for this user.
      "permissionId": "A String", # The user's ID as visible in Permission resources.
      "emailAddress": "A String", # The email address of the user. This may not be present in certain contexts if the user has not made their email address visible to the requester.
      "photoLink": "A String", # A link to the user's profile photo, if available.
    },
    "keepForever": True or False, # Whether to keep this revision forever, even if it is no longer the head revision. If not set, the revision will be automatically purged 30 days after newer content is uploaded. This can be set on a maximum of 200 revisions for a file.
        # This field is only applicable to files with binary content in Drive.
    "publishAuto": True or False, # Whether subsequent revisions will be automatically republished. This is only applicable to Google Docs.
    "originalFilename": "A String", # The original filename used to create this revision. This is only applicable to files with binary content in Drive.
    "exportLinks": { # Links for exporting Google Docs to specific formats.
      "a_key": "A String", # A mapping from export format to URL
    },
    "published": True or False, # Whether this revision is published. This is only applicable to Google Docs.
    "size": "A String", # The size of the revision's content in bytes. This is only applicable to files with binary content in Drive.
    "id": "A String", # The ID of the revision.
    "md5Checksum": "A String", # The MD5 checksum of the revision's content. This is only applicable to files with binary content in Drive.
    "publishedOutsideDomain": True or False, # Whether this revision is published outside the domain. This is only applicable to Google Docs.
  }
get_media(fileId=*, revisionId=*, acknowledgeAbuse=None)
Gets a revision's metadata or content by ID.

Args:
  fileId: string, The ID of the file. (required)
  revisionId: string, The ID of the revision. (required)
  acknowledgeAbuse: boolean, Whether the user is acknowledging the risk of downloading known malware or other abusive files. This is only applicable when alt=media.

Returns:
  The media object as a string.

    
list(fileId=*, pageToken=None, pageSize=None)
Lists a file's revisions.

Args:
  fileId: string, The ID of the file. (required)
  pageToken: string, The token for continuing a previous list request on the next page. This should be set to the value of 'nextPageToken' from the previous response.
  pageSize: integer, The maximum number of revisions to return per page.

Returns:
  An object of the form:

    { # A list of revisions of a file.
    "nextPageToken": "A String", # The page token for the next page of revisions. This will be absent if the end of the revisions list has been reached. If the token is rejected for any reason, it should be discarded, and pagination should be restarted from the first page of results.
    "kind": "drive#revisionList", # Identifies what kind of resource this is. Value: the fixed string "drive#revisionList".
    "revisions": [ # The list of revisions. If nextPageToken is populated, then this list may be incomplete and an additional page of results should be fetched.
      { # The metadata for a revision to a file.
        "mimeType": "A String", # The MIME type of the revision.
        "kind": "drive#revision", # Identifies what kind of resource this is. Value: the fixed string "drive#revision".
        "modifiedTime": "A String", # The last time the revision was modified (RFC 3339 date-time).
        "lastModifyingUser": { # Information about a Drive user. # The last user to modify this revision.
          "me": True or False, # Whether this user is the requesting user.
          "kind": "drive#user", # Identifies what kind of resource this is. Value: the fixed string "drive#user".
          "displayName": "A String", # A plain text displayable name for this user.
          "permissionId": "A String", # The user's ID as visible in Permission resources.
          "emailAddress": "A String", # The email address of the user. This may not be present in certain contexts if the user has not made their email address visible to the requester.
          "photoLink": "A String", # A link to the user's profile photo, if available.
        },
        "keepForever": True or False, # Whether to keep this revision forever, even if it is no longer the head revision. If not set, the revision will be automatically purged 30 days after newer content is uploaded. This can be set on a maximum of 200 revisions for a file.
            # This field is only applicable to files with binary content in Drive.
        "publishAuto": True or False, # Whether subsequent revisions will be automatically republished. This is only applicable to Google Docs.
        "originalFilename": "A String", # The original filename used to create this revision. This is only applicable to files with binary content in Drive.
        "exportLinks": { # Links for exporting Google Docs to specific formats.
          "a_key": "A String", # A mapping from export format to URL
        },
        "published": True or False, # Whether this revision is published. This is only applicable to Google Docs.
        "size": "A String", # The size of the revision's content in bytes. This is only applicable to files with binary content in Drive.
        "id": "A String", # The ID of the revision.
        "md5Checksum": "A String", # The MD5 checksum of the revision's content. This is only applicable to files with binary content in Drive.
        "publishedOutsideDomain": True or False, # Whether this revision is published outside the domain. This is only applicable to Google Docs.
      },
    ],
  }
list_next(previous_request=*, previous_response=*)
Retrieves the next page of results.

Args:
  previous_request: The request for the previous page. (required)
  previous_response: The response from the request for the previous page. (required)

Returns:
  A request object that you can call 'execute()' on to request the next
  page. Returns None if there are no more items in the collection.
    
update(fileId=*, revisionId=*, body=None)
Updates a revision with patch semantics.

Args:
  fileId: string, The ID of the file. (required)
  revisionId: string, The ID of the revision. (required)
  body: object, The request body.
    The object takes the form of:

{ # The metadata for a revision to a file.
  "mimeType": "A String", # The MIME type of the revision.
  "kind": "drive#revision", # Identifies what kind of resource this is. Value: the fixed string "drive#revision".
  "modifiedTime": "A String", # The last time the revision was modified (RFC 3339 date-time).
  "lastModifyingUser": { # Information about a Drive user. # The last user to modify this revision.
    "me": True or False, # Whether this user is the requesting user.
    "kind": "drive#user", # Identifies what kind of resource this is. Value: the fixed string "drive#user".
    "displayName": "A String", # A plain text displayable name for this user.
    "permissionId": "A String", # The user's ID as visible in Permission resources.
    "emailAddress": "A String", # The email address of the user. This may not be present in certain contexts if the user has not made their email address visible to the requester.
    "photoLink": "A String", # A link to the user's profile photo, if available.
  },
  "keepForever": True or False, # Whether to keep this revision forever, even if it is no longer the head revision. If not set, the revision will be automatically purged 30 days after newer content is uploaded. This can be set on a maximum of 200 revisions for a file.
      # This field is only applicable to files with binary content in Drive.
  "publishAuto": True or False, # Whether subsequent revisions will be automatically republished. This is only applicable to Google Docs.
  "originalFilename": "A String", # The original filename used to create this revision. This is only applicable to files with binary content in Drive.
  "exportLinks": { # Links for exporting Google Docs to specific formats.
    "a_key": "A String", # A mapping from export format to URL
  },
  "published": True or False, # Whether this revision is published. This is only applicable to Google Docs.
  "size": "A String", # The size of the revision's content in bytes. This is only applicable to files with binary content in Drive.
  "id": "A String", # The ID of the revision.
  "md5Checksum": "A String", # The MD5 checksum of the revision's content. This is only applicable to files with binary content in Drive.
  "publishedOutsideDomain": True or False, # Whether this revision is published outside the domain. This is only applicable to Google Docs.
}


Returns:
  An object of the form:

    { # The metadata for a revision to a file.
    "mimeType": "A String", # The MIME type of the revision.
    "kind": "drive#revision", # Identifies what kind of resource this is. Value: the fixed string "drive#revision".
    "modifiedTime": "A String", # The last time the revision was modified (RFC 3339 date-time).
    "lastModifyingUser": { # Information about a Drive user. # The last user to modify this revision.
      "me": True or False, # Whether this user is the requesting user.
      "kind": "drive#user", # Identifies what kind of resource this is. Value: the fixed string "drive#user".
      "displayName": "A String", # A plain text displayable name for this user.
      "permissionId": "A String", # The user's ID as visible in Permission resources.
      "emailAddress": "A String", # The email address of the user. This may not be present in certain contexts if the user has not made their email address visible to the requester.
      "photoLink": "A String", # A link to the user's profile photo, if available.
    },
    "keepForever": True or False, # Whether to keep this revision forever, even if it is no longer the head revision. If not set, the revision will be automatically purged 30 days after newer content is uploaded. This can be set on a maximum of 200 revisions for a file.
        # This field is only applicable to files with binary content in Drive.
    "publishAuto": True or False, # Whether subsequent revisions will be automatically republished. This is only applicable to Google Docs.
    "originalFilename": "A String", # The original filename used to create this revision. This is only applicable to files with binary content in Drive.
    "exportLinks": { # Links for exporting Google Docs to specific formats.
      "a_key": "A String", # A mapping from export format to URL
    },
    "published": True or False, # Whether this revision is published. This is only applicable to Google Docs.
    "size": "A String", # The size of the revision's content in bytes. This is only applicable to files with binary content in Drive.
    "id": "A String", # The ID of the revision.
    "md5Checksum": "A String", # The MD5 checksum of the revision's content. This is only applicable to files with binary content in Drive.
    "publishedOutsideDomain": True or False, # Whether this revision is published outside the domain. This is only applicable to Google Docs.
  }