Skip to main content

documents

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

Overview

Namedocuments
TypeResource
Idgoogle.contentwarehouse.documents

Fields

The following fields are returned by SELECT queries:

Successful response

NameDatatypeDescription
namestringThe resource name of the document. Format: projects/{project_number}/locations/{location}/documents/{document_id}. The name is ignored when creating a document.
cloudAiDocumentobjectDocument AI format to save the structured content, including OCR. (id: GoogleCloudDocumentaiV1Document)
contentCategorystringIndicates the category (image, audio, video etc.) of the original content.
createTimestring (google-datetime)Output only. The time when the document is created.
creatorstringThe user who creates the document.
displayNamestringRequired. Display name of the document given by the user. This name will be displayed in the UI. Customer can populate this field with the name of the document. This differs from the 'title' field as 'title' is optional and stores the top heading in the document.
displayUristringUri to display the document, for example, in the UI.
dispositionTimestring (google-datetime)Output only. If linked to a Collection with RetentionPolicy, the date when the document becomes mutable.
documentSchemaNamestringThe Document schema name. Format: projects/{project_number}/locations/{location}/documentSchemas/{document_schema_id}.
inlineRawDocumentstring (byte)Raw document content.
legalHoldbooleanOutput only. Indicates if the document has a legal hold on it.
plainTextstringOther document format, such as PPTX, XLXS
propertiesarrayList of values that are user supplied metadata.
rawDocumentFileTypestringThis is used when DocAI was not used to load the document and parsing/ extracting is needed for the inline_raw_document. For example, if inline_raw_document is the byte representation of a PDF file, then this should be set to: RAW_DOCUMENT_FILE_TYPE_PDF.
rawDocumentPathstringRaw document file in Cloud Storage path.
referenceIdstringThe reference ID set by customers. Must be unique per project and location.
textExtractionDisabledbooleanIf true, text extraction will not be performed.
textExtractionEnabledbooleanIf true, text extraction will be performed.
titlestringTitle that describes the document. This can be the top heading or text that describes the document.
updateTimestring (google-datetime)Output only. The time when the document is last updated.
updaterstringThe user who lastly updates the document.

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
getselectprojectsId, locationsId, documentsIdGets a document. Returns NOT_FOUND if the document does not exist.
createinsertprojectsId, locationsIdCreates a document.
patchupdateprojectsId, locationsId, documentsIdUpdates a document. Returns INVALID_ARGUMENT if the name of the document is non-empty and does not equal the existing name.
deletedeleteprojectsId, locationsId, documentsIdDeletes a document. Returns NOT_FOUND if the document does not exist.
set_aclexecprojectsId, locationsId, documentsIdSets the access control policy for a resource. Replaces any existing policy.
lockexecprojectsId, locationsId, documentsIdLock the document so the document cannot be updated by other users.
linked_targetsexecprojectsId, locationsId, documentsIdReturn all target document-links from the document.
searchexecprojectsId, locationsIdSearches for documents using provided SearchDocumentsRequest. This call only returns documents that the caller has permission to search against.
linked_sourcesexecprojectsId, locationsId, documentsIdReturn all source document-links from the document.

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
documentsIdstring
locationsIdstring
projectsIdstring

SELECT examples

Gets a document. Returns NOT_FOUND if the document does not exist.

SELECT
name,
cloudAiDocument,
contentCategory,
createTime,
creator,
displayName,
displayUri,
dispositionTime,
documentSchemaName,
inlineRawDocument,
legalHold,
plainText,
properties,
rawDocumentFileType,
rawDocumentPath,
referenceId,
textExtractionDisabled,
textExtractionEnabled,
title,
updateTime,
updater
FROM google.contentwarehouse.documents
WHERE projectsId = '{{ projectsId }}' -- required
AND locationsId = '{{ locationsId }}' -- required
AND documentsId = '{{ documentsId }}' -- required;

INSERT examples

Creates a document.

INSERT INTO google.contentwarehouse.documents (
data__cloudAiDocumentOption,
data__createMask,
data__policy,
data__requestMetadata,
data__document,
projectsId,
locationsId
)
SELECT
'{{ cloudAiDocumentOption }}',
'{{ createMask }}',
'{{ policy }}',
'{{ requestMetadata }}',
'{{ document }}',
'{{ projectsId }}',
'{{ locationsId }}'
RETURNING
document,
longRunningOperations,
metadata,
ruleEngineOutput
;

UPDATE examples

Updates a document. Returns INVALID_ARGUMENT if the name of the document is non-empty and does not equal the existing name.

UPDATE google.contentwarehouse.documents
SET
data__updateOptions = '{{ updateOptions }}',
data__document = '{{ document }}',
data__requestMetadata = '{{ requestMetadata }}',
data__cloudAiDocumentOption = '{{ cloudAiDocumentOption }}'
WHERE
projectsId = '{{ projectsId }}' --required
AND locationsId = '{{ locationsId }}' --required
AND documentsId = '{{ documentsId }}' --required
RETURNING
document,
metadata,
ruleEngineOutput;

DELETE examples

Deletes a document. Returns NOT_FOUND if the document does not exist.

DELETE FROM google.contentwarehouse.documents
WHERE projectsId = '{{ projectsId }}' --required
AND locationsId = '{{ locationsId }}' --required
AND documentsId = '{{ documentsId }}' --required;

Lifecycle Methods

Sets the access control policy for a resource. Replaces any existing policy.

EXEC google.contentwarehouse.documents.set_acl 
@projectsId='{{ projectsId }}' --required,
@locationsId='{{ locationsId }}' --required,
@documentsId='{{ documentsId }}' --required
@@json=
'{
"requestMetadata": "{{ requestMetadata }}",
"policy": "{{ policy }}",
"projectOwner": {{ projectOwner }}
}';