Skip to content
This repository has been archived by the owner on Sep 20, 2023. It is now read-only.

Commit

Permalink
feat: exposed GetProcessorType to v1beta3 (#444)
Browse files Browse the repository at this point in the history
* feat: exposed GetProcessorType to v1beta3

PiperOrigin-RevId: 502616281

Source-Link: googleapis/googleapis@04e6db9

Source-Link: https://github.com/googleapis/googleapis-gen/commit/f4bc77f905e68057db09b78397afbddb9b86c80e
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiZjRiYzc3ZjkwNWU2ODA1N2RiMDliNzgzOTdhZmJkZGI5Yjg2YzgwZSJ9

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
  • Loading branch information
gcf-owl-bot[bot] and gcf-owl-bot[bot] authored Jan 17, 2023
1 parent 8c7f52b commit e5835f4
Show file tree
Hide file tree
Showing 17 changed files with 854 additions and 3 deletions.
Binary file added documentai-v1beta3-py.tar.gz
Binary file not shown.
2 changes: 2 additions & 0 deletions google/cloud/documentai_v1beta3/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
FetchProcessorTypesResponse,
GetEvaluationRequest,
GetProcessorRequest,
GetProcessorTypeRequest,
GetProcessorVersionRequest,
HumanReviewStatus,
ListEvaluationsRequest,
Expand Down Expand Up @@ -129,6 +130,7 @@
"GcsPrefix",
"GetEvaluationRequest",
"GetProcessorRequest",
"GetProcessorTypeRequest",
"GetProcessorVersionRequest",
"HumanReviewStatus",
"ListEvaluationsRequest",
Expand Down
10 changes: 10 additions & 0 deletions google/cloud/documentai_v1beta3/gapic_metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@
"get_processor"
]
},
"GetProcessorType": {
"methods": [
"get_processor_type"
]
},
"GetProcessorVersion": {
"methods": [
"get_processor_version"
Expand Down Expand Up @@ -175,6 +180,11 @@
"get_processor"
]
},
"GetProcessorType": {
"methods": [
"get_processor_type"
]
},
"GetProcessorVersion": {
"methods": [
"get_processor_version"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
except AttributeError: # pragma: NO COVER
OptionalRetry = Union[retries.Retry, object] # type: ignore

from google.api import launch_stage_pb2 # type: ignore
from google.api_core import operation # type: ignore
from google.api_core import operation_async # type: ignore
from google.cloud.location import locations_pb2 # type: ignore
Expand Down Expand Up @@ -753,6 +754,111 @@ async def sample_list_processor_types():
# Done; return the response.
return response

async def get_processor_type(
self,
request: Optional[
Union[document_processor_service.GetProcessorTypeRequest, dict]
] = None,
*,
name: Optional[str] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> processor_type.ProcessorType:
r"""Gets a processor type detail.
.. code-block:: python
# This snippet has been automatically generated and should be regarded as a
# code template only.
# It will require modifications to work:
# - It may require correct/in-range values for request initialization.
# - It may require specifying regional endpoints when creating the service
# client as shown in:
# https://googleapis.dev/python/google-api-core/latest/client_options.html
from google.cloud import documentai_v1beta3
async def sample_get_processor_type():
# Create a client
client = documentai_v1beta3.DocumentProcessorServiceAsyncClient()
# Initialize request argument(s)
request = documentai_v1beta3.GetProcessorTypeRequest(
name="name_value",
)
# Make the request
response = await client.get_processor_type(request=request)
# Handle the response
print(response)
Args:
request (Optional[Union[google.cloud.documentai_v1beta3.types.GetProcessorTypeRequest, dict]]):
The request object. Request message for get processor.
name (:class:`str`):
Required. The processor type resource
name.
This corresponds to the ``name`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
retry (google.api_core.retry.Retry): Designation of what errors, if any,
should be retried.
timeout (float): The timeout for this request.
metadata (Sequence[Tuple[str, str]]): Strings which should be
sent along with the request as metadata.
Returns:
google.cloud.documentai_v1beta3.types.ProcessorType:
A processor type is responsible for
performing a certain document
understanding task on a certain type of
document.
"""
# Create or coerce a protobuf request object.
# 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:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
)

request = document_processor_service.GetProcessorTypeRequest(request)

# If we have keyword arguments corresponding to fields on the
# request, apply these.
if name is not None:
request.name = name

# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
rpc = gapic_v1.method_async.wrap_method(
self._client._transport.get_processor_type,
default_timeout=None,
client_info=DEFAULT_CLIENT_INFO,
)

# Certain fields should be provided within the metadata header;
# add these here.
metadata = tuple(metadata) + (
gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
)

# Send the request.
response = await rpc(
request,
retry=retry,
timeout=timeout,
metadata=metadata,
)

# Done; return the response.
return response

async def list_processors(
self,
request: Optional[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
except AttributeError: # pragma: NO COVER
OptionalRetry = Union[retries.Retry, object] # type: ignore

from google.api import launch_stage_pb2 # type: ignore
from google.api_core import operation # type: ignore
from google.api_core import operation_async # type: ignore
from google.cloud.location import locations_pb2 # type: ignore
Expand Down Expand Up @@ -1029,6 +1030,111 @@ def sample_list_processor_types():
# Done; return the response.
return response

def get_processor_type(
self,
request: Optional[
Union[document_processor_service.GetProcessorTypeRequest, dict]
] = None,
*,
name: Optional[str] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> processor_type.ProcessorType:
r"""Gets a processor type detail.
.. code-block:: python
# This snippet has been automatically generated and should be regarded as a
# code template only.
# It will require modifications to work:
# - It may require correct/in-range values for request initialization.
# - It may require specifying regional endpoints when creating the service
# client as shown in:
# https://googleapis.dev/python/google-api-core/latest/client_options.html
from google.cloud import documentai_v1beta3
def sample_get_processor_type():
# Create a client
client = documentai_v1beta3.DocumentProcessorServiceClient()
# Initialize request argument(s)
request = documentai_v1beta3.GetProcessorTypeRequest(
name="name_value",
)
# Make the request
response = client.get_processor_type(request=request)
# Handle the response
print(response)
Args:
request (Union[google.cloud.documentai_v1beta3.types.GetProcessorTypeRequest, dict]):
The request object. Request message for get processor.
name (str):
Required. The processor type resource
name.
This corresponds to the ``name`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
retry (google.api_core.retry.Retry): Designation of what errors, if any,
should be retried.
timeout (float): The timeout for this request.
metadata (Sequence[Tuple[str, str]]): Strings which should be
sent along with the request as metadata.
Returns:
google.cloud.documentai_v1beta3.types.ProcessorType:
A processor type is responsible for
performing a certain document
understanding task on a certain type of
document.
"""
# Create or coerce a protobuf request object.
# 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:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
)

# Minor optimization to avoid making a copy if the user passes
# in a document_processor_service.GetProcessorTypeRequest.
# There's no risk of modifying the input as we've already verified
# there are no flattened fields.
if not isinstance(request, document_processor_service.GetProcessorTypeRequest):
request = document_processor_service.GetProcessorTypeRequest(request)
# If we have keyword arguments corresponding to fields on the
# request, apply these.
if name is not None:
request.name = name

# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
rpc = self._transport._wrapped_methods[self._transport.get_processor_type]

# Certain fields should be provided within the metadata header;
# add these here.
metadata = tuple(metadata) + (
gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
)

# Send the request.
response = rpc(
request,
retry=retry,
timeout=timeout,
metadata=metadata,
)

# Done; return the response.
return response

def list_processors(
self,
request: Optional[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
from google.cloud.documentai_v1beta3.types import document_processor_service, evaluation
from google.cloud.documentai_v1beta3.types import processor
from google.cloud.documentai_v1beta3.types import processor as gcd_processor
from google.cloud.documentai_v1beta3.types import processor_type

DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
gapic_version=package_version.__version__
Expand Down Expand Up @@ -166,6 +167,11 @@ def _prep_wrapped_messages(self, client_info):
default_timeout=None,
client_info=client_info,
),
self.get_processor_type: gapic_v1.method.wrap_method(
self.get_processor_type,
default_timeout=None,
client_info=client_info,
),
self.list_processors: gapic_v1.method.wrap_method(
self.list_processors,
default_timeout=None,
Expand Down Expand Up @@ -322,6 +328,15 @@ def list_processor_types(
]:
raise NotImplementedError()

@property
def get_processor_type(
self,
) -> Callable[
[document_processor_service.GetProcessorTypeRequest],
Union[processor_type.ProcessorType, Awaitable[processor_type.ProcessorType]],
]:
raise NotImplementedError()

@property
def list_processors(
self,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
from google.cloud.documentai_v1beta3.types import document_processor_service, evaluation
from google.cloud.documentai_v1beta3.types import processor
from google.cloud.documentai_v1beta3.types import processor as gcd_processor
from google.cloud.documentai_v1beta3.types import processor_type

from .base import DEFAULT_CLIENT_INFO, DocumentProcessorServiceTransport

Expand Down Expand Up @@ -368,6 +369,35 @@ def list_processor_types(
)
return self._stubs["list_processor_types"]

@property
def get_processor_type(
self,
) -> Callable[
[document_processor_service.GetProcessorTypeRequest],
processor_type.ProcessorType,
]:
r"""Return a callable for the get processor type method over gRPC.
Gets a processor type detail.
Returns:
Callable[[~.GetProcessorTypeRequest],
~.ProcessorType]:
A function that, when called, will call the underlying RPC
on the server.
"""
# Generate a "stub function" on-the-fly which will actually make
# the request.
# gRPC handles serialization and deserialization, so we just need
# to pass in the functions for each.
if "get_processor_type" not in self._stubs:
self._stubs["get_processor_type"] = self.grpc_channel.unary_unary(
"/google.cloud.documentai.v1beta3.DocumentProcessorService/GetProcessorType",
request_serializer=document_processor_service.GetProcessorTypeRequest.serialize,
response_deserializer=processor_type.ProcessorType.deserialize,
)
return self._stubs["get_processor_type"]

@property
def list_processors(
self,
Expand Down
Loading

0 comments on commit e5835f4

Please sign in to comment.