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

Commit

Permalink
chore: use gapic-generator-python 0.53.4 (#279)
Browse files Browse the repository at this point in the history
- [ ] Regenerate this pull request now.

docs: list oneofs in docstring
fix(deps): require google-api-core >= 1.28.0
fix(deps): drop packaging dependency

committer: busunkim96@
PiperOrigin-RevId: 406468269

Source-Link: googleapis/googleapis@83d81b0

Source-Link: googleapis/googleapis-gen@2ff001f
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiMmZmMDAxZmJhY2I5ZTc3ZTcxZDczNGRlNWY5NTVjMDVmZGFlODUyNiJ9
  • Loading branch information
gcf-owl-bot[bot] committed Nov 1, 2021
1 parent 242af1b commit 43f25c0
Show file tree
Hide file tree
Showing 21 changed files with 157 additions and 413 deletions.
18 changes: 10 additions & 8 deletions google/cloud/speech_v1/services/speech/async_client.py
Expand Up @@ -28,13 +28,15 @@
)
import pkg_resources

import google.api_core.client_options as ClientOptions # type: ignore
from google.api_core.client_options import ClientOptions # type: ignore
from google.api_core import exceptions as core_exceptions # type: ignore
from google.api_core import gapic_v1 # type: ignore
from google.api_core import retry as retries # type: ignore
from google.auth import credentials as ga_credentials # type: ignore
from google.oauth2 import service_account # type: ignore

OptionalRetry = Union[retries.Retry, object]

