Skip to content

Commit aae7bf5

Browse files
feat: [google-cloud-documentai] A new field schema_override is added to message ProcessOptions (#12315)
- [ ] Regenerate this pull request now. BEGIN_COMMIT_OVERRIDE feat: A new field `schema_override` is added to message `ProcessOptions` feat: A new field `labels` is added to messages `ProcessRequest` and `BatchProcessRequest` feat: A new field `display_name` is added to message `DocumentSchema` docs: updated comments END_COMMIT_OVERRIDE PiperOrigin-RevId: 607148983 Source-Link: googleapis/googleapis@9a9bc9b Source-Link: googleapis/googleapis-gen@b8c71bc Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLWRvY3VtZW50YWkvLk93bEJvdC55YW1sIiwiaCI6ImI4YzcxYmMyMDVjM2FkZWEyMzVkYzg3NmMyMTVkMmNlY2NiYjY2YTgifQ== --------- Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
1 parent b099445 commit aae7bf5

File tree

6 files changed

+72
-17
lines changed

6 files changed

+72
-17
lines changed

packages/google-cloud-documentai/google/cloud/documentai_v1/services/document_processor_service/async_client.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1961,7 +1961,9 @@ async def sample_create_processor():
19611961
processor (:class:`google.cloud.documentai_v1.types.Processor`):
19621962
Required. The processor to be created, requires
19631963
[Processor.type][google.cloud.documentai.v1.Processor.type]
1964-
and [Processor.display_name]][] to be set. Also, the
1964+
and
1965+
[Processor.display_name][google.cloud.documentai.v1.Processor.display_name]
1966+
to be set. Also, the
19651967
[Processor.kms_key_name][google.cloud.documentai.v1.Processor.kms_key_name]
19661968
field must be set if the processor is under CMEK.
19671969

packages/google-cloud-documentai/google/cloud/documentai_v1/services/document_processor_service/client.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2441,7 +2441,9 @@ def sample_create_processor():
24412441
processor (google.cloud.documentai_v1.types.Processor):
24422442
Required. The processor to be created, requires
24432443
[Processor.type][google.cloud.documentai.v1.Processor.type]
2444-
and [Processor.display_name]][] to be set. Also, the
2444+
and
2445+
[Processor.display_name][google.cloud.documentai.v1.Processor.display_name]
2446+
to be set. Also, the
24452447
[Processor.kms_key_name][google.cloud.documentai.v1.Processor.kms_key_name]
24462448
field must be set if the processor is under CMEK.
24472449

packages/google-cloud-documentai/google/cloud/documentai_v1/types/document.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1486,8 +1486,10 @@ class PageRef(proto.Message):
14861486
[PageRef.bounding_poly][google.cloud.documentai.v1.Document.PageAnchor.PageRef.bounding_poly]
14871487
instead.
14881488
bounding_poly (google.cloud.documentai_v1.types.BoundingPoly):
1489-
Optional. Identifies the bounding polygon of
1490-
a layout element on the page.
1489+
Optional. Identifies the bounding polygon of a layout
1490+
element on the page. If ``layout_type`` is set, the bounding
1491+
polygon must be exactly the same to the layout element it's
1492+
referring to.
14911493
confidence (float):
14921494
Optional. Confidence of detected page element, if
14931495
applicable. Range ``[0, 1]``.

packages/google-cloud-documentai/google/cloud/documentai_v1/types/document_processor_service.py

Lines changed: 46 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,16 @@ class ProcessOptions(proto.Message):
113113
114114
This field is a member of `oneof`_ ``page_range``.
115115
ocr_config (google.cloud.documentai_v1.types.OcrConfig):
116-
Only applicable to ``OCR_PROCESSOR``. Returns error if set
117-
on other processor types.
116+
Only applicable to ``OCR_PROCESSOR`` and
117+
``FORM_PARSER_PROCESSOR``. Returns error if set on other
118+
processor types.
119+
schema_override (google.cloud.documentai_v1.types.DocumentSchema):
120+
Optional. Override the schema of the
121+
[ProcessorVersion][google.cloud.documentai.v1.ProcessorVersion].
122+
Will return an Invalid Argument error if this field is set
123+
when the underlying
124+
[ProcessorVersion][google.cloud.documentai.v1.ProcessorVersion]
125+
doesn't support schema override.
118126
"""
119127

120128
class IndividualPageSelector(proto.Message):
@@ -152,6 +160,11 @@ class IndividualPageSelector(proto.Message):
152160
number=1,
153161
message=document_io.OcrConfig,
154162
)
163+
schema_override: gcd_document_schema.DocumentSchema = proto.Field(
164+
proto.MESSAGE,
165+
number=8,
166+
message=gcd_document_schema.DocumentSchema,
167+
)
155168

156169

157170
class ProcessRequest(proto.Message):
@@ -202,6 +215,15 @@ class ProcessRequest(proto.Message):
202215
``pages.{page_field_name}``.
203216
process_options (google.cloud.documentai_v1.types.ProcessOptions):
204217
Inference-time options for the process API
218+
labels (MutableMapping[str, str]):
219+
Optional. The labels with user-defined
220+
metadata for the request.
221+
Label keys and values can be no longer than 63
222+
characters (Unicode codepoints) and can only
223+
contain lowercase letters, numeric characters,
224+
underscores, and dashes. International
225+
characters are allowed. Label values are
226+
optional. Label keys must start with a letter.
205227
"""
206228

207229
inline_document: gcd_document.Document = proto.Field(
@@ -240,6 +262,11 @@ class ProcessRequest(proto.Message):
240262
number=7,
241263
message="ProcessOptions",
242264
)
265+
labels: MutableMapping[str, str] = proto.MapField(
266+
proto.STRING,
267+
proto.STRING,
268+
number=10,
269+
)
243270

