diff --git a/.coveragerc b/.coveragerc index 8620651a..2c6e2b9a 100644 --- a/.coveragerc +++ b/.coveragerc @@ -15,4 +15,4 @@ exclude_lines = # This is added at the module level as a safeguard for if someone # generates the code and tries to run it without pip installing. This # makes it virtually impossible to test properly. - except pkg_resources.DistributionNotFound \ No newline at end of file + except pkg_resources.DistributionNotFound diff --git a/docs/documentai_v1beta2/document_understanding_service.rst b/docs/documentai_v1beta2/document_understanding_service.rst new file mode 100644 index 00000000..a0d0da7e --- /dev/null +++ b/docs/documentai_v1beta2/document_understanding_service.rst @@ -0,0 +1,6 @@ +DocumentUnderstandingService +---------------------------------------------- + +.. automodule:: google.cloud.documentai_v1beta2.services.document_understanding_service + :members: + :inherited-members: diff --git a/docs/documentai_v1beta2/services.rst b/docs/documentai_v1beta2/services.rst index b1f00952..13f4a238 100644 --- a/docs/documentai_v1beta2/services.rst +++ b/docs/documentai_v1beta2/services.rst @@ -1,6 +1,6 @@ Services for Google Cloud Documentai v1beta2 API ================================================ +.. toctree:: + :maxdepth: 2 -.. automodule:: google.cloud.documentai_v1beta2.services.document_understanding_service - :members: - :inherited-members: + document_understanding_service diff --git a/docs/documentai_v1beta2/types.rst b/docs/documentai_v1beta2/types.rst index 35540dd0..9edede43 100644 --- a/docs/documentai_v1beta2/types.rst +++ b/docs/documentai_v1beta2/types.rst @@ -3,4 +3,5 @@ Types for Google Cloud Documentai v1beta2 API .. automodule:: google.cloud.documentai_v1beta2.types :members: + :undoc-members: :show-inheritance: diff --git a/docs/documentai_v1beta3/document_processor_service.rst b/docs/documentai_v1beta3/document_processor_service.rst new file mode 100644 index 00000000..6a2caa2b --- /dev/null +++ b/docs/documentai_v1beta3/document_processor_service.rst @@ -0,0 +1,6 @@ +DocumentProcessorService +------------------------------------------ + +.. automodule:: google.cloud.documentai_v1beta3.services.document_processor_service + :members: + :inherited-members: diff --git a/docs/documentai_v1beta3/services.rst b/docs/documentai_v1beta3/services.rst index b4a1011c..d19a944b 100644 --- a/docs/documentai_v1beta3/services.rst +++ b/docs/documentai_v1beta3/services.rst @@ -1,6 +1,6 @@ Services for Google Cloud Documentai v1beta3 API ================================================ +.. toctree:: + :maxdepth: 2 -.. automodule:: google.cloud.documentai_v1beta3.services.document_processor_service - :members: - :inherited-members: + document_processor_service diff --git a/docs/documentai_v1beta3/types.rst b/docs/documentai_v1beta3/types.rst index 31b489da..7e22aabc 100644 --- a/docs/documentai_v1beta3/types.rst +++ b/docs/documentai_v1beta3/types.rst @@ -3,4 +3,5 @@ Types for Google Cloud Documentai v1beta3 API .. automodule:: google.cloud.documentai_v1beta3.types :members: + :undoc-members: :show-inheritance: diff --git a/google/cloud/documentai_v1beta2/services/document_understanding_service/async_client.py b/google/cloud/documentai_v1beta2/services/document_understanding_service/async_client.py index c961662b..e57c3180 100644 --- a/google/cloud/documentai_v1beta2/services/document_understanding_service/async_client.py +++ b/google/cloud/documentai_v1beta2/services/document_understanding_service/async_client.py @@ -85,6 +85,9 @@ class DocumentUnderstandingServiceAsyncClient: DocumentUnderstandingServiceClient.parse_common_location_path ) + from_service_account_info = ( + DocumentUnderstandingServiceClient.from_service_account_info + ) from_service_account_file = ( DocumentUnderstandingServiceClient.from_service_account_file ) @@ -165,13 +168,14 @@ async def batch_process_documents( written to Cloud Storage as JSON in the [Document] format. Args: - request (:class:`~.document_understanding.BatchProcessDocumentsRequest`): + request (:class:`google.cloud.documentai_v1beta2.types.BatchProcessDocumentsRequest`): The request object. Request to batch process documents as an asynchronous operation. The output is written to Cloud Storage as JSON in the [Document] format. - requests (:class:`Sequence[~.document_understanding.ProcessDocumentRequest]`): + requests (:class:`Sequence[google.cloud.documentai_v1beta2.types.ProcessDocumentRequest]`): Required. Individual requests for each document. + This corresponds to the ``requests`` field on the ``request`` instance; if ``request`` is provided, this should not be set. @@ -183,14 +187,11 @@ async def batch_process_documents( sent along with the request as metadata. Returns: - ~.operation_async.AsyncOperation: + google.api_core.operation_async.AsyncOperation: An object representing a long-running operation. - The result type for the operation will be - :class:``~.document_understanding.BatchProcessDocumentsResponse``: - Response to an batch document processing request. This - is returned in the LRO Operation after the operation is - complete. + The result type for the operation will be :class:`google.cloud.documentai_v1beta2.types.BatchProcessDocumentsResponse` Response to an batch document processing request. This is returned in + the LRO Operation after the operation is complete. """ # Create or coerce a protobuf request object. @@ -258,7 +259,7 @@ async def process_document( r"""Processes a single document. Args: - request (:class:`~.document_understanding.ProcessDocumentRequest`): + request (:class:`google.cloud.documentai_v1beta2.types.ProcessDocumentRequest`): The request object. Request to process one document. retry (google.api_core.retry.Retry): Designation of what errors, if any, @@ -268,7 +269,7 @@ async def process_document( sent along with the request as metadata. Returns: - ~.document.Document: + google.cloud.documentai_v1beta2.types.Document: Document represents the canonical document resource in Document Understanding AI. It is an interchange diff --git a/google/cloud/documentai_v1beta2/services/document_understanding_service/client.py b/google/cloud/documentai_v1beta2/services/document_understanding_service/client.py index 0d740e5b..d417e2e0 100644 --- a/google/cloud/documentai_v1beta2/services/document_understanding_service/client.py +++ b/google/cloud/documentai_v1beta2/services/document_understanding_service/client.py @@ -122,6 +122,22 @@ def _get_default_mtls_endpoint(api_endpoint): DEFAULT_ENDPOINT ) + @classmethod + def from_service_account_info(cls, info: dict, *args, **kwargs): + """Creates an instance of this client using the provided credentials info. + + Args: + info (dict): The service account private key info. + args: Additional arguments to pass to the constructor. + kwargs: Additional arguments to pass to the constructor. + + Returns: + DocumentUnderstandingServiceClient: The constructed client. + """ + credentials = service_account.Credentials.from_service_account_info(info) + kwargs["credentials"] = credentials + return cls(*args, **kwargs) + @classmethod def from_service_account_file(cls, filename: str, *args, **kwargs): """Creates an instance of this client using the provided credentials @@ -134,7 +150,7 @@ def from_service_account_file(cls, filename: str, *args, **kwargs): kwargs: Additional arguments to pass to the constructor. Returns: - {@api.name}: The constructed client. + DocumentUnderstandingServiceClient: The constructed client. """ credentials = service_account.Credentials.from_service_account_file(filename) kwargs["credentials"] = credentials @@ -226,10 +242,10 @@ def __init__( credentials identify the application to the service; if none are specified, the client will attempt to ascertain the credentials from the environment. - transport (Union[str, ~.DocumentUnderstandingServiceTransport]): The + transport (Union[str, DocumentUnderstandingServiceTransport]): The transport to use. If set to None, a transport is chosen automatically. - client_options (client_options_lib.ClientOptions): Custom options for the + client_options (google.api_core.client_options.ClientOptions): Custom options for the client. It won't take effect if a ``transport`` instance is provided. (1) The ``api_endpoint`` property can be used to override the default endpoint provided by the client. GOOGLE_API_USE_MTLS_ENDPOINT @@ -340,13 +356,14 @@ def batch_process_documents( written to Cloud Storage as JSON in the [Document] format. Args: - request (:class:`~.document_understanding.BatchProcessDocumentsRequest`): + request (google.cloud.documentai_v1beta2.types.BatchProcessDocumentsRequest): The request object. Request to batch process documents as an asynchronous operation. The output is written to Cloud Storage as JSON in the [Document] format. - requests (:class:`Sequence[~.document_understanding.ProcessDocumentRequest]`): + requests (Sequence[google.cloud.documentai_v1beta2.types.ProcessDocumentRequest]): Required. Individual requests for each document. + This corresponds to the ``requests`` field on the ``request`` instance; if ``request`` is provided, this should not be set. @@ -358,14 +375,11 @@ def batch_process_documents( sent along with the request as metadata. Returns: - ~.operation.Operation: + google.api_core.operation.Operation: An object representing a long-running operation. - The result type for the operation will be - :class:``~.document_understanding.BatchProcessDocumentsResponse``: - Response to an batch document processing request. This - is returned in the LRO Operation after the operation is - complete. + The result type for the operation will be :class:`google.cloud.documentai_v1beta2.types.BatchProcessDocumentsResponse` Response to an batch document processing request. This is returned in + the LRO Operation after the operation is complete. """ # Create or coerce a protobuf request object. @@ -426,7 +440,7 @@ def process_document( r"""Processes a single document. Args: - request (:class:`~.document_understanding.ProcessDocumentRequest`): + request (google.cloud.documentai_v1beta2.types.ProcessDocumentRequest): The request object. Request to process one document. retry (google.api_core.retry.Retry): Designation of what errors, if any, @@ -436,7 +450,7 @@ def process_document( sent along with the request as metadata. Returns: - ~.document.Document: + google.cloud.documentai_v1beta2.types.Document: Document represents the canonical document resource in Document Understanding AI. It is an interchange diff --git a/google/cloud/documentai_v1beta2/types/document.py b/google/cloud/documentai_v1beta2/types/document.py index 7b7d15af..e2411002 100644 --- a/google/cloud/documentai_v1beta2/types/document.py +++ b/google/cloud/documentai_v1beta2/types/document.py @@ -55,29 +55,29 @@ class Document(proto.Message): text (str): UTF-8 encoded text in reading order from the document. - text_styles (Sequence[~.document.Document.Style]): + text_styles (Sequence[google.cloud.documentai_v1beta2.types.Document.Style]): Styles for the [Document.text][google.cloud.documentai.v1beta2.Document.text]. - pages (Sequence[~.document.Document.Page]): + pages (Sequence[google.cloud.documentai_v1beta2.types.Document.Page]): Visual page layout for the [Document][google.cloud.documentai.v1beta2.Document]. - entities (Sequence[~.document.Document.Entity]): + entities (Sequence[google.cloud.documentai_v1beta2.types.Document.Entity]): A list of entities detected on [Document.text][google.cloud.documentai.v1beta2.Document.text]. For document shards, entities in this list may cross shard boundaries. - entity_relations (Sequence[~.document.Document.EntityRelation]): + entity_relations (Sequence[google.cloud.documentai_v1beta2.types.Document.EntityRelation]): Relationship among [Document.entities][google.cloud.documentai.v1beta2.Document.entities]. - shard_info (~.document.Document.ShardInfo): + shard_info (google.cloud.documentai_v1beta2.types.Document.ShardInfo): Information about the sharding if this document is sharded part of a larger document. If the document is not sharded, this message is not specified. - labels (Sequence[~.document.Document.Label]): + labels (Sequence[google.cloud.documentai_v1beta2.types.Document.Label]): [Label][google.cloud.documentai.v1beta2.Document.Label]s for this document. - error (~.status.Status): + error (google.rpc.status_pb2.Status): Any error that occurred while processing this document. """ @@ -140,12 +140,12 @@ class Style(proto.Message): CSS conventions as much as possible. Attributes: - text_anchor (~.document.Document.TextAnchor): + text_anchor (google.cloud.documentai_v1beta2.types.Document.TextAnchor): Text anchor indexing into the [Document.text][google.cloud.documentai.v1beta2.Document.text]. - color (~.gt_color.Color): + color (google.type.color_pb2.Color): Text color. - background_color (~.gt_color.Color): + background_color (google.type.color_pb2.Color): Text background color. font_weight (str): Font weight. Possible values are normal, bold, bolder, and @@ -156,7 +156,7 @@ class Style(proto.Message): text_decoration (str): Text decoration. Follows CSS standard. https://www.w3schools.com/cssref/pr_text_text-decoration.asp - font_size (~.document.Document.Style.FontSize): + font_size (google.cloud.documentai_v1beta2.types.Document.Style.FontSize): Font size. """ @@ -204,37 +204,37 @@ class Page(proto.Message): Useful when a page is taken out of a [Document][google.cloud.documentai.v1beta2.Document] for individual processing. - dimension (~.document.Document.Page.Dimension): + dimension (google.cloud.documentai_v1beta2.types.Document.Page.Dimension): Physical dimension of the page. - layout (~.document.Document.Page.Layout): + layout (google.cloud.documentai_v1beta2.types.Document.Page.Layout): [Layout][google.cloud.documentai.v1beta2.Document.Page.Layout] for the page. - detected_languages (Sequence[~.document.Document.Page.DetectedLanguage]): + detected_languages (Sequence[google.cloud.documentai_v1beta2.types.Document.Page.DetectedLanguage]): A list of detected languages together with confidence. - blocks (Sequence[~.document.Document.Page.Block]): + blocks (Sequence[google.cloud.documentai_v1beta2.types.Document.Page.Block]): A list of visually detected text blocks on the page. A block has a set of lines (collected into paragraphs) that have a common line-spacing and orientation. - paragraphs (Sequence[~.document.Document.Page.Paragraph]): + paragraphs (Sequence[google.cloud.documentai_v1beta2.types.Document.Page.Paragraph]): A list of visually detected text paragraphs on the page. A collection of lines that a human would perceive as a paragraph. - lines (Sequence[~.document.Document.Page.Line]): + lines (Sequence[google.cloud.documentai_v1beta2.types.Document.Page.Line]): A list of visually detected text lines on the page. A collection of tokens that a human would perceive as a line. - tokens (Sequence[~.document.Document.Page.Token]): + tokens (Sequence[google.cloud.documentai_v1beta2.types.Document.Page.Token]): A list of visually detected tokens on the page. - visual_elements (Sequence[~.document.Document.Page.VisualElement]): + visual_elements (Sequence[google.cloud.documentai_v1beta2.types.Document.Page.VisualElement]): A list of detected non-text visual elements e.g. checkbox, signature etc. on the page. - tables (Sequence[~.document.Document.Page.Table]): + tables (Sequence[google.cloud.documentai_v1beta2.types.Document.Page.Table]): A list of visually detected tables on the page. - form_fields (Sequence[~.document.Document.Page.FormField]): + form_fields (Sequence[google.cloud.documentai_v1beta2.types.Document.Page.FormField]): A list of visually detected form fields on the page. """ @@ -261,7 +261,7 @@ class Layout(proto.Message): r"""Visual element describing a layout unit on a page. Attributes: - text_anchor (~.document.Document.TextAnchor): + text_anchor (google.cloud.documentai_v1beta2.types.Document.TextAnchor): Text anchor indexing into the [Document.text][google.cloud.documentai.v1beta2.Document.text]. confidence (float): @@ -270,10 +270,10 @@ class Layout(proto.Message): within context of the object this layout is for. e.g. confidence can be for a single token, a table, a visual element, etc. depending on context. Range [0, 1]. - bounding_poly (~.geometry.BoundingPoly): + bounding_poly (google.cloud.documentai_v1beta2.types.BoundingPoly): The bounding polygon for the [Layout][google.cloud.documentai.v1beta2.Document.Page.Layout]. - orientation (~.document.Document.Page.Layout.Orientation): + orientation (google.cloud.documentai_v1beta2.types.Document.Page.Layout.Orientation): Detected orientation for the [Layout][google.cloud.documentai.v1beta2.Document.Page.Layout]. id (str): @@ -310,11 +310,11 @@ class Block(proto.Message): have a common line-spacing and orientation. Attributes: - layout (~.document.Document.Page.Layout): + layout (google.cloud.documentai_v1beta2.types.Document.Page.Layout): [Layout][google.cloud.documentai.v1beta2.Document.Page.Layout] for [Block][google.cloud.documentai.v1beta2.Document.Page.Block]. - detected_languages (Sequence[~.document.Document.Page.DetectedLanguage]): + detected_languages (Sequence[google.cloud.documentai_v1beta2.types.Document.Page.DetectedLanguage]): A list of detected languages together with confidence. """ @@ -332,11 +332,11 @@ class Paragraph(proto.Message): paragraph. Attributes: - layout (~.document.Document.Page.Layout): + layout (google.cloud.documentai_v1beta2.types.Document.Page.Layout): [Layout][google.cloud.documentai.v1beta2.Document.Page.Layout] for [Paragraph][google.cloud.documentai.v1beta2.Document.Page.Paragraph]. - detected_languages (Sequence[~.document.Document.Page.DetectedLanguage]): + detected_languages (Sequence[google.cloud.documentai_v1beta2.types.Document.Page.DetectedLanguage]): A list of detected languages together with confidence. """ @@ -355,11 +355,11 @@ class Line(proto.Message): etc. Attributes: - layout (~.document.Document.Page.Layout): + layout (google.cloud.documentai_v1beta2.types.Document.Page.Layout): [Layout][google.cloud.documentai.v1beta2.Document.Page.Layout] for [Line][google.cloud.documentai.v1beta2.Document.Page.Line]. - detected_languages (Sequence[~.document.Document.Page.DetectedLanguage]): + detected_languages (Sequence[google.cloud.documentai_v1beta2.types.Document.Page.DetectedLanguage]): A list of detected languages together with confidence. """ @@ -376,14 +376,14 @@ class Token(proto.Message): r"""A detected token. Attributes: - layout (~.document.Document.Page.Layout): + layout (google.cloud.documentai_v1beta2.types.Document.Page.Layout): [Layout][google.cloud.documentai.v1beta2.Document.Page.Layout] for [Token][google.cloud.documentai.v1beta2.Document.Page.Token]. - detected_break (~.document.Document.Page.Token.DetectedBreak): + detected_break (google.cloud.documentai_v1beta2.types.Document.Page.Token.DetectedBreak): Detected break at the end of a [Token][google.cloud.documentai.v1beta2.Document.Page.Token]. - detected_languages (Sequence[~.document.Document.Page.DetectedLanguage]): + detected_languages (Sequence[google.cloud.documentai_v1beta2.types.Document.Page.DetectedLanguage]): A list of detected languages together with confidence. """ @@ -393,7 +393,7 @@ class DetectedBreak(proto.Message): [Token][google.cloud.documentai.v1beta2.Document.Page.Token]. Attributes: - type_ (~.document.Document.Page.Token.DetectedBreak.Type): + type_ (google.cloud.documentai_v1beta2.types.Document.Page.Token.DetectedBreak.Type): Detected break type. """ @@ -425,14 +425,14 @@ class VisualElement(proto.Message): etc. on the page. Attributes: - layout (~.document.Document.Page.Layout): + layout (google.cloud.documentai_v1beta2.types.Document.Page.Layout): [Layout][google.cloud.documentai.v1beta2.Document.Page.Layout] for [VisualElement][google.cloud.documentai.v1beta2.Document.Page.VisualElement]. type_ (str): Type of the [VisualElement][google.cloud.documentai.v1beta2.Document.Page.VisualElement]. - detected_languages (Sequence[~.document.Document.Page.DetectedLanguage]): + detected_languages (Sequence[google.cloud.documentai_v1beta2.types.Document.Page.DetectedLanguage]): A list of detected languages together with confidence. """ @@ -451,15 +451,15 @@ class Table(proto.Message): r"""A table representation similar to HTML table structure. Attributes: - layout (~.document.Document.Page.Layout): + layout (google.cloud.documentai_v1beta2.types.Document.Page.Layout): [Layout][google.cloud.documentai.v1beta2.Document.Page.Layout] for [Table][google.cloud.documentai.v1beta2.Document.Page.Table]. - header_rows (Sequence[~.document.Document.Page.Table.TableRow]): + header_rows (Sequence[google.cloud.documentai_v1beta2.types.Document.Page.Table.TableRow]): Header rows of the table. - body_rows (Sequence[~.document.Document.Page.Table.TableRow]): + body_rows (Sequence[google.cloud.documentai_v1beta2.types.Document.Page.Table.TableRow]): Body rows of the table. - detected_languages (Sequence[~.document.Document.Page.DetectedLanguage]): + detected_languages (Sequence[google.cloud.documentai_v1beta2.types.Document.Page.DetectedLanguage]): A list of detected languages together with confidence. """ @@ -468,7 +468,7 @@ class TableRow(proto.Message): r"""A row of table cells. Attributes: - cells (Sequence[~.document.Document.Page.Table.TableCell]): + cells (Sequence[google.cloud.documentai_v1beta2.types.Document.Page.Table.TableCell]): Cells that make up this row. """ @@ -480,7 +480,7 @@ class TableCell(proto.Message): r"""A cell representation inside the table. Attributes: - layout (~.document.Document.Page.Layout): + layout (google.cloud.documentai_v1beta2.types.Document.Page.Layout): [Layout][google.cloud.documentai.v1beta2.Document.Page.Layout] for [TableCell][google.cloud.documentai.v1beta2.Document.Page.Table.TableCell]. @@ -488,7 +488,7 @@ class TableCell(proto.Message): How many rows this cell spans. col_span (int): How many columns this cell spans. - detected_languages (Sequence[~.document.Document.Page.DetectedLanguage]): + detected_languages (Sequence[google.cloud.documentai_v1beta2.types.Document.Page.DetectedLanguage]): A list of detected languages together with confidence. """ @@ -525,21 +525,21 @@ class FormField(proto.Message): r"""A form field detected on the page. Attributes: - field_name (~.document.Document.Page.Layout): + field_name (google.cloud.documentai_v1beta2.types.Document.Page.Layout): [Layout][google.cloud.documentai.v1beta2.Document.Page.Layout] for the [FormField][google.cloud.documentai.v1beta2.Document.Page.FormField] name. e.g. ``Address``, ``Email``, ``Grand total``, ``Phone number``, etc. - field_value (~.document.Document.Page.Layout): + field_value (google.cloud.documentai_v1beta2.types.Document.Page.Layout): [Layout][google.cloud.documentai.v1beta2.Document.Page.Layout] for the [FormField][google.cloud.documentai.v1beta2.Document.Page.FormField] value. - name_detected_languages (Sequence[~.document.Document.Page.DetectedLanguage]): + name_detected_languages (Sequence[google.cloud.documentai_v1beta2.types.Document.Page.DetectedLanguage]): A list of detected languages for name together with confidence. - value_detected_languages (Sequence[~.document.Document.Page.DetectedLanguage]): + value_detected_languages (Sequence[google.cloud.documentai_v1beta2.types.Document.Page.DetectedLanguage]): A list of detected languages for value together with confidence. value_type (str): @@ -640,7 +640,7 @@ class Entity(proto.Message): person, an organization, or location. Attributes: - text_anchor (~.document.Document.TextAnchor): + text_anchor (google.cloud.documentai_v1beta2.types.Document.TextAnchor): Provenance of the entity. Text anchor indexing into the [Document.text][google.cloud.documentai.v1beta2.Document.text]. type_ (str): @@ -652,14 +652,14 @@ class Entity(proto.Message): confidence (float): Optional. Confidence of detected Schema entity. Range [0, 1]. - page_anchor (~.document.Document.PageAnchor): + page_anchor (google.cloud.documentai_v1beta2.types.Document.PageAnchor): Optional. Represents the provenance of this entity wrt. the location on the page where it was found. id (str): Optional. Canonical id. This will be a unique value in the entity list for this document. - bounding_poly_for_demo_frontend (~.geometry.BoundingPoly): + bounding_poly_for_demo_frontend (google.cloud.documentai_v1beta2.types.BoundingPoly): Optional. Temporary field to store the bounding poly for short-term POCs. Used by the frontend only. Do not use before you talk to @@ -712,7 +712,7 @@ class TextAnchor(proto.Message): [Document.text][google.cloud.documentai.v1beta2.Document.text]. Attributes: - text_segments (Sequence[~.document.Document.TextAnchor.TextSegment]): + text_segments (Sequence[google.cloud.documentai_v1beta2.types.Document.TextAnchor.TextSegment]): The text segments from the [Document.text][google.cloud.documentai.v1beta2.Document.text]. """ @@ -748,7 +748,7 @@ class PageAnchor(proto.Message): [Document.pages][google.cloud.documentai.v1beta2.Document.pages]. Attributes: - page_refs (Sequence[~.document.Document.PageAnchor.PageRef]): + page_refs (Sequence[google.cloud.documentai_v1beta2.types.Document.PageAnchor.PageRef]): One or more references to visual page elements """ @@ -762,7 +762,7 @@ class PageRef(proto.Message): Required. Index into the [Document.pages][google.cloud.documentai.v1beta2.Document.pages] element - layout_type (~.document.Document.PageAnchor.PageRef.LayoutType): + layout_type (google.cloud.documentai_v1beta2.types.Document.PageAnchor.PageRef.LayoutType): Optional. The type of the layout element that is being referenced. If not specified the whole page is assumed to be referenced. diff --git a/google/cloud/documentai_v1beta2/types/document_understanding.py b/google/cloud/documentai_v1beta2/types/document_understanding.py index bdf2299f..dd80f269 100644 --- a/google/cloud/documentai_v1beta2/types/document_understanding.py +++ b/google/cloud/documentai_v1beta2/types/document_understanding.py @@ -50,7 +50,7 @@ class BatchProcessDocumentsRequest(proto.Message): output is written to Cloud Storage as JSON in the [Document] format. Attributes: - requests (Sequence[~.document_understanding.ProcessDocumentRequest]): + requests (Sequence[google.cloud.documentai_v1beta2.types.ProcessDocumentRequest]): Required. Individual requests for each document. parent (str): @@ -81,9 +81,9 @@ class ProcessDocumentRequest(proto.Message): If no location is specified, a region will be chosen automatically. This field is only populated when used in ProcessDocument method. - input_config (~.document_understanding.InputConfig): + input_config (google.cloud.documentai_v1beta2.types.InputConfig): Required. Information about the input file. - output_config (~.document_understanding.OutputConfig): + output_config (google.cloud.documentai_v1beta2.types.OutputConfig): Optional. The desired output location. This field is only needed in BatchProcessDocumentsRequest. @@ -93,22 +93,22 @@ class ProcessDocumentRequest(proto.Message): "general" and "invoice". If not provided, "general"\ is used as default. If any other value is given, the request is rejected. - table_extraction_params (~.document_understanding.TableExtractionParams): + table_extraction_params (google.cloud.documentai_v1beta2.types.TableExtractionParams): Controls table extraction behavior. If not specified, the system will decide reasonable defaults. - form_extraction_params (~.document_understanding.FormExtractionParams): + form_extraction_params (google.cloud.documentai_v1beta2.types.FormExtractionParams): Controls form extraction behavior. If not specified, the system will decide reasonable defaults. - entity_extraction_params (~.document_understanding.EntityExtractionParams): + entity_extraction_params (google.cloud.documentai_v1beta2.types.EntityExtractionParams): Controls entity extraction behavior. If not specified, the system will decide reasonable defaults. - ocr_params (~.document_understanding.OcrParams): + ocr_params (google.cloud.documentai_v1beta2.types.OcrParams): Controls OCR behavior. If not specified, the system will decide reasonable defaults. - automl_params (~.document_understanding.AutoMlParams): + automl_params (google.cloud.documentai_v1beta2.types.AutoMlParams): Controls AutoML model prediction behavior. AutoMlParams cannot be used together with other Params. @@ -144,7 +144,7 @@ class BatchProcessDocumentsResponse(proto.Message): returned in the LRO Operation after the operation is complete. Attributes: - responses (Sequence[~.document_understanding.ProcessDocumentResponse]): + responses (Sequence[google.cloud.documentai_v1beta2.types.ProcessDocumentResponse]): Responses for each individual document. """ @@ -157,11 +157,11 @@ class ProcessDocumentResponse(proto.Message): r"""Response to a single document processing request. Attributes: - input_config (~.document_understanding.InputConfig): + input_config (google.cloud.documentai_v1beta2.types.InputConfig): Information about the input file. This is the same as the corresponding input config in the request. - output_config (~.document_understanding.OutputConfig): + output_config (google.cloud.documentai_v1beta2.types.OutputConfig): The output location of the parsed responses. The responses are written to this location as JSON-serialized ``Document`` objects. @@ -198,7 +198,7 @@ class TableExtractionParams(proto.Message): Attributes: enabled (bool): Whether to enable table extraction. - table_bound_hints (Sequence[~.document_understanding.TableBoundHint]): + table_bound_hints (Sequence[google.cloud.documentai_v1beta2.types.TableBoundHint]): Optional. Table bounding box hints that can be provided to complex cases which our algorithm cannot locate the table(s) in. @@ -233,7 +233,7 @@ class TableBoundHint(proto.Message): this hint applies to. If not provided, this hint will apply to all pages by default. This value is 1-based. - bounding_box (~.geometry.BoundingPoly): + bounding_box (google.cloud.documentai_v1beta2.types.BoundingPoly): Bounding box hint for a table on this page. The coordinates must be normalized to [0,1] and the bounding box must be an axis-aligned rectangle. @@ -250,7 +250,7 @@ class FormExtractionParams(proto.Message): Attributes: enabled (bool): Whether to enable form extraction. - key_value_pair_hints (Sequence[~.document_understanding.KeyValuePairHint]): + key_value_pair_hints (Sequence[google.cloud.documentai_v1beta2.types.KeyValuePairHint]): User can provide pairs of (key text, value type) to improve the parsing result. @@ -336,7 +336,7 @@ class InputConfig(proto.Message): r"""The desired input location and metadata. Attributes: - gcs_source (~.document_understanding.GcsSource): + gcs_source (google.cloud.documentai_v1beta2.types.GcsSource): The Google Cloud Storage location to read the input from. This must be a single file. contents (bytes): @@ -369,7 +369,7 @@ class OutputConfig(proto.Message): r"""The desired output location and metadata. Attributes: - gcs_destination (~.document_understanding.GcsDestination): + gcs_destination (google.cloud.documentai_v1beta2.types.GcsDestination): The Google Cloud Storage location to write the output to. pages_per_shard (int): @@ -427,14 +427,14 @@ class OperationMetadata(proto.Message): r"""Contains metadata for the BatchProcessDocuments operation. Attributes: - state (~.document_understanding.OperationMetadata.State): + state (google.cloud.documentai_v1beta2.types.OperationMetadata.State): The state of the current batch processing. state_message (str): A message providing more details about the current state of processing. - create_time (~.timestamp.Timestamp): + create_time (google.protobuf.timestamp_pb2.Timestamp): The creation time of the operation. - update_time (~.timestamp.Timestamp): + update_time (google.protobuf.timestamp_pb2.Timestamp): The last update time of the operation. """ diff --git a/google/cloud/documentai_v1beta2/types/geometry.py b/google/cloud/documentai_v1beta2/types/geometry.py index 0592f336..38ae138a 100644 --- a/google/cloud/documentai_v1beta2/types/geometry.py +++ b/google/cloud/documentai_v1beta2/types/geometry.py @@ -62,9 +62,9 @@ class BoundingPoly(proto.Message): r"""A bounding polygon for the detected image annotation. Attributes: - vertices (Sequence[~.geometry.Vertex]): + vertices (Sequence[google.cloud.documentai_v1beta2.types.Vertex]): The bounding polygon vertices. - normalized_vertices (Sequence[~.geometry.NormalizedVertex]): + normalized_vertices (Sequence[google.cloud.documentai_v1beta2.types.NormalizedVertex]): The bounding polygon normalized vertices. """ diff --git a/google/cloud/documentai_v1beta3/services/document_processor_service/async_client.py b/google/cloud/documentai_v1beta3/services/document_processor_service/async_client.py index 467b072a..a2077e22 100644 --- a/google/cloud/documentai_v1beta3/services/document_processor_service/async_client.py +++ b/google/cloud/documentai_v1beta3/services/document_processor_service/async_client.py @@ -95,6 +95,7 @@ class DocumentProcessorServiceAsyncClient: DocumentProcessorServiceClient.parse_common_location_path ) + from_service_account_info = DocumentProcessorServiceClient.from_service_account_info from_service_account_file = DocumentProcessorServiceClient.from_service_account_file from_service_account_json = from_service_account_file @@ -172,12 +173,13 @@ async def process_document( r"""Processes a single document. Args: - request (:class:`~.document_processor_service.ProcessRequest`): + request (:class:`google.cloud.documentai_v1beta3.types.ProcessRequest`): The request object. Request message for the process document method. name (:class:`str`): Required. The processor resource name. + This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. @@ -189,7 +191,7 @@ async def process_document( sent along with the request as metadata. Returns: - ~.document_processor_service.ProcessResponse: + google.cloud.documentai_v1beta3.types.ProcessResponse: Response message for the process document method. @@ -253,12 +255,13 @@ async def batch_process_documents( written to Cloud Storage as JSON in the [Document] format. Args: - request (:class:`~.document_processor_service.BatchProcessRequest`): + request (:class:`google.cloud.documentai_v1beta3.types.BatchProcessRequest`): The request object. Request message for batch process document method. name (:class:`str`): Required. The processor resource name. + This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. @@ -270,11 +273,11 @@ async def batch_process_documents( sent along with the request as metadata. Returns: - ~.operation_async.AsyncOperation: + google.api_core.operation_async.AsyncOperation: An object representing a long-running operation. The result type for the operation will be - :class:``~.document_processor_service.BatchProcessResponse``: + :class:`google.cloud.documentai_v1beta3.types.BatchProcessResponse` Response message for batch process document method. """ @@ -345,13 +348,14 @@ async def review_document( should be processed by the specified processor. Args: - request (:class:`~.document_processor_service.ReviewDocumentRequest`): + request (:class:`google.cloud.documentai_v1beta3.types.ReviewDocumentRequest`): The request object. Request message for review document method. human_review_config (:class:`str`): Required. The resource name of the HumanReviewConfig that the document will be reviewed with. + This corresponds to the ``human_review_config`` field on the ``request`` instance; if ``request`` is provided, this should not be set. @@ -363,11 +367,11 @@ async def review_document( sent along with the request as metadata. Returns: - ~.operation_async.AsyncOperation: + google.api_core.operation_async.AsyncOperation: An object representing a long-running operation. The result type for the operation will be - :class:``~.document_processor_service.ReviewDocumentResponse``: + :class:`google.cloud.documentai_v1beta3.types.ReviewDocumentResponse` Response message for review document method. """ diff --git a/google/cloud/documentai_v1beta3/services/document_processor_service/client.py b/google/cloud/documentai_v1beta3/services/document_processor_service/client.py index e621e251..3c039826 100644 --- a/google/cloud/documentai_v1beta3/services/document_processor_service/client.py +++ b/google/cloud/documentai_v1beta3/services/document_processor_service/client.py @@ -119,6 +119,22 @@ def _get_default_mtls_endpoint(api_endpoint): DEFAULT_ENDPOINT ) + @classmethod + def from_service_account_info(cls, info: dict, *args, **kwargs): + """Creates an instance of this client using the provided credentials info. + + Args: + info (dict): The service account private key info. + args: Additional arguments to pass to the constructor. + kwargs: Additional arguments to pass to the constructor. + + Returns: + DocumentProcessorServiceClient: The constructed client. + """ + credentials = service_account.Credentials.from_service_account_info(info) + kwargs["credentials"] = credentials + return cls(*args, **kwargs) + @classmethod def from_service_account_file(cls, filename: str, *args, **kwargs): """Creates an instance of this client using the provided credentials @@ -131,7 +147,7 @@ def from_service_account_file(cls, filename: str, *args, **kwargs): kwargs: Additional arguments to pass to the constructor. Returns: - {@api.name}: The constructed client. + DocumentProcessorServiceClient: The constructed client. """ credentials = service_account.Credentials.from_service_account_file(filename) kwargs["credentials"] = credentials @@ -255,10 +271,10 @@ def __init__( credentials identify the application to the service; if none are specified, the client will attempt to ascertain the credentials from the environment. - transport (Union[str, ~.DocumentProcessorServiceTransport]): The + transport (Union[str, DocumentProcessorServiceTransport]): The transport to use. If set to None, a transport is chosen automatically. - client_options (client_options_lib.ClientOptions): Custom options for the + client_options (google.api_core.client_options.ClientOptions): Custom options for the client. It won't take effect if a ``transport`` instance is provided. (1) The ``api_endpoint`` property can be used to override the default endpoint provided by the client. GOOGLE_API_USE_MTLS_ENDPOINT @@ -368,12 +384,13 @@ def process_document( r"""Processes a single document. Args: - request (:class:`~.document_processor_service.ProcessRequest`): + request (google.cloud.documentai_v1beta3.types.ProcessRequest): The request object. Request message for the process document method. - name (:class:`str`): + name (str): Required. The processor resource name. + This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. @@ -385,7 +402,7 @@ def process_document( sent along with the request as metadata. Returns: - ~.document_processor_service.ProcessResponse: + google.cloud.documentai_v1beta3.types.ProcessResponse: Response message for the process document method. @@ -442,12 +459,13 @@ def batch_process_documents( written to Cloud Storage as JSON in the [Document] format. Args: - request (:class:`~.document_processor_service.BatchProcessRequest`): + request (google.cloud.documentai_v1beta3.types.BatchProcessRequest): The request object. Request message for batch process document method. - name (:class:`str`): + name (str): Required. The processor resource name. + This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. @@ -459,11 +477,11 @@ def batch_process_documents( sent along with the request as metadata. Returns: - ~.operation.Operation: + google.api_core.operation.Operation: An object representing a long-running operation. The result type for the operation will be - :class:``~.document_processor_service.BatchProcessResponse``: + :class:`google.cloud.documentai_v1beta3.types.BatchProcessResponse` Response message for batch process document method. """ @@ -527,13 +545,14 @@ def review_document( should be processed by the specified processor. Args: - request (:class:`~.document_processor_service.ReviewDocumentRequest`): + request (google.cloud.documentai_v1beta3.types.ReviewDocumentRequest): The request object. Request message for review document method. - human_review_config (:class:`str`): + human_review_config (str): Required. The resource name of the HumanReviewConfig that the document will be reviewed with. + This corresponds to the ``human_review_config`` field on the ``request`` instance; if ``request`` is provided, this should not be set. @@ -545,11 +564,11 @@ def review_document( sent along with the request as metadata. Returns: - ~.operation.Operation: + google.api_core.operation.Operation: An object representing a long-running operation. The result type for the operation will be - :class:``~.document_processor_service.ReviewDocumentResponse``: + :class:`google.cloud.documentai_v1beta3.types.ReviewDocumentResponse` Response message for review document method. """ diff --git a/google/cloud/documentai_v1beta3/types/document.py b/google/cloud/documentai_v1beta3/types/document.py index 104a366c..f979c519 100644 --- a/google/cloud/documentai_v1beta3/types/document.py +++ b/google/cloud/documentai_v1beta3/types/document.py @@ -60,39 +60,39 @@ class Document(proto.Message): text (str): UTF-8 encoded text in reading order from the document. - text_styles (Sequence[~.document.Document.Style]): + text_styles (Sequence[google.cloud.documentai_v1beta3.types.Document.Style]): Styles for the [Document.text][google.cloud.documentai.v1beta3.Document.text]. - pages (Sequence[~.document.Document.Page]): + pages (Sequence[google.cloud.documentai_v1beta3.types.Document.Page]): Visual page layout for the [Document][google.cloud.documentai.v1beta3.Document]. - entities (Sequence[~.document.Document.Entity]): + entities (Sequence[google.cloud.documentai_v1beta3.types.Document.Entity]): A list of entities detected on [Document.text][google.cloud.documentai.v1beta3.Document.text]. For document shards, entities in this list may cross shard boundaries. - entity_relations (Sequence[~.document.Document.EntityRelation]): + entity_relations (Sequence[google.cloud.documentai_v1beta3.types.Document.EntityRelation]): Relationship among [Document.entities][google.cloud.documentai.v1beta3.Document.entities]. - translations (Sequence[~.document.Document.Translation]): + translations (Sequence[google.cloud.documentai_v1beta3.types.Document.Translation]): A list of translations on [Document.text][google.cloud.documentai.v1beta3.Document.text]. For document shards, translations in this list may cross shard boundaries. - text_changes (Sequence[~.document.Document.TextChange]): + text_changes (Sequence[google.cloud.documentai_v1beta3.types.Document.TextChange]): A list of text corrections made to [Document.text]. This is usually used for annotating corrections to OCR mistakes. Text changes for a given revision may not overlap with each other. - shard_info (~.document.Document.ShardInfo): + shard_info (google.cloud.documentai_v1beta3.types.Document.ShardInfo): Information about the sharding if this document is sharded part of a larger document. If the document is not sharded, this message is not specified. - error (~.status.Status): + error (google.rpc.status_pb2.Status): Any error that occurred while processing this document. - revisions (Sequence[~.document.Document.Revision]): + revisions (Sequence[google.cloud.documentai_v1beta3.types.Document.Revision]): Revision history of this document. """ @@ -123,12 +123,12 @@ class Style(proto.Message): CSS conventions as much as possible. Attributes: - text_anchor (~.document.Document.TextAnchor): + text_anchor (google.cloud.documentai_v1beta3.types.Document.TextAnchor): Text anchor indexing into the [Document.text][google.cloud.documentai.v1beta3.Document.text]. - color (~.gt_color.Color): + color (google.type.color_pb2.Color): Text color. - background_color (~.gt_color.Color): + background_color (google.type.color_pb2.Color): Text background color. font_weight (str): Font weight. Possible values are normal, bold, bolder, and @@ -139,7 +139,7 @@ class Style(proto.Message): text_decoration (str): Text decoration. Follows CSS standard. https://www.w3schools.com/cssref/pr_text_text-decoration.asp - font_size (~.document.Document.Style.FontSize): + font_size (google.cloud.documentai_v1beta3.types.Document.Style.FontSize): Font size. """ @@ -187,46 +187,46 @@ class Page(proto.Message): Useful when a page is taken out of a [Document][google.cloud.documentai.v1beta3.Document] for individual processing. - image (~.document.Document.Page.Image): + image (google.cloud.documentai_v1beta3.types.Document.Page.Image): Rendered image for this page. This image is preprocessed to remove any skew, rotation, and distortions such that the annotation bounding boxes can be upright and axis-aligned. - transforms (Sequence[~.document.Document.Page.Matrix]): + transforms (Sequence[google.cloud.documentai_v1beta3.types.Document.Page.Matrix]): Transformation matrices that were applied to the original document image to produce [Page.image][google.cloud.documentai.v1beta3.Document.Page.image]. - dimension (~.document.Document.Page.Dimension): + dimension (google.cloud.documentai_v1beta3.types.Document.Page.Dimension): Physical dimension of the page. - layout (~.document.Document.Page.Layout): + layout (google.cloud.documentai_v1beta3.types.Document.Page.Layout): [Layout][google.cloud.documentai.v1beta3.Document.Page.Layout] for the page. - detected_languages (Sequence[~.document.Document.Page.DetectedLanguage]): + detected_languages (Sequence[google.cloud.documentai_v1beta3.types.Document.Page.DetectedLanguage]): A list of detected languages together with confidence. - blocks (Sequence[~.document.Document.Page.Block]): + blocks (Sequence[google.cloud.documentai_v1beta3.types.Document.Page.Block]): A list of visually detected text blocks on the page. A block has a set of lines (collected into paragraphs) that have a common line-spacing and orientation. - paragraphs (Sequence[~.document.Document.Page.Paragraph]): + paragraphs (Sequence[google.cloud.documentai_v1beta3.types.Document.Page.Paragraph]): A list of visually detected text paragraphs on the page. A collection of lines that a human would perceive as a paragraph. - lines (Sequence[~.document.Document.Page.Line]): + lines (Sequence[google.cloud.documentai_v1beta3.types.Document.Page.Line]): A list of visually detected text lines on the page. A collection of tokens that a human would perceive as a line. - tokens (Sequence[~.document.Document.Page.Token]): + tokens (Sequence[google.cloud.documentai_v1beta3.types.Document.Page.Token]): A list of visually detected tokens on the page. - visual_elements (Sequence[~.document.Document.Page.VisualElement]): + visual_elements (Sequence[google.cloud.documentai_v1beta3.types.Document.Page.VisualElement]): A list of detected non-text visual elements e.g. checkbox, signature etc. on the page. - tables (Sequence[~.document.Document.Page.Table]): + tables (Sequence[google.cloud.documentai_v1beta3.types.Document.Page.Table]): A list of visually detected tables on the page. - form_fields (Sequence[~.document.Document.Page.FormField]): + form_fields (Sequence[google.cloud.documentai_v1beta3.types.Document.Page.FormField]): A list of visually detected form fields on the page. """ @@ -302,7 +302,7 @@ class Layout(proto.Message): r"""Visual element describing a layout unit on a page. Attributes: - text_anchor (~.document.Document.TextAnchor): + text_anchor (google.cloud.documentai_v1beta3.types.Document.TextAnchor): Text anchor indexing into the [Document.text][google.cloud.documentai.v1beta3.Document.text]. confidence (float): @@ -311,10 +311,10 @@ class Layout(proto.Message): within context of the object this layout is for. e.g. confidence can be for a single token, a table, a visual element, etc. depending on context. Range [0, 1]. - bounding_poly (~.geometry.BoundingPoly): + bounding_poly (google.cloud.documentai_v1beta3.types.BoundingPoly): The bounding polygon for the [Layout][google.cloud.documentai.v1beta3.Document.Page.Layout]. - orientation (~.document.Document.Page.Layout.Orientation): + orientation (google.cloud.documentai_v1beta3.types.Document.Page.Layout.Orientation): Detected orientation for the [Layout][google.cloud.documentai.v1beta3.Document.Page.Layout]. """ @@ -346,14 +346,14 @@ class Block(proto.Message): have a common line-spacing and orientation. Attributes: - layout (~.document.Document.Page.Layout): + layout (google.cloud.documentai_v1beta3.types.Document.Page.Layout): [Layout][google.cloud.documentai.v1beta3.Document.Page.Layout] for [Block][google.cloud.documentai.v1beta3.Document.Page.Block]. - detected_languages (Sequence[~.document.Document.Page.DetectedLanguage]): + detected_languages (Sequence[google.cloud.documentai_v1beta3.types.Document.Page.DetectedLanguage]): A list of detected languages together with confidence. - provenance (~.document.Document.Provenance): + provenance (google.cloud.documentai_v1beta3.types.Document.Provenance): The history of this annotation. """ @@ -374,14 +374,14 @@ class Paragraph(proto.Message): paragraph. Attributes: - layout (~.document.Document.Page.Layout): + layout (google.cloud.documentai_v1beta3.types.Document.Page.Layout): [Layout][google.cloud.documentai.v1beta3.Document.Page.Layout] for [Paragraph][google.cloud.documentai.v1beta3.Document.Page.Paragraph]. - detected_languages (Sequence[~.document.Document.Page.DetectedLanguage]): + detected_languages (Sequence[google.cloud.documentai_v1beta3.types.Document.Page.DetectedLanguage]): A list of detected languages together with confidence. - provenance (~.document.Document.Provenance): + provenance (google.cloud.documentai_v1beta3.types.Document.Provenance): The history of this annotation. """ @@ -403,14 +403,14 @@ class Line(proto.Message): etc. Attributes: - layout (~.document.Document.Page.Layout): + layout (google.cloud.documentai_v1beta3.types.Document.Page.Layout): [Layout][google.cloud.documentai.v1beta3.Document.Page.Layout] for [Line][google.cloud.documentai.v1beta3.Document.Page.Line]. - detected_languages (Sequence[~.document.Document.Page.DetectedLanguage]): + detected_languages (Sequence[google.cloud.documentai_v1beta3.types.Document.Page.DetectedLanguage]): A list of detected languages together with confidence. - provenance (~.document.Document.Provenance): + provenance (google.cloud.documentai_v1beta3.types.Document.Provenance): The history of this annotation. """ @@ -430,17 +430,17 @@ class Token(proto.Message): r"""A detected token. Attributes: - layout (~.document.Document.Page.Layout): + layout (google.cloud.documentai_v1beta3.types.Document.Page.Layout): [Layout][google.cloud.documentai.v1beta3.Document.Page.Layout] for [Token][google.cloud.documentai.v1beta3.Document.Page.Token]. - detected_break (~.document.Document.Page.Token.DetectedBreak): + detected_break (google.cloud.documentai_v1beta3.types.Document.Page.Token.DetectedBreak): Detected break at the end of a [Token][google.cloud.documentai.v1beta3.Document.Page.Token]. - detected_languages (Sequence[~.document.Document.Page.DetectedLanguage]): + detected_languages (Sequence[google.cloud.documentai_v1beta3.types.Document.Page.DetectedLanguage]): A list of detected languages together with confidence. - provenance (~.document.Document.Provenance): + provenance (google.cloud.documentai_v1beta3.types.Document.Provenance): The history of this annotation. """ @@ -449,7 +449,7 @@ class DetectedBreak(proto.Message): [Token][google.cloud.documentai.v1beta3.Document.Page.Token]. Attributes: - type_ (~.document.Document.Page.Token.DetectedBreak.Type): + type_ (google.cloud.documentai_v1beta3.types.Document.Page.Token.DetectedBreak.Type): Detected break type. """ @@ -485,14 +485,14 @@ class VisualElement(proto.Message): etc. on the page. Attributes: - layout (~.document.Document.Page.Layout): + layout (google.cloud.documentai_v1beta3.types.Document.Page.Layout): [Layout][google.cloud.documentai.v1beta3.Document.Page.Layout] for [VisualElement][google.cloud.documentai.v1beta3.Document.Page.VisualElement]. type_ (str): Type of the [VisualElement][google.cloud.documentai.v1beta3.Document.Page.VisualElement]. - detected_languages (Sequence[~.document.Document.Page.DetectedLanguage]): + detected_languages (Sequence[google.cloud.documentai_v1beta3.types.Document.Page.DetectedLanguage]): A list of detected languages together with confidence. """ @@ -511,15 +511,15 @@ class Table(proto.Message): r"""A table representation similar to HTML table structure. Attributes: - layout (~.document.Document.Page.Layout): + layout (google.cloud.documentai_v1beta3.types.Document.Page.Layout): [Layout][google.cloud.documentai.v1beta3.Document.Page.Layout] for [Table][google.cloud.documentai.v1beta3.Document.Page.Table]. - header_rows (Sequence[~.document.Document.Page.Table.TableRow]): + header_rows (Sequence[google.cloud.documentai_v1beta3.types.Document.Page.Table.TableRow]): Header rows of the table. - body_rows (Sequence[~.document.Document.Page.Table.TableRow]): + body_rows (Sequence[google.cloud.documentai_v1beta3.types.Document.Page.Table.TableRow]): Body rows of the table. - detected_languages (Sequence[~.document.Document.Page.DetectedLanguage]): + detected_languages (Sequence[google.cloud.documentai_v1beta3.types.Document.Page.DetectedLanguage]): A list of detected languages together with confidence. """ @@ -528,7 +528,7 @@ class TableRow(proto.Message): r"""A row of table cells. Attributes: - cells (Sequence[~.document.Document.Page.Table.TableCell]): + cells (Sequence[google.cloud.documentai_v1beta3.types.Document.Page.Table.TableCell]): Cells that make up this row. """ @@ -540,7 +540,7 @@ class TableCell(proto.Message): r"""A cell representation inside the table. Attributes: - layout (~.document.Document.Page.Layout): + layout (google.cloud.documentai_v1beta3.types.Document.Page.Layout): [Layout][google.cloud.documentai.v1beta3.Document.Page.Layout] for [TableCell][google.cloud.documentai.v1beta3.Document.Page.Table.TableCell]. @@ -548,7 +548,7 @@ class TableCell(proto.Message): How many rows this cell spans. col_span (int): How many columns this cell spans. - detected_languages (Sequence[~.document.Document.Page.DetectedLanguage]): + detected_languages (Sequence[google.cloud.documentai_v1beta3.types.Document.Page.DetectedLanguage]): A list of detected languages together with confidence. """ @@ -585,21 +585,21 @@ class FormField(proto.Message): r"""A form field detected on the page. Attributes: - field_name (~.document.Document.Page.Layout): + field_name (google.cloud.documentai_v1beta3.types.Document.Page.Layout): [Layout][google.cloud.documentai.v1beta3.Document.Page.Layout] for the [FormField][google.cloud.documentai.v1beta3.Document.Page.FormField] name. e.g. ``Address``, ``Email``, ``Grand total``, ``Phone number``, etc. - field_value (~.document.Document.Page.Layout): + field_value (google.cloud.documentai_v1beta3.types.Document.Page.Layout): [Layout][google.cloud.documentai.v1beta3.Document.Page.Layout] for the [FormField][google.cloud.documentai.v1beta3.Document.Page.FormField] value. - name_detected_languages (Sequence[~.document.Document.Page.DetectedLanguage]): + name_detected_languages (Sequence[google.cloud.documentai_v1beta3.types.Document.Page.DetectedLanguage]): A list of detected languages for name together with confidence. - value_detected_languages (Sequence[~.document.Document.Page.DetectedLanguage]): + value_detected_languages (Sequence[google.cloud.documentai_v1beta3.types.Document.Page.DetectedLanguage]): A list of detected languages for value together with confidence. value_type (str): @@ -696,7 +696,7 @@ class Entity(proto.Message): person, an organization, or location. Attributes: - text_anchor (~.document.Document.TextAnchor): + text_anchor (google.cloud.documentai_v1beta3.types.Document.TextAnchor): Provenance of the entity. Text anchor indexing into the [Document.text][google.cloud.documentai.v1beta3.Document.text]. type_ (str): @@ -708,24 +708,24 @@ class Entity(proto.Message): confidence (float): Optional. Confidence of detected Schema entity. Range [0, 1]. - page_anchor (~.document.Document.PageAnchor): + page_anchor (google.cloud.documentai_v1beta3.types.Document.PageAnchor): Optional. Represents the provenance of this entity wrt. the location on the page where it was found. id (str): Canonical id. This will be a unique value in the entity list for this document. - normalized_value (~.document.Document.Entity.NormalizedValue): + normalized_value (google.cloud.documentai_v1beta3.types.Document.Entity.NormalizedValue): Optional. Normalized entity value. Absent if the extracted value could not be converted or the type (e.g. address) is not supported for certain parsers. This field is also only populated for certain supported document types. - properties (Sequence[~.document.Document.Entity]): + properties (Sequence[google.cloud.documentai_v1beta3.types.Document.Entity]): Optional. Entities can be nested to form a hierarchical data structure representing the content in the document. - provenance (~.document.Document.Provenance): + provenance (google.cloud.documentai_v1beta3.types.Document.Provenance): Optional. The history of this annotation. redacted (bool): Optional. Whether the entity will be redacted @@ -736,21 +736,21 @@ class NormalizedValue(proto.Message): r"""Parsed and normalized entity value. Attributes: - money_value (~.money.Money): + money_value (google.type.money_pb2.Money): Money value. See also: https: github.com/googleapis/googleapis/blob/master/google/type/money.proto - date_value (~.date.Date): + date_value (google.type.date_pb2.Date): Date value. Includes year, month, day. See also: https: github.com/googleapis/googleapis/blob/master/google/type/date.proto - datetime_value (~.datetime.DateTime): + datetime_value (google.type.datetime_pb2.DateTime): DateTime value. Includes date, time, and timezone. See also: https: github.com/googleapis/googleapis/blob/master/google/type/datetime.proto - address_value (~.postal_address.PostalAddress): + address_value (google.type.postal_address_pb2.PostalAddress): Postal address. See also: https: @@ -848,7 +848,7 @@ class Translation(proto.Message): r"""A translation of the text segment. Attributes: - text_anchor (~.document.Document.TextAnchor): + text_anchor (google.cloud.documentai_v1beta3.types.Document.TextAnchor): Provenance of the translation. Text anchor indexing into the [Document.text][google.cloud.documentai.v1beta3.Document.text]. There can only be a single ``TextAnchor.text_segments`` @@ -860,7 +860,7 @@ class Translation(proto.Message): http://www.unicode.org/reports/tr35/#Unicode_locale_identifier. translated_text (str): Text translated into the target language. - provenance (Sequence[~.document.Document.Provenance]): + provenance (Sequence[google.cloud.documentai_v1beta3.types.Document.Provenance]): The history of this annotation. """ @@ -881,7 +881,7 @@ class TextAnchor(proto.Message): [Document.text][google.cloud.documentai.v1beta3.Document.text]. Attributes: - text_segments (Sequence[~.document.Document.TextAnchor.TextSegment]): + text_segments (Sequence[google.cloud.documentai_v1beta3.types.Document.TextAnchor.TextSegment]): The text segments from the [Document.text][google.cloud.documentai.v1beta3.Document.text]. content (str): @@ -924,7 +924,7 @@ class PageAnchor(proto.Message): polygons and optionally reference specific layout element types. Attributes: - page_refs (Sequence[~.document.Document.PageAnchor.PageRef]): + page_refs (Sequence[google.cloud.documentai_v1beta3.types.Document.PageAnchor.PageRef]): One or more references to visual page elements """ @@ -938,14 +938,14 @@ class PageRef(proto.Message): Required. Index into the [Document.pages][google.cloud.documentai.v1beta3.Document.pages] element - layout_type (~.document.Document.PageAnchor.PageRef.LayoutType): + layout_type (google.cloud.documentai_v1beta3.types.Document.PageAnchor.PageRef.LayoutType): Optional. The type of the layout element that is being referenced if any. layout_id (str): Optional. Deprecated. Use [PageRef.bounding_poly][google.cloud.documentai.v1beta3.Document.PageAnchor.PageRef.bounding_poly] instead. - bounding_poly (~.geometry.BoundingPoly): + bounding_poly (google.cloud.documentai_v1beta3.types.BoundingPoly): Optional. Identifies the bounding polygon of a layout element on the page. """ @@ -988,10 +988,10 @@ class Provenance(proto.Message): id (int): The Id of this operation. Needs to be unique within the scope of the revision. - parents (Sequence[~.document.Document.Provenance.Parent]): + parents (Sequence[google.cloud.documentai_v1beta3.types.Document.Provenance.Parent]): References to the original elements that are replaced. - type_ (~.document.Document.Provenance.OperationType): + type_ (google.cloud.documentai_v1beta3.types.Document.Provenance.OperationType): The type of provenance operation. """ @@ -1052,9 +1052,9 @@ class Revision(proto.Message): The revisions that this revision is based on. This can include one or more parent (when documents are merged.) This field represents the index into the ``revisions`` field. - create_time (~.timestamp.Timestamp): + create_time (google.protobuf.timestamp_pb2.Timestamp): The time that the revision was created. - human_review (~.document.Document.Revision.HumanReview): + human_review (google.cloud.documentai_v1beta3.types.Document.Revision.HumanReview): Human Review information of this revision. """ @@ -1093,7 +1093,7 @@ class TextChange(proto.Message): r"""This message is used for text changes aka. OCR corrections. Attributes: - text_anchor (~.document.Document.TextAnchor): + text_anchor (google.cloud.documentai_v1beta3.types.Document.TextAnchor): Provenance of the correction. Text anchor indexing into the [Document.text][google.cloud.documentai.v1beta3.Document.text]. There can only be a single ``TextAnchor.text_segments`` @@ -1102,7 +1102,7 @@ class TextChange(proto.Message): changed_text (str): The text that replaces the text identified in the ``text_anchor``. - provenance (Sequence[~.document.Document.Provenance]): + provenance (Sequence[google.cloud.documentai_v1beta3.types.Document.Provenance]): The history of this annotation. """ diff --git a/google/cloud/documentai_v1beta3/types/document_processor_service.py b/google/cloud/documentai_v1beta3/types/document_processor_service.py index 7d235c25..85e71196 100644 --- a/google/cloud/documentai_v1beta3/types/document_processor_service.py +++ b/google/cloud/documentai_v1beta3/types/document_processor_service.py @@ -44,7 +44,7 @@ class ProcessRequest(proto.Message): Attributes: name (str): Required. The processor resource name. - document (~.gcd_document.Document): + document (google.cloud.documentai_v1beta3.types.Document): The document payload, the [content] and [mime_type] fields must be set. skip_human_review (bool): @@ -63,7 +63,7 @@ class ProcessResponse(proto.Message): r"""Response message for the process document method. Attributes: - document (~.gcd_document.Document): + document (google.cloud.documentai_v1beta3.types.Document): The document payload, will populate fields based on the processor's behavior. human_review_operation (str): @@ -86,10 +86,10 @@ class BatchProcessRequest(proto.Message): Attributes: name (str): Required. The processor resource name. - input_configs (Sequence[~.document_processor_service.BatchProcessRequest.BatchInputConfig]): + input_configs (Sequence[google.cloud.documentai_v1beta3.types.BatchProcessRequest.BatchInputConfig]): The input config for each single document in the batch process. - output_config (~.document_processor_service.BatchProcessRequest.BatchOutputConfig): + output_config (google.cloud.documentai_v1beta3.types.BatchProcessRequest.BatchOutputConfig): The overall output config for batch process. """ @@ -139,17 +139,17 @@ class BatchProcessMetadata(proto.Message): r"""The long running operation metadata for batch process method. Attributes: - state (~.document_processor_service.BatchProcessMetadata.State): + state (google.cloud.documentai_v1beta3.types.BatchProcessMetadata.State): The state of the current batch processing. state_message (str): A message providing more details about the current state of processing. For example, the error message if the operation is failed. - create_time (~.timestamp.Timestamp): + create_time (google.protobuf.timestamp_pb2.Timestamp): The creation time of the operation. - update_time (~.timestamp.Timestamp): + update_time (google.protobuf.timestamp_pb2.Timestamp): The last update time of the operation. - individual_process_statuses (Sequence[~.document_processor_service.BatchProcessMetadata.IndividualProcessStatus]): + individual_process_statuses (Sequence[google.cloud.documentai_v1beta3.types.BatchProcessMetadata.IndividualProcessStatus]): The list of response details of each document. """ @@ -175,7 +175,7 @@ class IndividualProcessStatus(proto.Message): batch process is started by take snapshot of that document, since a user can move or change that document during the process. - status (~.gr_status.Status): + status (google.rpc.status_pb2.Status): The status of the processing of the document. output_gcs_destination (str): The output_gcs_destination (in the request as @@ -219,7 +219,7 @@ class ReviewDocumentRequest(proto.Message): Required. The resource name of the HumanReviewConfig that the document will be reviewed with. - document (~.gcd_document.Document): + document (google.cloud.documentai_v1beta3.types.Document): The document that needs human review. """ @@ -245,15 +245,15 @@ class ReviewDocumentOperationMetadata(proto.Message): method. Attributes: - state (~.document_processor_service.ReviewDocumentOperationMetadata.State): + state (google.cloud.documentai_v1beta3.types.ReviewDocumentOperationMetadata.State): Used only when Operation.done is false. state_message (str): A message providing more details about the current state of processing. For example, the error message if the operation is failed. - create_time (~.timestamp.Timestamp): + create_time (google.protobuf.timestamp_pb2.Timestamp): The creation time of the operation. - update_time (~.timestamp.Timestamp): + update_time (google.protobuf.timestamp_pb2.Timestamp): The last update time of the operation. """ diff --git a/google/cloud/documentai_v1beta3/types/geometry.py b/google/cloud/documentai_v1beta3/types/geometry.py index b72dab75..53c3b9b0 100644 --- a/google/cloud/documentai_v1beta3/types/geometry.py +++ b/google/cloud/documentai_v1beta3/types/geometry.py @@ -62,9 +62,9 @@ class BoundingPoly(proto.Message): r"""A bounding polygon for the detected image annotation. Attributes: - vertices (Sequence[~.geometry.Vertex]): + vertices (Sequence[google.cloud.documentai_v1beta3.types.Vertex]): The bounding polygon vertices. - normalized_vertices (Sequence[~.geometry.NormalizedVertex]): + normalized_vertices (Sequence[google.cloud.documentai_v1beta3.types.NormalizedVertex]): The bounding polygon normalized vertices. """ diff --git a/synth.metadata b/synth.metadata index 8d9424c7..a43fa836 100644 --- a/synth.metadata +++ b/synth.metadata @@ -4,15 +4,15 @@ "git": { "name": ".", "remote": "https://github.com/googleapis/python-documentai.git", - "sha": "c94afd55124b0abc8978bf86b84743dd4afb0778" + "sha": "33dc25806d5afd147c7cfb4b5f9c5505683b7ec4" } }, { "git": { "name": "googleapis", "remote": "https://github.com/googleapis/googleapis.git", - "sha": "dd372aa22ded7a8ba6f0e03a80e06358a3fa0907", - "internalRef": "347055288" + "sha": "520682435235d9c503983a360a2090025aa47cd1", + "internalRef": "350246057" } }, { @@ -51,6 +51,7 @@ } ], "generatedFiles": [ + ".coveragerc", ".flake8", ".github/CONTRIBUTING.md", ".github/ISSUE_TEMPLATE/bug_report.md", @@ -103,8 +104,10 @@ "docs/_static/custom.css", "docs/_templates/layout.html", "docs/conf.py", + "docs/documentai_v1beta2/document_understanding_service.rst", "docs/documentai_v1beta2/services.rst", "docs/documentai_v1beta2/types.rst", + "docs/documentai_v1beta3/document_processor_service.rst", "docs/documentai_v1beta3/services.rst", "docs/documentai_v1beta3/types.rst", "docs/multiprocessing.rst", diff --git a/tests/unit/gapic/documentai_v1beta2/test_document_understanding_service.py b/tests/unit/gapic/documentai_v1beta2/test_document_understanding_service.py index 507a10de..9e708943 100644 --- a/tests/unit/gapic/documentai_v1beta2/test_document_understanding_service.py +++ b/tests/unit/gapic/documentai_v1beta2/test_document_understanding_service.py @@ -99,9 +99,22 @@ def test__get_default_mtls_endpoint(): ) +def test_document_understanding_service_client_from_service_account_info(): + creds = credentials.AnonymousCredentials() + with mock.patch.object( + service_account.Credentials, "from_service_account_info" + ) as factory: + factory.return_value = creds + info = {"valid": True} + client = DocumentUnderstandingServiceClient.from_service_account_info(info) + assert client.transport._credentials == creds + + assert client.transport._host == "us-documentai.googleapis.com:443" + + @pytest.mark.parametrize( "client_class", - [DocumentUnderstandingServiceClient, DocumentUnderstandingServiceAsyncClient], + [DocumentUnderstandingServiceClient, DocumentUnderstandingServiceAsyncClient,], ) def test_document_understanding_service_client_from_service_account_file(client_class): creds = credentials.AnonymousCredentials() @@ -120,7 +133,10 @@ def test_document_understanding_service_client_from_service_account_file(client_ def test_document_understanding_service_client_get_transport_class(): transport = DocumentUnderstandingServiceClient.get_transport_class() - assert transport == transports.DocumentUnderstandingServiceGrpcTransport + available_transports = [ + transports.DocumentUnderstandingServiceGrpcTransport, + ] + assert transport in available_transports transport = DocumentUnderstandingServiceClient.get_transport_class("grpc") assert transport == transports.DocumentUnderstandingServiceGrpcTransport @@ -1032,7 +1048,7 @@ def test_document_understanding_service_host_with_port(): def test_document_understanding_service_grpc_transport_channel(): - channel = grpc.insecure_channel("http://localhost/") + channel = grpc.secure_channel("http://localhost/", grpc.local_channel_credentials()) # Check that channel is used if provided. transport = transports.DocumentUnderstandingServiceGrpcTransport( @@ -1044,7 +1060,7 @@ def test_document_understanding_service_grpc_transport_channel(): def test_document_understanding_service_grpc_asyncio_transport_channel(): - channel = aio.insecure_channel("http://localhost/") + channel = aio.secure_channel("http://localhost/", grpc.local_channel_credentials()) # Check that channel is used if provided. transport = transports.DocumentUnderstandingServiceGrpcAsyncIOTransport( @@ -1069,7 +1085,7 @@ def test_document_understanding_service_transport_channel_mtls_with_client_cert_ "grpc.ssl_channel_credentials", autospec=True ) as grpc_ssl_channel_cred: with mock.patch.object( - transport_class, "create_channel", autospec=True + transport_class, "create_channel" ) as grpc_create_channel: mock_ssl_cred = mock.Mock() grpc_ssl_channel_cred.return_value = mock_ssl_cred @@ -1124,7 +1140,7 @@ def test_document_understanding_service_transport_channel_mtls_with_adc( ssl_credentials=mock.PropertyMock(return_value=mock_ssl_cred), ): with mock.patch.object( - transport_class, "create_channel", autospec=True + transport_class, "create_channel" ) as grpc_create_channel: mock_grpc_channel = mock.Mock() grpc_create_channel.return_value = mock_grpc_channel diff --git a/tests/unit/gapic/documentai_v1beta3/test_document_processor_service.py b/tests/unit/gapic/documentai_v1beta3/test_document_processor_service.py index bfe8ffe9..abbb8905 100644 --- a/tests/unit/gapic/documentai_v1beta3/test_document_processor_service.py +++ b/tests/unit/gapic/documentai_v1beta3/test_document_processor_service.py @@ -106,9 +106,22 @@ def test__get_default_mtls_endpoint(): ) +def test_document_processor_service_client_from_service_account_info(): + creds = credentials.AnonymousCredentials() + with mock.patch.object( + service_account.Credentials, "from_service_account_info" + ) as factory: + factory.return_value = creds + info = {"valid": True} + client = DocumentProcessorServiceClient.from_service_account_info(info) + assert client.transport._credentials == creds + + assert client.transport._host == "us-documentai.googleapis.com:443" + + @pytest.mark.parametrize( "client_class", - [DocumentProcessorServiceClient, DocumentProcessorServiceAsyncClient], + [DocumentProcessorServiceClient, DocumentProcessorServiceAsyncClient,], ) def test_document_processor_service_client_from_service_account_file(client_class): creds = credentials.AnonymousCredentials() @@ -127,7 +140,10 @@ def test_document_processor_service_client_from_service_account_file(client_clas def test_document_processor_service_client_get_transport_class(): transport = DocumentProcessorServiceClient.get_transport_class() - assert transport == transports.DocumentProcessorServiceGrpcTransport + available_transports = [ + transports.DocumentProcessorServiceGrpcTransport, + ] + assert transport in available_transports transport = DocumentProcessorServiceClient.get_transport_class("grpc") assert transport == transports.DocumentProcessorServiceGrpcTransport @@ -1306,7 +1322,7 @@ def test_document_processor_service_host_with_port(): def test_document_processor_service_grpc_transport_channel(): - channel = grpc.insecure_channel("http://localhost/") + channel = grpc.secure_channel("http://localhost/", grpc.local_channel_credentials()) # Check that channel is used if provided. transport = transports.DocumentProcessorServiceGrpcTransport( @@ -1318,7 +1334,7 @@ def test_document_processor_service_grpc_transport_channel(): def test_document_processor_service_grpc_asyncio_transport_channel(): - channel = aio.insecure_channel("http://localhost/") + channel = aio.secure_channel("http://localhost/", grpc.local_channel_credentials()) # Check that channel is used if provided. transport = transports.DocumentProcessorServiceGrpcAsyncIOTransport( @@ -1343,7 +1359,7 @@ def test_document_processor_service_transport_channel_mtls_with_client_cert_sour "grpc.ssl_channel_credentials", autospec=True ) as grpc_ssl_channel_cred: with mock.patch.object( - transport_class, "create_channel", autospec=True + transport_class, "create_channel" ) as grpc_create_channel: mock_ssl_cred = mock.Mock() grpc_ssl_channel_cred.return_value = mock_ssl_cred @@ -1396,7 +1412,7 @@ def test_document_processor_service_transport_channel_mtls_with_adc(transport_cl ssl_credentials=mock.PropertyMock(return_value=mock_ssl_cred), ): with mock.patch.object( - transport_class, "create_channel", autospec=True + transport_class, "create_channel" ) as grpc_create_channel: mock_grpc_channel = mock.Mock() grpc_create_channel.return_value = mock_grpc_channel