diff --git a/.github/.OwlBot.lock.yaml b/.github/.OwlBot.lock.yaml
index 4ef44149..e2b39f94 100644
--- a/.github/.OwlBot.lock.yaml
+++ b/.github/.OwlBot.lock.yaml
@@ -1,3 +1,3 @@
docker:
image: gcr.io/repo-automation-bots/owlbot-python:latest
- digest: sha256:c66ba3c8d7bc8566f47df841f98cd0097b28fff0b1864c86f5817f4c8c3e8600
\ No newline at end of file
+ digest: sha256:99d90d097e4a4710cc8658ee0b5b963f4426d0e424819787c3ac1405c9a26719
diff --git a/.kokoro/samples/python3.9/common.cfg b/.kokoro/samples/python3.9/common.cfg
new file mode 100644
index 00000000..ffaa4eed
--- /dev/null
+++ b/.kokoro/samples/python3.9/common.cfg
@@ -0,0 +1,40 @@
+# Format: //devtools/kokoro/config/proto/build.proto
+
+# Build logs will be here
+action {
+ define_artifacts {
+ regex: "**/*sponge_log.xml"
+ }
+}
+
+# Specify which tests to run
+env_vars: {
+ key: "RUN_TESTS_SESSION"
+ value: "py-3.9"
+}
+
+# Declare build specific Cloud project.
+env_vars: {
+ key: "BUILD_SPECIFIC_GCLOUD_PROJECT"
+ value: "python-docs-samples-tests-py39"
+}
+
+env_vars: {
+ key: "TRAMPOLINE_BUILD_FILE"
+ value: "github/python-dialogflow-cx/.kokoro/test-samples.sh"
+}
+
+# Configure the docker image for kokoro-trampoline.
+env_vars: {
+ key: "TRAMPOLINE_IMAGE"
+ value: "gcr.io/cloud-devrel-kokoro-resources/python-samples-testing-docker"
+}
+
+# Download secrets for samples
+gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/python-docs-samples"
+
+# Download trampoline resources.
+gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline"
+
+# Use the trampoline script to run in docker.
+build_file: "python-dialogflow-cx/.kokoro/trampoline.sh"
\ No newline at end of file
diff --git a/.kokoro/samples/python3.9/continuous.cfg b/.kokoro/samples/python3.9/continuous.cfg
new file mode 100644
index 00000000..a1c8d975
--- /dev/null
+++ b/.kokoro/samples/python3.9/continuous.cfg
@@ -0,0 +1,6 @@
+# Format: //devtools/kokoro/config/proto/build.proto
+
+env_vars: {
+ key: "INSTALL_LIBRARY_FROM_SOURCE"
+ value: "True"
+}
\ No newline at end of file
diff --git a/.kokoro/samples/python3.9/periodic-head.cfg b/.kokoro/samples/python3.9/periodic-head.cfg
new file mode 100644
index 00000000..f9cfcd33
--- /dev/null
+++ b/.kokoro/samples/python3.9/periodic-head.cfg
@@ -0,0 +1,11 @@
+# Format: //devtools/kokoro/config/proto/build.proto
+
+env_vars: {
+ key: "INSTALL_LIBRARY_FROM_SOURCE"
+ value: "True"
+}
+
+env_vars: {
+ key: "TRAMPOLINE_BUILD_FILE"
+ value: "github/python-pubsub/.kokoro/test-samples-against-head.sh"
+}
diff --git a/.kokoro/samples/python3.9/periodic.cfg b/.kokoro/samples/python3.9/periodic.cfg
new file mode 100644
index 00000000..50fec964
--- /dev/null
+++ b/.kokoro/samples/python3.9/periodic.cfg
@@ -0,0 +1,6 @@
+# Format: //devtools/kokoro/config/proto/build.proto
+
+env_vars: {
+ key: "INSTALL_LIBRARY_FROM_SOURCE"
+ value: "False"
+}
\ No newline at end of file
diff --git a/.kokoro/samples/python3.9/presubmit.cfg b/.kokoro/samples/python3.9/presubmit.cfg
new file mode 100644
index 00000000..a1c8d975
--- /dev/null
+++ b/.kokoro/samples/python3.9/presubmit.cfg
@@ -0,0 +1,6 @@
+# Format: //devtools/kokoro/config/proto/build.proto
+
+env_vars: {
+ key: "INSTALL_LIBRARY_FROM_SOURCE"
+ value: "True"
+}
\ No newline at end of file
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 4f00c7cf..62eb5a77 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -16,7 +16,7 @@
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
- rev: v3.4.0
+ rev: v4.0.1
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 22f74b25..bc81f48c 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,26 @@
# Changelog
+## [0.8.0](https://www.github.com/googleapis/python-dialogflow-cx/compare/v0.7.1...v0.8.0) (2021-06-30)
+
+
+### Features
+
+* add always_use_jwt_access ([3550fa7](https://www.github.com/googleapis/python-dialogflow-cx/commit/3550fa7fa5863a313bd9288a1f515557f8f9fdea))
+* add return_partial response to Fulfillment ([3550fa7](https://www.github.com/googleapis/python-dialogflow-cx/commit/3550fa7fa5863a313bd9288a1f515557f8f9fdea))
+* mark agent.default_language_code as required ([3550fa7](https://www.github.com/googleapis/python-dialogflow-cx/commit/3550fa7fa5863a313bd9288a1f515557f8f9fdea))
+
+
+### Bug Fixes
+
+* disable always_use_jwt_access ([#119](https://www.github.com/googleapis/python-dialogflow-cx/issues/119)) ([3550fa7](https://www.github.com/googleapis/python-dialogflow-cx/commit/3550fa7fa5863a313bd9288a1f515557f8f9fdea))
+
+
+### Documentation
+
+* add notes to train agent before sending queries ([3550fa7](https://www.github.com/googleapis/python-dialogflow-cx/commit/3550fa7fa5863a313bd9288a1f515557f8f9fdea))
+* added notes to train agent before sending queries ([#111](https://www.github.com/googleapis/python-dialogflow-cx/issues/111)) ([8a53800](https://www.github.com/googleapis/python-dialogflow-cx/commit/8a5380055dfa7d58f83be5ce0da310318b54fc51))
+* omit mention of Python 2.7 in 'CONTRIBUTING.rst' ([#1127](https://www.github.com/googleapis/python-dialogflow-cx/issues/1127)) ([#110](https://www.github.com/googleapis/python-dialogflow-cx/issues/110)) ([40974f5](https://www.github.com/googleapis/python-dialogflow-cx/commit/40974f56c27833ab23575426f75d0868e1a10d94)), closes [#1126](https://www.github.com/googleapis/python-dialogflow-cx/issues/1126)
+
### [0.7.1](https://www.github.com/googleapis/python-dialogflow-cx/compare/v0.7.0...v0.7.1) (2021-06-16)
diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst
index 4698a856..9dfa1143 100644
--- a/CONTRIBUTING.rst
+++ b/CONTRIBUTING.rst
@@ -68,15 +68,12 @@ Using ``nox``
We use `nox `__ to instrument our tests.
- To test your changes, run unit tests with ``nox``::
+ $ nox -s unit
- $ nox -s unit-2.7
- $ nox -s unit-3.8
- $ ...
+- To run a single unit test::
-- Args to pytest can be passed through the nox command separated by a `--`. For
- example, to run a single test::
+ $ nox -s unit-3.9 -- -k
- $ nox -s unit-3.8 -- -k
.. note::
@@ -143,8 +140,7 @@ Running System Tests
- To run system tests, you can execute::
# Run all system tests
- $ nox -s system-3.8
- $ nox -s system-2.7
+ $ nox -s system
# Run a single system test
$ nox -s system-3.8 -- -k
@@ -152,9 +148,8 @@ Running System Tests
.. note::
- System tests are only configured to run under Python 2.7 and
- Python 3.8. For expediency, we do not run them in older versions
- of Python 3.
+ System tests are only configured to run under Python 3.8.
+ For expediency, we do not run them in older versions of Python 3.
This alone will not run the tests. You'll need to change some local
auth settings and change some configuration in your project to
@@ -218,8 +213,8 @@ Supported versions can be found in our ``noxfile.py`` `config`_.
.. _config: https://github.com/googleapis/python-dialogflow-cx/blob/master/noxfile.py
-We also explicitly decided to support Python 3 beginning with version
-3.6. Reasons for this include:
+We also explicitly decided to support Python 3 beginning with version 3.6.
+Reasons for this include:
- Encouraging use of newest versions of Python 3
- Taking the lead of `prominent`_ open-source `projects`_
diff --git a/docs/conf.py b/docs/conf.py
index d0da2b10..50eedc3b 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -80,9 +80,9 @@
master_doc = "index"
# General information about the project.
-project = u"google-cloud-dialogflow-cx"
-copyright = u"2019, Google"
-author = u"Google APIs"
+project = "google-cloud-dialogflow-cx"
+copyright = "2019, Google"
+author = "Google APIs"
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
@@ -281,7 +281,7 @@
(
master_doc,
"google-cloud-dialogflow-cx.tex",
- u"google-cloud-dialogflow-cx Documentation",
+ "google-cloud-dialogflow-cx Documentation",
author,
"manual",
)
@@ -316,7 +316,7 @@
(
master_doc,
"google-cloud-dialogflow-cx",
- u"google-cloud-dialogflow-cx Documentation",
+ "google-cloud-dialogflow-cx Documentation",
[author],
1,
)
@@ -335,7 +335,7 @@
(
master_doc,
"google-cloud-dialogflow-cx",
- u"google-cloud-dialogflow-cx Documentation",
+ "google-cloud-dialogflow-cx Documentation",
author,
"google-cloud-dialogflow-cx",
"google-cloud-dialogflow-cx Library",
diff --git a/google/cloud/dialogflowcx_v3/services/agents/async_client.py b/google/cloud/dialogflowcx_v3/services/agents/async_client.py
index 60e08061..89a55c6b 100644
--- a/google/cloud/dialogflowcx_v3/services/agents/async_client.py
+++ b/google/cloud/dialogflowcx_v3/services/agents/async_client.py
@@ -352,6 +352,10 @@ async def create_agent(
) -> gcdc_agent.Agent:
r"""Creates an agent in the specified location.
+ Note: You should always train flows prior to sending them
+ queries. See the `training
+ documentation `__.
+
Args:
request (:class:`google.cloud.dialogflowcx_v3.types.CreateAgentRequest`):
The request object. The request message for
@@ -443,6 +447,10 @@ async def update_agent(
) -> gcdc_agent.Agent:
r"""Updates the specified agent.
+ Note: You should always train flows prior to sending them
+ queries. See the `training
+ documentation `__.
+
Args:
request (:class:`google.cloud.dialogflowcx_v3.types.UpdateAgentRequest`):
The request object. The request message for
@@ -659,9 +667,14 @@ async def restore_agent(
metadata: Sequence[Tuple[str, str]] = (),
) -> operation_async.AsyncOperation:
r"""Restores the specified agent from a binary file.
+
Replaces the current agent with a new one. Note that all
- existing resources in agent (e.g. intents, entity types,
- flows) will be removed.
+ existing resources in agent (e.g. intents, entity types, flows)
+ will be removed.
+
+ Note: You should always train flows prior to sending them
+ queries. See the `training
+ documentation `__.
Args:
request (:class:`google.cloud.dialogflowcx_v3.types.RestoreAgentRequest`):
diff --git a/google/cloud/dialogflowcx_v3/services/agents/client.py b/google/cloud/dialogflowcx_v3/services/agents/client.py
index 61cbe72c..516930ae 100644
--- a/google/cloud/dialogflowcx_v3/services/agents/client.py
+++ b/google/cloud/dialogflowcx_v3/services/agents/client.py
@@ -613,6 +613,10 @@ def create_agent(
) -> gcdc_agent.Agent:
r"""Creates an agent in the specified location.
+ Note: You should always train flows prior to sending them
+ queries. See the `training
+ documentation `__.
+
Args:
request (google.cloud.dialogflowcx_v3.types.CreateAgentRequest):
The request object. The request message for
@@ -704,6 +708,10 @@ def update_agent(
) -> gcdc_agent.Agent:
r"""Updates the specified agent.
+ Note: You should always train flows prior to sending them
+ queries. See the `training
+ documentation `__.
+
Args:
request (google.cloud.dialogflowcx_v3.types.UpdateAgentRequest):
The request object. The request message for
@@ -921,9 +929,14 @@ def restore_agent(
metadata: Sequence[Tuple[str, str]] = (),
) -> operation.Operation:
r"""Restores the specified agent from a binary file.
+
Replaces the current agent with a new one. Note that all
- existing resources in agent (e.g. intents, entity types,
- flows) will be removed.
+ existing resources in agent (e.g. intents, entity types, flows)
+ will be removed.
+
+ Note: You should always train flows prior to sending them
+ queries. See the `training
+ documentation `__.
Args:
request (google.cloud.dialogflowcx_v3.types.RestoreAgentRequest):
diff --git a/google/cloud/dialogflowcx_v3/services/agents/transports/base.py b/google/cloud/dialogflowcx_v3/services/agents/transports/base.py
index 8fafde41..ee150fc4 100644
--- a/google/cloud/dialogflowcx_v3/services/agents/transports/base.py
+++ b/google/cloud/dialogflowcx_v3/services/agents/transports/base.py
@@ -25,6 +25,7 @@
from google.api_core import retry as retries # type: ignore
from google.api_core import operations_v1 # type: ignore
from google.auth import credentials as ga_credentials # type: ignore
+from google.oauth2 import service_account # type: ignore
from google.cloud.dialogflowcx_v3.types import agent
from google.cloud.dialogflowcx_v3.types import agent as gcdc_agent
@@ -49,8 +50,6 @@
except pkg_resources.DistributionNotFound: # pragma: NO COVER
_GOOGLE_AUTH_VERSION = None
-_API_CORE_VERSION = google.api_core.__version__
-
class AgentsTransport(abc.ABC):
"""Abstract transport class for Agents."""
@@ -71,6 +70,7 @@ def __init__(
scopes: Optional[Sequence[str]] = None,
quota_project_id: Optional[str] = None,
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
+ always_use_jwt_access: Optional[bool] = False,
**kwargs,
) -> None:
"""Instantiate the transport.
@@ -94,6 +94,8 @@ def __init__(
API requests. If ``None``, then default info will be used.
Generally, you only need to set this if you're developing
your own client library.
+ always_use_jwt_access (Optional[bool]): Whether self signed JWT should
+ be used for service account credentials.
"""
# Save the hostname. Default to port 443 (HTTPS) if none is specified.
if ":" not in host:
@@ -103,7 +105,7 @@ def __init__(
scopes_kwargs = self._get_scopes_kwargs(self._host, scopes)
# Save the scopes.
- self._scopes = scopes or self.AUTH_SCOPES
+ self._scopes = scopes
# If no credentials are provided, then determine the appropriate
# defaults.
@@ -122,13 +124,20 @@ def __init__(
**scopes_kwargs, quota_project_id=quota_project_id
)
+ # If the credentials is service account credentials, then always try to use self signed JWT.
+ if (
+ always_use_jwt_access
+ and isinstance(credentials, service_account.Credentials)
+ and hasattr(service_account.Credentials, "with_always_use_jwt_access")
+ ):
+ credentials = credentials.with_always_use_jwt_access(True)
+
# Save the credentials.
self._credentials = credentials
- # TODO(busunkim): These two class methods are in the base transport
+ # 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-api-core
- # and google-auth are increased.
+ # 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
@@ -149,27 +158,6 @@ def _get_scopes_kwargs(
return scopes_kwargs
- # TODO: Remove this function once google-api-core >= 1.26.0 is required
- @classmethod
- def _get_self_signed_jwt_kwargs(
- cls, host: str, scopes: Optional[Sequence[str]]
- ) -> Dict[str, Union[Optional[Sequence[str]], str]]:
- """Returns kwargs to pass to grpc_helpers.create_channel depending on the google-api-core version"""
-
- self_signed_jwt_kwargs: Dict[str, Union[Optional[Sequence[str]], str]] = {}
-
- if _API_CORE_VERSION and (
- packaging.version.parse(_API_CORE_VERSION)
- >= packaging.version.parse("1.26.0")
- ):
- self_signed_jwt_kwargs["default_scopes"] = cls.AUTH_SCOPES
- self_signed_jwt_kwargs["scopes"] = scopes
- self_signed_jwt_kwargs["default_host"] = cls.DEFAULT_HOST
- else:
- self_signed_jwt_kwargs["scopes"] = scopes or cls.AUTH_SCOPES
-
- return self_signed_jwt_kwargs
-
def _prep_wrapped_messages(self, client_info):
# Precompute the wrapped methods.
self._wrapped_methods = {
diff --git a/google/cloud/dialogflowcx_v3/services/agents/transports/grpc.py b/google/cloud/dialogflowcx_v3/services/agents/transports/grpc.py
index 99a98b9e..242f5237 100644
--- a/google/cloud/dialogflowcx_v3/services/agents/transports/grpc.py
+++ b/google/cloud/dialogflowcx_v3/services/agents/transports/grpc.py
@@ -61,6 +61,7 @@ def __init__(
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
quota_project_id: Optional[str] = None,
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
+ always_use_jwt_access: Optional[bool] = False,
) -> None:
"""Instantiate the transport.
@@ -101,6 +102,8 @@ def __init__(
API requests. If ``None``, then default info will be used.
Generally, you only need to set this if you're developing
your own client library.
+ always_use_jwt_access (Optional[bool]): Whether self signed JWT should
+ be used for service account credentials.
Raises:
google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport
@@ -154,6 +157,7 @@ def __init__(
scopes=scopes,
quota_project_id=quota_project_id,
client_info=client_info,
+ always_use_jwt_access=always_use_jwt_access,
)
if not self._grpc_channel:
@@ -209,14 +213,14 @@ def create_channel(
and ``credentials_file`` are passed.
"""
- self_signed_jwt_kwargs = cls._get_self_signed_jwt_kwargs(host, scopes)
-
return grpc_helpers.create_channel(
host,
credentials=credentials,
credentials_file=credentials_file,
quota_project_id=quota_project_id,
- **self_signed_jwt_kwargs,
+ default_scopes=cls.AUTH_SCOPES,
+ scopes=scopes,
+ default_host=cls.DEFAULT_HOST,
**kwargs,
)
@@ -299,6 +303,10 @@ def create_agent(
Creates an agent in the specified location.
+ Note: You should always train flows prior to sending them
+ queries. See the `training
+ documentation `__.
+
Returns:
Callable[[~.CreateAgentRequest],
~.Agent]:
@@ -325,6 +333,10 @@ def update_agent(
Updates the specified agent.
+ Note: You should always train flows prior to sending them
+ queries. See the `training
+ documentation `__.
+
Returns:
Callable[[~.UpdateAgentRequest],
~.Agent]:
@@ -400,9 +412,14 @@ def restore_agent(
r"""Return a callable for the restore agent method over gRPC.
Restores the specified agent from a binary file.
+
Replaces the current agent with a new one. Note that all
- existing resources in agent (e.g. intents, entity types,
- flows) will be removed.
+ existing resources in agent (e.g. intents, entity types, flows)
+ will be removed.
+
+ Note: You should always train flows prior to sending them
+ queries. See the `training
+ documentation `__.
Returns:
Callable[[~.RestoreAgentRequest],
diff --git a/google/cloud/dialogflowcx_v3/services/agents/transports/grpc_asyncio.py b/google/cloud/dialogflowcx_v3/services/agents/transports/grpc_asyncio.py
index a7b09070..540efbec 100644
--- a/google/cloud/dialogflowcx_v3/services/agents/transports/grpc_asyncio.py
+++ b/google/cloud/dialogflowcx_v3/services/agents/transports/grpc_asyncio.py
@@ -82,14 +82,14 @@ def create_channel(
aio.Channel: A gRPC AsyncIO channel object.
"""
- self_signed_jwt_kwargs = cls._get_self_signed_jwt_kwargs(host, scopes)
-
return grpc_helpers_async.create_channel(
host,
credentials=credentials,
credentials_file=credentials_file,
quota_project_id=quota_project_id,
- **self_signed_jwt_kwargs,
+ default_scopes=cls.AUTH_SCOPES,
+ scopes=scopes,
+ default_host=cls.DEFAULT_HOST,
**kwargs,
)
@@ -107,6 +107,7 @@ def __init__(
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
quota_project_id=None,
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
+ always_use_jwt_access: Optional[bool] = False,
) -> None:
"""Instantiate the transport.
@@ -148,6 +149,8 @@ def __init__(
API requests. If ``None``, then default info will be used.
Generally, you only need to set this if you're developing
your own client library.
+ always_use_jwt_access (Optional[bool]): Whether self signed JWT should
+ be used for service account credentials.
Raises:
google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport
@@ -200,6 +203,7 @@ def __init__(
scopes=scopes,
quota_project_id=quota_project_id,
client_info=client_info,
+ always_use_jwt_access=always_use_jwt_access,
)
if not self._grpc_channel:
@@ -304,6 +308,10 @@ def create_agent(
Creates an agent in the specified location.
+ Note: You should always train flows prior to sending them
+ queries. See the `training
+ documentation `__.
+
Returns:
Callable[[~.CreateAgentRequest],
Awaitable[~.Agent]]:
@@ -330,6 +338,10 @@ def update_agent(
Updates the specified agent.
+ Note: You should always train flows prior to sending them
+ queries. See the `training
+ documentation `__.
+
Returns:
Callable[[~.UpdateAgentRequest],
Awaitable[~.Agent]]:
@@ -407,9 +419,14 @@ def restore_agent(
r"""Return a callable for the restore agent method over gRPC.
Restores the specified agent from a binary file.
+
Replaces the current agent with a new one. Note that all
- existing resources in agent (e.g. intents, entity types,
- flows) will be removed.
+ existing resources in agent (e.g. intents, entity types, flows)
+ will be removed.
+
+ Note: You should always train flows prior to sending them
+ queries. See the `training
+ documentation `__.
Returns:
Callable[[~.RestoreAgentRequest],
diff --git a/google/cloud/dialogflowcx_v3/services/entity_types/async_client.py b/google/cloud/dialogflowcx_v3/services/entity_types/async_client.py
index 8ee7d941..cb98ab7e 100644
--- a/google/cloud/dialogflowcx_v3/services/entity_types/async_client.py
+++ b/google/cloud/dialogflowcx_v3/services/entity_types/async_client.py
@@ -358,6 +358,10 @@ async def create_entity_type(
) -> gcdc_entity_type.EntityType:
r"""Creates an entity type in the specified agent.
+ Note: You should always train a flow prior to sending it
+ queries. See the `training
+ documentation `__.
+
Args:
request (:class:`google.cloud.dialogflowcx_v3.types.CreateEntityTypeRequest`):
The request object. The request message for
@@ -469,6 +473,10 @@ async def update_entity_type(
) -> gcdc_entity_type.EntityType:
r"""Updates the specified entity type.
+ Note: You should always train a flow prior to sending it
+ queries. See the `training
+ documentation `__.
+
Args:
request (:class:`google.cloud.dialogflowcx_v3.types.UpdateEntityTypeRequest`):
The request object. The request message for
@@ -581,6 +589,10 @@ async def delete_entity_type(
) -> None:
r"""Deletes the specified entity type.
+ Note: You should always train a flow prior to sending it
+ queries. See the `training
+ documentation `__.
+
Args:
request (:class:`google.cloud.dialogflowcx_v3.types.DeleteEntityTypeRequest`):
The request object. The request message for
diff --git a/google/cloud/dialogflowcx_v3/services/entity_types/client.py b/google/cloud/dialogflowcx_v3/services/entity_types/client.py
index 6f12cfb0..4d9e1ade 100644
--- a/google/cloud/dialogflowcx_v3/services/entity_types/client.py
+++ b/google/cloud/dialogflowcx_v3/services/entity_types/client.py
@@ -547,6 +547,10 @@ def create_entity_type(
) -> gcdc_entity_type.EntityType:
r"""Creates an entity type in the specified agent.
+ Note: You should always train a flow prior to sending it
+ queries. See the `training
+ documentation `__.
+
Args:
request (google.cloud.dialogflowcx_v3.types.CreateEntityTypeRequest):
The request object. The request message for
@@ -658,6 +662,10 @@ def update_entity_type(
) -> gcdc_entity_type.EntityType:
r"""Updates the specified entity type.
+ Note: You should always train a flow prior to sending it
+ queries. See the `training
+ documentation `__.
+
Args:
request (google.cloud.dialogflowcx_v3.types.UpdateEntityTypeRequest):
The request object. The request message for
@@ -770,6 +778,10 @@ def delete_entity_type(
) -> None:
r"""Deletes the specified entity type.
+ Note: You should always train a flow prior to sending it
+ queries. See the `training
+ documentation `__.
+
Args:
request (google.cloud.dialogflowcx_v3.types.DeleteEntityTypeRequest):
The request object. The request message for
diff --git a/google/cloud/dialogflowcx_v3/services/entity_types/transports/base.py b/google/cloud/dialogflowcx_v3/services/entity_types/transports/base.py
index edd3e613..fe44ea0f 100644
--- a/google/cloud/dialogflowcx_v3/services/entity_types/transports/base.py
+++ b/google/cloud/dialogflowcx_v3/services/entity_types/transports/base.py
@@ -24,6 +24,7 @@
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
from google.cloud.dialogflowcx_v3.types import entity_type
from google.cloud.dialogflowcx_v3.types import entity_type as gcdc_entity_type
@@ -47,8 +48,6 @@
except pkg_resources.DistributionNotFound: # pragma: NO COVER
_GOOGLE_AUTH_VERSION = None
-_API_CORE_VERSION = google.api_core.__version__
-
class EntityTypesTransport(abc.ABC):
"""Abstract transport class for EntityTypes."""
@@ -69,6 +68,7 @@ def __init__(
scopes: Optional[Sequence[str]] = None,
quota_project_id: Optional[str] = None,
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
+ always_use_jwt_access: Optional[bool] = False,
**kwargs,
) -> None:
"""Instantiate the transport.
@@ -92,6 +92,8 @@ def __init__(
API requests. If ``None``, then default info will be used.
Generally, you only need to set this if you're developing
your own client library.
+ always_use_jwt_access (Optional[bool]): Whether self signed JWT should
+ be used for service account credentials.
"""
# Save the hostname. Default to port 443 (HTTPS) if none is specified.
if ":" not in host:
@@ -101,7 +103,7 @@ def __init__(
scopes_kwargs = self._get_scopes_kwargs(self._host, scopes)
# Save the scopes.
- self._scopes = scopes or self.AUTH_SCOPES
+ self._scopes = scopes
# If no credentials are provided, then determine the appropriate
# defaults.
@@ -120,13 +122,20 @@ def __init__(
**scopes_kwargs, quota_project_id=quota_project_id
)
+ # If the credentials is service account credentials, then always try to use self signed JWT.
+ if (
+ always_use_jwt_access
+ and isinstance(credentials, service_account.Credentials)
+ and hasattr(service_account.Credentials, "with_always_use_jwt_access")
+ ):
+ credentials = credentials.with_always_use_jwt_access(True)
+
# Save the credentials.
self._credentials = credentials
- # TODO(busunkim): These two class methods are in the base transport
+ # 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-api-core
- # and google-auth are increased.
+ # 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
@@ -147,27 +156,6 @@ def _get_scopes_kwargs(
return scopes_kwargs
- # TODO: Remove this function once google-api-core >= 1.26.0 is required
- @classmethod
- def _get_self_signed_jwt_kwargs(
- cls, host: str, scopes: Optional[Sequence[str]]
- ) -> Dict[str, Union[Optional[Sequence[str]], str]]:
- """Returns kwargs to pass to grpc_helpers.create_channel depending on the google-api-core version"""
-
- self_signed_jwt_kwargs: Dict[str, Union[Optional[Sequence[str]], str]] = {}
-
- if _API_CORE_VERSION and (
- packaging.version.parse(_API_CORE_VERSION)
- >= packaging.version.parse("1.26.0")
- ):
- self_signed_jwt_kwargs["default_scopes"] = cls.AUTH_SCOPES
- self_signed_jwt_kwargs["scopes"] = scopes
- self_signed_jwt_kwargs["default_host"] = cls.DEFAULT_HOST
- else:
- self_signed_jwt_kwargs["scopes"] = scopes or cls.AUTH_SCOPES
-
- return self_signed_jwt_kwargs
-
def _prep_wrapped_messages(self, client_info):
# Precompute the wrapped methods.
self._wrapped_methods = {
diff --git a/google/cloud/dialogflowcx_v3/services/entity_types/transports/grpc.py b/google/cloud/dialogflowcx_v3/services/entity_types/transports/grpc.py
index f4fe8095..9ad26c81 100644
--- a/google/cloud/dialogflowcx_v3/services/entity_types/transports/grpc.py
+++ b/google/cloud/dialogflowcx_v3/services/entity_types/transports/grpc.py
@@ -60,6 +60,7 @@ def __init__(
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
quota_project_id: Optional[str] = None,
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
+ always_use_jwt_access: Optional[bool] = False,
) -> None:
"""Instantiate the transport.
@@ -100,6 +101,8 @@ def __init__(
API requests. If ``None``, then default info will be used.
Generally, you only need to set this if you're developing
your own client library.
+ always_use_jwt_access (Optional[bool]): Whether self signed JWT should
+ be used for service account credentials.
Raises:
google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport
@@ -152,6 +155,7 @@ def __init__(
scopes=scopes,
quota_project_id=quota_project_id,
client_info=client_info,
+ always_use_jwt_access=always_use_jwt_access,
)
if not self._grpc_channel:
@@ -207,14 +211,14 @@ def create_channel(
and ``credentials_file`` are passed.
"""
- self_signed_jwt_kwargs = cls._get_self_signed_jwt_kwargs(host, scopes)
-
return grpc_helpers.create_channel(
host,
credentials=credentials,
credentials_file=credentials_file,
quota_project_id=quota_project_id,
- **self_signed_jwt_kwargs,
+ default_scopes=cls.AUTH_SCOPES,
+ scopes=scopes,
+ default_host=cls.DEFAULT_HOST,
**kwargs,
)
@@ -289,6 +293,10 @@ def create_entity_type(
Creates an entity type in the specified agent.
+ Note: You should always train a flow prior to sending it
+ queries. See the `training
+ documentation `__.
+
Returns:
Callable[[~.CreateEntityTypeRequest],
~.EntityType]:
@@ -317,6 +325,10 @@ def update_entity_type(
Updates the specified entity type.
+ Note: You should always train a flow prior to sending it
+ queries. See the `training
+ documentation `__.
+
Returns:
Callable[[~.UpdateEntityTypeRequest],
~.EntityType]:
@@ -343,6 +355,10 @@ def delete_entity_type(
Deletes the specified entity type.
+ Note: You should always train a flow prior to sending it
+ queries. See the `training
+ documentation `__.
+
Returns:
Callable[[~.DeleteEntityTypeRequest],
~.Empty]:
diff --git a/google/cloud/dialogflowcx_v3/services/entity_types/transports/grpc_asyncio.py b/google/cloud/dialogflowcx_v3/services/entity_types/transports/grpc_asyncio.py
index 38cec4de..167661be 100644
--- a/google/cloud/dialogflowcx_v3/services/entity_types/transports/grpc_asyncio.py
+++ b/google/cloud/dialogflowcx_v3/services/entity_types/transports/grpc_asyncio.py
@@ -81,14 +81,14 @@ def create_channel(
aio.Channel: A gRPC AsyncIO channel object.
"""
- self_signed_jwt_kwargs = cls._get_self_signed_jwt_kwargs(host, scopes)
-
return grpc_helpers_async.create_channel(
host,
credentials=credentials,
credentials_file=credentials_file,
quota_project_id=quota_project_id,
- **self_signed_jwt_kwargs,
+ default_scopes=cls.AUTH_SCOPES,
+ scopes=scopes,
+ default_host=cls.DEFAULT_HOST,
**kwargs,
)
@@ -106,6 +106,7 @@ def __init__(
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
quota_project_id=None,
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
+ always_use_jwt_access: Optional[bool] = False,
) -> None:
"""Instantiate the transport.
@@ -147,6 +148,8 @@ def __init__(
API requests. If ``None``, then default info will be used.
Generally, you only need to set this if you're developing
your own client library.
+ always_use_jwt_access (Optional[bool]): Whether self signed JWT should
+ be used for service account credentials.
Raises:
google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport
@@ -198,6 +201,7 @@ def __init__(
scopes=scopes,
quota_project_id=quota_project_id,
client_info=client_info,
+ always_use_jwt_access=always_use_jwt_access,
)
if not self._grpc_channel:
@@ -296,6 +300,10 @@ def create_entity_type(
Creates an entity type in the specified agent.
+ Note: You should always train a flow prior to sending it
+ queries. See the `training
+ documentation `__.
+
Returns:
Callable[[~.CreateEntityTypeRequest],
Awaitable[~.EntityType]]:
@@ -325,6 +333,10 @@ def update_entity_type(
Updates the specified entity type.
+ Note: You should always train a flow prior to sending it
+ queries. See the `training
+ documentation `__.
+
Returns:
Callable[[~.UpdateEntityTypeRequest],
Awaitable[~.EntityType]]:
@@ -351,6 +363,10 @@ def delete_entity_type(
Deletes the specified entity type.
+ Note: You should always train a flow prior to sending it
+ queries. See the `training
+ documentation `__.
+
Returns:
Callable[[~.DeleteEntityTypeRequest],
Awaitable[~.Empty]]:
diff --git a/google/cloud/dialogflowcx_v3/services/environments/transports/base.py b/google/cloud/dialogflowcx_v3/services/environments/transports/base.py
index e6683b3b..a065d0b1 100644
--- a/google/cloud/dialogflowcx_v3/services/environments/transports/base.py
+++ b/google/cloud/dialogflowcx_v3/services/environments/transports/base.py
@@ -25,6 +25,7 @@
from google.api_core import retry as retries # type: ignore
from google.api_core import operations_v1 # type: ignore
from google.auth import credentials as ga_credentials # type: ignore
+from google.oauth2 import service_account # type: ignore
from google.cloud.dialogflowcx_v3.types import environment
from google.cloud.dialogflowcx_v3.types import environment as gcdc_environment
@@ -49,8 +50,6 @@
except pkg_resources.DistributionNotFound: # pragma: NO COVER
_GOOGLE_AUTH_VERSION = None
-_API_CORE_VERSION = google.api_core.__version__
-
class EnvironmentsTransport(abc.ABC):
"""Abstract transport class for Environments."""
@@ -71,6 +70,7 @@ def __init__(
scopes: Optional[Sequence[str]] = None,
quota_project_id: Optional[str] = None,
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
+ always_use_jwt_access: Optional[bool] = False,
**kwargs,
) -> None:
"""Instantiate the transport.
@@ -94,6 +94,8 @@ def __init__(
API requests. If ``None``, then default info will be used.
Generally, you only need to set this if you're developing
your own client library.
+ always_use_jwt_access (Optional[bool]): Whether self signed JWT should
+ be used for service account credentials.
"""
# Save the hostname. Default to port 443 (HTTPS) if none is specified.
if ":" not in host:
@@ -103,7 +105,7 @@ def __init__(
scopes_kwargs = self._get_scopes_kwargs(self._host, scopes)
# Save the scopes.
- self._scopes = scopes or self.AUTH_SCOPES
+ self._scopes = scopes
# If no credentials are provided, then determine the appropriate
# defaults.
@@ -122,13 +124,20 @@ def __init__(
**scopes_kwargs, quota_project_id=quota_project_id
)
+ # If the credentials is service account credentials, then always try to use self signed JWT.
+ if (
+ always_use_jwt_access
+ and isinstance(credentials, service_account.Credentials)
+ and hasattr(service_account.Credentials, "with_always_use_jwt_access")
+ ):
+ credentials = credentials.with_always_use_jwt_access(True)
+
# Save the credentials.
self._credentials = credentials
- # TODO(busunkim): These two class methods are in the base transport
+ # 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-api-core
- # and google-auth are increased.
+ # 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
@@ -149,27 +158,6 @@ def _get_scopes_kwargs(
return scopes_kwargs
- # TODO: Remove this function once google-api-core >= 1.26.0 is required
- @classmethod
- def _get_self_signed_jwt_kwargs(
- cls, host: str, scopes: Optional[Sequence[str]]
- ) -> Dict[str, Union[Optional[Sequence[str]], str]]:
- """Returns kwargs to pass to grpc_helpers.create_channel depending on the google-api-core version"""
-
- self_signed_jwt_kwargs: Dict[str, Union[Optional[Sequence[str]], str]] = {}
-
- if _API_CORE_VERSION and (
- packaging.version.parse(_API_CORE_VERSION)
- >= packaging.version.parse("1.26.0")
- ):
- self_signed_jwt_kwargs["default_scopes"] = cls.AUTH_SCOPES
- self_signed_jwt_kwargs["scopes"] = scopes
- self_signed_jwt_kwargs["default_host"] = cls.DEFAULT_HOST
- else:
- self_signed_jwt_kwargs["scopes"] = scopes or cls.AUTH_SCOPES
-
- return self_signed_jwt_kwargs
-
def _prep_wrapped_messages(self, client_info):
# Precompute the wrapped methods.
self._wrapped_methods = {
diff --git a/google/cloud/dialogflowcx_v3/services/environments/transports/grpc.py b/google/cloud/dialogflowcx_v3/services/environments/transports/grpc.py
index 16fc53f2..1f2abf3d 100644
--- a/google/cloud/dialogflowcx_v3/services/environments/transports/grpc.py
+++ b/google/cloud/dialogflowcx_v3/services/environments/transports/grpc.py
@@ -62,6 +62,7 @@ def __init__(
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
quota_project_id: Optional[str] = None,
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
+ always_use_jwt_access: Optional[bool] = False,
) -> None:
"""Instantiate the transport.
@@ -102,6 +103,8 @@ def __init__(
API requests. If ``None``, then default info will be used.
Generally, you only need to set this if you're developing
your own client library.
+ always_use_jwt_access (Optional[bool]): Whether self signed JWT should
+ be used for service account credentials.
Raises:
google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport
@@ -155,6 +158,7 @@ def __init__(
scopes=scopes,
quota_project_id=quota_project_id,
client_info=client_info,
+ always_use_jwt_access=always_use_jwt_access,
)
if not self._grpc_channel:
@@ -210,14 +214,14 @@ def create_channel(
and ``credentials_file`` are passed.
"""
- self_signed_jwt_kwargs = cls._get_self_signed_jwt_kwargs(host, scopes)
-
return grpc_helpers.create_channel(
host,
credentials=credentials,
credentials_file=credentials_file,
quota_project_id=quota_project_id,
- **self_signed_jwt_kwargs,
+ default_scopes=cls.AUTH_SCOPES,
+ scopes=scopes,
+ default_host=cls.DEFAULT_HOST,
**kwargs,
)
diff --git a/google/cloud/dialogflowcx_v3/services/environments/transports/grpc_asyncio.py b/google/cloud/dialogflowcx_v3/services/environments/transports/grpc_asyncio.py
index 37b55d5b..79606cbf 100644
--- a/google/cloud/dialogflowcx_v3/services/environments/transports/grpc_asyncio.py
+++ b/google/cloud/dialogflowcx_v3/services/environments/transports/grpc_asyncio.py
@@ -83,14 +83,14 @@ def create_channel(
aio.Channel: A gRPC AsyncIO channel object.
"""
- self_signed_jwt_kwargs = cls._get_self_signed_jwt_kwargs(host, scopes)
-
return grpc_helpers_async.create_channel(
host,
credentials=credentials,
credentials_file=credentials_file,
quota_project_id=quota_project_id,
- **self_signed_jwt_kwargs,
+ default_scopes=cls.AUTH_SCOPES,
+ scopes=scopes,
+ default_host=cls.DEFAULT_HOST,
**kwargs,
)
@@ -108,6 +108,7 @@ def __init__(
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
quota_project_id=None,
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
+ always_use_jwt_access: Optional[bool] = False,
) -> None:
"""Instantiate the transport.
@@ -149,6 +150,8 @@ def __init__(
API requests. If ``None``, then default info will be used.
Generally, you only need to set this if you're developing
your own client library.
+ always_use_jwt_access (Optional[bool]): Whether self signed JWT should
+ be used for service account credentials.
Raises:
google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport
@@ -201,6 +204,7 @@ def __init__(
scopes=scopes,
quota_project_id=quota_project_id,
client_info=client_info,
+ always_use_jwt_access=always_use_jwt_access,
)
if not self._grpc_channel:
diff --git a/google/cloud/dialogflowcx_v3/services/experiments/transports/base.py b/google/cloud/dialogflowcx_v3/services/experiments/transports/base.py
index afba41e2..f783fa00 100644
--- a/google/cloud/dialogflowcx_v3/services/experiments/transports/base.py
+++ b/google/cloud/dialogflowcx_v3/services/experiments/transports/base.py
@@ -24,6 +24,7 @@
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
from google.cloud.dialogflowcx_v3.types import experiment
from google.cloud.dialogflowcx_v3.types import experiment as gcdc_experiment
@@ -47,8 +48,6 @@
except pkg_resources.DistributionNotFound: # pragma: NO COVER
_GOOGLE_AUTH_VERSION = None
-_API_CORE_VERSION = google.api_core.__version__
-
class ExperimentsTransport(abc.ABC):
"""Abstract transport class for Experiments."""
@@ -69,6 +68,7 @@ def __init__(
scopes: Optional[Sequence[str]] = None,
quota_project_id: Optional[str] = None,
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
+ always_use_jwt_access: Optional[bool] = False,
**kwargs,
) -> None:
"""Instantiate the transport.
@@ -92,6 +92,8 @@ def __init__(
API requests. If ``None``, then default info will be used.
Generally, you only need to set this if you're developing
your own client library.
+ always_use_jwt_access (Optional[bool]): Whether self signed JWT should
+ be used for service account credentials.
"""
# Save the hostname. Default to port 443 (HTTPS) if none is specified.
if ":" not in host:
@@ -101,7 +103,7 @@ def __init__(
scopes_kwargs = self._get_scopes_kwargs(self._host, scopes)
# Save the scopes.
- self._scopes = scopes or self.AUTH_SCOPES
+ self._scopes = scopes
# If no credentials are provided, then determine the appropriate
# defaults.
@@ -120,13 +122,20 @@ def __init__(
**scopes_kwargs, quota_project_id=quota_project_id
)
+ # If the credentials is service account credentials, then always try to use self signed JWT.
+ if (
+ always_use_jwt_access
+ and isinstance(credentials, service_account.Credentials)
+ and hasattr(service_account.Credentials, "with_always_use_jwt_access")
+ ):
+ credentials = credentials.with_always_use_jwt_access(True)
+
# Save the credentials.
self._credentials = credentials
- # TODO(busunkim): These two class methods are in the base transport
+ # 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-api-core
- # and google-auth are increased.
+ # 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
@@ -147,27 +156,6 @@ def _get_scopes_kwargs(
return scopes_kwargs
- # TODO: Remove this function once google-api-core >= 1.26.0 is required
- @classmethod
- def _get_self_signed_jwt_kwargs(
- cls, host: str, scopes: Optional[Sequence[str]]
- ) -> Dict[str, Union[Optional[Sequence[str]], str]]:
- """Returns kwargs to pass to grpc_helpers.create_channel depending on the google-api-core version"""
-
- self_signed_jwt_kwargs: Dict[str, Union[Optional[Sequence[str]], str]] = {}
-
- if _API_CORE_VERSION and (
- packaging.version.parse(_API_CORE_VERSION)
- >= packaging.version.parse("1.26.0")
- ):
- self_signed_jwt_kwargs["default_scopes"] = cls.AUTH_SCOPES
- self_signed_jwt_kwargs["scopes"] = scopes
- self_signed_jwt_kwargs["default_host"] = cls.DEFAULT_HOST
- else:
- self_signed_jwt_kwargs["scopes"] = scopes or cls.AUTH_SCOPES
-
- return self_signed_jwt_kwargs
-
def _prep_wrapped_messages(self, client_info):
# Precompute the wrapped methods.
self._wrapped_methods = {
diff --git a/google/cloud/dialogflowcx_v3/services/experiments/transports/grpc.py b/google/cloud/dialogflowcx_v3/services/experiments/transports/grpc.py
index f1deea19..81456f08 100644
--- a/google/cloud/dialogflowcx_v3/services/experiments/transports/grpc.py
+++ b/google/cloud/dialogflowcx_v3/services/experiments/transports/grpc.py
@@ -60,6 +60,7 @@ def __init__(
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
quota_project_id: Optional[str] = None,
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
+ always_use_jwt_access: Optional[bool] = False,
) -> None:
"""Instantiate the transport.
@@ -100,6 +101,8 @@ def __init__(
API requests. If ``None``, then default info will be used.
Generally, you only need to set this if you're developing
your own client library.
+ always_use_jwt_access (Optional[bool]): Whether self signed JWT should
+ be used for service account credentials.
Raises:
google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport
@@ -152,6 +155,7 @@ def __init__(
scopes=scopes,
quota_project_id=quota_project_id,
client_info=client_info,
+ always_use_jwt_access=always_use_jwt_access,
)
if not self._grpc_channel:
@@ -207,14 +211,14 @@ def create_channel(
and ``credentials_file`` are passed.
"""
- self_signed_jwt_kwargs = cls._get_self_signed_jwt_kwargs(host, scopes)
-
return grpc_helpers.create_channel(
host,
credentials=credentials,
credentials_file=credentials_file,
quota_project_id=quota_project_id,
- **self_signed_jwt_kwargs,
+ default_scopes=cls.AUTH_SCOPES,
+ scopes=scopes,
+ default_host=cls.DEFAULT_HOST,
**kwargs,
)
diff --git a/google/cloud/dialogflowcx_v3/services/experiments/transports/grpc_asyncio.py b/google/cloud/dialogflowcx_v3/services/experiments/transports/grpc_asyncio.py
index 2ce07e07..fd4a8100 100644
--- a/google/cloud/dialogflowcx_v3/services/experiments/transports/grpc_asyncio.py
+++ b/google/cloud/dialogflowcx_v3/services/experiments/transports/grpc_asyncio.py
@@ -81,14 +81,14 @@ def create_channel(
aio.Channel: A gRPC AsyncIO channel object.
"""
- self_signed_jwt_kwargs = cls._get_self_signed_jwt_kwargs(host, scopes)
-
return grpc_helpers_async.create_channel(
host,
credentials=credentials,
credentials_file=credentials_file,
quota_project_id=quota_project_id,
- **self_signed_jwt_kwargs,
+ default_scopes=cls.AUTH_SCOPES,
+ scopes=scopes,
+ default_host=cls.DEFAULT_HOST,
**kwargs,
)
@@ -106,6 +106,7 @@ def __init__(
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
quota_project_id=None,
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
+ always_use_jwt_access: Optional[bool] = False,
) -> None:
"""Instantiate the transport.
@@ -147,6 +148,8 @@ def __init__(
API requests. If ``None``, then default info will be used.
Generally, you only need to set this if you're developing
your own client library.
+ always_use_jwt_access (Optional[bool]): Whether self signed JWT should
+ be used for service account credentials.
Raises:
google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport
@@ -198,6 +201,7 @@ def __init__(
scopes=scopes,
quota_project_id=quota_project_id,
client_info=client_info,
+ always_use_jwt_access=always_use_jwt_access,
)
if not self._grpc_channel:
diff --git a/google/cloud/dialogflowcx_v3/services/flows/async_client.py b/google/cloud/dialogflowcx_v3/services/flows/async_client.py
index 6815a427..e32af9c8 100644
--- a/google/cloud/dialogflowcx_v3/services/flows/async_client.py
+++ b/google/cloud/dialogflowcx_v3/services/flows/async_client.py
@@ -186,6 +186,10 @@ async def create_flow(
) -> gcdc_flow.Flow:
r"""Creates a flow in the specified agent.
+ Note: You should always train a flow prior to sending it
+ queries. See the `training
+ documentation `__.
+
Args:
request (:class:`google.cloud.dialogflowcx_v3.types.CreateFlowRequest`):
The request object. The request message for
@@ -522,6 +526,10 @@ async def update_flow(
) -> gcdc_flow.Flow:
r"""Updates the specified flow.
+ Note: You should always train a flow prior to sending it
+ queries. See the `training
+ documentation `__.
+
Args:
request (:class:`google.cloud.dialogflowcx_v3.types.UpdateFlowRequest`):
The request object. The request message for
@@ -622,8 +630,12 @@ async def train_flow(
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> operation_async.AsyncOperation:
- r"""Trains the specified flow. Note that only the flow in
- 'draft' environment is trained.
+ r"""Trains the specified flow. Note that only the flow in 'draft'
+ environment is trained.
+
+ Note: You should always train a flow prior to sending it
+ queries. See the `training
+ documentation `__.
Args:
request (:class:`google.cloud.dialogflowcx_v3.types.TrainFlowRequest`):
@@ -838,8 +850,12 @@ async def import_flow(
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> operation_async.AsyncOperation:
- r"""Imports the specified flow to the specified agent
- from a binary file.
+ r"""Imports the specified flow to the specified agent from a binary
+ file.
+
+ Note: You should always train a flow prior to sending it
+ queries. See the `training
+ documentation `__.
Args:
request (:class:`google.cloud.dialogflowcx_v3.types.ImportFlowRequest`):
diff --git a/google/cloud/dialogflowcx_v3/services/flows/client.py b/google/cloud/dialogflowcx_v3/services/flows/client.py
index dd6bbebf..f07e9f7e 100644
--- a/google/cloud/dialogflowcx_v3/services/flows/client.py
+++ b/google/cloud/dialogflowcx_v3/services/flows/client.py
@@ -455,6 +455,10 @@ def create_flow(
) -> gcdc_flow.Flow:
r"""Creates a flow in the specified agent.
+ Note: You should always train a flow prior to sending it
+ queries. See the `training
+ documentation `__.
+
Args:
request (google.cloud.dialogflowcx_v3.types.CreateFlowRequest):
The request object. The request message for
@@ -791,6 +795,10 @@ def update_flow(
) -> gcdc_flow.Flow:
r"""Updates the specified flow.
+ Note: You should always train a flow prior to sending it
+ queries. See the `training
+ documentation `__.
+
Args:
request (google.cloud.dialogflowcx_v3.types.UpdateFlowRequest):
The request object. The request message for
@@ -891,8 +899,12 @@ def train_flow(
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> operation.Operation:
- r"""Trains the specified flow. Note that only the flow in
- 'draft' environment is trained.
+ r"""Trains the specified flow. Note that only the flow in 'draft'
+ environment is trained.
+
+ Note: You should always train a flow prior to sending it
+ queries. See the `training
+ documentation `__.
Args:
request (google.cloud.dialogflowcx_v3.types.TrainFlowRequest):
@@ -1110,8 +1122,12 @@ def import_flow(
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> operation.Operation:
- r"""Imports the specified flow to the specified agent
- from a binary file.
+ r"""Imports the specified flow to the specified agent from a binary
+ file.
+
+ Note: You should always train a flow prior to sending it
+ queries. See the `training
+ documentation `__.
Args:
request (google.cloud.dialogflowcx_v3.types.ImportFlowRequest):
diff --git a/google/cloud/dialogflowcx_v3/services/flows/transports/base.py b/google/cloud/dialogflowcx_v3/services/flows/transports/base.py
index 3999d848..dc4046ea 100644
--- a/google/cloud/dialogflowcx_v3/services/flows/transports/base.py
+++ b/google/cloud/dialogflowcx_v3/services/flows/transports/base.py
@@ -25,6 +25,7 @@
from google.api_core import retry as retries # type: ignore
from google.api_core import operations_v1 # type: ignore
from google.auth import credentials as ga_credentials # type: ignore
+from google.oauth2 import service_account # type: ignore
from google.cloud.dialogflowcx_v3.types import flow
from google.cloud.dialogflowcx_v3.types import flow as gcdc_flow
@@ -49,8 +50,6 @@
except pkg_resources.DistributionNotFound: # pragma: NO COVER
_GOOGLE_AUTH_VERSION = None
-_API_CORE_VERSION = google.api_core.__version__
-
class FlowsTransport(abc.ABC):
"""Abstract transport class for Flows."""
@@ -71,6 +70,7 @@ def __init__(
scopes: Optional[Sequence[str]] = None,
quota_project_id: Optional[str] = None,
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
+ always_use_jwt_access: Optional[bool] = False,
**kwargs,
) -> None:
"""Instantiate the transport.
@@ -94,6 +94,8 @@ def __init__(
API requests. If ``None``, then default info will be used.
Generally, you only need to set this if you're developing
your own client library.
+ always_use_jwt_access (Optional[bool]): Whether self signed JWT should
+ be used for service account credentials.
"""
# Save the hostname. Default to port 443 (HTTPS) if none is specified.
if ":" not in host:
@@ -103,7 +105,7 @@ def __init__(
scopes_kwargs = self._get_scopes_kwargs(self._host, scopes)
# Save the scopes.
- self._scopes = scopes or self.AUTH_SCOPES
+ self._scopes = scopes
# If no credentials are provided, then determine the appropriate
# defaults.
@@ -122,13 +124,20 @@ def __init__(
**scopes_kwargs, quota_project_id=quota_project_id
)
+ # If the credentials is service account credentials, then always try to use self signed JWT.
+ if (
+ always_use_jwt_access
+ and isinstance(credentials, service_account.Credentials)
+ and hasattr(service_account.Credentials, "with_always_use_jwt_access")
+ ):
+ credentials = credentials.with_always_use_jwt_access(True)
+
# Save the credentials.
self._credentials = credentials
- # TODO(busunkim): These two class methods are in the base transport
+ # 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-api-core
- # and google-auth are increased.
+ # 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
@@ -149,27 +158,6 @@ def _get_scopes_kwargs(
return scopes_kwargs
- # TODO: Remove this function once google-api-core >= 1.26.0 is required
- @classmethod
- def _get_self_signed_jwt_kwargs(
- cls, host: str, scopes: Optional[Sequence[str]]
- ) -> Dict[str, Union[Optional[Sequence[str]], str]]:
- """Returns kwargs to pass to grpc_helpers.create_channel depending on the google-api-core version"""
-
- self_signed_jwt_kwargs: Dict[str, Union[Optional[Sequence[str]], str]] = {}
-
- if _API_CORE_VERSION and (
- packaging.version.parse(_API_CORE_VERSION)
- >= packaging.version.parse("1.26.0")
- ):
- self_signed_jwt_kwargs["default_scopes"] = cls.AUTH_SCOPES
- self_signed_jwt_kwargs["scopes"] = scopes
- self_signed_jwt_kwargs["default_host"] = cls.DEFAULT_HOST
- else:
- self_signed_jwt_kwargs["scopes"] = scopes or cls.AUTH_SCOPES
-
- return self_signed_jwt_kwargs
-
def _prep_wrapped_messages(self, client_info):
# Precompute the wrapped methods.
self._wrapped_methods = {
diff --git a/google/cloud/dialogflowcx_v3/services/flows/transports/grpc.py b/google/cloud/dialogflowcx_v3/services/flows/transports/grpc.py
index 92016ca2..ca5c69e2 100644
--- a/google/cloud/dialogflowcx_v3/services/flows/transports/grpc.py
+++ b/google/cloud/dialogflowcx_v3/services/flows/transports/grpc.py
@@ -61,6 +61,7 @@ def __init__(
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
quota_project_id: Optional[str] = None,
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
+ always_use_jwt_access: Optional[bool] = False,
) -> None:
"""Instantiate the transport.
@@ -101,6 +102,8 @@ def __init__(
API requests. If ``None``, then default info will be used.
Generally, you only need to set this if you're developing
your own client library.
+ always_use_jwt_access (Optional[bool]): Whether self signed JWT should
+ be used for service account credentials.
Raises:
google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport
@@ -154,6 +157,7 @@ def __init__(
scopes=scopes,
quota_project_id=quota_project_id,
client_info=client_info,
+ always_use_jwt_access=always_use_jwt_access,
)
if not self._grpc_channel:
@@ -209,14 +213,14 @@ def create_channel(
and ``credentials_file`` are passed.
"""
- self_signed_jwt_kwargs = cls._get_self_signed_jwt_kwargs(host, scopes)
-
return grpc_helpers.create_channel(
host,
credentials=credentials,
credentials_file=credentials_file,
quota_project_id=quota_project_id,
- **self_signed_jwt_kwargs,
+ default_scopes=cls.AUTH_SCOPES,
+ scopes=scopes,
+ default_host=cls.DEFAULT_HOST,
**kwargs,
)
@@ -246,6 +250,10 @@ def create_flow(self) -> Callable[[gcdc_flow.CreateFlowRequest], gcdc_flow.Flow]
Creates a flow in the specified agent.
+ Note: You should always train a flow prior to sending it
+ queries. See the `training
+ documentation `__.
+
Returns:
Callable[[~.CreateFlowRequest],
~.Flow]:
@@ -342,6 +350,10 @@ def update_flow(self) -> Callable[[gcdc_flow.UpdateFlowRequest], gcdc_flow.Flow]
Updates the specified flow.
+ Note: You should always train a flow prior to sending it
+ queries. See the `training
+ documentation `__.
+
Returns:
Callable[[~.UpdateFlowRequest],
~.Flow]:
@@ -364,8 +376,12 @@ def update_flow(self) -> Callable[[gcdc_flow.UpdateFlowRequest], gcdc_flow.Flow]
def train_flow(self) -> Callable[[flow.TrainFlowRequest], operations_pb2.Operation]:
r"""Return a callable for the train flow method over gRPC.
- Trains the specified flow. Note that only the flow in
- 'draft' environment is trained.
+ Trains the specified flow. Note that only the flow in 'draft'
+ environment is trained.
+
+ Note: You should always train a flow prior to sending it
+ queries. See the `training
+ documentation `__.
Returns:
Callable[[~.TrainFlowRequest],
@@ -447,8 +463,12 @@ def import_flow(
) -> Callable[[flow.ImportFlowRequest], operations_pb2.Operation]:
r"""Return a callable for the import flow method over gRPC.
- Imports the specified flow to the specified agent
- from a binary file.
+ Imports the specified flow to the specified agent from a binary
+ file.
+
+ Note: You should always train a flow prior to sending it
+ queries. See the `training
+ documentation `__.
Returns:
Callable[[~.ImportFlowRequest],
diff --git a/google/cloud/dialogflowcx_v3/services/flows/transports/grpc_asyncio.py b/google/cloud/dialogflowcx_v3/services/flows/transports/grpc_asyncio.py
index 2a73cf2f..b502f59c 100644
--- a/google/cloud/dialogflowcx_v3/services/flows/transports/grpc_asyncio.py
+++ b/google/cloud/dialogflowcx_v3/services/flows/transports/grpc_asyncio.py
@@ -82,14 +82,14 @@ def create_channel(
aio.Channel: A gRPC AsyncIO channel object.
"""
- self_signed_jwt_kwargs = cls._get_self_signed_jwt_kwargs(host, scopes)
-
return grpc_helpers_async.create_channel(
host,
credentials=credentials,
credentials_file=credentials_file,
quota_project_id=quota_project_id,
- **self_signed_jwt_kwargs,
+ default_scopes=cls.AUTH_SCOPES,
+ scopes=scopes,
+ default_host=cls.DEFAULT_HOST,
**kwargs,
)
@@ -107,6 +107,7 @@ def __init__(
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
quota_project_id=None,
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
+ always_use_jwt_access: Optional[bool] = False,
) -> None:
"""Instantiate the transport.
@@ -148,6 +149,8 @@ def __init__(
API requests. If ``None``, then default info will be used.
Generally, you only need to set this if you're developing
your own client library.
+ always_use_jwt_access (Optional[bool]): Whether self signed JWT should
+ be used for service account credentials.
Raises:
google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport
@@ -200,6 +203,7 @@ def __init__(
scopes=scopes,
quota_project_id=quota_project_id,
client_info=client_info,
+ always_use_jwt_access=always_use_jwt_access,
)
if not self._grpc_channel:
@@ -253,6 +257,10 @@ def create_flow(
Creates a flow in the specified agent.
+ Note: You should always train a flow prior to sending it
+ queries. See the `training
+ documentation `__.
+
Returns:
Callable[[~.CreateFlowRequest],
Awaitable[~.Flow]]:
@@ -355,6 +363,10 @@ def update_flow(
Updates the specified flow.
+ Note: You should always train a flow prior to sending it
+ queries. See the `training
+ documentation `__.
+
Returns:
Callable[[~.UpdateFlowRequest],
Awaitable[~.Flow]]:
@@ -379,8 +391,12 @@ def train_flow(
) -> Callable[[flow.TrainFlowRequest], Awaitable[operations_pb2.Operation]]:
r"""Return a callable for the train flow method over gRPC.
- Trains the specified flow. Note that only the flow in
- 'draft' environment is trained.
+ Trains the specified flow. Note that only the flow in 'draft'
+ environment is trained.
+
+ Note: You should always train a flow prior to sending it
+ queries. See the `training
+ documentation `__.
Returns:
Callable[[~.TrainFlowRequest],
@@ -464,8 +480,12 @@ def import_flow(
) -> Callable[[flow.ImportFlowRequest], Awaitable[operations_pb2.Operation]]:
r"""Return a callable for the import flow method over gRPC.
- Imports the specified flow to the specified agent
- from a binary file.
+ Imports the specified flow to the specified agent from a binary
+ file.
+
+ Note: You should always train a flow prior to sending it
+ queries. See the `training
+ documentation `__.
Returns:
Callable[[~.ImportFlowRequest],
diff --git a/google/cloud/dialogflowcx_v3/services/intents/async_client.py b/google/cloud/dialogflowcx_v3/services/intents/async_client.py
index bdf87330..bc47f4ac 100644
--- a/google/cloud/dialogflowcx_v3/services/intents/async_client.py
+++ b/google/cloud/dialogflowcx_v3/services/intents/async_client.py
@@ -328,6 +328,10 @@ async def create_intent(
) -> gcdc_intent.Intent:
r"""Creates an intent in the specified agent.
+ Note: You should always train a flow prior to sending it
+ queries. See the `training
+ documentation `__.
+
Args:
request (:class:`google.cloud.dialogflowcx_v3.types.CreateIntentRequest`):
The request object. The request message for
@@ -412,6 +416,10 @@ async def update_intent(
) -> gcdc_intent.Intent:
r"""Updates the specified intent.
+ Note: You should always train a flow prior to sending it
+ queries. See the `training
+ documentation `__.
+
Args:
request (:class:`google.cloud.dialogflowcx_v3.types.UpdateIntentRequest`):
The request object. The request message for
@@ -498,6 +506,10 @@ async def delete_intent(
) -> None:
r"""Deletes the specified intent.
+ Note: You should always train a flow prior to sending it
+ queries. See the `training
+ documentation `__.
+
Args:
request (:class:`google.cloud.dialogflowcx_v3.types.DeleteIntentRequest`):
The request object. The request message for
diff --git a/google/cloud/dialogflowcx_v3/services/intents/client.py b/google/cloud/dialogflowcx_v3/services/intents/client.py
index c4a2fd9d..705dc5eb 100644
--- a/google/cloud/dialogflowcx_v3/services/intents/client.py
+++ b/google/cloud/dialogflowcx_v3/services/intents/client.py
@@ -535,6 +535,10 @@ def create_intent(
) -> gcdc_intent.Intent:
r"""Creates an intent in the specified agent.
+ Note: You should always train a flow prior to sending it
+ queries. See the `training
+ documentation `__.
+
Args:
request (google.cloud.dialogflowcx_v3.types.CreateIntentRequest):
The request object. The request message for
@@ -619,6 +623,10 @@ def update_intent(
) -> gcdc_intent.Intent:
r"""Updates the specified intent.
+ Note: You should always train a flow prior to sending it
+ queries. See the `training
+ documentation `__.
+
Args:
request (google.cloud.dialogflowcx_v3.types.UpdateIntentRequest):
The request object. The request message for
@@ -705,6 +713,10 @@ def delete_intent(
) -> None:
r"""Deletes the specified intent.
+ Note: You should always train a flow prior to sending it
+ queries. See the `training
+ documentation `__.
+
Args:
request (google.cloud.dialogflowcx_v3.types.DeleteIntentRequest):
The request object. The request message for
diff --git a/google/cloud/dialogflowcx_v3/services/intents/transports/base.py b/google/cloud/dialogflowcx_v3/services/intents/transports/base.py
index 7b147df4..90a38908 100644
--- a/google/cloud/dialogflowcx_v3/services/intents/transports/base.py
+++ b/google/cloud/dialogflowcx_v3/services/intents/transports/base.py
@@ -24,6 +24,7 @@
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
from google.cloud.dialogflowcx_v3.types import intent
from google.cloud.dialogflowcx_v3.types import intent as gcdc_intent
@@ -47,8 +48,6 @@
except pkg_resources.DistributionNotFound: # pragma: NO COVER
_GOOGLE_AUTH_VERSION = None
-_API_CORE_VERSION = google.api_core.__version__
-
class IntentsTransport(abc.ABC):
"""Abstract transport class for Intents."""
@@ -69,6 +68,7 @@ def __init__(
scopes: Optional[Sequence[str]] = None,
quota_project_id: Optional[str] = None,
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
+ always_use_jwt_access: Optional[bool] = False,
**kwargs,
) -> None:
"""Instantiate the transport.
@@ -92,6 +92,8 @@ def __init__(
API requests. If ``None``, then default info will be used.
Generally, you only need to set this if you're developing
your own client library.
+ always_use_jwt_access (Optional[bool]): Whether self signed JWT should
+ be used for service account credentials.
"""
# Save the hostname. Default to port 443 (HTTPS) if none is specified.
if ":" not in host:
@@ -101,7 +103,7 @@ def __init__(
scopes_kwargs = self._get_scopes_kwargs(self._host, scopes)
# Save the scopes.
- self._scopes = scopes or self.AUTH_SCOPES
+ self._scopes = scopes
# If no credentials are provided, then determine the appropriate
# defaults.
@@ -120,13 +122,20 @@ def __init__(
**scopes_kwargs, quota_project_id=quota_project_id
)
+ # If the credentials is service account credentials, then always try to use self signed JWT.
+ if (
+ always_use_jwt_access
+ and isinstance(credentials, service_account.Credentials)
+ and hasattr(service_account.Credentials, "with_always_use_jwt_access")
+ ):
+ credentials = credentials.with_always_use_jwt_access(True)
+
# Save the credentials.
self._credentials = credentials
- # TODO(busunkim): These two class methods are in the base transport
+ # 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-api-core
- # and google-auth are increased.
+ # 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
@@ -147,27 +156,6 @@ def _get_scopes_kwargs(
return scopes_kwargs
- # TODO: Remove this function once google-api-core >= 1.26.0 is required
- @classmethod
- def _get_self_signed_jwt_kwargs(
- cls, host: str, scopes: Optional[Sequence[str]]
- ) -> Dict[str, Union[Optional[Sequence[str]], str]]:
- """Returns kwargs to pass to grpc_helpers.create_channel depending on the google-api-core version"""
-
- self_signed_jwt_kwargs: Dict[str, Union[Optional[Sequence[str]], str]] = {}
-
- if _API_CORE_VERSION and (
- packaging.version.parse(_API_CORE_VERSION)
- >= packaging.version.parse("1.26.0")
- ):
- self_signed_jwt_kwargs["default_scopes"] = cls.AUTH_SCOPES
- self_signed_jwt_kwargs["scopes"] = scopes
- self_signed_jwt_kwargs["default_host"] = cls.DEFAULT_HOST
- else:
- self_signed_jwt_kwargs["scopes"] = scopes or cls.AUTH_SCOPES
-
- return self_signed_jwt_kwargs
-
def _prep_wrapped_messages(self, client_info):
# Precompute the wrapped methods.
self._wrapped_methods = {
diff --git a/google/cloud/dialogflowcx_v3/services/intents/transports/grpc.py b/google/cloud/dialogflowcx_v3/services/intents/transports/grpc.py
index cf6512f0..f42155f4 100644
--- a/google/cloud/dialogflowcx_v3/services/intents/transports/grpc.py
+++ b/google/cloud/dialogflowcx_v3/services/intents/transports/grpc.py
@@ -60,6 +60,7 @@ def __init__(
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
quota_project_id: Optional[str] = None,
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
+ always_use_jwt_access: Optional[bool] = False,
) -> None:
"""Instantiate the transport.
@@ -100,6 +101,8 @@ def __init__(
API requests. If ``None``, then default info will be used.
Generally, you only need to set this if you're developing
your own client library.
+ always_use_jwt_access (Optional[bool]): Whether self signed JWT should
+ be used for service account credentials.
Raises:
google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport
@@ -152,6 +155,7 @@ def __init__(
scopes=scopes,
quota_project_id=quota_project_id,
client_info=client_info,
+ always_use_jwt_access=always_use_jwt_access,
)
if not self._grpc_channel:
@@ -207,14 +211,14 @@ def create_channel(
and ``credentials_file`` are passed.
"""
- self_signed_jwt_kwargs = cls._get_self_signed_jwt_kwargs(host, scopes)
-
return grpc_helpers.create_channel(
host,
credentials=credentials,
credentials_file=credentials_file,
quota_project_id=quota_project_id,
- **self_signed_jwt_kwargs,
+ default_scopes=cls.AUTH_SCOPES,
+ scopes=scopes,
+ default_host=cls.DEFAULT_HOST,
**kwargs,
)
@@ -283,6 +287,10 @@ def create_intent(
Creates an intent in the specified agent.
+ Note: You should always train a flow prior to sending it
+ queries. See the `training
+ documentation `__.
+
Returns:
Callable[[~.CreateIntentRequest],
~.Intent]:
@@ -309,6 +317,10 @@ def update_intent(
Updates the specified intent.
+ Note: You should always train a flow prior to sending it
+ queries. See the `training
+ documentation `__.
+
Returns:
Callable[[~.UpdateIntentRequest],
~.Intent]:
@@ -333,6 +345,10 @@ def delete_intent(self) -> Callable[[intent.DeleteIntentRequest], empty_pb2.Empt
Deletes the specified intent.
+ Note: You should always train a flow prior to sending it
+ queries. See the `training
+ documentation `__.
+
Returns:
Callable[[~.DeleteIntentRequest],
~.Empty]:
diff --git a/google/cloud/dialogflowcx_v3/services/intents/transports/grpc_asyncio.py b/google/cloud/dialogflowcx_v3/services/intents/transports/grpc_asyncio.py
index b98be5ac..95f1dfb6 100644
--- a/google/cloud/dialogflowcx_v3/services/intents/transports/grpc_asyncio.py
+++ b/google/cloud/dialogflowcx_v3/services/intents/transports/grpc_asyncio.py
@@ -81,14 +81,14 @@ def create_channel(
aio.Channel: A gRPC AsyncIO channel object.
"""
- self_signed_jwt_kwargs = cls._get_self_signed_jwt_kwargs(host, scopes)
-
return grpc_helpers_async.create_channel(
host,
credentials=credentials,
credentials_file=credentials_file,
quota_project_id=quota_project_id,
- **self_signed_jwt_kwargs,
+ default_scopes=cls.AUTH_SCOPES,
+ scopes=scopes,
+ default_host=cls.DEFAULT_HOST,
**kwargs,
)
@@ -106,6 +106,7 @@ def __init__(
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
quota_project_id=None,
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
+ always_use_jwt_access: Optional[bool] = False,
) -> None:
"""Instantiate the transport.
@@ -147,6 +148,8 @@ def __init__(
API requests. If ``None``, then default info will be used.
Generally, you only need to set this if you're developing
your own client library.
+ always_use_jwt_access (Optional[bool]): Whether self signed JWT should
+ be used for service account credentials.
Raises:
google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport
@@ -198,6 +201,7 @@ def __init__(
scopes=scopes,
quota_project_id=quota_project_id,
client_info=client_info,
+ always_use_jwt_access=always_use_jwt_access,
)
if not self._grpc_channel:
@@ -288,6 +292,10 @@ def create_intent(
Creates an intent in the specified agent.
+ Note: You should always train a flow prior to sending it
+ queries. See the `training
+ documentation `__.
+
Returns:
Callable[[~.CreateIntentRequest],
Awaitable[~.Intent]]:
@@ -314,6 +322,10 @@ def update_intent(
Updates the specified intent.
+ Note: You should always train a flow prior to sending it
+ queries. See the `training
+ documentation `__.
+
Returns:
Callable[[~.UpdateIntentRequest],
Awaitable[~.Intent]]:
@@ -340,6 +352,10 @@ def delete_intent(
Deletes the specified intent.
+ Note: You should always train a flow prior to sending it
+ queries. See the `training
+ documentation `__.
+
Returns:
Callable[[~.DeleteIntentRequest],
Awaitable[~.Empty]]:
diff --git a/google/cloud/dialogflowcx_v3/services/pages/async_client.py b/google/cloud/dialogflowcx_v3/services/pages/async_client.py
index 79d410c1..0a7e9503 100644
--- a/google/cloud/dialogflowcx_v3/services/pages/async_client.py
+++ b/google/cloud/dialogflowcx_v3/services/pages/async_client.py
@@ -349,6 +349,10 @@ async def create_page(
) -> gcdc_page.Page:
r"""Creates a page in the specified flow.
+ Note: You should always train a flow prior to sending it
+ queries. See the `training
+ documentation `__.
+
Args:
request (:class:`google.cloud.dialogflowcx_v3.types.CreatePageRequest`):
The request object. The request message for
@@ -448,6 +452,10 @@ async def update_page(
) -> gcdc_page.Page:
r"""Updates the specified page.
+ Note: You should always train a flow prior to sending it
+ queries. See the `training
+ documentation `__.
+
Args:
request (:class:`google.cloud.dialogflowcx_v3.types.UpdatePageRequest`):
The request object. The request message for
@@ -549,6 +557,10 @@ async def delete_page(
) -> None:
r"""Deletes the specified page.
+ Note: You should always train a flow prior to sending it
+ queries. See the `training
+ documentation `__.
+
Args:
request (:class:`google.cloud.dialogflowcx_v3.types.DeletePageRequest`):
The request object. The request message for
diff --git a/google/cloud/dialogflowcx_v3/services/pages/client.py b/google/cloud/dialogflowcx_v3/services/pages/client.py
index a74f7673..cec7c48a 100644
--- a/google/cloud/dialogflowcx_v3/services/pages/client.py
+++ b/google/cloud/dialogflowcx_v3/services/pages/client.py
@@ -620,6 +620,10 @@ def create_page(
) -> gcdc_page.Page:
r"""Creates a page in the specified flow.
+ Note: You should always train a flow prior to sending it
+ queries. See the `training
+ documentation `__.
+
Args:
request (google.cloud.dialogflowcx_v3.types.CreatePageRequest):
The request object. The request message for
@@ -719,6 +723,10 @@ def update_page(
) -> gcdc_page.Page:
r"""Updates the specified page.
+ Note: You should always train a flow prior to sending it
+ queries. See the `training
+ documentation `__.
+
Args:
request (google.cloud.dialogflowcx_v3.types.UpdatePageRequest):
The request object. The request message for
@@ -820,6 +828,10 @@ def delete_page(
) -> None:
r"""Deletes the specified page.
+ Note: You should always train a flow prior to sending it
+ queries. See the `training
+ documentation `__.
+
Args:
request (google.cloud.dialogflowcx_v3.types.DeletePageRequest):
The request object. The request message for
diff --git a/google/cloud/dialogflowcx_v3/services/pages/transports/base.py b/google/cloud/dialogflowcx_v3/services/pages/transports/base.py
index 3325368a..a8a0312d 100644
--- a/google/cloud/dialogflowcx_v3/services/pages/transports/base.py
+++ b/google/cloud/dialogflowcx_v3/services/pages/transports/base.py
@@ -24,6 +24,7 @@
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
from google.cloud.dialogflowcx_v3.types import page
from google.cloud.dialogflowcx_v3.types import page as gcdc_page
@@ -47,8 +48,6 @@
except pkg_resources.DistributionNotFound: # pragma: NO COVER
_GOOGLE_AUTH_VERSION = None
-_API_CORE_VERSION = google.api_core.__version__
-
class PagesTransport(abc.ABC):
"""Abstract transport class for Pages."""
@@ -69,6 +68,7 @@ def __init__(
scopes: Optional[Sequence[str]] = None,
quota_project_id: Optional[str] = None,
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
+ always_use_jwt_access: Optional[bool] = False,
**kwargs,
) -> None:
"""Instantiate the transport.
@@ -92,6 +92,8 @@ def __init__(
API requests. If ``None``, then default info will be used.
Generally, you only need to set this if you're developing
your own client library.
+ always_use_jwt_access (Optional[bool]): Whether self signed JWT should
+ be used for service account credentials.
"""
# Save the hostname. Default to port 443 (HTTPS) if none is specified.
if ":" not in host:
@@ -101,7 +103,7 @@ def __init__(
scopes_kwargs = self._get_scopes_kwargs(self._host, scopes)
# Save the scopes.
- self._scopes = scopes or self.AUTH_SCOPES
+ self._scopes = scopes
# If no credentials are provided, then determine the appropriate
# defaults.
@@ -120,13 +122,20 @@ def __init__(
**scopes_kwargs, quota_project_id=quota_project_id
)
+ # If the credentials is service account credentials, then always try to use self signed JWT.
+ if (
+ always_use_jwt_access
+ and isinstance(credentials, service_account.Credentials)
+ and hasattr(service_account.Credentials, "with_always_use_jwt_access")
+ ):
+ credentials = credentials.with_always_use_jwt_access(True)
+
# Save the credentials.
self._credentials = credentials
- # TODO(busunkim): These two class methods are in the base transport
+ # 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-api-core
- # and google-auth are increased.
+ # 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
@@ -147,27 +156,6 @@ def _get_scopes_kwargs(
return scopes_kwargs
- # TODO: Remove this function once google-api-core >= 1.26.0 is required
- @classmethod
- def _get_self_signed_jwt_kwargs(
- cls, host: str, scopes: Optional[Sequence[str]]
- ) -> Dict[str, Union[Optional[Sequence[str]], str]]:
- """Returns kwargs to pass to grpc_helpers.create_channel depending on the google-api-core version"""
-
- self_signed_jwt_kwargs: Dict[str, Union[Optional[Sequence[str]], str]] = {}
-
- if _API_CORE_VERSION and (
- packaging.version.parse(_API_CORE_VERSION)
- >= packaging.version.parse("1.26.0")
- ):
- self_signed_jwt_kwargs["default_scopes"] = cls.AUTH_SCOPES
- self_signed_jwt_kwargs["scopes"] = scopes
- self_signed_jwt_kwargs["default_host"] = cls.DEFAULT_HOST
- else:
- self_signed_jwt_kwargs["scopes"] = scopes or cls.AUTH_SCOPES
-
- return self_signed_jwt_kwargs
-
def _prep_wrapped_messages(self, client_info):
# Precompute the wrapped methods.
self._wrapped_methods = {
diff --git a/google/cloud/dialogflowcx_v3/services/pages/transports/grpc.py b/google/cloud/dialogflowcx_v3/services/pages/transports/grpc.py
index 8d8361f7..0fc211bf 100644
--- a/google/cloud/dialogflowcx_v3/services/pages/transports/grpc.py
+++ b/google/cloud/dialogflowcx_v3/services/pages/transports/grpc.py
@@ -59,6 +59,7 @@ def __init__(
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
quota_project_id: Optional[str] = None,
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
+ always_use_jwt_access: Optional[bool] = False,
) -> None:
"""Instantiate the transport.
@@ -99,6 +100,8 @@ def __init__(
API requests. If ``None``, then default info will be used.
Generally, you only need to set this if you're developing
your own client library.
+ always_use_jwt_access (Optional[bool]): Whether self signed JWT should
+ be used for service account credentials.
Raises:
google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport
@@ -151,6 +154,7 @@ def __init__(
scopes=scopes,
quota_project_id=quota_project_id,
client_info=client_info,
+ always_use_jwt_access=always_use_jwt_access,
)
if not self._grpc_channel:
@@ -206,14 +210,14 @@ def create_channel(
and ``credentials_file`` are passed.
"""
- self_signed_jwt_kwargs = cls._get_self_signed_jwt_kwargs(host, scopes)
-
return grpc_helpers.create_channel(
host,
credentials=credentials,
credentials_file=credentials_file,
quota_project_id=quota_project_id,
- **self_signed_jwt_kwargs,
+ default_scopes=cls.AUTH_SCOPES,
+ scopes=scopes,
+ default_host=cls.DEFAULT_HOST,
**kwargs,
)
@@ -277,6 +281,10 @@ def create_page(self) -> Callable[[gcdc_page.CreatePageRequest], gcdc_page.Page]
Creates a page in the specified flow.
+ Note: You should always train a flow prior to sending it
+ queries. See the `training
+ documentation `__.
+
Returns:
Callable[[~.CreatePageRequest],
~.Page]:
@@ -301,6 +309,10 @@ def update_page(self) -> Callable[[gcdc_page.UpdatePageRequest], gcdc_page.Page]
Updates the specified page.
+ Note: You should always train a flow prior to sending it
+ queries. See the `training
+ documentation `__.
+
Returns:
Callable[[~.UpdatePageRequest],
~.Page]:
@@ -325,6 +337,10 @@ def delete_page(self) -> Callable[[page.DeletePageRequest], empty_pb2.Empty]:
Deletes the specified page.
+ Note: You should always train a flow prior to sending it
+ queries. See the `training
+ documentation `__.
+
Returns:
Callable[[~.DeletePageRequest],
~.Empty]:
diff --git a/google/cloud/dialogflowcx_v3/services/pages/transports/grpc_asyncio.py b/google/cloud/dialogflowcx_v3/services/pages/transports/grpc_asyncio.py
index 3f084d95..c6c574bf 100644
--- a/google/cloud/dialogflowcx_v3/services/pages/transports/grpc_asyncio.py
+++ b/google/cloud/dialogflowcx_v3/services/pages/transports/grpc_asyncio.py
@@ -80,14 +80,14 @@ def create_channel(
aio.Channel: A gRPC AsyncIO channel object.
"""
- self_signed_jwt_kwargs = cls._get_self_signed_jwt_kwargs(host, scopes)
-
return grpc_helpers_async.create_channel(
host,
credentials=credentials,
credentials_file=credentials_file,
quota_project_id=quota_project_id,
- **self_signed_jwt_kwargs,
+ default_scopes=cls.AUTH_SCOPES,
+ scopes=scopes,
+ default_host=cls.DEFAULT_HOST,
**kwargs,
)
@@ -105,6 +105,7 @@ def __init__(
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
quota_project_id=None,
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
+ always_use_jwt_access: Optional[bool] = False,
) -> None:
"""Instantiate the transport.
@@ -146,6 +147,8 @@ def __init__(
API requests. If ``None``, then default info will be used.
Generally, you only need to set this if you're developing
your own client library.
+ always_use_jwt_access (Optional[bool]): Whether self signed JWT should
+ be used for service account credentials.
Raises:
google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport
@@ -197,6 +200,7 @@ def __init__(
scopes=scopes,
quota_project_id=quota_project_id,
client_info=client_info,
+ always_use_jwt_access=always_use_jwt_access,
)
if not self._grpc_channel:
@@ -284,6 +288,10 @@ def create_page(
Creates a page in the specified flow.
+ Note: You should always train a flow prior to sending it
+ queries. See the `training
+ documentation `__.
+
Returns:
Callable[[~.CreatePageRequest],
Awaitable[~.Page]]:
@@ -310,6 +318,10 @@ def update_page(
Updates the specified page.
+ Note: You should always train a flow prior to sending it
+ queries. See the `training
+ documentation `__.
+
Returns:
Callable[[~.UpdatePageRequest],
Awaitable[~.Page]]:
@@ -336,6 +348,10 @@ def delete_page(
Deletes the specified page.
+ Note: You should always train a flow prior to sending it
+ queries. See the `training
+ documentation `__.
+
Returns:
Callable[[~.DeletePageRequest],
Awaitable[~.Empty]]:
diff --git a/google/cloud/dialogflowcx_v3/services/security_settings_service/transports/base.py b/google/cloud/dialogflowcx_v3/services/security_settings_service/transports/base.py
index 6ed6a73b..ad18cc76 100644
--- a/google/cloud/dialogflowcx_v3/services/security_settings_service/transports/base.py
+++ b/google/cloud/dialogflowcx_v3/services/security_settings_service/transports/base.py
@@ -24,6 +24,7 @@
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
from google.cloud.dialogflowcx_v3.types import security_settings
from google.cloud.dialogflowcx_v3.types import (
@@ -49,8 +50,6 @@
except pkg_resources.DistributionNotFound: # pragma: NO COVER
_GOOGLE_AUTH_VERSION = None
-_API_CORE_VERSION = google.api_core.__version__
-
class SecuritySettingsServiceTransport(abc.ABC):
"""Abstract transport class for SecuritySettingsService."""
@@ -71,6 +70,7 @@ def __init__(
scopes: Optional[Sequence[str]] = None,
quota_project_id: Optional[str] = None,
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
+ always_use_jwt_access: Optional[bool] = False,
**kwargs,
) -> None:
"""Instantiate the transport.
@@ -94,6 +94,8 @@ def __init__(
API requests. If ``None``, then default info will be used.
Generally, you only need to set this if you're developing
your own client library.
+ always_use_jwt_access (Optional[bool]): Whether self signed JWT should
+ be used for service account credentials.
"""
# Save the hostname. Default to port 443 (HTTPS) if none is specified.
if ":" not in host:
@@ -103,7 +105,7 @@ def __init__(
scopes_kwargs = self._get_scopes_kwargs(self._host, scopes)
# Save the scopes.
- self._scopes = scopes or self.AUTH_SCOPES
+ self._scopes = scopes
# If no credentials are provided, then determine the appropriate
# defaults.
@@ -122,13 +124,20 @@ def __init__(
**scopes_kwargs, quota_project_id=quota_project_id
)
+ # If the credentials is service account credentials, then always try to use self signed JWT.
+ if (
+ always_use_jwt_access
+ and isinstance(credentials, service_account.Credentials)
+ and hasattr(service_account.Credentials, "with_always_use_jwt_access")
+ ):
+ credentials = credentials.with_always_use_jwt_access(True)
+
# Save the credentials.
self._credentials = credentials
- # TODO(busunkim): These two class methods are in the base transport
+ # 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-api-core
- # and google-auth are increased.
+ # 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
@@ -149,27 +158,6 @@ def _get_scopes_kwargs(
return scopes_kwargs
- # TODO: Remove this function once google-api-core >= 1.26.0 is required
- @classmethod
- def _get_self_signed_jwt_kwargs(
- cls, host: str, scopes: Optional[Sequence[str]]
- ) -> Dict[str, Union[Optional[Sequence[str]], str]]:
- """Returns kwargs to pass to grpc_helpers.create_channel depending on the google-api-core version"""
-
- self_signed_jwt_kwargs: Dict[str, Union[Optional[Sequence[str]], str]] = {}
-
- if _API_CORE_VERSION and (
- packaging.version.parse(_API_CORE_VERSION)
- >= packaging.version.parse("1.26.0")
- ):
- self_signed_jwt_kwargs["default_scopes"] = cls.AUTH_SCOPES
- self_signed_jwt_kwargs["scopes"] = scopes
- self_signed_jwt_kwargs["default_host"] = cls.DEFAULT_HOST
- else:
- self_signed_jwt_kwargs["scopes"] = scopes or cls.AUTH_SCOPES
-
- return self_signed_jwt_kwargs
-
def _prep_wrapped_messages(self, client_info):
# Precompute the wrapped methods.
self._wrapped_methods = {
diff --git a/google/cloud/dialogflowcx_v3/services/security_settings_service/transports/grpc.py b/google/cloud/dialogflowcx_v3/services/security_settings_service/transports/grpc.py
index cf0d1917..7ed00ca3 100644
--- a/google/cloud/dialogflowcx_v3/services/security_settings_service/transports/grpc.py
+++ b/google/cloud/dialogflowcx_v3/services/security_settings_service/transports/grpc.py
@@ -61,6 +61,7 @@ def __init__(
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
quota_project_id: Optional[str] = None,
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
+ always_use_jwt_access: Optional[bool] = False,
) -> None:
"""Instantiate the transport.
@@ -101,6 +102,8 @@ def __init__(
API requests. If ``None``, then default info will be used.
Generally, you only need to set this if you're developing
your own client library.
+ always_use_jwt_access (Optional[bool]): Whether self signed JWT should
+ be used for service account credentials.
Raises:
google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport
@@ -153,6 +156,7 @@ def __init__(
scopes=scopes,
quota_project_id=quota_project_id,
client_info=client_info,
+ always_use_jwt_access=always_use_jwt_access,
)
if not self._grpc_channel:
@@ -208,14 +212,14 @@ def create_channel(
and ``credentials_file`` are passed.
"""
- self_signed_jwt_kwargs = cls._get_self_signed_jwt_kwargs(host, scopes)
-
return grpc_helpers.create_channel(
host,
credentials=credentials,
credentials_file=credentials_file,
quota_project_id=quota_project_id,
- **self_signed_jwt_kwargs,
+ default_scopes=cls.AUTH_SCOPES,
+ scopes=scopes,
+ default_host=cls.DEFAULT_HOST,
**kwargs,
)
diff --git a/google/cloud/dialogflowcx_v3/services/security_settings_service/transports/grpc_asyncio.py b/google/cloud/dialogflowcx_v3/services/security_settings_service/transports/grpc_asyncio.py
index 5fa7c384..5c7b6461 100644
--- a/google/cloud/dialogflowcx_v3/services/security_settings_service/transports/grpc_asyncio.py
+++ b/google/cloud/dialogflowcx_v3/services/security_settings_service/transports/grpc_asyncio.py
@@ -82,14 +82,14 @@ def create_channel(
aio.Channel: A gRPC AsyncIO channel object.
"""
- self_signed_jwt_kwargs = cls._get_self_signed_jwt_kwargs(host, scopes)
-
return grpc_helpers_async.create_channel(
host,
credentials=credentials,
credentials_file=credentials_file,
quota_project_id=quota_project_id,
- **self_signed_jwt_kwargs,
+ default_scopes=cls.AUTH_SCOPES,
+ scopes=scopes,
+ default_host=cls.DEFAULT_HOST,
**kwargs,
)
@@ -107,6 +107,7 @@ def __init__(
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
quota_project_id=None,
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
+ always_use_jwt_access: Optional[bool] = False,
) -> None:
"""Instantiate the transport.
@@ -148,6 +149,8 @@ def __init__(
API requests. If ``None``, then default info will be used.
Generally, you only need to set this if you're developing
your own client library.
+ always_use_jwt_access (Optional[bool]): Whether self signed JWT should
+ be used for service account credentials.
Raises:
google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport
@@ -199,6 +202,7 @@ def __init__(
scopes=scopes,
quota_project_id=quota_project_id,
client_info=client_info,
+ always_use_jwt_access=always_use_jwt_access,
)
if not self._grpc_channel:
diff --git a/google/cloud/dialogflowcx_v3/services/session_entity_types/transports/base.py b/google/cloud/dialogflowcx_v3/services/session_entity_types/transports/base.py
index 76f2dd22..67c904a6 100644
--- a/google/cloud/dialogflowcx_v3/services/session_entity_types/transports/base.py
+++ b/google/cloud/dialogflowcx_v3/services/session_entity_types/transports/base.py
@@ -24,6 +24,7 @@
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
from google.cloud.dialogflowcx_v3.types import session_entity_type
from google.cloud.dialogflowcx_v3.types import (
@@ -49,8 +50,6 @@
except pkg_resources.DistributionNotFound: # pragma: NO COVER
_GOOGLE_AUTH_VERSION = None
-_API_CORE_VERSION = google.api_core.__version__
-
class SessionEntityTypesTransport(abc.ABC):
"""Abstract transport class for SessionEntityTypes."""
@@ -71,6 +70,7 @@ def __init__(
scopes: Optional[Sequence[str]] = None,
quota_project_id: Optional[str] = None,
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
+ always_use_jwt_access: Optional[bool] = False,
**kwargs,
) -> None:
"""Instantiate the transport.
@@ -94,6 +94,8 @@ def __init__(
API requests. If ``None``, then default info will be used.
Generally, you only need to set this if you're developing
your own client library.
+ always_use_jwt_access (Optional[bool]): Whether self signed JWT should
+ be used for service account credentials.
"""
# Save the hostname. Default to port 443 (HTTPS) if none is specified.
if ":" not in host:
@@ -103,7 +105,7 @@ def __init__(
scopes_kwargs = self._get_scopes_kwargs(self._host, scopes)
# Save the scopes.
- self._scopes = scopes or self.AUTH_SCOPES
+ self._scopes = scopes
# If no credentials are provided, then determine the appropriate
# defaults.
@@ -122,13 +124,20 @@ def __init__(
**scopes_kwargs, quota_project_id=quota_project_id
)
+ # If the credentials is service account credentials, then always try to use self signed JWT.
+ if (
+ always_use_jwt_access
+ and isinstance(credentials, service_account.Credentials)
+ and hasattr(service_account.Credentials, "with_always_use_jwt_access")
+ ):
+ credentials = credentials.with_always_use_jwt_access(True)
+
# Save the credentials.
self._credentials = credentials
- # TODO(busunkim): These two class methods are in the base transport
+ # 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-api-core
- # and google-auth are increased.
+ # 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
@@ -149,27 +158,6 @@ def _get_scopes_kwargs(
return scopes_kwargs
- # TODO: Remove this function once google-api-core >= 1.26.0 is required
- @classmethod
- def _get_self_signed_jwt_kwargs(
- cls, host: str, scopes: Optional[Sequence[str]]
- ) -> Dict[str, Union[Optional[Sequence[str]], str]]:
- """Returns kwargs to pass to grpc_helpers.create_channel depending on the google-api-core version"""
-
- self_signed_jwt_kwargs: Dict[str, Union[Optional[Sequence[str]], str]] = {}
-
- if _API_CORE_VERSION and (
- packaging.version.parse(_API_CORE_VERSION)
- >= packaging.version.parse("1.26.0")
- ):
- self_signed_jwt_kwargs["default_scopes"] = cls.AUTH_SCOPES
- self_signed_jwt_kwargs["scopes"] = scopes
- self_signed_jwt_kwargs["default_host"] = cls.DEFAULT_HOST
- else:
- self_signed_jwt_kwargs["scopes"] = scopes or cls.AUTH_SCOPES
-
- return self_signed_jwt_kwargs
-
def _prep_wrapped_messages(self, client_info):
# Precompute the wrapped methods.
self._wrapped_methods = {
diff --git a/google/cloud/dialogflowcx_v3/services/session_entity_types/transports/grpc.py b/google/cloud/dialogflowcx_v3/services/session_entity_types/transports/grpc.py
index b1d2fcef..224ebcfd 100644
--- a/google/cloud/dialogflowcx_v3/services/session_entity_types/transports/grpc.py
+++ b/google/cloud/dialogflowcx_v3/services/session_entity_types/transports/grpc.py
@@ -62,6 +62,7 @@ def __init__(
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
quota_project_id: Optional[str] = None,
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
+ always_use_jwt_access: Optional[bool] = False,
) -> None:
"""Instantiate the transport.
@@ -102,6 +103,8 @@ def __init__(
API requests. If ``None``, then default info will be used.
Generally, you only need to set this if you're developing
your own client library.
+ always_use_jwt_access (Optional[bool]): Whether self signed JWT should
+ be used for service account credentials.
Raises:
google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport
@@ -154,6 +157,7 @@ def __init__(
scopes=scopes,
quota_project_id=quota_project_id,
client_info=client_info,
+ always_use_jwt_access=always_use_jwt_access,
)
if not self._grpc_channel:
@@ -209,14 +213,14 @@ def create_channel(
and ``credentials_file`` are passed.
"""
- self_signed_jwt_kwargs = cls._get_self_signed_jwt_kwargs(host, scopes)
-
return grpc_helpers.create_channel(
host,
credentials=credentials,
credentials_file=credentials_file,
quota_project_id=quota_project_id,
- **self_signed_jwt_kwargs,
+ default_scopes=cls.AUTH_SCOPES,
+ scopes=scopes,
+ default_host=cls.DEFAULT_HOST,
**kwargs,
)
diff --git a/google/cloud/dialogflowcx_v3/services/session_entity_types/transports/grpc_asyncio.py b/google/cloud/dialogflowcx_v3/services/session_entity_types/transports/grpc_asyncio.py
index e9cc5a9d..d8afcfc7 100644
--- a/google/cloud/dialogflowcx_v3/services/session_entity_types/transports/grpc_asyncio.py
+++ b/google/cloud/dialogflowcx_v3/services/session_entity_types/transports/grpc_asyncio.py
@@ -83,14 +83,14 @@ def create_channel(
aio.Channel: A gRPC AsyncIO channel object.
"""
- self_signed_jwt_kwargs = cls._get_self_signed_jwt_kwargs(host, scopes)
-
return grpc_helpers_async.create_channel(
host,
credentials=credentials,
credentials_file=credentials_file,
quota_project_id=quota_project_id,
- **self_signed_jwt_kwargs,
+ default_scopes=cls.AUTH_SCOPES,
+ scopes=scopes,
+ default_host=cls.DEFAULT_HOST,
**kwargs,
)
@@ -108,6 +108,7 @@ def __init__(
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
quota_project_id=None,
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
+ always_use_jwt_access: Optional[bool] = False,
) -> None:
"""Instantiate the transport.
@@ -149,6 +150,8 @@ def __init__(
API requests. If ``None``, then default info will be used.
Generally, you only need to set this if you're developing
your own client library.
+ always_use_jwt_access (Optional[bool]): Whether self signed JWT should
+ be used for service account credentials.
Raises:
google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport
@@ -200,6 +203,7 @@ def __init__(
scopes=scopes,
quota_project_id=quota_project_id,
client_info=client_info,
+ always_use_jwt_access=always_use_jwt_access,
)
if not self._grpc_channel:
diff --git a/google/cloud/dialogflowcx_v3/services/sessions/transports/base.py b/google/cloud/dialogflowcx_v3/services/sessions/transports/base.py
index e995fc1a..cce0d59f 100644
--- a/google/cloud/dialogflowcx_v3/services/sessions/transports/base.py
+++ b/google/cloud/dialogflowcx_v3/services/sessions/transports/base.py
@@ -24,6 +24,7 @@
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
from google.cloud.dialogflowcx_v3.types import session
@@ -45,8 +46,6 @@
except pkg_resources.DistributionNotFound: # pragma: NO COVER
_GOOGLE_AUTH_VERSION = None
-_API_CORE_VERSION = google.api_core.__version__
-
class SessionsTransport(abc.ABC):
"""Abstract transport class for Sessions."""
@@ -67,6 +66,7 @@ def __init__(
scopes: Optional[Sequence[str]] = None,
quota_project_id: Optional[str] = None,
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
+ always_use_jwt_access: Optional[bool] = False,
**kwargs,
) -> None:
"""Instantiate the transport.
@@ -90,6 +90,8 @@ def __init__(
API requests. If ``None``, then default info will be used.
Generally, you only need to set this if you're developing
your own client library.
+ always_use_jwt_access (Optional[bool]): Whether self signed JWT should
+ be used for service account credentials.
"""
# Save the hostname. Default to port 443 (HTTPS) if none is specified.
if ":" not in host:
@@ -99,7 +101,7 @@ def __init__(
scopes_kwargs = self._get_scopes_kwargs(self._host, scopes)
# Save the scopes.
- self._scopes = scopes or self.AUTH_SCOPES
+ self._scopes = scopes
# If no credentials are provided, then determine the appropriate
# defaults.
@@ -118,13 +120,20 @@ def __init__(
**scopes_kwargs, quota_project_id=quota_project_id
)
+ # If the credentials is service account credentials, then always try to use self signed JWT.
+ if (
+ always_use_jwt_access
+ and isinstance(credentials, service_account.Credentials)
+ and hasattr(service_account.Credentials, "with_always_use_jwt_access")
+ ):
+ credentials = credentials.with_always_use_jwt_access(True)
+
# Save the credentials.
self._credentials = credentials
- # TODO(busunkim): These two class methods are in the base transport
+ # 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-api-core
- # and google-auth are increased.
+ # 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
@@ -145,27 +154,6 @@ def _get_scopes_kwargs(
return scopes_kwargs
- # TODO: Remove this function once google-api-core >= 1.26.0 is required
- @classmethod
- def _get_self_signed_jwt_kwargs(
- cls, host: str, scopes: Optional[Sequence[str]]
- ) -> Dict[str, Union[Optional[Sequence[str]], str]]:
- """Returns kwargs to pass to grpc_helpers.create_channel depending on the google-api-core version"""
-
- self_signed_jwt_kwargs: Dict[str, Union[Optional[Sequence[str]], str]] = {}
-
- if _API_CORE_VERSION and (
- packaging.version.parse(_API_CORE_VERSION)
- >= packaging.version.parse("1.26.0")
- ):
- self_signed_jwt_kwargs["default_scopes"] = cls.AUTH_SCOPES
- self_signed_jwt_kwargs["scopes"] = scopes
- self_signed_jwt_kwargs["default_host"] = cls.DEFAULT_HOST
- else:
- self_signed_jwt_kwargs["scopes"] = scopes or cls.AUTH_SCOPES
-
- return self_signed_jwt_kwargs
-
def _prep_wrapped_messages(self, client_info):
# Precompute the wrapped methods.
self._wrapped_methods = {
diff --git a/google/cloud/dialogflowcx_v3/services/sessions/transports/grpc.py b/google/cloud/dialogflowcx_v3/services/sessions/transports/grpc.py
index 3b5a5fbd..a78d8c27 100644
--- a/google/cloud/dialogflowcx_v3/services/sessions/transports/grpc.py
+++ b/google/cloud/dialogflowcx_v3/services/sessions/transports/grpc.py
@@ -60,6 +60,7 @@ def __init__(
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
quota_project_id: Optional[str] = None,
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
+ always_use_jwt_access: Optional[bool] = False,
) -> None:
"""Instantiate the transport.
@@ -100,6 +101,8 @@ def __init__(
API requests. If ``None``, then default info will be used.
Generally, you only need to set this if you're developing
your own client library.
+ always_use_jwt_access (Optional[bool]): Whether self signed JWT should
+ be used for service account credentials.
Raises:
google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport
@@ -152,6 +155,7 @@ def __init__(
scopes=scopes,
quota_project_id=quota_project_id,
client_info=client_info,
+ always_use_jwt_access=always_use_jwt_access,
)
if not self._grpc_channel:
@@ -207,14 +211,14 @@ def create_channel(
and ``credentials_file`` are passed.
"""
- self_signed_jwt_kwargs = cls._get_self_signed_jwt_kwargs(host, scopes)
-
return grpc_helpers.create_channel(
host,
credentials=credentials,
credentials_file=credentials_file,
quota_project_id=quota_project_id,
- **self_signed_jwt_kwargs,
+ default_scopes=cls.AUTH_SCOPES,
+ scopes=scopes,
+ default_host=cls.DEFAULT_HOST,
**kwargs,
)
diff --git a/google/cloud/dialogflowcx_v3/services/sessions/transports/grpc_asyncio.py b/google/cloud/dialogflowcx_v3/services/sessions/transports/grpc_asyncio.py
index 94a6f61c..ff58d6a2 100644
--- a/google/cloud/dialogflowcx_v3/services/sessions/transports/grpc_asyncio.py
+++ b/google/cloud/dialogflowcx_v3/services/sessions/transports/grpc_asyncio.py
@@ -81,14 +81,14 @@ def create_channel(
aio.Channel: A gRPC AsyncIO channel object.
"""
- self_signed_jwt_kwargs = cls._get_self_signed_jwt_kwargs(host, scopes)
-
return grpc_helpers_async.create_channel(
host,
credentials=credentials,
credentials_file=credentials_file,
quota_project_id=quota_project_id,
- **self_signed_jwt_kwargs,
+ default_scopes=cls.AUTH_SCOPES,
+ scopes=scopes,
+ default_host=cls.DEFAULT_HOST,
**kwargs,
)
@@ -106,6 +106,7 @@ def __init__(
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
quota_project_id=None,
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
+ always_use_jwt_access: Optional[bool] = False,
) -> None:
"""Instantiate the transport.
@@ -147,6 +148,8 @@ def __init__(
API requests. If ``None``, then default info will be used.
Generally, you only need to set this if you're developing
your own client library.
+ always_use_jwt_access (Optional[bool]): Whether self signed JWT should
+ be used for service account credentials.
Raises:
google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport
@@ -198,6 +201,7 @@ def __init__(
scopes=scopes,
quota_project_id=quota_project_id,
client_info=client_info,
+ always_use_jwt_access=always_use_jwt_access,
)
if not self._grpc_channel:
diff --git a/google/cloud/dialogflowcx_v3/services/test_cases/transports/base.py b/google/cloud/dialogflowcx_v3/services/test_cases/transports/base.py
index 4cd9a366..5ec51667 100644
--- a/google/cloud/dialogflowcx_v3/services/test_cases/transports/base.py
+++ b/google/cloud/dialogflowcx_v3/services/test_cases/transports/base.py
@@ -25,6 +25,7 @@
from google.api_core import retry as retries # type: ignore
from google.api_core import operations_v1 # type: ignore
from google.auth import credentials as ga_credentials # type: ignore
+from google.oauth2 import service_account # type: ignore
from google.cloud.dialogflowcx_v3.types import test_case
from google.cloud.dialogflowcx_v3.types import test_case as gcdc_test_case
@@ -49,8 +50,6 @@
except pkg_resources.DistributionNotFound: # pragma: NO COVER
_GOOGLE_AUTH_VERSION = None
-_API_CORE_VERSION = google.api_core.__version__
-
class TestCasesTransport(abc.ABC):
"""Abstract transport class for TestCases."""
@@ -71,6 +70,7 @@ def __init__(
scopes: Optional[Sequence[str]] = None,
quota_project_id: Optional[str] = None,
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
+ always_use_jwt_access: Optional[bool] = False,
**kwargs,
) -> None:
"""Instantiate the transport.
@@ -94,6 +94,8 @@ def __init__(
API requests. If ``None``, then default info will be used.
Generally, you only need to set this if you're developing
your own client library.
+ always_use_jwt_access (Optional[bool]): Whether self signed JWT should
+ be used for service account credentials.
"""
# Save the hostname. Default to port 443 (HTTPS) if none is specified.
if ":" not in host:
@@ -103,7 +105,7 @@ def __init__(
scopes_kwargs = self._get_scopes_kwargs(self._host, scopes)
# Save the scopes.
- self._scopes = scopes or self.AUTH_SCOPES
+ self._scopes = scopes
# If no credentials are provided, then determine the appropriate
# defaults.
@@ -122,13 +124,20 @@ def __init__(
**scopes_kwargs, quota_project_id=quota_project_id
)
+ # If the credentials is service account credentials, then always try to use self signed JWT.
+ if (
+ always_use_jwt_access
+ and isinstance(credentials, service_account.Credentials)
+ and hasattr(service_account.Credentials, "with_always_use_jwt_access")
+ ):
+ credentials = credentials.with_always_use_jwt_access(True)
+
# Save the credentials.
self._credentials = credentials
- # TODO(busunkim): These two class methods are in the base transport
+ # 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-api-core
- # and google-auth are increased.
+ # 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
@@ -149,27 +158,6 @@ def _get_scopes_kwargs(
return scopes_kwargs
- # TODO: Remove this function once google-api-core >= 1.26.0 is required
- @classmethod
- def _get_self_signed_jwt_kwargs(
- cls, host: str, scopes: Optional[Sequence[str]]
- ) -> Dict[str, Union[Optional[Sequence[str]], str]]:
- """Returns kwargs to pass to grpc_helpers.create_channel depending on the google-api-core version"""
-
- self_signed_jwt_kwargs: Dict[str, Union[Optional[Sequence[str]], str]] = {}
-
- if _API_CORE_VERSION and (
- packaging.version.parse(_API_CORE_VERSION)
- >= packaging.version.parse("1.26.0")
- ):
- self_signed_jwt_kwargs["default_scopes"] = cls.AUTH_SCOPES
- self_signed_jwt_kwargs["scopes"] = scopes
- self_signed_jwt_kwargs["default_host"] = cls.DEFAULT_HOST
- else:
- self_signed_jwt_kwargs["scopes"] = scopes or cls.AUTH_SCOPES
-
- return self_signed_jwt_kwargs
-
def _prep_wrapped_messages(self, client_info):
# Precompute the wrapped methods.
self._wrapped_methods = {
diff --git a/google/cloud/dialogflowcx_v3/services/test_cases/transports/grpc.py b/google/cloud/dialogflowcx_v3/services/test_cases/transports/grpc.py
index 79b0442a..7f7ad9b9 100644
--- a/google/cloud/dialogflowcx_v3/services/test_cases/transports/grpc.py
+++ b/google/cloud/dialogflowcx_v3/services/test_cases/transports/grpc.py
@@ -63,6 +63,7 @@ def __init__(
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
quota_project_id: Optional[str] = None,
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
+ always_use_jwt_access: Optional[bool] = False,
) -> None:
"""Instantiate the transport.
@@ -103,6 +104,8 @@ def __init__(
API requests. If ``None``, then default info will be used.
Generally, you only need to set this if you're developing
your own client library.
+ always_use_jwt_access (Optional[bool]): Whether self signed JWT should
+ be used for service account credentials.
Raises:
google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport
@@ -156,6 +159,7 @@ def __init__(
scopes=scopes,
quota_project_id=quota_project_id,
client_info=client_info,
+ always_use_jwt_access=always_use_jwt_access,
)
if not self._grpc_channel:
@@ -211,14 +215,14 @@ def create_channel(
and ``credentials_file`` are passed.
"""
- self_signed_jwt_kwargs = cls._get_self_signed_jwt_kwargs(host, scopes)
-
return grpc_helpers.create_channel(
host,
credentials=credentials,
credentials_file=credentials_file,
quota_project_id=quota_project_id,
- **self_signed_jwt_kwargs,
+ default_scopes=cls.AUTH_SCOPES,
+ scopes=scopes,
+ default_host=cls.DEFAULT_HOST,
**kwargs,
)
diff --git a/google/cloud/dialogflowcx_v3/services/test_cases/transports/grpc_asyncio.py b/google/cloud/dialogflowcx_v3/services/test_cases/transports/grpc_asyncio.py
index a1bb484d..84c36ecb 100644
--- a/google/cloud/dialogflowcx_v3/services/test_cases/transports/grpc_asyncio.py
+++ b/google/cloud/dialogflowcx_v3/services/test_cases/transports/grpc_asyncio.py
@@ -84,14 +84,14 @@ def create_channel(
aio.Channel: A gRPC AsyncIO channel object.
"""
- self_signed_jwt_kwargs = cls._get_self_signed_jwt_kwargs(host, scopes)
-
return grpc_helpers_async.create_channel(
host,
credentials=credentials,
credentials_file=credentials_file,
quota_project_id=quota_project_id,
- **self_signed_jwt_kwargs,
+ default_scopes=cls.AUTH_SCOPES,
+ scopes=scopes,
+ default_host=cls.DEFAULT_HOST,
**kwargs,
)
@@ -109,6 +109,7 @@ def __init__(
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
quota_project_id=None,
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
+ always_use_jwt_access: Optional[bool] = False,
) -> None:
"""Instantiate the transport.
@@ -150,6 +151,8 @@ def __init__(
API requests. If ``None``, then default info will be used.
Generally, you only need to set this if you're developing
your own client library.
+ always_use_jwt_access (Optional[bool]): Whether self signed JWT should
+ be used for service account credentials.
Raises:
google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport
@@ -202,6 +205,7 @@ def __init__(
scopes=scopes,
quota_project_id=quota_project_id,
client_info=client_info,
+ always_use_jwt_access=always_use_jwt_access,
)
if not self._grpc_channel:
diff --git a/google/cloud/dialogflowcx_v3/services/transition_route_groups/async_client.py b/google/cloud/dialogflowcx_v3/services/transition_route_groups/async_client.py
index 49feee70..23095956 100644
--- a/google/cloud/dialogflowcx_v3/services/transition_route_groups/async_client.py
+++ b/google/cloud/dialogflowcx_v3/services/transition_route_groups/async_client.py
@@ -355,6 +355,10 @@ async def create_transition_route_group(
[TransitionRouteGroup][google.cloud.dialogflow.cx.v3.TransitionRouteGroup]
in the specified flow.
+ Note: You should always train a flow prior to sending it
+ queries. See the `training
+ documentation `__.
+
Args:
request (:class:`google.cloud.dialogflowcx_v3.types.CreateTransitionRouteGroupRequest`):
The request object. The request message for
@@ -441,6 +445,10 @@ async def update_transition_route_group(
r"""Updates the specified
[TransitionRouteGroup][google.cloud.dialogflow.cx.v3.TransitionRouteGroup].
+ Note: You should always train a flow prior to sending it
+ queries. See the `training
+ documentation `__.
+
Args:
request (:class:`google.cloud.dialogflowcx_v3.types.UpdateTransitionRouteGroupRequest`):
The request object. The request message for
@@ -526,6 +534,10 @@ async def delete_transition_route_group(
r"""Deletes the specified
[TransitionRouteGroup][google.cloud.dialogflow.cx.v3.TransitionRouteGroup].
+ Note: You should always train a flow prior to sending it
+ queries. See the `training
+ documentation `__.
+
Args:
request (:class:`google.cloud.dialogflowcx_v3.types.DeleteTransitionRouteGroupRequest`):
The request object. The request message for
diff --git a/google/cloud/dialogflowcx_v3/services/transition_route_groups/client.py b/google/cloud/dialogflowcx_v3/services/transition_route_groups/client.py
index 44903604..c16321f5 100644
--- a/google/cloud/dialogflowcx_v3/services/transition_route_groups/client.py
+++ b/google/cloud/dialogflowcx_v3/services/transition_route_groups/client.py
@@ -607,6 +607,10 @@ def create_transition_route_group(
[TransitionRouteGroup][google.cloud.dialogflow.cx.v3.TransitionRouteGroup]
in the specified flow.
+ Note: You should always train a flow prior to sending it
+ queries. See the `training
+ documentation `__.
+
Args:
request (google.cloud.dialogflowcx_v3.types.CreateTransitionRouteGroupRequest):
The request object. The request message for
@@ -699,6 +703,10 @@ def update_transition_route_group(
r"""Updates the specified
[TransitionRouteGroup][google.cloud.dialogflow.cx.v3.TransitionRouteGroup].
+ Note: You should always train a flow prior to sending it
+ queries. See the `training
+ documentation `__.
+
Args:
request (google.cloud.dialogflowcx_v3.types.UpdateTransitionRouteGroupRequest):
The request object. The request message for
@@ -790,6 +798,10 @@ def delete_transition_route_group(
r"""Deletes the specified
[TransitionRouteGroup][google.cloud.dialogflow.cx.v3.TransitionRouteGroup].
+ Note: You should always train a flow prior to sending it
+ queries. See the `training
+ documentation `__.
+
Args:
request (google.cloud.dialogflowcx_v3.types.DeleteTransitionRouteGroupRequest):
The request object. The request message for
diff --git a/google/cloud/dialogflowcx_v3/services/transition_route_groups/transports/base.py b/google/cloud/dialogflowcx_v3/services/transition_route_groups/transports/base.py
index 3a538d56..aeb1c799 100644
--- a/google/cloud/dialogflowcx_v3/services/transition_route_groups/transports/base.py
+++ b/google/cloud/dialogflowcx_v3/services/transition_route_groups/transports/base.py
@@ -24,6 +24,7 @@
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
from google.cloud.dialogflowcx_v3.types import transition_route_group
from google.cloud.dialogflowcx_v3.types import (
@@ -49,8 +50,6 @@
except pkg_resources.DistributionNotFound: # pragma: NO COVER
_GOOGLE_AUTH_VERSION = None
-_API_CORE_VERSION = google.api_core.__version__
-
class TransitionRouteGroupsTransport(abc.ABC):
"""Abstract transport class for TransitionRouteGroups."""
@@ -71,6 +70,7 @@ def __init__(
scopes: Optional[Sequence[str]] = None,
quota_project_id: Optional[str] = None,
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
+ always_use_jwt_access: Optional[bool] = False,
**kwargs,
) -> None:
"""Instantiate the transport.
@@ -94,6 +94,8 @@ def __init__(
API requests. If ``None``, then default info will be used.
Generally, you only need to set this if you're developing
your own client library.
+ always_use_jwt_access (Optional[bool]): Whether self signed JWT should
+ be used for service account credentials.
"""
# Save the hostname. Default to port 443 (HTTPS) if none is specified.
if ":" not in host:
@@ -103,7 +105,7 @@ def __init__(
scopes_kwargs = self._get_scopes_kwargs(self._host, scopes)
# Save the scopes.
- self._scopes = scopes or self.AUTH_SCOPES
+ self._scopes = scopes
# If no credentials are provided, then determine the appropriate
# defaults.
@@ -122,13 +124,20 @@ def __init__(
**scopes_kwargs, quota_project_id=quota_project_id
)
+ # If the credentials is service account credentials, then always try to use self signed JWT.
+ if (
+ always_use_jwt_access
+ and isinstance(credentials, service_account.Credentials)
+ and hasattr(service_account.Credentials, "with_always_use_jwt_access")
+ ):
+ credentials = credentials.with_always_use_jwt_access(True)
+
# Save the credentials.
self._credentials = credentials
- # TODO(busunkim): These two class methods are in the base transport
+ # 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-api-core
- # and google-auth are increased.
+ # 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
@@ -149,27 +158,6 @@ def _get_scopes_kwargs(
return scopes_kwargs
- # TODO: Remove this function once google-api-core >= 1.26.0 is required
- @classmethod
- def _get_self_signed_jwt_kwargs(
- cls, host: str, scopes: Optional[Sequence[str]]
- ) -> Dict[str, Union[Optional[Sequence[str]], str]]:
- """Returns kwargs to pass to grpc_helpers.create_channel depending on the google-api-core version"""
-
- self_signed_jwt_kwargs: Dict[str, Union[Optional[Sequence[str]], str]] = {}
-
- if _API_CORE_VERSION and (
- packaging.version.parse(_API_CORE_VERSION)
- >= packaging.version.parse("1.26.0")
- ):
- self_signed_jwt_kwargs["default_scopes"] = cls.AUTH_SCOPES
- self_signed_jwt_kwargs["scopes"] = scopes
- self_signed_jwt_kwargs["default_host"] = cls.DEFAULT_HOST
- else:
- self_signed_jwt_kwargs["scopes"] = scopes or cls.AUTH_SCOPES
-
- return self_signed_jwt_kwargs
-
def _prep_wrapped_messages(self, client_info):
# Precompute the wrapped methods.
self._wrapped_methods = {
diff --git a/google/cloud/dialogflowcx_v3/services/transition_route_groups/transports/grpc.py b/google/cloud/dialogflowcx_v3/services/transition_route_groups/transports/grpc.py
index 8e38881e..256252a0 100644
--- a/google/cloud/dialogflowcx_v3/services/transition_route_groups/transports/grpc.py
+++ b/google/cloud/dialogflowcx_v3/services/transition_route_groups/transports/grpc.py
@@ -62,6 +62,7 @@ def __init__(
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
quota_project_id: Optional[str] = None,
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
+ always_use_jwt_access: Optional[bool] = False,
) -> None:
"""Instantiate the transport.
@@ -102,6 +103,8 @@ def __init__(
API requests. If ``None``, then default info will be used.
Generally, you only need to set this if you're developing
your own client library.
+ always_use_jwt_access (Optional[bool]): Whether self signed JWT should
+ be used for service account credentials.
Raises:
google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport
@@ -154,6 +157,7 @@ def __init__(
scopes=scopes,
quota_project_id=quota_project_id,
client_info=client_info,
+ always_use_jwt_access=always_use_jwt_access,
)
if not self._grpc_channel:
@@ -209,14 +213,14 @@ def create_channel(
and ``credentials_file`` are passed.
"""
- self_signed_jwt_kwargs = cls._get_self_signed_jwt_kwargs(host, scopes)
-
return grpc_helpers.create_channel(
host,
credentials=credentials,
credentials_file=credentials_file,
quota_project_id=quota_project_id,
- **self_signed_jwt_kwargs,
+ default_scopes=cls.AUTH_SCOPES,
+ scopes=scopes,
+ default_host=cls.DEFAULT_HOST,
**kwargs,
)
@@ -299,6 +303,10 @@ def create_transition_route_group(
[TransitionRouteGroup][google.cloud.dialogflow.cx.v3.TransitionRouteGroup]
in the specified flow.
+ Note: You should always train a flow prior to sending it
+ queries. See the `training
+ documentation `__.
+
Returns:
Callable[[~.CreateTransitionRouteGroupRequest],
~.TransitionRouteGroup]:
@@ -331,6 +339,10 @@ def update_transition_route_group(
Updates the specified
[TransitionRouteGroup][google.cloud.dialogflow.cx.v3.TransitionRouteGroup].
+ Note: You should always train a flow prior to sending it
+ queries. See the `training
+ documentation `__.
+
Returns:
Callable[[~.UpdateTransitionRouteGroupRequest],
~.TransitionRouteGroup]:
@@ -362,6 +374,10 @@ def delete_transition_route_group(
Deletes the specified
[TransitionRouteGroup][google.cloud.dialogflow.cx.v3.TransitionRouteGroup].
+ Note: You should always train a flow prior to sending it
+ queries. See the `training
+ documentation `__.
+
Returns:
Callable[[~.DeleteTransitionRouteGroupRequest],
~.Empty]:
diff --git a/google/cloud/dialogflowcx_v3/services/transition_route_groups/transports/grpc_asyncio.py b/google/cloud/dialogflowcx_v3/services/transition_route_groups/transports/grpc_asyncio.py
index 58e0ce08..f67f5d3f 100644
--- a/google/cloud/dialogflowcx_v3/services/transition_route_groups/transports/grpc_asyncio.py
+++ b/google/cloud/dialogflowcx_v3/services/transition_route_groups/transports/grpc_asyncio.py
@@ -83,14 +83,14 @@ def create_channel(
aio.Channel: A gRPC AsyncIO channel object.
"""
- self_signed_jwt_kwargs = cls._get_self_signed_jwt_kwargs(host, scopes)
-
return grpc_helpers_async.create_channel(
host,
credentials=credentials,
credentials_file=credentials_file,
quota_project_id=quota_project_id,
- **self_signed_jwt_kwargs,
+ default_scopes=cls.AUTH_SCOPES,
+ scopes=scopes,
+ default_host=cls.DEFAULT_HOST,
**kwargs,
)
@@ -108,6 +108,7 @@ def __init__(
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
quota_project_id=None,
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
+ always_use_jwt_access: Optional[bool] = False,
) -> None:
"""Instantiate the transport.
@@ -149,6 +150,8 @@ def __init__(
API requests. If ``None``, then default info will be used.
Generally, you only need to set this if you're developing
your own client library.
+ always_use_jwt_access (Optional[bool]): Whether self signed JWT should
+ be used for service account credentials.
Raises:
google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport
@@ -200,6 +203,7 @@ def __init__(
scopes=scopes,
quota_project_id=quota_project_id,
client_info=client_info,
+ always_use_jwt_access=always_use_jwt_access,
)
if not self._grpc_channel:
@@ -302,6 +306,10 @@ def create_transition_route_group(
[TransitionRouteGroup][google.cloud.dialogflow.cx.v3.TransitionRouteGroup]
in the specified flow.
+ Note: You should always train a flow prior to sending it
+ queries. See the `training
+ documentation `__.
+
Returns:
Callable[[~.CreateTransitionRouteGroupRequest],
Awaitable[~.TransitionRouteGroup]]:
@@ -334,6 +342,10 @@ def update_transition_route_group(
Updates the specified
[TransitionRouteGroup][google.cloud.dialogflow.cx.v3.TransitionRouteGroup].
+ Note: You should always train a flow prior to sending it
+ queries. See the `training
+ documentation `__.
+
Returns:
Callable[[~.UpdateTransitionRouteGroupRequest],
Awaitable[~.TransitionRouteGroup]]:
@@ -366,6 +378,10 @@ def delete_transition_route_group(
Deletes the specified
[TransitionRouteGroup][google.cloud.dialogflow.cx.v3.TransitionRouteGroup].
+ Note: You should always train a flow prior to sending it
+ queries. See the `training
+ documentation `__.
+
Returns:
Callable[[~.DeleteTransitionRouteGroupRequest],
Awaitable[~.Empty]]:
diff --git a/google/cloud/dialogflowcx_v3/services/versions/transports/base.py b/google/cloud/dialogflowcx_v3/services/versions/transports/base.py
index 596f71d1..c6950934 100644
--- a/google/cloud/dialogflowcx_v3/services/versions/transports/base.py
+++ b/google/cloud/dialogflowcx_v3/services/versions/transports/base.py
@@ -25,6 +25,7 @@
from google.api_core import retry as retries # type: ignore
from google.api_core import operations_v1 # type: ignore
from google.auth import credentials as ga_credentials # type: ignore
+from google.oauth2 import service_account # type: ignore
from google.cloud.dialogflowcx_v3.types import version
from google.cloud.dialogflowcx_v3.types import version as gcdc_version
@@ -49,8 +50,6 @@
except pkg_resources.DistributionNotFound: # pragma: NO COVER
_GOOGLE_AUTH_VERSION = None
-_API_CORE_VERSION = google.api_core.__version__
-
class VersionsTransport(abc.ABC):
"""Abstract transport class for Versions."""
@@ -71,6 +70,7 @@ def __init__(
scopes: Optional[Sequence[str]] = None,
quota_project_id: Optional[str] = None,
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
+ always_use_jwt_access: Optional[bool] = False,
**kwargs,
) -> None:
"""Instantiate the transport.
@@ -94,6 +94,8 @@ def __init__(
API requests. If ``None``, then default info will be used.
Generally, you only need to set this if you're developing
your own client library.
+ always_use_jwt_access (Optional[bool]): Whether self signed JWT should
+ be used for service account credentials.
"""
# Save the hostname. Default to port 443 (HTTPS) if none is specified.
if ":" not in host:
@@ -103,7 +105,7 @@ def __init__(
scopes_kwargs = self._get_scopes_kwargs(self._host, scopes)
# Save the scopes.
- self._scopes = scopes or self.AUTH_SCOPES
+ self._scopes = scopes
# If no credentials are provided, then determine the appropriate
# defaults.
@@ -122,13 +124,20 @@ def __init__(
**scopes_kwargs, quota_project_id=quota_project_id
)
+ # If the credentials is service account credentials, then always try to use self signed JWT.
+ if (
+ always_use_jwt_access
+ and isinstance(credentials, service_account.Credentials)
+ and hasattr(service_account.Credentials, "with_always_use_jwt_access")
+ ):
+ credentials = credentials.with_always_use_jwt_access(True)
+
# Save the credentials.
self._credentials = credentials
- # TODO(busunkim): These two class methods are in the base transport
+ # 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-api-core
- # and google-auth are increased.
+ # 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
@@ -149,27 +158,6 @@ def _get_scopes_kwargs(
return scopes_kwargs
- # TODO: Remove this function once google-api-core >= 1.26.0 is required
- @classmethod
- def _get_self_signed_jwt_kwargs(
- cls, host: str, scopes: Optional[Sequence[str]]
- ) -> Dict[str, Union[Optional[Sequence[str]], str]]:
- """Returns kwargs to pass to grpc_helpers.create_channel depending on the google-api-core version"""
-
- self_signed_jwt_kwargs: Dict[str, Union[Optional[Sequence[str]], str]] = {}
-
- if _API_CORE_VERSION and (
- packaging.version.parse(_API_CORE_VERSION)
- >= packaging.version.parse("1.26.0")
- ):
- self_signed_jwt_kwargs["default_scopes"] = cls.AUTH_SCOPES
- self_signed_jwt_kwargs["scopes"] = scopes
- self_signed_jwt_kwargs["default_host"] = cls.DEFAULT_HOST
- else:
- self_signed_jwt_kwargs["scopes"] = scopes or cls.AUTH_SCOPES
-
- return self_signed_jwt_kwargs
-
def _prep_wrapped_messages(self, client_info):
# Precompute the wrapped methods.
self._wrapped_methods = {
diff --git a/google/cloud/dialogflowcx_v3/services/versions/transports/grpc.py b/google/cloud/dialogflowcx_v3/services/versions/transports/grpc.py
index 55989b8a..d26c214c 100644
--- a/google/cloud/dialogflowcx_v3/services/versions/transports/grpc.py
+++ b/google/cloud/dialogflowcx_v3/services/versions/transports/grpc.py
@@ -62,6 +62,7 @@ def __init__(
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
quota_project_id: Optional[str] = None,
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
+ always_use_jwt_access: Optional[bool] = False,
) -> None:
"""Instantiate the transport.
@@ -102,6 +103,8 @@ def __init__(
API requests. If ``None``, then default info will be used.
Generally, you only need to set this if you're developing
your own client library.
+ always_use_jwt_access (Optional[bool]): Whether self signed JWT should
+ be used for service account credentials.
Raises:
google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport
@@ -155,6 +158,7 @@ def __init__(
scopes=scopes,
quota_project_id=quota_project_id,
client_info=client_info,
+ always_use_jwt_access=always_use_jwt_access,
)
if not self._grpc_channel:
@@ -210,14 +214,14 @@ def create_channel(
and ``credentials_file`` are passed.
"""
- self_signed_jwt_kwargs = cls._get_self_signed_jwt_kwargs(host, scopes)
-
return grpc_helpers.create_channel(
host,
credentials=credentials,
credentials_file=credentials_file,
quota_project_id=quota_project_id,
- **self_signed_jwt_kwargs,
+ default_scopes=cls.AUTH_SCOPES,
+ scopes=scopes,
+ default_host=cls.DEFAULT_HOST,
**kwargs,
)
diff --git a/google/cloud/dialogflowcx_v3/services/versions/transports/grpc_asyncio.py b/google/cloud/dialogflowcx_v3/services/versions/transports/grpc_asyncio.py
index e61f15a6..f58db509 100644
--- a/google/cloud/dialogflowcx_v3/services/versions/transports/grpc_asyncio.py
+++ b/google/cloud/dialogflowcx_v3/services/versions/transports/grpc_asyncio.py
@@ -83,14 +83,14 @@ def create_channel(
aio.Channel: A gRPC AsyncIO channel object.
"""
- self_signed_jwt_kwargs = cls._get_self_signed_jwt_kwargs(host, scopes)
-
return grpc_helpers_async.create_channel(
host,
credentials=credentials,
credentials_file=credentials_file,
quota_project_id=quota_project_id,
- **self_signed_jwt_kwargs,
+ default_scopes=cls.AUTH_SCOPES,
+ scopes=scopes,
+ default_host=cls.DEFAULT_HOST,
**kwargs,
)
@@ -108,6 +108,7 @@ def __init__(
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
quota_project_id=None,
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
+ always_use_jwt_access: Optional[bool] = False,
) -> None:
"""Instantiate the transport.
@@ -149,6 +150,8 @@ def __init__(
API requests. If ``None``, then default info will be used.
Generally, you only need to set this if you're developing
your own client library.
+ always_use_jwt_access (Optional[bool]): Whether self signed JWT should
+ be used for service account credentials.
Raises:
google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport
@@ -201,6 +204,7 @@ def __init__(
scopes=scopes,
quota_project_id=quota_project_id,
client_info=client_info,
+ always_use_jwt_access=always_use_jwt_access,
)
if not self._grpc_channel:
diff --git a/google/cloud/dialogflowcx_v3/services/webhooks/transports/base.py b/google/cloud/dialogflowcx_v3/services/webhooks/transports/base.py
index 1ececbf7..ff16859b 100644
--- a/google/cloud/dialogflowcx_v3/services/webhooks/transports/base.py
+++ b/google/cloud/dialogflowcx_v3/services/webhooks/transports/base.py
@@ -24,6 +24,7 @@
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
from google.cloud.dialogflowcx_v3.types import webhook
from google.cloud.dialogflowcx_v3.types import webhook as gcdc_webhook
@@ -47,8 +48,6 @@
except pkg_resources.DistributionNotFound: # pragma: NO COVER
_GOOGLE_AUTH_VERSION = None
-_API_CORE_VERSION = google.api_core.__version__
-
class WebhooksTransport(abc.ABC):
"""Abstract transport class for Webhooks."""
@@ -69,6 +68,7 @@ def __init__(
scopes: Optional[Sequence[str]] = None,
quota_project_id: Optional[str] = None,
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
+ always_use_jwt_access: Optional[bool] = False,
**kwargs,
) -> None:
"""Instantiate the transport.
@@ -92,6 +92,8 @@ def __init__(
API requests. If ``None``, then default info will be used.
Generally, you only need to set this if you're developing
your own client library.
+ always_use_jwt_access (Optional[bool]): Whether self signed JWT should
+ be used for service account credentials.
"""
# Save the hostname. Default to port 443 (HTTPS) if none is specified.
if ":" not in host:
@@ -101,7 +103,7 @@ def __init__(
scopes_kwargs = self._get_scopes_kwargs(self._host, scopes)
# Save the scopes.
- self._scopes = scopes or self.AUTH_SCOPES
+ self._scopes = scopes
# If no credentials are provided, then determine the appropriate
# defaults.
@@ -120,13 +122,20 @@ def __init__(
**scopes_kwargs, quota_project_id=quota_project_id
)
+ # If the credentials is service account credentials, then always try to use self signed JWT.
+ if (
+ always_use_jwt_access
+ and isinstance(credentials, service_account.Credentials)
+ and hasattr(service_account.Credentials, "with_always_use_jwt_access")
+ ):
+ credentials = credentials.with_always_use_jwt_access(True)
+
# Save the credentials.
self._credentials = credentials
- # TODO(busunkim): These two class methods are in the base transport
+ # 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-api-core
- # and google-auth are increased.
+ # 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
@@ -147,27 +156,6 @@ def _get_scopes_kwargs(
return scopes_kwargs
- # TODO: Remove this function once google-api-core >= 1.26.0 is required
- @classmethod
- def _get_self_signed_jwt_kwargs(
- cls, host: str, scopes: Optional[Sequence[str]]
- ) -> Dict[str, Union[Optional[Sequence[str]], str]]:
- """Returns kwargs to pass to grpc_helpers.create_channel depending on the google-api-core version"""
-
- self_signed_jwt_kwargs: Dict[str, Union[Optional[Sequence[str]], str]] = {}
-
- if _API_CORE_VERSION and (
- packaging.version.parse(_API_CORE_VERSION)
- >= packaging.version.parse("1.26.0")
- ):
- self_signed_jwt_kwargs["default_scopes"] = cls.AUTH_SCOPES
- self_signed_jwt_kwargs["scopes"] = scopes
- self_signed_jwt_kwargs["default_host"] = cls.DEFAULT_HOST
- else:
- self_signed_jwt_kwargs["scopes"] = scopes or cls.AUTH_SCOPES
-
- return self_signed_jwt_kwargs
-
def _prep_wrapped_messages(self, client_info):
# Precompute the wrapped methods.
self._wrapped_methods = {
diff --git a/google/cloud/dialogflowcx_v3/services/webhooks/transports/grpc.py b/google/cloud/dialogflowcx_v3/services/webhooks/transports/grpc.py
index 7ce092c6..91cbe743 100644
--- a/google/cloud/dialogflowcx_v3/services/webhooks/transports/grpc.py
+++ b/google/cloud/dialogflowcx_v3/services/webhooks/transports/grpc.py
@@ -60,6 +60,7 @@ def __init__(
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
quota_project_id: Optional[str] = None,
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
+ always_use_jwt_access: Optional[bool] = False,
) -> None:
"""Instantiate the transport.
@@ -100,6 +101,8 @@ def __init__(
API requests. If ``None``, then default info will be used.
Generally, you only need to set this if you're developing
your own client library.
+ always_use_jwt_access (Optional[bool]): Whether self signed JWT should
+ be used for service account credentials.
Raises:
google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport
@@ -152,6 +155,7 @@ def __init__(
scopes=scopes,
quota_project_id=quota_project_id,
client_info=client_info,
+ always_use_jwt_access=always_use_jwt_access,
)
if not self._grpc_channel:
@@ -207,14 +211,14 @@ def create_channel(
and ``credentials_file`` are passed.
"""
- self_signed_jwt_kwargs = cls._get_self_signed_jwt_kwargs(host, scopes)
-
return grpc_helpers.create_channel(
host,
credentials=credentials,
credentials_file=credentials_file,
quota_project_id=quota_project_id,
- **self_signed_jwt_kwargs,
+ default_scopes=cls.AUTH_SCOPES,
+ scopes=scopes,
+ default_host=cls.DEFAULT_HOST,
**kwargs,
)
diff --git a/google/cloud/dialogflowcx_v3/services/webhooks/transports/grpc_asyncio.py b/google/cloud/dialogflowcx_v3/services/webhooks/transports/grpc_asyncio.py
index 7947152f..8fb5962e 100644
--- a/google/cloud/dialogflowcx_v3/services/webhooks/transports/grpc_asyncio.py
+++ b/google/cloud/dialogflowcx_v3/services/webhooks/transports/grpc_asyncio.py
@@ -81,14 +81,14 @@ def create_channel(
aio.Channel: A gRPC AsyncIO channel object.
"""
- self_signed_jwt_kwargs = cls._get_self_signed_jwt_kwargs(host, scopes)
-
return grpc_helpers_async.create_channel(
host,
credentials=credentials,
credentials_file=credentials_file,
quota_project_id=quota_project_id,
- **self_signed_jwt_kwargs,
+ default_scopes=cls.AUTH_SCOPES,
+ scopes=scopes,
+ default_host=cls.DEFAULT_HOST,
**kwargs,
)
@@ -106,6 +106,7 @@ def __init__(
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
quota_project_id=None,
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
+ always_use_jwt_access: Optional[bool] = False,
) -> None:
"""Instantiate the transport.
@@ -147,6 +148,8 @@ def __init__(
API requests. If ``None``, then default info will be used.
Generally, you only need to set this if you're developing
your own client library.
+ always_use_jwt_access (Optional[bool]): Whether self signed JWT should
+ be used for service account credentials.
Raises:
google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport
@@ -198,6 +201,7 @@ def __init__(
scopes=scopes,
quota_project_id=quota_project_id,
client_info=client_info,
+ always_use_jwt_access=always_use_jwt_access,
)
if not self._grpc_channel:
diff --git a/google/cloud/dialogflowcx_v3/types/agent.py b/google/cloud/dialogflowcx_v3/types/agent.py
index 52bec47e..2bdab12a 100644
--- a/google/cloud/dialogflowcx_v3/types/agent.py
+++ b/google/cloud/dialogflowcx_v3/types/agent.py
@@ -77,8 +77,8 @@ class Agent(proto.Message):
Required. The human-readable name of the
agent, unique within the location.
default_language_code (str):
- Immutable. The default language of the agent as a language
- tag. See `Language
+ Required. Immutable. The default language of the agent as a
+ language tag. See `Language
Support `__
for a list of the currently supported language codes. This
field cannot be set by the
diff --git a/google/cloud/dialogflowcx_v3/types/fulfillment.py b/google/cloud/dialogflowcx_v3/types/fulfillment.py
index a4cf0283..c5f9a941 100644
--- a/google/cloud/dialogflowcx_v3/types/fulfillment.py
+++ b/google/cloud/dialogflowcx_v3/types/fulfillment.py
@@ -52,6 +52,19 @@ class Fulfillment(proto.Message):
webhook (str):
The webhook to call. Format:
``projects//locations//agents//webhooks/``.
+ return_partial_responses (bool):
+ Whether Dialogflow should return currently
+ queued fulfillment response messages in
+ streaming APIs. If a webhook is specified, it
+ happens before Dialogflow invokes webhook.
+ Warning:
+ 1) This flag only affects streaming API.
+ Responses are still queued and returned once in
+ non-streaming API.
+ 2) The flag can be enabled in any fulfillment
+ but only the first 3 partial responses will be
+ returned. You may only want to apply it to
+ fulfillments that have slow webhooks.
tag (str):
The tag used by the webhook to identify which fulfillment is
being called. This field is required if ``webhook`` is
@@ -143,6 +156,7 @@ class CaseContent(proto.Message):
proto.MESSAGE, number=1, message=response_message.ResponseMessage,
)
webhook = proto.Field(proto.STRING, number=2,)
+ return_partial_responses = proto.Field(proto.BOOL, number=8,)
tag = proto.Field(proto.STRING, number=3,)
set_parameter_actions = proto.RepeatedField(
proto.MESSAGE, number=4, message=SetParameterAction,
diff --git a/google/cloud/dialogflowcx_v3/types/intent.py b/google/cloud/dialogflowcx_v3/types/intent.py
index 76c3bd0a..4ea72c20 100644
--- a/google/cloud/dialogflowcx_v3/types/intent.py
+++ b/google/cloud/dialogflowcx_v3/types/intent.py
@@ -95,12 +95,12 @@ class Intent(proto.Message):
and values can be no longer than 63 characters and no more
than 128 bytes.
- Prefix "sys." is reserved for Dialogflow defined labels.
+ Prefix "sys-" is reserved for Dialogflow defined labels.
Currently allowed Dialogflow defined labels include:
- - sys.head
- - sys.contextual The above labels do not require value.
- "sys.head" means the intent is a head intent.
+ - sys-head
+ - sys-contextual The above labels do not require value.
+ "sys-head" means the intent is a head intent.
"sys.contextual" means the intent is a contextual intent.
description (str):
Human readable description for better
diff --git a/google/cloud/dialogflowcx_v3/types/security_settings.py b/google/cloud/dialogflowcx_v3/types/security_settings.py
index 4267d511..4dec351e 100644
--- a/google/cloud/dialogflowcx_v3/types/security_settings.py
+++ b/google/cloud/dialogflowcx_v3/types/security_settings.py
@@ -165,8 +165,10 @@ class SecuritySettings(proto.Message):
If empty, we use the default DLP inspect config.
The template name will have one of the following formats:
- ``projects/PROJECT_ID/inspectTemplates/TEMPLATE_ID`` OR
- ``organizations/ORGANIZATION_ID/inspectTemplates/TEMPLATE_ID``
+ ``projects//inspectTemplates/`` OR
+ ``projects//locations//inspectTemplates/``
+ OR
+ ``organizations//inspectTemplates/``
retention_window_days (int):
Retains data in interaction logging for the
specified number of days. This does not apply to
diff --git a/google/cloud/dialogflowcx_v3/types/session.py b/google/cloud/dialogflowcx_v3/types/session.py
index 9eb76709..c58f4ef3 100644
--- a/google/cloud/dialogflowcx_v3/types/session.py
+++ b/google/cloud/dialogflowcx_v3/types/session.py
@@ -116,14 +116,29 @@ class DetectIntentResponse(proto.Message):
output_audio_config (google.cloud.dialogflowcx_v3.types.OutputAudioConfig):
The config used by the speech synthesizer to
generate the output audio.
+ response_type (google.cloud.dialogflowcx_v3.types.DetectIntentResponse.ResponseType):
+ Response type.
+ allow_cancellation (bool):
+ Indicates whether the partial response can be
+ cancelled when a later response arrives. e.g. if
+ the agent specified some music as partial
+ response, it can be cancelled.
"""
+ class ResponseType(proto.Enum):
+ r"""Represents different DetectIntentResponse types."""
+ RESPONSE_TYPE_UNSPECIFIED = 0
+ PARTIAL = 1
+ FINAL = 2
+
response_id = proto.Field(proto.STRING, number=1,)
query_result = proto.Field(proto.MESSAGE, number=2, message="QueryResult",)
output_audio = proto.Field(proto.BYTES, number=4,)
output_audio_config = proto.Field(
proto.MESSAGE, number=5, message=audio_config.OutputAudioConfig,
)
+ response_type = proto.Field(proto.ENUM, number=6, enum=ResponseType,)
+ allow_cancellation = proto.Field(proto.BOOL, number=7,)
class StreamingDetectIntentRequest(proto.Message):
@@ -189,6 +204,11 @@ class StreamingDetectIntentRequest(proto.Message):
output_audio_config (google.cloud.dialogflowcx_v3.types.OutputAudioConfig):
Instructs the speech synthesizer how to
generate the output audio.
+ enable_partial_response (bool):
+ Enable partial detect intent response. If this flag is not
+ enabled, response stream still contains only one final
+ ``DetectIntentResponse`` even if some ``Fulfillment``\ s in
+ the agent have been configured to return partial responses.
"""
session = proto.Field(proto.STRING, number=1,)
@@ -197,6 +217,7 @@ class StreamingDetectIntentRequest(proto.Message):
output_audio_config = proto.Field(
proto.MESSAGE, number=4, message=audio_config.OutputAudioConfig,
)
+ enable_partial_response = proto.Field(proto.BOOL, number=5,)
class StreamingDetectIntentResponse(proto.Message):
@@ -395,7 +416,7 @@ class QueryParameters(proto.Message):
[page][google.cloud.dialogflow.cx.v3.Page] to override the
[current page][QueryResult.current_page] in the session.
Format:
- ``projects//locations//agents//pages/``.
+ ``projects//locations//agents//flows//pages/``.
If ``current_page`` is specified, the previous state of the
session will be ignored by Dialogflow, including the
diff --git a/google/cloud/dialogflowcx_v3beta1/services/agents/async_client.py b/google/cloud/dialogflowcx_v3beta1/services/agents/async_client.py
index 7f0d9740..d2de4d33 100644
--- a/google/cloud/dialogflowcx_v3beta1/services/agents/async_client.py
+++ b/google/cloud/dialogflowcx_v3beta1/services/agents/async_client.py
@@ -354,6 +354,10 @@ async def create_agent(
) -> gcdc_agent.Agent:
r"""Creates an agent in the specified location.
+ Note: You should always train a flow prior to sending it
+ queries. See the `training
+ documentation `__.
+
Args:
request (:class:`google.cloud.dialogflowcx_v3beta1.types.CreateAgentRequest`):
The request object. The request message for
@@ -445,6 +449,10 @@ async def update_agent(
) -> gcdc_agent.Agent:
r"""Updates the specified agent.
+ Note: You should always train a flow prior to sending it
+ queries. See the `training
+ documentation `__.
+
Args:
request (:class:`google.cloud.dialogflowcx_v3beta1.types.UpdateAgentRequest`):
The request object. The request message for
@@ -661,9 +669,14 @@ async def restore_agent(
metadata: Sequence[Tuple[str, str]] = (),
) -> operation_async.AsyncOperation:
r"""Restores the specified agent from a binary file.
+
Replaces the current agent with a new one. Note that all
- existing resources in agent (e.g. intents, entity types,
- flows) will be removed.
+ existing resources in agent (e.g. intents, entity types, flows)
+ will be removed.
+
+ Note: You should always train a flow prior to sending it
+ queries. See the `training
+ documentation `__.
Args:
request (:class:`google.cloud.dialogflowcx_v3beta1.types.RestoreAgentRequest`):
diff --git a/google/cloud/dialogflowcx_v3beta1/services/agents/client.py b/google/cloud/dialogflowcx_v3beta1/services/agents/client.py
index 470a5baf..0eb3b793 100644
--- a/google/cloud/dialogflowcx_v3beta1/services/agents/client.py
+++ b/google/cloud/dialogflowcx_v3beta1/services/agents/client.py
@@ -615,6 +615,10 @@ def create_agent(
) -> gcdc_agent.Agent:
r"""Creates an agent in the specified location.
+ Note: You should always train a flow prior to sending it
+ queries. See the `training
+ documentation `__.
+
Args:
request (google.cloud.dialogflowcx_v3beta1.types.CreateAgentRequest):
The request object. The request message for
@@ -706,6 +710,10 @@ def update_agent(
) -> gcdc_agent.Agent:
r"""Updates the specified agent.
+ Note: You should always train a flow prior to sending it
+ queries. See the `training
+ documentation `__.
+
Args:
request (google.cloud.dialogflowcx_v3beta1.types.UpdateAgentRequest):
The request object. The request message for
@@ -923,9 +931,14 @@ def restore_agent(
metadata: Sequence[Tuple[str, str]] = (),
) -> operation.Operation:
r"""Restores the specified agent from a binary file.
+
Replaces the current agent with a new one. Note that all
- existing resources in agent (e.g. intents, entity types,
- flows) will be removed.
+ existing resources in agent (e.g. intents, entity types, flows)
+ will be removed.
+
+ Note: You should always train a flow prior to sending it
+ queries. See the `training
+ documentation `__.
Args:
request (google.cloud.dialogflowcx_v3beta1.types.RestoreAgentRequest):
diff --git a/google/cloud/dialogflowcx_v3beta1/services/agents/transports/base.py b/google/cloud/dialogflowcx_v3beta1/services/agents/transports/base.py
index 5bd4ea98..c23a2ffb 100644
--- a/google/cloud/dialogflowcx_v3beta1/services/agents/transports/base.py
+++ b/google/cloud/dialogflowcx_v3beta1/services/agents/transports/base.py
@@ -25,6 +25,7 @@
from google.api_core import retry as retries # type: ignore
from google.api_core import operations_v1 # type: ignore
from google.auth import credentials as ga_credentials # type: ignore
+from google.oauth2 import service_account # type: ignore
from google.cloud.dialogflowcx_v3beta1.types import agent
from google.cloud.dialogflowcx_v3beta1.types import agent as gcdc_agent
@@ -49,8 +50,6 @@
except pkg_resources.DistributionNotFound: # pragma: NO COVER
_GOOGLE_AUTH_VERSION = None
-_API_CORE_VERSION = google.api_core.__version__
-
class AgentsTransport(abc.ABC):
"""Abstract transport class for Agents."""
@@ -71,6 +70,7 @@ def __init__(
scopes: Optional[Sequence[str]] = None,
quota_project_id: Optional[str] = None,
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
+ always_use_jwt_access: Optional[bool] = False,
**kwargs,
) -> None:
"""Instantiate the transport.
@@ -94,6 +94,8 @@ def __init__(
API requests. If ``None``, then default info will be used.
Generally, you only need to set this if you're developing
your own client library.
+ always_use_jwt_access (Optional[bool]): Whether self signed JWT should
+ be used for service account credentials.
"""
# Save the hostname. Default to port 443 (HTTPS) if none is specified.
if ":" not in host:
@@ -103,7 +105,7 @@ def __init__(
scopes_kwargs = self._get_scopes_kwargs(self._host, scopes)
# Save the scopes.
- self._scopes = scopes or self.AUTH_SCOPES
+ self._scopes = scopes
# If no credentials are provided, then determine the appropriate
# defaults.
@@ -122,13 +124,20 @@ def __init__(
**scopes_kwargs, quota_project_id=quota_project_id
)
+ # If the credentials is service account credentials, then always try to use self signed JWT.
+ if (
+ always_use_jwt_access
+ and isinstance(credentials, service_account.Credentials)
+ and hasattr(service_account.Credentials, "with_always_use_jwt_access")
+ ):
+ credentials = credentials.with_always_use_jwt_access(True)
+
# Save the credentials.
self._credentials = credentials
- # TODO(busunkim): These two class methods are in the base transport
+ # 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-api-core
- # and google-auth are increased.
+ # 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
@@ -149,27 +158,6 @@ def _get_scopes_kwargs(
return scopes_kwargs
- # TODO: Remove this function once google-api-core >= 1.26.0 is required
- @classmethod
- def _get_self_signed_jwt_kwargs(
- cls, host: str, scopes: Optional[Sequence[str]]
- ) -> Dict[str, Union[Optional[Sequence[str]], str]]:
- """Returns kwargs to pass to grpc_helpers.create_channel depending on the google-api-core version"""
-
- self_signed_jwt_kwargs: Dict[str, Union[Optional[Sequence[str]], str]] = {}
-
- if _API_CORE_VERSION and (
- packaging.version.parse(_API_CORE_VERSION)
- >= packaging.version.parse("1.26.0")
- ):
- self_signed_jwt_kwargs["default_scopes"] = cls.AUTH_SCOPES
- self_signed_jwt_kwargs["scopes"] = scopes
- self_signed_jwt_kwargs["default_host"] = cls.DEFAULT_HOST
- else:
- self_signed_jwt_kwargs["scopes"] = scopes or cls.AUTH_SCOPES
-
- return self_signed_jwt_kwargs
-
def _prep_wrapped_messages(self, client_info):
# Precompute the wrapped methods.
self._wrapped_methods = {
diff --git a/google/cloud/dialogflowcx_v3beta1/services/agents/transports/grpc.py b/google/cloud/dialogflowcx_v3beta1/services/agents/transports/grpc.py
index b3de9352..39c6d1b9 100644
--- a/google/cloud/dialogflowcx_v3beta1/services/agents/transports/grpc.py
+++ b/google/cloud/dialogflowcx_v3beta1/services/agents/transports/grpc.py
@@ -62,6 +62,7 @@ def __init__(
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
quota_project_id: Optional[str] = None,
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
+ always_use_jwt_access: Optional[bool] = False,
) -> None:
"""Instantiate the transport.
@@ -102,6 +103,8 @@ def __init__(
API requests. If ``None``, then default info will be used.
Generally, you only need to set this if you're developing
your own client library.
+ always_use_jwt_access (Optional[bool]): Whether self signed JWT should
+ be used for service account credentials.
Raises:
google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport
@@ -155,6 +158,7 @@ def __init__(
scopes=scopes,
quota_project_id=quota_project_id,
client_info=client_info,
+ always_use_jwt_access=always_use_jwt_access,
)
if not self._grpc_channel:
@@ -210,14 +214,14 @@ def create_channel(
and ``credentials_file`` are passed.
"""
- self_signed_jwt_kwargs = cls._get_self_signed_jwt_kwargs(host, scopes)
-
return grpc_helpers.create_channel(
host,
credentials=credentials,
credentials_file=credentials_file,
quota_project_id=quota_project_id,
- **self_signed_jwt_kwargs,
+ default_scopes=cls.AUTH_SCOPES,
+ scopes=scopes,
+ default_host=cls.DEFAULT_HOST,
**kwargs,
)
@@ -300,6 +304,10 @@ def create_agent(
Creates an agent in the specified location.
+ Note: You should always train a flow prior to sending it
+ queries. See the `training
+ documentation `__.
+
Returns:
Callable[[~.CreateAgentRequest],
~.Agent]:
@@ -326,6 +334,10 @@ def update_agent(
Updates the specified agent.
+ Note: You should always train a flow prior to sending it
+ queries. See the `training
+ documentation `__.
+
Returns:
Callable[[~.UpdateAgentRequest],
~.Agent]:
@@ -401,9 +413,14 @@ def restore_agent(
r"""Return a callable for the restore agent method over gRPC.
Restores the specified agent from a binary file.
+
Replaces the current agent with a new one. Note that all
- existing resources in agent (e.g. intents, entity types,
- flows) will be removed.
+ existing resources in agent (e.g. intents, entity types, flows)
+ will be removed.
+
+ Note: You should always train a flow prior to sending it
+ queries. See the `training
+ documentation `__.
Returns:
Callable[[~.RestoreAgentRequest],
diff --git a/google/cloud/dialogflowcx_v3beta1/services/agents/transports/grpc_asyncio.py b/google/cloud/dialogflowcx_v3beta1/services/agents/transports/grpc_asyncio.py
index bdcd0538..195663d9 100644
--- a/google/cloud/dialogflowcx_v3beta1/services/agents/transports/grpc_asyncio.py
+++ b/google/cloud/dialogflowcx_v3beta1/services/agents/transports/grpc_asyncio.py
@@ -83,14 +83,14 @@ def create_channel(
aio.Channel: A gRPC AsyncIO channel object.
"""
- self_signed_jwt_kwargs = cls._get_self_signed_jwt_kwargs(host, scopes)
-
return grpc_helpers_async.create_channel(
host,
credentials=credentials,
credentials_file=credentials_file,
quota_project_id=quota_project_id,
- **self_signed_jwt_kwargs,
+ default_scopes=cls.AUTH_SCOPES,
+ scopes=scopes,
+ default_host=cls.DEFAULT_HOST,
**kwargs,
)
@@ -108,6 +108,7 @@ def __init__(
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
quota_project_id=None,
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
+ always_use_jwt_access: Optional[bool] = False,
) -> None:
"""Instantiate the transport.
@@ -149,6 +150,8 @@ def __init__(
API requests. If ``None``, then default info will be used.
Generally, you only need to set this if you're developing
your own client library.
+ always_use_jwt_access (Optional[bool]): Whether self signed JWT should
+ be used for service account credentials.
Raises:
google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport
@@ -201,6 +204,7 @@ def __init__(
scopes=scopes,
quota_project_id=quota_project_id,
client_info=client_info,
+ always_use_jwt_access=always_use_jwt_access,
)
if not self._grpc_channel:
@@ -305,6 +309,10 @@ def create_agent(
Creates an agent in the specified location.
+ Note: You should always train a flow prior to sending it
+ queries. See the `training
+ documentation `__.
+
Returns:
Callable[[~.CreateAgentRequest],
Awaitable[~.Agent]]:
@@ -331,6 +339,10 @@ def update_agent(
Updates the specified agent.
+ Note: You should always train a flow prior to sending it
+ queries. See the `training
+ documentation `__.
+
Returns:
Callable[[~.UpdateAgentRequest],
Awaitable[~.Agent]]:
@@ -408,9 +420,14 @@ def restore_agent(
r"""Return a callable for the restore agent method over gRPC.
Restores the specified agent from a binary file.
+
Replaces the current agent with a new one. Note that all
- existing resources in agent (e.g. intents, entity types,
- flows) will be removed.
+ existing resources in agent (e.g. intents, entity types, flows)
+ will be removed.
+
+ Note: You should always train a flow prior to sending it
+ queries. See the `training
+ documentation `__.
Returns:
Callable[[~.RestoreAgentRequest],
diff --git a/google/cloud/dialogflowcx_v3beta1/services/entity_types/async_client.py b/google/cloud/dialogflowcx_v3beta1/services/entity_types/async_client.py
index dda5c1e4..d6783258 100644
--- a/google/cloud/dialogflowcx_v3beta1/services/entity_types/async_client.py
+++ b/google/cloud/dialogflowcx_v3beta1/services/entity_types/async_client.py
@@ -469,6 +469,10 @@ async def update_entity_type(
) -> gcdc_entity_type.EntityType:
r"""Updates the specified entity type.
+ Note: You should always train a flow prior to sending it
+ queries. See the `training
+ documentation `__.
+
Args:
request (:class:`google.cloud.dialogflowcx_v3beta1.types.UpdateEntityTypeRequest`):
The request object. The request message for
@@ -581,6 +585,10 @@ async def delete_entity_type(
) -> None:
r"""Deletes the specified entity type.
+ Note: You should always train a flow prior to sending it
+ queries. See the `training
+ documentation `__.
+
Args:
request (:class:`google.cloud.dialogflowcx_v3beta1.types.DeleteEntityTypeRequest`):
The request object. The request message for
diff --git a/google/cloud/dialogflowcx_v3beta1/services/entity_types/client.py b/google/cloud/dialogflowcx_v3beta1/services/entity_types/client.py
index 77b0b2bc..791108c7 100644
--- a/google/cloud/dialogflowcx_v3beta1/services/entity_types/client.py
+++ b/google/cloud/dialogflowcx_v3beta1/services/entity_types/client.py
@@ -658,6 +658,10 @@ def update_entity_type(
) -> gcdc_entity_type.EntityType:
r"""Updates the specified entity type.
+ Note: You should always train a flow prior to sending it
+ queries. See the `training
+ documentation `__.
+
Args:
request (google.cloud.dialogflowcx_v3beta1.types.UpdateEntityTypeRequest):
The request object. The request message for
@@ -770,6 +774,10 @@ def delete_entity_type(
) -> None:
r"""Deletes the specified entity type.
+ Note: You should always train a flow prior to sending it
+ queries. See the `training
+ documentation `__.
+
Args:
request (google.cloud.dialogflowcx_v3beta1.types.DeleteEntityTypeRequest):
The request object. The request message for
diff --git a/google/cloud/dialogflowcx_v3beta1/services/entity_types/transports/base.py b/google/cloud/dialogflowcx_v3beta1/services/entity_types/transports/base.py
index 7776bc6b..63558e18 100644
--- a/google/cloud/dialogflowcx_v3beta1/services/entity_types/transports/base.py
+++ b/google/cloud/dialogflowcx_v3beta1/services/entity_types/transports/base.py
@@ -24,6 +24,7 @@
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
from google.cloud.dialogflowcx_v3beta1.types import entity_type
from google.cloud.dialogflowcx_v3beta1.types import entity_type as gcdc_entity_type
@@ -47,8 +48,6 @@
except pkg_resources.DistributionNotFound: # pragma: NO COVER
_GOOGLE_AUTH_VERSION = None
-_API_CORE_VERSION = google.api_core.__version__
-
class EntityTypesTransport(abc.ABC):
"""Abstract transport class for EntityTypes."""
@@ -69,6 +68,7 @@ def __init__(
scopes: Optional[Sequence[str]] = None,
quota_project_id: Optional[str] = None,
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
+ always_use_jwt_access: Optional[bool] = False,
**kwargs,
) -> None:
"""Instantiate the transport.
@@ -92,6 +92,8 @@ def __init__(
API requests. If ``None``, then default info will be used.
Generally, you only need to set this if you're developing
your own client library.
+ always_use_jwt_access (Optional[bool]): Whether self signed JWT should
+ be used for service account credentials.
"""
# Save the hostname. Default to port 443 (HTTPS) if none is specified.
if ":" not in host:
@@ -101,7 +103,7 @@ def __init__(
scopes_kwargs = self._get_scopes_kwargs(self._host, scopes)
# Save the scopes.
- self._scopes = scopes or self.AUTH_SCOPES
+ self._scopes = scopes
# If no credentials are provided, then determine the appropriate
# defaults.
@@ -120,13 +122,20 @@ def __init__(
**scopes_kwargs, quota_project_id=quota_project_id
)
+ # If the credentials is service account credentials, then always try to use self signed JWT.
+ if (
+ always_use_jwt_access
+ and isinstance(credentials, service_account.Credentials)
+ and hasattr(service_account.Credentials, "with_always_use_jwt_access")
+ ):
+ credentials = credentials.with_always_use_jwt_access(True)
+
# Save the credentials.
self._credentials = credentials
- # TODO(busunkim): These two class methods are in the base transport
+ # 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-api-core
- # and google-auth are increased.
+ # 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
@@ -147,27 +156,6 @@ def _get_scopes_kwargs(
return scopes_kwargs
- # TODO: Remove this function once google-api-core >= 1.26.0 is required
- @classmethod
- def _get_self_signed_jwt_kwargs(
- cls, host: str, scopes: Optional[Sequence[str]]
- ) -> Dict[str, Union[Optional[Sequence[str]], str]]:
- """Returns kwargs to pass to grpc_helpers.create_channel depending on the google-api-core version"""
-
- self_signed_jwt_kwargs: Dict[str, Union[Optional[Sequence[str]], str]] = {}
-
- if _API_CORE_VERSION and (
- packaging.version.parse(_API_CORE_VERSION)
- >= packaging.version.parse("1.26.0")
- ):
- self_signed_jwt_kwargs["default_scopes"] = cls.AUTH_SCOPES
- self_signed_jwt_kwargs["scopes"] = scopes
- self_signed_jwt_kwargs["default_host"] = cls.DEFAULT_HOST
- else:
- self_signed_jwt_kwargs["scopes"] = scopes or cls.AUTH_SCOPES
-
- return self_signed_jwt_kwargs
-
def _prep_wrapped_messages(self, client_info):
# Precompute the wrapped methods.
self._wrapped_methods = {
diff --git a/google/cloud/dialogflowcx_v3beta1/services/entity_types/transports/grpc.py b/google/cloud/dialogflowcx_v3beta1/services/entity_types/transports/grpc.py
index a709a61c..bd5823bd 100644
--- a/google/cloud/dialogflowcx_v3beta1/services/entity_types/transports/grpc.py
+++ b/google/cloud/dialogflowcx_v3beta1/services/entity_types/transports/grpc.py
@@ -60,6 +60,7 @@ def __init__(
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
quota_project_id: Optional[str] = None,
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
+ always_use_jwt_access: Optional[bool] = False,
) -> None:
"""Instantiate the transport.
@@ -100,6 +101,8 @@ def __init__(
API requests. If ``None``, then default info will be used.
Generally, you only need to set this if you're developing
your own client library.
+ always_use_jwt_access (Optional[bool]): Whether self signed JWT should
+ be used for service account credentials.
Raises:
google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport
@@ -152,6 +155,7 @@ def __init__(
scopes=scopes,
quota_project_id=quota_project_id,
client_info=client_info,
+ always_use_jwt_access=always_use_jwt_access,
)
if not self._grpc_channel:
@@ -207,14 +211,14 @@ def create_channel(
and ``credentials_file`` are passed.
"""
- self_signed_jwt_kwargs = cls._get_self_signed_jwt_kwargs(host, scopes)
-
return grpc_helpers.create_channel(
host,
credentials=credentials,
credentials_file=credentials_file,
quota_project_id=quota_project_id,
- **self_signed_jwt_kwargs,
+ default_scopes=cls.AUTH_SCOPES,
+ scopes=scopes,
+ default_host=cls.DEFAULT_HOST,
**kwargs,
)
@@ -317,6 +321,10 @@ def update_entity_type(
Updates the specified entity type.
+ Note: You should always train a flow prior to sending it
+ queries. See the `training
+ documentation `__.
+
Returns:
Callable[[~.UpdateEntityTypeRequest],
~.EntityType]:
@@ -343,6 +351,10 @@ def delete_entity_type(
Deletes the specified entity type.
+ Note: You should always train a flow prior to sending it
+ queries. See the `training
+ documentation `__.
+
Returns:
Callable[[~.DeleteEntityTypeRequest],
~.Empty]:
diff --git a/google/cloud/dialogflowcx_v3beta1/services/entity_types/transports/grpc_asyncio.py b/google/cloud/dialogflowcx_v3beta1/services/entity_types/transports/grpc_asyncio.py
index c565b0fc..918ec7e6 100644
--- a/google/cloud/dialogflowcx_v3beta1/services/entity_types/transports/grpc_asyncio.py
+++ b/google/cloud/dialogflowcx_v3beta1/services/entity_types/transports/grpc_asyncio.py
@@ -81,14 +81,14 @@ def create_channel(
aio.Channel: A gRPC AsyncIO channel object.
"""
- self_signed_jwt_kwargs = cls._get_self_signed_jwt_kwargs(host, scopes)
-
return grpc_helpers_async.create_channel(
host,
credentials=credentials,
credentials_file=credentials_file,
quota_project_id=quota_project_id,
- **self_signed_jwt_kwargs,
+ default_scopes=cls.AUTH_SCOPES,
+ scopes=scopes,
+ default_host=cls.DEFAULT_HOST,
**kwargs,
)
@@ -106,6 +106,7 @@ def __init__(
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
quota_project_id=None,
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
+ always_use_jwt_access: Optional[bool] = False,
) -> None:
"""Instantiate the transport.
@@ -147,6 +148,8 @@ def __init__(
API requests. If ``None``, then default info will be used.
Generally, you only need to set this if you're developing
your own client library.
+ always_use_jwt_access (Optional[bool]): Whether self signed JWT should
+ be used for service account credentials.
Raises:
google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport
@@ -198,6 +201,7 @@ def __init__(
scopes=scopes,
quota_project_id=quota_project_id,
client_info=client_info,
+ always_use_jwt_access=always_use_jwt_access,
)
if not self._grpc_channel:
@@ -325,6 +329,10 @@ def update_entity_type(
Updates the specified entity type.
+ Note: You should always train a flow prior to sending it
+ queries. See the `training
+ documentation `__.
+
Returns:
Callable[[~.UpdateEntityTypeRequest],
Awaitable[~.EntityType]]:
@@ -351,6 +359,10 @@ def delete_entity_type(
Deletes the specified entity type.
+ Note: You should always train a flow prior to sending it
+ queries. See the `training
+ documentation `__.
+
Returns:
Callable[[~.DeleteEntityTypeRequest],
Awaitable[~.Empty]]:
diff --git a/google/cloud/dialogflowcx_v3beta1/services/environments/transports/base.py b/google/cloud/dialogflowcx_v3beta1/services/environments/transports/base.py
index 697d55f9..5ee2f205 100644
--- a/google/cloud/dialogflowcx_v3beta1/services/environments/transports/base.py
+++ b/google/cloud/dialogflowcx_v3beta1/services/environments/transports/base.py
@@ -25,6 +25,7 @@
from google.api_core import retry as retries # type: ignore
from google.api_core import operations_v1 # type: ignore
from google.auth import credentials as ga_credentials # type: ignore
+from google.oauth2 import service_account # type: ignore
from google.cloud.dialogflowcx_v3beta1.types import environment
from google.cloud.dialogflowcx_v3beta1.types import environment as gcdc_environment
@@ -49,8 +50,6 @@
except pkg_resources.DistributionNotFound: # pragma: NO COVER
_GOOGLE_AUTH_VERSION = None
-_API_CORE_VERSION = google.api_core.__version__
-
class EnvironmentsTransport(abc.ABC):
"""Abstract transport class for Environments."""
@@ -71,6 +70,7 @@ def __init__(
scopes: Optional[Sequence[str]] = None,
quota_project_id: Optional[str] = None,
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
+ always_use_jwt_access: Optional[bool] = False,
**kwargs,
) -> None:
"""Instantiate the transport.
@@ -94,6 +94,8 @@ def __init__(
API requests. If ``None``, then default info will be used.
Generally, you only need to set this if you're developing
your own client library.
+ always_use_jwt_access (Optional[bool]): Whether self signed JWT should
+ be used for service account credentials.
"""
# Save the hostname. Default to port 443 (HTTPS) if none is specified.
if ":" not in host:
@@ -103,7 +105,7 @@ def __init__(
scopes_kwargs = self._get_scopes_kwargs(self._host, scopes)
# Save the scopes.
- self._scopes = scopes or self.AUTH_SCOPES
+ self._scopes = scopes
# If no credentials are provided, then determine the appropriate
# defaults.
@@ -122,13 +124,20 @@ def __init__(
**scopes_kwargs, quota_project_id=quota_project_id
)
+ # If the credentials is service account credentials, then always try to use self signed JWT.
+ if (
+ always_use_jwt_access
+ and isinstance(credentials, service_account.Credentials)
+ and hasattr(service_account.Credentials, "with_always_use_jwt_access")
+ ):
+ credentials = credentials.with_always_use_jwt_access(True)
+
# Save the credentials.
self._credentials = credentials
- # TODO(busunkim): These two class methods are in the base transport
+ # 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-api-core
- # and google-auth are increased.
+ # 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
@@ -149,27 +158,6 @@ def _get_scopes_kwargs(
return scopes_kwargs
- # TODO: Remove this function once google-api-core >= 1.26.0 is required
- @classmethod
- def _get_self_signed_jwt_kwargs(
- cls, host: str, scopes: Optional[Sequence[str]]
- ) -> Dict[str, Union[Optional[Sequence[str]], str]]:
- """Returns kwargs to pass to grpc_helpers.create_channel depending on the google-api-core version"""
-
- self_signed_jwt_kwargs: Dict[str, Union[Optional[Sequence[str]], str]] = {}
-
- if _API_CORE_VERSION and (
- packaging.version.parse(_API_CORE_VERSION)
- >= packaging.version.parse("1.26.0")
- ):
- self_signed_jwt_kwargs["default_scopes"] = cls.AUTH_SCOPES
- self_signed_jwt_kwargs["scopes"] = scopes
- self_signed_jwt_kwargs["default_host"] = cls.DEFAULT_HOST
- else:
- self_signed_jwt_kwargs["scopes"] = scopes or cls.AUTH_SCOPES
-
- return self_signed_jwt_kwargs
-
def _prep_wrapped_messages(self, client_info):
# Precompute the wrapped methods.
self._wrapped_methods = {
diff --git a/google/cloud/dialogflowcx_v3beta1/services/environments/transports/grpc.py b/google/cloud/dialogflowcx_v3beta1/services/environments/transports/grpc.py
index 6d0a6c9a..a56496d1 100644
--- a/google/cloud/dialogflowcx_v3beta1/services/environments/transports/grpc.py
+++ b/google/cloud/dialogflowcx_v3beta1/services/environments/transports/grpc.py
@@ -62,6 +62,7 @@ def __init__(
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
quota_project_id: Optional[str] = None,
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
+ always_use_jwt_access: Optional[bool] = False,
) -> None:
"""Instantiate the transport.
@@ -102,6 +103,8 @@ def __init__(
API requests. If ``None``, then default info will be used.
Generally, you only need to set this if you're developing
your own client library.
+ always_use_jwt_access (Optional[bool]): Whether self signed JWT should
+ be used for service account credentials.
Raises:
google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport
@@ -155,6 +158,7 @@ def __init__(
scopes=scopes,
quota_project_id=quota_project_id,
client_info=client_info,
+ always_use_jwt_access=always_use_jwt_access,
)
if not self._grpc_channel:
@@ -210,14 +214,14 @@ def create_channel(
and ``credentials_file`` are passed.
"""
- self_signed_jwt_kwargs = cls._get_self_signed_jwt_kwargs(host, scopes)
-
return grpc_helpers.create_channel(
host,
credentials=credentials,
credentials_file=credentials_file,
quota_project_id=quota_project_id,
- **self_signed_jwt_kwargs,
+ default_scopes=cls.AUTH_SCOPES,
+ scopes=scopes,
+ default_host=cls.DEFAULT_HOST,
**kwargs,
)
diff --git a/google/cloud/dialogflowcx_v3beta1/services/environments/transports/grpc_asyncio.py b/google/cloud/dialogflowcx_v3beta1/services/environments/transports/grpc_asyncio.py
index da9d3392..2d6bfcc0 100644
--- a/google/cloud/dialogflowcx_v3beta1/services/environments/transports/grpc_asyncio.py
+++ b/google/cloud/dialogflowcx_v3beta1/services/environments/transports/grpc_asyncio.py
@@ -83,14 +83,14 @@ def create_channel(
aio.Channel: A gRPC AsyncIO channel object.
"""
- self_signed_jwt_kwargs = cls._get_self_signed_jwt_kwargs(host, scopes)
-
return grpc_helpers_async.create_channel(
host,
credentials=credentials,
credentials_file=credentials_file,
quota_project_id=quota_project_id,
- **self_signed_jwt_kwargs,
+ default_scopes=cls.AUTH_SCOPES,
+ scopes=scopes,
+ default_host=cls.DEFAULT_HOST,
**kwargs,
)
@@ -108,6 +108,7 @@ def __init__(
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
quota_project_id=None,
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
+ always_use_jwt_access: Optional[bool] = False,
) -> None:
"""Instantiate the transport.
@@ -149,6 +150,8 @@ def __init__(
API requests. If ``None``, then default info will be used.
Generally, you only need to set this if you're developing
your own client library.
+ always_use_jwt_access (Optional[bool]): Whether self signed JWT should
+ be used for service account credentials.
Raises:
google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport
@@ -201,6 +204,7 @@ def __init__(
scopes=scopes,
quota_project_id=quota_project_id,
client_info=client_info,
+ always_use_jwt_access=always_use_jwt_access,
)
if not self._grpc_channel:
diff --git a/google/cloud/dialogflowcx_v3beta1/services/experiments/transports/base.py b/google/cloud/dialogflowcx_v3beta1/services/experiments/transports/base.py
index de090ca9..2ef669b2 100644
--- a/google/cloud/dialogflowcx_v3beta1/services/experiments/transports/base.py
+++ b/google/cloud/dialogflowcx_v3beta1/services/experiments/transports/base.py
@@ -24,6 +24,7 @@
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
from google.cloud.dialogflowcx_v3beta1.types import experiment
from google.cloud.dialogflowcx_v3beta1.types import experiment as gcdc_experiment
@@ -47,8 +48,6 @@
except pkg_resources.DistributionNotFound: # pragma: NO COVER
_GOOGLE_AUTH_VERSION = None
-_API_CORE_VERSION = google.api_core.__version__
-
class ExperimentsTransport(abc.ABC):
"""Abstract transport class for Experiments."""
@@ -69,6 +68,7 @@ def __init__(
scopes: Optional[Sequence[str]] = None,
quota_project_id: Optional[str] = None,
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
+ always_use_jwt_access: Optional[bool] = False,
**kwargs,
) -> None:
"""Instantiate the transport.
@@ -92,6 +92,8 @@ def __init__(
API requests. If ``None``, then default info will be used.
Generally, you only need to set this if you're developing
your own client library.
+ always_use_jwt_access (Optional[bool]): Whether self signed JWT should
+ be used for service account credentials.
"""
# Save the hostname. Default to port 443 (HTTPS) if none is specified.
if ":" not in host:
@@ -101,7 +103,7 @@ def __init__(
scopes_kwargs = self._get_scopes_kwargs(self._host, scopes)
# Save the scopes.
- self._scopes = scopes or self.AUTH_SCOPES
+ self._scopes = scopes
# If no credentials are provided, then determine the appropriate
# defaults.
@@ -120,13 +122,20 @@ def __init__(
**scopes_kwargs, quota_project_id=quota_project_id
)
+ # If the credentials is service account credentials, then always try to use self signed JWT.
+ if (
+ always_use_jwt_access
+ and isinstance(credentials, service_account.Credentials)
+ and hasattr(service_account.Credentials, "with_always_use_jwt_access")
+ ):
+ credentials = credentials.with_always_use_jwt_access(True)
+
# Save the credentials.
self._credentials = credentials
- # TODO(busunkim): These two class methods are in the base transport
+ # 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-api-core
- # and google-auth are increased.
+ # 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
@@ -147,27 +156,6 @@ def _get_scopes_kwargs(
return scopes_kwargs
- # TODO: Remove this function once google-api-core >= 1.26.0 is required
- @classmethod
- def _get_self_signed_jwt_kwargs(
- cls, host: str, scopes: Optional[Sequence[str]]
- ) -> Dict[str, Union[Optional[Sequence[str]], str]]:
- """Returns kwargs to pass to grpc_helpers.create_channel depending on the google-api-core version"""
-
- self_signed_jwt_kwargs: Dict[str, Union[Optional[Sequence[str]], str]] = {}
-
- if _API_CORE_VERSION and (
- packaging.version.parse(_API_CORE_VERSION)
- >= packaging.version.parse("1.26.0")
- ):
- self_signed_jwt_kwargs["default_scopes"] = cls.AUTH_SCOPES
- self_signed_jwt_kwargs["scopes"] = scopes
- self_signed_jwt_kwargs["default_host"] = cls.DEFAULT_HOST
- else:
- self_signed_jwt_kwargs["scopes"] = scopes or cls.AUTH_SCOPES
-
- return self_signed_jwt_kwargs
-
def _prep_wrapped_messages(self, client_info):
# Precompute the wrapped methods.
self._wrapped_methods = {
diff --git a/google/cloud/dialogflowcx_v3beta1/services/experiments/transports/grpc.py b/google/cloud/dialogflowcx_v3beta1/services/experiments/transports/grpc.py
index 688fc771..93b5e9be 100644
--- a/google/cloud/dialogflowcx_v3beta1/services/experiments/transports/grpc.py
+++ b/google/cloud/dialogflowcx_v3beta1/services/experiments/transports/grpc.py
@@ -60,6 +60,7 @@ def __init__(
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
quota_project_id: Optional[str] = None,
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
+ always_use_jwt_access: Optional[bool] = False,
) -> None:
"""Instantiate the transport.
@@ -100,6 +101,8 @@ def __init__(
API requests. If ``None``, then default info will be used.
Generally, you only need to set this if you're developing
your own client library.
+ always_use_jwt_access (Optional[bool]): Whether self signed JWT should
+ be used for service account credentials.
Raises:
google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport
@@ -152,6 +155,7 @@ def __init__(
scopes=scopes,
quota_project_id=quota_project_id,
client_info=client_info,
+ always_use_jwt_access=always_use_jwt_access,
)
if not self._grpc_channel:
@@ -207,14 +211,14 @@ def create_channel(
and ``credentials_file`` are passed.
"""
- self_signed_jwt_kwargs = cls._get_self_signed_jwt_kwargs(host, scopes)
-
return grpc_helpers.create_channel(
host,
credentials=credentials,
credentials_file=credentials_file,
quota_project_id=quota_project_id,
- **self_signed_jwt_kwargs,
+ default_scopes=cls.AUTH_SCOPES,
+ scopes=scopes,
+ default_host=cls.DEFAULT_HOST,
**kwargs,
)
diff --git a/google/cloud/dialogflowcx_v3beta1/services/experiments/transports/grpc_asyncio.py b/google/cloud/dialogflowcx_v3beta1/services/experiments/transports/grpc_asyncio.py
index d56b58cd..47425f1e 100644
--- a/google/cloud/dialogflowcx_v3beta1/services/experiments/transports/grpc_asyncio.py
+++ b/google/cloud/dialogflowcx_v3beta1/services/experiments/transports/grpc_asyncio.py
@@ -81,14 +81,14 @@ def create_channel(
aio.Channel: A gRPC AsyncIO channel object.
"""
- self_signed_jwt_kwargs = cls._get_self_signed_jwt_kwargs(host, scopes)
-
return grpc_helpers_async.create_channel(
host,
credentials=credentials,
credentials_file=credentials_file,
quota_project_id=quota_project_id,
- **self_signed_jwt_kwargs,
+ default_scopes=cls.AUTH_SCOPES,
+ scopes=scopes,
+ default_host=cls.DEFAULT_HOST,
**kwargs,
)
@@ -106,6 +106,7 @@ def __init__(
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
quota_project_id=None,
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
+ always_use_jwt_access: Optional[bool] = False,
) -> None:
"""Instantiate the transport.
@@ -147,6 +148,8 @@ def __init__(
API requests. If ``None``, then default info will be used.
Generally, you only need to set this if you're developing
your own client library.
+ always_use_jwt_access (Optional[bool]): Whether self signed JWT should
+ be used for service account credentials.
Raises:
google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport
@@ -198,6 +201,7 @@ def __init__(
scopes=scopes,
quota_project_id=quota_project_id,
client_info=client_info,
+ always_use_jwt_access=always_use_jwt_access,
)
if not self._grpc_channel:
diff --git a/google/cloud/dialogflowcx_v3beta1/services/flows/async_client.py b/google/cloud/dialogflowcx_v3beta1/services/flows/async_client.py
index 53b414fb..36aa1327 100644
--- a/google/cloud/dialogflowcx_v3beta1/services/flows/async_client.py
+++ b/google/cloud/dialogflowcx_v3beta1/services/flows/async_client.py
@@ -188,6 +188,10 @@ async def create_flow(
) -> gcdc_flow.Flow:
r"""Creates a flow in the specified agent.
+ Note: You should always train a flow prior to sending it
+ queries. See the `training
+ documentation `__.
+
Args:
request (:class:`google.cloud.dialogflowcx_v3beta1.types.CreateFlowRequest`):
The request object. The request message for
@@ -524,6 +528,10 @@ async def update_flow(
) -> gcdc_flow.Flow:
r"""Updates the specified flow.
+ Note: You should always train a flow prior to sending it
+ queries. See the `training
+ documentation `__.
+
Args:
request (:class:`google.cloud.dialogflowcx_v3beta1.types.UpdateFlowRequest`):
The request object. The request message for
@@ -624,8 +632,12 @@ async def train_flow(
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> operation_async.AsyncOperation:
- r"""Trains the specified flow. Note that only the flow in
- 'draft' environment is trained.
+ r"""Trains the specified flow. Note that only the flow in 'draft'
+ environment is trained.
+
+ Note: You should always train a flow prior to sending it
+ queries. See the `training
+ documentation `__.
Args:
request (:class:`google.cloud.dialogflowcx_v3beta1.types.TrainFlowRequest`):
@@ -840,8 +852,12 @@ async def import_flow(
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> operation_async.AsyncOperation:
- r"""Imports the specified flow to the specified agent
- from a binary file.
+ r"""Imports the specified flow to the specified agent from a binary
+ file.
+
+ Note: You should always train a flow prior to sending it
+ queries. See the `training
+ documentation `__.
Args:
request (:class:`google.cloud.dialogflowcx_v3beta1.types.ImportFlowRequest`):
diff --git a/google/cloud/dialogflowcx_v3beta1/services/flows/client.py b/google/cloud/dialogflowcx_v3beta1/services/flows/client.py
index 0f081120..dd898a12 100644
--- a/google/cloud/dialogflowcx_v3beta1/services/flows/client.py
+++ b/google/cloud/dialogflowcx_v3beta1/services/flows/client.py
@@ -457,6 +457,10 @@ def create_flow(
) -> gcdc_flow.Flow:
r"""Creates a flow in the specified agent.
+ Note: You should always train a flow prior to sending it
+ queries. See the `training
+ documentation `__.
+
Args:
request (google.cloud.dialogflowcx_v3beta1.types.CreateFlowRequest):
The request object. The request message for
@@ -793,6 +797,10 @@ def update_flow(
) -> gcdc_flow.Flow:
r"""Updates the specified flow.
+ Note: You should always train a flow prior to sending it
+ queries. See the `training
+ documentation `__.
+
Args:
request (google.cloud.dialogflowcx_v3beta1.types.UpdateFlowRequest):
The request object. The request message for
@@ -893,8 +901,12 @@ def train_flow(
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> operation.Operation:
- r"""Trains the specified flow. Note that only the flow in
- 'draft' environment is trained.
+ r"""Trains the specified flow. Note that only the flow in 'draft'
+ environment is trained.
+
+ Note: You should always train a flow prior to sending it
+ queries. See the `training
+ documentation `__.
Args:
request (google.cloud.dialogflowcx_v3beta1.types.TrainFlowRequest):
@@ -1112,8 +1124,12 @@ def import_flow(
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> operation.Operation:
- r"""Imports the specified flow to the specified agent
- from a binary file.
+ r"""Imports the specified flow to the specified agent from a binary
+ file.
+
+ Note: You should always train a flow prior to sending it
+ queries. See the `training
+ documentation `__.
Args:
request (google.cloud.dialogflowcx_v3beta1.types.ImportFlowRequest):
diff --git a/google/cloud/dialogflowcx_v3beta1/services/flows/transports/base.py b/google/cloud/dialogflowcx_v3beta1/services/flows/transports/base.py
index eda69e57..3f6e2e3a 100644
--- a/google/cloud/dialogflowcx_v3beta1/services/flows/transports/base.py
+++ b/google/cloud/dialogflowcx_v3beta1/services/flows/transports/base.py
@@ -25,6 +25,7 @@
from google.api_core import retry as retries # type: ignore
from google.api_core import operations_v1 # type: ignore
from google.auth import credentials as ga_credentials # type: ignore
+from google.oauth2 import service_account # type: ignore
from google.cloud.dialogflowcx_v3beta1.types import flow
from google.cloud.dialogflowcx_v3beta1.types import flow as gcdc_flow
@@ -49,8 +50,6 @@
except pkg_resources.DistributionNotFound: # pragma: NO COVER
_GOOGLE_AUTH_VERSION = None
-_API_CORE_VERSION = google.api_core.__version__
-
class FlowsTransport(abc.ABC):
"""Abstract transport class for Flows."""
@@ -71,6 +70,7 @@ def __init__(
scopes: Optional[Sequence[str]] = None,
quota_project_id: Optional[str] = None,
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
+ always_use_jwt_access: Optional[bool] = False,
**kwargs,
) -> None:
"""Instantiate the transport.
@@ -94,6 +94,8 @@ def __init__(
API requests. If ``None``, then default info will be used.
Generally, you only need to set this if you're developing
your own client library.
+ always_use_jwt_access (Optional[bool]): Whether self signed JWT should
+ be used for service account credentials.
"""
# Save the hostname. Default to port 443 (HTTPS) if none is specified.
if ":" not in host:
@@ -103,7 +105,7 @@ def __init__(
scopes_kwargs = self._get_scopes_kwargs(self._host, scopes)
# Save the scopes.
- self._scopes = scopes or self.AUTH_SCOPES
+ self._scopes = scopes
# If no credentials are provided, then determine the appropriate
# defaults.
@@ -122,13 +124,20 @@ def __init__(
**scopes_kwargs, quota_project_id=quota_project_id
)
+ # If the credentials is service account credentials, then always try to use self signed JWT.
+ if (
+ always_use_jwt_access
+ and isinstance(credentials, service_account.Credentials)
+ and hasattr(service_account.Credentials, "with_always_use_jwt_access")
+ ):
+ credentials = credentials.with_always_use_jwt_access(True)
+
# Save the credentials.
self._credentials = credentials
- # TODO(busunkim): These two class methods are in the base transport
+ # 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-api-core
- # and google-auth are increased.
+ # 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
@@ -149,27 +158,6 @@ def _get_scopes_kwargs(
return scopes_kwargs
- # TODO: Remove this function once google-api-core >= 1.26.0 is required
- @classmethod
- def _get_self_signed_jwt_kwargs(
- cls, host: str, scopes: Optional[Sequence[str]]
- ) -> Dict[str, Union[Optional[Sequence[str]], str]]:
- """Returns kwargs to pass to grpc_helpers.create_channel depending on the google-api-core version"""
-
- self_signed_jwt_kwargs: Dict[str, Union[Optional[Sequence[str]], str]] = {}
-
- if _API_CORE_VERSION and (
- packaging.version.parse(_API_CORE_VERSION)
- >= packaging.version.parse("1.26.0")
- ):
- self_signed_jwt_kwargs["default_scopes"] = cls.AUTH_SCOPES
- self_signed_jwt_kwargs["scopes"] = scopes
- self_signed_jwt_kwargs["default_host"] = cls.DEFAULT_HOST
- else:
- self_signed_jwt_kwargs["scopes"] = scopes or cls.AUTH_SCOPES
-
- return self_signed_jwt_kwargs
-
def _prep_wrapped_messages(self, client_info):
# Precompute the wrapped methods.
self._wrapped_methods = {
diff --git a/google/cloud/dialogflowcx_v3beta1/services/flows/transports/grpc.py b/google/cloud/dialogflowcx_v3beta1/services/flows/transports/grpc.py
index f802da9b..e8f66cba 100644
--- a/google/cloud/dialogflowcx_v3beta1/services/flows/transports/grpc.py
+++ b/google/cloud/dialogflowcx_v3beta1/services/flows/transports/grpc.py
@@ -62,6 +62,7 @@ def __init__(
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
quota_project_id: Optional[str] = None,
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
+ always_use_jwt_access: Optional[bool] = False,
) -> None:
"""Instantiate the transport.
@@ -102,6 +103,8 @@ def __init__(
API requests. If ``None``, then default info will be used.
Generally, you only need to set this if you're developing
your own client library.
+ always_use_jwt_access (Optional[bool]): Whether self signed JWT should
+ be used for service account credentials.
Raises:
google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport
@@ -155,6 +158,7 @@ def __init__(
scopes=scopes,
quota_project_id=quota_project_id,
client_info=client_info,
+ always_use_jwt_access=always_use_jwt_access,
)
if not self._grpc_channel:
@@ -210,14 +214,14 @@ def create_channel(
and ``credentials_file`` are passed.
"""
- self_signed_jwt_kwargs = cls._get_self_signed_jwt_kwargs(host, scopes)
-
return grpc_helpers.create_channel(
host,
credentials=credentials,
credentials_file=credentials_file,
quota_project_id=quota_project_id,
- **self_signed_jwt_kwargs,
+ default_scopes=cls.AUTH_SCOPES,
+ scopes=scopes,
+ default_host=cls.DEFAULT_HOST,
**kwargs,
)
@@ -247,6 +251,10 @@ def create_flow(self) -> Callable[[gcdc_flow.CreateFlowRequest], gcdc_flow.Flow]
Creates a flow in the specified agent.
+ Note: You should always train a flow prior to sending it
+ queries. See the `training
+ documentation `__.
+
Returns:
Callable[[~.CreateFlowRequest],
~.Flow]:
@@ -343,6 +351,10 @@ def update_flow(self) -> Callable[[gcdc_flow.UpdateFlowRequest], gcdc_flow.Flow]
Updates the specified flow.
+ Note: You should always train a flow prior to sending it
+ queries. See the `training
+ documentation `__.
+
Returns:
Callable[[~.UpdateFlowRequest],
~.Flow]:
@@ -365,8 +377,12 @@ def update_flow(self) -> Callable[[gcdc_flow.UpdateFlowRequest], gcdc_flow.Flow]
def train_flow(self) -> Callable[[flow.TrainFlowRequest], operations_pb2.Operation]:
r"""Return a callable for the train flow method over gRPC.
- Trains the specified flow. Note that only the flow in
- 'draft' environment is trained.
+ Trains the specified flow. Note that only the flow in 'draft'
+ environment is trained.
+
+ Note: You should always train a flow prior to sending it
+ queries. See the `training
+ documentation `__.
Returns:
Callable[[~.TrainFlowRequest],
@@ -448,8 +464,12 @@ def import_flow(
) -> Callable[[flow.ImportFlowRequest], operations_pb2.Operation]:
r"""Return a callable for the import flow method over gRPC.
- Imports the specified flow to the specified agent
- from a binary file.
+ Imports the specified flow to the specified agent from a binary
+ file.
+
+ Note: You should always train a flow prior to sending it
+ queries. See the `training
+ documentation `__.
Returns:
Callable[[~.ImportFlowRequest],
diff --git a/google/cloud/dialogflowcx_v3beta1/services/flows/transports/grpc_asyncio.py b/google/cloud/dialogflowcx_v3beta1/services/flows/transports/grpc_asyncio.py
index 6c2f560e..034f02ec 100644
--- a/google/cloud/dialogflowcx_v3beta1/services/flows/transports/grpc_asyncio.py
+++ b/google/cloud/dialogflowcx_v3beta1/services/flows/transports/grpc_asyncio.py
@@ -83,14 +83,14 @@ def create_channel(
aio.Channel: A gRPC AsyncIO channel object.
"""
- self_signed_jwt_kwargs = cls._get_self_signed_jwt_kwargs(host, scopes)
-
return grpc_helpers_async.create_channel(
host,
credentials=credentials,
credentials_file=credentials_file,
quota_project_id=quota_project_id,
- **self_signed_jwt_kwargs,
+ default_scopes=cls.AUTH_SCOPES,
+ scopes=scopes,
+ default_host=cls.DEFAULT_HOST,
**kwargs,
)
@@ -108,6 +108,7 @@ def __init__(
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
quota_project_id=None,
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
+ always_use_jwt_access: Optional[bool] = False,
) -> None:
"""Instantiate the transport.
@@ -149,6 +150,8 @@ def __init__(
API requests. If ``None``, then default info will be used.
Generally, you only need to set this if you're developing
your own client library.
+ always_use_jwt_access (Optional[bool]): Whether self signed JWT should
+ be used for service account credentials.
Raises:
google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport
@@ -201,6 +204,7 @@ def __init__(
scopes=scopes,
quota_project_id=quota_project_id,
client_info=client_info,
+ always_use_jwt_access=always_use_jwt_access,
)
if not self._grpc_channel:
@@ -254,6 +258,10 @@ def create_flow(
Creates a flow in the specified agent.
+ Note: You should always train a flow prior to sending it
+ queries. See the `training
+ documentation `__.
+
Returns:
Callable[[~.CreateFlowRequest],
Awaitable[~.Flow]]:
@@ -356,6 +364,10 @@ def update_flow(
Updates the specified flow.
+ Note: You should always train a flow prior to sending it
+ queries. See the `training
+ documentation `__.
+
Returns:
Callable[[~.UpdateFlowRequest],
Awaitable[~.Flow]]:
@@ -380,8 +392,12 @@ def train_flow(
) -> Callable[[flow.TrainFlowRequest], Awaitable[operations_pb2.Operation]]:
r"""Return a callable for the train flow method over gRPC.
- Trains the specified flow. Note that only the flow in
- 'draft' environment is trained.
+ Trains the specified flow. Note that only the flow in 'draft'
+ environment is trained.
+
+ Note: You should always train a flow prior to sending it
+ queries. See the `training
+ documentation `__.
Returns:
Callable[[~.TrainFlowRequest],
@@ -465,8 +481,12 @@ def import_flow(
) -> Callable[[flow.ImportFlowRequest], Awaitable[operations_pb2.Operation]]:
r"""Return a callable for the import flow method over gRPC.
- Imports the specified flow to the specified agent
- from a binary file.
+ Imports the specified flow to the specified agent from a binary
+ file.
+
+ Note: You should always train a flow prior to sending it
+ queries. See the `training
+ documentation `__.
Returns:
Callable[[~.ImportFlowRequest],
diff --git a/google/cloud/dialogflowcx_v3beta1/services/intents/async_client.py b/google/cloud/dialogflowcx_v3beta1/services/intents/async_client.py
index 9381483d..64f922bb 100644
--- a/google/cloud/dialogflowcx_v3beta1/services/intents/async_client.py
+++ b/google/cloud/dialogflowcx_v3beta1/services/intents/async_client.py
@@ -328,6 +328,10 @@ async def create_intent(
) -> gcdc_intent.Intent:
r"""Creates an intent in the specified agent.
+ Note: You should always train a flow prior to sending it
+ queries. See the `training
+ documentation `__.
+
Args:
request (:class:`google.cloud.dialogflowcx_v3beta1.types.CreateIntentRequest`):
The request object. The request message for
@@ -412,6 +416,10 @@ async def update_intent(
) -> gcdc_intent.Intent:
r"""Updates the specified intent.
+ Note: You should always train a flow prior to sending it
+ queries. See the `training
+ documentation `__.
+
Args:
request (:class:`google.cloud.dialogflowcx_v3beta1.types.UpdateIntentRequest`):
The request object. The request message for
@@ -498,6 +506,10 @@ async def delete_intent(
) -> None:
r"""Deletes the specified intent.
+ Note: You should always train a flow prior to sending it
+ queries. See the `training
+ documentation `__.
+
Args:
request (:class:`google.cloud.dialogflowcx_v3beta1.types.DeleteIntentRequest`):
The request object. The request message for
diff --git a/google/cloud/dialogflowcx_v3beta1/services/intents/client.py b/google/cloud/dialogflowcx_v3beta1/services/intents/client.py
index 1ca249f7..937b24be 100644
--- a/google/cloud/dialogflowcx_v3beta1/services/intents/client.py
+++ b/google/cloud/dialogflowcx_v3beta1/services/intents/client.py
@@ -535,6 +535,10 @@ def create_intent(
) -> gcdc_intent.Intent:
r"""Creates an intent in the specified agent.
+ Note: You should always train a flow prior to sending it
+ queries. See the `training
+ documentation `__.
+
Args:
request (google.cloud.dialogflowcx_v3beta1.types.CreateIntentRequest):
The request object. The request message for
@@ -619,6 +623,10 @@ def update_intent(
) -> gcdc_intent.Intent:
r"""Updates the specified intent.
+ Note: You should always train a flow prior to sending it
+ queries. See the `training
+ documentation `__.
+
Args:
request (google.cloud.dialogflowcx_v3beta1.types.UpdateIntentRequest):
The request object. The request message for
@@ -705,6 +713,10 @@ def delete_intent(
) -> None:
r"""Deletes the specified intent.
+ Note: You should always train a flow prior to sending it
+ queries. See the `training
+ documentation `__.
+
Args:
request (google.cloud.dialogflowcx_v3beta1.types.DeleteIntentRequest):
The request object. The request message for
diff --git a/google/cloud/dialogflowcx_v3beta1/services/intents/transports/base.py b/google/cloud/dialogflowcx_v3beta1/services/intents/transports/base.py
index 901ef629..d26294b6 100644
--- a/google/cloud/dialogflowcx_v3beta1/services/intents/transports/base.py
+++ b/google/cloud/dialogflowcx_v3beta1/services/intents/transports/base.py
@@ -24,6 +24,7 @@
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
from google.cloud.dialogflowcx_v3beta1.types import intent
from google.cloud.dialogflowcx_v3beta1.types import intent as gcdc_intent
@@ -47,8 +48,6 @@
except pkg_resources.DistributionNotFound: # pragma: NO COVER
_GOOGLE_AUTH_VERSION = None
-_API_CORE_VERSION = google.api_core.__version__
-
class IntentsTransport(abc.ABC):
"""Abstract transport class for Intents."""
@@ -69,6 +68,7 @@ def __init__(
scopes: Optional[Sequence[str]] = None,
quota_project_id: Optional[str] = None,
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
+ always_use_jwt_access: Optional[bool] = False,
**kwargs,
) -> None:
"""Instantiate the transport.
@@ -92,6 +92,8 @@ def __init__(
API requests. If ``None``, then default info will be used.
Generally, you only need to set this if you're developing
your own client library.
+ always_use_jwt_access (Optional[bool]): Whether self signed JWT should
+ be used for service account credentials.
"""
# Save the hostname. Default to port 443 (HTTPS) if none is specified.
if ":" not in host:
@@ -101,7 +103,7 @@ def __init__(
scopes_kwargs = self._get_scopes_kwargs(self._host, scopes)
# Save the scopes.
- self._scopes = scopes or self.AUTH_SCOPES
+ self._scopes = scopes
# If no credentials are provided, then determine the appropriate
# defaults.
@@ -120,13 +122,20 @@ def __init__(
**scopes_kwargs, quota_project_id=quota_project_id
)
+ # If the credentials is service account credentials, then always try to use self signed JWT.
+ if (
+ always_use_jwt_access
+ and isinstance(credentials, service_account.Credentials)
+ and hasattr(service_account.Credentials, "with_always_use_jwt_access")
+ ):
+ credentials = credentials.with_always_use_jwt_access(True)
+
# Save the credentials.
self._credentials = credentials
- # TODO(busunkim): These two class methods are in the base transport
+ # 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-api-core
- # and google-auth are increased.
+ # 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
@@ -147,27 +156,6 @@ def _get_scopes_kwargs(
return scopes_kwargs
- # TODO: Remove this function once google-api-core >= 1.26.0 is required
- @classmethod
- def _get_self_signed_jwt_kwargs(
- cls, host: str, scopes: Optional[Sequence[str]]
- ) -> Dict[str, Union[Optional[Sequence[str]], str]]:
- """Returns kwargs to pass to grpc_helpers.create_channel depending on the google-api-core version"""
-
- self_signed_jwt_kwargs: Dict[str, Union[Optional[Sequence[str]], str]] = {}
-
- if _API_CORE_VERSION and (
- packaging.version.parse(_API_CORE_VERSION)
- >= packaging.version.parse("1.26.0")
- ):
- self_signed_jwt_kwargs["default_scopes"] = cls.AUTH_SCOPES
- self_signed_jwt_kwargs["scopes"] = scopes
- self_signed_jwt_kwargs["default_host"] = cls.DEFAULT_HOST
- else:
- self_signed_jwt_kwargs["scopes"] = scopes or cls.AUTH_SCOPES
-
- return self_signed_jwt_kwargs
-
def _prep_wrapped_messages(self, client_info):
# Precompute the wrapped methods.
self._wrapped_methods = {
diff --git a/google/cloud/dialogflowcx_v3beta1/services/intents/transports/grpc.py b/google/cloud/dialogflowcx_v3beta1/services/intents/transports/grpc.py
index e2da4f31..c9881ace 100644
--- a/google/cloud/dialogflowcx_v3beta1/services/intents/transports/grpc.py
+++ b/google/cloud/dialogflowcx_v3beta1/services/intents/transports/grpc.py
@@ -60,6 +60,7 @@ def __init__(
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
quota_project_id: Optional[str] = None,
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
+ always_use_jwt_access: Optional[bool] = False,
) -> None:
"""Instantiate the transport.
@@ -100,6 +101,8 @@ def __init__(
API requests. If ``None``, then default info will be used.
Generally, you only need to set this if you're developing
your own client library.
+ always_use_jwt_access (Optional[bool]): Whether self signed JWT should
+ be used for service account credentials.
Raises:
google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport
@@ -152,6 +155,7 @@ def __init__(
scopes=scopes,
quota_project_id=quota_project_id,
client_info=client_info,
+ always_use_jwt_access=always_use_jwt_access,
)
if not self._grpc_channel:
@@ -207,14 +211,14 @@ def create_channel(
and ``credentials_file`` are passed.
"""
- self_signed_jwt_kwargs = cls._get_self_signed_jwt_kwargs(host, scopes)
-
return grpc_helpers.create_channel(
host,
credentials=credentials,
credentials_file=credentials_file,
quota_project_id=quota_project_id,
- **self_signed_jwt_kwargs,
+ default_scopes=cls.AUTH_SCOPES,
+ scopes=scopes,
+ default_host=cls.DEFAULT_HOST,
**kwargs,
)
@@ -283,6 +287,10 @@ def create_intent(
Creates an intent in the specified agent.
+ Note: You should always train a flow prior to sending it
+ queries. See the `training
+ documentation `__.
+
Returns:
Callable[[~.CreateIntentRequest],
~.Intent]:
@@ -309,6 +317,10 @@ def update_intent(
Updates the specified intent.
+ Note: You should always train a flow prior to sending it
+ queries. See the `training
+ documentation `__.
+
Returns:
Callable[[~.UpdateIntentRequest],
~.Intent]:
@@ -333,6 +345,10 @@ def delete_intent(self) -> Callable[[intent.DeleteIntentRequest], empty_pb2.Empt
Deletes the specified intent.
+ Note: You should always train a flow prior to sending it
+ queries. See the `training
+ documentation `__.
+
Returns:
Callable[[~.DeleteIntentRequest],
~.Empty]:
diff --git a/google/cloud/dialogflowcx_v3beta1/services/intents/transports/grpc_asyncio.py b/google/cloud/dialogflowcx_v3beta1/services/intents/transports/grpc_asyncio.py
index f2057bf1..337db908 100644
--- a/google/cloud/dialogflowcx_v3beta1/services/intents/transports/grpc_asyncio.py
+++ b/google/cloud/dialogflowcx_v3beta1/services/intents/transports/grpc_asyncio.py
@@ -81,14 +81,14 @@ def create_channel(
aio.Channel: A gRPC AsyncIO channel object.
"""
- self_signed_jwt_kwargs = cls._get_self_signed_jwt_kwargs(host, scopes)
-
return grpc_helpers_async.create_channel(
host,
credentials=credentials,
credentials_file=credentials_file,
quota_project_id=quota_project_id,
- **self_signed_jwt_kwargs,
+ default_scopes=cls.AUTH_SCOPES,
+ scopes=scopes,
+ default_host=cls.DEFAULT_HOST,
**kwargs,
)
@@ -106,6 +106,7 @@ def __init__(
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
quota_project_id=None,
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
+ always_use_jwt_access: Optional[bool] = False,
) -> None:
"""Instantiate the transport.
@@ -147,6 +148,8 @@ def __init__(
API requests. If ``None``, then default info will be used.
Generally, you only need to set this if you're developing
your own client library.
+ always_use_jwt_access (Optional[bool]): Whether self signed JWT should
+ be used for service account credentials.
Raises:
google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport
@@ -198,6 +201,7 @@ def __init__(
scopes=scopes,
quota_project_id=quota_project_id,
client_info=client_info,
+ always_use_jwt_access=always_use_jwt_access,
)
if not self._grpc_channel:
@@ -288,6 +292,10 @@ def create_intent(
Creates an intent in the specified agent.
+ Note: You should always train a flow prior to sending it
+ queries. See the `training
+ documentation `__.
+
Returns:
Callable[[~.CreateIntentRequest],
Awaitable[~.Intent]]:
@@ -314,6 +322,10 @@ def update_intent(
Updates the specified intent.
+ Note: You should always train a flow prior to sending it
+ queries. See the `training
+ documentation `__.
+
Returns:
Callable[[~.UpdateIntentRequest],
Awaitable[~.Intent]]:
@@ -340,6 +352,10 @@ def delete_intent(
Deletes the specified intent.
+ Note: You should always train a flow prior to sending it
+ queries. See the `training
+ documentation `__.
+
Returns:
Callable[[~.DeleteIntentRequest],
Awaitable[~.Empty]]:
diff --git a/google/cloud/dialogflowcx_v3beta1/services/pages/transports/base.py b/google/cloud/dialogflowcx_v3beta1/services/pages/transports/base.py
index 34fa8cf8..d85b439e 100644
--- a/google/cloud/dialogflowcx_v3beta1/services/pages/transports/base.py
+++ b/google/cloud/dialogflowcx_v3beta1/services/pages/transports/base.py
@@ -24,6 +24,7 @@
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
from google.cloud.dialogflowcx_v3beta1.types import page
from google.cloud.dialogflowcx_v3beta1.types import page as gcdc_page
@@ -47,8 +48,6 @@
except pkg_resources.DistributionNotFound: # pragma: NO COVER
_GOOGLE_AUTH_VERSION = None
-_API_CORE_VERSION = google.api_core.__version__
-
class PagesTransport(abc.ABC):
"""Abstract transport class for Pages."""
@@ -69,6 +68,7 @@ def __init__(
scopes: Optional[Sequence[str]] = None,
quota_project_id: Optional[str] = None,
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
+ always_use_jwt_access: Optional[bool] = False,
**kwargs,
) -> None:
"""Instantiate the transport.
@@ -92,6 +92,8 @@ def __init__(
API requests. If ``None``, then default info will be used.
Generally, you only need to set this if you're developing
your own client library.
+ always_use_jwt_access (Optional[bool]): Whether self signed JWT should
+ be used for service account credentials.
"""
# Save the hostname. Default to port 443 (HTTPS) if none is specified.
if ":" not in host:
@@ -101,7 +103,7 @@ def __init__(
scopes_kwargs = self._get_scopes_kwargs(self._host, scopes)
# Save the scopes.
- self._scopes = scopes or self.AUTH_SCOPES
+ self._scopes = scopes
# If no credentials are provided, then determine the appropriate
# defaults.
@@ -120,13 +122,20 @@ def __init__(
**scopes_kwargs, quota_project_id=quota_project_id
)
+ # If the credentials is service account credentials, then always try to use self signed JWT.
+ if (
+ always_use_jwt_access
+ and isinstance(credentials, service_account.Credentials)
+ and hasattr(service_account.Credentials, "with_always_use_jwt_access")
+ ):
+ credentials = credentials.with_always_use_jwt_access(True)
+
# Save the credentials.
self._credentials = credentials
- # TODO(busunkim): These two class methods are in the base transport
+ # 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-api-core
- # and google-auth are increased.
+ # 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
@@ -147,27 +156,6 @@ def _get_scopes_kwargs(
return scopes_kwargs
- # TODO: Remove this function once google-api-core >= 1.26.0 is required
- @classmethod
- def _get_self_signed_jwt_kwargs(
- cls, host: str, scopes: Optional[Sequence[str]]
- ) -> Dict[str, Union[Optional[Sequence[str]], str]]:
- """Returns kwargs to pass to grpc_helpers.create_channel depending on the google-api-core version"""
-
- self_signed_jwt_kwargs: Dict[str, Union[Optional[Sequence[str]], str]] = {}
-
- if _API_CORE_VERSION and (
- packaging.version.parse(_API_CORE_VERSION)
- >= packaging.version.parse("1.26.0")
- ):
- self_signed_jwt_kwargs["default_scopes"] = cls.AUTH_SCOPES
- self_signed_jwt_kwargs["scopes"] = scopes
- self_signed_jwt_kwargs["default_host"] = cls.DEFAULT_HOST
- else:
- self_signed_jwt_kwargs["scopes"] = scopes or cls.AUTH_SCOPES
-
- return self_signed_jwt_kwargs
-
def _prep_wrapped_messages(self, client_info):
# Precompute the wrapped methods.
self._wrapped_methods = {
diff --git a/google/cloud/dialogflowcx_v3beta1/services/pages/transports/grpc.py b/google/cloud/dialogflowcx_v3beta1/services/pages/transports/grpc.py
index c217af1f..15bbd9ba 100644
--- a/google/cloud/dialogflowcx_v3beta1/services/pages/transports/grpc.py
+++ b/google/cloud/dialogflowcx_v3beta1/services/pages/transports/grpc.py
@@ -60,6 +60,7 @@ def __init__(
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
quota_project_id: Optional[str] = None,
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
+ always_use_jwt_access: Optional[bool] = False,
) -> None:
"""Instantiate the transport.
@@ -100,6 +101,8 @@ def __init__(
API requests. If ``None``, then default info will be used.
Generally, you only need to set this if you're developing
your own client library.
+ always_use_jwt_access (Optional[bool]): Whether self signed JWT should
+ be used for service account credentials.
Raises:
google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport
@@ -152,6 +155,7 @@ def __init__(
scopes=scopes,
quota_project_id=quota_project_id,
client_info=client_info,
+ always_use_jwt_access=always_use_jwt_access,
)
if not self._grpc_channel:
@@ -207,14 +211,14 @@ def create_channel(
and ``credentials_file`` are passed.
"""
- self_signed_jwt_kwargs = cls._get_self_signed_jwt_kwargs(host, scopes)
-
return grpc_helpers.create_channel(
host,
credentials=credentials,
credentials_file=credentials_file,
quota_project_id=quota_project_id,
- **self_signed_jwt_kwargs,
+ default_scopes=cls.AUTH_SCOPES,
+ scopes=scopes,
+ default_host=cls.DEFAULT_HOST,
**kwargs,
)
diff --git a/google/cloud/dialogflowcx_v3beta1/services/pages/transports/grpc_asyncio.py b/google/cloud/dialogflowcx_v3beta1/services/pages/transports/grpc_asyncio.py
index a38bc8c4..25f2b4cf 100644
--- a/google/cloud/dialogflowcx_v3beta1/services/pages/transports/grpc_asyncio.py
+++ b/google/cloud/dialogflowcx_v3beta1/services/pages/transports/grpc_asyncio.py
@@ -81,14 +81,14 @@ def create_channel(
aio.Channel: A gRPC AsyncIO channel object.
"""
- self_signed_jwt_kwargs = cls._get_self_signed_jwt_kwargs(host, scopes)
-
return grpc_helpers_async.create_channel(
host,
credentials=credentials,
credentials_file=credentials_file,
quota_project_id=quota_project_id,
- **self_signed_jwt_kwargs,
+ default_scopes=cls.AUTH_SCOPES,
+ scopes=scopes,
+ default_host=cls.DEFAULT_HOST,
**kwargs,
)
@@ -106,6 +106,7 @@ def __init__(
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
quota_project_id=None,
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
+ always_use_jwt_access: Optional[bool] = False,
) -> None:
"""Instantiate the transport.
@@ -147,6 +148,8 @@ def __init__(
API requests. If ``None``, then default info will be used.
Generally, you only need to set this if you're developing
your own client library.
+ always_use_jwt_access (Optional[bool]): Whether self signed JWT should
+ be used for service account credentials.
Raises:
google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport
@@ -198,6 +201,7 @@ def __init__(
scopes=scopes,
quota_project_id=quota_project_id,
client_info=client_info,
+ always_use_jwt_access=always_use_jwt_access,
)
if not self._grpc_channel:
diff --git a/google/cloud/dialogflowcx_v3beta1/services/security_settings_service/transports/base.py b/google/cloud/dialogflowcx_v3beta1/services/security_settings_service/transports/base.py
index 503d80ff..c1b5f444 100644
--- a/google/cloud/dialogflowcx_v3beta1/services/security_settings_service/transports/base.py
+++ b/google/cloud/dialogflowcx_v3beta1/services/security_settings_service/transports/base.py
@@ -24,6 +24,7 @@
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
from google.cloud.dialogflowcx_v3beta1.types import security_settings
from google.cloud.dialogflowcx_v3beta1.types import (
@@ -49,8 +50,6 @@
except pkg_resources.DistributionNotFound: # pragma: NO COVER
_GOOGLE_AUTH_VERSION = None
-_API_CORE_VERSION = google.api_core.__version__
-
class SecuritySettingsServiceTransport(abc.ABC):
"""Abstract transport class for SecuritySettingsService."""
@@ -71,6 +70,7 @@ def __init__(
scopes: Optional[Sequence[str]] = None,
quota_project_id: Optional[str] = None,
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
+ always_use_jwt_access: Optional[bool] = False,
**kwargs,
) -> None:
"""Instantiate the transport.
@@ -94,6 +94,8 @@ def __init__(
API requests. If ``None``, then default info will be used.
Generally, you only need to set this if you're developing
your own client library.
+ always_use_jwt_access (Optional[bool]): Whether self signed JWT should
+ be used for service account credentials.
"""
# Save the hostname. Default to port 443 (HTTPS) if none is specified.
if ":" not in host:
@@ -103,7 +105,7 @@ def __init__(
scopes_kwargs = self._get_scopes_kwargs(self._host, scopes)
# Save the scopes.
- self._scopes = scopes or self.AUTH_SCOPES
+ self._scopes = scopes
# If no credentials are provided, then determine the appropriate
# defaults.
@@ -122,13 +124,20 @@ def __init__(
**scopes_kwargs, quota_project_id=quota_project_id
)
+ # If the credentials is service account credentials, then always try to use self signed JWT.
+ if (
+ always_use_jwt_access
+ and isinstance(credentials, service_account.Credentials)
+ and hasattr(service_account.Credentials, "with_always_use_jwt_access")
+ ):
+ credentials = credentials.with_always_use_jwt_access(True)
+
# Save the credentials.
self._credentials = credentials
- # TODO(busunkim): These two class methods are in the base transport
+ # 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-api-core
- # and google-auth are increased.
+ # 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
@@ -149,27 +158,6 @@ def _get_scopes_kwargs(
return scopes_kwargs
- # TODO: Remove this function once google-api-core >= 1.26.0 is required
- @classmethod
- def _get_self_signed_jwt_kwargs(
- cls, host: str, scopes: Optional[Sequence[str]]
- ) -> Dict[str, Union[Optional[Sequence[str]], str]]:
- """Returns kwargs to pass to grpc_helpers.create_channel depending on the google-api-core version"""
-
- self_signed_jwt_kwargs: Dict[str, Union[Optional[Sequence[str]], str]] = {}
-
- if _API_CORE_VERSION and (
- packaging.version.parse(_API_CORE_VERSION)
- >= packaging.version.parse("1.26.0")
- ):
- self_signed_jwt_kwargs["default_scopes"] = cls.AUTH_SCOPES
- self_signed_jwt_kwargs["scopes"] = scopes
- self_signed_jwt_kwargs["default_host"] = cls.DEFAULT_HOST
- else:
- self_signed_jwt_kwargs["scopes"] = scopes or cls.AUTH_SCOPES
-
- return self_signed_jwt_kwargs
-
def _prep_wrapped_messages(self, client_info):
# Precompute the wrapped methods.
self._wrapped_methods = {
diff --git a/google/cloud/dialogflowcx_v3beta1/services/security_settings_service/transports/grpc.py b/google/cloud/dialogflowcx_v3beta1/services/security_settings_service/transports/grpc.py
index 5fa72348..7aa0c48e 100644
--- a/google/cloud/dialogflowcx_v3beta1/services/security_settings_service/transports/grpc.py
+++ b/google/cloud/dialogflowcx_v3beta1/services/security_settings_service/transports/grpc.py
@@ -61,6 +61,7 @@ def __init__(
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
quota_project_id: Optional[str] = None,
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
+ always_use_jwt_access: Optional[bool] = False,
) -> None:
"""Instantiate the transport.
@@ -101,6 +102,8 @@ def __init__(
API requests. If ``None``, then default info will be used.
Generally, you only need to set this if you're developing
your own client library.
+ always_use_jwt_access (Optional[bool]): Whether self signed JWT should
+ be used for service account credentials.
Raises:
google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport
@@ -153,6 +156,7 @@ def __init__(
scopes=scopes,
quota_project_id=quota_project_id,
client_info=client_info,
+ always_use_jwt_access=always_use_jwt_access,
)
if not self._grpc_channel:
@@ -208,14 +212,14 @@ def create_channel(
and ``credentials_file`` are passed.
"""
- self_signed_jwt_kwargs = cls._get_self_signed_jwt_kwargs(host, scopes)
-
return grpc_helpers.create_channel(
host,
credentials=credentials,
credentials_file=credentials_file,
quota_project_id=quota_project_id,
- **self_signed_jwt_kwargs,
+ default_scopes=cls.AUTH_SCOPES,
+ scopes=scopes,
+ default_host=cls.DEFAULT_HOST,
**kwargs,
)
diff --git a/google/cloud/dialogflowcx_v3beta1/services/security_settings_service/transports/grpc_asyncio.py b/google/cloud/dialogflowcx_v3beta1/services/security_settings_service/transports/grpc_asyncio.py
index df24e44e..5b475c22 100644
--- a/google/cloud/dialogflowcx_v3beta1/services/security_settings_service/transports/grpc_asyncio.py
+++ b/google/cloud/dialogflowcx_v3beta1/services/security_settings_service/transports/grpc_asyncio.py
@@ -82,14 +82,14 @@ def create_channel(
aio.Channel: A gRPC AsyncIO channel object.
"""
- self_signed_jwt_kwargs = cls._get_self_signed_jwt_kwargs(host, scopes)
-
return grpc_helpers_async.create_channel(
host,
credentials=credentials,
credentials_file=credentials_file,
quota_project_id=quota_project_id,
- **self_signed_jwt_kwargs,
+ default_scopes=cls.AUTH_SCOPES,
+ scopes=scopes,
+ default_host=cls.DEFAULT_HOST,
**kwargs,
)
@@ -107,6 +107,7 @@ def __init__(
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
quota_project_id=None,
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
+ always_use_jwt_access: Optional[bool] = False,
) -> None:
"""Instantiate the transport.
@@ -148,6 +149,8 @@ def __init__(
API requests. If ``None``, then default info will be used.
Generally, you only need to set this if you're developing
your own client library.
+ always_use_jwt_access (Optional[bool]): Whether self signed JWT should
+ be used for service account credentials.
Raises:
google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport
@@ -199,6 +202,7 @@ def __init__(
scopes=scopes,
quota_project_id=quota_project_id,
client_info=client_info,
+ always_use_jwt_access=always_use_jwt_access,
)
if not self._grpc_channel:
diff --git a/google/cloud/dialogflowcx_v3beta1/services/session_entity_types/transports/base.py b/google/cloud/dialogflowcx_v3beta1/services/session_entity_types/transports/base.py
index 67dd7511..33369a64 100644
--- a/google/cloud/dialogflowcx_v3beta1/services/session_entity_types/transports/base.py
+++ b/google/cloud/dialogflowcx_v3beta1/services/session_entity_types/transports/base.py
@@ -24,6 +24,7 @@
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
from google.cloud.dialogflowcx_v3beta1.types import session_entity_type
from google.cloud.dialogflowcx_v3beta1.types import (
@@ -49,8 +50,6 @@
except pkg_resources.DistributionNotFound: # pragma: NO COVER
_GOOGLE_AUTH_VERSION = None
-_API_CORE_VERSION = google.api_core.__version__
-
class SessionEntityTypesTransport(abc.ABC):
"""Abstract transport class for SessionEntityTypes."""
@@ -71,6 +70,7 @@ def __init__(
scopes: Optional[Sequence[str]] = None,
quota_project_id: Optional[str] = None,
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
+ always_use_jwt_access: Optional[bool] = False,
**kwargs,
) -> None:
"""Instantiate the transport.
@@ -94,6 +94,8 @@ def __init__(
API requests. If ``None``, then default info will be used.
Generally, you only need to set this if you're developing
your own client library.
+ always_use_jwt_access (Optional[bool]): Whether self signed JWT should
+ be used for service account credentials.
"""
# Save the hostname. Default to port 443 (HTTPS) if none is specified.
if ":" not in host:
@@ -103,7 +105,7 @@ def __init__(
scopes_kwargs = self._get_scopes_kwargs(self._host, scopes)
# Save the scopes.
- self._scopes = scopes or self.AUTH_SCOPES
+ self._scopes = scopes
# If no credentials are provided, then determine the appropriate
# defaults.
@@ -122,13 +124,20 @@ def __init__(
**scopes_kwargs, quota_project_id=quota_project_id
)
+ # If the credentials is service account credentials, then always try to use self signed JWT.
+ if (
+ always_use_jwt_access
+ and isinstance(credentials, service_account.Credentials)
+ and hasattr(service_account.Credentials, "with_always_use_jwt_access")
+ ):
+ credentials = credentials.with_always_use_jwt_access(True)
+
# Save the credentials.
self._credentials = credentials
- # TODO(busunkim): These two class methods are in the base transport
+ # 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-api-core
- # and google-auth are increased.
+ # 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
@@ -149,27 +158,6 @@ def _get_scopes_kwargs(
return scopes_kwargs
- # TODO: Remove this function once google-api-core >= 1.26.0 is required
- @classmethod
- def _get_self_signed_jwt_kwargs(
- cls, host: str, scopes: Optional[Sequence[str]]
- ) -> Dict[str, Union[Optional[Sequence[str]], str]]:
- """Returns kwargs to pass to grpc_helpers.create_channel depending on the google-api-core version"""
-
- self_signed_jwt_kwargs: Dict[str, Union[Optional[Sequence[str]], str]] = {}
-
- if _API_CORE_VERSION and (
- packaging.version.parse(_API_CORE_VERSION)
- >= packaging.version.parse("1.26.0")
- ):
- self_signed_jwt_kwargs["default_scopes"] = cls.AUTH_SCOPES
- self_signed_jwt_kwargs["scopes"] = scopes
- self_signed_jwt_kwargs["default_host"] = cls.DEFAULT_HOST
- else:
- self_signed_jwt_kwargs["scopes"] = scopes or cls.AUTH_SCOPES
-
- return self_signed_jwt_kwargs
-
def _prep_wrapped_messages(self, client_info):
# Precompute the wrapped methods.
self._wrapped_methods = {
diff --git a/google/cloud/dialogflowcx_v3beta1/services/session_entity_types/transports/grpc.py b/google/cloud/dialogflowcx_v3beta1/services/session_entity_types/transports/grpc.py
index 7fcdd668..933f2540 100644
--- a/google/cloud/dialogflowcx_v3beta1/services/session_entity_types/transports/grpc.py
+++ b/google/cloud/dialogflowcx_v3beta1/services/session_entity_types/transports/grpc.py
@@ -62,6 +62,7 @@ def __init__(
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
quota_project_id: Optional[str] = None,
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
+ always_use_jwt_access: Optional[bool] = False,
) -> None:
"""Instantiate the transport.
@@ -102,6 +103,8 @@ def __init__(
API requests. If ``None``, then default info will be used.
Generally, you only need to set this if you're developing
your own client library.
+ always_use_jwt_access (Optional[bool]): Whether self signed JWT should
+ be used for service account credentials.
Raises:
google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport
@@ -154,6 +157,7 @@ def __init__(
scopes=scopes,
quota_project_id=quota_project_id,
client_info=client_info,
+ always_use_jwt_access=always_use_jwt_access,
)
if not self._grpc_channel:
@@ -209,14 +213,14 @@ def create_channel(
and ``credentials_file`` are passed.
"""
- self_signed_jwt_kwargs = cls._get_self_signed_jwt_kwargs(host, scopes)
-
return grpc_helpers.create_channel(
host,
credentials=credentials,
credentials_file=credentials_file,
quota_project_id=quota_project_id,
- **self_signed_jwt_kwargs,
+ default_scopes=cls.AUTH_SCOPES,
+ scopes=scopes,
+ default_host=cls.DEFAULT_HOST,
**kwargs,
)
diff --git a/google/cloud/dialogflowcx_v3beta1/services/session_entity_types/transports/grpc_asyncio.py b/google/cloud/dialogflowcx_v3beta1/services/session_entity_types/transports/grpc_asyncio.py
index a7f357c2..b410bd40 100644
--- a/google/cloud/dialogflowcx_v3beta1/services/session_entity_types/transports/grpc_asyncio.py
+++ b/google/cloud/dialogflowcx_v3beta1/services/session_entity_types/transports/grpc_asyncio.py
@@ -83,14 +83,14 @@ def create_channel(
aio.Channel: A gRPC AsyncIO channel object.
"""
- self_signed_jwt_kwargs = cls._get_self_signed_jwt_kwargs(host, scopes)
-
return grpc_helpers_async.create_channel(
host,
credentials=credentials,
credentials_file=credentials_file,
quota_project_id=quota_project_id,
- **self_signed_jwt_kwargs,
+ default_scopes=cls.AUTH_SCOPES,
+ scopes=scopes,
+ default_host=cls.DEFAULT_HOST,
**kwargs,
)
@@ -108,6 +108,7 @@ def __init__(
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
quota_project_id=None,
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
+ always_use_jwt_access: Optional[bool] = False,
) -> None:
"""Instantiate the transport.
@@ -149,6 +150,8 @@ def __init__(
API requests. If ``None``, then default info will be used.
Generally, you only need to set this if you're developing
your own client library.
+ always_use_jwt_access (Optional[bool]): Whether self signed JWT should
+ be used for service account credentials.
Raises:
google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport
@@ -200,6 +203,7 @@ def __init__(
scopes=scopes,
quota_project_id=quota_project_id,
client_info=client_info,
+ always_use_jwt_access=always_use_jwt_access,
)
if not self._grpc_channel:
diff --git a/google/cloud/dialogflowcx_v3beta1/services/sessions/transports/base.py b/google/cloud/dialogflowcx_v3beta1/services/sessions/transports/base.py
index 997984bd..07bc22d7 100644
--- a/google/cloud/dialogflowcx_v3beta1/services/sessions/transports/base.py
+++ b/google/cloud/dialogflowcx_v3beta1/services/sessions/transports/base.py
@@ -24,6 +24,7 @@
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
from google.cloud.dialogflowcx_v3beta1.types import session
@@ -45,8 +46,6 @@
except pkg_resources.DistributionNotFound: # pragma: NO COVER
_GOOGLE_AUTH_VERSION = None
-_API_CORE_VERSION = google.api_core.__version__
-
class SessionsTransport(abc.ABC):
"""Abstract transport class for Sessions."""
@@ -67,6 +66,7 @@ def __init__(
scopes: Optional[Sequence[str]] = None,
quota_project_id: Optional[str] = None,
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
+ always_use_jwt_access: Optional[bool] = False,
**kwargs,
) -> None:
"""Instantiate the transport.
@@ -90,6 +90,8 @@ def __init__(
API requests. If ``None``, then default info will be used.
Generally, you only need to set this if you're developing
your own client library.
+ always_use_jwt_access (Optional[bool]): Whether self signed JWT should
+ be used for service account credentials.
"""
# Save the hostname. Default to port 443 (HTTPS) if none is specified.
if ":" not in host:
@@ -99,7 +101,7 @@ def __init__(
scopes_kwargs = self._get_scopes_kwargs(self._host, scopes)
# Save the scopes.
- self._scopes = scopes or self.AUTH_SCOPES
+ self._scopes = scopes
# If no credentials are provided, then determine the appropriate
# defaults.
@@ -118,13 +120,20 @@ def __init__(
**scopes_kwargs, quota_project_id=quota_project_id
)
+ # If the credentials is service account credentials, then always try to use self signed JWT.
+ if (
+ always_use_jwt_access
+ and isinstance(credentials, service_account.Credentials)
+ and hasattr(service_account.Credentials, "with_always_use_jwt_access")
+ ):
+ credentials = credentials.with_always_use_jwt_access(True)
+
# Save the credentials.
self._credentials = credentials
- # TODO(busunkim): These two class methods are in the base transport
+ # 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-api-core
- # and google-auth are increased.
+ # 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
@@ -145,27 +154,6 @@ def _get_scopes_kwargs(
return scopes_kwargs
- # TODO: Remove this function once google-api-core >= 1.26.0 is required
- @classmethod
- def _get_self_signed_jwt_kwargs(
- cls, host: str, scopes: Optional[Sequence[str]]
- ) -> Dict[str, Union[Optional[Sequence[str]], str]]:
- """Returns kwargs to pass to grpc_helpers.create_channel depending on the google-api-core version"""
-
- self_signed_jwt_kwargs: Dict[str, Union[Optional[Sequence[str]], str]] = {}
-
- if _API_CORE_VERSION and (
- packaging.version.parse(_API_CORE_VERSION)
- >= packaging.version.parse("1.26.0")
- ):
- self_signed_jwt_kwargs["default_scopes"] = cls.AUTH_SCOPES
- self_signed_jwt_kwargs["scopes"] = scopes
- self_signed_jwt_kwargs["default_host"] = cls.DEFAULT_HOST
- else:
- self_signed_jwt_kwargs["scopes"] = scopes or cls.AUTH_SCOPES
-
- return self_signed_jwt_kwargs
-
def _prep_wrapped_messages(self, client_info):
# Precompute the wrapped methods.
self._wrapped_methods = {
diff --git a/google/cloud/dialogflowcx_v3beta1/services/sessions/transports/grpc.py b/google/cloud/dialogflowcx_v3beta1/services/sessions/transports/grpc.py
index 74179943..03d404a8 100644
--- a/google/cloud/dialogflowcx_v3beta1/services/sessions/transports/grpc.py
+++ b/google/cloud/dialogflowcx_v3beta1/services/sessions/transports/grpc.py
@@ -60,6 +60,7 @@ def __init__(
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
quota_project_id: Optional[str] = None,
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
+ always_use_jwt_access: Optional[bool] = False,
) -> None:
"""Instantiate the transport.
@@ -100,6 +101,8 @@ def __init__(
API requests. If ``None``, then default info will be used.
Generally, you only need to set this if you're developing
your own client library.
+ always_use_jwt_access (Optional[bool]): Whether self signed JWT should
+ be used for service account credentials.
Raises:
google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport
@@ -152,6 +155,7 @@ def __init__(
scopes=scopes,
quota_project_id=quota_project_id,
client_info=client_info,
+ always_use_jwt_access=always_use_jwt_access,
)
if not self._grpc_channel:
@@ -207,14 +211,14 @@ def create_channel(
and ``credentials_file`` are passed.
"""
- self_signed_jwt_kwargs = cls._get_self_signed_jwt_kwargs(host, scopes)
-
return grpc_helpers.create_channel(
host,
credentials=credentials,
credentials_file=credentials_file,
quota_project_id=quota_project_id,
- **self_signed_jwt_kwargs,
+ default_scopes=cls.AUTH_SCOPES,
+ scopes=scopes,
+ default_host=cls.DEFAULT_HOST,
**kwargs,
)
diff --git a/google/cloud/dialogflowcx_v3beta1/services/sessions/transports/grpc_asyncio.py b/google/cloud/dialogflowcx_v3beta1/services/sessions/transports/grpc_asyncio.py
index c3486303..4ec71476 100644
--- a/google/cloud/dialogflowcx_v3beta1/services/sessions/transports/grpc_asyncio.py
+++ b/google/cloud/dialogflowcx_v3beta1/services/sessions/transports/grpc_asyncio.py
@@ -81,14 +81,14 @@ def create_channel(
aio.Channel: A gRPC AsyncIO channel object.
"""
- self_signed_jwt_kwargs = cls._get_self_signed_jwt_kwargs(host, scopes)
-
return grpc_helpers_async.create_channel(
host,
credentials=credentials,
credentials_file=credentials_file,
quota_project_id=quota_project_id,
- **self_signed_jwt_kwargs,
+ default_scopes=cls.AUTH_SCOPES,
+ scopes=scopes,
+ default_host=cls.DEFAULT_HOST,
**kwargs,
)
@@ -106,6 +106,7 @@ def __init__(
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
quota_project_id=None,
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
+ always_use_jwt_access: Optional[bool] = False,
) -> None:
"""Instantiate the transport.
@@ -147,6 +148,8 @@ def __init__(
API requests. If ``None``, then default info will be used.
Generally, you only need to set this if you're developing
your own client library.
+ always_use_jwt_access (Optional[bool]): Whether self signed JWT should
+ be used for service account credentials.
Raises:
google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport
@@ -198,6 +201,7 @@ def __init__(
scopes=scopes,
quota_project_id=quota_project_id,
client_info=client_info,
+ always_use_jwt_access=always_use_jwt_access,
)
if not self._grpc_channel:
diff --git a/google/cloud/dialogflowcx_v3beta1/services/test_cases/transports/base.py b/google/cloud/dialogflowcx_v3beta1/services/test_cases/transports/base.py
index 938dea49..5aabda79 100644
--- a/google/cloud/dialogflowcx_v3beta1/services/test_cases/transports/base.py
+++ b/google/cloud/dialogflowcx_v3beta1/services/test_cases/transports/base.py
@@ -25,6 +25,7 @@
from google.api_core import retry as retries # type: ignore
from google.api_core import operations_v1 # type: ignore
from google.auth import credentials as ga_credentials # type: ignore
+from google.oauth2 import service_account # type: ignore
from google.cloud.dialogflowcx_v3beta1.types import test_case
from google.cloud.dialogflowcx_v3beta1.types import test_case as gcdc_test_case
@@ -49,8 +50,6 @@
except pkg_resources.DistributionNotFound: # pragma: NO COVER
_GOOGLE_AUTH_VERSION = None
-_API_CORE_VERSION = google.api_core.__version__
-
class TestCasesTransport(abc.ABC):
"""Abstract transport class for TestCases."""
@@ -71,6 +70,7 @@ def __init__(
scopes: Optional[Sequence[str]] = None,
quota_project_id: Optional[str] = None,
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
+ always_use_jwt_access: Optional[bool] = False,
**kwargs,
) -> None:
"""Instantiate the transport.
@@ -94,6 +94,8 @@ def __init__(
API requests. If ``None``, then default info will be used.
Generally, you only need to set this if you're developing
your own client library.
+ always_use_jwt_access (Optional[bool]): Whether self signed JWT should
+ be used for service account credentials.
"""
# Save the hostname. Default to port 443 (HTTPS) if none is specified.
if ":" not in host:
@@ -103,7 +105,7 @@ def __init__(
scopes_kwargs = self._get_scopes_kwargs(self._host, scopes)
# Save the scopes.
- self._scopes = scopes or self.AUTH_SCOPES
+ self._scopes = scopes
# If no credentials are provided, then determine the appropriate
# defaults.
@@ -122,13 +124,20 @@ def __init__(
**scopes_kwargs, quota_project_id=quota_project_id
)
+ # If the credentials is service account credentials, then always try to use self signed JWT.
+ if (
+ always_use_jwt_access
+ and isinstance(credentials, service_account.Credentials)
+ and hasattr(service_account.Credentials, "with_always_use_jwt_access")
+ ):
+ credentials = credentials.with_always_use_jwt_access(True)
+
# Save the credentials.
self._credentials = credentials
- # TODO(busunkim): These two class methods are in the base transport
+ # 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-api-core
- # and google-auth are increased.
+ # 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
@@ -149,27 +158,6 @@ def _get_scopes_kwargs(
return scopes_kwargs
- # TODO: Remove this function once google-api-core >= 1.26.0 is required
- @classmethod
- def _get_self_signed_jwt_kwargs(
- cls, host: str, scopes: Optional[Sequence[str]]
- ) -> Dict[str, Union[Optional[Sequence[str]], str]]:
- """Returns kwargs to pass to grpc_helpers.create_channel depending on the google-api-core version"""
-
- self_signed_jwt_kwargs: Dict[str, Union[Optional[Sequence[str]], str]] = {}
-
- if _API_CORE_VERSION and (
- packaging.version.parse(_API_CORE_VERSION)
- >= packaging.version.parse("1.26.0")
- ):
- self_signed_jwt_kwargs["default_scopes"] = cls.AUTH_SCOPES
- self_signed_jwt_kwargs["scopes"] = scopes
- self_signed_jwt_kwargs["default_host"] = cls.DEFAULT_HOST
- else:
- self_signed_jwt_kwargs["scopes"] = scopes or cls.AUTH_SCOPES
-
- return self_signed_jwt_kwargs
-
def _prep_wrapped_messages(self, client_info):
# Precompute the wrapped methods.
self._wrapped_methods = {
diff --git a/google/cloud/dialogflowcx_v3beta1/services/test_cases/transports/grpc.py b/google/cloud/dialogflowcx_v3beta1/services/test_cases/transports/grpc.py
index 0177d4dd..6bbaa6e9 100644
--- a/google/cloud/dialogflowcx_v3beta1/services/test_cases/transports/grpc.py
+++ b/google/cloud/dialogflowcx_v3beta1/services/test_cases/transports/grpc.py
@@ -63,6 +63,7 @@ def __init__(
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
quota_project_id: Optional[str] = None,
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
+ always_use_jwt_access: Optional[bool] = False,
) -> None:
"""Instantiate the transport.
@@ -103,6 +104,8 @@ def __init__(
API requests. If ``None``, then default info will be used.
Generally, you only need to set this if you're developing
your own client library.
+ always_use_jwt_access (Optional[bool]): Whether self signed JWT should
+ be used for service account credentials.
Raises:
google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport
@@ -156,6 +159,7 @@ def __init__(
scopes=scopes,
quota_project_id=quota_project_id,
client_info=client_info,
+ always_use_jwt_access=always_use_jwt_access,
)
if not self._grpc_channel:
@@ -211,14 +215,14 @@ def create_channel(
and ``credentials_file`` are passed.
"""
- self_signed_jwt_kwargs = cls._get_self_signed_jwt_kwargs(host, scopes)
-
return grpc_helpers.create_channel(
host,
credentials=credentials,
credentials_file=credentials_file,
quota_project_id=quota_project_id,
- **self_signed_jwt_kwargs,
+ default_scopes=cls.AUTH_SCOPES,
+ scopes=scopes,
+ default_host=cls.DEFAULT_HOST,
**kwargs,
)
diff --git a/google/cloud/dialogflowcx_v3beta1/services/test_cases/transports/grpc_asyncio.py b/google/cloud/dialogflowcx_v3beta1/services/test_cases/transports/grpc_asyncio.py
index 6b687ebd..a07ff2f2 100644
--- a/google/cloud/dialogflowcx_v3beta1/services/test_cases/transports/grpc_asyncio.py
+++ b/google/cloud/dialogflowcx_v3beta1/services/test_cases/transports/grpc_asyncio.py
@@ -84,14 +84,14 @@ def create_channel(
aio.Channel: A gRPC AsyncIO channel object.
"""
- self_signed_jwt_kwargs = cls._get_self_signed_jwt_kwargs(host, scopes)
-
return grpc_helpers_async.create_channel(
host,
credentials=credentials,
credentials_file=credentials_file,
quota_project_id=quota_project_id,
- **self_signed_jwt_kwargs,
+ default_scopes=cls.AUTH_SCOPES,
+ scopes=scopes,
+ default_host=cls.DEFAULT_HOST,
**kwargs,
)
@@ -109,6 +109,7 @@ def __init__(
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
quota_project_id=None,
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
+ always_use_jwt_access: Optional[bool] = False,
) -> None:
"""Instantiate the transport.
@@ -150,6 +151,8 @@ def __init__(
API requests. If ``None``, then default info will be used.
Generally, you only need to set this if you're developing
your own client library.
+ always_use_jwt_access (Optional[bool]): Whether self signed JWT should
+ be used for service account credentials.
Raises:
google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport
@@ -202,6 +205,7 @@ def __init__(
scopes=scopes,
quota_project_id=quota_project_id,
client_info=client_info,
+ always_use_jwt_access=always_use_jwt_access,
)
if not self._grpc_channel:
diff --git a/google/cloud/dialogflowcx_v3beta1/services/transition_route_groups/async_client.py b/google/cloud/dialogflowcx_v3beta1/services/transition_route_groups/async_client.py
index ebd3a056..9c14f4d3 100644
--- a/google/cloud/dialogflowcx_v3beta1/services/transition_route_groups/async_client.py
+++ b/google/cloud/dialogflowcx_v3beta1/services/transition_route_groups/async_client.py
@@ -355,6 +355,10 @@ async def create_transition_route_group(
[TransitionRouteGroup][google.cloud.dialogflow.cx.v3beta1.TransitionRouteGroup]
in the specified flow.
+ Note: You should always train a flow prior to sending it
+ queries. See the `training
+ documentation `__.
+
Args:
request (:class:`google.cloud.dialogflowcx_v3beta1.types.CreateTransitionRouteGroupRequest`):
The request object. The request message for
@@ -441,6 +445,10 @@ async def update_transition_route_group(
r"""Updates the specified
[TransitionRouteGroup][google.cloud.dialogflow.cx.v3beta1.TransitionRouteGroup].
+ Note: You should always train a flow prior to sending it
+ queries. See the `training
+ documentation `__.
+
Args:
request (:class:`google.cloud.dialogflowcx_v3beta1.types.UpdateTransitionRouteGroupRequest`):
The request object. The request message for
@@ -526,6 +534,10 @@ async def delete_transition_route_group(
r"""Deletes the specified
[TransitionRouteGroup][google.cloud.dialogflow.cx.v3beta1.TransitionRouteGroup].
+ Note: You should always train a flow prior to sending it
+ queries. See the `training
+ documentation `__.
+
Args:
request (:class:`google.cloud.dialogflowcx_v3beta1.types.DeleteTransitionRouteGroupRequest`):
The request object. The request message for
diff --git a/google/cloud/dialogflowcx_v3beta1/services/transition_route_groups/client.py b/google/cloud/dialogflowcx_v3beta1/services/transition_route_groups/client.py
index 9cab10af..71bf0139 100644
--- a/google/cloud/dialogflowcx_v3beta1/services/transition_route_groups/client.py
+++ b/google/cloud/dialogflowcx_v3beta1/services/transition_route_groups/client.py
@@ -607,6 +607,10 @@ def create_transition_route_group(
[TransitionRouteGroup][google.cloud.dialogflow.cx.v3beta1.TransitionRouteGroup]
in the specified flow.
+ Note: You should always train a flow prior to sending it
+ queries. See the `training
+ documentation `__.
+
Args:
request (google.cloud.dialogflowcx_v3beta1.types.CreateTransitionRouteGroupRequest):
The request object. The request message for
@@ -699,6 +703,10 @@ def update_transition_route_group(
r"""Updates the specified
[TransitionRouteGroup][google.cloud.dialogflow.cx.v3beta1.TransitionRouteGroup].
+ Note: You should always train a flow prior to sending it
+ queries. See the `training
+ documentation `__.
+
Args:
request (google.cloud.dialogflowcx_v3beta1.types.UpdateTransitionRouteGroupRequest):
The request object. The request message for
@@ -790,6 +798,10 @@ def delete_transition_route_group(
r"""Deletes the specified
[TransitionRouteGroup][google.cloud.dialogflow.cx.v3beta1.TransitionRouteGroup].
+ Note: You should always train a flow prior to sending it
+ queries. See the `training
+ documentation `__.
+
Args:
request (google.cloud.dialogflowcx_v3beta1.types.DeleteTransitionRouteGroupRequest):
The request object. The request message for
diff --git a/google/cloud/dialogflowcx_v3beta1/services/transition_route_groups/transports/base.py b/google/cloud/dialogflowcx_v3beta1/services/transition_route_groups/transports/base.py
index e7287904..56c11af2 100644
--- a/google/cloud/dialogflowcx_v3beta1/services/transition_route_groups/transports/base.py
+++ b/google/cloud/dialogflowcx_v3beta1/services/transition_route_groups/transports/base.py
@@ -24,6 +24,7 @@
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
from google.cloud.dialogflowcx_v3beta1.types import transition_route_group
from google.cloud.dialogflowcx_v3beta1.types import (
@@ -49,8 +50,6 @@
except pkg_resources.DistributionNotFound: # pragma: NO COVER
_GOOGLE_AUTH_VERSION = None
-_API_CORE_VERSION = google.api_core.__version__
-
class TransitionRouteGroupsTransport(abc.ABC):
"""Abstract transport class for TransitionRouteGroups."""
@@ -71,6 +70,7 @@ def __init__(
scopes: Optional[Sequence[str]] = None,
quota_project_id: Optional[str] = None,
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
+ always_use_jwt_access: Optional[bool] = False,
**kwargs,
) -> None:
"""Instantiate the transport.
@@ -94,6 +94,8 @@ def __init__(
API requests. If ``None``, then default info will be used.
Generally, you only need to set this if you're developing
your own client library.
+ always_use_jwt_access (Optional[bool]): Whether self signed JWT should
+ be used for service account credentials.
"""
# Save the hostname. Default to port 443 (HTTPS) if none is specified.
if ":" not in host:
@@ -103,7 +105,7 @@ def __init__(
scopes_kwargs = self._get_scopes_kwargs(self._host, scopes)
# Save the scopes.
- self._scopes = scopes or self.AUTH_SCOPES
+ self._scopes = scopes
# If no credentials are provided, then determine the appropriate
# defaults.
@@ -122,13 +124,20 @@ def __init__(
**scopes_kwargs, quota_project_id=quota_project_id
)
+ # If the credentials is service account credentials, then always try to use self signed JWT.
+ if (
+ always_use_jwt_access
+ and isinstance(credentials, service_account.Credentials)
+ and hasattr(service_account.Credentials, "with_always_use_jwt_access")
+ ):
+ credentials = credentials.with_always_use_jwt_access(True)
+
# Save the credentials.
self._credentials = credentials
- # TODO(busunkim): These two class methods are in the base transport
+ # 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-api-core
- # and google-auth are increased.
+ # 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
@@ -149,27 +158,6 @@ def _get_scopes_kwargs(
return scopes_kwargs
- # TODO: Remove this function once google-api-core >= 1.26.0 is required
- @classmethod
- def _get_self_signed_jwt_kwargs(
- cls, host: str, scopes: Optional[Sequence[str]]
- ) -> Dict[str, Union[Optional[Sequence[str]], str]]:
- """Returns kwargs to pass to grpc_helpers.create_channel depending on the google-api-core version"""
-
- self_signed_jwt_kwargs: Dict[str, Union[Optional[Sequence[str]], str]] = {}
-
- if _API_CORE_VERSION and (
- packaging.version.parse(_API_CORE_VERSION)
- >= packaging.version.parse("1.26.0")
- ):
- self_signed_jwt_kwargs["default_scopes"] = cls.AUTH_SCOPES
- self_signed_jwt_kwargs["scopes"] = scopes
- self_signed_jwt_kwargs["default_host"] = cls.DEFAULT_HOST
- else:
- self_signed_jwt_kwargs["scopes"] = scopes or cls.AUTH_SCOPES
-
- return self_signed_jwt_kwargs
-
def _prep_wrapped_messages(self, client_info):
# Precompute the wrapped methods.
self._wrapped_methods = {
diff --git a/google/cloud/dialogflowcx_v3beta1/services/transition_route_groups/transports/grpc.py b/google/cloud/dialogflowcx_v3beta1/services/transition_route_groups/transports/grpc.py
index eefe8323..a916616b 100644
--- a/google/cloud/dialogflowcx_v3beta1/services/transition_route_groups/transports/grpc.py
+++ b/google/cloud/dialogflowcx_v3beta1/services/transition_route_groups/transports/grpc.py
@@ -62,6 +62,7 @@ def __init__(
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
quota_project_id: Optional[str] = None,
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
+ always_use_jwt_access: Optional[bool] = False,
) -> None:
"""Instantiate the transport.
@@ -102,6 +103,8 @@ def __init__(
API requests. If ``None``, then default info will be used.
Generally, you only need to set this if you're developing
your own client library.
+ always_use_jwt_access (Optional[bool]): Whether self signed JWT should
+ be used for service account credentials.
Raises:
google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport
@@ -154,6 +157,7 @@ def __init__(
scopes=scopes,
quota_project_id=quota_project_id,
client_info=client_info,
+ always_use_jwt_access=always_use_jwt_access,
)
if not self._grpc_channel:
@@ -209,14 +213,14 @@ def create_channel(
and ``credentials_file`` are passed.
"""
- self_signed_jwt_kwargs = cls._get_self_signed_jwt_kwargs(host, scopes)
-
return grpc_helpers.create_channel(
host,
credentials=credentials,
credentials_file=credentials_file,
quota_project_id=quota_project_id,
- **self_signed_jwt_kwargs,
+ default_scopes=cls.AUTH_SCOPES,
+ scopes=scopes,
+ default_host=cls.DEFAULT_HOST,
**kwargs,
)
@@ -299,6 +303,10 @@ def create_transition_route_group(
[TransitionRouteGroup][google.cloud.dialogflow.cx.v3beta1.TransitionRouteGroup]
in the specified flow.
+ Note: You should always train a flow prior to sending it
+ queries. See the `training
+ documentation `__.
+
Returns:
Callable[[~.CreateTransitionRouteGroupRequest],
~.TransitionRouteGroup]:
@@ -331,6 +339,10 @@ def update_transition_route_group(
Updates the specified
[TransitionRouteGroup][google.cloud.dialogflow.cx.v3beta1.TransitionRouteGroup].
+ Note: You should always train a flow prior to sending it
+ queries. See the `training
+ documentation `__.
+
Returns:
Callable[[~.UpdateTransitionRouteGroupRequest],
~.TransitionRouteGroup]:
@@ -362,6 +374,10 @@ def delete_transition_route_group(
Deletes the specified
[TransitionRouteGroup][google.cloud.dialogflow.cx.v3beta1.TransitionRouteGroup].
+ Note: You should always train a flow prior to sending it
+ queries. See the `training
+ documentation `__.
+
Returns:
Callable[[~.DeleteTransitionRouteGroupRequest],
~.Empty]:
diff --git a/google/cloud/dialogflowcx_v3beta1/services/transition_route_groups/transports/grpc_asyncio.py b/google/cloud/dialogflowcx_v3beta1/services/transition_route_groups/transports/grpc_asyncio.py
index a9d6024d..e935b305 100644
--- a/google/cloud/dialogflowcx_v3beta1/services/transition_route_groups/transports/grpc_asyncio.py
+++ b/google/cloud/dialogflowcx_v3beta1/services/transition_route_groups/transports/grpc_asyncio.py
@@ -83,14 +83,14 @@ def create_channel(
aio.Channel: A gRPC AsyncIO channel object.
"""
- self_signed_jwt_kwargs = cls._get_self_signed_jwt_kwargs(host, scopes)
-
return grpc_helpers_async.create_channel(
host,
credentials=credentials,
credentials_file=credentials_file,
quota_project_id=quota_project_id,
- **self_signed_jwt_kwargs,
+ default_scopes=cls.AUTH_SCOPES,
+ scopes=scopes,
+ default_host=cls.DEFAULT_HOST,
**kwargs,
)
@@ -108,6 +108,7 @@ def __init__(
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
quota_project_id=None,
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
+ always_use_jwt_access: Optional[bool] = False,
) -> None:
"""Instantiate the transport.
@@ -149,6 +150,8 @@ def __init__(
API requests. If ``None``, then default info will be used.
Generally, you only need to set this if you're developing
your own client library.
+ always_use_jwt_access (Optional[bool]): Whether self signed JWT should
+ be used for service account credentials.
Raises:
google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport
@@ -200,6 +203,7 @@ def __init__(
scopes=scopes,
quota_project_id=quota_project_id,
client_info=client_info,
+ always_use_jwt_access=always_use_jwt_access,
)
if not self._grpc_channel:
@@ -302,6 +306,10 @@ def create_transition_route_group(
[TransitionRouteGroup][google.cloud.dialogflow.cx.v3beta1.TransitionRouteGroup]
in the specified flow.
+ Note: You should always train a flow prior to sending it
+ queries. See the `training
+ documentation `__.
+
Returns:
Callable[[~.CreateTransitionRouteGroupRequest],
Awaitable[~.TransitionRouteGroup]]:
@@ -334,6 +342,10 @@ def update_transition_route_group(
Updates the specified
[TransitionRouteGroup][google.cloud.dialogflow.cx.v3beta1.TransitionRouteGroup].
+ Note: You should always train a flow prior to sending it
+ queries. See the `training
+ documentation `__.
+
Returns:
Callable[[~.UpdateTransitionRouteGroupRequest],
Awaitable[~.TransitionRouteGroup]]:
@@ -366,6 +378,10 @@ def delete_transition_route_group(
Deletes the specified
[TransitionRouteGroup][google.cloud.dialogflow.cx.v3beta1.TransitionRouteGroup].
+ Note: You should always train a flow prior to sending it
+ queries. See the `training
+ documentation `__.
+
Returns:
Callable[[~.DeleteTransitionRouteGroupRequest],
Awaitable[~.Empty]]:
diff --git a/google/cloud/dialogflowcx_v3beta1/services/versions/transports/base.py b/google/cloud/dialogflowcx_v3beta1/services/versions/transports/base.py
index 32096dfa..7428f2cc 100644
--- a/google/cloud/dialogflowcx_v3beta1/services/versions/transports/base.py
+++ b/google/cloud/dialogflowcx_v3beta1/services/versions/transports/base.py
@@ -25,6 +25,7 @@
from google.api_core import retry as retries # type: ignore
from google.api_core import operations_v1 # type: ignore
from google.auth import credentials as ga_credentials # type: ignore
+from google.oauth2 import service_account # type: ignore
from google.cloud.dialogflowcx_v3beta1.types import version
from google.cloud.dialogflowcx_v3beta1.types import version as gcdc_version
@@ -49,8 +50,6 @@
except pkg_resources.DistributionNotFound: # pragma: NO COVER
_GOOGLE_AUTH_VERSION = None
-_API_CORE_VERSION = google.api_core.__version__
-
class VersionsTransport(abc.ABC):
"""Abstract transport class for Versions."""
@@ -71,6 +70,7 @@ def __init__(
scopes: Optional[Sequence[str]] = None,
quota_project_id: Optional[str] = None,
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
+ always_use_jwt_access: Optional[bool] = False,
**kwargs,
) -> None:
"""Instantiate the transport.
@@ -94,6 +94,8 @@ def __init__(
API requests. If ``None``, then default info will be used.
Generally, you only need to set this if you're developing
your own client library.
+ always_use_jwt_access (Optional[bool]): Whether self signed JWT should
+ be used for service account credentials.
"""
# Save the hostname. Default to port 443 (HTTPS) if none is specified.
if ":" not in host:
@@ -103,7 +105,7 @@ def __init__(
scopes_kwargs = self._get_scopes_kwargs(self._host, scopes)
# Save the scopes.
- self._scopes = scopes or self.AUTH_SCOPES
+ self._scopes = scopes
# If no credentials are provided, then determine the appropriate
# defaults.
@@ -122,13 +124,20 @@ def __init__(
**scopes_kwargs, quota_project_id=quota_project_id
)
+ # If the credentials is service account credentials, then always try to use self signed JWT.
+ if (
+ always_use_jwt_access
+ and isinstance(credentials, service_account.Credentials)
+ and hasattr(service_account.Credentials, "with_always_use_jwt_access")
+ ):
+ credentials = credentials.with_always_use_jwt_access(True)
+
# Save the credentials.
self._credentials = credentials
- # TODO(busunkim): These two class methods are in the base transport
+ # 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-api-core
- # and google-auth are increased.
+ # 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
@@ -149,27 +158,6 @@ def _get_scopes_kwargs(
return scopes_kwargs
- # TODO: Remove this function once google-api-core >= 1.26.0 is required
- @classmethod
- def _get_self_signed_jwt_kwargs(
- cls, host: str, scopes: Optional[Sequence[str]]
- ) -> Dict[str, Union[Optional[Sequence[str]], str]]:
- """Returns kwargs to pass to grpc_helpers.create_channel depending on the google-api-core version"""
-
- self_signed_jwt_kwargs: Dict[str, Union[Optional[Sequence[str]], str]] = {}
-
- if _API_CORE_VERSION and (
- packaging.version.parse(_API_CORE_VERSION)
- >= packaging.version.parse("1.26.0")
- ):
- self_signed_jwt_kwargs["default_scopes"] = cls.AUTH_SCOPES
- self_signed_jwt_kwargs["scopes"] = scopes
- self_signed_jwt_kwargs["default_host"] = cls.DEFAULT_HOST
- else:
- self_signed_jwt_kwargs["scopes"] = scopes or cls.AUTH_SCOPES
-
- return self_signed_jwt_kwargs
-
def _prep_wrapped_messages(self, client_info):
# Precompute the wrapped methods.
self._wrapped_methods = {
diff --git a/google/cloud/dialogflowcx_v3beta1/services/versions/transports/grpc.py b/google/cloud/dialogflowcx_v3beta1/services/versions/transports/grpc.py
index 9477f3f2..292e45c9 100644
--- a/google/cloud/dialogflowcx_v3beta1/services/versions/transports/grpc.py
+++ b/google/cloud/dialogflowcx_v3beta1/services/versions/transports/grpc.py
@@ -62,6 +62,7 @@ def __init__(
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
quota_project_id: Optional[str] = None,
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
+ always_use_jwt_access: Optional[bool] = False,
) -> None:
"""Instantiate the transport.
@@ -102,6 +103,8 @@ def __init__(
API requests. If ``None``, then default info will be used.
Generally, you only need to set this if you're developing
your own client library.
+ always_use_jwt_access (Optional[bool]): Whether self signed JWT should
+ be used for service account credentials.
Raises:
google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport
@@ -155,6 +158,7 @@ def __init__(
scopes=scopes,
quota_project_id=quota_project_id,
client_info=client_info,
+ always_use_jwt_access=always_use_jwt_access,
)
if not self._grpc_channel:
@@ -210,14 +214,14 @@ def create_channel(
and ``credentials_file`` are passed.
"""
- self_signed_jwt_kwargs = cls._get_self_signed_jwt_kwargs(host, scopes)
-
return grpc_helpers.create_channel(
host,
credentials=credentials,
credentials_file=credentials_file,
quota_project_id=quota_project_id,
- **self_signed_jwt_kwargs,
+ default_scopes=cls.AUTH_SCOPES,
+ scopes=scopes,
+ default_host=cls.DEFAULT_HOST,
**kwargs,
)
diff --git a/google/cloud/dialogflowcx_v3beta1/services/versions/transports/grpc_asyncio.py b/google/cloud/dialogflowcx_v3beta1/services/versions/transports/grpc_asyncio.py
index d1a29c1c..ad212622 100644
--- a/google/cloud/dialogflowcx_v3beta1/services/versions/transports/grpc_asyncio.py
+++ b/google/cloud/dialogflowcx_v3beta1/services/versions/transports/grpc_asyncio.py
@@ -83,14 +83,14 @@ def create_channel(
aio.Channel: A gRPC AsyncIO channel object.
"""
- self_signed_jwt_kwargs = cls._get_self_signed_jwt_kwargs(host, scopes)
-
return grpc_helpers_async.create_channel(
host,
credentials=credentials,
credentials_file=credentials_file,
quota_project_id=quota_project_id,
- **self_signed_jwt_kwargs,
+ default_scopes=cls.AUTH_SCOPES,
+ scopes=scopes,
+ default_host=cls.DEFAULT_HOST,
**kwargs,
)
@@ -108,6 +108,7 @@ def __init__(
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
quota_project_id=None,
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
+ always_use_jwt_access: Optional[bool] = False,
) -> None:
"""Instantiate the transport.
@@ -149,6 +150,8 @@ def __init__(
API requests. If ``None``, then default info will be used.
Generally, you only need to set this if you're developing
your own client library.
+ always_use_jwt_access (Optional[bool]): Whether self signed JWT should
+ be used for service account credentials.
Raises:
google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport
@@ -201,6 +204,7 @@ def __init__(
scopes=scopes,
quota_project_id=quota_project_id,
client_info=client_info,
+ always_use_jwt_access=always_use_jwt_access,
)
if not self._grpc_channel:
diff --git a/google/cloud/dialogflowcx_v3beta1/services/webhooks/transports/base.py b/google/cloud/dialogflowcx_v3beta1/services/webhooks/transports/base.py
index cb23b0a9..504b1752 100644
--- a/google/cloud/dialogflowcx_v3beta1/services/webhooks/transports/base.py
+++ b/google/cloud/dialogflowcx_v3beta1/services/webhooks/transports/base.py
@@ -24,6 +24,7 @@
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
from google.cloud.dialogflowcx_v3beta1.types import webhook
from google.cloud.dialogflowcx_v3beta1.types import webhook as gcdc_webhook
@@ -47,8 +48,6 @@
except pkg_resources.DistributionNotFound: # pragma: NO COVER
_GOOGLE_AUTH_VERSION = None
-_API_CORE_VERSION = google.api_core.__version__
-
class WebhooksTransport(abc.ABC):
"""Abstract transport class for Webhooks."""
@@ -69,6 +68,7 @@ def __init__(
scopes: Optional[Sequence[str]] = None,
quota_project_id: Optional[str] = None,
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
+ always_use_jwt_access: Optional[bool] = False,
**kwargs,
) -> None:
"""Instantiate the transport.
@@ -92,6 +92,8 @@ def __init__(
API requests. If ``None``, then default info will be used.
Generally, you only need to set this if you're developing
your own client library.
+ always_use_jwt_access (Optional[bool]): Whether self signed JWT should
+ be used for service account credentials.
"""
# Save the hostname. Default to port 443 (HTTPS) if none is specified.
if ":" not in host:
@@ -101,7 +103,7 @@ def __init__(
scopes_kwargs = self._get_scopes_kwargs(self._host, scopes)
# Save the scopes.
- self._scopes = scopes or self.AUTH_SCOPES
+ self._scopes = scopes
# If no credentials are provided, then determine the appropriate
# defaults.
@@ -120,13 +122,20 @@ def __init__(
**scopes_kwargs, quota_project_id=quota_project_id
)
+ # If the credentials is service account credentials, then always try to use self signed JWT.
+ if (
+ always_use_jwt_access
+ and isinstance(credentials, service_account.Credentials)
+ and hasattr(service_account.Credentials, "with_always_use_jwt_access")
+ ):
+ credentials = credentials.with_always_use_jwt_access(True)
+
# Save the credentials.
self._credentials = credentials
- # TODO(busunkim): These two class methods are in the base transport
+ # 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-api-core
- # and google-auth are increased.
+ # 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
@@ -147,27 +156,6 @@ def _get_scopes_kwargs(
return scopes_kwargs
- # TODO: Remove this function once google-api-core >= 1.26.0 is required
- @classmethod
- def _get_self_signed_jwt_kwargs(
- cls, host: str, scopes: Optional[Sequence[str]]
- ) -> Dict[str, Union[Optional[Sequence[str]], str]]:
- """Returns kwargs to pass to grpc_helpers.create_channel depending on the google-api-core version"""
-
- self_signed_jwt_kwargs: Dict[str, Union[Optional[Sequence[str]], str]] = {}
-
- if _API_CORE_VERSION and (
- packaging.version.parse(_API_CORE_VERSION)
- >= packaging.version.parse("1.26.0")
- ):
- self_signed_jwt_kwargs["default_scopes"] = cls.AUTH_SCOPES
- self_signed_jwt_kwargs["scopes"] = scopes
- self_signed_jwt_kwargs["default_host"] = cls.DEFAULT_HOST
- else:
- self_signed_jwt_kwargs["scopes"] = scopes or cls.AUTH_SCOPES
-
- return self_signed_jwt_kwargs
-
def _prep_wrapped_messages(self, client_info):
# Precompute the wrapped methods.
self._wrapped_methods = {
diff --git a/google/cloud/dialogflowcx_v3beta1/services/webhooks/transports/grpc.py b/google/cloud/dialogflowcx_v3beta1/services/webhooks/transports/grpc.py
index 753d2d80..0c91f64a 100644
--- a/google/cloud/dialogflowcx_v3beta1/services/webhooks/transports/grpc.py
+++ b/google/cloud/dialogflowcx_v3beta1/services/webhooks/transports/grpc.py
@@ -60,6 +60,7 @@ def __init__(
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
quota_project_id: Optional[str] = None,
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
+ always_use_jwt_access: Optional[bool] = False,
) -> None:
"""Instantiate the transport.
@@ -100,6 +101,8 @@ def __init__(
API requests. If ``None``, then default info will be used.
Generally, you only need to set this if you're developing
your own client library.
+ always_use_jwt_access (Optional[bool]): Whether self signed JWT should
+ be used for service account credentials.
Raises:
google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport
@@ -152,6 +155,7 @@ def __init__(
scopes=scopes,
quota_project_id=quota_project_id,
client_info=client_info,
+ always_use_jwt_access=always_use_jwt_access,
)
if not self._grpc_channel:
@@ -207,14 +211,14 @@ def create_channel(
and ``credentials_file`` are passed.
"""
- self_signed_jwt_kwargs = cls._get_self_signed_jwt_kwargs(host, scopes)
-
return grpc_helpers.create_channel(
host,
credentials=credentials,
credentials_file=credentials_file,
quota_project_id=quota_project_id,
- **self_signed_jwt_kwargs,
+ default_scopes=cls.AUTH_SCOPES,
+ scopes=scopes,
+ default_host=cls.DEFAULT_HOST,
**kwargs,
)
diff --git a/google/cloud/dialogflowcx_v3beta1/services/webhooks/transports/grpc_asyncio.py b/google/cloud/dialogflowcx_v3beta1/services/webhooks/transports/grpc_asyncio.py
index 2279f27d..bb86cf6e 100644
--- a/google/cloud/dialogflowcx_v3beta1/services/webhooks/transports/grpc_asyncio.py
+++ b/google/cloud/dialogflowcx_v3beta1/services/webhooks/transports/grpc_asyncio.py
@@ -81,14 +81,14 @@ def create_channel(
aio.Channel: A gRPC AsyncIO channel object.
"""
- self_signed_jwt_kwargs = cls._get_self_signed_jwt_kwargs(host, scopes)
-
return grpc_helpers_async.create_channel(
host,
credentials=credentials,
credentials_file=credentials_file,
quota_project_id=quota_project_id,
- **self_signed_jwt_kwargs,
+ default_scopes=cls.AUTH_SCOPES,
+ scopes=scopes,
+ default_host=cls.DEFAULT_HOST,
**kwargs,
)
@@ -106,6 +106,7 @@ def __init__(
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
quota_project_id=None,
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
+ always_use_jwt_access: Optional[bool] = False,
) -> None:
"""Instantiate the transport.
@@ -147,6 +148,8 @@ def __init__(
API requests. If ``None``, then default info will be used.
Generally, you only need to set this if you're developing
your own client library.
+ always_use_jwt_access (Optional[bool]): Whether self signed JWT should
+ be used for service account credentials.
Raises:
google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport
@@ -198,6 +201,7 @@ def __init__(
scopes=scopes,
quota_project_id=quota_project_id,
client_info=client_info,
+ always_use_jwt_access=always_use_jwt_access,
)
if not self._grpc_channel:
diff --git a/samples/snippets/requirements.txt b/samples/snippets/requirements.txt
index 6bcff5f1..4fad115e 100644
--- a/samples/snippets/requirements.txt
+++ b/samples/snippets/requirements.txt
@@ -1 +1 @@
-google-cloud-dialogflow-cx==0.6.0
+google-cloud-dialogflow-cx==0.7.1
diff --git a/setup.py b/setup.py
index f7a8605e..5464de85 100644
--- a/setup.py
+++ b/setup.py
@@ -19,7 +19,7 @@
import os
import setuptools # type: ignore
-version = "0.7.1"
+version = "0.8.0"
package_root = os.path.abspath(os.path.dirname(__file__))
@@ -45,7 +45,7 @@
platforms="Posix; MacOS X; Windows",
include_package_data=True,
install_requires=(
- "google-api-core[grpc] >= 1.22.2, < 2.0.0dev",
+ "google-api-core[grpc] >= 1.26.0, < 2.0.0dev",
"proto-plus >= 1.4.0",
"packaging >= 14.3",
),
diff --git a/testing/constraints-3.6.txt b/testing/constraints-3.6.txt
index 05a62e3a..1b1c1ae9 100644
--- a/testing/constraints-3.6.txt
+++ b/testing/constraints-3.6.txt
@@ -5,7 +5,7 @@
#
# 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.22.2
+google-api-core==1.26.0
proto-plus==1.4.0
packaging==14.3
google-auth==1.24.0 # TODO: remove when google-auth>=1.25.0 is required through google-api-core
diff --git a/tests/unit/gapic/dialogflowcx_v3/test_agents.py b/tests/unit/gapic/dialogflowcx_v3/test_agents.py
index 83921c26..0625f8f9 100644
--- a/tests/unit/gapic/dialogflowcx_v3/test_agents.py
+++ b/tests/unit/gapic/dialogflowcx_v3/test_agents.py
@@ -38,9 +38,6 @@
from google.cloud.dialogflowcx_v3.services.agents import AgentsClient
from google.cloud.dialogflowcx_v3.services.agents import pagers
from google.cloud.dialogflowcx_v3.services.agents import transports
-from google.cloud.dialogflowcx_v3.services.agents.transports.base import (
- _API_CORE_VERSION,
-)
from google.cloud.dialogflowcx_v3.services.agents.transports.base import (
_GOOGLE_AUTH_VERSION,
)
@@ -54,8 +51,9 @@
import google.auth
-# TODO(busunkim): Once google-api-core >= 1.26.0 is required:
-# - Delete all the api-core and auth "less than" test cases
+# TODO(busunkim): Once google-auth >= 1.25.0 is required transitively
+# through google-api-core:
+# - Delete the auth "less than" test cases
# - Delete these pytest markers (Make the "greater than or equal to" tests the default).
requires_google_auth_lt_1_25_0 = pytest.mark.skipif(
packaging.version.parse(_GOOGLE_AUTH_VERSION) >= packaging.version.parse("1.25.0"),
@@ -66,16 +64,6 @@
reason="This test requires google-auth >= 1.25.0",
)
-requires_api_core_lt_1_26_0 = pytest.mark.skipif(
- packaging.version.parse(_API_CORE_VERSION) >= packaging.version.parse("1.26.0"),
- reason="This test requires google-api-core < 1.26.0",
-)
-
-requires_api_core_gte_1_26_0 = pytest.mark.skipif(
- packaging.version.parse(_API_CORE_VERSION) < packaging.version.parse("1.26.0"),
- reason="This test requires google-api-core >= 1.26.0",
-)
-
def client_cert_source_callback():
return b"cert bytes", b"key bytes"
@@ -130,6 +118,34 @@ def test_agents_client_from_service_account_info(client_class):
assert client.transport._host == "dialogflow.googleapis.com:443"
+@pytest.mark.parametrize("client_class", [AgentsClient, AgentsAsyncClient,])
+def test_agents_client_service_account_always_use_jwt(client_class):
+ with mock.patch.object(
+ service_account.Credentials, "with_always_use_jwt_access", create=True
+ ) as use_jwt:
+ creds = service_account.Credentials(None, None, None)
+ client = client_class(credentials=creds)
+ use_jwt.assert_not_called()
+
+
+@pytest.mark.parametrize(
+ "transport_class,transport_name",
+ [
+ (transports.AgentsGrpcTransport, "grpc"),
+ (transports.AgentsGrpcAsyncIOTransport, "grpc_asyncio"),
+ ],
+)
+def test_agents_client_service_account_always_use_jwt_true(
+ transport_class, transport_name
+):
+ with mock.patch.object(
+ service_account.Credentials, "with_always_use_jwt_access", create=True
+ ) as use_jwt:
+ creds = service_account.Credentials(None, None, None)
+ transport = transport_class(credentials=creds, always_use_jwt_access=True)
+ use_jwt.assert_called_once_with(True)
+
+
@pytest.mark.parametrize("client_class", [AgentsClient, AgentsAsyncClient,])
def test_agents_client_from_service_account_file(client_class):
creds = ga_credentials.AnonymousCredentials()
@@ -2510,7 +2526,6 @@ def test_agents_transport_auth_adc_old_google_auth(transport_class):
(transports.AgentsGrpcAsyncIOTransport, grpc_helpers_async),
],
)
-@requires_api_core_gte_1_26_0
def test_agents_transport_create_channel(transport_class, grpc_helpers):
# If credentials and host are not provided, the transport class should use
# ADC credentials.
@@ -2542,78 +2557,6 @@ def test_agents_transport_create_channel(transport_class, grpc_helpers):
)
-@pytest.mark.parametrize(
- "transport_class,grpc_helpers",
- [
- (transports.AgentsGrpcTransport, grpc_helpers),
- (transports.AgentsGrpcAsyncIOTransport, grpc_helpers_async),
- ],
-)
-@requires_api_core_lt_1_26_0
-def test_agents_transport_create_channel_old_api_core(transport_class, grpc_helpers):
- # If credentials and host are not provided, the transport class should use
- # ADC credentials.
- with mock.patch.object(
- google.auth, "default", autospec=True
- ) as adc, mock.patch.object(
- grpc_helpers, "create_channel", autospec=True
- ) as create_channel:
- creds = ga_credentials.AnonymousCredentials()
- adc.return_value = (creds, None)
- transport_class(quota_project_id="octopus")
-
- create_channel.assert_called_with(
- "dialogflow.googleapis.com:443",
- credentials=creds,
- credentials_file=None,
- quota_project_id="octopus",
- scopes=(
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/dialogflow",
- ),
- ssl_credentials=None,
- options=[
- ("grpc.max_send_message_length", -1),
- ("grpc.max_receive_message_length", -1),
- ],
- )
-
-
-@pytest.mark.parametrize(
- "transport_class,grpc_helpers",
- [
- (transports.AgentsGrpcTransport, grpc_helpers),
- (transports.AgentsGrpcAsyncIOTransport, grpc_helpers_async),
- ],
-)
-@requires_api_core_lt_1_26_0
-def test_agents_transport_create_channel_user_scopes(transport_class, grpc_helpers):
- # If credentials and host are not provided, the transport class should use
- # ADC credentials.
- with mock.patch.object(
- google.auth, "default", autospec=True
- ) as adc, mock.patch.object(
- grpc_helpers, "create_channel", autospec=True
- ) as create_channel:
- creds = ga_credentials.AnonymousCredentials()
- adc.return_value = (creds, None)
-
- transport_class(quota_project_id="octopus", scopes=["1", "2"])
-
- create_channel.assert_called_with(
- "dialogflow.googleapis.com:443",
- credentials=creds,
- credentials_file=None,
- quota_project_id="octopus",
- scopes=["1", "2"],
- ssl_credentials=None,
- options=[
- ("grpc.max_send_message_length", -1),
- ("grpc.max_receive_message_length", -1),
- ],
- )
-
-
@pytest.mark.parametrize(
"transport_class",
[transports.AgentsGrpcTransport, transports.AgentsGrpcAsyncIOTransport],
@@ -2633,10 +2576,7 @@ def test_agents_grpc_transport_client_cert_source_for_mtls(transport_class):
"squid.clam.whelk:443",
credentials=cred,
credentials_file=None,
- scopes=(
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/dialogflow",
- ),
+ scopes=None,
ssl_credentials=mock_ssl_channel_creds,
quota_project_id=None,
options=[
@@ -2740,10 +2680,7 @@ def test_agents_transport_channel_mtls_with_client_cert_source(transport_class):
"mtls.squid.clam.whelk:443",
credentials=cred,
credentials_file=None,
- scopes=(
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/dialogflow",
- ),
+ scopes=None,
ssl_credentials=mock_ssl_cred,
quota_project_id=None,
options=[
@@ -2787,10 +2724,7 @@ def test_agents_transport_channel_mtls_with_adc(transport_class):
"mtls.squid.clam.whelk:443",
credentials=mock_cred,
credentials_file=None,
- scopes=(
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/dialogflow",
- ),
+ scopes=None,
ssl_credentials=mock_ssl_cred,
quota_project_id=None,
options=[
diff --git a/tests/unit/gapic/dialogflowcx_v3/test_entity_types.py b/tests/unit/gapic/dialogflowcx_v3/test_entity_types.py
index b2d6e0f3..dd426ff9 100644
--- a/tests/unit/gapic/dialogflowcx_v3/test_entity_types.py
+++ b/tests/unit/gapic/dialogflowcx_v3/test_entity_types.py
@@ -35,9 +35,6 @@
from google.cloud.dialogflowcx_v3.services.entity_types import EntityTypesClient
from google.cloud.dialogflowcx_v3.services.entity_types import pagers
from google.cloud.dialogflowcx_v3.services.entity_types import transports
-from google.cloud.dialogflowcx_v3.services.entity_types.transports.base import (
- _API_CORE_VERSION,
-)
from google.cloud.dialogflowcx_v3.services.entity_types.transports.base import (
_GOOGLE_AUTH_VERSION,
)
@@ -48,8 +45,9 @@
import google.auth
-# TODO(busunkim): Once google-api-core >= 1.26.0 is required:
-# - Delete all the api-core and auth "less than" test cases
+# TODO(busunkim): Once google-auth >= 1.25.0 is required transitively
+# through google-api-core:
+# - Delete the auth "less than" test cases
# - Delete these pytest markers (Make the "greater than or equal to" tests the default).
requires_google_auth_lt_1_25_0 = pytest.mark.skipif(
packaging.version.parse(_GOOGLE_AUTH_VERSION) >= packaging.version.parse("1.25.0"),
@@ -60,16 +58,6 @@
reason="This test requires google-auth >= 1.25.0",
)
-requires_api_core_lt_1_26_0 = pytest.mark.skipif(
- packaging.version.parse(_API_CORE_VERSION) >= packaging.version.parse("1.26.0"),
- reason="This test requires google-api-core < 1.26.0",
-)
-
-requires_api_core_gte_1_26_0 = pytest.mark.skipif(
- packaging.version.parse(_API_CORE_VERSION) < packaging.version.parse("1.26.0"),
- reason="This test requires google-api-core >= 1.26.0",
-)
-
def client_cert_source_callback():
return b"cert bytes", b"key bytes"
@@ -127,6 +115,34 @@ def test_entity_types_client_from_service_account_info(client_class):
assert client.transport._host == "dialogflow.googleapis.com:443"
+@pytest.mark.parametrize("client_class", [EntityTypesClient, EntityTypesAsyncClient,])
+def test_entity_types_client_service_account_always_use_jwt(client_class):
+ with mock.patch.object(
+ service_account.Credentials, "with_always_use_jwt_access", create=True
+ ) as use_jwt:
+ creds = service_account.Credentials(None, None, None)
+ client = client_class(credentials=creds)
+ use_jwt.assert_not_called()
+
+
+@pytest.mark.parametrize(
+ "transport_class,transport_name",
+ [
+ (transports.EntityTypesGrpcTransport, "grpc"),
+ (transports.EntityTypesGrpcAsyncIOTransport, "grpc_asyncio"),
+ ],
+)
+def test_entity_types_client_service_account_always_use_jwt_true(
+ transport_class, transport_name
+):
+ with mock.patch.object(
+ service_account.Credentials, "with_always_use_jwt_access", create=True
+ ) as use_jwt:
+ creds = service_account.Credentials(None, None, None)
+ transport = transport_class(credentials=creds, always_use_jwt_access=True)
+ use_jwt.assert_called_once_with(True)
+
+
@pytest.mark.parametrize("client_class", [EntityTypesClient, EntityTypesAsyncClient,])
def test_entity_types_client_from_service_account_file(client_class):
creds = ga_credentials.AnonymousCredentials()
@@ -2008,7 +2024,6 @@ def test_entity_types_transport_auth_adc_old_google_auth(transport_class):
(transports.EntityTypesGrpcAsyncIOTransport, grpc_helpers_async),
],
)
-@requires_api_core_gte_1_26_0
def test_entity_types_transport_create_channel(transport_class, grpc_helpers):
# If credentials and host are not provided, the transport class should use
# ADC credentials.
@@ -2040,82 +2055,6 @@ def test_entity_types_transport_create_channel(transport_class, grpc_helpers):
)
-@pytest.mark.parametrize(
- "transport_class,grpc_helpers",
- [
- (transports.EntityTypesGrpcTransport, grpc_helpers),
- (transports.EntityTypesGrpcAsyncIOTransport, grpc_helpers_async),
- ],
-)
-@requires_api_core_lt_1_26_0
-def test_entity_types_transport_create_channel_old_api_core(
- transport_class, grpc_helpers
-):
- # If credentials and host are not provided, the transport class should use
- # ADC credentials.
- with mock.patch.object(
- google.auth, "default", autospec=True
- ) as adc, mock.patch.object(
- grpc_helpers, "create_channel", autospec=True
- ) as create_channel:
- creds = ga_credentials.AnonymousCredentials()
- adc.return_value = (creds, None)
- transport_class(quota_project_id="octopus")
-
- create_channel.assert_called_with(
- "dialogflow.googleapis.com:443",
- credentials=creds,
- credentials_file=None,
- quota_project_id="octopus",
- scopes=(
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/dialogflow",
- ),
- ssl_credentials=None,
- options=[
- ("grpc.max_send_message_length", -1),
- ("grpc.max_receive_message_length", -1),
- ],
- )
-
-
-@pytest.mark.parametrize(
- "transport_class,grpc_helpers",
- [
- (transports.EntityTypesGrpcTransport, grpc_helpers),
- (transports.EntityTypesGrpcAsyncIOTransport, grpc_helpers_async),
- ],
-)
-@requires_api_core_lt_1_26_0
-def test_entity_types_transport_create_channel_user_scopes(
- transport_class, grpc_helpers
-):
- # If credentials and host are not provided, the transport class should use
- # ADC credentials.
- with mock.patch.object(
- google.auth, "default", autospec=True
- ) as adc, mock.patch.object(
- grpc_helpers, "create_channel", autospec=True
- ) as create_channel:
- creds = ga_credentials.AnonymousCredentials()
- adc.return_value = (creds, None)
-
- transport_class(quota_project_id="octopus", scopes=["1", "2"])
-
- create_channel.assert_called_with(
- "dialogflow.googleapis.com:443",
- credentials=creds,
- credentials_file=None,
- quota_project_id="octopus",
- scopes=["1", "2"],
- ssl_credentials=None,
- options=[
- ("grpc.max_send_message_length", -1),
- ("grpc.max_receive_message_length", -1),
- ],
- )
-
-
@pytest.mark.parametrize(
"transport_class",
[transports.EntityTypesGrpcTransport, transports.EntityTypesGrpcAsyncIOTransport],
@@ -2135,10 +2074,7 @@ def test_entity_types_grpc_transport_client_cert_source_for_mtls(transport_class
"squid.clam.whelk:443",
credentials=cred,
credentials_file=None,
- scopes=(
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/dialogflow",
- ),
+ scopes=None,
ssl_credentials=mock_ssl_channel_creds,
quota_project_id=None,
options=[
@@ -2242,10 +2178,7 @@ def test_entity_types_transport_channel_mtls_with_client_cert_source(transport_c
"mtls.squid.clam.whelk:443",
credentials=cred,
credentials_file=None,
- scopes=(
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/dialogflow",
- ),
+ scopes=None,
ssl_credentials=mock_ssl_cred,
quota_project_id=None,
options=[
@@ -2289,10 +2222,7 @@ def test_entity_types_transport_channel_mtls_with_adc(transport_class):
"mtls.squid.clam.whelk:443",
credentials=mock_cred,
credentials_file=None,
- scopes=(
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/dialogflow",
- ),
+ scopes=None,
ssl_credentials=mock_ssl_cred,
quota_project_id=None,
options=[
diff --git a/tests/unit/gapic/dialogflowcx_v3/test_environments.py b/tests/unit/gapic/dialogflowcx_v3/test_environments.py
index 33277fdb..47f3d46f 100644
--- a/tests/unit/gapic/dialogflowcx_v3/test_environments.py
+++ b/tests/unit/gapic/dialogflowcx_v3/test_environments.py
@@ -38,9 +38,6 @@
from google.cloud.dialogflowcx_v3.services.environments import EnvironmentsClient
from google.cloud.dialogflowcx_v3.services.environments import pagers
from google.cloud.dialogflowcx_v3.services.environments import transports
-from google.cloud.dialogflowcx_v3.services.environments.transports.base import (
- _API_CORE_VERSION,
-)
from google.cloud.dialogflowcx_v3.services.environments.transports.base import (
_GOOGLE_AUTH_VERSION,
)
@@ -54,8 +51,9 @@
import google.auth
-# TODO(busunkim): Once google-api-core >= 1.26.0 is required:
-# - Delete all the api-core and auth "less than" test cases
+# TODO(busunkim): Once google-auth >= 1.25.0 is required transitively
+# through google-api-core:
+# - Delete the auth "less than" test cases
# - Delete these pytest markers (Make the "greater than or equal to" tests the default).
requires_google_auth_lt_1_25_0 = pytest.mark.skipif(
packaging.version.parse(_GOOGLE_AUTH_VERSION) >= packaging.version.parse("1.25.0"),
@@ -66,16 +64,6 @@
reason="This test requires google-auth >= 1.25.0",
)
-requires_api_core_lt_1_26_0 = pytest.mark.skipif(
- packaging.version.parse(_API_CORE_VERSION) >= packaging.version.parse("1.26.0"),
- reason="This test requires google-api-core < 1.26.0",
-)
-
-requires_api_core_gte_1_26_0 = pytest.mark.skipif(
- packaging.version.parse(_API_CORE_VERSION) < packaging.version.parse("1.26.0"),
- reason="This test requires google-api-core >= 1.26.0",
-)
-
def client_cert_source_callback():
return b"cert bytes", b"key bytes"
@@ -133,6 +121,34 @@ def test_environments_client_from_service_account_info(client_class):
assert client.transport._host == "dialogflow.googleapis.com:443"
+@pytest.mark.parametrize("client_class", [EnvironmentsClient, EnvironmentsAsyncClient,])
+def test_environments_client_service_account_always_use_jwt(client_class):
+ with mock.patch.object(
+ service_account.Credentials, "with_always_use_jwt_access", create=True
+ ) as use_jwt:
+ creds = service_account.Credentials(None, None, None)
+ client = client_class(credentials=creds)
+ use_jwt.assert_not_called()
+
+
+@pytest.mark.parametrize(
+ "transport_class,transport_name",
+ [
+ (transports.EnvironmentsGrpcTransport, "grpc"),
+ (transports.EnvironmentsGrpcAsyncIOTransport, "grpc_asyncio"),
+ ],
+)
+def test_environments_client_service_account_always_use_jwt_true(
+ transport_class, transport_name
+):
+ with mock.patch.object(
+ service_account.Credentials, "with_always_use_jwt_access", create=True
+ ) as use_jwt:
+ creds = service_account.Credentials(None, None, None)
+ transport = transport_class(credentials=creds, always_use_jwt_access=True)
+ use_jwt.assert_called_once_with(True)
+
+
@pytest.mark.parametrize("client_class", [EnvironmentsClient, EnvironmentsAsyncClient,])
def test_environments_client_from_service_account_file(client_class):
creds = ga_credentials.AnonymousCredentials()
@@ -2845,7 +2861,6 @@ def test_environments_transport_auth_adc_old_google_auth(transport_class):
(transports.EnvironmentsGrpcAsyncIOTransport, grpc_helpers_async),
],
)
-@requires_api_core_gte_1_26_0
def test_environments_transport_create_channel(transport_class, grpc_helpers):
# If credentials and host are not provided, the transport class should use
# ADC credentials.
@@ -2877,82 +2892,6 @@ def test_environments_transport_create_channel(transport_class, grpc_helpers):
)
-@pytest.mark.parametrize(
- "transport_class,grpc_helpers",
- [
- (transports.EnvironmentsGrpcTransport, grpc_helpers),
- (transports.EnvironmentsGrpcAsyncIOTransport, grpc_helpers_async),
- ],
-)
-@requires_api_core_lt_1_26_0
-def test_environments_transport_create_channel_old_api_core(
- transport_class, grpc_helpers
-):
- # If credentials and host are not provided, the transport class should use
- # ADC credentials.
- with mock.patch.object(
- google.auth, "default", autospec=True
- ) as adc, mock.patch.object(
- grpc_helpers, "create_channel", autospec=True
- ) as create_channel:
- creds = ga_credentials.AnonymousCredentials()
- adc.return_value = (creds, None)
- transport_class(quota_project_id="octopus")
-
- create_channel.assert_called_with(
- "dialogflow.googleapis.com:443",
- credentials=creds,
- credentials_file=None,
- quota_project_id="octopus",
- scopes=(
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/dialogflow",
- ),
- ssl_credentials=None,
- options=[
- ("grpc.max_send_message_length", -1),
- ("grpc.max_receive_message_length", -1),
- ],
- )
-
-
-@pytest.mark.parametrize(
- "transport_class,grpc_helpers",
- [
- (transports.EnvironmentsGrpcTransport, grpc_helpers),
- (transports.EnvironmentsGrpcAsyncIOTransport, grpc_helpers_async),
- ],
-)
-@requires_api_core_lt_1_26_0
-def test_environments_transport_create_channel_user_scopes(
- transport_class, grpc_helpers
-):
- # If credentials and host are not provided, the transport class should use
- # ADC credentials.
- with mock.patch.object(
- google.auth, "default", autospec=True
- ) as adc, mock.patch.object(
- grpc_helpers, "create_channel", autospec=True
- ) as create_channel:
- creds = ga_credentials.AnonymousCredentials()
- adc.return_value = (creds, None)
-
- transport_class(quota_project_id="octopus", scopes=["1", "2"])
-
- create_channel.assert_called_with(
- "dialogflow.googleapis.com:443",
- credentials=creds,
- credentials_file=None,
- quota_project_id="octopus",
- scopes=["1", "2"],
- ssl_credentials=None,
- options=[
- ("grpc.max_send_message_length", -1),
- ("grpc.max_receive_message_length", -1),
- ],
- )
-
-
@pytest.mark.parametrize(
"transport_class",
[transports.EnvironmentsGrpcTransport, transports.EnvironmentsGrpcAsyncIOTransport],
@@ -2972,10 +2911,7 @@ def test_environments_grpc_transport_client_cert_source_for_mtls(transport_class
"squid.clam.whelk:443",
credentials=cred,
credentials_file=None,
- scopes=(
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/dialogflow",
- ),
+ scopes=None,
ssl_credentials=mock_ssl_channel_creds,
quota_project_id=None,
options=[
@@ -3079,10 +3015,7 @@ def test_environments_transport_channel_mtls_with_client_cert_source(transport_c
"mtls.squid.clam.whelk:443",
credentials=cred,
credentials_file=None,
- scopes=(
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/dialogflow",
- ),
+ scopes=None,
ssl_credentials=mock_ssl_cred,
quota_project_id=None,
options=[
@@ -3126,10 +3059,7 @@ def test_environments_transport_channel_mtls_with_adc(transport_class):
"mtls.squid.clam.whelk:443",
credentials=mock_cred,
credentials_file=None,
- scopes=(
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/dialogflow",
- ),
+ scopes=None,
ssl_credentials=mock_ssl_cred,
quota_project_id=None,
options=[
diff --git a/tests/unit/gapic/dialogflowcx_v3/test_experiments.py b/tests/unit/gapic/dialogflowcx_v3/test_experiments.py
index c27de0d0..37dc000a 100644
--- a/tests/unit/gapic/dialogflowcx_v3/test_experiments.py
+++ b/tests/unit/gapic/dialogflowcx_v3/test_experiments.py
@@ -35,9 +35,6 @@
from google.cloud.dialogflowcx_v3.services.experiments import ExperimentsClient
from google.cloud.dialogflowcx_v3.services.experiments import pagers
from google.cloud.dialogflowcx_v3.services.experiments import transports
-from google.cloud.dialogflowcx_v3.services.experiments.transports.base import (
- _API_CORE_VERSION,
-)
from google.cloud.dialogflowcx_v3.services.experiments.transports.base import (
_GOOGLE_AUTH_VERSION,
)
@@ -50,8 +47,9 @@
import google.auth
-# TODO(busunkim): Once google-api-core >= 1.26.0 is required:
-# - Delete all the api-core and auth "less than" test cases
+# TODO(busunkim): Once google-auth >= 1.25.0 is required transitively
+# through google-api-core:
+# - Delete the auth "less than" test cases
# - Delete these pytest markers (Make the "greater than or equal to" tests the default).
requires_google_auth_lt_1_25_0 = pytest.mark.skipif(
packaging.version.parse(_GOOGLE_AUTH_VERSION) >= packaging.version.parse("1.25.0"),
@@ -62,16 +60,6 @@
reason="This test requires google-auth >= 1.25.0",
)
-requires_api_core_lt_1_26_0 = pytest.mark.skipif(
- packaging.version.parse(_API_CORE_VERSION) >= packaging.version.parse("1.26.0"),
- reason="This test requires google-api-core < 1.26.0",
-)
-
-requires_api_core_gte_1_26_0 = pytest.mark.skipif(
- packaging.version.parse(_API_CORE_VERSION) < packaging.version.parse("1.26.0"),
- reason="This test requires google-api-core >= 1.26.0",
-)
-
def client_cert_source_callback():
return b"cert bytes", b"key bytes"
@@ -129,6 +117,34 @@ def test_experiments_client_from_service_account_info(client_class):
assert client.transport._host == "dialogflow.googleapis.com:443"
+@pytest.mark.parametrize("client_class", [ExperimentsClient, ExperimentsAsyncClient,])
+def test_experiments_client_service_account_always_use_jwt(client_class):
+ with mock.patch.object(
+ service_account.Credentials, "with_always_use_jwt_access", create=True
+ ) as use_jwt:
+ creds = service_account.Credentials(None, None, None)
+ client = client_class(credentials=creds)
+ use_jwt.assert_not_called()
+
+
+@pytest.mark.parametrize(
+ "transport_class,transport_name",
+ [
+ (transports.ExperimentsGrpcTransport, "grpc"),
+ (transports.ExperimentsGrpcAsyncIOTransport, "grpc_asyncio"),
+ ],
+)
+def test_experiments_client_service_account_always_use_jwt_true(
+ transport_class, transport_name
+):
+ with mock.patch.object(
+ service_account.Credentials, "with_always_use_jwt_access", create=True
+ ) as use_jwt:
+ creds = service_account.Credentials(None, None, None)
+ transport = transport_class(credentials=creds, always_use_jwt_access=True)
+ use_jwt.assert_called_once_with(True)
+
+
@pytest.mark.parametrize("client_class", [ExperimentsClient, ExperimentsAsyncClient,])
def test_experiments_client_from_service_account_file(client_class):
creds = ga_credentials.AnonymousCredentials()
@@ -2362,7 +2378,6 @@ def test_experiments_transport_auth_adc_old_google_auth(transport_class):
(transports.ExperimentsGrpcAsyncIOTransport, grpc_helpers_async),
],
)
-@requires_api_core_gte_1_26_0
def test_experiments_transport_create_channel(transport_class, grpc_helpers):
# If credentials and host are not provided, the transport class should use
# ADC credentials.
@@ -2394,82 +2409,6 @@ def test_experiments_transport_create_channel(transport_class, grpc_helpers):
)
-@pytest.mark.parametrize(
- "transport_class,grpc_helpers",
- [
- (transports.ExperimentsGrpcTransport, grpc_helpers),
- (transports.ExperimentsGrpcAsyncIOTransport, grpc_helpers_async),
- ],
-)
-@requires_api_core_lt_1_26_0
-def test_experiments_transport_create_channel_old_api_core(
- transport_class, grpc_helpers
-):
- # If credentials and host are not provided, the transport class should use
- # ADC credentials.
- with mock.patch.object(
- google.auth, "default", autospec=True
- ) as adc, mock.patch.object(
- grpc_helpers, "create_channel", autospec=True
- ) as create_channel:
- creds = ga_credentials.AnonymousCredentials()
- adc.return_value = (creds, None)
- transport_class(quota_project_id="octopus")
-
- create_channel.assert_called_with(
- "dialogflow.googleapis.com:443",
- credentials=creds,
- credentials_file=None,
- quota_project_id="octopus",
- scopes=(
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/dialogflow",
- ),
- ssl_credentials=None,
- options=[
- ("grpc.max_send_message_length", -1),
- ("grpc.max_receive_message_length", -1),
- ],
- )
-
-
-@pytest.mark.parametrize(
- "transport_class,grpc_helpers",
- [
- (transports.ExperimentsGrpcTransport, grpc_helpers),
- (transports.ExperimentsGrpcAsyncIOTransport, grpc_helpers_async),
- ],
-)
-@requires_api_core_lt_1_26_0
-def test_experiments_transport_create_channel_user_scopes(
- transport_class, grpc_helpers
-):
- # If credentials and host are not provided, the transport class should use
- # ADC credentials.
- with mock.patch.object(
- google.auth, "default", autospec=True
- ) as adc, mock.patch.object(
- grpc_helpers, "create_channel", autospec=True
- ) as create_channel:
- creds = ga_credentials.AnonymousCredentials()
- adc.return_value = (creds, None)
-
- transport_class(quota_project_id="octopus", scopes=["1", "2"])
-
- create_channel.assert_called_with(
- "dialogflow.googleapis.com:443",
- credentials=creds,
- credentials_file=None,
- quota_project_id="octopus",
- scopes=["1", "2"],
- ssl_credentials=None,
- options=[
- ("grpc.max_send_message_length", -1),
- ("grpc.max_receive_message_length", -1),
- ],
- )
-
-
@pytest.mark.parametrize(
"transport_class",
[transports.ExperimentsGrpcTransport, transports.ExperimentsGrpcAsyncIOTransport],
@@ -2489,10 +2428,7 @@ def test_experiments_grpc_transport_client_cert_source_for_mtls(transport_class)
"squid.clam.whelk:443",
credentials=cred,
credentials_file=None,
- scopes=(
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/dialogflow",
- ),
+ scopes=None,
ssl_credentials=mock_ssl_channel_creds,
quota_project_id=None,
options=[
@@ -2596,10 +2532,7 @@ def test_experiments_transport_channel_mtls_with_client_cert_source(transport_cl
"mtls.squid.clam.whelk:443",
credentials=cred,
credentials_file=None,
- scopes=(
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/dialogflow",
- ),
+ scopes=None,
ssl_credentials=mock_ssl_cred,
quota_project_id=None,
options=[
@@ -2643,10 +2576,7 @@ def test_experiments_transport_channel_mtls_with_adc(transport_class):
"mtls.squid.clam.whelk:443",
credentials=mock_cred,
credentials_file=None,
- scopes=(
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/dialogflow",
- ),
+ scopes=None,
ssl_credentials=mock_ssl_cred,
quota_project_id=None,
options=[
diff --git a/tests/unit/gapic/dialogflowcx_v3/test_flows.py b/tests/unit/gapic/dialogflowcx_v3/test_flows.py
index b29bba23..3d58264f 100644
--- a/tests/unit/gapic/dialogflowcx_v3/test_flows.py
+++ b/tests/unit/gapic/dialogflowcx_v3/test_flows.py
@@ -38,9 +38,6 @@
from google.cloud.dialogflowcx_v3.services.flows import FlowsClient
from google.cloud.dialogflowcx_v3.services.flows import pagers
from google.cloud.dialogflowcx_v3.services.flows import transports
-from google.cloud.dialogflowcx_v3.services.flows.transports.base import (
- _API_CORE_VERSION,
-)
from google.cloud.dialogflowcx_v3.services.flows.transports.base import (
_GOOGLE_AUTH_VERSION,
)
@@ -58,8 +55,9 @@
import google.auth
-# TODO(busunkim): Once google-api-core >= 1.26.0 is required:
-# - Delete all the api-core and auth "less than" test cases
+# TODO(busunkim): Once google-auth >= 1.25.0 is required transitively
+# through google-api-core:
+# - Delete the auth "less than" test cases
# - Delete these pytest markers (Make the "greater than or equal to" tests the default).
requires_google_auth_lt_1_25_0 = pytest.mark.skipif(
packaging.version.parse(_GOOGLE_AUTH_VERSION) >= packaging.version.parse("1.25.0"),
@@ -70,16 +68,6 @@
reason="This test requires google-auth >= 1.25.0",
)
-requires_api_core_lt_1_26_0 = pytest.mark.skipif(
- packaging.version.parse(_API_CORE_VERSION) >= packaging.version.parse("1.26.0"),
- reason="This test requires google-api-core < 1.26.0",
-)
-
-requires_api_core_gte_1_26_0 = pytest.mark.skipif(
- packaging.version.parse(_API_CORE_VERSION) < packaging.version.parse("1.26.0"),
- reason="This test requires google-api-core >= 1.26.0",
-)
-
def client_cert_source_callback():
return b"cert bytes", b"key bytes"
@@ -134,6 +122,34 @@ def test_flows_client_from_service_account_info(client_class):
assert client.transport._host == "dialogflow.googleapis.com:443"
+@pytest.mark.parametrize("client_class", [FlowsClient, FlowsAsyncClient,])
+def test_flows_client_service_account_always_use_jwt(client_class):
+ with mock.patch.object(
+ service_account.Credentials, "with_always_use_jwt_access", create=True
+ ) as use_jwt:
+ creds = service_account.Credentials(None, None, None)
+ client = client_class(credentials=creds)
+ use_jwt.assert_not_called()
+
+
+@pytest.mark.parametrize(
+ "transport_class,transport_name",
+ [
+ (transports.FlowsGrpcTransport, "grpc"),
+ (transports.FlowsGrpcAsyncIOTransport, "grpc_asyncio"),
+ ],
+)
+def test_flows_client_service_account_always_use_jwt_true(
+ transport_class, transport_name
+):
+ with mock.patch.object(
+ service_account.Credentials, "with_always_use_jwt_access", create=True
+ ) as use_jwt:
+ creds = service_account.Credentials(None, None, None)
+ transport = transport_class(credentials=creds, always_use_jwt_access=True)
+ use_jwt.assert_called_once_with(True)
+
+
@pytest.mark.parametrize("client_class", [FlowsClient, FlowsAsyncClient,])
def test_flows_client_from_service_account_file(client_class):
creds = ga_credentials.AnonymousCredentials()
@@ -2613,7 +2629,6 @@ def test_flows_transport_auth_adc_old_google_auth(transport_class):
(transports.FlowsGrpcAsyncIOTransport, grpc_helpers_async),
],
)
-@requires_api_core_gte_1_26_0
def test_flows_transport_create_channel(transport_class, grpc_helpers):
# If credentials and host are not provided, the transport class should use
# ADC credentials.
@@ -2645,78 +2660,6 @@ def test_flows_transport_create_channel(transport_class, grpc_helpers):
)
-@pytest.mark.parametrize(
- "transport_class,grpc_helpers",
- [
- (transports.FlowsGrpcTransport, grpc_helpers),
- (transports.FlowsGrpcAsyncIOTransport, grpc_helpers_async),
- ],
-)
-@requires_api_core_lt_1_26_0
-def test_flows_transport_create_channel_old_api_core(transport_class, grpc_helpers):
- # If credentials and host are not provided, the transport class should use
- # ADC credentials.
- with mock.patch.object(
- google.auth, "default", autospec=True
- ) as adc, mock.patch.object(
- grpc_helpers, "create_channel", autospec=True
- ) as create_channel:
- creds = ga_credentials.AnonymousCredentials()
- adc.return_value = (creds, None)
- transport_class(quota_project_id="octopus")
-
- create_channel.assert_called_with(
- "dialogflow.googleapis.com:443",
- credentials=creds,
- credentials_file=None,
- quota_project_id="octopus",
- scopes=(
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/dialogflow",
- ),
- ssl_credentials=None,
- options=[
- ("grpc.max_send_message_length", -1),
- ("grpc.max_receive_message_length", -1),
- ],
- )
-
-
-@pytest.mark.parametrize(
- "transport_class,grpc_helpers",
- [
- (transports.FlowsGrpcTransport, grpc_helpers),
- (transports.FlowsGrpcAsyncIOTransport, grpc_helpers_async),
- ],
-)
-@requires_api_core_lt_1_26_0
-def test_flows_transport_create_channel_user_scopes(transport_class, grpc_helpers):
- # If credentials and host are not provided, the transport class should use
- # ADC credentials.
- with mock.patch.object(
- google.auth, "default", autospec=True
- ) as adc, mock.patch.object(
- grpc_helpers, "create_channel", autospec=True
- ) as create_channel:
- creds = ga_credentials.AnonymousCredentials()
- adc.return_value = (creds, None)
-
- transport_class(quota_project_id="octopus", scopes=["1", "2"])
-
- create_channel.assert_called_with(
- "dialogflow.googleapis.com:443",
- credentials=creds,
- credentials_file=None,
- quota_project_id="octopus",
- scopes=["1", "2"],
- ssl_credentials=None,
- options=[
- ("grpc.max_send_message_length", -1),
- ("grpc.max_receive_message_length", -1),
- ],
- )
-
-
@pytest.mark.parametrize(
"transport_class",
[transports.FlowsGrpcTransport, transports.FlowsGrpcAsyncIOTransport],
@@ -2736,10 +2679,7 @@ def test_flows_grpc_transport_client_cert_source_for_mtls(transport_class):
"squid.clam.whelk:443",
credentials=cred,
credentials_file=None,
- scopes=(
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/dialogflow",
- ),
+ scopes=None,
ssl_credentials=mock_ssl_channel_creds,
quota_project_id=None,
options=[
@@ -2841,10 +2781,7 @@ def test_flows_transport_channel_mtls_with_client_cert_source(transport_class):
"mtls.squid.clam.whelk:443",
credentials=cred,
credentials_file=None,
- scopes=(
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/dialogflow",
- ),
+ scopes=None,
ssl_credentials=mock_ssl_cred,
quota_project_id=None,
options=[
@@ -2888,10 +2825,7 @@ def test_flows_transport_channel_mtls_with_adc(transport_class):
"mtls.squid.clam.whelk:443",
credentials=mock_cred,
credentials_file=None,
- scopes=(
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/dialogflow",
- ),
+ scopes=None,
ssl_credentials=mock_ssl_cred,
quota_project_id=None,
options=[
diff --git a/tests/unit/gapic/dialogflowcx_v3/test_intents.py b/tests/unit/gapic/dialogflowcx_v3/test_intents.py
index 3eb0e707..6485f62d 100644
--- a/tests/unit/gapic/dialogflowcx_v3/test_intents.py
+++ b/tests/unit/gapic/dialogflowcx_v3/test_intents.py
@@ -35,9 +35,6 @@
from google.cloud.dialogflowcx_v3.services.intents import IntentsClient
from google.cloud.dialogflowcx_v3.services.intents import pagers
from google.cloud.dialogflowcx_v3.services.intents import transports
-from google.cloud.dialogflowcx_v3.services.intents.transports.base import (
- _API_CORE_VERSION,
-)
from google.cloud.dialogflowcx_v3.services.intents.transports.base import (
_GOOGLE_AUTH_VERSION,
)
@@ -48,8 +45,9 @@
import google.auth
-# TODO(busunkim): Once google-api-core >= 1.26.0 is required:
-# - Delete all the api-core and auth "less than" test cases
+# TODO(busunkim): Once google-auth >= 1.25.0 is required transitively
+# through google-api-core:
+# - Delete the auth "less than" test cases
# - Delete these pytest markers (Make the "greater than or equal to" tests the default).
requires_google_auth_lt_1_25_0 = pytest.mark.skipif(
packaging.version.parse(_GOOGLE_AUTH_VERSION) >= packaging.version.parse("1.25.0"),
@@ -60,16 +58,6 @@
reason="This test requires google-auth >= 1.25.0",
)
-requires_api_core_lt_1_26_0 = pytest.mark.skipif(
- packaging.version.parse(_API_CORE_VERSION) >= packaging.version.parse("1.26.0"),
- reason="This test requires google-api-core < 1.26.0",
-)
-
-requires_api_core_gte_1_26_0 = pytest.mark.skipif(
- packaging.version.parse(_API_CORE_VERSION) < packaging.version.parse("1.26.0"),
- reason="This test requires google-api-core >= 1.26.0",
-)
-
def client_cert_source_callback():
return b"cert bytes", b"key bytes"
@@ -124,6 +112,34 @@ def test_intents_client_from_service_account_info(client_class):
assert client.transport._host == "dialogflow.googleapis.com:443"
+@pytest.mark.parametrize("client_class", [IntentsClient, IntentsAsyncClient,])
+def test_intents_client_service_account_always_use_jwt(client_class):
+ with mock.patch.object(
+ service_account.Credentials, "with_always_use_jwt_access", create=True
+ ) as use_jwt:
+ creds = service_account.Credentials(None, None, None)
+ client = client_class(credentials=creds)
+ use_jwt.assert_not_called()
+
+
+@pytest.mark.parametrize(
+ "transport_class,transport_name",
+ [
+ (transports.IntentsGrpcTransport, "grpc"),
+ (transports.IntentsGrpcAsyncIOTransport, "grpc_asyncio"),
+ ],
+)
+def test_intents_client_service_account_always_use_jwt_true(
+ transport_class, transport_name
+):
+ with mock.patch.object(
+ service_account.Credentials, "with_always_use_jwt_access", create=True
+ ) as use_jwt:
+ creds = service_account.Credentials(None, None, None)
+ transport = transport_class(credentials=creds, always_use_jwt_access=True)
+ use_jwt.assert_called_once_with(True)
+
+
@pytest.mark.parametrize("client_class", [IntentsClient, IntentsAsyncClient,])
def test_intents_client_from_service_account_file(client_class):
creds = ga_credentials.AnonymousCredentials()
@@ -1835,7 +1851,6 @@ def test_intents_transport_auth_adc_old_google_auth(transport_class):
(transports.IntentsGrpcAsyncIOTransport, grpc_helpers_async),
],
)
-@requires_api_core_gte_1_26_0
def test_intents_transport_create_channel(transport_class, grpc_helpers):
# If credentials and host are not provided, the transport class should use
# ADC credentials.
@@ -1867,78 +1882,6 @@ def test_intents_transport_create_channel(transport_class, grpc_helpers):
)
-@pytest.mark.parametrize(
- "transport_class,grpc_helpers",
- [
- (transports.IntentsGrpcTransport, grpc_helpers),
- (transports.IntentsGrpcAsyncIOTransport, grpc_helpers_async),
- ],
-)
-@requires_api_core_lt_1_26_0
-def test_intents_transport_create_channel_old_api_core(transport_class, grpc_helpers):
- # If credentials and host are not provided, the transport class should use
- # ADC credentials.
- with mock.patch.object(
- google.auth, "default", autospec=True
- ) as adc, mock.patch.object(
- grpc_helpers, "create_channel", autospec=True
- ) as create_channel:
- creds = ga_credentials.AnonymousCredentials()
- adc.return_value = (creds, None)
- transport_class(quota_project_id="octopus")
-
- create_channel.assert_called_with(
- "dialogflow.googleapis.com:443",
- credentials=creds,
- credentials_file=None,
- quota_project_id="octopus",
- scopes=(
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/dialogflow",
- ),
- ssl_credentials=None,
- options=[
- ("grpc.max_send_message_length", -1),
- ("grpc.max_receive_message_length", -1),
- ],
- )
-
-
-@pytest.mark.parametrize(
- "transport_class,grpc_helpers",
- [
- (transports.IntentsGrpcTransport, grpc_helpers),
- (transports.IntentsGrpcAsyncIOTransport, grpc_helpers_async),
- ],
-)
-@requires_api_core_lt_1_26_0
-def test_intents_transport_create_channel_user_scopes(transport_class, grpc_helpers):
- # If credentials and host are not provided, the transport class should use
- # ADC credentials.
- with mock.patch.object(
- google.auth, "default", autospec=True
- ) as adc, mock.patch.object(
- grpc_helpers, "create_channel", autospec=True
- ) as create_channel:
- creds = ga_credentials.AnonymousCredentials()
- adc.return_value = (creds, None)
-
- transport_class(quota_project_id="octopus", scopes=["1", "2"])
-
- create_channel.assert_called_with(
- "dialogflow.googleapis.com:443",
- credentials=creds,
- credentials_file=None,
- quota_project_id="octopus",
- scopes=["1", "2"],
- ssl_credentials=None,
- options=[
- ("grpc.max_send_message_length", -1),
- ("grpc.max_receive_message_length", -1),
- ],
- )
-
-
@pytest.mark.parametrize(
"transport_class",
[transports.IntentsGrpcTransport, transports.IntentsGrpcAsyncIOTransport],
@@ -1958,10 +1901,7 @@ def test_intents_grpc_transport_client_cert_source_for_mtls(transport_class):
"squid.clam.whelk:443",
credentials=cred,
credentials_file=None,
- scopes=(
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/dialogflow",
- ),
+ scopes=None,
ssl_credentials=mock_ssl_channel_creds,
quota_project_id=None,
options=[
@@ -2065,10 +2005,7 @@ def test_intents_transport_channel_mtls_with_client_cert_source(transport_class)
"mtls.squid.clam.whelk:443",
credentials=cred,
credentials_file=None,
- scopes=(
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/dialogflow",
- ),
+ scopes=None,
ssl_credentials=mock_ssl_cred,
quota_project_id=None,
options=[
@@ -2112,10 +2049,7 @@ def test_intents_transport_channel_mtls_with_adc(transport_class):
"mtls.squid.clam.whelk:443",
credentials=mock_cred,
credentials_file=None,
- scopes=(
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/dialogflow",
- ),
+ scopes=None,
ssl_credentials=mock_ssl_cred,
quota_project_id=None,
options=[
diff --git a/tests/unit/gapic/dialogflowcx_v3/test_pages.py b/tests/unit/gapic/dialogflowcx_v3/test_pages.py
index eac60ce1..8a3fdf2f 100644
--- a/tests/unit/gapic/dialogflowcx_v3/test_pages.py
+++ b/tests/unit/gapic/dialogflowcx_v3/test_pages.py
@@ -35,9 +35,6 @@
from google.cloud.dialogflowcx_v3.services.pages import PagesClient
from google.cloud.dialogflowcx_v3.services.pages import pagers
from google.cloud.dialogflowcx_v3.services.pages import transports
-from google.cloud.dialogflowcx_v3.services.pages.transports.base import (
- _API_CORE_VERSION,
-)
from google.cloud.dialogflowcx_v3.services.pages.transports.base import (
_GOOGLE_AUTH_VERSION,
)
@@ -51,8 +48,9 @@
import google.auth
-# TODO(busunkim): Once google-api-core >= 1.26.0 is required:
-# - Delete all the api-core and auth "less than" test cases
+# TODO(busunkim): Once google-auth >= 1.25.0 is required transitively
+# through google-api-core:
+# - Delete the auth "less than" test cases
# - Delete these pytest markers (Make the "greater than or equal to" tests the default).
requires_google_auth_lt_1_25_0 = pytest.mark.skipif(
packaging.version.parse(_GOOGLE_AUTH_VERSION) >= packaging.version.parse("1.25.0"),
@@ -63,16 +61,6 @@
reason="This test requires google-auth >= 1.25.0",
)
-requires_api_core_lt_1_26_0 = pytest.mark.skipif(
- packaging.version.parse(_API_CORE_VERSION) >= packaging.version.parse("1.26.0"),
- reason="This test requires google-api-core < 1.26.0",
-)
-
-requires_api_core_gte_1_26_0 = pytest.mark.skipif(
- packaging.version.parse(_API_CORE_VERSION) < packaging.version.parse("1.26.0"),
- reason="This test requires google-api-core >= 1.26.0",
-)
-
def client_cert_source_callback():
return b"cert bytes", b"key bytes"
@@ -127,6 +115,34 @@ def test_pages_client_from_service_account_info(client_class):
assert client.transport._host == "dialogflow.googleapis.com:443"
+@pytest.mark.parametrize("client_class", [PagesClient, PagesAsyncClient,])
+def test_pages_client_service_account_always_use_jwt(client_class):
+ with mock.patch.object(
+ service_account.Credentials, "with_always_use_jwt_access", create=True
+ ) as use_jwt:
+ creds = service_account.Credentials(None, None, None)
+ client = client_class(credentials=creds)
+ use_jwt.assert_not_called()
+
+
+@pytest.mark.parametrize(
+ "transport_class,transport_name",
+ [
+ (transports.PagesGrpcTransport, "grpc"),
+ (transports.PagesGrpcAsyncIOTransport, "grpc_asyncio"),
+ ],
+)
+def test_pages_client_service_account_always_use_jwt_true(
+ transport_class, transport_name
+):
+ with mock.patch.object(
+ service_account.Credentials, "with_always_use_jwt_access", create=True
+ ) as use_jwt:
+ creds = service_account.Credentials(None, None, None)
+ transport = transport_class(credentials=creds, always_use_jwt_access=True)
+ use_jwt.assert_called_once_with(True)
+
+
@pytest.mark.parametrize("client_class", [PagesClient, PagesAsyncClient,])
def test_pages_client_from_service_account_file(client_class):
creds = ga_credentials.AnonymousCredentials()
@@ -1796,7 +1812,6 @@ def test_pages_transport_auth_adc_old_google_auth(transport_class):
(transports.PagesGrpcAsyncIOTransport, grpc_helpers_async),
],
)
-@requires_api_core_gte_1_26_0
def test_pages_transport_create_channel(transport_class, grpc_helpers):
# If credentials and host are not provided, the transport class should use
# ADC credentials.
@@ -1828,78 +1843,6 @@ def test_pages_transport_create_channel(transport_class, grpc_helpers):
)
-@pytest.mark.parametrize(
- "transport_class,grpc_helpers",
- [
- (transports.PagesGrpcTransport, grpc_helpers),
- (transports.PagesGrpcAsyncIOTransport, grpc_helpers_async),
- ],
-)
-@requires_api_core_lt_1_26_0
-def test_pages_transport_create_channel_old_api_core(transport_class, grpc_helpers):
- # If credentials and host are not provided, the transport class should use
- # ADC credentials.
- with mock.patch.object(
- google.auth, "default", autospec=True
- ) as adc, mock.patch.object(
- grpc_helpers, "create_channel", autospec=True
- ) as create_channel:
- creds = ga_credentials.AnonymousCredentials()
- adc.return_value = (creds, None)
- transport_class(quota_project_id="octopus")
-
- create_channel.assert_called_with(
- "dialogflow.googleapis.com:443",
- credentials=creds,
- credentials_file=None,
- quota_project_id="octopus",
- scopes=(
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/dialogflow",
- ),
- ssl_credentials=None,
- options=[
- ("grpc.max_send_message_length", -1),
- ("grpc.max_receive_message_length", -1),
- ],
- )
-
-
-@pytest.mark.parametrize(
- "transport_class,grpc_helpers",
- [
- (transports.PagesGrpcTransport, grpc_helpers),
- (transports.PagesGrpcAsyncIOTransport, grpc_helpers_async),
- ],
-)
-@requires_api_core_lt_1_26_0
-def test_pages_transport_create_channel_user_scopes(transport_class, grpc_helpers):
- # If credentials and host are not provided, the transport class should use
- # ADC credentials.
- with mock.patch.object(
- google.auth, "default", autospec=True
- ) as adc, mock.patch.object(
- grpc_helpers, "create_channel", autospec=True
- ) as create_channel:
- creds = ga_credentials.AnonymousCredentials()
- adc.return_value = (creds, None)
-
- transport_class(quota_project_id="octopus", scopes=["1", "2"])
-
- create_channel.assert_called_with(
- "dialogflow.googleapis.com:443",
- credentials=creds,
- credentials_file=None,
- quota_project_id="octopus",
- scopes=["1", "2"],
- ssl_credentials=None,
- options=[
- ("grpc.max_send_message_length", -1),
- ("grpc.max_receive_message_length", -1),
- ],
- )
-
-
@pytest.mark.parametrize(
"transport_class",
[transports.PagesGrpcTransport, transports.PagesGrpcAsyncIOTransport],
@@ -1919,10 +1862,7 @@ def test_pages_grpc_transport_client_cert_source_for_mtls(transport_class):
"squid.clam.whelk:443",
credentials=cred,
credentials_file=None,
- scopes=(
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/dialogflow",
- ),
+ scopes=None,
ssl_credentials=mock_ssl_channel_creds,
quota_project_id=None,
options=[
@@ -2024,10 +1964,7 @@ def test_pages_transport_channel_mtls_with_client_cert_source(transport_class):
"mtls.squid.clam.whelk:443",
credentials=cred,
credentials_file=None,
- scopes=(
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/dialogflow",
- ),
+ scopes=None,
ssl_credentials=mock_ssl_cred,
quota_project_id=None,
options=[
@@ -2071,10 +2008,7 @@ def test_pages_transport_channel_mtls_with_adc(transport_class):
"mtls.squid.clam.whelk:443",
credentials=mock_cred,
credentials_file=None,
- scopes=(
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/dialogflow",
- ),
+ scopes=None,
ssl_credentials=mock_ssl_cred,
quota_project_id=None,
options=[
diff --git a/tests/unit/gapic/dialogflowcx_v3/test_security_settings_service.py b/tests/unit/gapic/dialogflowcx_v3/test_security_settings_service.py
index 78e89baa..14e958ec 100644
--- a/tests/unit/gapic/dialogflowcx_v3/test_security_settings_service.py
+++ b/tests/unit/gapic/dialogflowcx_v3/test_security_settings_service.py
@@ -39,9 +39,6 @@
)
from google.cloud.dialogflowcx_v3.services.security_settings_service import pagers
from google.cloud.dialogflowcx_v3.services.security_settings_service import transports
-from google.cloud.dialogflowcx_v3.services.security_settings_service.transports.base import (
- _API_CORE_VERSION,
-)
from google.cloud.dialogflowcx_v3.services.security_settings_service.transports.base import (
_GOOGLE_AUTH_VERSION,
)
@@ -54,8 +51,9 @@
import google.auth
-# TODO(busunkim): Once google-api-core >= 1.26.0 is required:
-# - Delete all the api-core and auth "less than" test cases
+# TODO(busunkim): Once google-auth >= 1.25.0 is required transitively
+# through google-api-core:
+# - Delete the auth "less than" test cases
# - Delete these pytest markers (Make the "greater than or equal to" tests the default).
requires_google_auth_lt_1_25_0 = pytest.mark.skipif(
packaging.version.parse(_GOOGLE_AUTH_VERSION) >= packaging.version.parse("1.25.0"),
@@ -66,16 +64,6 @@
reason="This test requires google-auth >= 1.25.0",
)
-requires_api_core_lt_1_26_0 = pytest.mark.skipif(
- packaging.version.parse(_API_CORE_VERSION) >= packaging.version.parse("1.26.0"),
- reason="This test requires google-api-core < 1.26.0",
-)
-
-requires_api_core_gte_1_26_0 = pytest.mark.skipif(
- packaging.version.parse(_API_CORE_VERSION) < packaging.version.parse("1.26.0"),
- reason="This test requires google-api-core >= 1.26.0",
-)
-
def client_cert_source_callback():
return b"cert bytes", b"key bytes"
@@ -139,6 +127,36 @@ def test_security_settings_service_client_from_service_account_info(client_class
assert client.transport._host == "dialogflow.googleapis.com:443"
+@pytest.mark.parametrize(
+ "client_class", [SecuritySettingsServiceClient, SecuritySettingsServiceAsyncClient,]
+)
+def test_security_settings_service_client_service_account_always_use_jwt(client_class):
+ with mock.patch.object(
+ service_account.Credentials, "with_always_use_jwt_access", create=True
+ ) as use_jwt:
+ creds = service_account.Credentials(None, None, None)
+ client = client_class(credentials=creds)
+ use_jwt.assert_not_called()
+
+
+@pytest.mark.parametrize(
+ "transport_class,transport_name",
+ [
+ (transports.SecuritySettingsServiceGrpcTransport, "grpc"),
+ (transports.SecuritySettingsServiceGrpcAsyncIOTransport, "grpc_asyncio"),
+ ],
+)
+def test_security_settings_service_client_service_account_always_use_jwt_true(
+ transport_class, transport_name
+):
+ with mock.patch.object(
+ service_account.Credentials, "with_always_use_jwt_access", create=True
+ ) as use_jwt:
+ creds = service_account.Credentials(None, None, None)
+ transport = transport_class(credentials=creds, always_use_jwt_access=True)
+ use_jwt.assert_called_once_with(True)
+
+
@pytest.mark.parametrize(
"client_class", [SecuritySettingsServiceClient, SecuritySettingsServiceAsyncClient,]
)
@@ -2238,7 +2256,6 @@ def test_security_settings_service_transport_auth_adc_old_google_auth(transport_
(transports.SecuritySettingsServiceGrpcAsyncIOTransport, grpc_helpers_async),
],
)
-@requires_api_core_gte_1_26_0
def test_security_settings_service_transport_create_channel(
transport_class, grpc_helpers
):
@@ -2272,82 +2289,6 @@ def test_security_settings_service_transport_create_channel(
)
-@pytest.mark.parametrize(
- "transport_class,grpc_helpers",
- [
- (transports.SecuritySettingsServiceGrpcTransport, grpc_helpers),
- (transports.SecuritySettingsServiceGrpcAsyncIOTransport, grpc_helpers_async),
- ],
-)
-@requires_api_core_lt_1_26_0
-def test_security_settings_service_transport_create_channel_old_api_core(
- transport_class, grpc_helpers
-):
- # If credentials and host are not provided, the transport class should use
- # ADC credentials.
- with mock.patch.object(
- google.auth, "default", autospec=True
- ) as adc, mock.patch.object(
- grpc_helpers, "create_channel", autospec=True
- ) as create_channel:
- creds = ga_credentials.AnonymousCredentials()
- adc.return_value = (creds, None)
- transport_class(quota_project_id="octopus")
-
- create_channel.assert_called_with(
- "dialogflow.googleapis.com:443",
- credentials=creds,
- credentials_file=None,
- quota_project_id="octopus",
- scopes=(
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/dialogflow",
- ),
- ssl_credentials=None,
- options=[
- ("grpc.max_send_message_length", -1),
- ("grpc.max_receive_message_length", -1),
- ],
- )
-
-
-@pytest.mark.parametrize(
- "transport_class,grpc_helpers",
- [
- (transports.SecuritySettingsServiceGrpcTransport, grpc_helpers),
- (transports.SecuritySettingsServiceGrpcAsyncIOTransport, grpc_helpers_async),
- ],
-)
-@requires_api_core_lt_1_26_0
-def test_security_settings_service_transport_create_channel_user_scopes(
- transport_class, grpc_helpers
-):
- # If credentials and host are not provided, the transport class should use
- # ADC credentials.
- with mock.patch.object(
- google.auth, "default", autospec=True
- ) as adc, mock.patch.object(
- grpc_helpers, "create_channel", autospec=True
- ) as create_channel:
- creds = ga_credentials.AnonymousCredentials()
- adc.return_value = (creds, None)
-
- transport_class(quota_project_id="octopus", scopes=["1", "2"])
-
- create_channel.assert_called_with(
- "dialogflow.googleapis.com:443",
- credentials=creds,
- credentials_file=None,
- quota_project_id="octopus",
- scopes=["1", "2"],
- ssl_credentials=None,
- options=[
- ("grpc.max_send_message_length", -1),
- ("grpc.max_receive_message_length", -1),
- ],
- )
-
-
@pytest.mark.parametrize(
"transport_class",
[
@@ -2372,10 +2313,7 @@ def test_security_settings_service_grpc_transport_client_cert_source_for_mtls(
"squid.clam.whelk:443",
credentials=cred,
credentials_file=None,
- scopes=(
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/dialogflow",
- ),
+ scopes=None,
ssl_credentials=mock_ssl_channel_creds,
quota_project_id=None,
options=[
@@ -2484,10 +2422,7 @@ def test_security_settings_service_transport_channel_mtls_with_client_cert_sourc
"mtls.squid.clam.whelk:443",
credentials=cred,
credentials_file=None,
- scopes=(
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/dialogflow",
- ),
+ scopes=None,
ssl_credentials=mock_ssl_cred,
quota_project_id=None,
options=[
@@ -2534,10 +2469,7 @@ def test_security_settings_service_transport_channel_mtls_with_adc(transport_cla
"mtls.squid.clam.whelk:443",
credentials=mock_cred,
credentials_file=None,
- scopes=(
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/dialogflow",
- ),
+ scopes=None,
ssl_credentials=mock_ssl_cred,
quota_project_id=None,
options=[
diff --git a/tests/unit/gapic/dialogflowcx_v3/test_session_entity_types.py b/tests/unit/gapic/dialogflowcx_v3/test_session_entity_types.py
index a1ced677..9897056d 100644
--- a/tests/unit/gapic/dialogflowcx_v3/test_session_entity_types.py
+++ b/tests/unit/gapic/dialogflowcx_v3/test_session_entity_types.py
@@ -39,9 +39,6 @@
)
from google.cloud.dialogflowcx_v3.services.session_entity_types import pagers
from google.cloud.dialogflowcx_v3.services.session_entity_types import transports
-from google.cloud.dialogflowcx_v3.services.session_entity_types.transports.base import (
- _API_CORE_VERSION,
-)
from google.cloud.dialogflowcx_v3.services.session_entity_types.transports.base import (
_GOOGLE_AUTH_VERSION,
)
@@ -55,8 +52,9 @@
import google.auth
-# TODO(busunkim): Once google-api-core >= 1.26.0 is required:
-# - Delete all the api-core and auth "less than" test cases
+# TODO(busunkim): Once google-auth >= 1.25.0 is required transitively
+# through google-api-core:
+# - Delete the auth "less than" test cases
# - Delete these pytest markers (Make the "greater than or equal to" tests the default).
requires_google_auth_lt_1_25_0 = pytest.mark.skipif(
packaging.version.parse(_GOOGLE_AUTH_VERSION) >= packaging.version.parse("1.25.0"),
@@ -67,16 +65,6 @@
reason="This test requires google-auth >= 1.25.0",
)
-requires_api_core_lt_1_26_0 = pytest.mark.skipif(
- packaging.version.parse(_API_CORE_VERSION) >= packaging.version.parse("1.26.0"),
- reason="This test requires google-api-core < 1.26.0",
-)
-
-requires_api_core_gte_1_26_0 = pytest.mark.skipif(
- packaging.version.parse(_API_CORE_VERSION) < packaging.version.parse("1.26.0"),
- reason="This test requires google-api-core >= 1.26.0",
-)
-
def client_cert_source_callback():
return b"cert bytes", b"key bytes"
@@ -140,6 +128,36 @@ def test_session_entity_types_client_from_service_account_info(client_class):
assert client.transport._host == "dialogflow.googleapis.com:443"
+@pytest.mark.parametrize(
+ "client_class", [SessionEntityTypesClient, SessionEntityTypesAsyncClient,]
+)
+def test_session_entity_types_client_service_account_always_use_jwt(client_class):
+ with mock.patch.object(
+ service_account.Credentials, "with_always_use_jwt_access", create=True
+ ) as use_jwt:
+ creds = service_account.Credentials(None, None, None)
+ client = client_class(credentials=creds)
+ use_jwt.assert_not_called()
+
+
+@pytest.mark.parametrize(
+ "transport_class,transport_name",
+ [
+ (transports.SessionEntityTypesGrpcTransport, "grpc"),
+ (transports.SessionEntityTypesGrpcAsyncIOTransport, "grpc_asyncio"),
+ ],
+)
+def test_session_entity_types_client_service_account_always_use_jwt_true(
+ transport_class, transport_name
+):
+ with mock.patch.object(
+ service_account.Credentials, "with_always_use_jwt_access", create=True
+ ) as use_jwt:
+ creds = service_account.Credentials(None, None, None)
+ transport = transport_class(credentials=creds, always_use_jwt_access=True)
+ use_jwt.assert_called_once_with(True)
+
+
@pytest.mark.parametrize(
"client_class", [SessionEntityTypesClient, SessionEntityTypesAsyncClient,]
)
@@ -2142,7 +2160,6 @@ def test_session_entity_types_transport_auth_adc_old_google_auth(transport_class
(transports.SessionEntityTypesGrpcAsyncIOTransport, grpc_helpers_async),
],
)
-@requires_api_core_gte_1_26_0
def test_session_entity_types_transport_create_channel(transport_class, grpc_helpers):
# If credentials and host are not provided, the transport class should use
# ADC credentials.
@@ -2174,82 +2191,6 @@ def test_session_entity_types_transport_create_channel(transport_class, grpc_hel
)
-@pytest.mark.parametrize(
- "transport_class,grpc_helpers",
- [
- (transports.SessionEntityTypesGrpcTransport, grpc_helpers),
- (transports.SessionEntityTypesGrpcAsyncIOTransport, grpc_helpers_async),
- ],
-)
-@requires_api_core_lt_1_26_0
-def test_session_entity_types_transport_create_channel_old_api_core(
- transport_class, grpc_helpers
-):
- # If credentials and host are not provided, the transport class should use
- # ADC credentials.
- with mock.patch.object(
- google.auth, "default", autospec=True
- ) as adc, mock.patch.object(
- grpc_helpers, "create_channel", autospec=True
- ) as create_channel:
- creds = ga_credentials.AnonymousCredentials()
- adc.return_value = (creds, None)
- transport_class(quota_project_id="octopus")
-
- create_channel.assert_called_with(
- "dialogflow.googleapis.com:443",
- credentials=creds,
- credentials_file=None,
- quota_project_id="octopus",
- scopes=(
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/dialogflow",
- ),
- ssl_credentials=None,
- options=[
- ("grpc.max_send_message_length", -1),
- ("grpc.max_receive_message_length", -1),
- ],
- )
-
-
-@pytest.mark.parametrize(
- "transport_class,grpc_helpers",
- [
- (transports.SessionEntityTypesGrpcTransport, grpc_helpers),
- (transports.SessionEntityTypesGrpcAsyncIOTransport, grpc_helpers_async),
- ],
-)
-@requires_api_core_lt_1_26_0
-def test_session_entity_types_transport_create_channel_user_scopes(
- transport_class, grpc_helpers
-):
- # If credentials and host are not provided, the transport class should use
- # ADC credentials.
- with mock.patch.object(
- google.auth, "default", autospec=True
- ) as adc, mock.patch.object(
- grpc_helpers, "create_channel", autospec=True
- ) as create_channel:
- creds = ga_credentials.AnonymousCredentials()
- adc.return_value = (creds, None)
-
- transport_class(quota_project_id="octopus", scopes=["1", "2"])
-
- create_channel.assert_called_with(
- "dialogflow.googleapis.com:443",
- credentials=creds,
- credentials_file=None,
- quota_project_id="octopus",
- scopes=["1", "2"],
- ssl_credentials=None,
- options=[
- ("grpc.max_send_message_length", -1),
- ("grpc.max_receive_message_length", -1),
- ],
- )
-
-
@pytest.mark.parametrize(
"transport_class",
[
@@ -2274,10 +2215,7 @@ def test_session_entity_types_grpc_transport_client_cert_source_for_mtls(
"squid.clam.whelk:443",
credentials=cred,
credentials_file=None,
- scopes=(
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/dialogflow",
- ),
+ scopes=None,
ssl_credentials=mock_ssl_channel_creds,
quota_project_id=None,
options=[
@@ -2386,10 +2324,7 @@ def test_session_entity_types_transport_channel_mtls_with_client_cert_source(
"mtls.squid.clam.whelk:443",
credentials=cred,
credentials_file=None,
- scopes=(
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/dialogflow",
- ),
+ scopes=None,
ssl_credentials=mock_ssl_cred,
quota_project_id=None,
options=[
@@ -2436,10 +2371,7 @@ def test_session_entity_types_transport_channel_mtls_with_adc(transport_class):
"mtls.squid.clam.whelk:443",
credentials=mock_cred,
credentials_file=None,
- scopes=(
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/dialogflow",
- ),
+ scopes=None,
ssl_credentials=mock_ssl_cred,
quota_project_id=None,
options=[
diff --git a/tests/unit/gapic/dialogflowcx_v3/test_sessions.py b/tests/unit/gapic/dialogflowcx_v3/test_sessions.py
index d0e152c3..d4f826c7 100644
--- a/tests/unit/gapic/dialogflowcx_v3/test_sessions.py
+++ b/tests/unit/gapic/dialogflowcx_v3/test_sessions.py
@@ -34,9 +34,6 @@
from google.cloud.dialogflowcx_v3.services.sessions import SessionsAsyncClient
from google.cloud.dialogflowcx_v3.services.sessions import SessionsClient
from google.cloud.dialogflowcx_v3.services.sessions import transports
-from google.cloud.dialogflowcx_v3.services.sessions.transports.base import (
- _API_CORE_VERSION,
-)
from google.cloud.dialogflowcx_v3.services.sessions.transports.base import (
_GOOGLE_AUTH_VERSION,
)
@@ -52,8 +49,9 @@
import google.auth
-# TODO(busunkim): Once google-api-core >= 1.26.0 is required:
-# - Delete all the api-core and auth "less than" test cases
+# TODO(busunkim): Once google-auth >= 1.25.0 is required transitively
+# through google-api-core:
+# - Delete the auth "less than" test cases
# - Delete these pytest markers (Make the "greater than or equal to" tests the default).
requires_google_auth_lt_1_25_0 = pytest.mark.skipif(
packaging.version.parse(_GOOGLE_AUTH_VERSION) >= packaging.version.parse("1.25.0"),
@@ -64,16 +62,6 @@
reason="This test requires google-auth >= 1.25.0",
)
-requires_api_core_lt_1_26_0 = pytest.mark.skipif(
- packaging.version.parse(_API_CORE_VERSION) >= packaging.version.parse("1.26.0"),
- reason="This test requires google-api-core < 1.26.0",
-)
-
-requires_api_core_gte_1_26_0 = pytest.mark.skipif(
- packaging.version.parse(_API_CORE_VERSION) < packaging.version.parse("1.26.0"),
- reason="This test requires google-api-core >= 1.26.0",
-)
-
def client_cert_source_callback():
return b"cert bytes", b"key bytes"
@@ -129,6 +117,34 @@ def test_sessions_client_from_service_account_info(client_class):
assert client.transport._host == "dialogflow.googleapis.com:443"
+@pytest.mark.parametrize("client_class", [SessionsClient, SessionsAsyncClient,])
+def test_sessions_client_service_account_always_use_jwt(client_class):
+ with mock.patch.object(
+ service_account.Credentials, "with_always_use_jwt_access", create=True
+ ) as use_jwt:
+ creds = service_account.Credentials(None, None, None)
+ client = client_class(credentials=creds)
+ use_jwt.assert_not_called()
+
+
+@pytest.mark.parametrize(
+ "transport_class,transport_name",
+ [
+ (transports.SessionsGrpcTransport, "grpc"),
+ (transports.SessionsGrpcAsyncIOTransport, "grpc_asyncio"),
+ ],
+)
+def test_sessions_client_service_account_always_use_jwt_true(
+ transport_class, transport_name
+):
+ with mock.patch.object(
+ service_account.Credentials, "with_always_use_jwt_access", create=True
+ ) as use_jwt:
+ creds = service_account.Credentials(None, None, None)
+ transport = transport_class(credentials=creds, always_use_jwt_access=True)
+ use_jwt.assert_called_once_with(True)
+
+
@pytest.mark.parametrize("client_class", [SessionsClient, SessionsAsyncClient,])
def test_sessions_client_from_service_account_file(client_class):
creds = ga_credentials.AnonymousCredentials()
@@ -463,7 +479,10 @@ def test_detect_intent(
with mock.patch.object(type(client.transport.detect_intent), "__call__") as call:
# Designate an appropriate return value for the call.
call.return_value = session.DetectIntentResponse(
- response_id="response_id_value", output_audio=b"output_audio_blob",
+ response_id="response_id_value",
+ output_audio=b"output_audio_blob",
+ response_type=session.DetectIntentResponse.ResponseType.PARTIAL,
+ allow_cancellation=True,
)
response = client.detect_intent(request)
@@ -476,6 +495,8 @@ def test_detect_intent(
assert isinstance(response, session.DetectIntentResponse)
assert response.response_id == "response_id_value"
assert response.output_audio == b"output_audio_blob"
+ assert response.response_type == session.DetectIntentResponse.ResponseType.PARTIAL
+ assert response.allow_cancellation is True
def test_detect_intent_from_dict():
@@ -514,7 +535,10 @@ async def test_detect_intent_async(
# Designate an appropriate return value for the call.
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
session.DetectIntentResponse(
- response_id="response_id_value", output_audio=b"output_audio_blob",
+ response_id="response_id_value",
+ output_audio=b"output_audio_blob",
+ response_type=session.DetectIntentResponse.ResponseType.PARTIAL,
+ allow_cancellation=True,
)
)
response = await client.detect_intent(request)
@@ -528,6 +552,8 @@ async def test_detect_intent_async(
assert isinstance(response, session.DetectIntentResponse)
assert response.response_id == "response_id_value"
assert response.output_audio == b"output_audio_blob"
+ assert response.response_type == session.DetectIntentResponse.ResponseType.PARTIAL
+ assert response.allow_cancellation is True
@pytest.mark.asyncio
@@ -1172,7 +1198,6 @@ def test_sessions_transport_auth_adc_old_google_auth(transport_class):
(transports.SessionsGrpcAsyncIOTransport, grpc_helpers_async),
],
)
-@requires_api_core_gte_1_26_0
def test_sessions_transport_create_channel(transport_class, grpc_helpers):
# If credentials and host are not provided, the transport class should use
# ADC credentials.
@@ -1204,78 +1229,6 @@ def test_sessions_transport_create_channel(transport_class, grpc_helpers):
)
-@pytest.mark.parametrize(
- "transport_class,grpc_helpers",
- [
- (transports.SessionsGrpcTransport, grpc_helpers),
- (transports.SessionsGrpcAsyncIOTransport, grpc_helpers_async),
- ],
-)
-@requires_api_core_lt_1_26_0
-def test_sessions_transport_create_channel_old_api_core(transport_class, grpc_helpers):
- # If credentials and host are not provided, the transport class should use
- # ADC credentials.
- with mock.patch.object(
- google.auth, "default", autospec=True
- ) as adc, mock.patch.object(
- grpc_helpers, "create_channel", autospec=True
- ) as create_channel:
- creds = ga_credentials.AnonymousCredentials()
- adc.return_value = (creds, None)
- transport_class(quota_project_id="octopus")
-
- create_channel.assert_called_with(
- "dialogflow.googleapis.com:443",
- credentials=creds,
- credentials_file=None,
- quota_project_id="octopus",
- scopes=(
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/dialogflow",
- ),
- ssl_credentials=None,
- options=[
- ("grpc.max_send_message_length", -1),
- ("grpc.max_receive_message_length", -1),
- ],
- )
-
-
-@pytest.mark.parametrize(
- "transport_class,grpc_helpers",
- [
- (transports.SessionsGrpcTransport, grpc_helpers),
- (transports.SessionsGrpcAsyncIOTransport, grpc_helpers_async),
- ],
-)
-@requires_api_core_lt_1_26_0
-def test_sessions_transport_create_channel_user_scopes(transport_class, grpc_helpers):
- # If credentials and host are not provided, the transport class should use
- # ADC credentials.
- with mock.patch.object(
- google.auth, "default", autospec=True
- ) as adc, mock.patch.object(
- grpc_helpers, "create_channel", autospec=True
- ) as create_channel:
- creds = ga_credentials.AnonymousCredentials()
- adc.return_value = (creds, None)
-
- transport_class(quota_project_id="octopus", scopes=["1", "2"])
-
- create_channel.assert_called_with(
- "dialogflow.googleapis.com:443",
- credentials=creds,
- credentials_file=None,
- quota_project_id="octopus",
- scopes=["1", "2"],
- ssl_credentials=None,
- options=[
- ("grpc.max_send_message_length", -1),
- ("grpc.max_receive_message_length", -1),
- ],
- )
-
-
@pytest.mark.parametrize(
"transport_class",
[transports.SessionsGrpcTransport, transports.SessionsGrpcAsyncIOTransport],
@@ -1295,10 +1248,7 @@ def test_sessions_grpc_transport_client_cert_source_for_mtls(transport_class):
"squid.clam.whelk:443",
credentials=cred,
credentials_file=None,
- scopes=(
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/dialogflow",
- ),
+ scopes=None,
ssl_credentials=mock_ssl_channel_creds,
quota_project_id=None,
options=[
@@ -1402,10 +1352,7 @@ def test_sessions_transport_channel_mtls_with_client_cert_source(transport_class
"mtls.squid.clam.whelk:443",
credentials=cred,
credentials_file=None,
- scopes=(
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/dialogflow",
- ),
+ scopes=None,
ssl_credentials=mock_ssl_cred,
quota_project_id=None,
options=[
@@ -1449,10 +1396,7 @@ def test_sessions_transport_channel_mtls_with_adc(transport_class):
"mtls.squid.clam.whelk:443",
credentials=mock_cred,
credentials_file=None,
- scopes=(
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/dialogflow",
- ),
+ scopes=None,
ssl_credentials=mock_ssl_cred,
quota_project_id=None,
options=[
diff --git a/tests/unit/gapic/dialogflowcx_v3/test_test_cases.py b/tests/unit/gapic/dialogflowcx_v3/test_test_cases.py
index 2572625a..4c14787f 100644
--- a/tests/unit/gapic/dialogflowcx_v3/test_test_cases.py
+++ b/tests/unit/gapic/dialogflowcx_v3/test_test_cases.py
@@ -38,9 +38,6 @@
from google.cloud.dialogflowcx_v3.services.test_cases import TestCasesClient
from google.cloud.dialogflowcx_v3.services.test_cases import pagers
from google.cloud.dialogflowcx_v3.services.test_cases import transports
-from google.cloud.dialogflowcx_v3.services.test_cases.transports.base import (
- _API_CORE_VERSION,
-)
from google.cloud.dialogflowcx_v3.services.test_cases.transports.base import (
_GOOGLE_AUTH_VERSION,
)
@@ -62,8 +59,9 @@
import google.auth
-# TODO(busunkim): Once google-api-core >= 1.26.0 is required:
-# - Delete all the api-core and auth "less than" test cases
+# TODO(busunkim): Once google-auth >= 1.25.0 is required transitively
+# through google-api-core:
+# - Delete the auth "less than" test cases
# - Delete these pytest markers (Make the "greater than or equal to" tests the default).
requires_google_auth_lt_1_25_0 = pytest.mark.skipif(
packaging.version.parse(_GOOGLE_AUTH_VERSION) >= packaging.version.parse("1.25.0"),
@@ -74,16 +72,6 @@
reason="This test requires google-auth >= 1.25.0",
)
-requires_api_core_lt_1_26_0 = pytest.mark.skipif(
- packaging.version.parse(_API_CORE_VERSION) >= packaging.version.parse("1.26.0"),
- reason="This test requires google-api-core < 1.26.0",
-)
-
-requires_api_core_gte_1_26_0 = pytest.mark.skipif(
- packaging.version.parse(_API_CORE_VERSION) < packaging.version.parse("1.26.0"),
- reason="This test requires google-api-core >= 1.26.0",
-)
-
def client_cert_source_callback():
return b"cert bytes", b"key bytes"
@@ -139,6 +127,34 @@ def test_test_cases_client_from_service_account_info(client_class):
assert client.transport._host == "dialogflow.googleapis.com:443"
+@pytest.mark.parametrize("client_class", [TestCasesClient, TestCasesAsyncClient,])
+def test_test_cases_client_service_account_always_use_jwt(client_class):
+ with mock.patch.object(
+ service_account.Credentials, "with_always_use_jwt_access", create=True
+ ) as use_jwt:
+ creds = service_account.Credentials(None, None, None)
+ client = client_class(credentials=creds)
+ use_jwt.assert_not_called()
+
+
+@pytest.mark.parametrize(
+ "transport_class,transport_name",
+ [
+ (transports.TestCasesGrpcTransport, "grpc"),
+ (transports.TestCasesGrpcAsyncIOTransport, "grpc_asyncio"),
+ ],
+)
+def test_test_cases_client_service_account_always_use_jwt_true(
+ transport_class, transport_name
+):
+ with mock.patch.object(
+ service_account.Credentials, "with_always_use_jwt_access", create=True
+ ) as use_jwt:
+ creds = service_account.Credentials(None, None, None)
+ transport = transport_class(credentials=creds, always_use_jwt_access=True)
+ use_jwt.assert_called_once_with(True)
+
+
@pytest.mark.parametrize("client_class", [TestCasesClient, TestCasesAsyncClient,])
def test_test_cases_client_from_service_account_file(client_class):
creds = ga_credentials.AnonymousCredentials()
@@ -3221,7 +3237,6 @@ def test_test_cases_transport_auth_adc_old_google_auth(transport_class):
(transports.TestCasesGrpcAsyncIOTransport, grpc_helpers_async),
],
)
-@requires_api_core_gte_1_26_0
def test_test_cases_transport_create_channel(transport_class, grpc_helpers):
# If credentials and host are not provided, the transport class should use
# ADC credentials.
@@ -3253,80 +3268,6 @@ def test_test_cases_transport_create_channel(transport_class, grpc_helpers):
)
-@pytest.mark.parametrize(
- "transport_class,grpc_helpers",
- [
- (transports.TestCasesGrpcTransport, grpc_helpers),
- (transports.TestCasesGrpcAsyncIOTransport, grpc_helpers_async),
- ],
-)
-@requires_api_core_lt_1_26_0
-def test_test_cases_transport_create_channel_old_api_core(
- transport_class, grpc_helpers
-):
- # If credentials and host are not provided, the transport class should use
- # ADC credentials.
- with mock.patch.object(
- google.auth, "default", autospec=True
- ) as adc, mock.patch.object(
- grpc_helpers, "create_channel", autospec=True
- ) as create_channel:
- creds = ga_credentials.AnonymousCredentials()
- adc.return_value = (creds, None)
- transport_class(quota_project_id="octopus")
-
- create_channel.assert_called_with(
- "dialogflow.googleapis.com:443",
- credentials=creds,
- credentials_file=None,
- quota_project_id="octopus",
- scopes=(
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/dialogflow",
- ),
- ssl_credentials=None,
- options=[
- ("grpc.max_send_message_length", -1),
- ("grpc.max_receive_message_length", -1),
- ],
- )
-
-
-@pytest.mark.parametrize(
- "transport_class,grpc_helpers",
- [
- (transports.TestCasesGrpcTransport, grpc_helpers),
- (transports.TestCasesGrpcAsyncIOTransport, grpc_helpers_async),
- ],
-)
-@requires_api_core_lt_1_26_0
-def test_test_cases_transport_create_channel_user_scopes(transport_class, grpc_helpers):
- # If credentials and host are not provided, the transport class should use
- # ADC credentials.
- with mock.patch.object(
- google.auth, "default", autospec=True
- ) as adc, mock.patch.object(
- grpc_helpers, "create_channel", autospec=True
- ) as create_channel:
- creds = ga_credentials.AnonymousCredentials()
- adc.return_value = (creds, None)
-
- transport_class(quota_project_id="octopus", scopes=["1", "2"])
-
- create_channel.assert_called_with(
- "dialogflow.googleapis.com:443",
- credentials=creds,
- credentials_file=None,
- quota_project_id="octopus",
- scopes=["1", "2"],
- ssl_credentials=None,
- options=[
- ("grpc.max_send_message_length", -1),
- ("grpc.max_receive_message_length", -1),
- ],
- )
-
-
@pytest.mark.parametrize(
"transport_class",
[transports.TestCasesGrpcTransport, transports.TestCasesGrpcAsyncIOTransport],
@@ -3346,10 +3287,7 @@ def test_test_cases_grpc_transport_client_cert_source_for_mtls(transport_class):
"squid.clam.whelk:443",
credentials=cred,
credentials_file=None,
- scopes=(
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/dialogflow",
- ),
+ scopes=None,
ssl_credentials=mock_ssl_channel_creds,
quota_project_id=None,
options=[
@@ -3453,10 +3391,7 @@ def test_test_cases_transport_channel_mtls_with_client_cert_source(transport_cla
"mtls.squid.clam.whelk:443",
credentials=cred,
credentials_file=None,
- scopes=(
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/dialogflow",
- ),
+ scopes=None,
ssl_credentials=mock_ssl_cred,
quota_project_id=None,
options=[
@@ -3500,10 +3435,7 @@ def test_test_cases_transport_channel_mtls_with_adc(transport_class):
"mtls.squid.clam.whelk:443",
credentials=mock_cred,
credentials_file=None,
- scopes=(
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/dialogflow",
- ),
+ scopes=None,
ssl_credentials=mock_ssl_cred,
quota_project_id=None,
options=[
diff --git a/tests/unit/gapic/dialogflowcx_v3/test_transition_route_groups.py b/tests/unit/gapic/dialogflowcx_v3/test_transition_route_groups.py
index 23367381..129f66ea 100644
--- a/tests/unit/gapic/dialogflowcx_v3/test_transition_route_groups.py
+++ b/tests/unit/gapic/dialogflowcx_v3/test_transition_route_groups.py
@@ -39,9 +39,6 @@
)
from google.cloud.dialogflowcx_v3.services.transition_route_groups import pagers
from google.cloud.dialogflowcx_v3.services.transition_route_groups import transports
-from google.cloud.dialogflowcx_v3.services.transition_route_groups.transports.base import (
- _API_CORE_VERSION,
-)
from google.cloud.dialogflowcx_v3.services.transition_route_groups.transports.base import (
_GOOGLE_AUTH_VERSION,
)
@@ -58,8 +55,9 @@
import google.auth
-# TODO(busunkim): Once google-api-core >= 1.26.0 is required:
-# - Delete all the api-core and auth "less than" test cases
+# TODO(busunkim): Once google-auth >= 1.25.0 is required transitively
+# through google-api-core:
+# - Delete the auth "less than" test cases
# - Delete these pytest markers (Make the "greater than or equal to" tests the default).
requires_google_auth_lt_1_25_0 = pytest.mark.skipif(
packaging.version.parse(_GOOGLE_AUTH_VERSION) >= packaging.version.parse("1.25.0"),
@@ -70,16 +68,6 @@
reason="This test requires google-auth >= 1.25.0",
)
-requires_api_core_lt_1_26_0 = pytest.mark.skipif(
- packaging.version.parse(_API_CORE_VERSION) >= packaging.version.parse("1.26.0"),
- reason="This test requires google-api-core < 1.26.0",
-)
-
-requires_api_core_gte_1_26_0 = pytest.mark.skipif(
- packaging.version.parse(_API_CORE_VERSION) < packaging.version.parse("1.26.0"),
- reason="This test requires google-api-core >= 1.26.0",
-)
-
def client_cert_source_callback():
return b"cert bytes", b"key bytes"
@@ -143,6 +131,36 @@ def test_transition_route_groups_client_from_service_account_info(client_class):
assert client.transport._host == "dialogflow.googleapis.com:443"
+@pytest.mark.parametrize(
+ "client_class", [TransitionRouteGroupsClient, TransitionRouteGroupsAsyncClient,]
+)
+def test_transition_route_groups_client_service_account_always_use_jwt(client_class):
+ with mock.patch.object(
+ service_account.Credentials, "with_always_use_jwt_access", create=True
+ ) as use_jwt:
+ creds = service_account.Credentials(None, None, None)
+ client = client_class(credentials=creds)
+ use_jwt.assert_not_called()
+
+
+@pytest.mark.parametrize(
+ "transport_class,transport_name",
+ [
+ (transports.TransitionRouteGroupsGrpcTransport, "grpc"),
+ (transports.TransitionRouteGroupsGrpcAsyncIOTransport, "grpc_asyncio"),
+ ],
+)
+def test_transition_route_groups_client_service_account_always_use_jwt_true(
+ transport_class, transport_name
+):
+ with mock.patch.object(
+ service_account.Credentials, "with_always_use_jwt_access", create=True
+ ) as use_jwt:
+ creds = service_account.Credentials(None, None, None)
+ transport = transport_class(credentials=creds, always_use_jwt_access=True)
+ use_jwt.assert_called_once_with(True)
+
+
@pytest.mark.parametrize(
"client_class", [TransitionRouteGroupsClient, TransitionRouteGroupsAsyncClient,]
)
@@ -2164,7 +2182,6 @@ def test_transition_route_groups_transport_auth_adc_old_google_auth(transport_cl
(transports.TransitionRouteGroupsGrpcAsyncIOTransport, grpc_helpers_async),
],
)
-@requires_api_core_gte_1_26_0
def test_transition_route_groups_transport_create_channel(
transport_class, grpc_helpers
):
@@ -2198,82 +2215,6 @@ def test_transition_route_groups_transport_create_channel(
)
-@pytest.mark.parametrize(
- "transport_class,grpc_helpers",
- [
- (transports.TransitionRouteGroupsGrpcTransport, grpc_helpers),
- (transports.TransitionRouteGroupsGrpcAsyncIOTransport, grpc_helpers_async),
- ],
-)
-@requires_api_core_lt_1_26_0
-def test_transition_route_groups_transport_create_channel_old_api_core(
- transport_class, grpc_helpers
-):
- # If credentials and host are not provided, the transport class should use
- # ADC credentials.
- with mock.patch.object(
- google.auth, "default", autospec=True
- ) as adc, mock.patch.object(
- grpc_helpers, "create_channel", autospec=True
- ) as create_channel:
- creds = ga_credentials.AnonymousCredentials()
- adc.return_value = (creds, None)
- transport_class(quota_project_id="octopus")
-
- create_channel.assert_called_with(
- "dialogflow.googleapis.com:443",
- credentials=creds,
- credentials_file=None,
- quota_project_id="octopus",
- scopes=(
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/dialogflow",
- ),
- ssl_credentials=None,
- options=[
- ("grpc.max_send_message_length", -1),
- ("grpc.max_receive_message_length", -1),
- ],
- )
-
-
-@pytest.mark.parametrize(
- "transport_class,grpc_helpers",
- [
- (transports.TransitionRouteGroupsGrpcTransport, grpc_helpers),
- (transports.TransitionRouteGroupsGrpcAsyncIOTransport, grpc_helpers_async),
- ],
-)
-@requires_api_core_lt_1_26_0
-def test_transition_route_groups_transport_create_channel_user_scopes(
- transport_class, grpc_helpers
-):
- # If credentials and host are not provided, the transport class should use
- # ADC credentials.
- with mock.patch.object(
- google.auth, "default", autospec=True
- ) as adc, mock.patch.object(
- grpc_helpers, "create_channel", autospec=True
- ) as create_channel:
- creds = ga_credentials.AnonymousCredentials()
- adc.return_value = (creds, None)
-
- transport_class(quota_project_id="octopus", scopes=["1", "2"])
-
- create_channel.assert_called_with(
- "dialogflow.googleapis.com:443",
- credentials=creds,
- credentials_file=None,
- quota_project_id="octopus",
- scopes=["1", "2"],
- ssl_credentials=None,
- options=[
- ("grpc.max_send_message_length", -1),
- ("grpc.max_receive_message_length", -1),
- ],
- )
-
-
@pytest.mark.parametrize(
"transport_class",
[
@@ -2298,10 +2239,7 @@ def test_transition_route_groups_grpc_transport_client_cert_source_for_mtls(
"squid.clam.whelk:443",
credentials=cred,
credentials_file=None,
- scopes=(
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/dialogflow",
- ),
+ scopes=None,
ssl_credentials=mock_ssl_channel_creds,
quota_project_id=None,
options=[
@@ -2410,10 +2348,7 @@ def test_transition_route_groups_transport_channel_mtls_with_client_cert_source(
"mtls.squid.clam.whelk:443",
credentials=cred,
credentials_file=None,
- scopes=(
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/dialogflow",
- ),
+ scopes=None,
ssl_credentials=mock_ssl_cred,
quota_project_id=None,
options=[
@@ -2460,10 +2395,7 @@ def test_transition_route_groups_transport_channel_mtls_with_adc(transport_class
"mtls.squid.clam.whelk:443",
credentials=mock_cred,
credentials_file=None,
- scopes=(
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/dialogflow",
- ),
+ scopes=None,
ssl_credentials=mock_ssl_cred,
quota_project_id=None,
options=[
diff --git a/tests/unit/gapic/dialogflowcx_v3/test_versions.py b/tests/unit/gapic/dialogflowcx_v3/test_versions.py
index 86ffdef4..f3f324f6 100644
--- a/tests/unit/gapic/dialogflowcx_v3/test_versions.py
+++ b/tests/unit/gapic/dialogflowcx_v3/test_versions.py
@@ -38,9 +38,6 @@
from google.cloud.dialogflowcx_v3.services.versions import VersionsClient
from google.cloud.dialogflowcx_v3.services.versions import pagers
from google.cloud.dialogflowcx_v3.services.versions import transports
-from google.cloud.dialogflowcx_v3.services.versions.transports.base import (
- _API_CORE_VERSION,
-)
from google.cloud.dialogflowcx_v3.services.versions.transports.base import (
_GOOGLE_AUTH_VERSION,
)
@@ -55,8 +52,9 @@
import google.auth
-# TODO(busunkim): Once google-api-core >= 1.26.0 is required:
-# - Delete all the api-core and auth "less than" test cases
+# TODO(busunkim): Once google-auth >= 1.25.0 is required transitively
+# through google-api-core:
+# - Delete the auth "less than" test cases
# - Delete these pytest markers (Make the "greater than or equal to" tests the default).
requires_google_auth_lt_1_25_0 = pytest.mark.skipif(
packaging.version.parse(_GOOGLE_AUTH_VERSION) >= packaging.version.parse("1.25.0"),
@@ -67,16 +65,6 @@
reason="This test requires google-auth >= 1.25.0",
)
-requires_api_core_lt_1_26_0 = pytest.mark.skipif(
- packaging.version.parse(_API_CORE_VERSION) >= packaging.version.parse("1.26.0"),
- reason="This test requires google-api-core < 1.26.0",
-)
-
-requires_api_core_gte_1_26_0 = pytest.mark.skipif(
- packaging.version.parse(_API_CORE_VERSION) < packaging.version.parse("1.26.0"),
- reason="This test requires google-api-core >= 1.26.0",
-)
-
def client_cert_source_callback():
return b"cert bytes", b"key bytes"
@@ -132,6 +120,34 @@ def test_versions_client_from_service_account_info(client_class):
assert client.transport._host == "dialogflow.googleapis.com:443"
+@pytest.mark.parametrize("client_class", [VersionsClient, VersionsAsyncClient,])
+def test_versions_client_service_account_always_use_jwt(client_class):
+ with mock.patch.object(
+ service_account.Credentials, "with_always_use_jwt_access", create=True
+ ) as use_jwt:
+ creds = service_account.Credentials(None, None, None)
+ client = client_class(credentials=creds)
+ use_jwt.assert_not_called()
+
+
+@pytest.mark.parametrize(
+ "transport_class,transport_name",
+ [
+ (transports.VersionsGrpcTransport, "grpc"),
+ (transports.VersionsGrpcAsyncIOTransport, "grpc_asyncio"),
+ ],
+)
+def test_versions_client_service_account_always_use_jwt_true(
+ transport_class, transport_name
+):
+ with mock.patch.object(
+ service_account.Credentials, "with_always_use_jwt_access", create=True
+ ) as use_jwt:
+ creds = service_account.Credentials(None, None, None)
+ transport = transport_class(credentials=creds, always_use_jwt_access=True)
+ use_jwt.assert_called_once_with(True)
+
+
@pytest.mark.parametrize("client_class", [VersionsClient, VersionsAsyncClient,])
def test_versions_client_from_service_account_file(client_class):
creds = ga_credentials.AnonymousCredentials()
@@ -2037,7 +2053,6 @@ def test_versions_transport_auth_adc_old_google_auth(transport_class):
(transports.VersionsGrpcAsyncIOTransport, grpc_helpers_async),
],
)
-@requires_api_core_gte_1_26_0
def test_versions_transport_create_channel(transport_class, grpc_helpers):
# If credentials and host are not provided, the transport class should use
# ADC credentials.
@@ -2069,78 +2084,6 @@ def test_versions_transport_create_channel(transport_class, grpc_helpers):
)
-@pytest.mark.parametrize(
- "transport_class,grpc_helpers",
- [
- (transports.VersionsGrpcTransport, grpc_helpers),
- (transports.VersionsGrpcAsyncIOTransport, grpc_helpers_async),
- ],
-)
-@requires_api_core_lt_1_26_0
-def test_versions_transport_create_channel_old_api_core(transport_class, grpc_helpers):
- # If credentials and host are not provided, the transport class should use
- # ADC credentials.
- with mock.patch.object(
- google.auth, "default", autospec=True
- ) as adc, mock.patch.object(
- grpc_helpers, "create_channel", autospec=True
- ) as create_channel:
- creds = ga_credentials.AnonymousCredentials()
- adc.return_value = (creds, None)
- transport_class(quota_project_id="octopus")
-
- create_channel.assert_called_with(
- "dialogflow.googleapis.com:443",
- credentials=creds,
- credentials_file=None,
- quota_project_id="octopus",
- scopes=(
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/dialogflow",
- ),
- ssl_credentials=None,
- options=[
- ("grpc.max_send_message_length", -1),
- ("grpc.max_receive_message_length", -1),
- ],
- )
-
-
-@pytest.mark.parametrize(
- "transport_class,grpc_helpers",
- [
- (transports.VersionsGrpcTransport, grpc_helpers),
- (transports.VersionsGrpcAsyncIOTransport, grpc_helpers_async),
- ],
-)
-@requires_api_core_lt_1_26_0
-def test_versions_transport_create_channel_user_scopes(transport_class, grpc_helpers):
- # If credentials and host are not provided, the transport class should use
- # ADC credentials.
- with mock.patch.object(
- google.auth, "default", autospec=True
- ) as adc, mock.patch.object(
- grpc_helpers, "create_channel", autospec=True
- ) as create_channel:
- creds = ga_credentials.AnonymousCredentials()
- adc.return_value = (creds, None)
-
- transport_class(quota_project_id="octopus", scopes=["1", "2"])
-
- create_channel.assert_called_with(
- "dialogflow.googleapis.com:443",
- credentials=creds,
- credentials_file=None,
- quota_project_id="octopus",
- scopes=["1", "2"],
- ssl_credentials=None,
- options=[
- ("grpc.max_send_message_length", -1),
- ("grpc.max_receive_message_length", -1),
- ],
- )
-
-
@pytest.mark.parametrize(
"transport_class",
[transports.VersionsGrpcTransport, transports.VersionsGrpcAsyncIOTransport],
@@ -2160,10 +2103,7 @@ def test_versions_grpc_transport_client_cert_source_for_mtls(transport_class):
"squid.clam.whelk:443",
credentials=cred,
credentials_file=None,
- scopes=(
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/dialogflow",
- ),
+ scopes=None,
ssl_credentials=mock_ssl_channel_creds,
quota_project_id=None,
options=[
@@ -2267,10 +2207,7 @@ def test_versions_transport_channel_mtls_with_client_cert_source(transport_class
"mtls.squid.clam.whelk:443",
credentials=cred,
credentials_file=None,
- scopes=(
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/dialogflow",
- ),
+ scopes=None,
ssl_credentials=mock_ssl_cred,
quota_project_id=None,
options=[
@@ -2314,10 +2251,7 @@ def test_versions_transport_channel_mtls_with_adc(transport_class):
"mtls.squid.clam.whelk:443",
credentials=mock_cred,
credentials_file=None,
- scopes=(
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/dialogflow",
- ),
+ scopes=None,
ssl_credentials=mock_ssl_cred,
quota_project_id=None,
options=[
diff --git a/tests/unit/gapic/dialogflowcx_v3/test_webhooks.py b/tests/unit/gapic/dialogflowcx_v3/test_webhooks.py
index 5ade2328..ca1ebca9 100644
--- a/tests/unit/gapic/dialogflowcx_v3/test_webhooks.py
+++ b/tests/unit/gapic/dialogflowcx_v3/test_webhooks.py
@@ -35,9 +35,6 @@
from google.cloud.dialogflowcx_v3.services.webhooks import WebhooksClient
from google.cloud.dialogflowcx_v3.services.webhooks import pagers
from google.cloud.dialogflowcx_v3.services.webhooks import transports
-from google.cloud.dialogflowcx_v3.services.webhooks.transports.base import (
- _API_CORE_VERSION,
-)
from google.cloud.dialogflowcx_v3.services.webhooks.transports.base import (
_GOOGLE_AUTH_VERSION,
)
@@ -49,8 +46,9 @@
import google.auth
-# TODO(busunkim): Once google-api-core >= 1.26.0 is required:
-# - Delete all the api-core and auth "less than" test cases
+# TODO(busunkim): Once google-auth >= 1.25.0 is required transitively
+# through google-api-core:
+# - Delete the auth "less than" test cases
# - Delete these pytest markers (Make the "greater than or equal to" tests the default).
requires_google_auth_lt_1_25_0 = pytest.mark.skipif(
packaging.version.parse(_GOOGLE_AUTH_VERSION) >= packaging.version.parse("1.25.0"),
@@ -61,16 +59,6 @@
reason="This test requires google-auth >= 1.25.0",
)
-requires_api_core_lt_1_26_0 = pytest.mark.skipif(
- packaging.version.parse(_API_CORE_VERSION) >= packaging.version.parse("1.26.0"),
- reason="This test requires google-api-core < 1.26.0",
-)
-
-requires_api_core_gte_1_26_0 = pytest.mark.skipif(
- packaging.version.parse(_API_CORE_VERSION) < packaging.version.parse("1.26.0"),
- reason="This test requires google-api-core >= 1.26.0",
-)
-
def client_cert_source_callback():
return b"cert bytes", b"key bytes"
@@ -126,6 +114,34 @@ def test_webhooks_client_from_service_account_info(client_class):
assert client.transport._host == "dialogflow.googleapis.com:443"
+@pytest.mark.parametrize("client_class", [WebhooksClient, WebhooksAsyncClient,])
+def test_webhooks_client_service_account_always_use_jwt(client_class):
+ with mock.patch.object(
+ service_account.Credentials, "with_always_use_jwt_access", create=True
+ ) as use_jwt:
+ creds = service_account.Credentials(None, None, None)
+ client = client_class(credentials=creds)
+ use_jwt.assert_not_called()
+
+
+@pytest.mark.parametrize(
+ "transport_class,transport_name",
+ [
+ (transports.WebhooksGrpcTransport, "grpc"),
+ (transports.WebhooksGrpcAsyncIOTransport, "grpc_asyncio"),
+ ],
+)
+def test_webhooks_client_service_account_always_use_jwt_true(
+ transport_class, transport_name
+):
+ with mock.patch.object(
+ service_account.Credentials, "with_always_use_jwt_access", create=True
+ ) as use_jwt:
+ creds = service_account.Credentials(None, None, None)
+ transport = transport_class(credentials=creds, always_use_jwt_access=True)
+ use_jwt.assert_called_once_with(True)
+
+
@pytest.mark.parametrize("client_class", [WebhooksClient, WebhooksAsyncClient,])
def test_webhooks_client_from_service_account_file(client_class):
creds = ga_credentials.AnonymousCredentials()
@@ -1836,7 +1852,6 @@ def test_webhooks_transport_auth_adc_old_google_auth(transport_class):
(transports.WebhooksGrpcAsyncIOTransport, grpc_helpers_async),
],
)
-@requires_api_core_gte_1_26_0
def test_webhooks_transport_create_channel(transport_class, grpc_helpers):
# If credentials and host are not provided, the transport class should use
# ADC credentials.
@@ -1868,78 +1883,6 @@ def test_webhooks_transport_create_channel(transport_class, grpc_helpers):
)
-@pytest.mark.parametrize(
- "transport_class,grpc_helpers",
- [
- (transports.WebhooksGrpcTransport, grpc_helpers),
- (transports.WebhooksGrpcAsyncIOTransport, grpc_helpers_async),
- ],
-)
-@requires_api_core_lt_1_26_0
-def test_webhooks_transport_create_channel_old_api_core(transport_class, grpc_helpers):
- # If credentials and host are not provided, the transport class should use
- # ADC credentials.
- with mock.patch.object(
- google.auth, "default", autospec=True
- ) as adc, mock.patch.object(
- grpc_helpers, "create_channel", autospec=True
- ) as create_channel:
- creds = ga_credentials.AnonymousCredentials()
- adc.return_value = (creds, None)
- transport_class(quota_project_id="octopus")
-
- create_channel.assert_called_with(
- "dialogflow.googleapis.com:443",
- credentials=creds,
- credentials_file=None,
- quota_project_id="octopus",
- scopes=(
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/dialogflow",
- ),
- ssl_credentials=None,
- options=[
- ("grpc.max_send_message_length", -1),
- ("grpc.max_receive_message_length", -1),
- ],
- )
-
-
-@pytest.mark.parametrize(
- "transport_class,grpc_helpers",
- [
- (transports.WebhooksGrpcTransport, grpc_helpers),
- (transports.WebhooksGrpcAsyncIOTransport, grpc_helpers_async),
- ],
-)
-@requires_api_core_lt_1_26_0
-def test_webhooks_transport_create_channel_user_scopes(transport_class, grpc_helpers):
- # If credentials and host are not provided, the transport class should use
- # ADC credentials.
- with mock.patch.object(
- google.auth, "default", autospec=True
- ) as adc, mock.patch.object(
- grpc_helpers, "create_channel", autospec=True
- ) as create_channel:
- creds = ga_credentials.AnonymousCredentials()
- adc.return_value = (creds, None)
-
- transport_class(quota_project_id="octopus", scopes=["1", "2"])
-
- create_channel.assert_called_with(
- "dialogflow.googleapis.com:443",
- credentials=creds,
- credentials_file=None,
- quota_project_id="octopus",
- scopes=["1", "2"],
- ssl_credentials=None,
- options=[
- ("grpc.max_send_message_length", -1),
- ("grpc.max_receive_message_length", -1),
- ],
- )
-
-
@pytest.mark.parametrize(
"transport_class",
[transports.WebhooksGrpcTransport, transports.WebhooksGrpcAsyncIOTransport],
@@ -1959,10 +1902,7 @@ def test_webhooks_grpc_transport_client_cert_source_for_mtls(transport_class):
"squid.clam.whelk:443",
credentials=cred,
credentials_file=None,
- scopes=(
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/dialogflow",
- ),
+ scopes=None,
ssl_credentials=mock_ssl_channel_creds,
quota_project_id=None,
options=[
@@ -2066,10 +2006,7 @@ def test_webhooks_transport_channel_mtls_with_client_cert_source(transport_class
"mtls.squid.clam.whelk:443",
credentials=cred,
credentials_file=None,
- scopes=(
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/dialogflow",
- ),
+ scopes=None,
ssl_credentials=mock_ssl_cred,
quota_project_id=None,
options=[
@@ -2113,10 +2050,7 @@ def test_webhooks_transport_channel_mtls_with_adc(transport_class):
"mtls.squid.clam.whelk:443",
credentials=mock_cred,
credentials_file=None,
- scopes=(
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/dialogflow",
- ),
+ scopes=None,
ssl_credentials=mock_ssl_cred,
quota_project_id=None,
options=[
diff --git a/tests/unit/gapic/dialogflowcx_v3beta1/test_agents.py b/tests/unit/gapic/dialogflowcx_v3beta1/test_agents.py
index ee7559ef..72ccfc4b 100644
--- a/tests/unit/gapic/dialogflowcx_v3beta1/test_agents.py
+++ b/tests/unit/gapic/dialogflowcx_v3beta1/test_agents.py
@@ -38,9 +38,6 @@
from google.cloud.dialogflowcx_v3beta1.services.agents import AgentsClient
from google.cloud.dialogflowcx_v3beta1.services.agents import pagers
from google.cloud.dialogflowcx_v3beta1.services.agents import transports
-from google.cloud.dialogflowcx_v3beta1.services.agents.transports.base import (
- _API_CORE_VERSION,
-)
from google.cloud.dialogflowcx_v3beta1.services.agents.transports.base import (
_GOOGLE_AUTH_VERSION,
)
@@ -54,8 +51,9 @@
import google.auth
-# TODO(busunkim): Once google-api-core >= 1.26.0 is required:
-# - Delete all the api-core and auth "less than" test cases
+# TODO(busunkim): Once google-auth >= 1.25.0 is required transitively
+# through google-api-core:
+# - Delete the auth "less than" test cases
# - Delete these pytest markers (Make the "greater than or equal to" tests the default).
requires_google_auth_lt_1_25_0 = pytest.mark.skipif(
packaging.version.parse(_GOOGLE_AUTH_VERSION) >= packaging.version.parse("1.25.0"),
@@ -66,16 +64,6 @@
reason="This test requires google-auth >= 1.25.0",
)
-requires_api_core_lt_1_26_0 = pytest.mark.skipif(
- packaging.version.parse(_API_CORE_VERSION) >= packaging.version.parse("1.26.0"),
- reason="This test requires google-api-core < 1.26.0",
-)
-
-requires_api_core_gte_1_26_0 = pytest.mark.skipif(
- packaging.version.parse(_API_CORE_VERSION) < packaging.version.parse("1.26.0"),
- reason="This test requires google-api-core >= 1.26.0",
-)
-
def client_cert_source_callback():
return b"cert bytes", b"key bytes"
@@ -130,6 +118,34 @@ def test_agents_client_from_service_account_info(client_class):
assert client.transport._host == "dialogflow.googleapis.com:443"
+@pytest.mark.parametrize("client_class", [AgentsClient, AgentsAsyncClient,])
+def test_agents_client_service_account_always_use_jwt(client_class):
+ with mock.patch.object(
+ service_account.Credentials, "with_always_use_jwt_access", create=True
+ ) as use_jwt:
+ creds = service_account.Credentials(None, None, None)
+ client = client_class(credentials=creds)
+ use_jwt.assert_not_called()
+
+
+@pytest.mark.parametrize(
+ "transport_class,transport_name",
+ [
+ (transports.AgentsGrpcTransport, "grpc"),
+ (transports.AgentsGrpcAsyncIOTransport, "grpc_asyncio"),
+ ],
+)
+def test_agents_client_service_account_always_use_jwt_true(
+ transport_class, transport_name
+):
+ with mock.patch.object(
+ service_account.Credentials, "with_always_use_jwt_access", create=True
+ ) as use_jwt:
+ creds = service_account.Credentials(None, None, None)
+ transport = transport_class(credentials=creds, always_use_jwt_access=True)
+ use_jwt.assert_called_once_with(True)
+
+
@pytest.mark.parametrize("client_class", [AgentsClient, AgentsAsyncClient,])
def test_agents_client_from_service_account_file(client_class):
creds = ga_credentials.AnonymousCredentials()
@@ -2510,7 +2526,6 @@ def test_agents_transport_auth_adc_old_google_auth(transport_class):
(transports.AgentsGrpcAsyncIOTransport, grpc_helpers_async),
],
)
-@requires_api_core_gte_1_26_0
def test_agents_transport_create_channel(transport_class, grpc_helpers):
# If credentials and host are not provided, the transport class should use
# ADC credentials.
@@ -2542,78 +2557,6 @@ def test_agents_transport_create_channel(transport_class, grpc_helpers):
)
-@pytest.mark.parametrize(
- "transport_class,grpc_helpers",
- [
- (transports.AgentsGrpcTransport, grpc_helpers),
- (transports.AgentsGrpcAsyncIOTransport, grpc_helpers_async),
- ],
-)
-@requires_api_core_lt_1_26_0
-def test_agents_transport_create_channel_old_api_core(transport_class, grpc_helpers):
- # If credentials and host are not provided, the transport class should use
- # ADC credentials.
- with mock.patch.object(
- google.auth, "default", autospec=True
- ) as adc, mock.patch.object(
- grpc_helpers, "create_channel", autospec=True
- ) as create_channel:
- creds = ga_credentials.AnonymousCredentials()
- adc.return_value = (creds, None)
- transport_class(quota_project_id="octopus")
-
- create_channel.assert_called_with(
- "dialogflow.googleapis.com:443",
- credentials=creds,
- credentials_file=None,
- quota_project_id="octopus",
- scopes=(
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/dialogflow",
- ),
- ssl_credentials=None,
- options=[
- ("grpc.max_send_message_length", -1),
- ("grpc.max_receive_message_length", -1),
- ],
- )
-
-
-@pytest.mark.parametrize(
- "transport_class,grpc_helpers",
- [
- (transports.AgentsGrpcTransport, grpc_helpers),
- (transports.AgentsGrpcAsyncIOTransport, grpc_helpers_async),
- ],
-)
-@requires_api_core_lt_1_26_0
-def test_agents_transport_create_channel_user_scopes(transport_class, grpc_helpers):
- # If credentials and host are not provided, the transport class should use
- # ADC credentials.
- with mock.patch.object(
- google.auth, "default", autospec=True
- ) as adc, mock.patch.object(
- grpc_helpers, "create_channel", autospec=True
- ) as create_channel:
- creds = ga_credentials.AnonymousCredentials()
- adc.return_value = (creds, None)
-
- transport_class(quota_project_id="octopus", scopes=["1", "2"])
-
- create_channel.assert_called_with(
- "dialogflow.googleapis.com:443",
- credentials=creds,
- credentials_file=None,
- quota_project_id="octopus",
- scopes=["1", "2"],
- ssl_credentials=None,
- options=[
- ("grpc.max_send_message_length", -1),
- ("grpc.max_receive_message_length", -1),
- ],
- )
-
-
@pytest.mark.parametrize(
"transport_class",
[transports.AgentsGrpcTransport, transports.AgentsGrpcAsyncIOTransport],
@@ -2633,10 +2576,7 @@ def test_agents_grpc_transport_client_cert_source_for_mtls(transport_class):
"squid.clam.whelk:443",
credentials=cred,
credentials_file=None,
- scopes=(
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/dialogflow",
- ),
+ scopes=None,
ssl_credentials=mock_ssl_channel_creds,
quota_project_id=None,
options=[
@@ -2740,10 +2680,7 @@ def test_agents_transport_channel_mtls_with_client_cert_source(transport_class):
"mtls.squid.clam.whelk:443",
credentials=cred,
credentials_file=None,
- scopes=(
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/dialogflow",
- ),
+ scopes=None,
ssl_credentials=mock_ssl_cred,
quota_project_id=None,
options=[
@@ -2787,10 +2724,7 @@ def test_agents_transport_channel_mtls_with_adc(transport_class):
"mtls.squid.clam.whelk:443",
credentials=mock_cred,
credentials_file=None,
- scopes=(
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/dialogflow",
- ),
+ scopes=None,
ssl_credentials=mock_ssl_cred,
quota_project_id=None,
options=[
diff --git a/tests/unit/gapic/dialogflowcx_v3beta1/test_entity_types.py b/tests/unit/gapic/dialogflowcx_v3beta1/test_entity_types.py
index 2c7b5005..15004b16 100644
--- a/tests/unit/gapic/dialogflowcx_v3beta1/test_entity_types.py
+++ b/tests/unit/gapic/dialogflowcx_v3beta1/test_entity_types.py
@@ -37,9 +37,6 @@
from google.cloud.dialogflowcx_v3beta1.services.entity_types import EntityTypesClient
from google.cloud.dialogflowcx_v3beta1.services.entity_types import pagers
from google.cloud.dialogflowcx_v3beta1.services.entity_types import transports
-from google.cloud.dialogflowcx_v3beta1.services.entity_types.transports.base import (
- _API_CORE_VERSION,
-)
from google.cloud.dialogflowcx_v3beta1.services.entity_types.transports.base import (
_GOOGLE_AUTH_VERSION,
)
@@ -50,8 +47,9 @@
import google.auth
-# TODO(busunkim): Once google-api-core >= 1.26.0 is required:
-# - Delete all the api-core and auth "less than" test cases
+# TODO(busunkim): Once google-auth >= 1.25.0 is required transitively
+# through google-api-core:
+# - Delete the auth "less than" test cases
# - Delete these pytest markers (Make the "greater than or equal to" tests the default).
requires_google_auth_lt_1_25_0 = pytest.mark.skipif(
packaging.version.parse(_GOOGLE_AUTH_VERSION) >= packaging.version.parse("1.25.0"),
@@ -62,16 +60,6 @@
reason="This test requires google-auth >= 1.25.0",
)
-requires_api_core_lt_1_26_0 = pytest.mark.skipif(
- packaging.version.parse(_API_CORE_VERSION) >= packaging.version.parse("1.26.0"),
- reason="This test requires google-api-core < 1.26.0",
-)
-
-requires_api_core_gte_1_26_0 = pytest.mark.skipif(
- packaging.version.parse(_API_CORE_VERSION) < packaging.version.parse("1.26.0"),
- reason="This test requires google-api-core >= 1.26.0",
-)
-
def client_cert_source_callback():
return b"cert bytes", b"key bytes"
@@ -129,6 +117,34 @@ def test_entity_types_client_from_service_account_info(client_class):
assert client.transport._host == "dialogflow.googleapis.com:443"
+@pytest.mark.parametrize("client_class", [EntityTypesClient, EntityTypesAsyncClient,])
+def test_entity_types_client_service_account_always_use_jwt(client_class):
+ with mock.patch.object(
+ service_account.Credentials, "with_always_use_jwt_access", create=True
+ ) as use_jwt:
+ creds = service_account.Credentials(None, None, None)
+ client = client_class(credentials=creds)
+ use_jwt.assert_not_called()
+
+
+@pytest.mark.parametrize(
+ "transport_class,transport_name",
+ [
+ (transports.EntityTypesGrpcTransport, "grpc"),
+ (transports.EntityTypesGrpcAsyncIOTransport, "grpc_asyncio"),
+ ],
+)
+def test_entity_types_client_service_account_always_use_jwt_true(
+ transport_class, transport_name
+):
+ with mock.patch.object(
+ service_account.Credentials, "with_always_use_jwt_access", create=True
+ ) as use_jwt:
+ creds = service_account.Credentials(None, None, None)
+ transport = transport_class(credentials=creds, always_use_jwt_access=True)
+ use_jwt.assert_called_once_with(True)
+
+
@pytest.mark.parametrize("client_class", [EntityTypesClient, EntityTypesAsyncClient,])
def test_entity_types_client_from_service_account_file(client_class):
creds = ga_credentials.AnonymousCredentials()
@@ -2010,7 +2026,6 @@ def test_entity_types_transport_auth_adc_old_google_auth(transport_class):
(transports.EntityTypesGrpcAsyncIOTransport, grpc_helpers_async),
],
)
-@requires_api_core_gte_1_26_0
def test_entity_types_transport_create_channel(transport_class, grpc_helpers):
# If credentials and host are not provided, the transport class should use
# ADC credentials.
@@ -2042,82 +2057,6 @@ def test_entity_types_transport_create_channel(transport_class, grpc_helpers):
)
-@pytest.mark.parametrize(
- "transport_class,grpc_helpers",
- [
- (transports.EntityTypesGrpcTransport, grpc_helpers),
- (transports.EntityTypesGrpcAsyncIOTransport, grpc_helpers_async),
- ],
-)
-@requires_api_core_lt_1_26_0
-def test_entity_types_transport_create_channel_old_api_core(
- transport_class, grpc_helpers
-):
- # If credentials and host are not provided, the transport class should use
- # ADC credentials.
- with mock.patch.object(
- google.auth, "default", autospec=True
- ) as adc, mock.patch.object(
- grpc_helpers, "create_channel", autospec=True
- ) as create_channel:
- creds = ga_credentials.AnonymousCredentials()
- adc.return_value = (creds, None)
- transport_class(quota_project_id="octopus")
-
- create_channel.assert_called_with(
- "dialogflow.googleapis.com:443",
- credentials=creds,
- credentials_file=None,
- quota_project_id="octopus",
- scopes=(
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/dialogflow",
- ),
- ssl_credentials=None,
- options=[
- ("grpc.max_send_message_length", -1),
- ("grpc.max_receive_message_length", -1),
- ],
- )
-
-
-@pytest.mark.parametrize(
- "transport_class,grpc_helpers",
- [
- (transports.EntityTypesGrpcTransport, grpc_helpers),
- (transports.EntityTypesGrpcAsyncIOTransport, grpc_helpers_async),
- ],
-)
-@requires_api_core_lt_1_26_0
-def test_entity_types_transport_create_channel_user_scopes(
- transport_class, grpc_helpers
-):
- # If credentials and host are not provided, the transport class should use
- # ADC credentials.
- with mock.patch.object(
- google.auth, "default", autospec=True
- ) as adc, mock.patch.object(
- grpc_helpers, "create_channel", autospec=True
- ) as create_channel:
- creds = ga_credentials.AnonymousCredentials()
- adc.return_value = (creds, None)
-
- transport_class(quota_project_id="octopus", scopes=["1", "2"])
-
- create_channel.assert_called_with(
- "dialogflow.googleapis.com:443",
- credentials=creds,
- credentials_file=None,
- quota_project_id="octopus",
- scopes=["1", "2"],
- ssl_credentials=None,
- options=[
- ("grpc.max_send_message_length", -1),
- ("grpc.max_receive_message_length", -1),
- ],
- )
-
-
@pytest.mark.parametrize(
"transport_class",
[transports.EntityTypesGrpcTransport, transports.EntityTypesGrpcAsyncIOTransport],
@@ -2137,10 +2076,7 @@ def test_entity_types_grpc_transport_client_cert_source_for_mtls(transport_class
"squid.clam.whelk:443",
credentials=cred,
credentials_file=None,
- scopes=(
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/dialogflow",
- ),
+ scopes=None,
ssl_credentials=mock_ssl_channel_creds,
quota_project_id=None,
options=[
@@ -2244,10 +2180,7 @@ def test_entity_types_transport_channel_mtls_with_client_cert_source(transport_c
"mtls.squid.clam.whelk:443",
credentials=cred,
credentials_file=None,
- scopes=(
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/dialogflow",
- ),
+ scopes=None,
ssl_credentials=mock_ssl_cred,
quota_project_id=None,
options=[
@@ -2291,10 +2224,7 @@ def test_entity_types_transport_channel_mtls_with_adc(transport_class):
"mtls.squid.clam.whelk:443",
credentials=mock_cred,
credentials_file=None,
- scopes=(
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/dialogflow",
- ),
+ scopes=None,
ssl_credentials=mock_ssl_cred,
quota_project_id=None,
options=[
diff --git a/tests/unit/gapic/dialogflowcx_v3beta1/test_environments.py b/tests/unit/gapic/dialogflowcx_v3beta1/test_environments.py
index fd6bc8a6..f3d397c6 100644
--- a/tests/unit/gapic/dialogflowcx_v3beta1/test_environments.py
+++ b/tests/unit/gapic/dialogflowcx_v3beta1/test_environments.py
@@ -40,9 +40,6 @@
from google.cloud.dialogflowcx_v3beta1.services.environments import EnvironmentsClient
from google.cloud.dialogflowcx_v3beta1.services.environments import pagers
from google.cloud.dialogflowcx_v3beta1.services.environments import transports
-from google.cloud.dialogflowcx_v3beta1.services.environments.transports.base import (
- _API_CORE_VERSION,
-)
from google.cloud.dialogflowcx_v3beta1.services.environments.transports.base import (
_GOOGLE_AUTH_VERSION,
)
@@ -56,8 +53,9 @@
import google.auth
-# TODO(busunkim): Once google-api-core >= 1.26.0 is required:
-# - Delete all the api-core and auth "less than" test cases
+# TODO(busunkim): Once google-auth >= 1.25.0 is required transitively
+# through google-api-core:
+# - Delete the auth "less than" test cases
# - Delete these pytest markers (Make the "greater than or equal to" tests the default).
requires_google_auth_lt_1_25_0 = pytest.mark.skipif(
packaging.version.parse(_GOOGLE_AUTH_VERSION) >= packaging.version.parse("1.25.0"),
@@ -68,16 +66,6 @@
reason="This test requires google-auth >= 1.25.0",
)
-requires_api_core_lt_1_26_0 = pytest.mark.skipif(
- packaging.version.parse(_API_CORE_VERSION) >= packaging.version.parse("1.26.0"),
- reason="This test requires google-api-core < 1.26.0",
-)
-
-requires_api_core_gte_1_26_0 = pytest.mark.skipif(
- packaging.version.parse(_API_CORE_VERSION) < packaging.version.parse("1.26.0"),
- reason="This test requires google-api-core >= 1.26.0",
-)
-
def client_cert_source_callback():
return b"cert bytes", b"key bytes"
@@ -135,6 +123,34 @@ def test_environments_client_from_service_account_info(client_class):
assert client.transport._host == "dialogflow.googleapis.com:443"
+@pytest.mark.parametrize("client_class", [EnvironmentsClient, EnvironmentsAsyncClient,])
+def test_environments_client_service_account_always_use_jwt(client_class):
+ with mock.patch.object(
+ service_account.Credentials, "with_always_use_jwt_access", create=True
+ ) as use_jwt:
+ creds = service_account.Credentials(None, None, None)
+ client = client_class(credentials=creds)
+ use_jwt.assert_not_called()
+
+
+@pytest.mark.parametrize(
+ "transport_class,transport_name",
+ [
+ (transports.EnvironmentsGrpcTransport, "grpc"),
+ (transports.EnvironmentsGrpcAsyncIOTransport, "grpc_asyncio"),
+ ],
+)
+def test_environments_client_service_account_always_use_jwt_true(
+ transport_class, transport_name
+):
+ with mock.patch.object(
+ service_account.Credentials, "with_always_use_jwt_access", create=True
+ ) as use_jwt:
+ creds = service_account.Credentials(None, None, None)
+ transport = transport_class(credentials=creds, always_use_jwt_access=True)
+ use_jwt.assert_called_once_with(True)
+
+
@pytest.mark.parametrize("client_class", [EnvironmentsClient, EnvironmentsAsyncClient,])
def test_environments_client_from_service_account_file(client_class):
creds = ga_credentials.AnonymousCredentials()
@@ -2847,7 +2863,6 @@ def test_environments_transport_auth_adc_old_google_auth(transport_class):
(transports.EnvironmentsGrpcAsyncIOTransport, grpc_helpers_async),
],
)
-@requires_api_core_gte_1_26_0
def test_environments_transport_create_channel(transport_class, grpc_helpers):
# If credentials and host are not provided, the transport class should use
# ADC credentials.
@@ -2879,82 +2894,6 @@ def test_environments_transport_create_channel(transport_class, grpc_helpers):
)
-@pytest.mark.parametrize(
- "transport_class,grpc_helpers",
- [
- (transports.EnvironmentsGrpcTransport, grpc_helpers),
- (transports.EnvironmentsGrpcAsyncIOTransport, grpc_helpers_async),
- ],
-)
-@requires_api_core_lt_1_26_0
-def test_environments_transport_create_channel_old_api_core(
- transport_class, grpc_helpers
-):
- # If credentials and host are not provided, the transport class should use
- # ADC credentials.
- with mock.patch.object(
- google.auth, "default", autospec=True
- ) as adc, mock.patch.object(
- grpc_helpers, "create_channel", autospec=True
- ) as create_channel:
- creds = ga_credentials.AnonymousCredentials()
- adc.return_value = (creds, None)
- transport_class(quota_project_id="octopus")
-
- create_channel.assert_called_with(
- "dialogflow.googleapis.com:443",
- credentials=creds,
- credentials_file=None,
- quota_project_id="octopus",
- scopes=(
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/dialogflow",
- ),
- ssl_credentials=None,
- options=[
- ("grpc.max_send_message_length", -1),
- ("grpc.max_receive_message_length", -1),
- ],
- )
-
-
-@pytest.mark.parametrize(
- "transport_class,grpc_helpers",
- [
- (transports.EnvironmentsGrpcTransport, grpc_helpers),
- (transports.EnvironmentsGrpcAsyncIOTransport, grpc_helpers_async),
- ],
-)
-@requires_api_core_lt_1_26_0
-def test_environments_transport_create_channel_user_scopes(
- transport_class, grpc_helpers
-):
- # If credentials and host are not provided, the transport class should use
- # ADC credentials.
- with mock.patch.object(
- google.auth, "default", autospec=True
- ) as adc, mock.patch.object(
- grpc_helpers, "create_channel", autospec=True
- ) as create_channel:
- creds = ga_credentials.AnonymousCredentials()
- adc.return_value = (creds, None)
-
- transport_class(quota_project_id="octopus", scopes=["1", "2"])
-
- create_channel.assert_called_with(
- "dialogflow.googleapis.com:443",
- credentials=creds,
- credentials_file=None,
- quota_project_id="octopus",
- scopes=["1", "2"],
- ssl_credentials=None,
- options=[
- ("grpc.max_send_message_length", -1),
- ("grpc.max_receive_message_length", -1),
- ],
- )
-
-
@pytest.mark.parametrize(
"transport_class",
[transports.EnvironmentsGrpcTransport, transports.EnvironmentsGrpcAsyncIOTransport],
@@ -2974,10 +2913,7 @@ def test_environments_grpc_transport_client_cert_source_for_mtls(transport_class
"squid.clam.whelk:443",
credentials=cred,
credentials_file=None,
- scopes=(
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/dialogflow",
- ),
+ scopes=None,
ssl_credentials=mock_ssl_channel_creds,
quota_project_id=None,
options=[
@@ -3081,10 +3017,7 @@ def test_environments_transport_channel_mtls_with_client_cert_source(transport_c
"mtls.squid.clam.whelk:443",
credentials=cred,
credentials_file=None,
- scopes=(
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/dialogflow",
- ),
+ scopes=None,
ssl_credentials=mock_ssl_cred,
quota_project_id=None,
options=[
@@ -3128,10 +3061,7 @@ def test_environments_transport_channel_mtls_with_adc(transport_class):
"mtls.squid.clam.whelk:443",
credentials=mock_cred,
credentials_file=None,
- scopes=(
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/dialogflow",
- ),
+ scopes=None,
ssl_credentials=mock_ssl_cred,
quota_project_id=None,
options=[
diff --git a/tests/unit/gapic/dialogflowcx_v3beta1/test_experiments.py b/tests/unit/gapic/dialogflowcx_v3beta1/test_experiments.py
index 73adc4d8..67727ee1 100644
--- a/tests/unit/gapic/dialogflowcx_v3beta1/test_experiments.py
+++ b/tests/unit/gapic/dialogflowcx_v3beta1/test_experiments.py
@@ -37,9 +37,6 @@
from google.cloud.dialogflowcx_v3beta1.services.experiments import ExperimentsClient
from google.cloud.dialogflowcx_v3beta1.services.experiments import pagers
from google.cloud.dialogflowcx_v3beta1.services.experiments import transports
-from google.cloud.dialogflowcx_v3beta1.services.experiments.transports.base import (
- _API_CORE_VERSION,
-)
from google.cloud.dialogflowcx_v3beta1.services.experiments.transports.base import (
_GOOGLE_AUTH_VERSION,
)
@@ -52,8 +49,9 @@
import google.auth
-# TODO(busunkim): Once google-api-core >= 1.26.0 is required:
-# - Delete all the api-core and auth "less than" test cases
+# TODO(busunkim): Once google-auth >= 1.25.0 is required transitively
+# through google-api-core:
+# - Delete the auth "less than" test cases
# - Delete these pytest markers (Make the "greater than or equal to" tests the default).
requires_google_auth_lt_1_25_0 = pytest.mark.skipif(
packaging.version.parse(_GOOGLE_AUTH_VERSION) >= packaging.version.parse("1.25.0"),
@@ -64,16 +62,6 @@
reason="This test requires google-auth >= 1.25.0",
)
-requires_api_core_lt_1_26_0 = pytest.mark.skipif(
- packaging.version.parse(_API_CORE_VERSION) >= packaging.version.parse("1.26.0"),
- reason="This test requires google-api-core < 1.26.0",
-)
-
-requires_api_core_gte_1_26_0 = pytest.mark.skipif(
- packaging.version.parse(_API_CORE_VERSION) < packaging.version.parse("1.26.0"),
- reason="This test requires google-api-core >= 1.26.0",
-)
-
def client_cert_source_callback():
return b"cert bytes", b"key bytes"
@@ -131,6 +119,34 @@ def test_experiments_client_from_service_account_info(client_class):
assert client.transport._host == "dialogflow.googleapis.com:443"
+@pytest.mark.parametrize("client_class", [ExperimentsClient, ExperimentsAsyncClient,])
+def test_experiments_client_service_account_always_use_jwt(client_class):
+ with mock.patch.object(
+ service_account.Credentials, "with_always_use_jwt_access", create=True
+ ) as use_jwt:
+ creds = service_account.Credentials(None, None, None)
+ client = client_class(credentials=creds)
+ use_jwt.assert_not_called()
+
+
+@pytest.mark.parametrize(
+ "transport_class,transport_name",
+ [
+ (transports.ExperimentsGrpcTransport, "grpc"),
+ (transports.ExperimentsGrpcAsyncIOTransport, "grpc_asyncio"),
+ ],
+)
+def test_experiments_client_service_account_always_use_jwt_true(
+ transport_class, transport_name
+):
+ with mock.patch.object(
+ service_account.Credentials, "with_always_use_jwt_access", create=True
+ ) as use_jwt:
+ creds = service_account.Credentials(None, None, None)
+ transport = transport_class(credentials=creds, always_use_jwt_access=True)
+ use_jwt.assert_called_once_with(True)
+
+
@pytest.mark.parametrize("client_class", [ExperimentsClient, ExperimentsAsyncClient,])
def test_experiments_client_from_service_account_file(client_class):
creds = ga_credentials.AnonymousCredentials()
@@ -2364,7 +2380,6 @@ def test_experiments_transport_auth_adc_old_google_auth(transport_class):
(transports.ExperimentsGrpcAsyncIOTransport, grpc_helpers_async),
],
)
-@requires_api_core_gte_1_26_0
def test_experiments_transport_create_channel(transport_class, grpc_helpers):
# If credentials and host are not provided, the transport class should use
# ADC credentials.
@@ -2396,82 +2411,6 @@ def test_experiments_transport_create_channel(transport_class, grpc_helpers):
)
-@pytest.mark.parametrize(
- "transport_class,grpc_helpers",
- [
- (transports.ExperimentsGrpcTransport, grpc_helpers),
- (transports.ExperimentsGrpcAsyncIOTransport, grpc_helpers_async),
- ],
-)
-@requires_api_core_lt_1_26_0
-def test_experiments_transport_create_channel_old_api_core(
- transport_class, grpc_helpers
-):
- # If credentials and host are not provided, the transport class should use
- # ADC credentials.
- with mock.patch.object(
- google.auth, "default", autospec=True
- ) as adc, mock.patch.object(
- grpc_helpers, "create_channel", autospec=True
- ) as create_channel:
- creds = ga_credentials.AnonymousCredentials()
- adc.return_value = (creds, None)
- transport_class(quota_project_id="octopus")
-
- create_channel.assert_called_with(
- "dialogflow.googleapis.com:443",
- credentials=creds,
- credentials_file=None,
- quota_project_id="octopus",
- scopes=(
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/dialogflow",
- ),
- ssl_credentials=None,
- options=[
- ("grpc.max_send_message_length", -1),
- ("grpc.max_receive_message_length", -1),
- ],
- )
-
-
-@pytest.mark.parametrize(
- "transport_class,grpc_helpers",
- [
- (transports.ExperimentsGrpcTransport, grpc_helpers),
- (transports.ExperimentsGrpcAsyncIOTransport, grpc_helpers_async),
- ],
-)
-@requires_api_core_lt_1_26_0
-def test_experiments_transport_create_channel_user_scopes(
- transport_class, grpc_helpers
-):
- # If credentials and host are not provided, the transport class should use
- # ADC credentials.
- with mock.patch.object(
- google.auth, "default", autospec=True
- ) as adc, mock.patch.object(
- grpc_helpers, "create_channel", autospec=True
- ) as create_channel:
- creds = ga_credentials.AnonymousCredentials()
- adc.return_value = (creds, None)
-
- transport_class(quota_project_id="octopus", scopes=["1", "2"])
-
- create_channel.assert_called_with(
- "dialogflow.googleapis.com:443",
- credentials=creds,
- credentials_file=None,
- quota_project_id="octopus",
- scopes=["1", "2"],
- ssl_credentials=None,
- options=[
- ("grpc.max_send_message_length", -1),
- ("grpc.max_receive_message_length", -1),
- ],
- )
-
-
@pytest.mark.parametrize(
"transport_class",
[transports.ExperimentsGrpcTransport, transports.ExperimentsGrpcAsyncIOTransport],
@@ -2491,10 +2430,7 @@ def test_experiments_grpc_transport_client_cert_source_for_mtls(transport_class)
"squid.clam.whelk:443",
credentials=cred,
credentials_file=None,
- scopes=(
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/dialogflow",
- ),
+ scopes=None,
ssl_credentials=mock_ssl_channel_creds,
quota_project_id=None,
options=[
@@ -2598,10 +2534,7 @@ def test_experiments_transport_channel_mtls_with_client_cert_source(transport_cl
"mtls.squid.clam.whelk:443",
credentials=cred,
credentials_file=None,
- scopes=(
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/dialogflow",
- ),
+ scopes=None,
ssl_credentials=mock_ssl_cred,
quota_project_id=None,
options=[
@@ -2645,10 +2578,7 @@ def test_experiments_transport_channel_mtls_with_adc(transport_class):
"mtls.squid.clam.whelk:443",
credentials=mock_cred,
credentials_file=None,
- scopes=(
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/dialogflow",
- ),
+ scopes=None,
ssl_credentials=mock_ssl_cred,
quota_project_id=None,
options=[
diff --git a/tests/unit/gapic/dialogflowcx_v3beta1/test_flows.py b/tests/unit/gapic/dialogflowcx_v3beta1/test_flows.py
index a728506a..6689ae8e 100644
--- a/tests/unit/gapic/dialogflowcx_v3beta1/test_flows.py
+++ b/tests/unit/gapic/dialogflowcx_v3beta1/test_flows.py
@@ -38,9 +38,6 @@
from google.cloud.dialogflowcx_v3beta1.services.flows import FlowsClient
from google.cloud.dialogflowcx_v3beta1.services.flows import pagers
from google.cloud.dialogflowcx_v3beta1.services.flows import transports
-from google.cloud.dialogflowcx_v3beta1.services.flows.transports.base import (
- _API_CORE_VERSION,
-)
from google.cloud.dialogflowcx_v3beta1.services.flows.transports.base import (
_GOOGLE_AUTH_VERSION,
)
@@ -58,8 +55,9 @@
import google.auth
-# TODO(busunkim): Once google-api-core >= 1.26.0 is required:
-# - Delete all the api-core and auth "less than" test cases
+# TODO(busunkim): Once google-auth >= 1.25.0 is required transitively
+# through google-api-core:
+# - Delete the auth "less than" test cases
# - Delete these pytest markers (Make the "greater than or equal to" tests the default).
requires_google_auth_lt_1_25_0 = pytest.mark.skipif(
packaging.version.parse(_GOOGLE_AUTH_VERSION) >= packaging.version.parse("1.25.0"),
@@ -70,16 +68,6 @@
reason="This test requires google-auth >= 1.25.0",
)
-requires_api_core_lt_1_26_0 = pytest.mark.skipif(
- packaging.version.parse(_API_CORE_VERSION) >= packaging.version.parse("1.26.0"),
- reason="This test requires google-api-core < 1.26.0",
-)
-
-requires_api_core_gte_1_26_0 = pytest.mark.skipif(
- packaging.version.parse(_API_CORE_VERSION) < packaging.version.parse("1.26.0"),
- reason="This test requires google-api-core >= 1.26.0",
-)
-
def client_cert_source_callback():
return b"cert bytes", b"key bytes"
@@ -134,6 +122,34 @@ def test_flows_client_from_service_account_info(client_class):
assert client.transport._host == "dialogflow.googleapis.com:443"
+@pytest.mark.parametrize("client_class", [FlowsClient, FlowsAsyncClient,])
+def test_flows_client_service_account_always_use_jwt(client_class):
+ with mock.patch.object(
+ service_account.Credentials, "with_always_use_jwt_access", create=True
+ ) as use_jwt:
+ creds = service_account.Credentials(None, None, None)
+ client = client_class(credentials=creds)
+ use_jwt.assert_not_called()
+
+
+@pytest.mark.parametrize(
+ "transport_class,transport_name",
+ [
+ (transports.FlowsGrpcTransport, "grpc"),
+ (transports.FlowsGrpcAsyncIOTransport, "grpc_asyncio"),
+ ],
+)
+def test_flows_client_service_account_always_use_jwt_true(
+ transport_class, transport_name
+):
+ with mock.patch.object(
+ service_account.Credentials, "with_always_use_jwt_access", create=True
+ ) as use_jwt:
+ creds = service_account.Credentials(None, None, None)
+ transport = transport_class(credentials=creds, always_use_jwt_access=True)
+ use_jwt.assert_called_once_with(True)
+
+
@pytest.mark.parametrize("client_class", [FlowsClient, FlowsAsyncClient,])
def test_flows_client_from_service_account_file(client_class):
creds = ga_credentials.AnonymousCredentials()
@@ -2613,7 +2629,6 @@ def test_flows_transport_auth_adc_old_google_auth(transport_class):
(transports.FlowsGrpcAsyncIOTransport, grpc_helpers_async),
],
)
-@requires_api_core_gte_1_26_0
def test_flows_transport_create_channel(transport_class, grpc_helpers):
# If credentials and host are not provided, the transport class should use
# ADC credentials.
@@ -2645,78 +2660,6 @@ def test_flows_transport_create_channel(transport_class, grpc_helpers):
)
-@pytest.mark.parametrize(
- "transport_class,grpc_helpers",
- [
- (transports.FlowsGrpcTransport, grpc_helpers),
- (transports.FlowsGrpcAsyncIOTransport, grpc_helpers_async),
- ],
-)
-@requires_api_core_lt_1_26_0
-def test_flows_transport_create_channel_old_api_core(transport_class, grpc_helpers):
- # If credentials and host are not provided, the transport class should use
- # ADC credentials.
- with mock.patch.object(
- google.auth, "default", autospec=True
- ) as adc, mock.patch.object(
- grpc_helpers, "create_channel", autospec=True
- ) as create_channel:
- creds = ga_credentials.AnonymousCredentials()
- adc.return_value = (creds, None)
- transport_class(quota_project_id="octopus")
-
- create_channel.assert_called_with(
- "dialogflow.googleapis.com:443",
- credentials=creds,
- credentials_file=None,
- quota_project_id="octopus",
- scopes=(
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/dialogflow",
- ),
- ssl_credentials=None,
- options=[
- ("grpc.max_send_message_length", -1),
- ("grpc.max_receive_message_length", -1),
- ],
- )
-
-
-@pytest.mark.parametrize(
- "transport_class,grpc_helpers",
- [
- (transports.FlowsGrpcTransport, grpc_helpers),
- (transports.FlowsGrpcAsyncIOTransport, grpc_helpers_async),
- ],
-)
-@requires_api_core_lt_1_26_0
-def test_flows_transport_create_channel_user_scopes(transport_class, grpc_helpers):
- # If credentials and host are not provided, the transport class should use
- # ADC credentials.
- with mock.patch.object(
- google.auth, "default", autospec=True
- ) as adc, mock.patch.object(
- grpc_helpers, "create_channel", autospec=True
- ) as create_channel:
- creds = ga_credentials.AnonymousCredentials()
- adc.return_value = (creds, None)
-
- transport_class(quota_project_id="octopus", scopes=["1", "2"])
-
- create_channel.assert_called_with(
- "dialogflow.googleapis.com:443",
- credentials=creds,
- credentials_file=None,
- quota_project_id="octopus",
- scopes=["1", "2"],
- ssl_credentials=None,
- options=[
- ("grpc.max_send_message_length", -1),
- ("grpc.max_receive_message_length", -1),
- ],
- )
-
-
@pytest.mark.parametrize(
"transport_class",
[transports.FlowsGrpcTransport, transports.FlowsGrpcAsyncIOTransport],
@@ -2736,10 +2679,7 @@ def test_flows_grpc_transport_client_cert_source_for_mtls(transport_class):
"squid.clam.whelk:443",
credentials=cred,
credentials_file=None,
- scopes=(
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/dialogflow",
- ),
+ scopes=None,
ssl_credentials=mock_ssl_channel_creds,
quota_project_id=None,
options=[
@@ -2841,10 +2781,7 @@ def test_flows_transport_channel_mtls_with_client_cert_source(transport_class):
"mtls.squid.clam.whelk:443",
credentials=cred,
credentials_file=None,
- scopes=(
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/dialogflow",
- ),
+ scopes=None,
ssl_credentials=mock_ssl_cred,
quota_project_id=None,
options=[
@@ -2888,10 +2825,7 @@ def test_flows_transport_channel_mtls_with_adc(transport_class):
"mtls.squid.clam.whelk:443",
credentials=mock_cred,
credentials_file=None,
- scopes=(
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/dialogflow",
- ),
+ scopes=None,
ssl_credentials=mock_ssl_cred,
quota_project_id=None,
options=[
diff --git a/tests/unit/gapic/dialogflowcx_v3beta1/test_intents.py b/tests/unit/gapic/dialogflowcx_v3beta1/test_intents.py
index 8e507537..842f7e2d 100644
--- a/tests/unit/gapic/dialogflowcx_v3beta1/test_intents.py
+++ b/tests/unit/gapic/dialogflowcx_v3beta1/test_intents.py
@@ -35,9 +35,6 @@
from google.cloud.dialogflowcx_v3beta1.services.intents import IntentsClient
from google.cloud.dialogflowcx_v3beta1.services.intents import pagers
from google.cloud.dialogflowcx_v3beta1.services.intents import transports
-from google.cloud.dialogflowcx_v3beta1.services.intents.transports.base import (
- _API_CORE_VERSION,
-)
from google.cloud.dialogflowcx_v3beta1.services.intents.transports.base import (
_GOOGLE_AUTH_VERSION,
)
@@ -48,8 +45,9 @@
import google.auth
-# TODO(busunkim): Once google-api-core >= 1.26.0 is required:
-# - Delete all the api-core and auth "less than" test cases
+# TODO(busunkim): Once google-auth >= 1.25.0 is required transitively
+# through google-api-core:
+# - Delete the auth "less than" test cases
# - Delete these pytest markers (Make the "greater than or equal to" tests the default).
requires_google_auth_lt_1_25_0 = pytest.mark.skipif(
packaging.version.parse(_GOOGLE_AUTH_VERSION) >= packaging.version.parse("1.25.0"),
@@ -60,16 +58,6 @@
reason="This test requires google-auth >= 1.25.0",
)
-requires_api_core_lt_1_26_0 = pytest.mark.skipif(
- packaging.version.parse(_API_CORE_VERSION) >= packaging.version.parse("1.26.0"),
- reason="This test requires google-api-core < 1.26.0",
-)
-
-requires_api_core_gte_1_26_0 = pytest.mark.skipif(
- packaging.version.parse(_API_CORE_VERSION) < packaging.version.parse("1.26.0"),
- reason="This test requires google-api-core >= 1.26.0",
-)
-
def client_cert_source_callback():
return b"cert bytes", b"key bytes"
@@ -124,6 +112,34 @@ def test_intents_client_from_service_account_info(client_class):
assert client.transport._host == "dialogflow.googleapis.com:443"
+@pytest.mark.parametrize("client_class", [IntentsClient, IntentsAsyncClient,])
+def test_intents_client_service_account_always_use_jwt(client_class):
+ with mock.patch.object(
+ service_account.Credentials, "with_always_use_jwt_access", create=True
+ ) as use_jwt:
+ creds = service_account.Credentials(None, None, None)
+ client = client_class(credentials=creds)
+ use_jwt.assert_not_called()
+
+
+@pytest.mark.parametrize(
+ "transport_class,transport_name",
+ [
+ (transports.IntentsGrpcTransport, "grpc"),
+ (transports.IntentsGrpcAsyncIOTransport, "grpc_asyncio"),
+ ],
+)
+def test_intents_client_service_account_always_use_jwt_true(
+ transport_class, transport_name
+):
+ with mock.patch.object(
+ service_account.Credentials, "with_always_use_jwt_access", create=True
+ ) as use_jwt:
+ creds = service_account.Credentials(None, None, None)
+ transport = transport_class(credentials=creds, always_use_jwt_access=True)
+ use_jwt.assert_called_once_with(True)
+
+
@pytest.mark.parametrize("client_class", [IntentsClient, IntentsAsyncClient,])
def test_intents_client_from_service_account_file(client_class):
creds = ga_credentials.AnonymousCredentials()
@@ -1835,7 +1851,6 @@ def test_intents_transport_auth_adc_old_google_auth(transport_class):
(transports.IntentsGrpcAsyncIOTransport, grpc_helpers_async),
],
)
-@requires_api_core_gte_1_26_0
def test_intents_transport_create_channel(transport_class, grpc_helpers):
# If credentials and host are not provided, the transport class should use
# ADC credentials.
@@ -1867,78 +1882,6 @@ def test_intents_transport_create_channel(transport_class, grpc_helpers):
)
-@pytest.mark.parametrize(
- "transport_class,grpc_helpers",
- [
- (transports.IntentsGrpcTransport, grpc_helpers),
- (transports.IntentsGrpcAsyncIOTransport, grpc_helpers_async),
- ],
-)
-@requires_api_core_lt_1_26_0
-def test_intents_transport_create_channel_old_api_core(transport_class, grpc_helpers):
- # If credentials and host are not provided, the transport class should use
- # ADC credentials.
- with mock.patch.object(
- google.auth, "default", autospec=True
- ) as adc, mock.patch.object(
- grpc_helpers, "create_channel", autospec=True
- ) as create_channel:
- creds = ga_credentials.AnonymousCredentials()
- adc.return_value = (creds, None)
- transport_class(quota_project_id="octopus")
-
- create_channel.assert_called_with(
- "dialogflow.googleapis.com:443",
- credentials=creds,
- credentials_file=None,
- quota_project_id="octopus",
- scopes=(
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/dialogflow",
- ),
- ssl_credentials=None,
- options=[
- ("grpc.max_send_message_length", -1),
- ("grpc.max_receive_message_length", -1),
- ],
- )
-
-
-@pytest.mark.parametrize(
- "transport_class,grpc_helpers",
- [
- (transports.IntentsGrpcTransport, grpc_helpers),
- (transports.IntentsGrpcAsyncIOTransport, grpc_helpers_async),
- ],
-)
-@requires_api_core_lt_1_26_0
-def test_intents_transport_create_channel_user_scopes(transport_class, grpc_helpers):
- # If credentials and host are not provided, the transport class should use
- # ADC credentials.
- with mock.patch.object(
- google.auth, "default", autospec=True
- ) as adc, mock.patch.object(
- grpc_helpers, "create_channel", autospec=True
- ) as create_channel:
- creds = ga_credentials.AnonymousCredentials()
- adc.return_value = (creds, None)
-
- transport_class(quota_project_id="octopus", scopes=["1", "2"])
-
- create_channel.assert_called_with(
- "dialogflow.googleapis.com:443",
- credentials=creds,
- credentials_file=None,
- quota_project_id="octopus",
- scopes=["1", "2"],
- ssl_credentials=None,
- options=[
- ("grpc.max_send_message_length", -1),
- ("grpc.max_receive_message_length", -1),
- ],
- )
-
-
@pytest.mark.parametrize(
"transport_class",
[transports.IntentsGrpcTransport, transports.IntentsGrpcAsyncIOTransport],
@@ -1958,10 +1901,7 @@ def test_intents_grpc_transport_client_cert_source_for_mtls(transport_class):
"squid.clam.whelk:443",
credentials=cred,
credentials_file=None,
- scopes=(
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/dialogflow",
- ),
+ scopes=None,
ssl_credentials=mock_ssl_channel_creds,
quota_project_id=None,
options=[
@@ -2065,10 +2005,7 @@ def test_intents_transport_channel_mtls_with_client_cert_source(transport_class)
"mtls.squid.clam.whelk:443",
credentials=cred,
credentials_file=None,
- scopes=(
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/dialogflow",
- ),
+ scopes=None,
ssl_credentials=mock_ssl_cred,
quota_project_id=None,
options=[
@@ -2112,10 +2049,7 @@ def test_intents_transport_channel_mtls_with_adc(transport_class):
"mtls.squid.clam.whelk:443",
credentials=mock_cred,
credentials_file=None,
- scopes=(
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/dialogflow",
- ),
+ scopes=None,
ssl_credentials=mock_ssl_cred,
quota_project_id=None,
options=[
diff --git a/tests/unit/gapic/dialogflowcx_v3beta1/test_pages.py b/tests/unit/gapic/dialogflowcx_v3beta1/test_pages.py
index fcd7abd7..defdd8fc 100644
--- a/tests/unit/gapic/dialogflowcx_v3beta1/test_pages.py
+++ b/tests/unit/gapic/dialogflowcx_v3beta1/test_pages.py
@@ -35,9 +35,6 @@
from google.cloud.dialogflowcx_v3beta1.services.pages import PagesClient
from google.cloud.dialogflowcx_v3beta1.services.pages import pagers
from google.cloud.dialogflowcx_v3beta1.services.pages import transports
-from google.cloud.dialogflowcx_v3beta1.services.pages.transports.base import (
- _API_CORE_VERSION,
-)
from google.cloud.dialogflowcx_v3beta1.services.pages.transports.base import (
_GOOGLE_AUTH_VERSION,
)
@@ -51,8 +48,9 @@
import google.auth
-# TODO(busunkim): Once google-api-core >= 1.26.0 is required:
-# - Delete all the api-core and auth "less than" test cases
+# TODO(busunkim): Once google-auth >= 1.25.0 is required transitively
+# through google-api-core:
+# - Delete the auth "less than" test cases
# - Delete these pytest markers (Make the "greater than or equal to" tests the default).
requires_google_auth_lt_1_25_0 = pytest.mark.skipif(
packaging.version.parse(_GOOGLE_AUTH_VERSION) >= packaging.version.parse("1.25.0"),
@@ -63,16 +61,6 @@
reason="This test requires google-auth >= 1.25.0",
)
-requires_api_core_lt_1_26_0 = pytest.mark.skipif(
- packaging.version.parse(_API_CORE_VERSION) >= packaging.version.parse("1.26.0"),
- reason="This test requires google-api-core < 1.26.0",
-)
-
-requires_api_core_gte_1_26_0 = pytest.mark.skipif(
- packaging.version.parse(_API_CORE_VERSION) < packaging.version.parse("1.26.0"),
- reason="This test requires google-api-core >= 1.26.0",
-)
-
def client_cert_source_callback():
return b"cert bytes", b"key bytes"
@@ -127,6 +115,34 @@ def test_pages_client_from_service_account_info(client_class):
assert client.transport._host == "dialogflow.googleapis.com:443"
+@pytest.mark.parametrize("client_class", [PagesClient, PagesAsyncClient,])
+def test_pages_client_service_account_always_use_jwt(client_class):
+ with mock.patch.object(
+ service_account.Credentials, "with_always_use_jwt_access", create=True
+ ) as use_jwt:
+ creds = service_account.Credentials(None, None, None)
+ client = client_class(credentials=creds)
+ use_jwt.assert_not_called()
+
+
+@pytest.mark.parametrize(
+ "transport_class,transport_name",
+ [
+ (transports.PagesGrpcTransport, "grpc"),
+ (transports.PagesGrpcAsyncIOTransport, "grpc_asyncio"),
+ ],
+)
+def test_pages_client_service_account_always_use_jwt_true(
+ transport_class, transport_name
+):
+ with mock.patch.object(
+ service_account.Credentials, "with_always_use_jwt_access", create=True
+ ) as use_jwt:
+ creds = service_account.Credentials(None, None, None)
+ transport = transport_class(credentials=creds, always_use_jwt_access=True)
+ use_jwt.assert_called_once_with(True)
+
+
@pytest.mark.parametrize("client_class", [PagesClient, PagesAsyncClient,])
def test_pages_client_from_service_account_file(client_class):
creds = ga_credentials.AnonymousCredentials()
@@ -1796,7 +1812,6 @@ def test_pages_transport_auth_adc_old_google_auth(transport_class):
(transports.PagesGrpcAsyncIOTransport, grpc_helpers_async),
],
)
-@requires_api_core_gte_1_26_0
def test_pages_transport_create_channel(transport_class, grpc_helpers):
# If credentials and host are not provided, the transport class should use
# ADC credentials.
@@ -1828,78 +1843,6 @@ def test_pages_transport_create_channel(transport_class, grpc_helpers):
)
-@pytest.mark.parametrize(
- "transport_class,grpc_helpers",
- [
- (transports.PagesGrpcTransport, grpc_helpers),
- (transports.PagesGrpcAsyncIOTransport, grpc_helpers_async),
- ],
-)
-@requires_api_core_lt_1_26_0
-def test_pages_transport_create_channel_old_api_core(transport_class, grpc_helpers):
- # If credentials and host are not provided, the transport class should use
- # ADC credentials.
- with mock.patch.object(
- google.auth, "default", autospec=True
- ) as adc, mock.patch.object(
- grpc_helpers, "create_channel", autospec=True
- ) as create_channel:
- creds = ga_credentials.AnonymousCredentials()
- adc.return_value = (creds, None)
- transport_class(quota_project_id="octopus")
-
- create_channel.assert_called_with(
- "dialogflow.googleapis.com:443",
- credentials=creds,
- credentials_file=None,
- quota_project_id="octopus",
- scopes=(
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/dialogflow",
- ),
- ssl_credentials=None,
- options=[
- ("grpc.max_send_message_length", -1),
- ("grpc.max_receive_message_length", -1),
- ],
- )
-
-
-@pytest.mark.parametrize(
- "transport_class,grpc_helpers",
- [
- (transports.PagesGrpcTransport, grpc_helpers),
- (transports.PagesGrpcAsyncIOTransport, grpc_helpers_async),
- ],
-)
-@requires_api_core_lt_1_26_0
-def test_pages_transport_create_channel_user_scopes(transport_class, grpc_helpers):
- # If credentials and host are not provided, the transport class should use
- # ADC credentials.
- with mock.patch.object(
- google.auth, "default", autospec=True
- ) as adc, mock.patch.object(
- grpc_helpers, "create_channel", autospec=True
- ) as create_channel:
- creds = ga_credentials.AnonymousCredentials()
- adc.return_value = (creds, None)
-
- transport_class(quota_project_id="octopus", scopes=["1", "2"])
-
- create_channel.assert_called_with(
- "dialogflow.googleapis.com:443",
- credentials=creds,
- credentials_file=None,
- quota_project_id="octopus",
- scopes=["1", "2"],
- ssl_credentials=None,
- options=[
- ("grpc.max_send_message_length", -1),
- ("grpc.max_receive_message_length", -1),
- ],
- )
-
-
@pytest.mark.parametrize(
"transport_class",
[transports.PagesGrpcTransport, transports.PagesGrpcAsyncIOTransport],
@@ -1919,10 +1862,7 @@ def test_pages_grpc_transport_client_cert_source_for_mtls(transport_class):
"squid.clam.whelk:443",
credentials=cred,
credentials_file=None,
- scopes=(
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/dialogflow",
- ),
+ scopes=None,
ssl_credentials=mock_ssl_channel_creds,
quota_project_id=None,
options=[
@@ -2024,10 +1964,7 @@ def test_pages_transport_channel_mtls_with_client_cert_source(transport_class):
"mtls.squid.clam.whelk:443",
credentials=cred,
credentials_file=None,
- scopes=(
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/dialogflow",
- ),
+ scopes=None,
ssl_credentials=mock_ssl_cred,
quota_project_id=None,
options=[
@@ -2071,10 +2008,7 @@ def test_pages_transport_channel_mtls_with_adc(transport_class):
"mtls.squid.clam.whelk:443",
credentials=mock_cred,
credentials_file=None,
- scopes=(
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/dialogflow",
- ),
+ scopes=None,
ssl_credentials=mock_ssl_cred,
quota_project_id=None,
options=[
diff --git a/tests/unit/gapic/dialogflowcx_v3beta1/test_security_settings_service.py b/tests/unit/gapic/dialogflowcx_v3beta1/test_security_settings_service.py
index fbcefa33..55ab77bd 100644
--- a/tests/unit/gapic/dialogflowcx_v3beta1/test_security_settings_service.py
+++ b/tests/unit/gapic/dialogflowcx_v3beta1/test_security_settings_service.py
@@ -41,9 +41,6 @@
from google.cloud.dialogflowcx_v3beta1.services.security_settings_service import (
transports,
)
-from google.cloud.dialogflowcx_v3beta1.services.security_settings_service.transports.base import (
- _API_CORE_VERSION,
-)
from google.cloud.dialogflowcx_v3beta1.services.security_settings_service.transports.base import (
_GOOGLE_AUTH_VERSION,
)
@@ -56,8 +53,9 @@
import google.auth
-# TODO(busunkim): Once google-api-core >= 1.26.0 is required:
-# - Delete all the api-core and auth "less than" test cases
+# TODO(busunkim): Once google-auth >= 1.25.0 is required transitively
+# through google-api-core:
+# - Delete the auth "less than" test cases
# - Delete these pytest markers (Make the "greater than or equal to" tests the default).
requires_google_auth_lt_1_25_0 = pytest.mark.skipif(
packaging.version.parse(_GOOGLE_AUTH_VERSION) >= packaging.version.parse("1.25.0"),
@@ -68,16 +66,6 @@
reason="This test requires google-auth >= 1.25.0",
)
-requires_api_core_lt_1_26_0 = pytest.mark.skipif(
- packaging.version.parse(_API_CORE_VERSION) >= packaging.version.parse("1.26.0"),
- reason="This test requires google-api-core < 1.26.0",
-)
-
-requires_api_core_gte_1_26_0 = pytest.mark.skipif(
- packaging.version.parse(_API_CORE_VERSION) < packaging.version.parse("1.26.0"),
- reason="This test requires google-api-core >= 1.26.0",
-)
-
def client_cert_source_callback():
return b"cert bytes", b"key bytes"
@@ -141,6 +129,36 @@ def test_security_settings_service_client_from_service_account_info(client_class
assert client.transport._host == "dialogflow.googleapis.com:443"
+@pytest.mark.parametrize(
+ "client_class", [SecuritySettingsServiceClient, SecuritySettingsServiceAsyncClient,]
+)
+def test_security_settings_service_client_service_account_always_use_jwt(client_class):
+ with mock.patch.object(
+ service_account.Credentials, "with_always_use_jwt_access", create=True
+ ) as use_jwt:
+ creds = service_account.Credentials(None, None, None)
+ client = client_class(credentials=creds)
+ use_jwt.assert_not_called()
+
+
+@pytest.mark.parametrize(
+ "transport_class,transport_name",
+ [
+ (transports.SecuritySettingsServiceGrpcTransport, "grpc"),
+ (transports.SecuritySettingsServiceGrpcAsyncIOTransport, "grpc_asyncio"),
+ ],
+)
+def test_security_settings_service_client_service_account_always_use_jwt_true(
+ transport_class, transport_name
+):
+ with mock.patch.object(
+ service_account.Credentials, "with_always_use_jwt_access", create=True
+ ) as use_jwt:
+ creds = service_account.Credentials(None, None, None)
+ transport = transport_class(credentials=creds, always_use_jwt_access=True)
+ use_jwt.assert_called_once_with(True)
+
+
@pytest.mark.parametrize(
"client_class", [SecuritySettingsServiceClient, SecuritySettingsServiceAsyncClient,]
)
@@ -2240,7 +2258,6 @@ def test_security_settings_service_transport_auth_adc_old_google_auth(transport_
(transports.SecuritySettingsServiceGrpcAsyncIOTransport, grpc_helpers_async),
],
)
-@requires_api_core_gte_1_26_0
def test_security_settings_service_transport_create_channel(
transport_class, grpc_helpers
):
@@ -2274,82 +2291,6 @@ def test_security_settings_service_transport_create_channel(
)
-@pytest.mark.parametrize(
- "transport_class,grpc_helpers",
- [
- (transports.SecuritySettingsServiceGrpcTransport, grpc_helpers),
- (transports.SecuritySettingsServiceGrpcAsyncIOTransport, grpc_helpers_async),
- ],
-)
-@requires_api_core_lt_1_26_0
-def test_security_settings_service_transport_create_channel_old_api_core(
- transport_class, grpc_helpers
-):
- # If credentials and host are not provided, the transport class should use
- # ADC credentials.
- with mock.patch.object(
- google.auth, "default", autospec=True
- ) as adc, mock.patch.object(
- grpc_helpers, "create_channel", autospec=True
- ) as create_channel:
- creds = ga_credentials.AnonymousCredentials()
- adc.return_value = (creds, None)
- transport_class(quota_project_id="octopus")
-
- create_channel.assert_called_with(
- "dialogflow.googleapis.com:443",
- credentials=creds,
- credentials_file=None,
- quota_project_id="octopus",
- scopes=(
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/dialogflow",
- ),
- ssl_credentials=None,
- options=[
- ("grpc.max_send_message_length", -1),
- ("grpc.max_receive_message_length", -1),
- ],
- )
-
-
-@pytest.mark.parametrize(
- "transport_class,grpc_helpers",
- [
- (transports.SecuritySettingsServiceGrpcTransport, grpc_helpers),
- (transports.SecuritySettingsServiceGrpcAsyncIOTransport, grpc_helpers_async),
- ],
-)
-@requires_api_core_lt_1_26_0
-def test_security_settings_service_transport_create_channel_user_scopes(
- transport_class, grpc_helpers
-):
- # If credentials and host are not provided, the transport class should use
- # ADC credentials.
- with mock.patch.object(
- google.auth, "default", autospec=True
- ) as adc, mock.patch.object(
- grpc_helpers, "create_channel", autospec=True
- ) as create_channel:
- creds = ga_credentials.AnonymousCredentials()
- adc.return_value = (creds, None)
-
- transport_class(quota_project_id="octopus", scopes=["1", "2"])
-
- create_channel.assert_called_with(
- "dialogflow.googleapis.com:443",
- credentials=creds,
- credentials_file=None,
- quota_project_id="octopus",
- scopes=["1", "2"],
- ssl_credentials=None,
- options=[
- ("grpc.max_send_message_length", -1),
- ("grpc.max_receive_message_length", -1),
- ],
- )
-
-
@pytest.mark.parametrize(
"transport_class",
[
@@ -2374,10 +2315,7 @@ def test_security_settings_service_grpc_transport_client_cert_source_for_mtls(
"squid.clam.whelk:443",
credentials=cred,
credentials_file=None,
- scopes=(
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/dialogflow",
- ),
+ scopes=None,
ssl_credentials=mock_ssl_channel_creds,
quota_project_id=None,
options=[
@@ -2486,10 +2424,7 @@ def test_security_settings_service_transport_channel_mtls_with_client_cert_sourc
"mtls.squid.clam.whelk:443",
credentials=cred,
credentials_file=None,
- scopes=(
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/dialogflow",
- ),
+ scopes=None,
ssl_credentials=mock_ssl_cred,
quota_project_id=None,
options=[
@@ -2536,10 +2471,7 @@ def test_security_settings_service_transport_channel_mtls_with_adc(transport_cla
"mtls.squid.clam.whelk:443",
credentials=mock_cred,
credentials_file=None,
- scopes=(
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/dialogflow",
- ),
+ scopes=None,
ssl_credentials=mock_ssl_cred,
quota_project_id=None,
options=[
diff --git a/tests/unit/gapic/dialogflowcx_v3beta1/test_session_entity_types.py b/tests/unit/gapic/dialogflowcx_v3beta1/test_session_entity_types.py
index 79f85a0c..5e03e082 100644
--- a/tests/unit/gapic/dialogflowcx_v3beta1/test_session_entity_types.py
+++ b/tests/unit/gapic/dialogflowcx_v3beta1/test_session_entity_types.py
@@ -39,9 +39,6 @@
)
from google.cloud.dialogflowcx_v3beta1.services.session_entity_types import pagers
from google.cloud.dialogflowcx_v3beta1.services.session_entity_types import transports
-from google.cloud.dialogflowcx_v3beta1.services.session_entity_types.transports.base import (
- _API_CORE_VERSION,
-)
from google.cloud.dialogflowcx_v3beta1.services.session_entity_types.transports.base import (
_GOOGLE_AUTH_VERSION,
)
@@ -55,8 +52,9 @@
import google.auth
-# TODO(busunkim): Once google-api-core >= 1.26.0 is required:
-# - Delete all the api-core and auth "less than" test cases
+# TODO(busunkim): Once google-auth >= 1.25.0 is required transitively
+# through google-api-core:
+# - Delete the auth "less than" test cases
# - Delete these pytest markers (Make the "greater than or equal to" tests the default).
requires_google_auth_lt_1_25_0 = pytest.mark.skipif(
packaging.version.parse(_GOOGLE_AUTH_VERSION) >= packaging.version.parse("1.25.0"),
@@ -67,16 +65,6 @@
reason="This test requires google-auth >= 1.25.0",
)
-requires_api_core_lt_1_26_0 = pytest.mark.skipif(
- packaging.version.parse(_API_CORE_VERSION) >= packaging.version.parse("1.26.0"),
- reason="This test requires google-api-core < 1.26.0",
-)
-
-requires_api_core_gte_1_26_0 = pytest.mark.skipif(
- packaging.version.parse(_API_CORE_VERSION) < packaging.version.parse("1.26.0"),
- reason="This test requires google-api-core >= 1.26.0",
-)
-
def client_cert_source_callback():
return b"cert bytes", b"key bytes"
@@ -140,6 +128,36 @@ def test_session_entity_types_client_from_service_account_info(client_class):
assert client.transport._host == "dialogflow.googleapis.com:443"
+@pytest.mark.parametrize(
+ "client_class", [SessionEntityTypesClient, SessionEntityTypesAsyncClient,]
+)
+def test_session_entity_types_client_service_account_always_use_jwt(client_class):
+ with mock.patch.object(
+ service_account.Credentials, "with_always_use_jwt_access", create=True
+ ) as use_jwt:
+ creds = service_account.Credentials(None, None, None)
+ client = client_class(credentials=creds)
+ use_jwt.assert_not_called()
+
+
+@pytest.mark.parametrize(
+ "transport_class,transport_name",
+ [
+ (transports.SessionEntityTypesGrpcTransport, "grpc"),
+ (transports.SessionEntityTypesGrpcAsyncIOTransport, "grpc_asyncio"),
+ ],
+)
+def test_session_entity_types_client_service_account_always_use_jwt_true(
+ transport_class, transport_name
+):
+ with mock.patch.object(
+ service_account.Credentials, "with_always_use_jwt_access", create=True
+ ) as use_jwt:
+ creds = service_account.Credentials(None, None, None)
+ transport = transport_class(credentials=creds, always_use_jwt_access=True)
+ use_jwt.assert_called_once_with(True)
+
+
@pytest.mark.parametrize(
"client_class", [SessionEntityTypesClient, SessionEntityTypesAsyncClient,]
)
@@ -2142,7 +2160,6 @@ def test_session_entity_types_transport_auth_adc_old_google_auth(transport_class
(transports.SessionEntityTypesGrpcAsyncIOTransport, grpc_helpers_async),
],
)
-@requires_api_core_gte_1_26_0
def test_session_entity_types_transport_create_channel(transport_class, grpc_helpers):
# If credentials and host are not provided, the transport class should use
# ADC credentials.
@@ -2174,82 +2191,6 @@ def test_session_entity_types_transport_create_channel(transport_class, grpc_hel
)
-@pytest.mark.parametrize(
- "transport_class,grpc_helpers",
- [
- (transports.SessionEntityTypesGrpcTransport, grpc_helpers),
- (transports.SessionEntityTypesGrpcAsyncIOTransport, grpc_helpers_async),
- ],
-)
-@requires_api_core_lt_1_26_0
-def test_session_entity_types_transport_create_channel_old_api_core(
- transport_class, grpc_helpers
-):
- # If credentials and host are not provided, the transport class should use
- # ADC credentials.
- with mock.patch.object(
- google.auth, "default", autospec=True
- ) as adc, mock.patch.object(
- grpc_helpers, "create_channel", autospec=True
- ) as create_channel:
- creds = ga_credentials.AnonymousCredentials()
- adc.return_value = (creds, None)
- transport_class(quota_project_id="octopus")
-
- create_channel.assert_called_with(
- "dialogflow.googleapis.com:443",
- credentials=creds,
- credentials_file=None,
- quota_project_id="octopus",
- scopes=(
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/dialogflow",
- ),
- ssl_credentials=None,
- options=[
- ("grpc.max_send_message_length", -1),
- ("grpc.max_receive_message_length", -1),
- ],
- )
-
-
-@pytest.mark.parametrize(
- "transport_class,grpc_helpers",
- [
- (transports.SessionEntityTypesGrpcTransport, grpc_helpers),
- (transports.SessionEntityTypesGrpcAsyncIOTransport, grpc_helpers_async),
- ],
-)
-@requires_api_core_lt_1_26_0
-def test_session_entity_types_transport_create_channel_user_scopes(
- transport_class, grpc_helpers
-):
- # If credentials and host are not provided, the transport class should use
- # ADC credentials.
- with mock.patch.object(
- google.auth, "default", autospec=True
- ) as adc, mock.patch.object(
- grpc_helpers, "create_channel", autospec=True
- ) as create_channel:
- creds = ga_credentials.AnonymousCredentials()
- adc.return_value = (creds, None)
-
- transport_class(quota_project_id="octopus", scopes=["1", "2"])
-
- create_channel.assert_called_with(
- "dialogflow.googleapis.com:443",
- credentials=creds,
- credentials_file=None,
- quota_project_id="octopus",
- scopes=["1", "2"],
- ssl_credentials=None,
- options=[
- ("grpc.max_send_message_length", -1),
- ("grpc.max_receive_message_length", -1),
- ],
- )
-
-
@pytest.mark.parametrize(
"transport_class",
[
@@ -2274,10 +2215,7 @@ def test_session_entity_types_grpc_transport_client_cert_source_for_mtls(
"squid.clam.whelk:443",
credentials=cred,
credentials_file=None,
- scopes=(
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/dialogflow",
- ),
+ scopes=None,
ssl_credentials=mock_ssl_channel_creds,
quota_project_id=None,
options=[
@@ -2386,10 +2324,7 @@ def test_session_entity_types_transport_channel_mtls_with_client_cert_source(
"mtls.squid.clam.whelk:443",
credentials=cred,
credentials_file=None,
- scopes=(
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/dialogflow",
- ),
+ scopes=None,
ssl_credentials=mock_ssl_cred,
quota_project_id=None,
options=[
@@ -2436,10 +2371,7 @@ def test_session_entity_types_transport_channel_mtls_with_adc(transport_class):
"mtls.squid.clam.whelk:443",
credentials=mock_cred,
credentials_file=None,
- scopes=(
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/dialogflow",
- ),
+ scopes=None,
ssl_credentials=mock_ssl_cred,
quota_project_id=None,
options=[
diff --git a/tests/unit/gapic/dialogflowcx_v3beta1/test_sessions.py b/tests/unit/gapic/dialogflowcx_v3beta1/test_sessions.py
index e1f3a61f..3396aff3 100644
--- a/tests/unit/gapic/dialogflowcx_v3beta1/test_sessions.py
+++ b/tests/unit/gapic/dialogflowcx_v3beta1/test_sessions.py
@@ -34,9 +34,6 @@
from google.cloud.dialogflowcx_v3beta1.services.sessions import SessionsAsyncClient
from google.cloud.dialogflowcx_v3beta1.services.sessions import SessionsClient
from google.cloud.dialogflowcx_v3beta1.services.sessions import transports
-from google.cloud.dialogflowcx_v3beta1.services.sessions.transports.base import (
- _API_CORE_VERSION,
-)
from google.cloud.dialogflowcx_v3beta1.services.sessions.transports.base import (
_GOOGLE_AUTH_VERSION,
)
@@ -52,8 +49,9 @@
import google.auth
-# TODO(busunkim): Once google-api-core >= 1.26.0 is required:
-# - Delete all the api-core and auth "less than" test cases
+# TODO(busunkim): Once google-auth >= 1.25.0 is required transitively
+# through google-api-core:
+# - Delete the auth "less than" test cases
# - Delete these pytest markers (Make the "greater than or equal to" tests the default).
requires_google_auth_lt_1_25_0 = pytest.mark.skipif(
packaging.version.parse(_GOOGLE_AUTH_VERSION) >= packaging.version.parse("1.25.0"),
@@ -64,16 +62,6 @@
reason="This test requires google-auth >= 1.25.0",
)
-requires_api_core_lt_1_26_0 = pytest.mark.skipif(
- packaging.version.parse(_API_CORE_VERSION) >= packaging.version.parse("1.26.0"),
- reason="This test requires google-api-core < 1.26.0",
-)
-
-requires_api_core_gte_1_26_0 = pytest.mark.skipif(
- packaging.version.parse(_API_CORE_VERSION) < packaging.version.parse("1.26.0"),
- reason="This test requires google-api-core >= 1.26.0",
-)
-
def client_cert_source_callback():
return b"cert bytes", b"key bytes"
@@ -129,6 +117,34 @@ def test_sessions_client_from_service_account_info(client_class):
assert client.transport._host == "dialogflow.googleapis.com:443"
+@pytest.mark.parametrize("client_class", [SessionsClient, SessionsAsyncClient,])
+def test_sessions_client_service_account_always_use_jwt(client_class):
+ with mock.patch.object(
+ service_account.Credentials, "with_always_use_jwt_access", create=True
+ ) as use_jwt:
+ creds = service_account.Credentials(None, None, None)
+ client = client_class(credentials=creds)
+ use_jwt.assert_not_called()
+
+
+@pytest.mark.parametrize(
+ "transport_class,transport_name",
+ [
+ (transports.SessionsGrpcTransport, "grpc"),
+ (transports.SessionsGrpcAsyncIOTransport, "grpc_asyncio"),
+ ],
+)
+def test_sessions_client_service_account_always_use_jwt_true(
+ transport_class, transport_name
+):
+ with mock.patch.object(
+ service_account.Credentials, "with_always_use_jwt_access", create=True
+ ) as use_jwt:
+ creds = service_account.Credentials(None, None, None)
+ transport = transport_class(credentials=creds, always_use_jwt_access=True)
+ use_jwt.assert_called_once_with(True)
+
+
@pytest.mark.parametrize("client_class", [SessionsClient, SessionsAsyncClient,])
def test_sessions_client_from_service_account_file(client_class):
creds = ga_credentials.AnonymousCredentials()
@@ -1182,7 +1198,6 @@ def test_sessions_transport_auth_adc_old_google_auth(transport_class):
(transports.SessionsGrpcAsyncIOTransport, grpc_helpers_async),
],
)
-@requires_api_core_gte_1_26_0
def test_sessions_transport_create_channel(transport_class, grpc_helpers):
# If credentials and host are not provided, the transport class should use
# ADC credentials.
@@ -1214,78 +1229,6 @@ def test_sessions_transport_create_channel(transport_class, grpc_helpers):
)
-@pytest.mark.parametrize(
- "transport_class,grpc_helpers",
- [
- (transports.SessionsGrpcTransport, grpc_helpers),
- (transports.SessionsGrpcAsyncIOTransport, grpc_helpers_async),
- ],
-)
-@requires_api_core_lt_1_26_0
-def test_sessions_transport_create_channel_old_api_core(transport_class, grpc_helpers):
- # If credentials and host are not provided, the transport class should use
- # ADC credentials.
- with mock.patch.object(
- google.auth, "default", autospec=True
- ) as adc, mock.patch.object(
- grpc_helpers, "create_channel", autospec=True
- ) as create_channel:
- creds = ga_credentials.AnonymousCredentials()
- adc.return_value = (creds, None)
- transport_class(quota_project_id="octopus")
-
- create_channel.assert_called_with(
- "dialogflow.googleapis.com:443",
- credentials=creds,
- credentials_file=None,
- quota_project_id="octopus",
- scopes=(
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/dialogflow",
- ),
- ssl_credentials=None,
- options=[
- ("grpc.max_send_message_length", -1),
- ("grpc.max_receive_message_length", -1),
- ],
- )
-
-
-@pytest.mark.parametrize(
- "transport_class,grpc_helpers",
- [
- (transports.SessionsGrpcTransport, grpc_helpers),
- (transports.SessionsGrpcAsyncIOTransport, grpc_helpers_async),
- ],
-)
-@requires_api_core_lt_1_26_0
-def test_sessions_transport_create_channel_user_scopes(transport_class, grpc_helpers):
- # If credentials and host are not provided, the transport class should use
- # ADC credentials.
- with mock.patch.object(
- google.auth, "default", autospec=True
- ) as adc, mock.patch.object(
- grpc_helpers, "create_channel", autospec=True
- ) as create_channel:
- creds = ga_credentials.AnonymousCredentials()
- adc.return_value = (creds, None)
-
- transport_class(quota_project_id="octopus", scopes=["1", "2"])
-
- create_channel.assert_called_with(
- "dialogflow.googleapis.com:443",
- credentials=creds,
- credentials_file=None,
- quota_project_id="octopus",
- scopes=["1", "2"],
- ssl_credentials=None,
- options=[
- ("grpc.max_send_message_length", -1),
- ("grpc.max_receive_message_length", -1),
- ],
- )
-
-
@pytest.mark.parametrize(
"transport_class",
[transports.SessionsGrpcTransport, transports.SessionsGrpcAsyncIOTransport],
@@ -1305,10 +1248,7 @@ def test_sessions_grpc_transport_client_cert_source_for_mtls(transport_class):
"squid.clam.whelk:443",
credentials=cred,
credentials_file=None,
- scopes=(
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/dialogflow",
- ),
+ scopes=None,
ssl_credentials=mock_ssl_channel_creds,
quota_project_id=None,
options=[
@@ -1412,10 +1352,7 @@ def test_sessions_transport_channel_mtls_with_client_cert_source(transport_class
"mtls.squid.clam.whelk:443",
credentials=cred,
credentials_file=None,
- scopes=(
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/dialogflow",
- ),
+ scopes=None,
ssl_credentials=mock_ssl_cred,
quota_project_id=None,
options=[
@@ -1459,10 +1396,7 @@ def test_sessions_transport_channel_mtls_with_adc(transport_class):
"mtls.squid.clam.whelk:443",
credentials=mock_cred,
credentials_file=None,
- scopes=(
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/dialogflow",
- ),
+ scopes=None,
ssl_credentials=mock_ssl_cred,
quota_project_id=None,
options=[
diff --git a/tests/unit/gapic/dialogflowcx_v3beta1/test_test_cases.py b/tests/unit/gapic/dialogflowcx_v3beta1/test_test_cases.py
index 67ea8c6b..11930066 100644
--- a/tests/unit/gapic/dialogflowcx_v3beta1/test_test_cases.py
+++ b/tests/unit/gapic/dialogflowcx_v3beta1/test_test_cases.py
@@ -38,9 +38,6 @@
from google.cloud.dialogflowcx_v3beta1.services.test_cases import TestCasesClient
from google.cloud.dialogflowcx_v3beta1.services.test_cases import pagers
from google.cloud.dialogflowcx_v3beta1.services.test_cases import transports
-from google.cloud.dialogflowcx_v3beta1.services.test_cases.transports.base import (
- _API_CORE_VERSION,
-)
from google.cloud.dialogflowcx_v3beta1.services.test_cases.transports.base import (
_GOOGLE_AUTH_VERSION,
)
@@ -62,8 +59,9 @@
import google.auth
-# TODO(busunkim): Once google-api-core >= 1.26.0 is required:
-# - Delete all the api-core and auth "less than" test cases
+# TODO(busunkim): Once google-auth >= 1.25.0 is required transitively
+# through google-api-core:
+# - Delete the auth "less than" test cases
# - Delete these pytest markers (Make the "greater than or equal to" tests the default).
requires_google_auth_lt_1_25_0 = pytest.mark.skipif(
packaging.version.parse(_GOOGLE_AUTH_VERSION) >= packaging.version.parse("1.25.0"),
@@ -74,16 +72,6 @@
reason="This test requires google-auth >= 1.25.0",
)
-requires_api_core_lt_1_26_0 = pytest.mark.skipif(
- packaging.version.parse(_API_CORE_VERSION) >= packaging.version.parse("1.26.0"),
- reason="This test requires google-api-core < 1.26.0",
-)
-
-requires_api_core_gte_1_26_0 = pytest.mark.skipif(
- packaging.version.parse(_API_CORE_VERSION) < packaging.version.parse("1.26.0"),
- reason="This test requires google-api-core >= 1.26.0",
-)
-
def client_cert_source_callback():
return b"cert bytes", b"key bytes"
@@ -139,6 +127,34 @@ def test_test_cases_client_from_service_account_info(client_class):
assert client.transport._host == "dialogflow.googleapis.com:443"
+@pytest.mark.parametrize("client_class", [TestCasesClient, TestCasesAsyncClient,])
+def test_test_cases_client_service_account_always_use_jwt(client_class):
+ with mock.patch.object(
+ service_account.Credentials, "with_always_use_jwt_access", create=True
+ ) as use_jwt:
+ creds = service_account.Credentials(None, None, None)
+ client = client_class(credentials=creds)
+ use_jwt.assert_not_called()
+
+
+@pytest.mark.parametrize(
+ "transport_class,transport_name",
+ [
+ (transports.TestCasesGrpcTransport, "grpc"),
+ (transports.TestCasesGrpcAsyncIOTransport, "grpc_asyncio"),
+ ],
+)
+def test_test_cases_client_service_account_always_use_jwt_true(
+ transport_class, transport_name
+):
+ with mock.patch.object(
+ service_account.Credentials, "with_always_use_jwt_access", create=True
+ ) as use_jwt:
+ creds = service_account.Credentials(None, None, None)
+ transport = transport_class(credentials=creds, always_use_jwt_access=True)
+ use_jwt.assert_called_once_with(True)
+
+
@pytest.mark.parametrize("client_class", [TestCasesClient, TestCasesAsyncClient,])
def test_test_cases_client_from_service_account_file(client_class):
creds = ga_credentials.AnonymousCredentials()
@@ -3221,7 +3237,6 @@ def test_test_cases_transport_auth_adc_old_google_auth(transport_class):
(transports.TestCasesGrpcAsyncIOTransport, grpc_helpers_async),
],
)
-@requires_api_core_gte_1_26_0
def test_test_cases_transport_create_channel(transport_class, grpc_helpers):
# If credentials and host are not provided, the transport class should use
# ADC credentials.
@@ -3253,80 +3268,6 @@ def test_test_cases_transport_create_channel(transport_class, grpc_helpers):
)
-@pytest.mark.parametrize(
- "transport_class,grpc_helpers",
- [
- (transports.TestCasesGrpcTransport, grpc_helpers),
- (transports.TestCasesGrpcAsyncIOTransport, grpc_helpers_async),
- ],
-)
-@requires_api_core_lt_1_26_0
-def test_test_cases_transport_create_channel_old_api_core(
- transport_class, grpc_helpers
-):
- # If credentials and host are not provided, the transport class should use
- # ADC credentials.
- with mock.patch.object(
- google.auth, "default", autospec=True
- ) as adc, mock.patch.object(
- grpc_helpers, "create_channel", autospec=True
- ) as create_channel:
- creds = ga_credentials.AnonymousCredentials()
- adc.return_value = (creds, None)
- transport_class(quota_project_id="octopus")
-
- create_channel.assert_called_with(
- "dialogflow.googleapis.com:443",
- credentials=creds,
- credentials_file=None,
- quota_project_id="octopus",
- scopes=(
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/dialogflow",
- ),
- ssl_credentials=None,
- options=[
- ("grpc.max_send_message_length", -1),
- ("grpc.max_receive_message_length", -1),
- ],
- )
-
-
-@pytest.mark.parametrize(
- "transport_class,grpc_helpers",
- [
- (transports.TestCasesGrpcTransport, grpc_helpers),
- (transports.TestCasesGrpcAsyncIOTransport, grpc_helpers_async),
- ],
-)
-@requires_api_core_lt_1_26_0
-def test_test_cases_transport_create_channel_user_scopes(transport_class, grpc_helpers):
- # If credentials and host are not provided, the transport class should use
- # ADC credentials.
- with mock.patch.object(
- google.auth, "default", autospec=True
- ) as adc, mock.patch.object(
- grpc_helpers, "create_channel", autospec=True
- ) as create_channel:
- creds = ga_credentials.AnonymousCredentials()
- adc.return_value = (creds, None)
-
- transport_class(quota_project_id="octopus", scopes=["1", "2"])
-
- create_channel.assert_called_with(
- "dialogflow.googleapis.com:443",
- credentials=creds,
- credentials_file=None,
- quota_project_id="octopus",
- scopes=["1", "2"],
- ssl_credentials=None,
- options=[
- ("grpc.max_send_message_length", -1),
- ("grpc.max_receive_message_length", -1),
- ],
- )
-
-
@pytest.mark.parametrize(
"transport_class",
[transports.TestCasesGrpcTransport, transports.TestCasesGrpcAsyncIOTransport],
@@ -3346,10 +3287,7 @@ def test_test_cases_grpc_transport_client_cert_source_for_mtls(transport_class):
"squid.clam.whelk:443",
credentials=cred,
credentials_file=None,
- scopes=(
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/dialogflow",
- ),
+ scopes=None,
ssl_credentials=mock_ssl_channel_creds,
quota_project_id=None,
options=[
@@ -3453,10 +3391,7 @@ def test_test_cases_transport_channel_mtls_with_client_cert_source(transport_cla
"mtls.squid.clam.whelk:443",
credentials=cred,
credentials_file=None,
- scopes=(
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/dialogflow",
- ),
+ scopes=None,
ssl_credentials=mock_ssl_cred,
quota_project_id=None,
options=[
@@ -3500,10 +3435,7 @@ def test_test_cases_transport_channel_mtls_with_adc(transport_class):
"mtls.squid.clam.whelk:443",
credentials=mock_cred,
credentials_file=None,
- scopes=(
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/dialogflow",
- ),
+ scopes=None,
ssl_credentials=mock_ssl_cred,
quota_project_id=None,
options=[
diff --git a/tests/unit/gapic/dialogflowcx_v3beta1/test_transition_route_groups.py b/tests/unit/gapic/dialogflowcx_v3beta1/test_transition_route_groups.py
index 718f6680..d6d286e9 100644
--- a/tests/unit/gapic/dialogflowcx_v3beta1/test_transition_route_groups.py
+++ b/tests/unit/gapic/dialogflowcx_v3beta1/test_transition_route_groups.py
@@ -41,9 +41,6 @@
from google.cloud.dialogflowcx_v3beta1.services.transition_route_groups import (
transports,
)
-from google.cloud.dialogflowcx_v3beta1.services.transition_route_groups.transports.base import (
- _API_CORE_VERSION,
-)
from google.cloud.dialogflowcx_v3beta1.services.transition_route_groups.transports.base import (
_GOOGLE_AUTH_VERSION,
)
@@ -60,8 +57,9 @@
import google.auth
-# TODO(busunkim): Once google-api-core >= 1.26.0 is required:
-# - Delete all the api-core and auth "less than" test cases
+# TODO(busunkim): Once google-auth >= 1.25.0 is required transitively
+# through google-api-core:
+# - Delete the auth "less than" test cases
# - Delete these pytest markers (Make the "greater than or equal to" tests the default).
requires_google_auth_lt_1_25_0 = pytest.mark.skipif(
packaging.version.parse(_GOOGLE_AUTH_VERSION) >= packaging.version.parse("1.25.0"),
@@ -72,16 +70,6 @@
reason="This test requires google-auth >= 1.25.0",
)
-requires_api_core_lt_1_26_0 = pytest.mark.skipif(
- packaging.version.parse(_API_CORE_VERSION) >= packaging.version.parse("1.26.0"),
- reason="This test requires google-api-core < 1.26.0",
-)
-
-requires_api_core_gte_1_26_0 = pytest.mark.skipif(
- packaging.version.parse(_API_CORE_VERSION) < packaging.version.parse("1.26.0"),
- reason="This test requires google-api-core >= 1.26.0",
-)
-
def client_cert_source_callback():
return b"cert bytes", b"key bytes"
@@ -145,6 +133,36 @@ def test_transition_route_groups_client_from_service_account_info(client_class):
assert client.transport._host == "dialogflow.googleapis.com:443"
+@pytest.mark.parametrize(
+ "client_class", [TransitionRouteGroupsClient, TransitionRouteGroupsAsyncClient,]
+)
+def test_transition_route_groups_client_service_account_always_use_jwt(client_class):
+ with mock.patch.object(
+ service_account.Credentials, "with_always_use_jwt_access", create=True
+ ) as use_jwt:
+ creds = service_account.Credentials(None, None, None)
+ client = client_class(credentials=creds)
+ use_jwt.assert_not_called()
+
+
+@pytest.mark.parametrize(
+ "transport_class,transport_name",
+ [
+ (transports.TransitionRouteGroupsGrpcTransport, "grpc"),
+ (transports.TransitionRouteGroupsGrpcAsyncIOTransport, "grpc_asyncio"),
+ ],
+)
+def test_transition_route_groups_client_service_account_always_use_jwt_true(
+ transport_class, transport_name
+):
+ with mock.patch.object(
+ service_account.Credentials, "with_always_use_jwt_access", create=True
+ ) as use_jwt:
+ creds = service_account.Credentials(None, None, None)
+ transport = transport_class(credentials=creds, always_use_jwt_access=True)
+ use_jwt.assert_called_once_with(True)
+
+
@pytest.mark.parametrize(
"client_class", [TransitionRouteGroupsClient, TransitionRouteGroupsAsyncClient,]
)
@@ -2166,7 +2184,6 @@ def test_transition_route_groups_transport_auth_adc_old_google_auth(transport_cl
(transports.TransitionRouteGroupsGrpcAsyncIOTransport, grpc_helpers_async),
],
)
-@requires_api_core_gte_1_26_0
def test_transition_route_groups_transport_create_channel(
transport_class, grpc_helpers
):
@@ -2200,82 +2217,6 @@ def test_transition_route_groups_transport_create_channel(
)
-@pytest.mark.parametrize(
- "transport_class,grpc_helpers",
- [
- (transports.TransitionRouteGroupsGrpcTransport, grpc_helpers),
- (transports.TransitionRouteGroupsGrpcAsyncIOTransport, grpc_helpers_async),
- ],
-)
-@requires_api_core_lt_1_26_0
-def test_transition_route_groups_transport_create_channel_old_api_core(
- transport_class, grpc_helpers
-):
- # If credentials and host are not provided, the transport class should use
- # ADC credentials.
- with mock.patch.object(
- google.auth, "default", autospec=True
- ) as adc, mock.patch.object(
- grpc_helpers, "create_channel", autospec=True
- ) as create_channel:
- creds = ga_credentials.AnonymousCredentials()
- adc.return_value = (creds, None)
- transport_class(quota_project_id="octopus")
-
- create_channel.assert_called_with(
- "dialogflow.googleapis.com:443",
- credentials=creds,
- credentials_file=None,
- quota_project_id="octopus",
- scopes=(
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/dialogflow",
- ),
- ssl_credentials=None,
- options=[
- ("grpc.max_send_message_length", -1),
- ("grpc.max_receive_message_length", -1),
- ],
- )
-
-
-@pytest.mark.parametrize(
- "transport_class,grpc_helpers",
- [
- (transports.TransitionRouteGroupsGrpcTransport, grpc_helpers),
- (transports.TransitionRouteGroupsGrpcAsyncIOTransport, grpc_helpers_async),
- ],
-)
-@requires_api_core_lt_1_26_0
-def test_transition_route_groups_transport_create_channel_user_scopes(
- transport_class, grpc_helpers
-):
- # If credentials and host are not provided, the transport class should use
- # ADC credentials.
- with mock.patch.object(
- google.auth, "default", autospec=True
- ) as adc, mock.patch.object(
- grpc_helpers, "create_channel", autospec=True
- ) as create_channel:
- creds = ga_credentials.AnonymousCredentials()
- adc.return_value = (creds, None)
-
- transport_class(quota_project_id="octopus", scopes=["1", "2"])
-
- create_channel.assert_called_with(
- "dialogflow.googleapis.com:443",
- credentials=creds,
- credentials_file=None,
- quota_project_id="octopus",
- scopes=["1", "2"],
- ssl_credentials=None,
- options=[
- ("grpc.max_send_message_length", -1),
- ("grpc.max_receive_message_length", -1),
- ],
- )
-
-
@pytest.mark.parametrize(
"transport_class",
[
@@ -2300,10 +2241,7 @@ def test_transition_route_groups_grpc_transport_client_cert_source_for_mtls(
"squid.clam.whelk:443",
credentials=cred,
credentials_file=None,
- scopes=(
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/dialogflow",
- ),
+ scopes=None,
ssl_credentials=mock_ssl_channel_creds,
quota_project_id=None,
options=[
@@ -2412,10 +2350,7 @@ def test_transition_route_groups_transport_channel_mtls_with_client_cert_source(
"mtls.squid.clam.whelk:443",
credentials=cred,
credentials_file=None,
- scopes=(
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/dialogflow",
- ),
+ scopes=None,
ssl_credentials=mock_ssl_cred,
quota_project_id=None,
options=[
@@ -2462,10 +2397,7 @@ def test_transition_route_groups_transport_channel_mtls_with_adc(transport_class
"mtls.squid.clam.whelk:443",
credentials=mock_cred,
credentials_file=None,
- scopes=(
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/dialogflow",
- ),
+ scopes=None,
ssl_credentials=mock_ssl_cred,
quota_project_id=None,
options=[
diff --git a/tests/unit/gapic/dialogflowcx_v3beta1/test_versions.py b/tests/unit/gapic/dialogflowcx_v3beta1/test_versions.py
index e23a6cf4..b4bf8802 100644
--- a/tests/unit/gapic/dialogflowcx_v3beta1/test_versions.py
+++ b/tests/unit/gapic/dialogflowcx_v3beta1/test_versions.py
@@ -38,9 +38,6 @@
from google.cloud.dialogflowcx_v3beta1.services.versions import VersionsClient
from google.cloud.dialogflowcx_v3beta1.services.versions import pagers
from google.cloud.dialogflowcx_v3beta1.services.versions import transports
-from google.cloud.dialogflowcx_v3beta1.services.versions.transports.base import (
- _API_CORE_VERSION,
-)
from google.cloud.dialogflowcx_v3beta1.services.versions.transports.base import (
_GOOGLE_AUTH_VERSION,
)
@@ -55,8 +52,9 @@
import google.auth
-# TODO(busunkim): Once google-api-core >= 1.26.0 is required:
-# - Delete all the api-core and auth "less than" test cases
+# TODO(busunkim): Once google-auth >= 1.25.0 is required transitively
+# through google-api-core:
+# - Delete the auth "less than" test cases
# - Delete these pytest markers (Make the "greater than or equal to" tests the default).
requires_google_auth_lt_1_25_0 = pytest.mark.skipif(
packaging.version.parse(_GOOGLE_AUTH_VERSION) >= packaging.version.parse("1.25.0"),
@@ -67,16 +65,6 @@
reason="This test requires google-auth >= 1.25.0",
)
-requires_api_core_lt_1_26_0 = pytest.mark.skipif(
- packaging.version.parse(_API_CORE_VERSION) >= packaging.version.parse("1.26.0"),
- reason="This test requires google-api-core < 1.26.0",
-)
-
-requires_api_core_gte_1_26_0 = pytest.mark.skipif(
- packaging.version.parse(_API_CORE_VERSION) < packaging.version.parse("1.26.0"),
- reason="This test requires google-api-core >= 1.26.0",
-)
-
def client_cert_source_callback():
return b"cert bytes", b"key bytes"
@@ -132,6 +120,34 @@ def test_versions_client_from_service_account_info(client_class):
assert client.transport._host == "dialogflow.googleapis.com:443"
+@pytest.mark.parametrize("client_class", [VersionsClient, VersionsAsyncClient,])
+def test_versions_client_service_account_always_use_jwt(client_class):
+ with mock.patch.object(
+ service_account.Credentials, "with_always_use_jwt_access", create=True
+ ) as use_jwt:
+ creds = service_account.Credentials(None, None, None)
+ client = client_class(credentials=creds)
+ use_jwt.assert_not_called()
+
+
+@pytest.mark.parametrize(
+ "transport_class,transport_name",
+ [
+ (transports.VersionsGrpcTransport, "grpc"),
+ (transports.VersionsGrpcAsyncIOTransport, "grpc_asyncio"),
+ ],
+)
+def test_versions_client_service_account_always_use_jwt_true(
+ transport_class, transport_name
+):
+ with mock.patch.object(
+ service_account.Credentials, "with_always_use_jwt_access", create=True
+ ) as use_jwt:
+ creds = service_account.Credentials(None, None, None)
+ transport = transport_class(credentials=creds, always_use_jwt_access=True)
+ use_jwt.assert_called_once_with(True)
+
+
@pytest.mark.parametrize("client_class", [VersionsClient, VersionsAsyncClient,])
def test_versions_client_from_service_account_file(client_class):
creds = ga_credentials.AnonymousCredentials()
@@ -2037,7 +2053,6 @@ def test_versions_transport_auth_adc_old_google_auth(transport_class):
(transports.VersionsGrpcAsyncIOTransport, grpc_helpers_async),
],
)
-@requires_api_core_gte_1_26_0
def test_versions_transport_create_channel(transport_class, grpc_helpers):
# If credentials and host are not provided, the transport class should use
# ADC credentials.
@@ -2069,78 +2084,6 @@ def test_versions_transport_create_channel(transport_class, grpc_helpers):
)
-@pytest.mark.parametrize(
- "transport_class,grpc_helpers",
- [
- (transports.VersionsGrpcTransport, grpc_helpers),
- (transports.VersionsGrpcAsyncIOTransport, grpc_helpers_async),
- ],
-)
-@requires_api_core_lt_1_26_0
-def test_versions_transport_create_channel_old_api_core(transport_class, grpc_helpers):
- # If credentials and host are not provided, the transport class should use
- # ADC credentials.
- with mock.patch.object(
- google.auth, "default", autospec=True
- ) as adc, mock.patch.object(
- grpc_helpers, "create_channel", autospec=True
- ) as create_channel:
- creds = ga_credentials.AnonymousCredentials()
- adc.return_value = (creds, None)
- transport_class(quota_project_id="octopus")
-
- create_channel.assert_called_with(
- "dialogflow.googleapis.com:443",
- credentials=creds,
- credentials_file=None,
- quota_project_id="octopus",
- scopes=(
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/dialogflow",
- ),
- ssl_credentials=None,
- options=[
- ("grpc.max_send_message_length", -1),
- ("grpc.max_receive_message_length", -1),
- ],
- )
-
-
-@pytest.mark.parametrize(
- "transport_class,grpc_helpers",
- [
- (transports.VersionsGrpcTransport, grpc_helpers),
- (transports.VersionsGrpcAsyncIOTransport, grpc_helpers_async),
- ],
-)
-@requires_api_core_lt_1_26_0
-def test_versions_transport_create_channel_user_scopes(transport_class, grpc_helpers):
- # If credentials and host are not provided, the transport class should use
- # ADC credentials.
- with mock.patch.object(
- google.auth, "default", autospec=True
- ) as adc, mock.patch.object(
- grpc_helpers, "create_channel", autospec=True
- ) as create_channel:
- creds = ga_credentials.AnonymousCredentials()
- adc.return_value = (creds, None)
-
- transport_class(quota_project_id="octopus", scopes=["1", "2"])
-
- create_channel.assert_called_with(
- "dialogflow.googleapis.com:443",
- credentials=creds,
- credentials_file=None,
- quota_project_id="octopus",
- scopes=["1", "2"],
- ssl_credentials=None,
- options=[
- ("grpc.max_send_message_length", -1),
- ("grpc.max_receive_message_length", -1),
- ],
- )
-
-
@pytest.mark.parametrize(
"transport_class",
[transports.VersionsGrpcTransport, transports.VersionsGrpcAsyncIOTransport],
@@ -2160,10 +2103,7 @@ def test_versions_grpc_transport_client_cert_source_for_mtls(transport_class):
"squid.clam.whelk:443",
credentials=cred,
credentials_file=None,
- scopes=(
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/dialogflow",
- ),
+ scopes=None,
ssl_credentials=mock_ssl_channel_creds,
quota_project_id=None,
options=[
@@ -2267,10 +2207,7 @@ def test_versions_transport_channel_mtls_with_client_cert_source(transport_class
"mtls.squid.clam.whelk:443",
credentials=cred,
credentials_file=None,
- scopes=(
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/dialogflow",
- ),
+ scopes=None,
ssl_credentials=mock_ssl_cred,
quota_project_id=None,
options=[
@@ -2314,10 +2251,7 @@ def test_versions_transport_channel_mtls_with_adc(transport_class):
"mtls.squid.clam.whelk:443",
credentials=mock_cred,
credentials_file=None,
- scopes=(
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/dialogflow",
- ),
+ scopes=None,
ssl_credentials=mock_ssl_cred,
quota_project_id=None,
options=[
diff --git a/tests/unit/gapic/dialogflowcx_v3beta1/test_webhooks.py b/tests/unit/gapic/dialogflowcx_v3beta1/test_webhooks.py
index 54676cb7..bf2a5940 100644
--- a/tests/unit/gapic/dialogflowcx_v3beta1/test_webhooks.py
+++ b/tests/unit/gapic/dialogflowcx_v3beta1/test_webhooks.py
@@ -35,9 +35,6 @@
from google.cloud.dialogflowcx_v3beta1.services.webhooks import WebhooksClient
from google.cloud.dialogflowcx_v3beta1.services.webhooks import pagers
from google.cloud.dialogflowcx_v3beta1.services.webhooks import transports
-from google.cloud.dialogflowcx_v3beta1.services.webhooks.transports.base import (
- _API_CORE_VERSION,
-)
from google.cloud.dialogflowcx_v3beta1.services.webhooks.transports.base import (
_GOOGLE_AUTH_VERSION,
)
@@ -49,8 +46,9 @@
import google.auth
-# TODO(busunkim): Once google-api-core >= 1.26.0 is required:
-# - Delete all the api-core and auth "less than" test cases
+# TODO(busunkim): Once google-auth >= 1.25.0 is required transitively
+# through google-api-core:
+# - Delete the auth "less than" test cases
# - Delete these pytest markers (Make the "greater than or equal to" tests the default).
requires_google_auth_lt_1_25_0 = pytest.mark.skipif(
packaging.version.parse(_GOOGLE_AUTH_VERSION) >= packaging.version.parse("1.25.0"),
@@ -61,16 +59,6 @@
reason="This test requires google-auth >= 1.25.0",
)
-requires_api_core_lt_1_26_0 = pytest.mark.skipif(
- packaging.version.parse(_API_CORE_VERSION) >= packaging.version.parse("1.26.0"),
- reason="This test requires google-api-core < 1.26.0",
-)
-
-requires_api_core_gte_1_26_0 = pytest.mark.skipif(
- packaging.version.parse(_API_CORE_VERSION) < packaging.version.parse("1.26.0"),
- reason="This test requires google-api-core >= 1.26.0",
-)
-
def client_cert_source_callback():
return b"cert bytes", b"key bytes"
@@ -126,6 +114,34 @@ def test_webhooks_client_from_service_account_info(client_class):
assert client.transport._host == "dialogflow.googleapis.com:443"
+@pytest.mark.parametrize("client_class", [WebhooksClient, WebhooksAsyncClient,])
+def test_webhooks_client_service_account_always_use_jwt(client_class):
+ with mock.patch.object(
+ service_account.Credentials, "with_always_use_jwt_access", create=True
+ ) as use_jwt:
+ creds = service_account.Credentials(None, None, None)
+ client = client_class(credentials=creds)
+ use_jwt.assert_not_called()
+
+
+@pytest.mark.parametrize(
+ "transport_class,transport_name",
+ [
+ (transports.WebhooksGrpcTransport, "grpc"),
+ (transports.WebhooksGrpcAsyncIOTransport, "grpc_asyncio"),
+ ],
+)
+def test_webhooks_client_service_account_always_use_jwt_true(
+ transport_class, transport_name
+):
+ with mock.patch.object(
+ service_account.Credentials, "with_always_use_jwt_access", create=True
+ ) as use_jwt:
+ creds = service_account.Credentials(None, None, None)
+ transport = transport_class(credentials=creds, always_use_jwt_access=True)
+ use_jwt.assert_called_once_with(True)
+
+
@pytest.mark.parametrize("client_class", [WebhooksClient, WebhooksAsyncClient,])
def test_webhooks_client_from_service_account_file(client_class):
creds = ga_credentials.AnonymousCredentials()
@@ -1836,7 +1852,6 @@ def test_webhooks_transport_auth_adc_old_google_auth(transport_class):
(transports.WebhooksGrpcAsyncIOTransport, grpc_helpers_async),
],
)
-@requires_api_core_gte_1_26_0
def test_webhooks_transport_create_channel(transport_class, grpc_helpers):
# If credentials and host are not provided, the transport class should use
# ADC credentials.
@@ -1868,78 +1883,6 @@ def test_webhooks_transport_create_channel(transport_class, grpc_helpers):
)
-@pytest.mark.parametrize(
- "transport_class,grpc_helpers",
- [
- (transports.WebhooksGrpcTransport, grpc_helpers),
- (transports.WebhooksGrpcAsyncIOTransport, grpc_helpers_async),
- ],
-)
-@requires_api_core_lt_1_26_0
-def test_webhooks_transport_create_channel_old_api_core(transport_class, grpc_helpers):
- # If credentials and host are not provided, the transport class should use
- # ADC credentials.
- with mock.patch.object(
- google.auth, "default", autospec=True
- ) as adc, mock.patch.object(
- grpc_helpers, "create_channel", autospec=True
- ) as create_channel:
- creds = ga_credentials.AnonymousCredentials()
- adc.return_value = (creds, None)
- transport_class(quota_project_id="octopus")
-
- create_channel.assert_called_with(
- "dialogflow.googleapis.com:443",
- credentials=creds,
- credentials_file=None,
- quota_project_id="octopus",
- scopes=(
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/dialogflow",
- ),
- ssl_credentials=None,
- options=[
- ("grpc.max_send_message_length", -1),
- ("grpc.max_receive_message_length", -1),
- ],
- )
-
-
-@pytest.mark.parametrize(
- "transport_class,grpc_helpers",
- [
- (transports.WebhooksGrpcTransport, grpc_helpers),
- (transports.WebhooksGrpcAsyncIOTransport, grpc_helpers_async),
- ],
-)
-@requires_api_core_lt_1_26_0
-def test_webhooks_transport_create_channel_user_scopes(transport_class, grpc_helpers):
- # If credentials and host are not provided, the transport class should use
- # ADC credentials.
- with mock.patch.object(
- google.auth, "default", autospec=True
- ) as adc, mock.patch.object(
- grpc_helpers, "create_channel", autospec=True
- ) as create_channel:
- creds = ga_credentials.AnonymousCredentials()
- adc.return_value = (creds, None)
-
- transport_class(quota_project_id="octopus", scopes=["1", "2"])
-
- create_channel.assert_called_with(
- "dialogflow.googleapis.com:443",
- credentials=creds,
- credentials_file=None,
- quota_project_id="octopus",
- scopes=["1", "2"],
- ssl_credentials=None,
- options=[
- ("grpc.max_send_message_length", -1),
- ("grpc.max_receive_message_length", -1),
- ],
- )
-
-
@pytest.mark.parametrize(
"transport_class",
[transports.WebhooksGrpcTransport, transports.WebhooksGrpcAsyncIOTransport],
@@ -1959,10 +1902,7 @@ def test_webhooks_grpc_transport_client_cert_source_for_mtls(transport_class):
"squid.clam.whelk:443",
credentials=cred,
credentials_file=None,
- scopes=(
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/dialogflow",
- ),
+ scopes=None,
ssl_credentials=mock_ssl_channel_creds,
quota_project_id=None,
options=[
@@ -2066,10 +2006,7 @@ def test_webhooks_transport_channel_mtls_with_client_cert_source(transport_class
"mtls.squid.clam.whelk:443",
credentials=cred,
credentials_file=None,
- scopes=(
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/dialogflow",
- ),
+ scopes=None,
ssl_credentials=mock_ssl_cred,
quota_project_id=None,
options=[
@@ -2113,10 +2050,7 @@ def test_webhooks_transport_channel_mtls_with_adc(transport_class):
"mtls.squid.clam.whelk:443",
credentials=mock_cred,
credentials_file=None,
- scopes=(
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/dialogflow",
- ),
+ scopes=None,
ssl_credentials=mock_ssl_cred,
quota_project_id=None,
options=[