From 63a600a5ff1d946754f73c07e76951739f27d21c Mon Sep 17 00:00:00 2001 From: yoshi-automation Date: Wed, 6 Jan 2021 07:27:00 -0800 Subject: [PATCH] chore: upgrade gapic-generator-python to 0.39.1 feat: add 'from_service_account_info' factory to clients fix: fix sphinx identifiers PiperOrigin-RevId: 350246057 Source-Author: Google APIs Source-Date: Tue Jan 5 16:44:11 2021 -0800 Source-Repo: googleapis/googleapis Source-Sha: 520682435235d9c503983a360a2090025aa47cd1 Source-Link: https://github.com/googleapis/googleapis/commit/520682435235d9c503983a360a2090025aa47cd1 --- .coveragerc | 22 +--- docs/language_v1/language_service.rst | 6 ++ docs/language_v1/services.rst | 6 +- docs/language_v1/types.rst | 1 + docs/language_v1beta2/language_service.rst | 6 ++ docs/language_v1beta2/services.rst | 6 +- docs/language_v1beta2/types.rst | 1 + .../services/language_service/async_client.py | 54 +++++----- .../services/language_service/client.py | 75 ++++++++----- .../language_v1/types/language_service.py | 100 +++++++++--------- .../services/language_service/async_client.py | 54 +++++----- .../services/language_service/client.py | 75 ++++++++----- .../types/language_service.py | 100 +++++++++--------- synth.metadata | 9 +- .../language_v1/test_language_service.py | 28 +++-- .../language_v1beta2/test_language_service.py | 28 +++-- 16 files changed, 328 insertions(+), 243 deletions(-) create mode 100644 docs/language_v1/language_service.rst create mode 100644 docs/language_v1beta2/language_service.rst diff --git a/.coveragerc b/.coveragerc index fff276ec..8aa27c09 100644 --- a/.coveragerc +++ b/.coveragerc @@ -1,29 +1,11 @@ -# -*- coding: utf-8 -*- -# -# Copyright 2020 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# Generated by synthtool. DO NOT EDIT! [run] branch = True -omit = - google/cloud/__init__.py [report] fail_under = 100 show_missing = True -omit = google/cloud/language/__init__.py +omit = + google/cloud/language/__init__.py exclude_lines = # Re-enable the standard pragma pragma: NO COVER diff --git a/docs/language_v1/language_service.rst b/docs/language_v1/language_service.rst new file mode 100644 index 00000000..96e8755a --- /dev/null +++ b/docs/language_v1/language_service.rst @@ -0,0 +1,6 @@ +LanguageService +--------------------------------- + +.. automodule:: google.cloud.language_v1.services.language_service + :members: + :inherited-members: diff --git a/docs/language_v1/services.rst b/docs/language_v1/services.rst index e1af1f07..26f74fe9 100644 --- a/docs/language_v1/services.rst +++ b/docs/language_v1/services.rst @@ -1,6 +1,6 @@ Services for Google Cloud Language v1 API ========================================= +.. toctree:: + :maxdepth: 2 -.. automodule:: google.cloud.language_v1.services.language_service - :members: - :inherited-members: + language_service diff --git a/docs/language_v1/types.rst b/docs/language_v1/types.rst index 5dd3769e..a8633727 100644 --- a/docs/language_v1/types.rst +++ b/docs/language_v1/types.rst @@ -3,4 +3,5 @@ Types for Google Cloud Language v1 API .. automodule:: google.cloud.language_v1.types :members: + :undoc-members: :show-inheritance: diff --git a/docs/language_v1beta2/language_service.rst b/docs/language_v1beta2/language_service.rst new file mode 100644 index 00000000..799a7892 --- /dev/null +++ b/docs/language_v1beta2/language_service.rst @@ -0,0 +1,6 @@ +LanguageService +--------------------------------- + +.. automodule:: google.cloud.language_v1beta2.services.language_service + :members: + :inherited-members: diff --git a/docs/language_v1beta2/services.rst b/docs/language_v1beta2/services.rst index 275e2e7c..40ead585 100644 --- a/docs/language_v1beta2/services.rst +++ b/docs/language_v1beta2/services.rst @@ -1,6 +1,6 @@ Services for Google Cloud Language v1beta2 API ============================================== +.. toctree:: + :maxdepth: 2 -.. automodule:: google.cloud.language_v1beta2.services.language_service - :members: - :inherited-members: + language_service diff --git a/docs/language_v1beta2/types.rst b/docs/language_v1beta2/types.rst index 2e834e61..6c5a9493 100644 --- a/docs/language_v1beta2/types.rst +++ b/docs/language_v1beta2/types.rst @@ -3,4 +3,5 @@ Types for Google Cloud Language v1beta2 API .. automodule:: google.cloud.language_v1beta2.types :members: + :undoc-members: :show-inheritance: diff --git a/google/cloud/language_v1/services/language_service/async_client.py b/google/cloud/language_v1/services/language_service/async_client.py index 0d7fd084..e0a357ea 100644 --- a/google/cloud/language_v1/services/language_service/async_client.py +++ b/google/cloud/language_v1/services/language_service/async_client.py @@ -74,6 +74,7 @@ class LanguageServiceAsyncClient: LanguageServiceClient.parse_common_location_path ) + from_service_account_info = LanguageServiceClient.from_service_account_info from_service_account_file = LanguageServiceClient.from_service_account_file from_service_account_json = from_service_account_file @@ -151,17 +152,18 @@ async def analyze_sentiment( r"""Analyzes the sentiment of the provided text. Args: - request (:class:`~.language_service.AnalyzeSentimentRequest`): + request (:class:`google.cloud.language_v1.types.AnalyzeSentimentRequest`): The request object. The sentiment analysis request message. - document (:class:`~.language_service.Document`): + document (:class:`google.cloud.language_v1.types.Document`): Input document. This corresponds to the ``document`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - encoding_type (:class:`~.language_service.EncodingType`): + encoding_type (:class:`google.cloud.language_v1.types.EncodingType`): The encoding type used by the API to calculate sentence offsets. + This corresponds to the ``encoding_type`` field on the ``request`` instance; if ``request`` is provided, this should not be set. @@ -173,7 +175,7 @@ async def analyze_sentiment( sent along with the request as metadata. Returns: - ~.language_service.AnalyzeSentimentResponse: + google.cloud.language_v1.types.AnalyzeSentimentResponse: The sentiment analysis response message. @@ -236,16 +238,17 @@ async def analyze_entities( properties. Args: - request (:class:`~.language_service.AnalyzeEntitiesRequest`): + request (:class:`google.cloud.language_v1.types.AnalyzeEntitiesRequest`): The request object. The entity analysis request message. - document (:class:`~.language_service.Document`): + document (:class:`google.cloud.language_v1.types.Document`): Input document. This corresponds to the ``document`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - encoding_type (:class:`~.language_service.EncodingType`): + encoding_type (:class:`google.cloud.language_v1.types.EncodingType`): The encoding type used by the API to calculate offsets. + This corresponds to the ``encoding_type`` field on the ``request`` instance; if ``request`` is provided, this should not be set. @@ -257,7 +260,7 @@ async def analyze_entities( sent along with the request as metadata. Returns: - ~.language_service.AnalyzeEntitiesResponse: + google.cloud.language_v1.types.AnalyzeEntitiesResponse: The entity analysis response message. """ # Create or coerce a protobuf request object. @@ -318,17 +321,18 @@ async def analyze_entity_sentiment( and its mentions. Args: - request (:class:`~.language_service.AnalyzeEntitySentimentRequest`): + request (:class:`google.cloud.language_v1.types.AnalyzeEntitySentimentRequest`): The request object. The entity-level sentiment analysis request message. - document (:class:`~.language_service.Document`): + document (:class:`google.cloud.language_v1.types.Document`): Input document. This corresponds to the ``document`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - encoding_type (:class:`~.language_service.EncodingType`): + encoding_type (:class:`google.cloud.language_v1.types.EncodingType`): The encoding type used by the API to calculate offsets. + This corresponds to the ``encoding_type`` field on the ``request`` instance; if ``request`` is provided, this should not be set. @@ -340,7 +344,7 @@ async def analyze_entity_sentiment( sent along with the request as metadata. Returns: - ~.language_service.AnalyzeEntitySentimentResponse: + google.cloud.language_v1.types.AnalyzeEntitySentimentResponse: The entity-level sentiment analysis response message. @@ -402,16 +406,17 @@ async def analyze_syntax( tags, dependency trees, and other properties. Args: - request (:class:`~.language_service.AnalyzeSyntaxRequest`): + request (:class:`google.cloud.language_v1.types.AnalyzeSyntaxRequest`): The request object. The syntax analysis request message. - document (:class:`~.language_service.Document`): + document (:class:`google.cloud.language_v1.types.Document`): Input document. This corresponds to the ``document`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - encoding_type (:class:`~.language_service.EncodingType`): + encoding_type (:class:`google.cloud.language_v1.types.EncodingType`): The encoding type used by the API to calculate offsets. + This corresponds to the ``encoding_type`` field on the ``request`` instance; if ``request`` is provided, this should not be set. @@ -423,7 +428,7 @@ async def analyze_syntax( sent along with the request as metadata. Returns: - ~.language_service.AnalyzeSyntaxResponse: + google.cloud.language_v1.types.AnalyzeSyntaxResponse: The syntax analysis response message. """ # Create or coerce a protobuf request object. @@ -480,10 +485,10 @@ async def classify_text( r"""Classifies a document into categories. Args: - request (:class:`~.language_service.ClassifyTextRequest`): + request (:class:`google.cloud.language_v1.types.ClassifyTextRequest`): The request object. The document classification request message. - document (:class:`~.language_service.Document`): + document (:class:`google.cloud.language_v1.types.Document`): Input document. This corresponds to the ``document`` field on the ``request`` instance; if ``request`` is provided, this @@ -496,7 +501,7 @@ async def classify_text( sent along with the request as metadata. Returns: - ~.language_service.ClassifyTextResponse: + google.cloud.language_v1.types.ClassifyTextResponse: The document classification response message. @@ -557,23 +562,24 @@ async def annotate_text( analyzeSyntax provide in one call. Args: - request (:class:`~.language_service.AnnotateTextRequest`): + request (:class:`google.cloud.language_v1.types.AnnotateTextRequest`): The request object. The request message for the text annotation API, which can perform multiple analysis types (sentiment, entities, and syntax) in one call. - document (:class:`~.language_service.Document`): + document (:class:`google.cloud.language_v1.types.Document`): Input document. This corresponds to the ``document`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - features (:class:`~.language_service.AnnotateTextRequest.Features`): + features (:class:`google.cloud.language_v1.types.AnnotateTextRequest.Features`): The enabled features. This corresponds to the ``features`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - encoding_type (:class:`~.language_service.EncodingType`): + encoding_type (:class:`google.cloud.language_v1.types.EncodingType`): The encoding type used by the API to calculate offsets. + This corresponds to the ``encoding_type`` field on the ``request`` instance; if ``request`` is provided, this should not be set. @@ -585,7 +591,7 @@ async def annotate_text( sent along with the request as metadata. Returns: - ~.language_service.AnnotateTextResponse: + google.cloud.language_v1.types.AnnotateTextResponse: The text annotations response message. diff --git a/google/cloud/language_v1/services/language_service/client.py b/google/cloud/language_v1/services/language_service/client.py index 2c4d9504..2e54333c 100644 --- a/google/cloud/language_v1/services/language_service/client.py +++ b/google/cloud/language_v1/services/language_service/client.py @@ -111,6 +111,22 @@ def _get_default_mtls_endpoint(api_endpoint): DEFAULT_ENDPOINT ) + @classmethod + def from_service_account_info(cls, info: dict, *args, **kwargs): + """Creates an instance of this client using the provided credentials info. + + Args: + info (dict): The service account private key info. + args: Additional arguments to pass to the constructor. + kwargs: Additional arguments to pass to the constructor. + + Returns: + LanguageServiceClient: The constructed client. + """ + credentials = service_account.Credentials.from_service_account_info(info) + kwargs["credentials"] = credentials + return cls(*args, **kwargs) + @classmethod def from_service_account_file(cls, filename: str, *args, **kwargs): """Creates an instance of this client using the provided credentials @@ -123,7 +139,7 @@ def from_service_account_file(cls, filename: str, *args, **kwargs): kwargs: Additional arguments to pass to the constructor. Returns: - {@api.name}: The constructed client. + LanguageServiceClient: The constructed client. """ credentials = service_account.Credentials.from_service_account_file(filename) kwargs["credentials"] = credentials @@ -215,10 +231,10 @@ def __init__( credentials identify the application to the service; if none are specified, the client will attempt to ascertain the credentials from the environment. - transport (Union[str, ~.LanguageServiceTransport]): The + transport (Union[str, LanguageServiceTransport]): The transport to use. If set to None, a transport is chosen automatically. - client_options (client_options_lib.ClientOptions): Custom options for the + client_options (google.api_core.client_options.ClientOptions): Custom options for the client. It won't take effect if a ``transport`` instance is provided. (1) The ``api_endpoint`` property can be used to override the default endpoint provided by the client. GOOGLE_API_USE_MTLS_ENDPOINT @@ -329,17 +345,18 @@ def analyze_sentiment( r"""Analyzes the sentiment of the provided text. Args: - request (:class:`~.language_service.AnalyzeSentimentRequest`): + request (google.cloud.language_v1.types.AnalyzeSentimentRequest): The request object. The sentiment analysis request message. - document (:class:`~.language_service.Document`): + document (google.cloud.language_v1.types.Document): Input document. This corresponds to the ``document`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - encoding_type (:class:`~.language_service.EncodingType`): + encoding_type (google.cloud.language_v1.types.EncodingType): The encoding type used by the API to calculate sentence offsets. + This corresponds to the ``encoding_type`` field on the ``request`` instance; if ``request`` is provided, this should not be set. @@ -351,7 +368,7 @@ def analyze_sentiment( sent along with the request as metadata. Returns: - ~.language_service.AnalyzeSentimentResponse: + google.cloud.language_v1.types.AnalyzeSentimentResponse: The sentiment analysis response message. @@ -407,16 +424,17 @@ def analyze_entities( properties. Args: - request (:class:`~.language_service.AnalyzeEntitiesRequest`): + request (google.cloud.language_v1.types.AnalyzeEntitiesRequest): The request object. The entity analysis request message. - document (:class:`~.language_service.Document`): + document (google.cloud.language_v1.types.Document): Input document. This corresponds to the ``document`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - encoding_type (:class:`~.language_service.EncodingType`): + encoding_type (google.cloud.language_v1.types.EncodingType): The encoding type used by the API to calculate offsets. + This corresponds to the ``encoding_type`` field on the ``request`` instance; if ``request`` is provided, this should not be set. @@ -428,7 +446,7 @@ def analyze_entities( sent along with the request as metadata. Returns: - ~.language_service.AnalyzeEntitiesResponse: + google.cloud.language_v1.types.AnalyzeEntitiesResponse: The entity analysis response message. """ # Create or coerce a protobuf request object. @@ -482,17 +500,18 @@ def analyze_entity_sentiment( and its mentions. Args: - request (:class:`~.language_service.AnalyzeEntitySentimentRequest`): + request (google.cloud.language_v1.types.AnalyzeEntitySentimentRequest): The request object. The entity-level sentiment analysis request message. - document (:class:`~.language_service.Document`): + document (google.cloud.language_v1.types.Document): Input document. This corresponds to the ``document`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - encoding_type (:class:`~.language_service.EncodingType`): + encoding_type (google.cloud.language_v1.types.EncodingType): The encoding type used by the API to calculate offsets. + This corresponds to the ``encoding_type`` field on the ``request`` instance; if ``request`` is provided, this should not be set. @@ -504,7 +523,7 @@ def analyze_entity_sentiment( sent along with the request as metadata. Returns: - ~.language_service.AnalyzeEntitySentimentResponse: + google.cloud.language_v1.types.AnalyzeEntitySentimentResponse: The entity-level sentiment analysis response message. @@ -559,16 +578,17 @@ def analyze_syntax( tags, dependency trees, and other properties. Args: - request (:class:`~.language_service.AnalyzeSyntaxRequest`): + request (google.cloud.language_v1.types.AnalyzeSyntaxRequest): The request object. The syntax analysis request message. - document (:class:`~.language_service.Document`): + document (google.cloud.language_v1.types.Document): Input document. This corresponds to the ``document`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - encoding_type (:class:`~.language_service.EncodingType`): + encoding_type (google.cloud.language_v1.types.EncodingType): The encoding type used by the API to calculate offsets. + This corresponds to the ``encoding_type`` field on the ``request`` instance; if ``request`` is provided, this should not be set. @@ -580,7 +600,7 @@ def analyze_syntax( sent along with the request as metadata. Returns: - ~.language_service.AnalyzeSyntaxResponse: + google.cloud.language_v1.types.AnalyzeSyntaxResponse: The syntax analysis response message. """ # Create or coerce a protobuf request object. @@ -630,10 +650,10 @@ def classify_text( r"""Classifies a document into categories. Args: - request (:class:`~.language_service.ClassifyTextRequest`): + request (google.cloud.language_v1.types.ClassifyTextRequest): The request object. The document classification request message. - document (:class:`~.language_service.Document`): + document (google.cloud.language_v1.types.Document): Input document. This corresponds to the ``document`` field on the ``request`` instance; if ``request`` is provided, this @@ -646,7 +666,7 @@ def classify_text( sent along with the request as metadata. Returns: - ~.language_service.ClassifyTextResponse: + google.cloud.language_v1.types.ClassifyTextResponse: The document classification response message. @@ -700,23 +720,24 @@ def annotate_text( analyzeSyntax provide in one call. Args: - request (:class:`~.language_service.AnnotateTextRequest`): + request (google.cloud.language_v1.types.AnnotateTextRequest): The request object. The request message for the text annotation API, which can perform multiple analysis types (sentiment, entities, and syntax) in one call. - document (:class:`~.language_service.Document`): + document (google.cloud.language_v1.types.Document): Input document. This corresponds to the ``document`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - features (:class:`~.language_service.AnnotateTextRequest.Features`): + features (google.cloud.language_v1.types.AnnotateTextRequest.Features): The enabled features. This corresponds to the ``features`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - encoding_type (:class:`~.language_service.EncodingType`): + encoding_type (google.cloud.language_v1.types.EncodingType): The encoding type used by the API to calculate offsets. + This corresponds to the ``encoding_type`` field on the ``request`` instance; if ``request`` is provided, this should not be set. @@ -728,7 +749,7 @@ def annotate_text( sent along with the request as metadata. Returns: - ~.language_service.AnnotateTextResponse: + google.cloud.language_v1.types.AnnotateTextResponse: The text annotations response message. diff --git a/google/cloud/language_v1/types/language_service.py b/google/cloud/language_v1/types/language_service.py index 4fedc52d..10f0cb9e 100644 --- a/google/cloud/language_v1/types/language_service.py +++ b/google/cloud/language_v1/types/language_service.py @@ -65,7 +65,7 @@ class Document(proto.Message): r"""Represents the input to API methods. Attributes: - type_ (~.language_service.Document.Type): + type_ (google.cloud.language_v1.types.Document.Type): Required. If the type is not set or is ``TYPE_UNSPECIFIED``, returns an ``INVALID_ARGUMENT`` error. content (str): @@ -108,9 +108,9 @@ class Sentence(proto.Message): r"""Represents a sentence in the input document. Attributes: - text (~.language_service.TextSpan): + text (google.cloud.language_v1.types.TextSpan): The sentence text. - sentiment (~.language_service.Sentiment): + sentiment (google.cloud.language_v1.types.Sentiment): For calls to [AnalyzeSentiment][] or if [AnnotateTextRequest.Features.extract_document_sentiment][google.cloud.language.v1.AnnotateTextRequest.Features.extract_document_sentiment] is set to true, this field will contain the sentiment for @@ -130,9 +130,9 @@ class Entity(proto.Message): Attributes: name (str): The representative name for the entity. - type_ (~.language_service.Entity.Type): + type_ (google.cloud.language_v1.types.Entity.Type): The entity type. - metadata (Sequence[~.language_service.Entity.MetadataEntry]): + metadata (Sequence[google.cloud.language_v1.types.Entity.MetadataEntry]): Metadata associated with the entity. For most entity types, the metadata is a Wikipedia URL @@ -147,11 +147,11 @@ class Entity(proto.Message): the importance or centrality of that entity to the entire document text. Scores closer to 0 are less salient, while scores closer to 1.0 are highly salient. - mentions (Sequence[~.language_service.EntityMention]): + mentions (Sequence[google.cloud.language_v1.types.EntityMention]): The mentions of this entity in the input document. The API currently supports proper noun mentions. - sentiment (~.language_service.Sentiment): + sentiment (google.cloud.language_v1.types.Sentiment): For calls to [AnalyzeEntitySentiment][] or if [AnnotateTextRequest.Features.extract_entity_sentiment][google.cloud.language.v1.AnnotateTextRequest.Features.extract_entity_sentiment] is set to true, this field will contain the aggregate @@ -196,11 +196,11 @@ class Token(proto.Message): r"""Represents the smallest syntactic building block of the text. Attributes: - text (~.language_service.TextSpan): + text (google.cloud.language_v1.types.TextSpan): The token text. - part_of_speech (~.language_service.PartOfSpeech): + part_of_speech (google.cloud.language_v1.types.PartOfSpeech): Parts of speech tag for this token. - dependency_edge (~.language_service.DependencyEdge): + dependency_edge (google.cloud.language_v1.types.DependencyEdge): Dependency tree parse for this token. lemma (str): `Lemma `__ @@ -241,29 +241,29 @@ class PartOfSpeech(proto.Message): http://www.lrec-conf.org/proceedings/lrec2012/pdf/274_Paper.pdf Attributes: - tag (~.language_service.PartOfSpeech.Tag): + tag (google.cloud.language_v1.types.PartOfSpeech.Tag): The part of speech tag. - aspect (~.language_service.PartOfSpeech.Aspect): + aspect (google.cloud.language_v1.types.PartOfSpeech.Aspect): The grammatical aspect. - case (~.language_service.PartOfSpeech.Case): + case (google.cloud.language_v1.types.PartOfSpeech.Case): The grammatical case. - form (~.language_service.PartOfSpeech.Form): + form (google.cloud.language_v1.types.PartOfSpeech.Form): The grammatical form. - gender (~.language_service.PartOfSpeech.Gender): + gender (google.cloud.language_v1.types.PartOfSpeech.Gender): The grammatical gender. - mood (~.language_service.PartOfSpeech.Mood): + mood (google.cloud.language_v1.types.PartOfSpeech.Mood): The grammatical mood. - number (~.language_service.PartOfSpeech.Number): + number (google.cloud.language_v1.types.PartOfSpeech.Number): The grammatical number. - person (~.language_service.PartOfSpeech.Person): + person (google.cloud.language_v1.types.PartOfSpeech.Person): The grammatical person. - proper (~.language_service.PartOfSpeech.Proper): + proper (google.cloud.language_v1.types.PartOfSpeech.Proper): The grammatical properness. - reciprocity (~.language_service.PartOfSpeech.Reciprocity): + reciprocity (google.cloud.language_v1.types.PartOfSpeech.Reciprocity): The grammatical reciprocity. - tense (~.language_service.PartOfSpeech.Tense): + tense (google.cloud.language_v1.types.PartOfSpeech.Tense): The grammatical tense. - voice (~.language_service.PartOfSpeech.Voice): + voice (google.cloud.language_v1.types.PartOfSpeech.Voice): The grammatical voice. """ @@ -442,7 +442,7 @@ class DependencyEdge(proto.Message): array of tokens returned by the API method. If this token is a root token, then the ``head_token_index`` is its own index. - label (~.language_service.DependencyEdge.Label): + label (google.cloud.language_v1.types.DependencyEdge.Label): The parse label for the token. """ @@ -542,11 +542,11 @@ class EntityMention(proto.Message): proper noun mentions are supported. Attributes: - text (~.language_service.TextSpan): + text (google.cloud.language_v1.types.TextSpan): The mention text. - type_ (~.language_service.EntityMention.Type): + type_ (google.cloud.language_v1.types.EntityMention.Type): The type of the entity mention. - sentiment (~.language_service.Sentiment): + sentiment (google.cloud.language_v1.types.Sentiment): For calls to [AnalyzeEntitySentiment][] or if [AnnotateTextRequest.Features.extract_entity_sentiment][google.cloud.language.v1.AnnotateTextRequest.Features.extract_entity_sentiment] is set to true, this field will contain the sentiment @@ -608,9 +608,9 @@ class AnalyzeSentimentRequest(proto.Message): r"""The sentiment analysis request message. Attributes: - document (~.language_service.Document): + document (google.cloud.language_v1.types.Document): Input document. - encoding_type (~.language_service.EncodingType): + encoding_type (google.cloud.language_v1.types.EncodingType): The encoding type used by the API to calculate sentence offsets. """ @@ -624,7 +624,7 @@ class AnalyzeSentimentResponse(proto.Message): r"""The sentiment analysis response message. Attributes: - document_sentiment (~.language_service.Sentiment): + document_sentiment (google.cloud.language_v1.types.Sentiment): The overall sentiment of the input document. language (str): The language of the text, which will be the same as the @@ -632,7 +632,7 @@ class AnalyzeSentimentResponse(proto.Message): automatically-detected language. See [Document.language][google.cloud.language.v1.Document.language] field for more details. - sentences (Sequence[~.language_service.Sentence]): + sentences (Sequence[google.cloud.language_v1.types.Sentence]): The sentiment for all the sentences in the document. """ @@ -648,9 +648,9 @@ class AnalyzeEntitySentimentRequest(proto.Message): r"""The entity-level sentiment analysis request message. Attributes: - document (~.language_service.Document): + document (google.cloud.language_v1.types.Document): Input document. - encoding_type (~.language_service.EncodingType): + encoding_type (google.cloud.language_v1.types.EncodingType): The encoding type used by the API to calculate offsets. """ @@ -664,7 +664,7 @@ class AnalyzeEntitySentimentResponse(proto.Message): r"""The entity-level sentiment analysis response message. Attributes: - entities (Sequence[~.language_service.Entity]): + entities (Sequence[google.cloud.language_v1.types.Entity]): The recognized entities in the input document with associated sentiments. language (str): @@ -684,9 +684,9 @@ class AnalyzeEntitiesRequest(proto.Message): r"""The entity analysis request message. Attributes: - document (~.language_service.Document): + document (google.cloud.language_v1.types.Document): Input document. - encoding_type (~.language_service.EncodingType): + encoding_type (google.cloud.language_v1.types.EncodingType): The encoding type used by the API to calculate offsets. """ @@ -700,7 +700,7 @@ class AnalyzeEntitiesResponse(proto.Message): r"""The entity analysis response message. Attributes: - entities (Sequence[~.language_service.Entity]): + entities (Sequence[google.cloud.language_v1.types.Entity]): The recognized entities in the input document. language (str): @@ -720,9 +720,9 @@ class AnalyzeSyntaxRequest(proto.Message): r"""The syntax analysis request message. Attributes: - document (~.language_service.Document): + document (google.cloud.language_v1.types.Document): Input document. - encoding_type (~.language_service.EncodingType): + encoding_type (google.cloud.language_v1.types.EncodingType): The encoding type used by the API to calculate offsets. """ @@ -736,9 +736,9 @@ class AnalyzeSyntaxResponse(proto.Message): r"""The syntax analysis response message. Attributes: - sentences (Sequence[~.language_service.Sentence]): + sentences (Sequence[google.cloud.language_v1.types.Sentence]): Sentences in the input document. - tokens (Sequence[~.language_service.Token]): + tokens (Sequence[google.cloud.language_v1.types.Token]): Tokens, along with their syntactic information, in the input document. language (str): @@ -760,7 +760,7 @@ class ClassifyTextRequest(proto.Message): r"""The document classification request message. Attributes: - document (~.language_service.Document): + document (google.cloud.language_v1.types.Document): Input document. """ @@ -771,7 +771,7 @@ class ClassifyTextResponse(proto.Message): r"""The document classification response message. Attributes: - categories (Sequence[~.language_service.ClassificationCategory]): + categories (Sequence[google.cloud.language_v1.types.ClassificationCategory]): Categories representing the input document. """ @@ -786,11 +786,11 @@ class AnnotateTextRequest(proto.Message): syntax) in one call. Attributes: - document (~.language_service.Document): + document (google.cloud.language_v1.types.Document): Input document. - features (~.language_service.AnnotateTextRequest.Features): + features (google.cloud.language_v1.types.AnnotateTextRequest.Features): The enabled features. - encoding_type (~.language_service.EncodingType): + encoding_type (google.cloud.language_v1.types.EncodingType): The encoding type used by the API to calculate offsets. """ @@ -835,19 +835,19 @@ class AnnotateTextResponse(proto.Message): r"""The text annotations response message. Attributes: - sentences (Sequence[~.language_service.Sentence]): + sentences (Sequence[google.cloud.language_v1.types.Sentence]): Sentences in the input document. Populated if the user enables [AnnotateTextRequest.Features.extract_syntax][google.cloud.language.v1.AnnotateTextRequest.Features.extract_syntax]. - tokens (Sequence[~.language_service.Token]): + tokens (Sequence[google.cloud.language_v1.types.Token]): Tokens, along with their syntactic information, in the input document. Populated if the user enables [AnnotateTextRequest.Features.extract_syntax][google.cloud.language.v1.AnnotateTextRequest.Features.extract_syntax]. - entities (Sequence[~.language_service.Entity]): + entities (Sequence[google.cloud.language_v1.types.Entity]): Entities, along with their semantic information, in the input document. Populated if the user enables [AnnotateTextRequest.Features.extract_entities][google.cloud.language.v1.AnnotateTextRequest.Features.extract_entities]. - document_sentiment (~.language_service.Sentiment): + document_sentiment (google.cloud.language_v1.types.Sentiment): The overall sentiment for the document. Populated if the user enables [AnnotateTextRequest.Features.extract_document_sentiment][google.cloud.language.v1.AnnotateTextRequest.Features.extract_document_sentiment]. @@ -857,7 +857,7 @@ class AnnotateTextResponse(proto.Message): automatically-detected language. See [Document.language][google.cloud.language.v1.Document.language] field for more details. - categories (Sequence[~.language_service.ClassificationCategory]): + categories (Sequence[google.cloud.language_v1.types.ClassificationCategory]): Categories identified in the input document. """ diff --git a/google/cloud/language_v1beta2/services/language_service/async_client.py b/google/cloud/language_v1beta2/services/language_service/async_client.py index dab4fba9..a1ab4d7d 100644 --- a/google/cloud/language_v1beta2/services/language_service/async_client.py +++ b/google/cloud/language_v1beta2/services/language_service/async_client.py @@ -74,6 +74,7 @@ class LanguageServiceAsyncClient: LanguageServiceClient.parse_common_location_path ) + from_service_account_info = LanguageServiceClient.from_service_account_info from_service_account_file = LanguageServiceClient.from_service_account_file from_service_account_json = from_service_account_file @@ -151,18 +152,19 @@ async def analyze_sentiment( r"""Analyzes the sentiment of the provided text. Args: - request (:class:`~.language_service.AnalyzeSentimentRequest`): + request (:class:`google.cloud.language_v1beta2.types.AnalyzeSentimentRequest`): The request object. The sentiment analysis request message. - document (:class:`~.language_service.Document`): + document (:class:`google.cloud.language_v1beta2.types.Document`): Required. Input document. This corresponds to the ``document`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - encoding_type (:class:`~.language_service.EncodingType`): + encoding_type (:class:`google.cloud.language_v1beta2.types.EncodingType`): The encoding type used by the API to calculate sentence offsets for the sentence sentiment. + This corresponds to the ``encoding_type`` field on the ``request`` instance; if ``request`` is provided, this should not be set. @@ -174,7 +176,7 @@ async def analyze_sentiment( sent along with the request as metadata. Returns: - ~.language_service.AnalyzeSentimentResponse: + google.cloud.language_v1beta2.types.AnalyzeSentimentResponse: The sentiment analysis response message. @@ -237,16 +239,17 @@ async def analyze_entities( properties. Args: - request (:class:`~.language_service.AnalyzeEntitiesRequest`): + request (:class:`google.cloud.language_v1beta2.types.AnalyzeEntitiesRequest`): The request object. The entity analysis request message. - document (:class:`~.language_service.Document`): + document (:class:`google.cloud.language_v1beta2.types.Document`): Required. Input document. This corresponds to the ``document`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - encoding_type (:class:`~.language_service.EncodingType`): + encoding_type (:class:`google.cloud.language_v1beta2.types.EncodingType`): The encoding type used by the API to calculate offsets. + This corresponds to the ``encoding_type`` field on the ``request`` instance; if ``request`` is provided, this should not be set. @@ -258,7 +261,7 @@ async def analyze_entities( sent along with the request as metadata. Returns: - ~.language_service.AnalyzeEntitiesResponse: + google.cloud.language_v1beta2.types.AnalyzeEntitiesResponse: The entity analysis response message. """ # Create or coerce a protobuf request object. @@ -319,17 +322,18 @@ async def analyze_entity_sentiment( and its mentions. Args: - request (:class:`~.language_service.AnalyzeEntitySentimentRequest`): + request (:class:`google.cloud.language_v1beta2.types.AnalyzeEntitySentimentRequest`): The request object. The entity-level sentiment analysis request message. - document (:class:`~.language_service.Document`): + document (:class:`google.cloud.language_v1beta2.types.Document`): Required. Input document. This corresponds to the ``document`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - encoding_type (:class:`~.language_service.EncodingType`): + encoding_type (:class:`google.cloud.language_v1beta2.types.EncodingType`): The encoding type used by the API to calculate offsets. + This corresponds to the ``encoding_type`` field on the ``request`` instance; if ``request`` is provided, this should not be set. @@ -341,7 +345,7 @@ async def analyze_entity_sentiment( sent along with the request as metadata. Returns: - ~.language_service.AnalyzeEntitySentimentResponse: + google.cloud.language_v1beta2.types.AnalyzeEntitySentimentResponse: The entity-level sentiment analysis response message. @@ -403,16 +407,17 @@ async def analyze_syntax( tags, dependency trees, and other properties. Args: - request (:class:`~.language_service.AnalyzeSyntaxRequest`): + request (:class:`google.cloud.language_v1beta2.types.AnalyzeSyntaxRequest`): The request object. The syntax analysis request message. - document (:class:`~.language_service.Document`): + document (:class:`google.cloud.language_v1beta2.types.Document`): Required. Input document. This corresponds to the ``document`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - encoding_type (:class:`~.language_service.EncodingType`): + encoding_type (:class:`google.cloud.language_v1beta2.types.EncodingType`): The encoding type used by the API to calculate offsets. + This corresponds to the ``encoding_type`` field on the ``request`` instance; if ``request`` is provided, this should not be set. @@ -424,7 +429,7 @@ async def analyze_syntax( sent along with the request as metadata. Returns: - ~.language_service.AnalyzeSyntaxResponse: + google.cloud.language_v1beta2.types.AnalyzeSyntaxResponse: The syntax analysis response message. """ # Create or coerce a protobuf request object. @@ -481,10 +486,10 @@ async def classify_text( r"""Classifies a document into categories. Args: - request (:class:`~.language_service.ClassifyTextRequest`): + request (:class:`google.cloud.language_v1beta2.types.ClassifyTextRequest`): The request object. The document classification request message. - document (:class:`~.language_service.Document`): + document (:class:`google.cloud.language_v1beta2.types.Document`): Required. Input document. This corresponds to the ``document`` field on the ``request`` instance; if ``request`` is provided, this @@ -497,7 +502,7 @@ async def classify_text( sent along with the request as metadata. Returns: - ~.language_service.ClassifyTextResponse: + google.cloud.language_v1beta2.types.ClassifyTextResponse: The document classification response message. @@ -558,23 +563,24 @@ async def annotate_text( call. Args: - request (:class:`~.language_service.AnnotateTextRequest`): + request (:class:`google.cloud.language_v1beta2.types.AnnotateTextRequest`): The request object. The request message for the text annotation API, which can perform multiple analysis types (sentiment, entities, and syntax) in one call. - document (:class:`~.language_service.Document`): + document (:class:`google.cloud.language_v1beta2.types.Document`): Required. Input document. This corresponds to the ``document`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - features (:class:`~.language_service.AnnotateTextRequest.Features`): + features (:class:`google.cloud.language_v1beta2.types.AnnotateTextRequest.Features`): Required. The enabled features. This corresponds to the ``features`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - encoding_type (:class:`~.language_service.EncodingType`): + encoding_type (:class:`google.cloud.language_v1beta2.types.EncodingType`): The encoding type used by the API to calculate offsets. + This corresponds to the ``encoding_type`` field on the ``request`` instance; if ``request`` is provided, this should not be set. @@ -586,7 +592,7 @@ async def annotate_text( sent along with the request as metadata. Returns: - ~.language_service.AnnotateTextResponse: + google.cloud.language_v1beta2.types.AnnotateTextResponse: The text annotations response message. diff --git a/google/cloud/language_v1beta2/services/language_service/client.py b/google/cloud/language_v1beta2/services/language_service/client.py index b5346311..40c75c69 100644 --- a/google/cloud/language_v1beta2/services/language_service/client.py +++ b/google/cloud/language_v1beta2/services/language_service/client.py @@ -111,6 +111,22 @@ def _get_default_mtls_endpoint(api_endpoint): DEFAULT_ENDPOINT ) + @classmethod + def from_service_account_info(cls, info: dict, *args, **kwargs): + """Creates an instance of this client using the provided credentials info. + + Args: + info (dict): The service account private key info. + args: Additional arguments to pass to the constructor. + kwargs: Additional arguments to pass to the constructor. + + Returns: + LanguageServiceClient: The constructed client. + """ + credentials = service_account.Credentials.from_service_account_info(info) + kwargs["credentials"] = credentials + return cls(*args, **kwargs) + @classmethod def from_service_account_file(cls, filename: str, *args, **kwargs): """Creates an instance of this client using the provided credentials @@ -123,7 +139,7 @@ def from_service_account_file(cls, filename: str, *args, **kwargs): kwargs: Additional arguments to pass to the constructor. Returns: - {@api.name}: The constructed client. + LanguageServiceClient: The constructed client. """ credentials = service_account.Credentials.from_service_account_file(filename) kwargs["credentials"] = credentials @@ -215,10 +231,10 @@ def __init__( credentials identify the application to the service; if none are specified, the client will attempt to ascertain the credentials from the environment. - transport (Union[str, ~.LanguageServiceTransport]): The + transport (Union[str, LanguageServiceTransport]): The transport to use. If set to None, a transport is chosen automatically. - client_options (client_options_lib.ClientOptions): Custom options for the + client_options (google.api_core.client_options.ClientOptions): Custom options for the client. It won't take effect if a ``transport`` instance is provided. (1) The ``api_endpoint`` property can be used to override the default endpoint provided by the client. GOOGLE_API_USE_MTLS_ENDPOINT @@ -329,18 +345,19 @@ def analyze_sentiment( r"""Analyzes the sentiment of the provided text. Args: - request (:class:`~.language_service.AnalyzeSentimentRequest`): + request (google.cloud.language_v1beta2.types.AnalyzeSentimentRequest): The request object. The sentiment analysis request message. - document (:class:`~.language_service.Document`): + document (google.cloud.language_v1beta2.types.Document): Required. Input document. This corresponds to the ``document`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - encoding_type (:class:`~.language_service.EncodingType`): + encoding_type (google.cloud.language_v1beta2.types.EncodingType): The encoding type used by the API to calculate sentence offsets for the sentence sentiment. + This corresponds to the ``encoding_type`` field on the ``request`` instance; if ``request`` is provided, this should not be set. @@ -352,7 +369,7 @@ def analyze_sentiment( sent along with the request as metadata. Returns: - ~.language_service.AnalyzeSentimentResponse: + google.cloud.language_v1beta2.types.AnalyzeSentimentResponse: The sentiment analysis response message. @@ -408,16 +425,17 @@ def analyze_entities( properties. Args: - request (:class:`~.language_service.AnalyzeEntitiesRequest`): + request (google.cloud.language_v1beta2.types.AnalyzeEntitiesRequest): The request object. The entity analysis request message. - document (:class:`~.language_service.Document`): + document (google.cloud.language_v1beta2.types.Document): Required. Input document. This corresponds to the ``document`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - encoding_type (:class:`~.language_service.EncodingType`): + encoding_type (google.cloud.language_v1beta2.types.EncodingType): The encoding type used by the API to calculate offsets. + This corresponds to the ``encoding_type`` field on the ``request`` instance; if ``request`` is provided, this should not be set. @@ -429,7 +447,7 @@ def analyze_entities( sent along with the request as metadata. Returns: - ~.language_service.AnalyzeEntitiesResponse: + google.cloud.language_v1beta2.types.AnalyzeEntitiesResponse: The entity analysis response message. """ # Create or coerce a protobuf request object. @@ -483,17 +501,18 @@ def analyze_entity_sentiment( and its mentions. Args: - request (:class:`~.language_service.AnalyzeEntitySentimentRequest`): + request (google.cloud.language_v1beta2.types.AnalyzeEntitySentimentRequest): The request object. The entity-level sentiment analysis request message. - document (:class:`~.language_service.Document`): + document (google.cloud.language_v1beta2.types.Document): Required. Input document. This corresponds to the ``document`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - encoding_type (:class:`~.language_service.EncodingType`): + encoding_type (google.cloud.language_v1beta2.types.EncodingType): The encoding type used by the API to calculate offsets. + This corresponds to the ``encoding_type`` field on the ``request`` instance; if ``request`` is provided, this should not be set. @@ -505,7 +524,7 @@ def analyze_entity_sentiment( sent along with the request as metadata. Returns: - ~.language_service.AnalyzeEntitySentimentResponse: + google.cloud.language_v1beta2.types.AnalyzeEntitySentimentResponse: The entity-level sentiment analysis response message. @@ -560,16 +579,17 @@ def analyze_syntax( tags, dependency trees, and other properties. Args: - request (:class:`~.language_service.AnalyzeSyntaxRequest`): + request (google.cloud.language_v1beta2.types.AnalyzeSyntaxRequest): The request object. The syntax analysis request message. - document (:class:`~.language_service.Document`): + document (google.cloud.language_v1beta2.types.Document): Required. Input document. This corresponds to the ``document`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - encoding_type (:class:`~.language_service.EncodingType`): + encoding_type (google.cloud.language_v1beta2.types.EncodingType): The encoding type used by the API to calculate offsets. + This corresponds to the ``encoding_type`` field on the ``request`` instance; if ``request`` is provided, this should not be set. @@ -581,7 +601,7 @@ def analyze_syntax( sent along with the request as metadata. Returns: - ~.language_service.AnalyzeSyntaxResponse: + google.cloud.language_v1beta2.types.AnalyzeSyntaxResponse: The syntax analysis response message. """ # Create or coerce a protobuf request object. @@ -631,10 +651,10 @@ def classify_text( r"""Classifies a document into categories. Args: - request (:class:`~.language_service.ClassifyTextRequest`): + request (google.cloud.language_v1beta2.types.ClassifyTextRequest): The request object. The document classification request message. - document (:class:`~.language_service.Document`): + document (google.cloud.language_v1beta2.types.Document): Required. Input document. This corresponds to the ``document`` field on the ``request`` instance; if ``request`` is provided, this @@ -647,7 +667,7 @@ def classify_text( sent along with the request as metadata. Returns: - ~.language_service.ClassifyTextResponse: + google.cloud.language_v1beta2.types.ClassifyTextResponse: The document classification response message. @@ -701,23 +721,24 @@ def annotate_text( call. Args: - request (:class:`~.language_service.AnnotateTextRequest`): + request (google.cloud.language_v1beta2.types.AnnotateTextRequest): The request object. The request message for the text annotation API, which can perform multiple analysis types (sentiment, entities, and syntax) in one call. - document (:class:`~.language_service.Document`): + document (google.cloud.language_v1beta2.types.Document): Required. Input document. This corresponds to the ``document`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - features (:class:`~.language_service.AnnotateTextRequest.Features`): + features (google.cloud.language_v1beta2.types.AnnotateTextRequest.Features): Required. The enabled features. This corresponds to the ``features`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - encoding_type (:class:`~.language_service.EncodingType`): + encoding_type (google.cloud.language_v1beta2.types.EncodingType): The encoding type used by the API to calculate offsets. + This corresponds to the ``encoding_type`` field on the ``request`` instance; if ``request`` is provided, this should not be set. @@ -729,7 +750,7 @@ def annotate_text( sent along with the request as metadata. Returns: - ~.language_service.AnnotateTextResponse: + google.cloud.language_v1beta2.types.AnnotateTextResponse: The text annotations response message. diff --git a/google/cloud/language_v1beta2/types/language_service.py b/google/cloud/language_v1beta2/types/language_service.py index 567aca06..adc1113f 100644 --- a/google/cloud/language_v1beta2/types/language_service.py +++ b/google/cloud/language_v1beta2/types/language_service.py @@ -65,7 +65,7 @@ class Document(proto.Message): r"""Represents the input to API methods. Attributes: - type_ (~.language_service.Document.Type): + type_ (google.cloud.language_v1beta2.types.Document.Type): Required. If the type is not set or is ``TYPE_UNSPECIFIED``, returns an ``INVALID_ARGUMENT`` error. content (str): @@ -108,9 +108,9 @@ class Sentence(proto.Message): r"""Represents a sentence in the input document. Attributes: - text (~.language_service.TextSpan): + text (google.cloud.language_v1beta2.types.TextSpan): The sentence text. - sentiment (~.language_service.Sentiment): + sentiment (google.cloud.language_v1beta2.types.Sentiment): For calls to [AnalyzeSentiment][] or if [AnnotateTextRequest.Features.extract_document_sentiment][google.cloud.language.v1beta2.AnnotateTextRequest.Features.extract_document_sentiment] is set to true, this field will contain the sentiment for @@ -130,9 +130,9 @@ class Entity(proto.Message): Attributes: name (str): The representative name for the entity. - type_ (~.language_service.Entity.Type): + type_ (google.cloud.language_v1beta2.types.Entity.Type): The entity type. - metadata (Sequence[~.language_service.Entity.MetadataEntry]): + metadata (Sequence[google.cloud.language_v1beta2.types.Entity.MetadataEntry]): Metadata associated with the entity. For most entity types, the metadata is a Wikipedia URL @@ -147,11 +147,11 @@ class Entity(proto.Message): the importance or centrality of that entity to the entire document text. Scores closer to 0 are less salient, while scores closer to 1.0 are highly salient. - mentions (Sequence[~.language_service.EntityMention]): + mentions (Sequence[google.cloud.language_v1beta2.types.EntityMention]): The mentions of this entity in the input document. The API currently supports proper noun mentions. - sentiment (~.language_service.Sentiment): + sentiment (google.cloud.language_v1beta2.types.Sentiment): For calls to [AnalyzeEntitySentiment][] or if [AnnotateTextRequest.Features.extract_entity_sentiment][google.cloud.language.v1beta2.AnnotateTextRequest.Features.extract_entity_sentiment] is set to true, this field will contain the aggregate @@ -196,11 +196,11 @@ class Token(proto.Message): r"""Represents the smallest syntactic building block of the text. Attributes: - text (~.language_service.TextSpan): + text (google.cloud.language_v1beta2.types.TextSpan): The token text. - part_of_speech (~.language_service.PartOfSpeech): + part_of_speech (google.cloud.language_v1beta2.types.PartOfSpeech): Parts of speech tag for this token. - dependency_edge (~.language_service.DependencyEdge): + dependency_edge (google.cloud.language_v1beta2.types.DependencyEdge): Dependency tree parse for this token. lemma (str): `Lemma `__ @@ -240,29 +240,29 @@ class PartOfSpeech(proto.Message): r"""Represents part of speech information for a token. Attributes: - tag (~.language_service.PartOfSpeech.Tag): + tag (google.cloud.language_v1beta2.types.PartOfSpeech.Tag): The part of speech tag. - aspect (~.language_service.PartOfSpeech.Aspect): + aspect (google.cloud.language_v1beta2.types.PartOfSpeech.Aspect): The grammatical aspect. - case (~.language_service.PartOfSpeech.Case): + case (google.cloud.language_v1beta2.types.PartOfSpeech.Case): The grammatical case. - form (~.language_service.PartOfSpeech.Form): + form (google.cloud.language_v1beta2.types.PartOfSpeech.Form): The grammatical form. - gender (~.language_service.PartOfSpeech.Gender): + gender (google.cloud.language_v1beta2.types.PartOfSpeech.Gender): The grammatical gender. - mood (~.language_service.PartOfSpeech.Mood): + mood (google.cloud.language_v1beta2.types.PartOfSpeech.Mood): The grammatical mood. - number (~.language_service.PartOfSpeech.Number): + number (google.cloud.language_v1beta2.types.PartOfSpeech.Number): The grammatical number. - person (~.language_service.PartOfSpeech.Person): + person (google.cloud.language_v1beta2.types.PartOfSpeech.Person): The grammatical person. - proper (~.language_service.PartOfSpeech.Proper): + proper (google.cloud.language_v1beta2.types.PartOfSpeech.Proper): The grammatical properness. - reciprocity (~.language_service.PartOfSpeech.Reciprocity): + reciprocity (google.cloud.language_v1beta2.types.PartOfSpeech.Reciprocity): The grammatical reciprocity. - tense (~.language_service.PartOfSpeech.Tense): + tense (google.cloud.language_v1beta2.types.PartOfSpeech.Tense): The grammatical tense. - voice (~.language_service.PartOfSpeech.Voice): + voice (google.cloud.language_v1beta2.types.PartOfSpeech.Voice): The grammatical voice. """ @@ -439,7 +439,7 @@ class DependencyEdge(proto.Message): array of tokens returned by the API method. If this token is a root token, then the ``head_token_index`` is its own index. - label (~.language_service.DependencyEdge.Label): + label (google.cloud.language_v1beta2.types.DependencyEdge.Label): The parse label for the token. """ @@ -539,11 +539,11 @@ class EntityMention(proto.Message): proper noun mentions are supported. Attributes: - text (~.language_service.TextSpan): + text (google.cloud.language_v1beta2.types.TextSpan): The mention text. - type_ (~.language_service.EntityMention.Type): + type_ (google.cloud.language_v1beta2.types.EntityMention.Type): The type of the entity mention. - sentiment (~.language_service.Sentiment): + sentiment (google.cloud.language_v1beta2.types.Sentiment): For calls to [AnalyzeEntitySentiment][] or if [AnnotateTextRequest.Features.extract_entity_sentiment][google.cloud.language.v1beta2.AnnotateTextRequest.Features.extract_entity_sentiment] is set to true, this field will contain the sentiment @@ -605,9 +605,9 @@ class AnalyzeSentimentRequest(proto.Message): r"""The sentiment analysis request message. Attributes: - document (~.language_service.Document): + document (google.cloud.language_v1beta2.types.Document): Required. Input document. - encoding_type (~.language_service.EncodingType): + encoding_type (google.cloud.language_v1beta2.types.EncodingType): The encoding type used by the API to calculate sentence offsets for the sentence sentiment. @@ -622,7 +622,7 @@ class AnalyzeSentimentResponse(proto.Message): r"""The sentiment analysis response message. Attributes: - document_sentiment (~.language_service.Sentiment): + document_sentiment (google.cloud.language_v1beta2.types.Sentiment): The overall sentiment of the input document. language (str): The language of the text, which will be the same as the @@ -630,7 +630,7 @@ class AnalyzeSentimentResponse(proto.Message): automatically-detected language. See [Document.language][google.cloud.language.v1beta2.Document.language] field for more details. - sentences (Sequence[~.language_service.Sentence]): + sentences (Sequence[google.cloud.language_v1beta2.types.Sentence]): The sentiment for all the sentences in the document. """ @@ -646,9 +646,9 @@ class AnalyzeEntitySentimentRequest(proto.Message): r"""The entity-level sentiment analysis request message. Attributes: - document (~.language_service.Document): + document (google.cloud.language_v1beta2.types.Document): Required. Input document. - encoding_type (~.language_service.EncodingType): + encoding_type (google.cloud.language_v1beta2.types.EncodingType): The encoding type used by the API to calculate offsets. """ @@ -662,7 +662,7 @@ class AnalyzeEntitySentimentResponse(proto.Message): r"""The entity-level sentiment analysis response message. Attributes: - entities (Sequence[~.language_service.Entity]): + entities (Sequence[google.cloud.language_v1beta2.types.Entity]): The recognized entities in the input document with associated sentiments. language (str): @@ -682,9 +682,9 @@ class AnalyzeEntitiesRequest(proto.Message): r"""The entity analysis request message. Attributes: - document (~.language_service.Document): + document (google.cloud.language_v1beta2.types.Document): Required. Input document. - encoding_type (~.language_service.EncodingType): + encoding_type (google.cloud.language_v1beta2.types.EncodingType): The encoding type used by the API to calculate offsets. """ @@ -698,7 +698,7 @@ class AnalyzeEntitiesResponse(proto.Message): r"""The entity analysis response message. Attributes: - entities (Sequence[~.language_service.Entity]): + entities (Sequence[google.cloud.language_v1beta2.types.Entity]): The recognized entities in the input document. language (str): @@ -718,9 +718,9 @@ class AnalyzeSyntaxRequest(proto.Message): r"""The syntax analysis request message. Attributes: - document (~.language_service.Document): + document (google.cloud.language_v1beta2.types.Document): Required. Input document. - encoding_type (~.language_service.EncodingType): + encoding_type (google.cloud.language_v1beta2.types.EncodingType): The encoding type used by the API to calculate offsets. """ @@ -734,9 +734,9 @@ class AnalyzeSyntaxResponse(proto.Message): r"""The syntax analysis response message. Attributes: - sentences (Sequence[~.language_service.Sentence]): + sentences (Sequence[google.cloud.language_v1beta2.types.Sentence]): Sentences in the input document. - tokens (Sequence[~.language_service.Token]): + tokens (Sequence[google.cloud.language_v1beta2.types.Token]): Tokens, along with their syntactic information, in the input document. language (str): @@ -758,7 +758,7 @@ class ClassifyTextRequest(proto.Message): r"""The document classification request message. Attributes: - document (~.language_service.Document): + document (google.cloud.language_v1beta2.types.Document): Required. Input document. """ @@ -769,7 +769,7 @@ class ClassifyTextResponse(proto.Message): r"""The document classification response message. Attributes: - categories (Sequence[~.language_service.ClassificationCategory]): + categories (Sequence[google.cloud.language_v1beta2.types.ClassificationCategory]): Categories representing the input document. """ @@ -784,11 +784,11 @@ class AnnotateTextRequest(proto.Message): syntax) in one call. Attributes: - document (~.language_service.Document): + document (google.cloud.language_v1beta2.types.Document): Required. Input document. - features (~.language_service.AnnotateTextRequest.Features): + features (google.cloud.language_v1beta2.types.AnnotateTextRequest.Features): Required. The enabled features. - encoding_type (~.language_service.EncodingType): + encoding_type (google.cloud.language_v1beta2.types.EncodingType): The encoding type used by the API to calculate offsets. """ @@ -836,19 +836,19 @@ class AnnotateTextResponse(proto.Message): r"""The text annotations response message. Attributes: - sentences (Sequence[~.language_service.Sentence]): + sentences (Sequence[google.cloud.language_v1beta2.types.Sentence]): Sentences in the input document. Populated if the user enables [AnnotateTextRequest.Features.extract_syntax][google.cloud.language.v1beta2.AnnotateTextRequest.Features.extract_syntax]. - tokens (Sequence[~.language_service.Token]): + tokens (Sequence[google.cloud.language_v1beta2.types.Token]): Tokens, along with their syntactic information, in the input document. Populated if the user enables [AnnotateTextRequest.Features.extract_syntax][google.cloud.language.v1beta2.AnnotateTextRequest.Features.extract_syntax]. - entities (Sequence[~.language_service.Entity]): + entities (Sequence[google.cloud.language_v1beta2.types.Entity]): Entities, along with their semantic information, in the input document. Populated if the user enables [AnnotateTextRequest.Features.extract_entities][google.cloud.language.v1beta2.AnnotateTextRequest.Features.extract_entities]. - document_sentiment (~.language_service.Sentiment): + document_sentiment (google.cloud.language_v1beta2.types.Sentiment): The overall sentiment for the document. Populated if the user enables [AnnotateTextRequest.Features.extract_document_sentiment][google.cloud.language.v1beta2.AnnotateTextRequest.Features.extract_document_sentiment]. @@ -858,7 +858,7 @@ class AnnotateTextResponse(proto.Message): automatically-detected language. See [Document.language][google.cloud.language.v1beta2.Document.language] field for more details. - categories (Sequence[~.language_service.ClassificationCategory]): + categories (Sequence[google.cloud.language_v1beta2.types.ClassificationCategory]): Categories identified in the input document. """ diff --git a/synth.metadata b/synth.metadata index a9f62bc7..98b94222 100644 --- a/synth.metadata +++ b/synth.metadata @@ -4,15 +4,15 @@ "git": { "name": ".", "remote": "https://github.com/googleapis/python-language.git", - "sha": "8dde55cdd0e956c333039c0b74e49a06dd6ad33b" + "sha": "3476c0f72529cbcbe61ea5c7e6a22291777bed7e" } }, { "git": { "name": "googleapis", "remote": "https://github.com/googleapis/googleapis.git", - "sha": "dd372aa22ded7a8ba6f0e03a80e06358a3fa0907", - "internalRef": "347055288" + "sha": "520682435235d9c503983a360a2090025aa47cd1", + "internalRef": "350246057" } }, { @@ -51,6 +51,7 @@ } ], "generatedFiles": [ + ".coveragerc", ".flake8", ".github/CONTRIBUTING.md", ".github/ISSUE_TEMPLATE/bug_report.md", @@ -102,8 +103,10 @@ "docs/_static/custom.css", "docs/_templates/layout.html", "docs/conf.py", + "docs/language_v1/language_service.rst", "docs/language_v1/services.rst", "docs/language_v1/types.rst", + "docs/language_v1beta2/language_service.rst", "docs/language_v1beta2/services.rst", "docs/language_v1beta2/types.rst", "docs/multiprocessing.rst", diff --git a/tests/unit/gapic/language_v1/test_language_service.py b/tests/unit/gapic/language_v1/test_language_service.py index 644c3250..d2c1fbff 100644 --- a/tests/unit/gapic/language_v1/test_language_service.py +++ b/tests/unit/gapic/language_v1/test_language_service.py @@ -85,8 +85,21 @@ def test__get_default_mtls_endpoint(): ) +def test_language_service_client_from_service_account_info(): + creds = credentials.AnonymousCredentials() + with mock.patch.object( + service_account.Credentials, "from_service_account_info" + ) as factory: + factory.return_value = creds + info = {"valid": True} + client = LanguageServiceClient.from_service_account_info(info) + assert client.transport._credentials == creds + + assert client.transport._host == "language.googleapis.com:443" + + @pytest.mark.parametrize( - "client_class", [LanguageServiceClient, LanguageServiceAsyncClient] + "client_class", [LanguageServiceClient, LanguageServiceAsyncClient,] ) def test_language_service_client_from_service_account_file(client_class): creds = credentials.AnonymousCredentials() @@ -105,7 +118,10 @@ def test_language_service_client_from_service_account_file(client_class): def test_language_service_client_get_transport_class(): transport = LanguageServiceClient.get_transport_class() - assert transport == transports.LanguageServiceGrpcTransport + available_transports = [ + transports.LanguageServiceGrpcTransport, + ] + assert transport in available_transports transport = LanguageServiceClient.get_transport_class("grpc") assert transport == transports.LanguageServiceGrpcTransport @@ -1667,7 +1683,7 @@ def test_language_service_host_with_port(): def test_language_service_grpc_transport_channel(): - channel = grpc.insecure_channel("http://localhost/") + channel = grpc.secure_channel("http://localhost/", grpc.local_channel_credentials()) # Check that channel is used if provided. transport = transports.LanguageServiceGrpcTransport( @@ -1679,7 +1695,7 @@ def test_language_service_grpc_transport_channel(): def test_language_service_grpc_asyncio_transport_channel(): - channel = aio.insecure_channel("http://localhost/") + channel = aio.secure_channel("http://localhost/", grpc.local_channel_credentials()) # Check that channel is used if provided. transport = transports.LanguageServiceGrpcAsyncIOTransport( @@ -1704,7 +1720,7 @@ def test_language_service_transport_channel_mtls_with_client_cert_source( "grpc.ssl_channel_credentials", autospec=True ) as grpc_ssl_channel_cred: with mock.patch.object( - transport_class, "create_channel", autospec=True + transport_class, "create_channel" ) as grpc_create_channel: mock_ssl_cred = mock.Mock() grpc_ssl_channel_cred.return_value = mock_ssl_cred @@ -1760,7 +1776,7 @@ def test_language_service_transport_channel_mtls_with_adc(transport_class): ssl_credentials=mock.PropertyMock(return_value=mock_ssl_cred), ): with mock.patch.object( - transport_class, "create_channel", autospec=True + transport_class, "create_channel" ) as grpc_create_channel: mock_grpc_channel = mock.Mock() grpc_create_channel.return_value = mock_grpc_channel diff --git a/tests/unit/gapic/language_v1beta2/test_language_service.py b/tests/unit/gapic/language_v1beta2/test_language_service.py index 2cf5a618..c25ca765 100644 --- a/tests/unit/gapic/language_v1beta2/test_language_service.py +++ b/tests/unit/gapic/language_v1beta2/test_language_service.py @@ -87,8 +87,21 @@ def test__get_default_mtls_endpoint(): ) +def test_language_service_client_from_service_account_info(): + creds = credentials.AnonymousCredentials() + with mock.patch.object( + service_account.Credentials, "from_service_account_info" + ) as factory: + factory.return_value = creds + info = {"valid": True} + client = LanguageServiceClient.from_service_account_info(info) + assert client.transport._credentials == creds + + assert client.transport._host == "language.googleapis.com:443" + + @pytest.mark.parametrize( - "client_class", [LanguageServiceClient, LanguageServiceAsyncClient] + "client_class", [LanguageServiceClient, LanguageServiceAsyncClient,] ) def test_language_service_client_from_service_account_file(client_class): creds = credentials.AnonymousCredentials() @@ -107,7 +120,10 @@ def test_language_service_client_from_service_account_file(client_class): def test_language_service_client_get_transport_class(): transport = LanguageServiceClient.get_transport_class() - assert transport == transports.LanguageServiceGrpcTransport + available_transports = [ + transports.LanguageServiceGrpcTransport, + ] + assert transport in available_transports transport = LanguageServiceClient.get_transport_class("grpc") assert transport == transports.LanguageServiceGrpcTransport @@ -1669,7 +1685,7 @@ def test_language_service_host_with_port(): def test_language_service_grpc_transport_channel(): - channel = grpc.insecure_channel("http://localhost/") + channel = grpc.secure_channel("http://localhost/", grpc.local_channel_credentials()) # Check that channel is used if provided. transport = transports.LanguageServiceGrpcTransport( @@ -1681,7 +1697,7 @@ def test_language_service_grpc_transport_channel(): def test_language_service_grpc_asyncio_transport_channel(): - channel = aio.insecure_channel("http://localhost/") + channel = aio.secure_channel("http://localhost/", grpc.local_channel_credentials()) # Check that channel is used if provided. transport = transports.LanguageServiceGrpcAsyncIOTransport( @@ -1706,7 +1722,7 @@ def test_language_service_transport_channel_mtls_with_client_cert_source( "grpc.ssl_channel_credentials", autospec=True ) as grpc_ssl_channel_cred: with mock.patch.object( - transport_class, "create_channel", autospec=True + transport_class, "create_channel" ) as grpc_create_channel: mock_ssl_cred = mock.Mock() grpc_ssl_channel_cred.return_value = mock_ssl_cred @@ -1762,7 +1778,7 @@ def test_language_service_transport_channel_mtls_with_adc(transport_class): ssl_credentials=mock.PropertyMock(return_value=mock_ssl_cred), ): with mock.patch.object( - transport_class, "create_channel", autospec=True + transport_class, "create_channel" ) as grpc_create_channel: mock_grpc_channel = mock.Mock() grpc_create_channel.return_value = mock_grpc_channel