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

chore: use gapic-generator-python 0.53.4 #429

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
58 changes: 30 additions & 28 deletions google/cloud/dialogflow_v2/services/agents/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.api_core import operation # type: ignore
from google.api_core import operation_async # type: ignore
from google.cloud.dialogflow_v2.services.agents import pagers
Expand Down Expand Up @@ -159,17 +161,17 @@ def __init__(

async def get_agent(
self,
request: agent.GetAgentRequest = None,
request: Union[agent.GetAgentRequest, dict] = None,
*,
parent: str = None,
retry: retries.Retry = gapic_v1.method.DEFAULT,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> agent.Agent:
r"""Retrieves the specified agent.

Args:
request (:class:`google.cloud.dialogflow_v2.types.GetAgentRequest`):
request (Union[google.cloud.dialogflow_v2.types.GetAgentRequest, dict]):
The request object. The request message for
[Agents.GetAgent][google.cloud.dialogflow.v2.Agents.GetAgent].
parent (:class:`str`):
Expand Down Expand Up @@ -239,10 +241,10 @@ async def get_agent(

async def set_agent(
self,
request: gcd_agent.SetAgentRequest = None,
request: Union[gcd_agent.SetAgentRequest, dict] = None,
*,
agent: gcd_agent.Agent = None,
retry: retries.Retry = gapic_v1.method.DEFAULT,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> gcd_agent.Agent:
Expand All @@ -253,7 +255,7 @@ async def set_agent(
documentation <https://cloud.google.com/dialogflow/es/docs/training>`__.

Args:
request (:class:`google.cloud.dialogflow_v2.types.SetAgentRequest`):
request (Union[google.cloud.dialogflow_v2.types.SetAgentRequest, dict]):
The request object. The request message for
[Agents.SetAgent][google.cloud.dialogflow.v2.Agents.SetAgent].
agent (:class:`google.cloud.dialogflow_v2.types.Agent`):
Expand Down Expand Up @@ -323,17 +325,17 @@ async def set_agent(

async def delete_agent(
self,
request: agent.DeleteAgentRequest = None,
request: Union[agent.DeleteAgentRequest, dict] = None,
*,
parent: str = None,
retry: retries.Retry = gapic_v1.method.DEFAULT,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> None:
r"""Deletes the specified agent.

Args:
request (:class:`google.cloud.dialogflow_v2.types.DeleteAgentRequest`):
request (Union[google.cloud.dialogflow_v2.types.DeleteAgentRequest, dict]):
The request object. The request message for
[Agents.DeleteAgent][google.cloud.dialogflow.v2.Agents.DeleteAgent].
parent (:class:`str`):
Expand Down Expand Up @@ -387,10 +389,10 @@ async def delete_agent(

async def search_agents(
self,
request: agent.SearchAgentsRequest = None,
request: Union[agent.SearchAgentsRequest, dict] = None,
*,
parent: str = None,
retry: retries.Retry = gapic_v1.method.DEFAULT,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> pagers.SearchAgentsAsyncPager:
Expand All @@ -403,7 +405,7 @@ async def search_agents(
Sub-Collections <https://cloud.google.com/apis/design/design_patterns#list_sub-collections>`__.

Args:
request (:class:`google.cloud.dialogflow_v2.types.SearchAgentsRequest`):
request (Union[google.cloud.dialogflow_v2.types.SearchAgentsRequest, dict]):
The request object. The request message for
[Agents.SearchAgents][google.cloud.dialogflow.v2.Agents.SearchAgents].
parent (:class:`str`):
Expand Down Expand Up @@ -473,10 +475,10 @@ async def search_agents(

async def train_agent(
self,
request: agent.TrainAgentRequest = None,
request: Union[agent.TrainAgentRequest, dict] = None,
*,
parent: str = None,
retry: retries.Retry = gapic_v1.method.DEFAULT,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> operation_async.AsyncOperation:
Expand All @@ -497,7 +499,7 @@ async def train_agent(
documentation <https://cloud.google.com/dialogflow/es/docs/training>`__.

Args:
request (:class:`google.cloud.dialogflow_v2.types.TrainAgentRequest`):
request (Union[google.cloud.dialogflow_v2.types.TrainAgentRequest, dict]):
The request object. The request message for
[Agents.TrainAgent][google.cloud.dialogflow.v2.Agents.TrainAgent].
parent (:class:`str`):
Expand Down Expand Up @@ -579,10 +581,10 @@ async def train_agent(

async def export_agent(
self,
request: agent.ExportAgentRequest = None,
request: Union[agent.ExportAgentRequest, dict] = None,
*,
parent: str = None,
retry: retries.Retry = gapic_v1.method.DEFAULT,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> operation_async.AsyncOperation:
Expand All @@ -599,7 +601,7 @@ async def export_agent(
[ExportAgentResponse][google.cloud.dialogflow.v2.ExportAgentResponse]

Args:
request (:class:`google.cloud.dialogflow_v2.types.ExportAgentRequest`):
request (Union[google.cloud.dialogflow_v2.types.ExportAgentRequest, dict]):
The request object. The request message for
[Agents.ExportAgent][google.cloud.dialogflow.v2.Agents.ExportAgent].
parent (:class:`str`):
Expand Down Expand Up @@ -672,9 +674,9 @@ async def export_agent(

async def import_agent(
self,
request: agent.ImportAgentRequest = None,
request: Union[agent.ImportAgentRequest, dict] = None,
*,
retry: retries.Retry = gapic_v1.method.DEFAULT,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> operation_async.AsyncOperation:
Expand Down Expand Up @@ -709,7 +711,7 @@ async def import_agent(
documentation <https://cloud.google.com/dialogflow/es/docs/training>`__.

Args:
request (:class:`google.cloud.dialogflow_v2.types.ImportAgentRequest`):
request (Union[google.cloud.dialogflow_v2.types.ImportAgentRequest, dict]):
The request object. The request message for
[Agents.ImportAgent][google.cloud.dialogflow.v2.Agents.ImportAgent].
retry (google.api_core.retry.Retry): Designation of what errors, if any,
Expand Down Expand Up @@ -770,9 +772,9 @@ async def import_agent(

async def restore_agent(
self,
request: agent.RestoreAgentRequest = None,
request: Union[agent.RestoreAgentRequest, dict] = None,
*,
retry: retries.Retry = gapic_v1.method.DEFAULT,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> operation_async.AsyncOperation:
Expand Down Expand Up @@ -805,7 +807,7 @@ async def restore_agent(
documentation <https://cloud.google.com/dialogflow/es/docs/training>`__.

Args:
request (:class:`google.cloud.dialogflow_v2.types.RestoreAgentRequest`):
request (Union[google.cloud.dialogflow_v2.types.RestoreAgentRequest, dict]):
The request object. The request message for
[Agents.RestoreAgent][google.cloud.dialogflow.v2.Agents.RestoreAgent].
retry (google.api_core.retry.Retry): Designation of what errors, if any,
Expand Down Expand Up @@ -866,9 +868,9 @@ async def restore_agent(

async def get_validation_result(
self,
request: agent.GetValidationResultRequest = None,
request: Union[agent.GetValidationResultRequest, dict] = None,
*,
retry: retries.Retry = gapic_v1.method.DEFAULT,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> validation_result.ValidationResult:
Expand All @@ -877,7 +879,7 @@ async def get_validation_result(
automatically when training is completed.

Args:
request (:class:`google.cloud.dialogflow_v2.types.GetValidationResultRequest`):
request (Union[google.cloud.dialogflow_v2.types.GetValidationResultRequest, dict]):
The request object. The request message for
[Agents.GetValidationResult][google.cloud.dialogflow.v2.Agents.GetValidationResult].
retry (google.api_core.retry.Retry): Designation of what errors, if any,
Expand Down
20 changes: 11 additions & 9 deletions google/cloud/dialogflow_v2/services/agents/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.api_core import operation # type: ignore
from google.api_core import operation_async # type: ignore
from google.cloud.dialogflow_v2.services.agents import pagers
Expand Down Expand Up @@ -351,7 +353,7 @@ def get_agent(
request: Union[agent.GetAgentRequest, dict] = None,
*,
parent: str = None,
retry: retries.Retry = gapic_v1.method.DEFAULT,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> agent.Agent:
Expand Down Expand Up @@ -431,7 +433,7 @@ def set_agent(
request: Union[gcd_agent.SetAgentRequest, dict] = None,
*,
agent: gcd_agent.Agent = None,
retry: retries.Retry = gapic_v1.method.DEFAULT,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> gcd_agent.Agent:
Expand Down Expand Up @@ -515,7 +517,7 @@ def delete_agent(
request: Union[agent.DeleteAgentRequest, dict] = None,
*,
parent: str = None,
retry: retries.Retry = gapic_v1.method.DEFAULT,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> None:
Expand Down Expand Up @@ -579,7 +581,7 @@ def search_agents(
request: Union[agent.SearchAgentsRequest, dict] = None,
*,
parent: str = None,
retry: retries.Retry = gapic_v1.method.DEFAULT,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> pagers.SearchAgentsPager:
Expand Down Expand Up @@ -665,7 +667,7 @@ def train_agent(
request: Union[agent.TrainAgentRequest, dict] = None,
*,
parent: str = None,
retry: retries.Retry = gapic_v1.method.DEFAULT,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> operation.Operation:
Expand Down Expand Up @@ -771,7 +773,7 @@ def export_agent(
request: Union[agent.ExportAgentRequest, dict] = None,
*,
parent: str = None,
retry: retries.Retry = gapic_v1.method.DEFAULT,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> operation.Operation:
Expand Down Expand Up @@ -863,7 +865,7 @@ def import_agent(
self,
request: Union[agent.ImportAgentRequest, dict] = None,
*,
retry: retries.Retry = gapic_v1.method.DEFAULT,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> operation.Operation:
Expand Down Expand Up @@ -962,7 +964,7 @@ def restore_agent(
self,
request: Union[agent.RestoreAgentRequest, dict] = None,
*,
retry: retries.Retry = gapic_v1.method.DEFAULT,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> operation.Operation:
Expand Down Expand Up @@ -1059,7 +1061,7 @@ def get_validation_result(
self,
request: Union[agent.GetValidationResultRequest, dict] = None,
*,
retry: retries.Retry = gapic_v1.method.DEFAULT,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> validation_result.ValidationResult:
Expand Down
37 changes: 2 additions & 35 deletions google/cloud/dialogflow_v2/services/agents/transports/base.py
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 @@ -42,15 +41,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 AgentsTransport(abc.ABC):
"""Abstract transport class for Agents."""
Expand Down Expand Up @@ -103,7 +93,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 @@ -136,29 +126,6 @@ def __init__(
# Save the credentials.
self._credentials = credentials

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

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

scopes_kwargs = {}

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

return scopes_kwargs

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

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def __init__(
self._grpc_channel = None
self._ssl_channel_credentials = ssl_channel_credentials
self._stubs: Dict[str, Callable] = {}
self._operations_client = None
self._operations_client: Optional[operations_v1.OperationsClient] = None

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

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

if api_mtls_endpoint:
warnings.warn("api_mtls_endpoint is deprecated", DeprecationWarning)
Expand Down
Loading