244271

245272
class HumanReviewStatus(proto.Message):
@@ -357,6 +384,15 @@ class BatchProcessRequest(proto.Message):
357384
Default to ``false``.
358385
process_options (google.cloud.documentai_v1.types.ProcessOptions):
359386
Inference-time options for the process API
387+
labels (MutableMapping[str, str]):
388+
Optional. The labels with user-defined
389+
metadata for the request.
390+
Label keys and values can be no longer than 63
391+
characters (Unicode codepoints) and can only
392+
contain lowercase letters, numeric characters,
393+
underscores, and dashes. International
394+
characters are allowed. Label values are
395+
optional. Label keys must start with a letter.
360396
"""
361397

362398
name: str = proto.Field(
@@ -382,6 +418,11 @@ class BatchProcessRequest(proto.Message):
382418
number=7,
383419
message="ProcessOptions",
384420
)
421+
labels: MutableMapping[str, str] = proto.MapField(
422+
proto.STRING,
423+
proto.STRING,
424+
number=9,
425+
)
385426

386427

387428
class BatchProcessResponse(proto.Message):
@@ -917,7 +958,9 @@ class CreateProcessorRequest(proto.Message):
917958
processor (google.cloud.documentai_v1.types.Processor):
918959
Required. The processor to be created, requires
919960
[Processor.type][google.cloud.documentai.v1.Processor.type]
920-
and [Processor.display_name]][] to be set. Also, the
961+
and
962+
[Processor.display_name][google.cloud.documentai.v1.Processor.display_name]
963+
to be set. Also, the
921964
[Processor.kms_key_name][google.cloud.documentai.v1.Processor.kms_key_name]
922965
field must be set if the processor is under CMEK.
923966
"""

packages/google-cloud-documentai/google/cloud/documentai_v1/types/document_schema.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,8 @@ class Property(proto.Message):
107107
name (str):
108108
The name of the property. Follows the same
109109
guidelines as the EntityType name.
110+
display_name (str):
111+
User defined name for the property.
110112
value_type (str):
111113
A reference to the value type of the property. This type is
112114
subject to the same conventions as the ``Entity.base_types``
@@ -119,14 +121,14 @@ class Property(proto.Message):
119121

120122
class OccurrenceType(proto.Enum):
121123
r"""Types of occurrences of the entity type in the document. This
122-
represents the number of instances of an entity, not number of
123-
mentions of an entity. For example, a bank statement may only have
124-
one ``account_number``, but this account number may be mentioned in
125-
several places on the document. In this case the 'account_number'
126-
would be considered a ``REQUIRED_ONCE`` entity type. If, on the
127-
other hand, we expect a bank statement to contain the status of
128-
multiple different accounts for the customers, the occurrence type
129-
will be set to ``REQUIRED_MULTIPLE``.
124+
represents the number of instances, not mentions, of an entity. For
125+
example, a bank statement might only have one ``account_number``,
126+
but this account number can be mentioned in several places on the
127+
document. In this case, the ``account_number`` is considered a
128+
``REQUIRED_ONCE`` entity type. If, on the other hand, we expect a
129+
bank statement to contain the status of multiple different accounts
130+
for the customers, the occurrence type is set to
131+
``REQUIRED_MULTIPLE``.
130132
131133
Values:
132134
OCCURRENCE_TYPE_UNSPECIFIED (0):
@@ -156,6 +158,10 @@ class OccurrenceType(proto.Enum):
156158
proto.STRING,
157159
number=1,
158160
)
161+
display_name: str = proto.Field(
162+
proto.STRING,
163+
number=6,
164+
)
159165
value_type: str = proto.Field(
160166
proto.STRING,
161167
number=2,

packages/google-cloud-documentai/scripts/fixup_documentai_v1_keywords.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def partition(
3939
class documentaiCallTransformer(cst.CSTTransformer):
4040
CTRL_PARAMS: Tuple[str] = ('retry', 'timeout', 'metadata')
4141
METHOD_TO_PARAMS: Dict[str, Tuple[str]] = {
42-
'batch_process_documents': ('name', 'input_documents', 'document_output_config', 'skip_human_review', 'process_options', ),
42+
'batch_process_documents': ('name', 'input_documents', 'document_output_config', 'skip_human_review', 'process_options', 'labels', ),
4343
'create_processor': ('parent', 'processor', ),
4444
'delete_processor': ('name', ),
4545
'delete_processor_version': ('name', ),
@@ -56,7 +56,7 @@ class documentaiCallTransformer(cst.CSTTransformer):
5656
'list_processors': ('parent', 'page_size', 'page_token', ),
5757
'list_processor_types': ('parent', 'page_size', 'page_token', ),
5858
'list_processor_versions': ('parent', 'page_size', 'page_token', ),
59-
'process_document': ('name', 'inline_document', 'raw_document', 'gcs_document', 'skip_human_review', 'field_mask', 'process_options', ),
59+
'process_document': ('name', 'inline_document', 'raw_document', 'gcs_document', 'skip_human_review', 'field_mask', 'process_options', 'labels', ),
6060
'review_document': ('human_review_config', 'inline_document', 'enable_schema_validation', 'priority', 'document_schema', ),
6161
'set_default_processor_version': ('processor', 'default_processor_version', ),
6262
'train_processor_version': ('parent', 'processor_version', 'custom_document_extraction_options', 'document_schema', 'input_data', 'base_processor_version', ),

0 commit comments

Comments
 (0)