Skip to main content

comments

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

Overview

Namecomments
TypeResource
Idgoogleworkspace.drivev3.comments

Fields

The following fields are returned by SELECT queries:

NameDatatypeDescription
idstringOutput only. The ID of the comment.
anchorstringA region of the document represented as a JSON string. For details on defining anchor properties, refer to Manage comments and replies.
authorobjectInformation about a Drive user. (id: User)
contentstringThe plain text content of the comment. This field is used for setting the content, while htmlContent should be displayed.
createdTimestring (date-time)The time at which the comment was created (RFC 3339 date-time).
deletedbooleanOutput only. Whether the comment has been deleted. A deleted comment has no content.
htmlContentstringOutput only. The content of the comment with HTML formatting.
kindstringOutput only. Identifies what kind of resource this is. Value: the fixed string "drive#comment". (default: drive#comment)
modifiedTimestring (date-time)The last time the comment or any of its replies was modified (RFC 3339 date-time).
quotedFileContentobjectThe file content to which the comment refers, typically within the anchor region. For a text file, for example, this would be the text at the location of the comment.
repliesarrayOutput only. The full list of replies to the comment in chronological order.
resolvedbooleanOutput only. Whether the comment has been resolved by one of its replies.

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
getselectfileId, commentIdincludeDeletedGets a comment by ID. For more information, see Manage comments and replies. Required: The fields parameter must be set. To return the exact fields you need, see Return specific fields.
listselectfileIdincludeDeleted, pageSize, pageToken, startModifiedTimeLists a file's comments. For more information, see Manage comments and replies. Required: The fields parameter must be set. To return the exact fields you need, see Return specific fields.
createinsertfileIdCreates a comment on a file. For more information, see Manage comments and replies. Required: The fields parameter must be set. To return the exact fields you need, see Return specific fields.
updateupdatefileId, commentIdUpdates a comment with patch semantics. For more information, see Manage comments and replies. Required: The fields parameter must be set. To return the exact fields you need, see Return specific fields.
deletedeletefileId, commentIdDeletes a comment. For more information, see Manage comments and replies.

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
commentIdstring
fileIdstring
includeDeletedboolean
pageSizeinteger (int32)
pageTokenstring
startModifiedTimestring

SELECT examples

Gets a comment by ID. For more information, see Manage comments and replies. Required: The fields parameter must be set. To return the exact fields you need, see Return specific fields.

SELECT
id,
anchor,
author,
content,
createdTime,
deleted,
htmlContent,
kind,
modifiedTime,
quotedFileContent,
replies,
resolved
FROM googleworkspace.drivev3.comments
WHERE fileId = '{{ fileId }}' -- required
AND commentId = '{{ commentId }}' -- required
AND includeDeleted = '{{ includeDeleted }}'
;

INSERT examples

Creates a comment on a file. For more information, see Manage comments and replies. Required: The fields parameter must be set. To return the exact fields you need, see Return specific fields.

INSERT INTO googleworkspace.drivev3.comments (
data__id,
data__kind,
data__createdTime,
data__modifiedTime,
data__resolved,
data__anchor,
data__replies,
data__author,
data__deleted,
data__htmlContent,
data__content,
data__quotedFileContent,
fileId
)
SELECT
'{{ id }}',
'{{ kind }}',
'{{ createdTime }}',
'{{ modifiedTime }}',
{{ resolved }},
'{{ anchor }}',
'{{ replies }}',
'{{ author }}',
{{ deleted }},
'{{ htmlContent }}',
'{{ content }}',
'{{ quotedFileContent }}',
'{{ fileId }}'
RETURNING
id,
anchor,
author,
content,
createdTime,
deleted,
htmlContent,
kind,
modifiedTime,
quotedFileContent,
replies,
resolved
;

UPDATE examples

Updates a comment with patch semantics. For more information, see Manage comments and replies. Required: The fields parameter must be set. To return the exact fields you need, see Return specific fields.

UPDATE googleworkspace.drivev3.comments
SET
data__id = '{{ id }}',
data__kind = '{{ kind }}',
data__createdTime = '{{ createdTime }}',
data__modifiedTime = '{{ modifiedTime }}',
data__resolved = {{ resolved }},
data__anchor = '{{ anchor }}',
data__replies = '{{ replies }}',
data__author = '{{ author }}',
data__deleted = {{ deleted }},
data__htmlContent = '{{ htmlContent }}',
data__content = '{{ content }}',
data__quotedFileContent = '{{ quotedFileContent }}'
WHERE
fileId = '{{ fileId }}' --required
AND commentId = '{{ commentId }}' --required
RETURNING
id,
anchor,
author,
content,
createdTime,
deleted,
htmlContent,
kind,
modifiedTime,
quotedFileContent,
replies,
resolved;

DELETE examples

Deletes a comment. For more information, see Manage comments and replies.

DELETE FROM googleworkspace.drivev3.comments
WHERE fileId = '{{ fileId }}' --required
AND commentId = '{{ commentId }}' --required
;