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

Commit

Permalink
chore: use gapic-generator-python 0.53.4 (#214)
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] authored Nov 1, 2021
1 parent 20babb6 commit 6374e7f
Show file tree
Hide file tree
Showing 14 changed files with 98 additions and 307 deletions.
40 changes: 21 additions & 19 deletions google/cloud/language_v1/services/language_service/async_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@
from typing import Dict, Sequence, Tuple, Type, Union
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.cloud.language_v1.types import language_service
from .transports.base import LanguageServiceTransport, DEFAULT_CLIENT_INFO
from .transports.grpc_asyncio import LanguageServiceGrpcAsyncIOTransport
Expand Down Expand Up @@ -162,18 +164,18 @@ def __init__(

async def analyze_sentiment(
self,
request: language_service.AnalyzeSentimentRequest = None,
request: Union[language_service.AnalyzeSentimentRequest, dict] = None,
*,
document: language_service.Document = None,
encoding_type: language_service.EncodingType = None,
retry: retries.Retry = gapic_v1.method.DEFAULT,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> language_service.AnalyzeSentimentResponse:
r"""Analyzes the sentiment of the provided text.
Args:
request (:class:`google.cloud.language_v1.types.AnalyzeSentimentRequest`):
request (Union[google.cloud.language_v1.types.AnalyzeSentimentRequest, dict]):
The request object. The sentiment analysis request
message.
document (:class:`google.cloud.language_v1.types.Document`):
Expand Down Expand Up @@ -245,11 +247,11 @@ async def analyze_sentiment(

async def analyze_entities(
self,
request: language_service.AnalyzeEntitiesRequest = None,
request: Union[language_service.AnalyzeEntitiesRequest, dict] = None,
*,
document: language_service.Document = None,
encoding_type: language_service.EncodingType = None,
retry: retries.Retry = gapic_v1.method.DEFAULT,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> language_service.AnalyzeEntitiesResponse:
Expand All @@ -259,7 +261,7 @@ async def analyze_entities(
properties.
Args:
request (:class:`google.cloud.language_v1.types.AnalyzeEntitiesRequest`):
request (Union[google.cloud.language_v1.types.AnalyzeEntitiesRequest, dict]):
The request object. The entity analysis request message.
document (:class:`google.cloud.language_v1.types.Document`):
Input document.
Expand Down Expand Up @@ -328,11 +330,11 @@ async def analyze_entities(

async def analyze_entity_sentiment(
self,
request: language_service.AnalyzeEntitySentimentRequest = None,
request: Union[language_service.AnalyzeEntitySentimentRequest, dict] = None,
*,
document: language_service.Document = None,
encoding_type: language_service.EncodingType = None,
retry: retries.Retry = gapic_v1.method.DEFAULT,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> language_service.AnalyzeEntitySentimentResponse:
Expand All @@ -342,7 +344,7 @@ async def analyze_entity_sentiment(
and its mentions.
Args:
request (:class:`google.cloud.language_v1.types.AnalyzeEntitySentimentRequest`):
request (Union[google.cloud.language_v1.types.AnalyzeEntitySentimentRequest, dict]):
The request object. The entity-level sentiment analysis
request message.
document (:class:`google.cloud.language_v1.types.Document`):
Expand Down Expand Up @@ -414,11 +416,11 @@ async def analyze_entity_sentiment(

async def analyze_syntax(
self,
request: language_service.AnalyzeSyntaxRequest = None,
request: Union[language_service.AnalyzeSyntaxRequest, dict] = None,
*,
document: language_service.Document = None,
encoding_type: language_service.EncodingType = None,
retry: retries.Retry = gapic_v1.method.DEFAULT,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> language_service.AnalyzeSyntaxResponse:
Expand All @@ -427,7 +429,7 @@ async def analyze_syntax(
tags, dependency trees, and other properties.
Args:
request (:class:`google.cloud.language_v1.types.AnalyzeSyntaxRequest`):
request (Union[google.cloud.language_v1.types.AnalyzeSyntaxRequest, dict]):
The request object. The syntax analysis request message.
document (:class:`google.cloud.language_v1.types.Document`):
Input document.
Expand Down Expand Up @@ -496,17 +498,17 @@ async def analyze_syntax(

async def classify_text(
self,
request: language_service.ClassifyTextRequest = None,
request: Union[language_service.ClassifyTextRequest, dict] = None,
*,
document: language_service.Document = None,
retry: retries.Retry = gapic_v1.method.DEFAULT,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> language_service.ClassifyTextResponse:
r"""Classifies a document into categories.
Args:
request (:class:`google.cloud.language_v1.types.ClassifyTextRequest`):
request (Union[google.cloud.language_v1.types.ClassifyTextRequest, dict]):
The request object. The document classification request
message.
document (:class:`google.cloud.language_v1.types.Document`):
Expand Down Expand Up @@ -569,12 +571,12 @@ async def classify_text(

async def annotate_text(
self,
request: language_service.AnnotateTextRequest = None,
request: Union[language_service.AnnotateTextRequest, dict] = None,
*,
document: language_service.Document = None,
features: language_service.AnnotateTextRequest.Features = None,
encoding_type: language_service.EncodingType = None,
retry: retries.Retry = gapic_v1.method.DEFAULT,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> language_service.AnnotateTextResponse:
Expand All @@ -583,7 +585,7 @@ async def annotate_text(
analyzeSyntax provide in one call.
Args:
request (:class:`google.cloud.language_v1.types.AnnotateTextRequest`):
request (Union[google.cloud.language_v1.types.AnnotateTextRequest, dict]):
The request object. The request message for the text
annotation API, which can perform multiple analysis
types (sentiment, entities, and syntax) in one call.
Expand Down
14 changes: 8 additions & 6 deletions google/cloud/language_v1/services/language_service/client.py
Original file line number Diff line number Diff line change
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.cloud.language_v1.types import language_service
from .transports.base import LanguageServiceTransport, DEFAULT_CLIENT_INFO
from .transports.grpc import LanguageServiceGrpcTransport
Expand Down Expand Up @@ -338,7 +340,7 @@ def analyze_sentiment(
*,
document: language_service.Document = None,
encoding_type: language_service.EncodingType = None,
retry: retries.Retry = gapic_v1.method.DEFAULT,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> language_service.AnalyzeSentimentResponse:
Expand Down Expand Up @@ -411,7 +413,7 @@ def analyze_entities(
*,
document: language_service.Document = None,
encoding_type: language_service.EncodingType = None,
retry: retries.Retry = gapic_v1.method.DEFAULT,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> language_service.AnalyzeEntitiesResponse:
Expand Down Expand Up @@ -484,7 +486,7 @@ def analyze_entity_sentiment(
*,
document: language_service.Document = None,
encoding_type: language_service.EncodingType = None,
retry: retries.Retry = gapic_v1.method.DEFAULT,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> language_service.AnalyzeEntitySentimentResponse:
Expand Down Expand Up @@ -560,7 +562,7 @@ def analyze_syntax(
*,
document: language_service.Document = None,
encoding_type: language_service.EncodingType = None,
retry: retries.Retry = gapic_v1.method.DEFAULT,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> language_service.AnalyzeSyntaxResponse:
Expand Down Expand Up @@ -631,7 +633,7 @@ def classify_text(
request: Union[language_service.ClassifyTextRequest, dict] = None,
*,
document: language_service.Document = None,
retry: retries.Retry = gapic_v1.method.DEFAULT,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> language_service.ClassifyTextResponse:
Expand Down Expand Up @@ -696,7 +698,7 @@ def annotate_text(
document: language_service.Document = None,
features: language_service.AnnotateTextRequest.Features = None,
encoding_type: language_service.EncodingType = None,
retry: retries.Retry = gapic_v1.method.DEFAULT,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> language_service.AnnotateTextResponse:
Expand Down
Original file line number Diff line number Diff line change
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 @@ -35,15 +34,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 LanguageServiceTransport(abc.ABC):
"""Abstract transport class for LanguageService."""
Expand Down Expand Up @@ -96,7 +86,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 @@ -129,29 +119,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
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
from google.api_core import grpc_helpers_async # 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
9 changes: 9 additions & 0 deletions google/cloud/language_v1/types/language_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,13 @@ class EncodingType(proto.Enum):
class Document(proto.Message):
r"""Represents the input to API methods.
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:
type_ (google.cloud.language_v1.types.Document.Type):
Required. If the type is not set or is ``TYPE_UNSPECIFIED``,
Expand All @@ -70,12 +77,14 @@ class Document(proto.Message):
The content of the input in string format.
Cloud audit logging exempt since it is based on
user data.
This field is a member of `oneof`_ ``source``.
gcs_content_uri (str):
The Google Cloud Storage URI where the file content is
located. This URI must be of the form:
gs://bucket_name/object_name. For more details, see
https://cloud.google.com/storage/docs/reference-uris. NOTE:
Cloud Storage object versioning is not supported.
This field is a member of `oneof`_ ``source``.
language (str):
The language of the document (if not specified, the language
is automatically detected). Both ISO and BCP-47 language
Expand Down
Loading

0 comments on commit 6374e7f

Please sign in to comment.