from google.api_core import operation # type: ignore
from google.api_core import operation_async # type: ignore
from google.cloud.speech_v1.types import cloud_speech
Expand Down Expand Up @@ -163,19 +165,19 @@ def __init__(

async def recognize(
self,
request: cloud_speech.RecognizeRequest = None,
request: Union[cloud_speech.RecognizeRequest, dict] = None,
*,
config: cloud_speech.RecognitionConfig = None,
audio: cloud_speech.RecognitionAudio = None,
retry: retries.Retry = gapic_v1.method.DEFAULT,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> cloud_speech.RecognizeResponse:
r"""Performs synchronous speech recognition: receive
results after all audio has been sent and processed.
Args:
request (:class:`google.cloud.speech_v1.types.RecognizeRequest`):
request (Union[google.cloud.speech_v1.types.RecognizeRequest, dict]):
The request object. The top-level message sent by the
client for the `Recognize` method.
config (:class:`google.cloud.speech_v1.types.RecognitionConfig`):
Expand Down Expand Up @@ -251,11 +253,11 @@ async def recognize(

async def long_running_recognize(
self,
request: cloud_speech.LongRunningRecognizeRequest = None,
request: Union[cloud_speech.LongRunningRecognizeRequest, dict] = None,
*,
config: cloud_speech.RecognitionConfig = None,
audio: cloud_speech.RecognitionAudio = None,
retry: retries.Retry = gapic_v1.method.DEFAULT,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> operation_async.AsyncOperation:
Expand All @@ -267,7 +269,7 @@ async def long_running_recognize(
`how-to <https://cloud.google.com/speech-to-text/docs/async-recognize>`__.
Args:
request (:class:`google.cloud.speech_v1.types.LongRunningRecognizeRequest`):
request (Union[google.cloud.speech_v1.types.LongRunningRecognizeRequest, dict]):
The request object. The top-level message sent by the
client for the `LongRunningRecognize` method.
config (:class:`google.cloud.speech_v1.types.RecognitionConfig`):
Expand Down Expand Up @@ -348,7 +350,7 @@ def streaming_recognize(
self,
requests: AsyncIterator[cloud_speech.StreamingRecognizeRequest] = None,
*,
retry: retries.Retry = gapic_v1.method.DEFAULT,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> Awaitable[AsyncIterable[cloud_speech.StreamingRecognizeResponse]]:
Expand Down
8 changes: 5 additions & 3 deletions google/cloud/speech_v1/services/speech/client.py
Expand Up @@ -30,6 +30,8 @@
from google.auth.exceptions import MutualTLSChannelError # type: ignore
from google.oauth2 import service_account # type: ignore

OptionalRetry = Union[retries.Retry, object]

from google.api_core import operation # type: ignore
from google.api_core import operation_async # type: ignore
from google.cloud.speech_v1.types import cloud_speech
Expand Down Expand Up @@ -338,7 +340,7 @@ def recognize(
*,
config: cloud_speech.RecognitionConfig = None,
audio: cloud_speech.RecognitionAudio = None,
retry: retries.Retry = gapic_v1.method.DEFAULT,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> cloud_speech.RecognizeResponse:
Expand Down Expand Up @@ -416,7 +418,7 @@ def long_running_recognize(
*,
config: cloud_speech.RecognitionConfig = None,
audio: cloud_speech.RecognitionAudio = None,
retry: retries.Retry = gapic_v1.method.DEFAULT,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> operation.Operation:
Expand Down Expand Up @@ -509,7 +511,7 @@ def streaming_recognize(
self,
requests: Iterator[cloud_speech.StreamingRecognizeRequest] = None,
*,
retry: retries.Retry = gapic_v1.method.DEFAULT,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> Iterable[cloud_speech.StreamingRecognizeResponse]:
Expand Down
37 changes: 2 additions & 35 deletions google/cloud/speech_v1/services/speech/transports/base.py
Expand Up @@ -15,7 +15,6 @@
#
import abc
from typing import Awaitable, Callable, Dict, Optional, Sequence, Union
import packaging.version
import pkg_resources

import google.auth # type: ignore
Expand All @@ -37,15 +36,6 @@
except pkg_resources.DistributionNotFound:
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo()

try:
# google.auth.__version__ was added in 1.26.0
_GOOGLE_AUTH_VERSION = google.auth.__version__
except AttributeError:
try: # try pkg_resources if it is available
_GOOGLE_AUTH_VERSION = pkg_resources.get_distribution("google-auth").version
except pkg_resources.DistributionNotFound: # pragma: NO COVER
_GOOGLE_AUTH_VERSION = None


class SpeechTransport(abc.ABC):
"""Abstract transport class for Speech."""
Expand Down Expand Up @@ -95,7 +85,7 @@ def __init__(
host += ":443"
self._host = host

scopes_kwargs = self._get_scopes_kwargs(self._host, scopes)
scopes_kwargs = {"scopes": scopes, "default_scopes": self.AUTH_SCOPES}

# Save the scopes.
self._scopes = scopes
Expand Down Expand Up @@ -128,29 +118,6 @@ def __init__(
# Save the credentials.
self._credentials = credentials

# TODO(busunkim): This method is in the base transport
# to avoid duplicating code across the transport classes. These functions
# should be deleted once the minimum required versions of google-auth is increased.

# TODO: Remove this function once google-auth >= 1.25.0 is required
@classmethod
def _get_scopes_kwargs(
cls, host: str, scopes: Optional[Sequence[str]]
) -> Dict[str, Optional[Sequence[str]]]:
"""Returns scopes kwargs to pass to google-auth methods depending on the google-auth version"""

scopes_kwargs = {}

if _GOOGLE_AUTH_VERSION and (
packaging.version.parse(_GOOGLE_AUTH_VERSION)
>= packaging.version.parse("1.25.0")
):
scopes_kwargs = {"scopes": scopes, "default_scopes": cls.AUTH_SCOPES}
else:
scopes_kwargs = {"scopes": scopes or cls.AUTH_SCOPES}

return scopes_kwargs

def _prep_wrapped_messages(self, client_info):
# Precompute the wrapped methods.
self._wrapped_methods = {
Expand Down Expand Up @@ -201,7 +168,7 @@ def close(self):
raise NotImplementedError()

@property
def operations_client(self) -> operations_v1.OperationsClient:
def operations_client(self):
"""Return the client designed to process long-running operations."""
raise NotImplementedError()

Expand Down
2 changes: 1 addition & 1 deletion google/cloud/speech_v1/services/speech/transports/grpc.py
Expand Up @@ -112,7 +112,7 @@ def __init__(
self._grpc_channel = None
self._ssl_channel_credentials = ssl_channel_credentials
self._stubs: Dict[str, Callable] = {}
self._operations_client = None
self._operations_client: Optional[operations_v1.OperationsClient] = None

if api_mtls_endpoint:
warnings.warn("api_mtls_endpoint is deprecated", DeprecationWarning)
Expand Down
Expand Up @@ -21,7 +21,6 @@
from google.api_core import operations_v1 # type: ignore
from google.auth import credentials as ga_credentials # type: ignore
from google.auth.transport.grpc import SslCredentials # type: ignore
import packaging.version

import grpc # type: ignore
from grpc.experimental import aio # type: ignore
Expand Down Expand Up @@ -159,7 +158,7 @@ def __init__(
self._grpc_channel = None
self._ssl_channel_credentials = ssl_channel_credentials
self._stubs: Dict[str, Callable] = {}
self._operations_client = None
self._operations_client: Optional[operations_v1.OperationsAsyncClient] = None

if api_mtls_endpoint:
warnings.warn("api_mtls_endpoint is deprecated", DeprecationWarning)
Expand Down
22 changes: 22 additions & 0 deletions google/cloud/speech_v1/types/cloud_speech.py
Expand Up @@ -89,12 +89,16 @@ class TranscriptOutputConfig(proto.Message):
r"""Specifies an optional destination for the recognition
results.
.. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields
Attributes:
gcs_uri (str):
Specifies a Cloud Storage URI for the recognition results.
Must be specified in the format:
``gs://bucket_name/object_name``, and the bucket must
already exist.
This field is a member of `oneof`_ ``output_type``.
"""

gcs_uri = proto.Field(proto.STRING, number=1, oneof="output_type",)
Expand All @@ -109,11 +113,19 @@ class StreamingRecognizeRequest(proto.Message):
``audio_content`` and must not contain a ``streaming_config``
message.
This message has `oneof`_ fields (mutually exclusive fields).
For each oneof, at most one member field can be set at the same time.
Setting any member of the oneof automatically clears all other
members.
.. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields
Attributes:
streaming_config (google.cloud.speech_v1.types.StreamingRecognitionConfig):
Provides information to the recognizer that specifies how to
process the request. The first ``StreamingRecognizeRequest``
message must contain a ``streaming_config`` message.
This field is a member of `oneof`_ ``streaming_request``.
audio_content (bytes):
The audio data to be recognized. Sequential chunks of audio
data are sent in sequential ``StreamingRecognizeRequest``
Expand All @@ -125,6 +137,7 @@ class StreamingRecognizeRequest(proto.Message):
fields, proto buffers use a pure binary representation (not
base64). See `content
limits <https://cloud.google.com/speech-to-text/quotas#content>`__.
This field is a member of `oneof`_ ``streaming_request``.
"""

streaming_config = proto.Field(
Expand Down Expand Up @@ -531,12 +544,20 @@ class RecognitionAudio(proto.Message):
See `content
limits <https://cloud.google.com/speech-to-text/quotas#content>`__.
This message has `oneof`_ fields (mutually exclusive fields).
For each oneof, at most one member field can be set at the same time.
Setting any member of the oneof automatically clears all other
members.
.. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields
Attributes:
content (bytes):
The audio data bytes encoded as specified in
``RecognitionConfig``. Note: as with all bytes fields, proto
buffers use a pure binary representation, whereas JSON
representations use base64.
This field is a member of `oneof`_ ``audio_source``.
uri (str):
URI that points to a file that contains audio data bytes as
specified in ``RecognitionConfig``. The file must not be
Expand All @@ -547,6 +568,7 @@ class RecognitionAudio(proto.Message):
[google.rpc.Code.INVALID_ARGUMENT][google.rpc.Code.INVALID_ARGUMENT]).
For more information, see `Request
URIs <https://cloud.google.com/storage/docs/reference-uris>`__.
This field is a member of `oneof`_ ``audio_source``.
"""

content = proto.Field(proto.BYTES, number=1, oneof="audio_source",)
Expand Down

0 comments on commit 43f25c0

Please sign in to comment.