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

chore: use gapic-generator-python 0.53.4 #101

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.dataqna_v1alpha.types import auto_suggestion_service
from .transports.base import AutoSuggestionServiceTransport, DEFAULT_CLIENT_INFO
from .transports.grpc_asyncio import AutoSuggestionServiceGrpcAsyncIOTransport
Expand Down Expand Up @@ -234,17 +236,17 @@ def __init__(

async def suggest_queries(
self,
request: auto_suggestion_service.SuggestQueriesRequest = None,
request: Union[auto_suggestion_service.SuggestQueriesRequest, dict] = None,
*,
retry: retries.Retry = gapic_v1.method.DEFAULT,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> auto_suggestion_service.SuggestQueriesResponse:
r"""Gets a list of suggestions based on a prefix string.
AutoSuggestion tolerance should be less than 1 second.

Args:
request (:class:`google.cloud.dataqna_v1alpha.types.SuggestQueriesRequest`):
request (Union[google.cloud.dataqna_v1alpha.types.SuggestQueriesRequest, dict]):
The request object. Request for query suggestions.
retry (google.api_core.retry.Retry): Designation of what errors, if any,
should be retried.
Expand Down
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.dataqna_v1alpha.types import auto_suggestion_service
from .transports.base import AutoSuggestionServiceTransport, DEFAULT_CLIENT_INFO
from .transports.grpc import AutoSuggestionServiceGrpcTransport
Expand Down Expand Up @@ -407,7 +409,7 @@ def suggest_queries(
self,
request: Union[auto_suggestion_service.SuggestQueriesRequest, dict] = None,
*,
retry: retries.Retry = gapic_v1.method.DEFAULT,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> auto_suggestion_service.SuggestQueriesResponse:
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 AutoSuggestionServiceTransport(abc.ABC):
"""Abstract transport class for AutoSuggestionService."""
Expand Down Expand Up @@ -93,7 +83,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 @@ -126,29 +116,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
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.dataqna_v1alpha.types import question
from google.cloud.dataqna_v1alpha.types import question as gcd_question
from google.cloud.dataqna_v1alpha.types import question_service
Expand Down Expand Up @@ -190,17 +192,17 @@ def __init__(

async def get_question(
self,
request: question_service.GetQuestionRequest = None,
request: Union[question_service.GetQuestionRequest, dict] = None,
*,
name: str = None,
retry: retries.Retry = gapic_v1.method.DEFAULT,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> question.Question:
r"""Gets a previously created question.

Args:
request (:class:`google.cloud.dataqna_v1alpha.types.GetQuestionRequest`):
request (Union[google.cloud.dataqna_v1alpha.types.GetQuestionRequest, dict]):
The request object. A request to get a previously
created question.
name (:class:`str`):
Expand Down Expand Up @@ -264,18 +266,18 @@ async def get_question(

async def create_question(
self,
request: question_service.CreateQuestionRequest = None,
request: Union[question_service.CreateQuestionRequest, dict] = None,
*,
parent: str = None,
question: gcd_question.Question = None,
retry: retries.Retry = gapic_v1.method.DEFAULT,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> gcd_question.Question:
r"""Creates a question.

Args:
request (:class:`google.cloud.dataqna_v1alpha.types.CreateQuestionRequest`):
request (Union[google.cloud.dataqna_v1alpha.types.CreateQuestionRequest, dict]):
The request object. Request to create a question
resource.
parent (:class:`str`):
Expand Down Expand Up @@ -347,18 +349,18 @@ async def create_question(

async def execute_question(
self,
request: question_service.ExecuteQuestionRequest = None,
request: Union[question_service.ExecuteQuestionRequest, dict] = None,
*,
name: str = None,
interpretation_index: int = None,
retry: retries.Retry = gapic_v1.method.DEFAULT,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> question.Question:
r"""Executes an interpretation.

Args:
request (:class:`google.cloud.dataqna_v1alpha.types.ExecuteQuestionRequest`):
request (Union[google.cloud.dataqna_v1alpha.types.ExecuteQuestionRequest, dict]):
The request object. Request to execute an
interpretation.
name (:class:`str`):
Expand Down Expand Up @@ -431,17 +433,17 @@ async def execute_question(

async def get_user_feedback(
self,
request: question_service.GetUserFeedbackRequest = None,
request: Union[question_service.GetUserFeedbackRequest, dict] = None,
*,
name: str = None,
retry: retries.Retry = gapic_v1.method.DEFAULT,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> user_feedback.UserFeedback:
r"""Gets previously created user feedback.

Args:
request (:class:`google.cloud.dataqna_v1alpha.types.GetUserFeedbackRequest`):
request (Union[google.cloud.dataqna_v1alpha.types.GetUserFeedbackRequest, dict]):
The request object. Request to get user feedback.
name (:class:`str`):
Required. The unique identifier for the user feedback.
Expand Down Expand Up @@ -501,19 +503,19 @@ async def get_user_feedback(

async def update_user_feedback(
self,
request: question_service.UpdateUserFeedbackRequest = None,
request: Union[question_service.UpdateUserFeedbackRequest, dict] = None,
*,
user_feedback: gcd_user_feedback.UserFeedback = None,
update_mask: field_mask_pb2.FieldMask = None,
retry: retries.Retry = gapic_v1.method.DEFAULT,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> gcd_user_feedback.UserFeedback:
r"""Updates user feedback. This creates user feedback if
there was none before (upsert).

Args:
request (:class:`google.cloud.dataqna_v1alpha.types.UpdateUserFeedbackRequest`):
request (Union[google.cloud.dataqna_v1alpha.types.UpdateUserFeedbackRequest, dict]):
The request object. Request to updates user feedback.
user_feedback (:class:`google.cloud.dataqna_v1alpha.types.UserFeedback`):
Required. The user feedback to
Expand Down
12 changes: 7 additions & 5 deletions google/cloud/dataqna_v1alpha/services/question_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.dataqna_v1alpha.types import question
from google.cloud.dataqna_v1alpha.types import question as gcd_question
from google.cloud.dataqna_v1alpha.types import question_service
Expand Down Expand Up @@ -391,7 +393,7 @@ def get_question(
request: Union[question_service.GetQuestionRequest, dict] = None,
*,
name: str = None,
retry: retries.Retry = gapic_v1.method.DEFAULT,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> question.Question:
Expand Down Expand Up @@ -466,7 +468,7 @@ def create_question(
*,
parent: str = None,
question: gcd_question.Question = None,
retry: retries.Retry = gapic_v1.method.DEFAULT,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> gcd_question.Question:
Expand Down Expand Up @@ -549,7 +551,7 @@ def execute_question(
*,
name: str = None,
interpretation_index: int = None,
retry: retries.Retry = gapic_v1.method.DEFAULT,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> question.Question:
Expand Down Expand Up @@ -632,7 +634,7 @@ def get_user_feedback(
request: Union[question_service.GetUserFeedbackRequest, dict] = None,
*,
name: str = None,
retry: retries.Retry = gapic_v1.method.DEFAULT,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> user_feedback.UserFeedback:
Expand Down Expand Up @@ -703,7 +705,7 @@ def update_user_feedback(
*,
user_feedback: gcd_user_feedback.UserFeedback = None,
update_mask: field_mask_pb2.FieldMask = None,
retry: retries.Retry = gapic_v1.method.DEFAULT,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> gcd_user_feedback.UserFeedback:
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 @@ -39,15 +38,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 QuestionServiceTransport(abc.ABC):
"""Abstract transport class for QuestionService."""
Expand Down Expand Up @@ -97,7 +87,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 @@ -130,29 +120,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
3 changes: 1 addition & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,8 @@
# NOTE: Maintainers, please do not require google-api-core>=2.x.x
# Until this issue is closed
# https://github.com/googleapis/google-cloud-python/issues/10566
"google-api-core[grpc] >= 1.26.0, <3.0.0dev",
"google-api-core[grpc] >= 1.28.0, <3.0.0dev",
"proto-plus >= 1.10.0",
"packaging >= 14.3",
),
python_requires=">=3.6",
classifiers=[
Expand Down
6 changes: 1 addition & 5 deletions testing/constraints-3.6.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,5 @@
#
# e.g., if setup.py has "foo >= 1.14.0, < 2.0.0dev",
# Then this file should have foo==1.14.0
google-api-core==1.26.0
google-api-core==1.28.0
proto-plus==1.10.0
packaging==14.3
# TODO: remove once google-auth>=1.25.0 is required transitively
# through google-api-core>=1.28.0
google-auth==1.24.0
Loading