diff --git a/google/cloud/documentai_v1/services/document_processor_service/async_client.py b/google/cloud/documentai_v1/services/document_processor_service/async_client.py index 24251564..1437536a 100644 --- a/google/cloud/documentai_v1/services/document_processor_service/async_client.py +++ b/google/cloud/documentai_v1/services/document_processor_service/async_client.py @@ -245,14 +245,9 @@ def sample_process_document(): inline_document = documentai_v1.Document() inline_document.uri = "uri_value" - project = "my-project-id" - location = "us-central1" - processor = "processor_value" - name = f"projects/{project}/locations/{location}/processors/{processor}" - request = documentai_v1.ProcessRequest( inline_document=inline_document, - name=name, + name="name_value", ) # Make the request @@ -285,7 +280,7 @@ def sample_process_document(): """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -353,13 +348,8 @@ def sample_batch_process_documents(): client = documentai_v1.DocumentProcessorServiceClient() # Initialize request argument(s) - project = "my-project-id" - location = "us-central1" - processor = "processor_value" - name = f"projects/{project}/locations/{location}/processors/{processor}" - request = documentai_v1.BatchProcessRequest( - name=name, + name="name_value", ) # Make the request @@ -397,7 +387,7 @@ def sample_batch_process_documents(): """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -476,14 +466,9 @@ def sample_review_document(): inline_document = documentai_v1.Document() inline_document.uri = "uri_value" - project = "my-project-id" - location = "us-central1" - processor = "processor_value" - human_review_config = f"projects/{project}/locations/{location}/processors/{processor}/humanReviewConfig" - request = documentai_v1.ReviewDocumentRequest( inline_document=inline_document, - human_review_config=human_review_config, + human_review_config="human_review_config_value", ) # Make the request @@ -522,7 +507,7 @@ def sample_review_document(): """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([human_review_config]) if request is not None and has_flattened_params: diff --git a/google/cloud/documentai_v1/services/document_processor_service/client.py b/google/cloud/documentai_v1/services/document_processor_service/client.py index 55c0d90d..2c7020a6 100644 --- a/google/cloud/documentai_v1/services/document_processor_service/client.py +++ b/google/cloud/documentai_v1/services/document_processor_service/client.py @@ -448,14 +448,9 @@ def sample_process_document(): inline_document = documentai_v1.Document() inline_document.uri = "uri_value" - project = "my-project-id" - location = "us-central1" - processor = "processor_value" - name = f"projects/{project}/locations/{location}/processors/{processor}" - request = documentai_v1.ProcessRequest( inline_document=inline_document, - name=name, + name="name_value", ) # Make the request @@ -488,7 +483,7 @@ def sample_process_document(): """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -547,13 +542,8 @@ def sample_batch_process_documents(): client = documentai_v1.DocumentProcessorServiceClient() # Initialize request argument(s) - project = "my-project-id" - location = "us-central1" - processor = "processor_value" - name = f"projects/{project}/locations/{location}/processors/{processor}" - request = documentai_v1.BatchProcessRequest( - name=name, + name="name_value", ) # Make the request @@ -591,7 +581,7 @@ def sample_batch_process_documents(): """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -661,14 +651,9 @@ def sample_review_document(): inline_document = documentai_v1.Document() inline_document.uri = "uri_value" - project = "my-project-id" - location = "us-central1" - processor = "processor_value" - human_review_config = f"projects/{project}/locations/{location}/processors/{processor}/humanReviewConfig" - request = documentai_v1.ReviewDocumentRequest( inline_document=inline_document, - human_review_config=human_review_config, + human_review_config="human_review_config_value", ) # Make the request @@ -707,7 +692,7 @@ def sample_review_document(): """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([human_review_config]) if request is not None and has_flattened_params: diff --git a/google/cloud/documentai_v1/services/document_processor_service/transports/grpc.py b/google/cloud/documentai_v1/services/document_processor_service/transports/grpc.py index 58e02f35..4dac54a9 100644 --- a/google/cloud/documentai_v1/services/document_processor_service/transports/grpc.py +++ b/google/cloud/documentai_v1/services/document_processor_service/transports/grpc.py @@ -165,8 +165,11 @@ def __init__( if not self._grpc_channel: self._grpc_channel = type(self).create_channel( self._host, + # use the credentials which are saved credentials=self._credentials, - credentials_file=credentials_file, + # Set ``credentials_file`` to ``None`` here as + # the credentials that we saved earlier should be used. + credentials_file=None, scopes=self._scopes, ssl_credentials=self._ssl_channel_credentials, quota_project_id=quota_project_id, @@ -239,7 +242,7 @@ def operations_client(self) -> operations_v1.OperationsClient: This property caches on the instance; repeated calls return the same client. """ - # Sanity check: Only create a new client if we do not already have one. + # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsClient(self.grpc_channel) diff --git a/google/cloud/documentai_v1/services/document_processor_service/transports/grpc_asyncio.py b/google/cloud/documentai_v1/services/document_processor_service/transports/grpc_asyncio.py index 0578ce72..226aaabc 100644 --- a/google/cloud/documentai_v1/services/document_processor_service/transports/grpc_asyncio.py +++ b/google/cloud/documentai_v1/services/document_processor_service/transports/grpc_asyncio.py @@ -210,8 +210,11 @@ def __init__( if not self._grpc_channel: self._grpc_channel = type(self).create_channel( self._host, + # use the credentials which are saved credentials=self._credentials, - credentials_file=credentials_file, + # Set ``credentials_file`` to ``None`` here as + # the credentials that we saved earlier should be used. + credentials_file=None, scopes=self._scopes, ssl_credentials=self._ssl_channel_credentials, quota_project_id=quota_project_id, @@ -241,7 +244,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: This property caches on the instance; repeated calls return the same client. """ - # Sanity check: Only create a new client if we do not already have one. + # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( self.grpc_channel diff --git a/google/cloud/documentai_v1/types/document.py b/google/cloud/documentai_v1/types/document.py index ef8a59ac..1463cdd5 100644 --- a/google/cloud/documentai_v1/types/document.py +++ b/google/cloud/documentai_v1/types/document.py @@ -63,8 +63,7 @@ class Document(proto.Message): mime_type (str): An IANA published MIME type (also referred to as media type). For more information, see - https://www.iana.org/assignments/media- - types/media-types.xhtml. + https://www.iana.org/assignments/media-types/media-types.xhtml. text (str): Optional. UTF-8 encoded text in reading order from the document. 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 79ca5a3b..11edf231 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 @@ -254,7 +254,7 @@ async def batch_process_documents( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([requests]) if request is not None and has_flattened_params: 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 68ffe016..3105d9c4 100644 --- a/google/cloud/documentai_v1beta2/services/document_understanding_service/client.py +++ b/google/cloud/documentai_v1beta2/services/document_understanding_service/client.py @@ -436,7 +436,7 @@ def batch_process_documents( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([requests]) if request is not None and has_flattened_params: diff --git a/google/cloud/documentai_v1beta2/services/document_understanding_service/transports/grpc.py b/google/cloud/documentai_v1beta2/services/document_understanding_service/transports/grpc.py index c08a8db1..c54e7d7b 100644 --- a/google/cloud/documentai_v1beta2/services/document_understanding_service/transports/grpc.py +++ b/google/cloud/documentai_v1beta2/services/document_understanding_service/transports/grpc.py @@ -164,8 +164,11 @@ def __init__( if not self._grpc_channel: self._grpc_channel = type(self).create_channel( self._host, + # use the credentials which are saved credentials=self._credentials, - credentials_file=credentials_file, + # Set ``credentials_file`` to ``None`` here as + # the credentials that we saved earlier should be used. + credentials_file=None, scopes=self._scopes, ssl_credentials=self._ssl_channel_credentials, quota_project_id=quota_project_id, @@ -238,7 +241,7 @@ def operations_client(self) -> operations_v1.OperationsClient: This property caches on the instance; repeated calls return the same client. """ - # Sanity check: Only create a new client if we do not already have one. + # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsClient(self.grpc_channel) diff --git a/google/cloud/documentai_v1beta2/services/document_understanding_service/transports/grpc_asyncio.py b/google/cloud/documentai_v1beta2/services/document_understanding_service/transports/grpc_asyncio.py index 238594d1..d01f15c4 100644 --- a/google/cloud/documentai_v1beta2/services/document_understanding_service/transports/grpc_asyncio.py +++ b/google/cloud/documentai_v1beta2/services/document_understanding_service/transports/grpc_asyncio.py @@ -211,8 +211,11 @@ def __init__( if not self._grpc_channel: self._grpc_channel = type(self).create_channel( self._host, + # use the credentials which are saved credentials=self._credentials, - credentials_file=credentials_file, + # Set ``credentials_file`` to ``None`` here as + # the credentials that we saved earlier should be used. + credentials_file=None, scopes=self._scopes, ssl_credentials=self._ssl_channel_credentials, quota_project_id=quota_project_id, @@ -242,7 +245,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: This property caches on the instance; repeated calls return the same client. """ - # Sanity check: Only create a new client if we do not already have one. + # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( self.grpc_channel diff --git a/google/cloud/documentai_v1beta2/types/document.py b/google/cloud/documentai_v1beta2/types/document.py index b58ec2b9..92b32c1b 100644 --- a/google/cloud/documentai_v1beta2/types/document.py +++ b/google/cloud/documentai_v1beta2/types/document.py @@ -58,8 +58,7 @@ class Document(proto.Message): mime_type (str): An IANA published MIME type (also referred to as media type). For more information, see - https://www.iana.org/assignments/media- - types/media-types.xhtml. + https://www.iana.org/assignments/media-types/media-types.xhtml. text (str): UTF-8 encoded text in reading order from the document. 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 ee40b706..3e41571a 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 @@ -257,14 +257,9 @@ def sample_process_document(): inline_document = documentai_v1beta3.Document() inline_document.uri = "uri_value" - project = "my-project-id" - location = "us-central1" - processor = "processor_value" - name = f"projects/{project}/locations/{location}/processors/{processor}" - request = documentai_v1beta3.ProcessRequest( inline_document=inline_document, - name=name, + name="name_value", ) # Make the request @@ -297,7 +292,7 @@ def sample_process_document(): """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -365,13 +360,8 @@ def sample_batch_process_documents(): client = documentai_v1beta3.DocumentProcessorServiceClient() # Initialize request argument(s) - project = "my-project-id" - location = "us-central1" - processor = "processor_value" - name = f"projects/{project}/locations/{location}/processors/{processor}" - request = documentai_v1beta3.BatchProcessRequest( - name=name, + name="name_value", ) # Make the request @@ -409,7 +399,7 @@ def sample_batch_process_documents(): """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -485,13 +475,8 @@ def sample_fetch_processor_types(): client = documentai_v1beta3.DocumentProcessorServiceClient() # Initialize request argument(s) - project = "my-project-id" - location = "us-central1" - processor_type = "processor_type_value" - parent = f"projects/{project}/locations/{location}/processorTypes/{processor_type}" - request = documentai_v1beta3.FetchProcessorTypesRequest( - parent=parent, + parent="parent_value", ) # Make the request @@ -525,7 +510,7 @@ def sample_fetch_processor_types(): """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent]) if request is not None and has_flattened_params: @@ -581,13 +566,8 @@ def sample_list_processors(): client = documentai_v1beta3.DocumentProcessorServiceClient() # Initialize request argument(s) - project = "my-project-id" - location = "us-central1" - processor = "processor_value" - parent = f"projects/{project}/locations/{location}/processors/{processor}" - request = documentai_v1beta3.ListProcessorsRequest( - parent=parent, + parent="parent_value", ) # Make the request @@ -623,7 +603,7 @@ def sample_list_processors(): """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent]) if request is not None and has_flattened_params: @@ -689,13 +669,8 @@ def sample_create_processor(): client = documentai_v1beta3.DocumentProcessorServiceClient() # Initialize request argument(s) - project = "my-project-id" - location = "us-central1" - processor = "processor_value" - parent = f"projects/{project}/locations/{location}/processors/{processor}" - request = documentai_v1beta3.CreateProcessorRequest( - parent=parent, + parent="parent_value", ) # Make the request @@ -742,7 +717,7 @@ def sample_create_processor(): """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent, processor]) if request is not None and has_flattened_params: @@ -803,13 +778,8 @@ def sample_delete_processor(): client = documentai_v1beta3.DocumentProcessorServiceClient() # Initialize request argument(s) - project = "my-project-id" - location = "us-central1" - processor = "processor_value" - name = f"projects/{project}/locations/{location}/processors/{processor}" - request = documentai_v1beta3.DeleteProcessorRequest( - name=name, + name="name_value", ) # Make the request @@ -857,7 +827,7 @@ def sample_delete_processor(): """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -920,13 +890,8 @@ def sample_enable_processor(): client = documentai_v1beta3.DocumentProcessorServiceClient() # Initialize request argument(s) - project = "my-project-id" - location = "us-central1" - processor = "processor_value" - name = f"projects/{project}/locations/{location}/processors/{processor}" - request = documentai_v1beta3.EnableProcessorRequest( - name=name, + name="name_value", ) # Make the request @@ -1006,13 +971,8 @@ def sample_disable_processor(): client = documentai_v1beta3.DocumentProcessorServiceClient() # Initialize request argument(s) - project = "my-project-id" - location = "us-central1" - processor = "processor_value" - name = f"projects/{project}/locations/{location}/processors/{processor}" - request = documentai_v1beta3.DisableProcessorRequest( - name=name, + name="name_value", ) # Make the request @@ -1098,14 +1058,9 @@ def sample_review_document(): inline_document = documentai_v1beta3.Document() inline_document.uri = "uri_value" - project = "my-project-id" - location = "us-central1" - processor = "processor_value" - human_review_config = f"projects/{project}/locations/{location}/processors/{processor}/humanReviewConfig" - request = documentai_v1beta3.ReviewDocumentRequest( inline_document=inline_document, - human_review_config=human_review_config, + human_review_config="human_review_config_value", ) # Make the request @@ -1144,7 +1099,7 @@ def sample_review_document(): """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([human_review_config]) if request is not None and has_flattened_params: 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 0465908b..716a9401 100644 --- a/google/cloud/documentai_v1beta3/services/document_processor_service/client.py +++ b/google/cloud/documentai_v1beta3/services/document_processor_service/client.py @@ -470,14 +470,9 @@ def sample_process_document(): inline_document = documentai_v1beta3.Document() inline_document.uri = "uri_value" - project = "my-project-id" - location = "us-central1" - processor = "processor_value" - name = f"projects/{project}/locations/{location}/processors/{processor}" - request = documentai_v1beta3.ProcessRequest( inline_document=inline_document, - name=name, + name="name_value", ) # Make the request @@ -510,7 +505,7 @@ def sample_process_document(): """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -569,13 +564,8 @@ def sample_batch_process_documents(): client = documentai_v1beta3.DocumentProcessorServiceClient() # Initialize request argument(s) - project = "my-project-id" - location = "us-central1" - processor = "processor_value" - name = f"projects/{project}/locations/{location}/processors/{processor}" - request = documentai_v1beta3.BatchProcessRequest( - name=name, + name="name_value", ) # Make the request @@ -613,7 +603,7 @@ def sample_batch_process_documents(): """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -680,13 +670,8 @@ def sample_fetch_processor_types(): client = documentai_v1beta3.DocumentProcessorServiceClient() # Initialize request argument(s) - project = "my-project-id" - location = "us-central1" - processor_type = "processor_type_value" - parent = f"projects/{project}/locations/{location}/processorTypes/{processor_type}" - request = documentai_v1beta3.FetchProcessorTypesRequest( - parent=parent, + parent="parent_value", ) # Make the request @@ -720,7 +705,7 @@ def sample_fetch_processor_types(): """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent]) if request is not None and has_flattened_params: @@ -779,13 +764,8 @@ def sample_list_processors(): client = documentai_v1beta3.DocumentProcessorServiceClient() # Initialize request argument(s) - project = "my-project-id" - location = "us-central1" - processor = "processor_value" - parent = f"projects/{project}/locations/{location}/processors/{processor}" - request = documentai_v1beta3.ListProcessorsRequest( - parent=parent, + parent="parent_value", ) # Make the request @@ -821,7 +801,7 @@ def sample_list_processors(): """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent]) if request is not None and has_flattened_params: @@ -888,13 +868,8 @@ def sample_create_processor(): client = documentai_v1beta3.DocumentProcessorServiceClient() # Initialize request argument(s) - project = "my-project-id" - location = "us-central1" - processor = "processor_value" - parent = f"projects/{project}/locations/{location}/processors/{processor}" - request = documentai_v1beta3.CreateProcessorRequest( - parent=parent, + parent="parent_value", ) # Make the request @@ -941,7 +916,7 @@ def sample_create_processor(): """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent, processor]) if request is not None and has_flattened_params: @@ -1003,13 +978,8 @@ def sample_delete_processor(): client = documentai_v1beta3.DocumentProcessorServiceClient() # Initialize request argument(s) - project = "my-project-id" - location = "us-central1" - processor = "processor_value" - name = f"projects/{project}/locations/{location}/processors/{processor}" - request = documentai_v1beta3.DeleteProcessorRequest( - name=name, + name="name_value", ) # Make the request @@ -1057,7 +1027,7 @@ def sample_delete_processor(): """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -1121,13 +1091,8 @@ def sample_enable_processor(): client = documentai_v1beta3.DocumentProcessorServiceClient() # Initialize request argument(s) - project = "my-project-id" - location = "us-central1" - processor = "processor_value" - name = f"projects/{project}/locations/{location}/processors/{processor}" - request = documentai_v1beta3.EnableProcessorRequest( - name=name, + name="name_value", ) # Make the request @@ -1209,13 +1174,8 @@ def sample_disable_processor(): client = documentai_v1beta3.DocumentProcessorServiceClient() # Initialize request argument(s) - project = "my-project-id" - location = "us-central1" - processor = "processor_value" - name = f"projects/{project}/locations/{location}/processors/{processor}" - request = documentai_v1beta3.DisableProcessorRequest( - name=name, + name="name_value", ) # Make the request @@ -1303,14 +1263,9 @@ def sample_review_document(): inline_document = documentai_v1beta3.Document() inline_document.uri = "uri_value" - project = "my-project-id" - location = "us-central1" - processor = "processor_value" - human_review_config = f"projects/{project}/locations/{location}/processors/{processor}/humanReviewConfig" - request = documentai_v1beta3.ReviewDocumentRequest( inline_document=inline_document, - human_review_config=human_review_config, + human_review_config="human_review_config_value", ) # Make the request @@ -1349,7 +1304,7 @@ def sample_review_document(): """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([human_review_config]) if request is not None and has_flattened_params: diff --git a/google/cloud/documentai_v1beta3/services/document_processor_service/transports/grpc.py b/google/cloud/documentai_v1beta3/services/document_processor_service/transports/grpc.py index ec345fc9..3aed9bee 100644 --- a/google/cloud/documentai_v1beta3/services/document_processor_service/transports/grpc.py +++ b/google/cloud/documentai_v1beta3/services/document_processor_service/transports/grpc.py @@ -166,8 +166,11 @@ def __init__( if not self._grpc_channel: self._grpc_channel = type(self).create_channel( self._host, + # use the credentials which are saved credentials=self._credentials, - credentials_file=credentials_file, + # Set ``credentials_file`` to ``None`` here as + # the credentials that we saved earlier should be used. + credentials_file=None, scopes=self._scopes, ssl_credentials=self._ssl_channel_credentials, quota_project_id=quota_project_id, @@ -240,7 +243,7 @@ def operations_client(self) -> operations_v1.OperationsClient: This property caches on the instance; repeated calls return the same client. """ - # Sanity check: Only create a new client if we do not already have one. + # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsClient(self.grpc_channel) diff --git a/google/cloud/documentai_v1beta3/services/document_processor_service/transports/grpc_asyncio.py b/google/cloud/documentai_v1beta3/services/document_processor_service/transports/grpc_asyncio.py index b5e9f687..3f24b015 100644 --- a/google/cloud/documentai_v1beta3/services/document_processor_service/transports/grpc_asyncio.py +++ b/google/cloud/documentai_v1beta3/services/document_processor_service/transports/grpc_asyncio.py @@ -211,8 +211,11 @@ def __init__( if not self._grpc_channel: self._grpc_channel = type(self).create_channel( self._host, + # use the credentials which are saved credentials=self._credentials, - credentials_file=credentials_file, + # Set ``credentials_file`` to ``None`` here as + # the credentials that we saved earlier should be used. + credentials_file=None, scopes=self._scopes, ssl_credentials=self._ssl_channel_credentials, quota_project_id=quota_project_id, @@ -242,7 +245,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: This property caches on the instance; repeated calls return the same client. """ - # Sanity check: Only create a new client if we do not already have one. + # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( self.grpc_channel diff --git a/google/cloud/documentai_v1beta3/types/document.py b/google/cloud/documentai_v1beta3/types/document.py index 1f02f195..fbcbc833 100644 --- a/google/cloud/documentai_v1beta3/types/document.py +++ b/google/cloud/documentai_v1beta3/types/document.py @@ -63,8 +63,7 @@ class Document(proto.Message): mime_type (str): An IANA published MIME type (also referred to as media type). For more information, see - https://www.iana.org/assignments/media- - types/media-types.xhtml. + https://www.iana.org/assignments/media-types/media-types.xhtml. text (str): Optional. UTF-8 encoded text in reading order from the document. diff --git a/google/cloud/documentai_v1beta3/types/document_processor_service.py b/google/cloud/documentai_v1beta3/types/document_processor_service.py index a7980cbe..18a4700e 100644 --- a/google/cloud/documentai_v1beta3/types/document_processor_service.py +++ b/google/cloud/documentai_v1beta3/types/document_processor_service.py @@ -543,6 +543,8 @@ class ReviewDocumentOperationMetadata(proto.Message): common_metadata (google.cloud.documentai_v1beta3.types.CommonOperationMetadata): The basic metadata of the long running operation. + question_id (str): + The question ID. """ class State(proto.Enum): @@ -561,6 +563,7 @@ class State(proto.Enum): common_metadata = proto.Field( proto.MESSAGE, number=5, message=operation_metadata.CommonOperationMetadata, ) + question_id = proto.Field(proto.STRING, number=6,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/documentai_v1beta3/types/processor.py b/google/cloud/documentai_v1beta3/types/processor.py index 0c613e7d..f4ed2d28 100644 --- a/google/cloud/documentai_v1beta3/types/processor.py +++ b/google/cloud/documentai_v1beta3/types/processor.py @@ -48,8 +48,7 @@ class Processor(proto.Message): kms_key_name (str): The KMS key used for encryption/decryption in CMEK scenarios. See - https://cloud.google.com/security-key- - management. + https://cloud.google.com/security-key-management. """ class State(proto.Enum): diff --git a/samples/generated_samples/documentai_generated_documentai_v1_document_processor_service_batch_process_documents_async.py b/samples/generated_samples/documentai_generated_documentai_v1_document_processor_service_batch_process_documents_async.py index 2df83287..55ccffb6 100644 --- a/samples/generated_samples/documentai_generated_documentai_v1_document_processor_service_batch_process_documents_async.py +++ b/samples/generated_samples/documentai_generated_documentai_v1_document_processor_service_batch_process_documents_async.py @@ -32,13 +32,8 @@ async def sample_batch_process_documents(): client = documentai_v1.DocumentProcessorServiceAsyncClient() # Initialize request argument(s) - project = "my-project-id" - location = "us-central1" - processor = "processor_value" - name = f"projects/{project}/locations/{location}/processors/{processor}" - request = documentai_v1.BatchProcessRequest( - name=name, + name="name_value", ) # Make the request diff --git a/samples/generated_samples/documentai_generated_documentai_v1_document_processor_service_batch_process_documents_sync.py b/samples/generated_samples/documentai_generated_documentai_v1_document_processor_service_batch_process_documents_sync.py index f8027cc4..acb2cad0 100644 --- a/samples/generated_samples/documentai_generated_documentai_v1_document_processor_service_batch_process_documents_sync.py +++ b/samples/generated_samples/documentai_generated_documentai_v1_document_processor_service_batch_process_documents_sync.py @@ -32,13 +32,8 @@ def sample_batch_process_documents(): client = documentai_v1.DocumentProcessorServiceClient() # Initialize request argument(s) - project = "my-project-id" - location = "us-central1" - processor = "processor_value" - name = f"projects/{project}/locations/{location}/processors/{processor}" - request = documentai_v1.BatchProcessRequest( - name=name, + name="name_value", ) # Make the request diff --git a/samples/generated_samples/documentai_generated_documentai_v1_document_processor_service_process_document_async.py b/samples/generated_samples/documentai_generated_documentai_v1_document_processor_service_process_document_async.py index 7f590b7c..e4d2bc33 100644 --- a/samples/generated_samples/documentai_generated_documentai_v1_document_processor_service_process_document_async.py +++ b/samples/generated_samples/documentai_generated_documentai_v1_document_processor_service_process_document_async.py @@ -35,14 +35,9 @@ async def sample_process_document(): inline_document = documentai_v1.Document() inline_document.uri = "uri_value" - project = "my-project-id" - location = "us-central1" - processor = "processor_value" - name = f"projects/{project}/locations/{location}/processors/{processor}" - request = documentai_v1.ProcessRequest( inline_document=inline_document, - name=name, + name="name_value", ) # Make the request diff --git a/samples/generated_samples/documentai_generated_documentai_v1_document_processor_service_process_document_sync.py b/samples/generated_samples/documentai_generated_documentai_v1_document_processor_service_process_document_sync.py index 04bd0820..069c79ae 100644 --- a/samples/generated_samples/documentai_generated_documentai_v1_document_processor_service_process_document_sync.py +++ b/samples/generated_samples/documentai_generated_documentai_v1_document_processor_service_process_document_sync.py @@ -35,14 +35,9 @@ def sample_process_document(): inline_document = documentai_v1.Document() inline_document.uri = "uri_value" - project = "my-project-id" - location = "us-central1" - processor = "processor_value" - name = f"projects/{project}/locations/{location}/processors/{processor}" - request = documentai_v1.ProcessRequest( inline_document=inline_document, - name=name, + name="name_value", ) # Make the request diff --git a/samples/generated_samples/documentai_generated_documentai_v1_document_processor_service_review_document_async.py b/samples/generated_samples/documentai_generated_documentai_v1_document_processor_service_review_document_async.py index b69d841f..1c959a07 100644 --- a/samples/generated_samples/documentai_generated_documentai_v1_document_processor_service_review_document_async.py +++ b/samples/generated_samples/documentai_generated_documentai_v1_document_processor_service_review_document_async.py @@ -35,14 +35,9 @@ async def sample_review_document(): inline_document = documentai_v1.Document() inline_document.uri = "uri_value" - project = "my-project-id" - location = "us-central1" - processor = "processor_value" - human_review_config = f"projects/{project}/locations/{location}/processors/{processor}/humanReviewConfig" - request = documentai_v1.ReviewDocumentRequest( inline_document=inline_document, - human_review_config=human_review_config, + human_review_config="human_review_config_value", ) # Make the request diff --git a/samples/generated_samples/documentai_generated_documentai_v1_document_processor_service_review_document_sync.py b/samples/generated_samples/documentai_generated_documentai_v1_document_processor_service_review_document_sync.py index 91ce9329..74645f59 100644 --- a/samples/generated_samples/documentai_generated_documentai_v1_document_processor_service_review_document_sync.py +++ b/samples/generated_samples/documentai_generated_documentai_v1_document_processor_service_review_document_sync.py @@ -35,14 +35,9 @@ def sample_review_document(): inline_document = documentai_v1.Document() inline_document.uri = "uri_value" - project = "my-project-id" - location = "us-central1" - processor = "processor_value" - human_review_config = f"projects/{project}/locations/{location}/processors/{processor}/humanReviewConfig" - request = documentai_v1.ReviewDocumentRequest( inline_document=inline_document, - human_review_config=human_review_config, + human_review_config="human_review_config_value", ) # Make the request diff --git a/samples/generated_samples/documentai_generated_documentai_v1beta3_document_processor_service_batch_process_documents_async.py b/samples/generated_samples/documentai_generated_documentai_v1beta3_document_processor_service_batch_process_documents_async.py index 90352630..85522bc7 100644 --- a/samples/generated_samples/documentai_generated_documentai_v1beta3_document_processor_service_batch_process_documents_async.py +++ b/samples/generated_samples/documentai_generated_documentai_v1beta3_document_processor_service_batch_process_documents_async.py @@ -32,13 +32,8 @@ async def sample_batch_process_documents(): client = documentai_v1beta3.DocumentProcessorServiceAsyncClient() # Initialize request argument(s) - project = "my-project-id" - location = "us-central1" - processor = "processor_value" - name = f"projects/{project}/locations/{location}/processors/{processor}" - request = documentai_v1beta3.BatchProcessRequest( - name=name, + name="name_value", ) # Make the request diff --git a/samples/generated_samples/documentai_generated_documentai_v1beta3_document_processor_service_batch_process_documents_sync.py b/samples/generated_samples/documentai_generated_documentai_v1beta3_document_processor_service_batch_process_documents_sync.py index 47503255..b13d451d 100644 --- a/samples/generated_samples/documentai_generated_documentai_v1beta3_document_processor_service_batch_process_documents_sync.py +++ b/samples/generated_samples/documentai_generated_documentai_v1beta3_document_processor_service_batch_process_documents_sync.py @@ -32,13 +32,8 @@ def sample_batch_process_documents(): client = documentai_v1beta3.DocumentProcessorServiceClient() # Initialize request argument(s) - project = "my-project-id" - location = "us-central1" - processor = "processor_value" - name = f"projects/{project}/locations/{location}/processors/{processor}" - request = documentai_v1beta3.BatchProcessRequest( - name=name, + name="name_value", ) # Make the request diff --git a/samples/generated_samples/documentai_generated_documentai_v1beta3_document_processor_service_create_processor_async.py b/samples/generated_samples/documentai_generated_documentai_v1beta3_document_processor_service_create_processor_async.py index d9d4cb39..ac789db6 100644 --- a/samples/generated_samples/documentai_generated_documentai_v1beta3_document_processor_service_create_processor_async.py +++ b/samples/generated_samples/documentai_generated_documentai_v1beta3_document_processor_service_create_processor_async.py @@ -32,13 +32,8 @@ async def sample_create_processor(): client = documentai_v1beta3.DocumentProcessorServiceAsyncClient() # Initialize request argument(s) - project = "my-project-id" - location = "us-central1" - processor = "processor_value" - parent = f"projects/{project}/locations/{location}/processors/{processor}" - request = documentai_v1beta3.CreateProcessorRequest( - parent=parent, + parent="parent_value", ) # Make the request diff --git a/samples/generated_samples/documentai_generated_documentai_v1beta3_document_processor_service_create_processor_sync.py b/samples/generated_samples/documentai_generated_documentai_v1beta3_document_processor_service_create_processor_sync.py index 1e4b05e7..db122cc6 100644 --- a/samples/generated_samples/documentai_generated_documentai_v1beta3_document_processor_service_create_processor_sync.py +++ b/samples/generated_samples/documentai_generated_documentai_v1beta3_document_processor_service_create_processor_sync.py @@ -32,13 +32,8 @@ def sample_create_processor(): client = documentai_v1beta3.DocumentProcessorServiceClient() # Initialize request argument(s) - project = "my-project-id" - location = "us-central1" - processor = "processor_value" - parent = f"projects/{project}/locations/{location}/processors/{processor}" - request = documentai_v1beta3.CreateProcessorRequest( - parent=parent, + parent="parent_value", ) # Make the request diff --git a/samples/generated_samples/documentai_generated_documentai_v1beta3_document_processor_service_delete_processor_async.py b/samples/generated_samples/documentai_generated_documentai_v1beta3_document_processor_service_delete_processor_async.py index 39a598f3..fb3bf286 100644 --- a/samples/generated_samples/documentai_generated_documentai_v1beta3_document_processor_service_delete_processor_async.py +++ b/samples/generated_samples/documentai_generated_documentai_v1beta3_document_processor_service_delete_processor_async.py @@ -32,13 +32,8 @@ async def sample_delete_processor(): client = documentai_v1beta3.DocumentProcessorServiceAsyncClient() # Initialize request argument(s) - project = "my-project-id" - location = "us-central1" - processor = "processor_value" - name = f"projects/{project}/locations/{location}/processors/{processor}" - request = documentai_v1beta3.DeleteProcessorRequest( - name=name, + name="name_value", ) # Make the request diff --git a/samples/generated_samples/documentai_generated_documentai_v1beta3_document_processor_service_delete_processor_sync.py b/samples/generated_samples/documentai_generated_documentai_v1beta3_document_processor_service_delete_processor_sync.py index 6208cb9b..5add3bb0 100644 --- a/samples/generated_samples/documentai_generated_documentai_v1beta3_document_processor_service_delete_processor_sync.py +++ b/samples/generated_samples/documentai_generated_documentai_v1beta3_document_processor_service_delete_processor_sync.py @@ -32,13 +32,8 @@ def sample_delete_processor(): client = documentai_v1beta3.DocumentProcessorServiceClient() # Initialize request argument(s) - project = "my-project-id" - location = "us-central1" - processor = "processor_value" - name = f"projects/{project}/locations/{location}/processors/{processor}" - request = documentai_v1beta3.DeleteProcessorRequest( - name=name, + name="name_value", ) # Make the request diff --git a/samples/generated_samples/documentai_generated_documentai_v1beta3_document_processor_service_disable_processor_async.py b/samples/generated_samples/documentai_generated_documentai_v1beta3_document_processor_service_disable_processor_async.py index 1976ff6c..3e951cbc 100644 --- a/samples/generated_samples/documentai_generated_documentai_v1beta3_document_processor_service_disable_processor_async.py +++ b/samples/generated_samples/documentai_generated_documentai_v1beta3_document_processor_service_disable_processor_async.py @@ -32,13 +32,8 @@ async def sample_disable_processor(): client = documentai_v1beta3.DocumentProcessorServiceAsyncClient() # Initialize request argument(s) - project = "my-project-id" - location = "us-central1" - processor = "processor_value" - name = f"projects/{project}/locations/{location}/processors/{processor}" - request = documentai_v1beta3.DisableProcessorRequest( - name=name, + name="name_value", ) # Make the request diff --git a/samples/generated_samples/documentai_generated_documentai_v1beta3_document_processor_service_disable_processor_sync.py b/samples/generated_samples/documentai_generated_documentai_v1beta3_document_processor_service_disable_processor_sync.py index fa77436e..209c7995 100644 --- a/samples/generated_samples/documentai_generated_documentai_v1beta3_document_processor_service_disable_processor_sync.py +++ b/samples/generated_samples/documentai_generated_documentai_v1beta3_document_processor_service_disable_processor_sync.py @@ -32,13 +32,8 @@ def sample_disable_processor(): client = documentai_v1beta3.DocumentProcessorServiceClient() # Initialize request argument(s) - project = "my-project-id" - location = "us-central1" - processor = "processor_value" - name = f"projects/{project}/locations/{location}/processors/{processor}" - request = documentai_v1beta3.DisableProcessorRequest( - name=name, + name="name_value", ) # Make the request diff --git a/samples/generated_samples/documentai_generated_documentai_v1beta3_document_processor_service_enable_processor_async.py b/samples/generated_samples/documentai_generated_documentai_v1beta3_document_processor_service_enable_processor_async.py index ae4a243c..24df5c87 100644 --- a/samples/generated_samples/documentai_generated_documentai_v1beta3_document_processor_service_enable_processor_async.py +++ b/samples/generated_samples/documentai_generated_documentai_v1beta3_document_processor_service_enable_processor_async.py @@ -32,13 +32,8 @@ async def sample_enable_processor(): client = documentai_v1beta3.DocumentProcessorServiceAsyncClient() # Initialize request argument(s) - project = "my-project-id" - location = "us-central1" - processor = "processor_value" - name = f"projects/{project}/locations/{location}/processors/{processor}" - request = documentai_v1beta3.EnableProcessorRequest( - name=name, + name="name_value", ) # Make the request diff --git a/samples/generated_samples/documentai_generated_documentai_v1beta3_document_processor_service_enable_processor_sync.py b/samples/generated_samples/documentai_generated_documentai_v1beta3_document_processor_service_enable_processor_sync.py index 63624e81..e55fd915 100644 --- a/samples/generated_samples/documentai_generated_documentai_v1beta3_document_processor_service_enable_processor_sync.py +++ b/samples/generated_samples/documentai_generated_documentai_v1beta3_document_processor_service_enable_processor_sync.py @@ -32,13 +32,8 @@ def sample_enable_processor(): client = documentai_v1beta3.DocumentProcessorServiceClient() # Initialize request argument(s) - project = "my-project-id" - location = "us-central1" - processor = "processor_value" - name = f"projects/{project}/locations/{location}/processors/{processor}" - request = documentai_v1beta3.EnableProcessorRequest( - name=name, + name="name_value", ) # Make the request diff --git a/samples/generated_samples/documentai_generated_documentai_v1beta3_document_processor_service_fetch_processor_types_async.py b/samples/generated_samples/documentai_generated_documentai_v1beta3_document_processor_service_fetch_processor_types_async.py index b7d09770..13843198 100644 --- a/samples/generated_samples/documentai_generated_documentai_v1beta3_document_processor_service_fetch_processor_types_async.py +++ b/samples/generated_samples/documentai_generated_documentai_v1beta3_document_processor_service_fetch_processor_types_async.py @@ -32,13 +32,8 @@ async def sample_fetch_processor_types(): client = documentai_v1beta3.DocumentProcessorServiceAsyncClient() # Initialize request argument(s) - project = "my-project-id" - location = "us-central1" - processor_type = "processor_type_value" - parent = f"projects/{project}/locations/{location}/processorTypes/{processor_type}" - request = documentai_v1beta3.FetchProcessorTypesRequest( - parent=parent, + parent="parent_value", ) # Make the request diff --git a/samples/generated_samples/documentai_generated_documentai_v1beta3_document_processor_service_fetch_processor_types_sync.py b/samples/generated_samples/documentai_generated_documentai_v1beta3_document_processor_service_fetch_processor_types_sync.py index eabe9b7e..7c9b1a2c 100644 --- a/samples/generated_samples/documentai_generated_documentai_v1beta3_document_processor_service_fetch_processor_types_sync.py +++ b/samples/generated_samples/documentai_generated_documentai_v1beta3_document_processor_service_fetch_processor_types_sync.py @@ -32,13 +32,8 @@ def sample_fetch_processor_types(): client = documentai_v1beta3.DocumentProcessorServiceClient() # Initialize request argument(s) - project = "my-project-id" - location = "us-central1" - processor_type = "processor_type_value" - parent = f"projects/{project}/locations/{location}/processorTypes/{processor_type}" - request = documentai_v1beta3.FetchProcessorTypesRequest( - parent=parent, + parent="parent_value", ) # Make the request diff --git a/samples/generated_samples/documentai_generated_documentai_v1beta3_document_processor_service_list_processors_async.py b/samples/generated_samples/documentai_generated_documentai_v1beta3_document_processor_service_list_processors_async.py index 7302c57b..0d8ecf5a 100644 --- a/samples/generated_samples/documentai_generated_documentai_v1beta3_document_processor_service_list_processors_async.py +++ b/samples/generated_samples/documentai_generated_documentai_v1beta3_document_processor_service_list_processors_async.py @@ -32,13 +32,8 @@ async def sample_list_processors(): client = documentai_v1beta3.DocumentProcessorServiceAsyncClient() # Initialize request argument(s) - project = "my-project-id" - location = "us-central1" - processor = "processor_value" - parent = f"projects/{project}/locations/{location}/processors/{processor}" - request = documentai_v1beta3.ListProcessorsRequest( - parent=parent, + parent="parent_value", ) # Make the request diff --git a/samples/generated_samples/documentai_generated_documentai_v1beta3_document_processor_service_list_processors_sync.py b/samples/generated_samples/documentai_generated_documentai_v1beta3_document_processor_service_list_processors_sync.py index 4a7c2e28..a7cba52d 100644 --- a/samples/generated_samples/documentai_generated_documentai_v1beta3_document_processor_service_list_processors_sync.py +++ b/samples/generated_samples/documentai_generated_documentai_v1beta3_document_processor_service_list_processors_sync.py @@ -32,13 +32,8 @@ def sample_list_processors(): client = documentai_v1beta3.DocumentProcessorServiceClient() # Initialize request argument(s) - project = "my-project-id" - location = "us-central1" - processor = "processor_value" - parent = f"projects/{project}/locations/{location}/processors/{processor}" - request = documentai_v1beta3.ListProcessorsRequest( - parent=parent, + parent="parent_value", ) # Make the request diff --git a/samples/generated_samples/documentai_generated_documentai_v1beta3_document_processor_service_process_document_async.py b/samples/generated_samples/documentai_generated_documentai_v1beta3_document_processor_service_process_document_async.py index c393fc0d..c8a6da70 100644 --- a/samples/generated_samples/documentai_generated_documentai_v1beta3_document_processor_service_process_document_async.py +++ b/samples/generated_samples/documentai_generated_documentai_v1beta3_document_processor_service_process_document_async.py @@ -35,14 +35,9 @@ async def sample_process_document(): inline_document = documentai_v1beta3.Document() inline_document.uri = "uri_value" - project = "my-project-id" - location = "us-central1" - processor = "processor_value" - name = f"projects/{project}/locations/{location}/processors/{processor}" - request = documentai_v1beta3.ProcessRequest( inline_document=inline_document, - name=name, + name="name_value", ) # Make the request diff --git a/samples/generated_samples/documentai_generated_documentai_v1beta3_document_processor_service_process_document_sync.py b/samples/generated_samples/documentai_generated_documentai_v1beta3_document_processor_service_process_document_sync.py index 5fb67eb6..30983e0b 100644 --- a/samples/generated_samples/documentai_generated_documentai_v1beta3_document_processor_service_process_document_sync.py +++ b/samples/generated_samples/documentai_generated_documentai_v1beta3_document_processor_service_process_document_sync.py @@ -35,14 +35,9 @@ def sample_process_document(): inline_document = documentai_v1beta3.Document() inline_document.uri = "uri_value" - project = "my-project-id" - location = "us-central1" - processor = "processor_value" - name = f"projects/{project}/locations/{location}/processors/{processor}" - request = documentai_v1beta3.ProcessRequest( inline_document=inline_document, - name=name, + name="name_value", ) # Make the request diff --git a/samples/generated_samples/documentai_generated_documentai_v1beta3_document_processor_service_review_document_async.py b/samples/generated_samples/documentai_generated_documentai_v1beta3_document_processor_service_review_document_async.py index 3312825d..7028bd75 100644 --- a/samples/generated_samples/documentai_generated_documentai_v1beta3_document_processor_service_review_document_async.py +++ b/samples/generated_samples/documentai_generated_documentai_v1beta3_document_processor_service_review_document_async.py @@ -35,14 +35,9 @@ async def sample_review_document(): inline_document = documentai_v1beta3.Document() inline_document.uri = "uri_value" - project = "my-project-id" - location = "us-central1" - processor = "processor_value" - human_review_config = f"projects/{project}/locations/{location}/processors/{processor}/humanReviewConfig" - request = documentai_v1beta3.ReviewDocumentRequest( inline_document=inline_document, - human_review_config=human_review_config, + human_review_config="human_review_config_value", ) # Make the request diff --git a/samples/generated_samples/documentai_generated_documentai_v1beta3_document_processor_service_review_document_sync.py b/samples/generated_samples/documentai_generated_documentai_v1beta3_document_processor_service_review_document_sync.py index 21176d5b..28fa9d6d 100644 --- a/samples/generated_samples/documentai_generated_documentai_v1beta3_document_processor_service_review_document_sync.py +++ b/samples/generated_samples/documentai_generated_documentai_v1beta3_document_processor_service_review_document_sync.py @@ -35,14 +35,9 @@ def sample_review_document(): inline_document = documentai_v1beta3.Document() inline_document.uri = "uri_value" - project = "my-project-id" - location = "us-central1" - processor = "processor_value" - human_review_config = f"projects/{project}/locations/{location}/processors/{processor}/humanReviewConfig" - request = documentai_v1beta3.ReviewDocumentRequest( inline_document=inline_document, - human_review_config=human_review_config, + human_review_config="human_review_config_value", ) # Make the request diff --git a/samples/generated_samples/snippet_metadata_documentai_v1.json b/samples/generated_samples/snippet_metadata_documentai_v1.json index dceb51eb..60023d4b 100644 --- a/samples/generated_samples/snippet_metadata_documentai_v1.json +++ b/samples/generated_samples/snippet_metadata_documentai_v1.json @@ -14,12 +14,12 @@ "regionTag": "documentai_generated_documentai_v1_DocumentProcessorService_BatchProcessDocuments_async", "segments": [ { - "end": 51, + "end": 46, "start": 27, "type": "FULL" }, { - "end": 51, + "end": 46, "start": 27, "type": "SHORT" }, @@ -29,16 +29,16 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 43, + "end": 38, "start": 34, "type": "REQUEST_INITIALIZATION" }, { - "start": 44, + "start": 39, "type": "REQUEST_EXECUTION" }, { - "end": 52, + "end": 47, "type": "RESPONSE_HANDLING" } ] @@ -56,12 +56,12 @@ "regionTag": "documentai_generated_documentai_v1_DocumentProcessorService_BatchProcessDocuments_sync", "segments": [ { - "end": 51, + "end": 46, "start": 27, "type": "FULL" }, { - "end": 51, + "end": 46, "start": 27, "type": "SHORT" }, @@ -71,16 +71,16 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 43, + "end": 38, "start": 34, "type": "REQUEST_INITIALIZATION" }, { - "start": 44, + "start": 39, "type": "REQUEST_EXECUTION" }, { - "end": 52, + "end": 47, "type": "RESPONSE_HANDLING" } ] @@ -99,12 +99,12 @@ "regionTag": "documentai_generated_documentai_v1_DocumentProcessorService_ProcessDocument_async", "segments": [ { - "end": 53, + "end": 48, "start": 27, "type": "FULL" }, { - "end": 53, + "end": 48, "start": 27, "type": "SHORT" }, @@ -114,18 +114,18 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 47, + "end": 42, "start": 34, "type": "REQUEST_INITIALIZATION" }, { - "end": 50, - "start": 48, + "end": 45, + "start": 43, "type": "REQUEST_EXECUTION" }, { - "end": 54, - "start": 51, + "end": 49, + "start": 46, "type": "RESPONSE_HANDLING" } ] @@ -143,12 +143,12 @@ "regionTag": "documentai_generated_documentai_v1_DocumentProcessorService_ProcessDocument_sync", "segments": [ { - "end": 53, + "end": 48, "start": 27, "type": "FULL" }, { - "end": 53, + "end": 48, "start": 27, "type": "SHORT" }, @@ -158,18 +158,18 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 47, + "end": 42, "start": 34, "type": "REQUEST_INITIALIZATION" }, { - "end": 50, - "start": 48, + "end": 45, + "start": 43, "type": "REQUEST_EXECUTION" }, { - "end": 54, - "start": 51, + "end": 49, + "start": 46, "type": "RESPONSE_HANDLING" } ] @@ -188,12 +188,12 @@ "regionTag": "documentai_generated_documentai_v1_DocumentProcessorService_ReviewDocument_async", "segments": [ { - "end": 55, + "end": 50, "start": 27, "type": "FULL" }, { - "end": 55, + "end": 50, "start": 27, "type": "SHORT" }, @@ -203,16 +203,16 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 47, + "end": 42, "start": 34, "type": "REQUEST_INITIALIZATION" }, { - "start": 48, + "start": 43, "type": "REQUEST_EXECUTION" }, { - "end": 56, + "end": 51, "type": "RESPONSE_HANDLING" } ] @@ -230,12 +230,12 @@ "regionTag": "documentai_generated_documentai_v1_DocumentProcessorService_ReviewDocument_sync", "segments": [ { - "end": 55, + "end": 50, "start": 27, "type": "FULL" }, { - "end": 55, + "end": 50, "start": 27, "type": "SHORT" }, @@ -245,16 +245,16 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 47, + "end": 42, "start": 34, "type": "REQUEST_INITIALIZATION" }, { - "start": 48, + "start": 43, "type": "REQUEST_EXECUTION" }, { - "end": 56, + "end": 51, "type": "RESPONSE_HANDLING" } ] diff --git a/samples/generated_samples/snippet_metadata_documentai_v1beta3.json b/samples/generated_samples/snippet_metadata_documentai_v1beta3.json index 8cec3983..c5c11d82 100644 --- a/samples/generated_samples/snippet_metadata_documentai_v1beta3.json +++ b/samples/generated_samples/snippet_metadata_documentai_v1beta3.json @@ -14,12 +14,12 @@ "regionTag": "documentai_generated_documentai_v1beta3_DocumentProcessorService_BatchProcessDocuments_async", "segments": [ { - "end": 51, + "end": 46, "start": 27, "type": "FULL" }, { - "end": 51, + "end": 46, "start": 27, "type": "SHORT" }, @@ -29,16 +29,16 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 43, + "end": 38, "start": 34, "type": "REQUEST_INITIALIZATION" }, { - "start": 44, + "start": 39, "type": "REQUEST_EXECUTION" }, { - "end": 52, + "end": 47, "type": "RESPONSE_HANDLING" } ] @@ -56,12 +56,12 @@ "regionTag": "documentai_generated_documentai_v1beta3_DocumentProcessorService_BatchProcessDocuments_sync", "segments": [ { - "end": 51, + "end": 46, "start": 27, "type": "FULL" }, { - "end": 51, + "end": 46, "start": 27, "type": "SHORT" }, @@ -71,16 +71,16 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 43, + "end": 38, "start": 34, "type": "REQUEST_INITIALIZATION" }, { - "start": 44, + "start": 39, "type": "REQUEST_EXECUTION" }, { - "end": 52, + "end": 47, "type": "RESPONSE_HANDLING" } ] @@ -99,12 +99,12 @@ "regionTag": "documentai_generated_documentai_v1beta3_DocumentProcessorService_CreateProcessor_async", "segments": [ { - "end": 49, + "end": 44, "start": 27, "type": "FULL" }, { - "end": 49, + "end": 44, "start": 27, "type": "SHORT" }, @@ -114,18 +114,18 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 43, + "end": 38, "start": 34, "type": "REQUEST_INITIALIZATION" }, { - "end": 46, - "start": 44, + "end": 41, + "start": 39, "type": "REQUEST_EXECUTION" }, { - "end": 50, - "start": 47, + "end": 45, + "start": 42, "type": "RESPONSE_HANDLING" } ] @@ -143,12 +143,12 @@ "regionTag": "documentai_generated_documentai_v1beta3_DocumentProcessorService_CreateProcessor_sync", "segments": [ { - "end": 49, + "end": 44, "start": 27, "type": "FULL" }, { - "end": 49, + "end": 44, "start": 27, "type": "SHORT" }, @@ -158,18 +158,18 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 43, + "end": 38, "start": 34, "type": "REQUEST_INITIALIZATION" }, { - "end": 46, - "start": 44, + "end": 41, + "start": 39, "type": "REQUEST_EXECUTION" }, { - "end": 50, - "start": 47, + "end": 45, + "start": 42, "type": "RESPONSE_HANDLING" } ] @@ -188,12 +188,12 @@ "regionTag": "documentai_generated_documentai_v1beta3_DocumentProcessorService_DeleteProcessor_async", "segments": [ { - "end": 51, + "end": 46, "start": 27, "type": "FULL" }, { - "end": 51, + "end": 46, "start": 27, "type": "SHORT" }, @@ -203,16 +203,16 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 43, + "end": 38, "start": 34, "type": "REQUEST_INITIALIZATION" }, { - "start": 44, + "start": 39, "type": "REQUEST_EXECUTION" }, { - "end": 52, + "end": 47, "type": "RESPONSE_HANDLING" } ] @@ -230,12 +230,12 @@ "regionTag": "documentai_generated_documentai_v1beta3_DocumentProcessorService_DeleteProcessor_sync", "segments": [ { - "end": 51, + "end": 46, "start": 27, "type": "FULL" }, { - "end": 51, + "end": 46, "start": 27, "type": "SHORT" }, @@ -245,16 +245,16 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 43, + "end": 38, "start": 34, "type": "REQUEST_INITIALIZATION" }, { - "start": 44, + "start": 39, "type": "REQUEST_EXECUTION" }, { - "end": 52, + "end": 47, "type": "RESPONSE_HANDLING" } ] @@ -273,12 +273,12 @@ "regionTag": "documentai_generated_documentai_v1beta3_DocumentProcessorService_DisableProcessor_async", "segments": [ { - "end": 51, + "end": 46, "start": 27, "type": "FULL" }, { - "end": 51, + "end": 46, "start": 27, "type": "SHORT" }, @@ -288,16 +288,16 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 43, + "end": 38, "start": 34, "type": "REQUEST_INITIALIZATION" }, { - "start": 44, + "start": 39, "type": "REQUEST_EXECUTION" }, { - "end": 52, + "end": 47, "type": "RESPONSE_HANDLING" } ] @@ -315,12 +315,12 @@ "regionTag": "documentai_generated_documentai_v1beta3_DocumentProcessorService_DisableProcessor_sync", "segments": [ { - "end": 51, + "end": 46, "start": 27, "type": "FULL" }, { - "end": 51, + "end": 46, "start": 27, "type": "SHORT" }, @@ -330,16 +330,16 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 43, + "end": 38, "start": 34, "type": "REQUEST_INITIALIZATION" }, { - "start": 44, + "start": 39, "type": "REQUEST_EXECUTION" }, { - "end": 52, + "end": 47, "type": "RESPONSE_HANDLING" } ] @@ -358,12 +358,12 @@ "regionTag": "documentai_generated_documentai_v1beta3_DocumentProcessorService_EnableProcessor_async", "segments": [ { - "end": 51, + "end": 46, "start": 27, "type": "FULL" }, { - "end": 51, + "end": 46, "start": 27, "type": "SHORT" }, @@ -373,16 +373,16 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 43, + "end": 38, "start": 34, "type": "REQUEST_INITIALIZATION" }, { - "start": 44, + "start": 39, "type": "REQUEST_EXECUTION" }, { - "end": 52, + "end": 47, "type": "RESPONSE_HANDLING" } ] @@ -400,12 +400,12 @@ "regionTag": "documentai_generated_documentai_v1beta3_DocumentProcessorService_EnableProcessor_sync", "segments": [ { - "end": 51, + "end": 46, "start": 27, "type": "FULL" }, { - "end": 51, + "end": 46, "start": 27, "type": "SHORT" }, @@ -415,16 +415,16 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 43, + "end": 38, "start": 34, "type": "REQUEST_INITIALIZATION" }, { - "start": 44, + "start": 39, "type": "REQUEST_EXECUTION" }, { - "end": 52, + "end": 47, "type": "RESPONSE_HANDLING" } ] @@ -443,12 +443,12 @@ "regionTag": "documentai_generated_documentai_v1beta3_DocumentProcessorService_FetchProcessorTypes_async", "segments": [ { - "end": 49, + "end": 44, "start": 27, "type": "FULL" }, { - "end": 49, + "end": 44, "start": 27, "type": "SHORT" }, @@ -458,18 +458,18 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 43, + "end": 38, "start": 34, "type": "REQUEST_INITIALIZATION" }, { - "end": 46, - "start": 44, + "end": 41, + "start": 39, "type": "REQUEST_EXECUTION" }, { - "end": 50, - "start": 47, + "end": 45, + "start": 42, "type": "RESPONSE_HANDLING" } ] @@ -487,12 +487,12 @@ "regionTag": "documentai_generated_documentai_v1beta3_DocumentProcessorService_FetchProcessorTypes_sync", "segments": [ { - "end": 49, + "end": 44, "start": 27, "type": "FULL" }, { - "end": 49, + "end": 44, "start": 27, "type": "SHORT" }, @@ -502,18 +502,18 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 43, + "end": 38, "start": 34, "type": "REQUEST_INITIALIZATION" }, { - "end": 46, - "start": 44, + "end": 41, + "start": 39, "type": "REQUEST_EXECUTION" }, { - "end": 50, - "start": 47, + "end": 45, + "start": 42, "type": "RESPONSE_HANDLING" } ] @@ -532,12 +532,12 @@ "regionTag": "documentai_generated_documentai_v1beta3_DocumentProcessorService_ListProcessors_async", "segments": [ { - "end": 48, + "end": 43, "start": 27, "type": "FULL" }, { - "end": 48, + "end": 43, "start": 27, "type": "SHORT" }, @@ -547,16 +547,16 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 43, + "end": 38, "start": 34, "type": "REQUEST_INITIALIZATION" }, { - "start": 44, + "start": 39, "type": "REQUEST_EXECUTION" }, { - "end": 49, + "end": 44, "type": "RESPONSE_HANDLING" } ] @@ -574,12 +574,12 @@ "regionTag": "documentai_generated_documentai_v1beta3_DocumentProcessorService_ListProcessors_sync", "segments": [ { - "end": 48, + "end": 43, "start": 27, "type": "FULL" }, { - "end": 48, + "end": 43, "start": 27, "type": "SHORT" }, @@ -589,16 +589,16 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 43, + "end": 38, "start": 34, "type": "REQUEST_INITIALIZATION" }, { - "start": 44, + "start": 39, "type": "REQUEST_EXECUTION" }, { - "end": 49, + "end": 44, "type": "RESPONSE_HANDLING" } ] @@ -617,12 +617,12 @@ "regionTag": "documentai_generated_documentai_v1beta3_DocumentProcessorService_ProcessDocument_async", "segments": [ { - "end": 53, + "end": 48, "start": 27, "type": "FULL" }, { - "end": 53, + "end": 48, "start": 27, "type": "SHORT" }, @@ -632,18 +632,18 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 47, + "end": 42, "start": 34, "type": "REQUEST_INITIALIZATION" }, { - "end": 50, - "start": 48, + "end": 45, + "start": 43, "type": "REQUEST_EXECUTION" }, { - "end": 54, - "start": 51, + "end": 49, + "start": 46, "type": "RESPONSE_HANDLING" } ] @@ -661,12 +661,12 @@ "regionTag": "documentai_generated_documentai_v1beta3_DocumentProcessorService_ProcessDocument_sync", "segments": [ { - "end": 53, + "end": 48, "start": 27, "type": "FULL" }, { - "end": 53, + "end": 48, "start": 27, "type": "SHORT" }, @@ -676,18 +676,18 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 47, + "end": 42, "start": 34, "type": "REQUEST_INITIALIZATION" }, { - "end": 50, - "start": 48, + "end": 45, + "start": 43, "type": "REQUEST_EXECUTION" }, { - "end": 54, - "start": 51, + "end": 49, + "start": 46, "type": "RESPONSE_HANDLING" } ] @@ -706,12 +706,12 @@ "regionTag": "documentai_generated_documentai_v1beta3_DocumentProcessorService_ReviewDocument_async", "segments": [ { - "end": 55, + "end": 50, "start": 27, "type": "FULL" }, { - "end": 55, + "end": 50, "start": 27, "type": "SHORT" }, @@ -721,16 +721,16 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 47, + "end": 42, "start": 34, "type": "REQUEST_INITIALIZATION" }, { - "start": 48, + "start": 43, "type": "REQUEST_EXECUTION" }, { - "end": 56, + "end": 51, "type": "RESPONSE_HANDLING" } ] @@ -748,12 +748,12 @@ "regionTag": "documentai_generated_documentai_v1beta3_DocumentProcessorService_ReviewDocument_sync", "segments": [ { - "end": 55, + "end": 50, "start": 27, "type": "FULL" }, { - "end": 55, + "end": 50, "start": 27, "type": "SHORT" }, @@ -763,16 +763,16 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 47, + "end": 42, "start": 34, "type": "REQUEST_INITIALIZATION" }, { - "start": 48, + "start": 43, "type": "REQUEST_EXECUTION" }, { - "end": 56, + "end": 51, "type": "RESPONSE_HANDLING" } ] diff --git a/tests/unit/gapic/documentai_v1/test_document_processor_service.py b/tests/unit/gapic/documentai_v1/test_document_processor_service.py index e3ab04e6..0e124540 100644 --- a/tests/unit/gapic/documentai_v1/test_document_processor_service.py +++ b/tests/unit/gapic/documentai_v1/test_document_processor_service.py @@ -29,6 +29,7 @@ from google.api_core import gapic_v1 from google.api_core import grpc_helpers from google.api_core import grpc_helpers_async +from google.api_core import operation from google.api_core import operation_async # type: ignore from google.api_core import operations_v1 from google.api_core import path_template @@ -556,25 +557,28 @@ def test_document_processor_service_client_client_options_scopes( @pytest.mark.parametrize( - "client_class,transport_class,transport_name", + "client_class,transport_class,transport_name,grpc_helpers", [ ( DocumentProcessorServiceClient, transports.DocumentProcessorServiceGrpcTransport, "grpc", + grpc_helpers, ), ( DocumentProcessorServiceAsyncClient, transports.DocumentProcessorServiceGrpcAsyncIOTransport, "grpc_asyncio", + grpc_helpers_async, ), ], ) def test_document_processor_service_client_client_options_credentials_file( - client_class, transport_class, transport_name + client_class, transport_class, transport_name, grpc_helpers ): # Check the case credentials file is provided. options = client_options.ClientOptions(credentials_file="credentials.json") + with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None client = client_class(client_options=options, transport=transport_name) @@ -610,6 +614,72 @@ def test_document_processor_service_client_client_options_from_dict(): ) +@pytest.mark.parametrize( + "client_class,transport_class,transport_name,grpc_helpers", + [ + ( + DocumentProcessorServiceClient, + transports.DocumentProcessorServiceGrpcTransport, + "grpc", + grpc_helpers, + ), + ( + DocumentProcessorServiceAsyncClient, + transports.DocumentProcessorServiceGrpcAsyncIOTransport, + "grpc_asyncio", + grpc_helpers_async, + ), + ], +) +def test_document_processor_service_client_create_channel_credentials_file( + client_class, transport_class, transport_name, grpc_helpers +): + # Check the case credentials file is provided. + options = client_options.ClientOptions(credentials_file="credentials.json") + + with mock.patch.object(transport_class, "__init__") as patched: + patched.return_value = None + client = client_class(client_options=options, transport=transport_name) + patched.assert_called_once_with( + credentials=None, + credentials_file="credentials.json", + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + ) + + # test that the credentials from file are saved and used as the credentials. + with mock.patch.object( + google.auth, "load_credentials_from_file", autospec=True + ) as load_creds, mock.patch.object( + google.auth, "default", autospec=True + ) as adc, mock.patch.object( + grpc_helpers, "create_channel" + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + file_creds = ga_credentials.AnonymousCredentials() + load_creds.return_value = (file_creds, None) + adc.return_value = (creds, None) + client = client_class(client_options=options, transport=transport_name) + create_channel.assert_called_with( + "documentai.googleapis.com:443", + credentials=file_creds, + credentials_file=None, + quota_project_id=None, + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), + scopes=None, + default_host="documentai.googleapis.com", + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + @pytest.mark.parametrize( "request_type", [document_processor_service.ProcessRequest, dict,] ) 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 cbe80650..e69d7198 100644 --- a/tests/unit/gapic/documentai_v1beta2/test_document_understanding_service.py +++ b/tests/unit/gapic/documentai_v1beta2/test_document_understanding_service.py @@ -29,6 +29,7 @@ from google.api_core import gapic_v1 from google.api_core import grpc_helpers from google.api_core import grpc_helpers_async +from google.api_core import operation from google.api_core import operation_async # type: ignore from google.api_core import operations_v1 from google.api_core import path_template @@ -550,25 +551,28 @@ def test_document_understanding_service_client_client_options_scopes( @pytest.mark.parametrize( - "client_class,transport_class,transport_name", + "client_class,transport_class,transport_name,grpc_helpers", [ ( DocumentUnderstandingServiceClient, transports.DocumentUnderstandingServiceGrpcTransport, "grpc", + grpc_helpers, ), ( DocumentUnderstandingServiceAsyncClient, transports.DocumentUnderstandingServiceGrpcAsyncIOTransport, "grpc_asyncio", + grpc_helpers_async, ), ], ) def test_document_understanding_service_client_client_options_credentials_file( - client_class, transport_class, transport_name + client_class, transport_class, transport_name, grpc_helpers ): # Check the case credentials file is provided. options = client_options.ClientOptions(credentials_file="credentials.json") + with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None client = client_class(client_options=options, transport=transport_name) @@ -604,6 +608,72 @@ def test_document_understanding_service_client_client_options_from_dict(): ) +@pytest.mark.parametrize( + "client_class,transport_class,transport_name,grpc_helpers", + [ + ( + DocumentUnderstandingServiceClient, + transports.DocumentUnderstandingServiceGrpcTransport, + "grpc", + grpc_helpers, + ), + ( + DocumentUnderstandingServiceAsyncClient, + transports.DocumentUnderstandingServiceGrpcAsyncIOTransport, + "grpc_asyncio", + grpc_helpers_async, + ), + ], +) +def test_document_understanding_service_client_create_channel_credentials_file( + client_class, transport_class, transport_name, grpc_helpers +): + # Check the case credentials file is provided. + options = client_options.ClientOptions(credentials_file="credentials.json") + + with mock.patch.object(transport_class, "__init__") as patched: + patched.return_value = None + client = client_class(client_options=options, transport=transport_name) + patched.assert_called_once_with( + credentials=None, + credentials_file="credentials.json", + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + ) + + # test that the credentials from file are saved and used as the credentials. + with mock.patch.object( + google.auth, "load_credentials_from_file", autospec=True + ) as load_creds, mock.patch.object( + google.auth, "default", autospec=True + ) as adc, mock.patch.object( + grpc_helpers, "create_channel" + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + file_creds = ga_credentials.AnonymousCredentials() + load_creds.return_value = (file_creds, None) + adc.return_value = (creds, None) + client = client_class(client_options=options, transport=transport_name) + create_channel.assert_called_with( + "documentai.googleapis.com:443", + credentials=file_creds, + credentials_file=None, + quota_project_id=None, + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), + scopes=None, + default_host="documentai.googleapis.com", + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + @pytest.mark.parametrize( "request_type", [document_understanding.BatchProcessDocumentsRequest, dict,] ) 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 e1f8b101..42fda531 100644 --- a/tests/unit/gapic/documentai_v1beta3/test_document_processor_service.py +++ b/tests/unit/gapic/documentai_v1beta3/test_document_processor_service.py @@ -29,6 +29,7 @@ from google.api_core import gapic_v1 from google.api_core import grpc_helpers from google.api_core import grpc_helpers_async +from google.api_core import operation from google.api_core import operation_async # type: ignore from google.api_core import operations_v1 from google.api_core import path_template @@ -562,25 +563,28 @@ def test_document_processor_service_client_client_options_scopes( @pytest.mark.parametrize( - "client_class,transport_class,transport_name", + "client_class,transport_class,transport_name,grpc_helpers", [ ( DocumentProcessorServiceClient, transports.DocumentProcessorServiceGrpcTransport, "grpc", + grpc_helpers, ), ( DocumentProcessorServiceAsyncClient, transports.DocumentProcessorServiceGrpcAsyncIOTransport, "grpc_asyncio", + grpc_helpers_async, ), ], ) def test_document_processor_service_client_client_options_credentials_file( - client_class, transport_class, transport_name + client_class, transport_class, transport_name, grpc_helpers ): # Check the case credentials file is provided. options = client_options.ClientOptions(credentials_file="credentials.json") + with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None client = client_class(client_options=options, transport=transport_name) @@ -616,6 +620,72 @@ def test_document_processor_service_client_client_options_from_dict(): ) +@pytest.mark.parametrize( + "client_class,transport_class,transport_name,grpc_helpers", + [ + ( + DocumentProcessorServiceClient, + transports.DocumentProcessorServiceGrpcTransport, + "grpc", + grpc_helpers, + ), + ( + DocumentProcessorServiceAsyncClient, + transports.DocumentProcessorServiceGrpcAsyncIOTransport, + "grpc_asyncio", + grpc_helpers_async, + ), + ], +) +def test_document_processor_service_client_create_channel_credentials_file( + client_class, transport_class, transport_name, grpc_helpers +): + # Check the case credentials file is provided. + options = client_options.ClientOptions(credentials_file="credentials.json") + + with mock.patch.object(transport_class, "__init__") as patched: + patched.return_value = None + client = client_class(client_options=options, transport=transport_name) + patched.assert_called_once_with( + credentials=None, + credentials_file="credentials.json", + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + ) + + # test that the credentials from file are saved and used as the credentials. + with mock.patch.object( + google.auth, "load_credentials_from_file", autospec=True + ) as load_creds, mock.patch.object( + google.auth, "default", autospec=True + ) as adc, mock.patch.object( + grpc_helpers, "create_channel" + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + file_creds = ga_credentials.AnonymousCredentials() + load_creds.return_value = (file_creds, None) + adc.return_value = (creds, None) + client = client_class(client_options=options, transport=transport_name) + create_channel.assert_called_with( + "documentai.googleapis.com:443", + credentials=file_creds, + credentials_file=None, + quota_project_id=None, + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), + scopes=None, + default_host="documentai.googleapis.com", + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + @pytest.mark.parametrize( "request_type", [document_processor_service.ProcessRequest, dict,] )